@vellumai/web 0.12.2-dev.202609170044.9cbb729 → 0.12.2-dev.202609170127.2eef54c

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 (200) hide show
  1. package/dist/assets/{a2a-invite-CPOepgSQ.js → a2a-invite-CGyWwrVb.js} +1 -1
  2. package/dist/assets/{about-page-mvJO6yza.js → about-page-CpXKAK5Z.js} +1 -1
  3. package/dist/assets/{account-page-yyir0M2y.js → account-page-cpDusq21.js} +1 -1
  4. package/dist/assets/{account-shell-B5314FtI.js → account-shell-D1_mSHj9.js} +1 -1
  5. package/dist/assets/{acp-run-detail-panel-BYr2gH9F.js → acp-run-detail-panel-D_bA-uwm.js} +1 -1
  6. package/dist/assets/{activation-list-route-dhx_UhFW.js → activation-list-route-_x10pg_q.js} +1 -1
  7. package/dist/assets/{activity-redirect-page-Cyo877Rg.js → activity-redirect-page-CLc8hSfC.js} +1 -1
  8. package/dist/assets/{activity-steps-panel-DKg15Oc4.js → activity-steps-panel-YPKDTvLp.js} +1 -1
  9. package/dist/assets/{add-credits-modal-CzpgEkT9.js → add-credits-modal-CXIeeHpM.js} +1 -1
  10. package/dist/assets/add-credits-modal-Lw_orElQ.js +1 -0
  11. package/dist/assets/{ai-page-CBX1v1tS.js → ai-page-532485Rg.js} +1 -1
  12. package/dist/assets/{android-billing-handoff-CWqhP_0I.js → android-billing-handoff-BjLOXHzL.js} +1 -1
  13. package/dist/assets/{api-key-screen-DKzLIFst.js → api-key-screen-DBRohhxk.js} +1 -1
  14. package/dist/assets/{app-BffxeWB8.js → app-Bevxq2OH.js} +13 -13
  15. package/dist/assets/{app-info-DsEx-jq_.js → app-info-CLe39i6W.js} +1 -1
  16. package/dist/assets/{archive-redirect-page-BK_dY4v-.js → archive-redirect-page-CrqrZE0I.js} +1 -1
  17. package/dist/assets/{assistant-status-panel-BSioaCpK.js → assistant-status-panel-D0GMw4-F.js} +1 -1
  18. package/dist/assets/auth-store-CpWb7YyB.js +1 -0
  19. package/dist/assets/{auth-welcome-screen-LyL7WDL8.js → auth-welcome-screen-DqyGTmht.js} +1 -1
  20. package/dist/assets/avatar-bundled-components-Dg1tq-xF.js +1 -0
  21. package/dist/assets/{avatar-random-DIn9GmRk.js → avatar-random-Bg-JtW3h.js} +2 -2
  22. package/dist/assets/{await-org-header-settled-DNIo8_Tf.js → await-org-header-settled-CPTObvNn.js} +1 -1
  23. package/dist/assets/{background-task-detail-panel-HleNtRAe.js → background-task-detail-panel-BVlprJsr.js} +1 -1
  24. package/dist/assets/{billing-page-DbEVS2q_.js → billing-page-7AqrZkVw.js} +3 -3
  25. package/dist/assets/{billing-redirect-page-CdcCmEUc.js → billing-redirect-page-CBdGeWQH.js} +1 -1
  26. package/dist/assets/{bookmarks-page-CUi4LhrR.js → bookmarks-page-BlaJ96ej.js} +1 -1
  27. package/dist/assets/{bundle-confirm-page-Tz6RPE2c.js → bundle-confirm-page-C-nGTAWg.js} +1 -1
  28. package/dist/assets/{channel-transcript-panel-gPgCvcoI.js → channel-transcript-panel-C8sNJBUg.js} +1 -1
  29. package/dist/assets/{channels-page-route-D8adodpU.js → channels-page-route-Ccf07m7d.js} +1 -1
  30. package/dist/assets/{chat-info-panel-jeK_s1xx.js → chat-info-panel-Dc7yOSba.js} +1 -1
  31. package/dist/assets/{checkout-continuation-BJuTfVL4.js → checkout-continuation-DndPlOQH.js} +1 -1
  32. package/dist/assets/{checkout-page-BEB-CumM.js → checkout-page-BubQ6HKx.js} +1 -1
  33. package/dist/assets/checkout-return-target-UI7zqK_V.js +1 -0
  34. package/dist/assets/command-palette-C1EnF4gm.js +1 -0
  35. package/dist/assets/{command-palette-CWDqjKuB.js → command-palette-CMP9k9JI.js} +1 -1
  36. package/dist/assets/{command-palette-window-page-C0OorhM_.js → command-palette-window-page-BiTxCLMC.js} +1 -1
  37. package/dist/assets/{community-page-Dp56nq4K.js → community-page-BnK8lv_7.js} +1 -1
  38. package/dist/assets/{companion-accent-BkhXA9n8.js → companion-accent-Cw1QrON6.js} +1 -1
  39. package/dist/assets/{companion-dock-zones-page-BiaNWu9U.js → companion-dock-zones-page-BDH8JnN-.js} +1 -1
  40. package/dist/assets/{companion-layout-CPz7l-4W.js → companion-layout-DY7WNHKB.js} +1 -1
  41. package/dist/assets/{companion-popover-Wr9gfDIe.js → companion-popover-CrjiSDbu.js} +1 -1
  42. package/dist/assets/{companion-popover-page-PVlrSn4w.js → companion-popover-page-CySPinox.js} +1 -1
  43. package/dist/assets/{companion-surface-page-Dp_CShHP.js → companion-surface-page-BOo03Cql.js} +1 -1
  44. package/dist/assets/{companion-watch-frame-page-CVY57Wpn.js → companion-watch-frame-page-D0gmPDdg.js} +1 -1
  45. package/dist/assets/{connect-page-BSje-9ym.js → connect-page-ASh20AlX.js} +1 -1
  46. package/dist/assets/{consent-controls-Bz_IOnmZ.js → consent-controls-CEkwbqJw.js} +1 -1
  47. package/dist/assets/{contacts-gateway-CY5vUfM2.js → contacts-gateway-BFbyNbl_.js} +1 -1
  48. package/dist/assets/{contacts-page-route-JRYP87zz.js → contacts-page-route-Dq0E2ER7.js} +1 -1
  49. package/dist/assets/{copy-button-BuISIxU2.js → copy-button-CpRMm23v.js} +1 -1
  50. package/dist/assets/{credential-entry-page-D2GsP2g5.js → credential-entry-page-7W319fSF.js} +1 -1
  51. package/dist/assets/{credentials-page-B2B50A98.js → credentials-page-CZjpoj-1.js} +1 -1
  52. package/dist/assets/{csv-preview--DFbpKhn.js → csv-preview-BntRaLY3.js} +1 -1
  53. package/dist/assets/{danger-zone-redirect-page-BizWd5Ru.js → danger-zone-redirect-page-BIJ7iH3z.js} +1 -1
  54. package/dist/assets/{debug-page-C5iUTBcy.js → debug-page-5TIa2DWf.js} +1 -1
  55. package/dist/assets/{deploy-dialogs-Cb2DGIT-.js → deploy-dialogs-6ed2FkO5.js} +1 -1
  56. package/dist/assets/deploy-dialogs-Gj5nNCwe.js +1 -0
  57. package/dist/assets/{desktop-preview-content-C-2TO84E.js → desktop-preview-content-C8-eBvWs.js} +2 -2
  58. package/dist/assets/{desktop-status-Cq9tSoVe.js → desktop-status-Bb9_j80h.js} +1 -1
  59. package/dist/assets/{desktop-viewer-BFoFR7Sg.js → desktop-viewer-B1LngIwF.js} +1 -1
  60. package/dist/assets/{detail-card-B3_bSihf.js → detail-card-BwHvhGMs.js} +1 -1
  61. package/dist/assets/{detail-panel-stop-button-DOTn90Cm.js → detail-panel-stop-button-CeSH5ncG.js} +1 -1
  62. package/dist/assets/{detail-primitives-Bc5PDjkl.js → detail-primitives-DscaN9rD.js} +1 -1
  63. package/dist/assets/{developer-page-CWg9QzIf.js → developer-page-BAPxl51t.js} +1 -1
  64. package/dist/assets/{devices-redirect-page-c67PRqw0.js → devices-redirect-page-CL5kygqy.js} +1 -1
  65. package/dist/assets/{dictation-overlay-page-UYCz2T3V.js → dictation-overlay-page-CqBYNqCX.js} +1 -1
  66. package/dist/assets/{document-load-DHCCLogD.js → document-load-D6zwCeMh.js} +1 -1
  67. package/dist/assets/document-load-DwJmiaST.js +1 -0
  68. package/dist/assets/{document-viewer-page-ClJvwnU-.js → document-viewer-page-CgUpLtrR.js} +1 -1
  69. package/dist/assets/{emails-page-2ou2eAkW.js → emails-page-B3KXvdQh.js} +1 -1
  70. package/dist/assets/{environment-store-Dka2FZhs.js → environment-store-gXJzyQ9n.js} +1 -1
  71. package/dist/assets/{file-diff-view-BmdOQaeZ.js → file-diff-view-gj5qz7ac.js} +1 -1
  72. package/dist/assets/{file-editor--nn3ZR0r.js → file-editor-yxcARNDB.js} +1 -1
  73. package/dist/assets/{general-page-uvMmHHyl.js → general-page-Be2OEMQv.js} +1 -1
  74. package/dist/assets/{hatching-screen-C5Hdkxta.js → hatching-screen-Os08fIB7.js} +1 -1
  75. package/dist/assets/{hosting-screen-D3yRf7Vz.js → hosting-screen-KGS2hNnI.js} +1 -1
  76. package/dist/assets/{identity-page-route-CBystW_n.js → identity-page-route-CcWEsb73.js} +1 -1
  77. package/dist/assets/{inspect-page-VMZxgoOP.js → inspect-page-BqwGgtCg.js} +3 -3
  78. package/dist/assets/{integrations-page-_YxXV8LC.js → integrations-page-DxXjeCOU.js} +1 -1
  79. package/dist/assets/{intelligence-layout-COHWei3O.js → intelligence-layout-0GHP1abK.js} +1 -1
  80. package/dist/assets/intelligence-layout-slots-store-DO8r8MbX.js +1 -0
  81. package/dist/assets/{keyboard-shortcuts-redirect-page-CkO8sqRv.js → keyboard-shortcuts-redirect-page-D8Sd0awe.js} +1 -1
  82. package/dist/assets/{latest-assistant-text-px--r87U.js → latest-assistant-text-CFfTfLEE.js} +1 -1
  83. package/dist/assets/{library-detail-page-BROUcqvW.js → library-detail-page-hchQ6i_Z.js} +1 -1
  84. package/dist/assets/{library-page-D8lvqAnn.js → library-page-DCcuCaVz.js} +1 -1
  85. package/dist/assets/local-mode-BF0BHVrs.js +1 -0
  86. package/dist/assets/{login-page-KwB7QV63.js → login-page-CFu2kSt0.js} +1 -1
  87. package/dist/assets/{logout-page-BS_b3wIp.js → logout-page-TdBoJnoW.js} +1 -1
  88. package/dist/assets/{logs-layout-3574H70Q.js → logs-layout-CB0oUcCN.js} +1 -1
  89. package/dist/assets/{markdown-preview-BQBD4nZl.js → markdown-preview-DFx6LTIB.js} +1 -1
  90. package/dist/assets/{media-preview-B8dzo6SD.js → media-preview-s9zPdEVg.js} +1 -1
  91. package/dist/assets/{memory-page-route-lL9WqSlP.js → memory-page-route-BfiwTjz6.js} +1 -1
  92. package/dist/assets/{memory-router-playground-page-Xn90HoK0.js → memory-router-playground-page-BMqYc2PM.js} +1 -1
  93. package/dist/assets/{message-files-panel-BLVYF2bR.js → message-files-panel-DFgNQOkk.js} +1 -1
  94. package/dist/assets/{metric-card-qtWiXfjv.js → metric-card-Cp9VXC7R.js} +1 -1
  95. package/dist/assets/native-attachment-pickers-Da2NEx1r.js +1 -0
  96. package/dist/assets/native-file-BE23yEsJ.js +1 -0
  97. package/dist/assets/{notifications-page-Butll45i.js → notifications-page-B9YszO_J.js} +1 -1
  98. package/dist/assets/{oauth-complete-page-CEcHbwIV.js → oauth-complete-page-BNh9-xUX.js} +1 -1
  99. package/dist/assets/{oauth-popup-complete-page-D3zQC3el.js → oauth-popup-complete-page-IDBMA6bj.js} +1 -1
  100. package/dist/assets/paired-platform-identity-CV09bF6L.js +1 -0
  101. package/dist/assets/{pairing-page-BfAzRCkh.js → pairing-page-BiagkAmV.js} +1 -1
  102. package/dist/assets/password-reset-page-BnC4ZtAH.js +1 -0
  103. package/dist/assets/{pdf-file-preview-BNNzH1Lj.js → pdf-file-preview-DyZKuW6K.js} +1 -1
  104. package/dist/assets/{personality-page-pYkfDoiT.js → personality-page-CaVp-IFA.js} +1 -1
  105. package/dist/assets/{personality-page-C9g8m-ZV.js → personality-page-D9S6ceuR.js} +1 -1
  106. package/dist/assets/{personality-sliders-vC7qRQZ4.js → personality-sliders-B8XJXHql.js} +1 -1
  107. package/dist/assets/{plans-page-Cqz11rXC.js → plans-page-COqIWjjU.js} +1 -1
  108. package/dist/assets/{platform-loopback-page-zI5kt-1B.js → platform-loopback-page-Be6zZTjk.js} +1 -1
  109. package/dist/assets/{plugin-detail-page-BVUJF_Z0.js → plugin-detail-page-B7rDYqFA.js} +1 -1
  110. package/dist/assets/{plugins-page-grMYw6ca.js → plugins-page-CLR2LTmD.js} +1 -1
  111. package/dist/assets/plugins-surface-DV2Ze-pt.js +1 -0
  112. package/dist/assets/{preview-error-DAI-w4oR.js → preview-error-BJZmVu5_.js} +1 -1
  113. package/dist/assets/{privacy-page-CkYCyPUl.js → privacy-page-DoWHQiAM.js} +1 -1
  114. package/dist/assets/{privacy-screen-C8KSanLw.js → privacy-screen-CqHYvdcC.js} +1 -1
  115. package/dist/assets/{provider-callback-page-CaXQeoGc.js → provider-callback-page-CoDo_LGa.js} +1 -1
  116. package/dist/assets/{provider-key-CMRKdOp6.js → provider-key-CdT-QLy6.js} +1 -1
  117. package/dist/assets/{provider-signup-page-pmWAHHvg.js → provider-signup-page-BqLSsqmz.js} +1 -1
  118. package/dist/assets/{quick-input-page-D2Ps4Nn9.js → quick-input-page-DNQrrRym.js} +1 -1
  119. package/dist/assets/referral-modal-Cb9yHvB_.js +1 -0
  120. package/dist/assets/{referral-modal-T0tz9cKz.js → referral-modal-Cxu42QEQ.js} +1 -1
  121. package/dist/assets/{research-mock-page-C2hO1AJp.js → research-mock-page-BGxSDObT.js} +1 -1
  122. package/dist/assets/{research-onboarding-route-YUY_VAoR.js → research-onboarding-route-DIsnSqMQ.js} +1 -1
  123. package/dist/assets/{review-terms-screen-ClCuevTT.js → review-terms-screen-DO7ygsE4.js} +1 -1
  124. package/dist/assets/routes-CBqv5JWO.js +1 -0
  125. package/dist/assets/{schedules-C4v6G4Yl.js → schedules-BVvKpKi_.js} +1 -1
  126. package/dist/assets/{schedules-page-BEE6gG-0.js → schedules-page-DMg82o_w.js} +1 -1
  127. package/dist/assets/{security-redirect-page-CfHdAiGm.js → security-redirect-page-Dt9NUQpQ.js} +1 -1
  128. package/dist/assets/{select-assistant-screen-uEMd-mms.js → select-assistant-screen-C_lmPTkj.js} +1 -1
  129. package/dist/assets/{self-hosted-servers-qDFPnEcM.js → self-hosted-servers-rVknxhh5.js} +1 -1
  130. package/dist/assets/{service-form-controls-DTOMkj0Y.js → service-form-controls-Dtw6VZjE.js} +1 -1
  131. package/dist/assets/{setting-row-snAhMVc8.js → setting-row-Dl37RqUe.js} +1 -1
  132. package/dist/assets/{settings-divider-DAr-iUO3.js → settings-divider-CqLEhf9T.js} +1 -1
  133. package/dist/assets/{settings-layout-iM3mkXFz.js → settings-layout-g2w2BcMj.js} +1 -1
  134. package/dist/assets/share-feedback-modal-Cw4b0uTf.js +1 -0
  135. package/dist/assets/{share-feedback-modal-BkIQkrgI.js → share-feedback-modal-DQOqrbac.js} +1 -1
  136. package/dist/assets/{sidebar-tree-Ar6vYFqW.js → sidebar-tree-AAmgDds0.js} +1 -1
  137. package/dist/assets/{signup-page-DP1R2EYG.js → signup-page-Bo3kV3uI.js} +1 -1
  138. package/dist/assets/{signup-shell-DDOwFm8f.js → signup-shell-BFlnJZeT.js} +1 -1
  139. package/dist/assets/{skill-detail-page-tlOn1SgY.js → skill-detail-page-D3aEzdPR.js} +1 -1
  140. package/dist/assets/{skill-detail-panel-BT-gwhZC.js → skill-detail-panel-p4BBQO99.js} +1 -1
  141. package/dist/assets/{skill-removal-dialog-BKxKHM93.js → skill-removal-dialog-DDrOdXOm.js} +1 -1
  142. package/dist/assets/{skills-page-CNDvB7S4.js → skills-page-C6d2b4U2.js} +1 -1
  143. package/dist/assets/{sounds-page-CB-BYrIs.js → sounds-page-DcDVb904.js} +1 -1
  144. package/dist/assets/{start-screen-TdesbZb_.js → start-screen-xNv_UqZY.js} +1 -1
  145. package/dist/assets/{stt-language-picker-modal-DPCuG3ZL.js → stt-language-picker-modal-ClWhCUb4.js} +1 -1
  146. package/dist/assets/{subagent-detail-panel-CZ80KyIm.js → subagent-detail-panel-Br1VLPKI.js} +1 -1
  147. package/dist/assets/{superpowers-page-CWF29nBb.js → superpowers-page-4mJC8gCY.js} +1 -1
  148. package/dist/assets/{system-events-page-1v0djQRa.js → system-events-page-BxTLnX53.js} +1 -1
  149. package/dist/assets/{system-events-redirect-page-H4jpP5pT.js → system-events-redirect-page-sTK7jdID.js} +1 -1
  150. package/dist/assets/{text-preview-DSjmL18D.js → text-preview-ByPfVkyx.js} +1 -1
  151. package/dist/assets/{theme-stage-page-DW2rC9j9.js → theme-stage-page-BUDy_3aW.js} +1 -1
  152. package/dist/assets/{tiptap-document-editor-nrxutBtH.js → tiptap-document-editor-D0xp5ZOs.js} +1 -1
  153. package/dist/assets/tool-detail-panel-DkIHPygu.js +1 -0
  154. package/dist/assets/tool-detail-panel-aNvOK4DH.js +15 -0
  155. package/dist/assets/{trait-cycle-row-BSA19j9_.js → trait-cycle-row-DxnV3-Yt.js} +1 -1
  156. package/dist/assets/{upgrade-cancel-page-DTHemN5k.js → upgrade-cancel-page-C30oAeVw.js} +1 -1
  157. package/dist/assets/{upgrade-success-page-CIFrIxM0.js → upgrade-success-page-oW6vbrAs.js} +1 -1
  158. package/dist/assets/{usage-redirect-page-Cq63trs2.js → usage-redirect-page-CgUD4SND.js} +1 -1
  159. package/dist/assets/{use-app-delete-BE_RhdkC.js → use-app-delete-CKSNRj2W.js} +1 -1
  160. package/dist/assets/{use-assistant-identity-details-CrtLW4Dl.js → use-assistant-identity-details-V-aHH_Fd.js} +1 -1
  161. package/dist/assets/{use-checkout-dismiss-refresh-Ch1dFcBe.js → use-checkout-dismiss-refresh-3vETASUz.js} +1 -1
  162. package/dist/assets/{use-edge-swipe-back-DCbPXF6z.js → use-edge-swipe-back-iYvf5Z3Y.js} +1 -1
  163. package/dist/assets/{use-hotkey-recorder-v5Akb2eM.js → use-hotkey-recorder-D_xoveSa.js} +1 -1
  164. package/dist/assets/{use-invite-link-dialog-BWou3cIT.js → use-invite-link-dialog-BmO2UW56.js} +1 -1
  165. package/dist/assets/{use-platform-assistant-id-eSCNuEeV.js → use-platform-assistant-id-B2zxeseH.js} +1 -1
  166. package/dist/assets/{use-plugins-list-BeN4VoGr.js → use-plugins-list-B2RZk-mQ.js} +1 -1
  167. package/dist/assets/{use-return-to-short-circuit-sIhAEoPs.js → use-return-to-short-circuit-DmEpr1I6.js} +1 -1
  168. package/dist/assets/{use-side-list-room-DKS_urYu.js → use-side-list-room-Bzn8D2aH.js} +1 -1
  169. package/dist/assets/{use-skill-actions-VsDYLi1F.js → use-skill-actions-D8xWO_74.js} +1 -1
  170. package/dist/assets/{use-skill-detail-files-4oFtcDS1.js → use-skill-detail-files-tb5cSgGr.js} +1 -1
  171. package/dist/assets/use-supports-credentials-settings-D7VgTBHl.js +1 -0
  172. package/dist/assets/{use-transcript-message-by-id-DAnqm2sU.js → use-transcript-message-by-id-CUhOzUVt.js} +1 -1
  173. package/dist/assets/{voice-page-ZM6m4a6g.js → voice-page-V5DTtBCx.js} +1 -1
  174. package/dist/assets/{wake-detail-panel-DDiMpVwh.js → wake-detail-panel-CwGS3ebR.js} +1 -1
  175. package/dist/assets/{weather-forecast-display-BidX04za.js → weather-forecast-display-Cy7gAmUS.js} +1 -1
  176. package/dist/assets/{welcome-screen-BLO3HSl6.js → welcome-screen-CsDlUcyv.js} +1 -1
  177. package/dist/assets/{workflow-detail-panel-DoYNc1Sc.js → workflow-detail-panel-BoCJgSNC.js} +1 -1
  178. package/dist/assets/{workspace-page-CBkUkz3A.js → workspace-page-ch8vZBtm.js} +1 -1
  179. package/dist/index.html +1 -1
  180. package/package.json +1 -1
  181. package/dist/assets/add-credits-modal-3J4yC3LM.js +0 -1
  182. package/dist/assets/auth-store-BPEP8tVJ.js +0 -1
  183. package/dist/assets/avatar-bundled-components-B9pE82_X.js +0 -1
  184. package/dist/assets/checkout-return-target-Be4ZEj1n.js +0 -1
  185. package/dist/assets/command-palette-Qu5B2KQE.js +0 -1
  186. package/dist/assets/deploy-dialogs-X-N6_uqc.js +0 -1
  187. package/dist/assets/document-load-Cr8Ud-va.js +0 -1
  188. package/dist/assets/intelligence-layout-slots-store-BmRlMDFx.js +0 -1
  189. package/dist/assets/local-mode-CBsNlz7d.js +0 -1
  190. package/dist/assets/native-attachment-pickers-CtYddiW_.js +0 -1
  191. package/dist/assets/native-file-D3F1srNM.js +0 -1
  192. package/dist/assets/paired-platform-identity-B0dB5CoX.js +0 -1
  193. package/dist/assets/password-reset-page-Dr4-0_xs.js +0 -1
  194. package/dist/assets/plugins-surface-BSzMy9bT.js +0 -1
  195. package/dist/assets/referral-modal-CeOVD766.js +0 -1
  196. package/dist/assets/routes-DxNQ44wo.js +0 -1
  197. package/dist/assets/share-feedback-modal-BPKLrcqs.js +0 -1
  198. package/dist/assets/tool-detail-panel-CFC6gU9K.js +0 -15
  199. package/dist/assets/tool-detail-panel-CVYxc8vR.js +0 -1
  200. package/dist/assets/use-supports-credentials-settings-DqJKqLDf.js +0 -1
@@ -1,2 +1,2 @@
1
1
  const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["assets/esm-DNzQmwtL.js","assets/react-B9IgSVeK.js","assets/rolldown-runtime-BM3Ffeng.js","assets/vendor-CtuA73w5.js"])))=>i.map(i=>d[i]);
2
- import{o as e}from"./rolldown-runtime-BM3Ffeng.js";import{$_ as t,$x as n,A as r,Ag as i,Ap as a,Au as o,Ba as s,Bb as c,Bm as l,Bx as u,Cg as d,Cp as f,Cx as p,Dm as m,Dp as h,Ei as g,Ey as _,Fb as v,Fi as y,Fx as b,Gb as x,Gy as S,Hb as C,Hm as w,Hx as T,Ib as E,Ii as D,Jb as O,Jc as k,Jl as A,Ju as j,Kl as ee,Km as M,Ku as te,Kx as N,Lb as ne,Lm as P,Lx as re,Ly as F,M as ie,Mx as I,Nb as ae,Nh as oe,Ni as se,Nx as L,Ny as ce,Oi as le,Ph as ue,Pi as de,Pm as fe,Ps as pe,Py as me,Q_ as he,Qh as ge,Qm as _e,R as ve,Ra as ye,Rg as R,Ry as be,Sg as xe,Sl as Se,Sp as Ce,Ty as we,Um as Te,Ux as z,Uy as Ee,Vm as De,Wb as B,Wh as Oe,Wm as ke,Xx as V,Yb as Ae,Yr as je,Yu as Me,Yx as Ne,Zb as Pe,Zh as Fe,Zx as Ie,_g as Le,_l as Re,_u as ze,_y as Be,ab as Ve,ag as He,ah as Ue,ax as We,cd as Ge,ch as Ke,cn as qe,cu as Je,db as Ye,dg as Xe,dh as Ze,dn as Qe,dx as $e,eh as et,et as tt,ex as nt,fg as rt,fh as it,fl as at,gb as ot,gg as st,gh as ct,gl as lt,gu as ut,hg as dt,hh as ft,hl as pt,hu as mt,hx as H,ig as ht,ih as gt,j as _t,jg as U,jh as vt,jy as yt,kb as bt,ki as xt,kr as St,kx as Ct,ln as wt,lx as Tt,ml as Et,mn as W,mu as Dt,mx as Ot,nS as kt,nh as At,nv as jt,oh as Mt,ol as Nt,pb as Pt,pl as Ft,pu as It,qu as Lt,rb as Rt,rf as zt,rh as Bt,ru as Vt,rx as Ht,sh as Ut,su as Wt,th as Gt,to as Kt,ub as qt,ui as Jt,vl as Yt,vu as Xt,vx as Zt,wp as Qt,xb as $t,xl as en,yl as tn,ym as nn,z as rn,zx as an}from"./app-BffxeWB8.js";import{E as on,I as G,Jn as sn,N as cn,Q as ln,Zn as K,_ as un,er as q,f as dn,g as fn,j as J,k as pn}from"./vendor-CtuA73w5.js";import{_ as mn,f as hn,n as gn,t as _n,v as vn,x as yn}from"./react-B9IgSVeK.js";import{B as bn,Ca as xn,E as Sn,Et as Cn,Hi as wn,Ja as Tn,Jn as Y,Ki as En,Q as Dn,Ri as On,Tt as kn,_n as An,br as jn,ci as Mn,gr as Nn,i as Pn,kt as Fn,nt as In,qi as Ln,vn as Rn}from"./icons-DxrLl-Dj.js";import{t as X}from"./detail-card-B3_bSihf.js";import{t as zn}from"./environment-store-Dka2FZhs.js";import{t as Bn}from"./app-info-DsEx-jq_.js";import{a as Vn,i as Hn,l as Un,o as Wn}from"./machine-sizes--PLzvcMG.js";import{t as Gn}from"./format-countdown-Dceq8qd-.js";import{a as Kn,i as qn,n as Jn,r as Yn,t as Xn}from"./assistant-status-panel-BSioaCpK.js";import{t as Zn}from"./trait-cycle-row-BSA19j9_.js";import{n as Qn,r as $n,t as er}from"./settings-divider-DAr-iUO3.js";import{t as tr}from"./use-hotkey-recorder-v5Akb2eM.js";var nr=Tn(`fingerprint-pattern`,[[`path`,{d:`M12 10a2 2 0 0 0-2 2c0 1.02-.1 2.51-.26 4`,key:`1nerag`}],[`path`,{d:`M14 13.12c0 2.38 0 6.38-1 8.88`,key:`o46ks0`}],[`path`,{d:`M17.29 21.02c.12-.6.43-2.3.5-3.02`,key:`ptglia`}],[`path`,{d:`M2 12a10 10 0 0 1 18-6`,key:`ydlgp0`}],[`path`,{d:`M2 16h.01`,key:`1gqxmh`}],[`path`,{d:`M21.8 16c.2-2 .131-5.354 0-6`,key:`drycrb`}],[`path`,{d:`M5 19.5C5.5 18 6 15 6 12a6 6 0 0 1 .34-2`,key:`1tidbn`}],[`path`,{d:`M8.65 22c.21-.66.45-1.32.57-2`,key:`13wd9y`}],[`path`,{d:`M9 6.8a6 6 0 0 1 9 5.2v2`,key:`1fr1j5`}]]),rr=Tn(`server`,[[`rect`,{width:`20`,height:`8`,x:`2`,y:`2`,rx:`2`,ry:`2`,key:`ngkwjq`}],[`rect`,{width:`20`,height:`8`,x:`2`,y:`14`,rx:`2`,ry:`2`,key:`iecqi9`}],[`line`,{x1:`6`,x2:`6.01`,y1:`6`,y2:`6`,key:`16zg32`}],[`line`,{x1:`6`,x2:`6.01`,y1:`18`,y2:`18`,key:`nzw8ys`}]]),ir=Tn(`vibrate`,[[`path`,{d:`m2 8 2 2-2 2 2 2-2 2`,key:`sv1b1`}],[`path`,{d:`m22 8-2 2 2 2-2 2 2 2`,key:`101i4y`}],[`rect`,{width:`8`,height:`14`,x:`8`,y:`5`,rx:`1`,key:`1oyrl4`}]]),Z=e(yn(),1),Q=_n();function ar(){let{t:e}=J(`settings`),t=R.use.velvet(),{theme:n,setThemePreference:r}=Jt(),i=[{value:`system`,label:e(`themePicker.system`),icon:(0,Q.jsx)(Rn,{className:`h-4 w-4`})},{value:`light`,label:e(`themePicker.light`),icon:(0,Q.jsx)(bn,{className:`h-4 w-4`})},{value:`dark`,label:e(`themePicker.dark`),icon:(0,Q.jsx)(An,{className:`h-4 w-4`})},...t?[{value:`velvet`,label:e(`themePicker.velvet`),icon:(0,Q.jsx)(Nn,{className:`h-4 w-4`})}]:[]];return(0,Q.jsxs)(`section`,{children:[(0,Q.jsx)(`h3`,{className:`text-title-small text-[var(--content-emphasised)]`,children:e(`themePicker.title`)}),(0,Q.jsx)(`div`,{className:`mt-2 max-w-[360px]`,children:(0,Q.jsx)(re,{ariaLabel:e(`themePicker.ariaLabel`),value:n,onChange:r,items:i})})]})}var or=l,sr=`Please choose a different handle.`;async function cr(e,t){let{data:n,error:r,response:i}=await st({path:{id:e},body:{handle:t},throwOnError:!1});if(!i)return{kind:`error`,message:Pe(r,void 0,`Failed to save handle.`)??`Failed to save handle.`};if(i.ok&&n)return{kind:`ok`,data:n};if(i.status===409){let{message:e}=ke(r,`handle`,or.taken);return{kind:`taken`,message:e}}if(i.status===400){let{code:e,message:t}=ke(r,`handle`,sr);return{kind:`invalid`,code:e,message:t}}return{kind:`error`,message:Pe(r,i,`Failed to save handle.`)}}async function lr(e,t,n){let{data:r,error:i,response:a}=await Xe({path:{assistant_id:e},query:{handle:t},signal:n,throwOnError:!1});if(Ae(a,i,`Failed to check handle availability.`),!a.ok||!r)throw new O(a.status,a.status===429?`Too many checks — try again in a moment.`:Pe(i,a,`Failed to check handle availability.`));return{available:r.available,code:r.code??null,message:r.message??null}}function ur(e){return/\d{2,}$/.test(e)}var dr=300,fr=1400;function pr({initialHandle:e,inputLabel:t,helperText:r,idleHelperText:i,checkAvailable:a,save:o,onSaved:s,saveSuccessToast:c,fieldId:l}){let{t:u}=J(),[d,f]=(0,Z.useState)(e),[p,m]=(0,Z.useState)(null),[h,g]=(0,Z.useState)(!1),[_,v]=(0,Z.useState)(`idle`),[y,b]=(0,Z.useState)(null),x=dn(),S=(0,Z.useRef)(null),C=(0,Z.useMemo)(()=>d.trim().toLowerCase(),[d]),w=C===e.toLowerCase();(0,Z.useEffect)(()=>{if(w||C.length===0){g(!1),S.current?.abort();return}let e=new AbortController;S.current?.abort(),S.current=e,g(!0);let t=window.setTimeout(async()=>{try{let t=await a(C,e.signal);e.signal.aborted||m(t)}catch(t){e.signal.aborted||b(t instanceof Error?t.message:u(`profileCard.checkAvailabilityFailed`))}finally{e.signal.aborted||g(!1)}},dr);return()=>{window.clearTimeout(t),e.abort()}},[C,w,a,u]);let T=(()=>{if(y)return y;if(p&&!p.available){let e=p.code;return p.message??(e?or[e]:u(`profileCard.chooseDifferentHandle`))}return null})(),E=T?r:w?i??null:h?u(`profileCard.checkingAvailability`):p?.available?u(`profileCard.availableHelper`):null,D=!w&&!h&&p?.available!==!1&&_!==`saving`,O=(0,Z.useCallback)(async()=>{if(!D)return;v(`saving`),b(null);let e=await o(C);if(e.kind===`ok`){v(`saved`),s(e.data),L.success(c),window.setTimeout(()=>v(`idle`),fr);return}if(e.kind===`taken`){v(`idle`),m({available:!1,code:`taken`,message:e.message});return}if(e.kind===`invalid`){v(`idle`),m({available:!1,code:e.code,message:e.message});return}v(`error`),b(e.message),L.error(e.message)},[D,C,s,o,c]),k=(()=>{if(w&&d.length>0||d.length===0)return null;let e=h?`checking`:p?.available?`available`:p?.available===!1?`invalid`:null;return e?(0,Q.jsx)(un,{mode:`wait`,initial:!1,children:(0,Q.jsxs)(fn.span,{initial:x?!1:{opacity:0,scale:.85},animate:{opacity:1,scale:1},exit:x?void 0:{opacity:0,scale:.85},transition:{duration:.14,ease:`easeOut`},className:`flex items-center`,"aria-hidden":e!==`available`&&e!==`invalid`,children:[e===`checking`&&(0,Q.jsx)(Y,{className:`h-4 w-4 animate-spin text-[var(--content-tertiary)]`}),e===`available`&&(0,Q.jsx)(Ln,{className:`h-4 w-4 text-[var(--system-positive-strong)]`,"aria-label":u(`profileCard.available`)}),e===`invalid`&&(0,Q.jsx)(wn,{className:`h-4 w-4 text-[var(--system-negative-strong)]`,"aria-label":u(`profileCard.notAvailable`)})]},e)}):null})(),A=(()=>{switch(_){case`saving`:return(0,Q.jsxs)(`span`,{className:`inline-flex items-center gap-1.5`,children:[(0,Q.jsx)(Y,{className:`h-3.5 w-3.5 animate-spin`,"aria-hidden":!0}),u(`profileCard.saving`)]});case`saved`:return(0,Q.jsxs)(`span`,{className:`inline-flex items-center gap-1.5`,children:[(0,Q.jsx)(Ln,{className:`h-3.5 w-3.5`,"aria-hidden":!0}),u(`profileCard.saved`)]});default:return u(`profileCard.save`)}})();return(0,Q.jsxs)(`div`,{className:`flex flex-col gap-4`,children:[(0,Q.jsx)(z,{label:t,value:d,onChange:e=>{f(e.target.value.replace(/\s+/g,``)),m(null),b(null)},autoCorrect:`off`,autoCapitalize:`none`,spellCheck:!1,maxLength:30,leftIcon:(0,Q.jsx)(`span`,{className:`select-none font-mono text-[var(--content-tertiary)]`,"aria-hidden":!0,children:`@`}),rightIcon:k,errorText:T??void 0,helperText:E??void 0,"aria-invalid":!!T,fullWidth:!0,"data-testid":`${l}-input`}),(!w||_!==`idle`)&&(0,Q.jsx)(`div`,{className:`flex justify-end`,children:(0,Q.jsx)(n,{variant:`primary`,size:`compact`,onClick:O,disabled:!D,"aria-live":`polite`,"data-testid":`${l}-save`,children:A})})]})}function mr({initial:e,onSaved:t}){let{t:n}=J(),r=h.use.refreshSession(),i=ur(e.username)?n(`profileCard.userHandleIdleAutoGenerated`):void 0,a=(0,Z.useCallback)(async e=>await Te({username:e}),[]),o=(0,Z.useCallback)((e,t)=>De(e,t),[]),s=(0,Z.useCallback)(e=>{t(e),r()},[t,r]);return(0,Q.jsx)(pr,{initialHandle:e.username,inputLabel:n(`profileCard.userHandleLabel`),helperText:n(`profileCard.handleHelper`),idleHelperText:i,checkAvailable:o,save:a,onSaved:s,saveSuccessToast:n(`profileCard.profileUpdated`),fieldId:`user-handle`})}function hr({assistant:e,onSaved:t}){let{t:n}=J(),r=e.handle??``,i=K({...k({path:{assistant_id:e.id}})}).data?.results?.[0],a=!!i&&i.subdomain.toLowerCase()===r.toLowerCase(),o=r.length===0?n(`profileCard.assistantHandleIdleEmpty`):void 0,s=(0,Z.useCallback)(async t=>await cr(e.id,t),[e.id]),c=(0,Z.useCallback)((t,n)=>lr(e.id,t,n),[e.id]);return a?(0,Q.jsxs)(`div`,{className:`flex flex-col gap-2`,children:[(0,Q.jsx)(z,{label:n(`profileCard.assistantHandleLabel`),value:r,readOnly:!0,disabled:!0,leftIcon:(0,Q.jsx)(`span`,{className:`select-none font-mono text-[var(--content-tertiary)]`,"aria-hidden":!0,children:`@`}),fullWidth:!0,"data-testid":`assistant-handle-input`}),(0,Q.jsx)(`p`,{className:`text-body-small-default text-[var(--content-tertiary)]`,children:(0,Q.jsx)(cn,{i18nKey:`profileCard.handleLocked`,components:{releaseLink:(0,Q.jsx)(gn,{to:`${v.channels}?setup=email&release=1`,className:`text-[var(--content-link)] underline hover:text-[var(--content-link-hover)]`})}})})]}):(0,Q.jsx)(pr,{initialHandle:r,inputLabel:n(`profileCard.assistantHandleLabel`),helperText:n(`profileCard.handleHelper`),idleHelperText:o,checkAvailable:c,save:s,onSaved:t,saveSuccessToast:n(`profileCard.assistantHandleUpdated`),fieldId:`assistant-handle`})}function gr(){let{t:e}=J();return(0,Q.jsxs)(`div`,{className:`flex flex-col gap-4`,"aria-busy":!0,"aria-live":`polite`,children:[(0,Q.jsxs)(`div`,{className:`flex flex-col gap-2`,children:[(0,Q.jsx)(Zt,{className:`h-3 w-16`}),(0,Q.jsx)(Zt,{className:`h-9 w-full rounded-md`}),(0,Q.jsx)(Zt,{className:`h-3 w-72`})]}),(0,Q.jsx)(Zt,{className:`h-9 w-full rounded-md`}),(0,Q.jsxs)(`div`,{className:`flex items-center justify-between gap-3`,children:[(0,Q.jsx)(Zt,{className:`h-3 w-60`}),(0,Q.jsx)(Zt,{className:`h-7 w-16 rounded-md`})]}),(0,Q.jsx)(`span`,{className:`sr-only`,children:e(`profileCard.loading`)})]})}function _r(){return(0,Q.jsx)(`div`,{className:`border-t border-[var(--border-subtle)]`})}function vr({assistant:e,showHandles:t=!0,children:n}={}){let{t:r}=J(),i=h.use.user?.()?.email??null;return(0,Q.jsx)(X,{title:r(`profileCard.title`),subtitle:r(`profileCard.subtitle`),children:(0,Q.jsxs)(`div`,{className:`flex flex-col gap-6`,children:[i&&(0,Q.jsx)(`div`,{className:`max-w-[420px]`,children:(0,Q.jsx)(z,{label:r(`profileCard.emailLabel`),value:i,disabled:!0,readOnly:!0})}),t&&(0,Q.jsxs)(Q.Fragment,{children:[i&&(0,Q.jsx)(_r,{}),(0,Q.jsx)(yr,{assistant:e})]}),n!=null&&(0,Q.jsxs)(Q.Fragment,{children:[(i||t)&&(0,Q.jsx)(_r,{}),n]})]})})}function yr({assistant:e}){let[t,n]=(0,Z.useState)(null),[r,i]=(0,Z.useState)(null),a=dn(),[o,s]=(0,Z.useState)(e??null);return(0,Z.useEffect)(()=>{s(e??null)},[e]),(0,Z.useEffect)(()=>{let e=!1;return w().then(t=>{e||n(t)}).catch(t=>{e||i(t instanceof Error?t.message:`Failed to load profile.`)}),()=>{e=!0}},[]),r?(0,Q.jsx)(`p`,{className:`text-body-small-default text-[var(--system-negative-strong)]`,children:r}):t?(0,Q.jsxs)(fn.div,{initial:a?!1:{opacity:0,y:4},animate:{opacity:1,y:0},transition:{duration:.22,ease:`easeOut`},className:`flex flex-col gap-6`,children:[(0,Q.jsx)(mr,{initial:t,onSaved:n}),o&&(0,Q.jsxs)(Q.Fragment,{children:[(0,Q.jsx)(`div`,{className:`border-t border-[var(--border-subtle)]`}),(0,Q.jsx)(hr,{assistant:o,onSaved:s})]})]}):(0,Q.jsx)(gr,{})}var br=.5,xr={dazed:.55,bashful:.4},Sr=.224,Cr=`var(--surface-sunken)`,wr=64;function Tr(e){return xr[e]??br}function Er(e,t,n,r){let i=e?.eyeStyles.find(e=>e.id===t);if(!i||i.paths.length===0)return null;let a=xt(i.paths.map(e=>le(e.svgPath)));if(a.w<=0||a.h<=0)return null;let o=n*(r?br:Tr(t)),s=Math.min(o/a.w,o/a.h),c=n/2-(a.x+a.w/2)*s,l=n/2-(a.y+a.h/2)*s;return{paths:i.paths,transform:`matrix(${s},0,0,${s},${c},${l})`}}function Dr({components:e,eyeStyle:t,color:n,primary:r=!1,fieldColor:i,size:a=wr,className:o}){let s=(0,Z.useMemo)(()=>Er(e,t,a,r),[e,t,a,r]),c=e?.colors.find(e=>e.id===n)?.hex,l=i??c,u=a*Sr;return(0,Q.jsxs)(`svg`,{"aria-hidden":`true`,"data-testid":`app-icon-preview`,className:o,width:a,height:a,viewBox:`0 0 ${a} ${a}`,style:{display:`block`,flexShrink:0},children:[(0,Q.jsx)(`rect`,{"data-testid":`app-icon-preview-field`,width:a,height:a,rx:u,ry:u,fill:l??Cr}),s?(0,Q.jsx)(`g`,{"data-testid":`app-icon-preview-eyes`,transform:s.transform,children:s.paths.map((e,t)=>(0,Q.jsx)(`path`,{d:e.svgPath,fill:e.color},t))}):null]})}var Or={production:`#4C9B50`,staging:`#E9C91A`,dev:`#FF88C9`};g.eyeStyles.find(e=>e.id===`quirky`);var kr=`avatar-eyes-`,Ar={eyeStyle:`quirky`,color:`green`};function jr(e,t){return`${kr}${e}-${t}`}function Mr(e){if(e===null||e.kind!==`character`)return null;let t=e.traits;return fe(t)?jr(t.eyeStyle,t.color):null}function Nr(e){return e!==null&&e.startsWith(kr)}function Pr(e){if(e===null||!Nr(e))return null;let t=e.slice(12),n=t.indexOf(`-`);return n<=0||n===t.length-1?null:{eyeStyle:t.slice(0,n),color:t.slice(n+1)}}function Fr(e,t){let n=Mr(e);return{target:n,availableMatch:t.supported&&n!==null&&t.available.includes(n)}}var Ir=160;function Lr(e,t,n){return t<=0?0:(e+n+t)%t}function Rr(e,t){let n=e?.findIndex(e=>e.id===t)??-1;return n>=0?n:0}function zr({open:e,onClose:t,components:r,currentIcon:i,targetIcon:a,canSyncAvatar:o,availableIcons:s,onApply:c,onReset:l}){let{t:u}=J(`settings`),d=Mt(),[f,p]=(0,Z.useState)(0),[m,h]=(0,Z.useState)(0),[g,_]=(0,Z.useState)(!1),[v,y]=(0,Z.useState)(!1),x=o?Pr(a):null;(0,Z.useEffect)(()=>{if(!e)return;let t=Pr(i)??Pr(a)??Ar;p(Rr(r?.eyeStyles,t.eyeStyle)),h(Rr(r?.colors,t.color)),y(!1)},[e,r,i,a]);let S=r?.eyeStyles[f],C=r?.colors[m],w=S?.id??Ar.eyeStyle,T=C?.id??Ar.color,E=jr(w,T),D=E!==i&&s.includes(E),O=async e=>{_(!0),y(!1);try{await e()?t():y(!0)}finally{_(!1)}};return(0,Q.jsx)(b.Root,{open:e,onOpenChange:e=>{e||t()},children:(0,Q.jsxs)(b.Content,{size:`sm`,"data-testid":`app-icon-modal`,children:[(0,Q.jsx)(b.Header,{children:(0,Q.jsx)(b.Title,{children:u(`appIcon.title`)})}),(0,Q.jsxs)(b.Body,{className:`space-y-4`,children:[(0,Q.jsx)(`div`,{className:`flex justify-center`,children:(0,Q.jsx)(`div`,{className:`rounded-2xl bg-[var(--surface-sunken)] p-6`,children:(0,Q.jsx)(Dr,{components:r,eyeStyle:w,color:T,size:Ir})})}),(0,Q.jsxs)(`div`,{className:`space-y-3`,children:[(0,Q.jsx)(Zn,{label:u(`appIcon.eyes`),value:w,onPrev:()=>p(Lr(f,r?.eyeStyles.length??0,-1)),onNext:()=>p(Lr(f,r?.eyeStyles.length??0,1))}),(0,Q.jsx)(Zn,{label:u(`appIcon.color`),value:T,colorHex:C?.hex,onPrev:()=>h(Lr(m,r?.colors.length??0,-1)),onNext:()=>h(Lr(m,r?.colors.length??0,1))})]}),x===null?null:(0,Q.jsx)(n,{type:`button`,variant:`outlined`,fullWidth:!0,disabled:g,onClick:()=>{x!==null&&(p(Rr(r?.eyeStyles,x.eyeStyle)),h(Rr(r?.colors,x.color)),y(!1))},children:u(`appIcon.matchAvatar`)}),(0,Q.jsx)(`p`,{className:`text-body-small-lighter text-[var(--content-tertiary)]`,children:u(d?`appIcon.androidApplyNote`:`appIcon.note`)}),v?(0,Q.jsx)(`p`,{role:`alert`,className:`text-body-small-lighter text-[color:var(--content-negative)]`,children:u(d?`appIcon.androidError`:`appIcon.error`)}):null]}),(0,Q.jsxs)(b.Footer,{children:[i===null?null:(0,Q.jsx)(n,{type:`button`,variant:`outlined`,disabled:g,onClick:()=>void O(l),children:u(`appIcon.reset`)}),(0,Q.jsx)(n,{type:`button`,variant:`primary`,disabled:g||!D,onClick:()=>void O(()=>c(E)),children:u(`appIcon.apply`)})]})]})})}var Br=`AppIcon`,Vr=pn(Br);function Hr(){return{supported:!1,current:null,available:[]}}function Ur(){return et()&&on.isPluginAvailable(Br)}async function Wr(){if(!Ur())return Hr();try{let{supported:e,current:t,available:n}=await Vr.getState();return{supported:e===!0,current:typeof t==`string`?t:null,available:n??[]}}catch(e){return B(e,{context:`app_icon_get_state`,bestEffort:!0}),Hr()}}async function Gr(e){if(!Ur())return!1;try{let{ok:t,error:n}=await Vr.set({name:e});return t===!0?!0:(B(Error(n??`setAlternateIconName failed`),{context:`app_icon_set`,bestEffort:!0}),!1)}catch(e){return B(e,{context:`app_icon_set`,bestEffort:!0}),!1}}var Kr={supported:!1,current:null,available:[]};function qr(e,t){return e.supported===t.supported&&e.current===t.current&&e.available.length===t.available.length&&e.available.every((e,n)=>e===t.available[n])}var Jr=$e(ln()((e,t)=>({snapshot:Kr,setSnapshot:n=>{qr(t().snapshot,n)||e({snapshot:n})}}))),Yr=[];function Xr(e){let t=Ut(),n=Mt(),r=R.use.androidAvatarAppIcon(),i=t||n&&r,{state:a}=nn(e),s=Jr.use.snapshot(),c=Jr.use.setSnapshot(),l=(0,Z.useCallback)(async()=>{if(!i)return c(Kr),Kr;let e=await Wr();return c(e),e},[i,c]);(0,Z.useEffect)(()=>{l()},[l]),o(`app.resume`,()=>{l()});let u=i&&s.supported,{target:d,availableMatch:f}=Fr(a,s),p=f&&d!==s.current,m=s.available,h=(0,Z.useCallback)(async e=>{if(!u||!m.includes(e))return!1;await Gr(e);let t=await l();return t.supported&&t.current===e},[u,m,l]),g=(0,Z.useCallback)(async()=>{if(!u)return!1;await Gr(null);let e=await l();return e.supported&&e.current===null},[u,l]);return{enabled:u,currentIcon:u?s.current:null,targetIcon:u?d:null,availableIcons:u?m:Yr,canSyncAvatar:p,apply:h,reset:g}}var Zr=[`ai.vocify-inc.vellum-assistant-ios`,`ai.vellum.assistant`],Qr={"":`production`,".staging":`staging`,".dev":`dev`};function $r(e){for(let t of Zr){if(!e.startsWith(t))continue;let n=Qr[e.slice(t.length)];if(n)return n}return null}async function ei(){try{let{App:e}=await vn(async()=>{let{App:e}=await import(`./esm-DNzQmwtL.js`);return{App:e}},__vite__mapDeps([0,1,2,3])),{id:t}=await e.getInfo();return $r(t)}catch(e){return console.debug(`[shell-environment] no native shell identity:`,e),null}}function ti(){let[e,t]=(0,Z.useState)();return(0,Z.useEffect)(()=>{let e=!0;return ei().then(n=>{e&&t(n)}),()=>{e=!1}},[]),e}var ni=32,ri={dev:{displayP3:`color(display-p3 0.9387 0.55755 0.7777)`,srgb:Or.dev},staging:{displayP3:`color(display-p3 0.89313 0.79283 0.2841)`,srgb:Or.staging}},ii={local:`dev`,dev:`dev`,staging:`staging`};function ai(){return typeof CSS>`u`||typeof CSS.supports!=`function`?!1:CSS.supports(`color`,`color(display-p3 1 1 1)`)}function oi(e){if(e)return ai()?e.displayP3:e.srgb}function si(e){if(e)return e;if(e===null)return ii.local}function ci(e,t){let n=si(e);if(!n)return;let r=ri[n];return t?r?.srgb:oi(r)}function li(){let e=Be.use.activeAssistantId(),t=Xr(e);return t.enabled?(0,Q.jsx)(ui,{assistantId:e,sync:t}):null}function ui({assistantId:e,sync:t}){let{t:r}=J(`settings`),{components:i}=nn(e),a=je(),o=ti(),s=Mt(),[c,l]=(0,Z.useState)(!1),u=i??a,d=Pr(t.currentIcon),f=d??Ar,p=d===null;return(0,Q.jsxs)(Q.Fragment,{children:[(0,Q.jsxs)(`div`,{className:`flex items-center justify-between gap-3`,children:[(0,Q.jsxs)(`div`,{className:`flex min-w-0 flex-col gap-0.5`,children:[(0,Q.jsx)(`div`,{className:`text-body-medium-lighter text-[var(--content-default)]`,children:r(`appIcon.title`)}),(0,Q.jsx)(`p`,{className:`text-body-small-lighter text-[var(--content-tertiary)]`,children:r(`appIcon.description`)})]}),(0,Q.jsxs)(`div`,{className:`flex shrink-0 items-center gap-3`,children:[(0,Q.jsx)(Dr,{components:u,eyeStyle:f.eyeStyle,color:f.color,primary:p,fieldColor:p?ci(o,s):void 0,size:ni}),(0,Q.jsx)(n,{variant:`outlined`,onClick:()=>l(!0),children:r(`appIcon.change`)})]})]}),(0,Q.jsx)(zr,{open:c,onClose:()=>l(!1),components:u,currentIcon:t.currentIcon,targetIcon:t.targetIcon,canSyncAvatar:t.canSyncAvatar,availableIcons:t.availableIcons,onApply:t.apply,onReset:t.reset})]})}var di=Nt({query:{hosting:`platform`}});function fi(){let{t:e}=J(`settings`),t=tt(),r=K(di),i=r.data?.results??[];return r.isPending||i.length<2?null:(0,Q.jsx)(X,{title:e(`assistantPicker.title`),subtitle:e(`assistantPicker.subtitle`),children:(0,Q.jsx)(`div`,{className:`space-y-2`,children:i.map(r=>{let i=r.id===t;return(0,Q.jsxs)(`div`,{className:`flex items-center justify-between gap-4 rounded-lg border px-4 py-3 ${i?`border-[var(--border-focus)] bg-[var(--surface-lift)]`:`border-[var(--border-base)] bg-[var(--surface-default)]`}`,children:[(0,Q.jsxs)(`div`,{className:`flex min-w-0 items-center gap-3`,children:[(0,Q.jsx)(Rn,{className:`h-4 w-4 shrink-0 text-[var(--content-tertiary)]`}),(0,Q.jsx)(`div`,{className:`min-w-0`,children:(0,Q.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,Q.jsx)(`span`,{className:`truncate text-body-medium-default text-[var(--content-default)]`,children:r.name||e(`assistantPicker.unnamed`)}),r.status!==`active`&&(0,Q.jsx)(N,{tone:`warning`,children:r.status})]})})]}),(0,Q.jsx)(`div`,{className:`shrink-0`,children:i?(0,Q.jsxs)(`span`,{className:`flex items-center gap-1.5 text-body-small-default text-[var(--system-positive-default)]`,children:[(0,Q.jsx)(Ln,{className:`h-4 w-4`}),e(`assistantPicker.active`)]}):(0,Q.jsx)(n,{variant:`outlined`,size:`compact`,disabled:r.status!==`active`,onClick:()=>{vt(r.id),L.success(e(`assistantPicker.switchedToast`))},children:e(`assistantPicker.switch`)})})]},r.id)})})})}var pi=[0,300,600,3600,10800,86400,259200,604800,1209600,2592e3],mi=new Set([300,600]);function hi(e,t){if(e===0)return t(`assistantSleepPolicy.neverSleep`);let n=Math.floor(e/86400),r=Math.floor(e%86400/3600);if(n>0&&r>0)return t(`assistantSleepPolicy.daysHours`,{days:n,hours:r});if(n>0)return t(`assistantSleepPolicy.days`,{days:n});if(r>0)return t(`assistantSleepPolicy.hours`,{hours:r});let i=Math.floor(e/60);return i>0?t(`assistantSleepPolicy.minutes`,{minutes:i}):t(`assistantSleepPolicy.seconds`,{seconds:e})}function gi(e,t){switch(e){case 0:return t(`assistantSleepPolicy.presetNever`);case 300:return t(`assistantSleepPolicy.preset5Min`);case 600:return t(`assistantSleepPolicy.preset10Min`);case 3600:return t(`assistantSleepPolicy.preset1Hour`);case 10800:return t(`assistantSleepPolicy.preset3Hours`);case 86400:return t(`assistantSleepPolicy.preset1Day`);case 259200:return t(`assistantSleepPolicy.preset3Days`);case 604800:return t(`assistantSleepPolicy.preset7Days`);case 1209600:return t(`assistantSleepPolicy.preset14Days`);case 2592e3:return t(`assistantSleepPolicy.preset30Days`);default:return hi(e,t)}}function _i({assistantId:e}){let{t}=J(`settings`),r=q(),i=zn.use.isNonProduction(),a=(0,Z.useMemo)(()=>pi.filter(e=>!mi.has(e)||i),[i]),{data:o,isLoading:s,isError:c}=K(Yt({path:{id:e}})),l=(0,Z.useMemo)(()=>o?.idle_timeout_seconds??259200,[o]),[u,d]=(0,Z.useState)(null),f=u??l,p=u!==null,m=Je({onSuccess:()=>{L.success(t(`assistantSleepPolicy.savedToast`)),d(null),r.invalidateQueries({queryKey:tn({path:{id:e}})})},onError:()=>{L.error(t(`assistantSleepPolicy.saveErrorToast`))}});return s?(0,Q.jsxs)(`div`,{className:`flex items-center gap-2 text-body-medium-lighter text-[var(--content-tertiary)]`,children:[(0,Q.jsx)(Y,{className:`h-4 w-4 animate-spin`}),t(`assistantSleepPolicy.loading`)]}):c?(0,Q.jsx)(`p`,{className:`text-body-medium-lighter text-[var(--system-negative-strong)]`,children:t(`assistantSleepPolicy.loadError`)}):(0,Q.jsxs)(`div`,{className:`space-y-4`,children:[(0,Q.jsxs)(`div`,{children:[(0,Q.jsx)(`label`,{className:`block text-body-medium-default text-[var(--content-default)]`,children:t(`assistantSleepPolicy.idleTimeout`)}),(0,Q.jsx)(`p`,{className:`text-body-small-lighter text-[var(--content-tertiary)]`,children:t(`assistantSleepPolicy.idleTimeoutDescription`)}),(0,Q.jsx)(`div`,{className:`mt-2 flex flex-wrap gap-2`,children:a.map(e=>(0,Q.jsx)(n,{variant:`outlined`,active:f===e,onClick:()=>d(e),children:gi(e,t)},e))}),(0,Q.jsx)(`p`,{className:`mt-2 text-body-small-default text-[var(--content-tertiary)]`,children:t(`assistantSleepPolicy.current`,{duration:hi(f,t)})})]}),p&&(0,Q.jsxs)(`div`,{className:`flex items-center gap-3`,children:[(0,Q.jsx)(n,{variant:`primary`,leftIcon:m.isPending?(0,Q.jsx)(Y,{className:`animate-spin`}):void 0,onClick:()=>m.mutate({path:{id:e},body:{idle_timeout_seconds:f}}),disabled:m.isPending,children:t(`assistantSleepPolicy.save`)}),(0,Q.jsx)(n,{variant:`outlined`,onClick:()=>d(null),disabled:m.isPending,children:t(`assistantSleepPolicy.cancel`)})]})]})}function vi(e,t,n){let r=[e.version];return e.version===n&&r.push(G(`settings:assistantUpgrades.latestSuffix`)),t&&e.version===t&&r.push(G(`settings:assistantUpgrades.currentSuffix`)),r.join(` `)}var yi=3e3;function bi({version:e,assistantId:t}){let{onTap:n,message:r}=qn(t);return(0,Q.jsxs)(`div`,{className:`min-w-0`,children:[(0,Q.jsx)(`button`,{type:`button`,className:`block min-w-0 break-all text-left text-body-medium-lighter text-[var(--content-default)]`,onClick:n,children:e??`—`}),r&&(0,Q.jsx)(`p`,{className:`mt-1 text-body-small-default text-[var(--content-accent)]`,children:r})]})}function xi({assistantId:e,currentVersion:t,releaseChannel:r,onUpgradeComplete:i}){let{t:a}=J(`settings`),o=Ge.use.rollbackEnabled(),s=R.use.previewChannel(),c=q(),l=de(r,s),u=l===`preview`,[d,f]=(0,Z.useState)(!1),m=(0,Z.useRef)(null),[h,g]=(0,Z.useState)(null),[_,v]=(0,Z.useState)(!1),[y,b]=(0,Z.useState)(!1),[x,S]=(0,Z.useState)(null),C=e=>e&&m.current&&e===m.current?(queueMicrotask(()=>{S(a(y?`assistantUpgrades.successRolledBack`:`assistantUpgrades.successUpdated`,{version:m.current})),f(!1),m.current=null,g(null),L.success(a(y?`assistantUpgrades.toastRollbackComplete`:`assistantUpgrades.toastUpdateComplete`),{id:`runtime-upgrade-complete`,tone:`strong`}),i?.()}),!1):yi;K({...lt({path:{id:e}}),refetchInterval:d?e=>C(e.state.data?.current_release_version):!1});let{data:w,isLoading:T}=K(Vt({query:{channel:l}})),E=w?.find(e=>e.is_stable!==!1)??w?.[0],D=h??E?.version??null,O=(0,Z.useMemo)(()=>{if(!o||!D||!t)return!1;let e=ct(D),n=ct(t);return!e||!n?!1:ft(e,n)<0},[o,D,t]),k=(0,Z.useMemo)(()=>{if(!D)return!1;if(!t)return!0;let e=ct(D),n=ct(t);if(!e||!n)return D!==t;let r=ft(e,n);return o?r!==0:r>0},[o,D,t]),A=sn({mutationFn:async t=>{let{data:n}=await xe({path:{id:e},body:t,throwOnError:!0});return n}}),j=sn({mutationFn:async t=>{let{data:n}=await Le({path:{id:e},body:t,throwOnError:!0});return n}}),ee=async()=>{v(!1),S(null);let t=o?D??void 0:void 0;try{if(O){let e=await j.mutateAsync({version:t});m.current=e.version??t??null,L.success(e.detail||a(`assistantUpgrades.toastRollbackInitiated`,{version:t}))}else{let e=await A.mutateAsync({version:t});if(e.detail?.includes(`Already on the latest`)){L.warning(e.detail);return}m.current=e.version??t??null,L.success(e.detail||a(`assistantUpgrades.toastUpdateInitiated`,{version:e.version??t??a(`assistantUpgrades.latest`)}))}b(O),f(!0),c.invalidateQueries({queryKey:Re({path:{id:e}})})}catch{L.error(a(O?`assistantUpgrades.toastRollbackFailed`:`assistantUpgrades.toastUpdateFailed`))}},M=a(u?`assistantUpgrades.previewRelease`:k?O?`assistantUpgrades.rollbackTo`:`assistantUpgrades.updateTo`:`assistantUpgrades.selected`);return(0,Q.jsxs)(`div`,{className:`space-y-5`,children:[(0,Q.jsxs)(`div`,{className:`flex flex-col gap-4 md:grid md:grid-cols-[auto_minmax(0,1fr)] md:items-center md:gap-x-8 md:gap-y-4`,children:[(0,Q.jsxs)(`div`,{className:`flex flex-col gap-1 md:contents`,children:[(0,Q.jsx)(`span`,{className:`text-body-medium-default text-[var(--content-tertiary)]`,children:a(`assistantUpgrades.current`)}),(0,Q.jsx)(bi,{version:t,assistantId:e})]}),(0,Q.jsxs)(`div`,{className:`flex flex-col gap-1 md:contents`,children:[(0,Q.jsx)(`span`,{className:`text-body-medium-default text-[var(--content-tertiary)]`,children:M}),(0,Q.jsxs)(`div`,{className:`flex min-w-0 flex-col gap-3 md:flex-row md:items-center md:gap-4`,children:[(0,Q.jsx)(`span`,{className:`block min-w-0 flex-1`,children:T?(0,Q.jsxs)(`span`,{className:`flex items-center gap-1 text-body-medium-lighter text-[var(--content-tertiary)]`,children:[(0,Q.jsx)(Y,{className:`h-3 w-3 animate-spin`}),a(`assistantUpgrades.loading`)]}):w&&w.length>0?o?(0,Q.jsx)(p,{value:D??``,onChange:e=>g(e===E?.version?null:e),disabled:d||A.isPending||j.isPending,options:w.map(e=>({value:e.version,label:vi(e,t,E?.version)}))}):(0,Q.jsx)(`span`,{className:`block min-w-0 break-all text-body-medium-lighter text-[var(--content-default)]`,children:E?vi(E,t,E.version):`—`}):a(`assistantUpgrades.noReleases`)}),(0,Q.jsx)(n,{variant:O?`outlined`:`primary`,className:`min-w-[160px] shrink-0`,leftIcon:A.isPending||j.isPending||d?(0,Q.jsx)(Y,{className:`animate-spin`}):(0,Q.jsx)(Fn,{}),onClick:()=>v(!0),disabled:!k||A.isPending||j.isPending||d||T||!w?.length,children:a(d?y?`assistantUpgrades.rollingBack`:`assistantUpgrades.updating`:O?`assistantUpgrades.rollback`:u?`assistantUpgrades.updatePreview`:`assistantUpgrades.update`)})]})]})]}),u&&(0,Q.jsx)(`p`,{className:`text-body-small-default text-[var(--content-tertiary)]`,children:(0,Q.jsx)(cn,{ns:`settings`,i18nKey:`assistantUpgrades.usingPreviewReleases`,components:{stableLink:(0,Q.jsx)(`a`,{href:`#preview-release-channel`,className:`text-[var(--primary-base)] underline-offset-2 hover:underline`})}})}),!k&&t&&D&&!T&&(0,Q.jsx)(`p`,{className:`text-body-medium-lighter text-[var(--system-positive-strong)]`,children:x??a(`assistantUpgrades.alreadyOnVersion`)}),(0,Q.jsx)(I,{open:_,title:a(O?`assistantUpgrades.confirmRollbackTitle`:u?`assistantUpgrades.confirmPreviewTitle`:`assistantUpgrades.confirmUpdateTitle`),message:O?a(`assistantUpgrades.confirmRollbackMessage`,{version:D??a(`assistantUpgrades.unknown`)}):a(u?`assistantUpgrades.confirmPreviewMessage`:`assistantUpgrades.confirmUpdateMessage`,{version:D??a(`assistantUpgrades.latest`)}),confirmLabel:a(O?`assistantUpgrades.rollback`:u?`assistantUpgrades.updatePreview`:`assistantUpgrades.update`),onConfirm:ee,onCancel:()=>v(!1)})]})}function Si({assistantId:e,currentVersion:t,onUpgradeComplete:r}){let{t:i}=J(`settings`),[a,o]=(0,Z.useState)(!1),[s,c]=(0,Z.useState)(null),{data:l,isLoading:u}=K(Vt({query:{stable:!0,limit:100}})),d=(0,Z.useMemo)(()=>se(l),[l]),f=d?.version,p=t?y(t,f):!!f,m=D({assistantId:e,targetVersion:f});return(0,Q.jsxs)(`div`,{className:`space-y-5`,children:[(0,Q.jsxs)(`div`,{className:`flex flex-col gap-4 md:grid md:grid-cols-[auto_minmax(0,1fr)] md:items-center md:gap-x-8 md:gap-y-4`,children:[(0,Q.jsxs)(`div`,{className:`flex flex-col gap-1 md:contents`,children:[(0,Q.jsx)(`span`,{className:`text-body-medium-default text-[var(--content-tertiary)]`,children:i(`assistantUpgrades.current`)}),(0,Q.jsx)(bi,{version:t,assistantId:e})]}),(0,Q.jsxs)(`div`,{className:`flex flex-col gap-1 md:contents`,children:[(0,Q.jsx)(`span`,{className:`text-body-medium-default text-[var(--content-tertiary)]`,children:i(`assistantUpgrades.updateTo`)}),(0,Q.jsx)(`span`,{className:`block min-w-0 break-all text-body-medium-lighter text-[var(--content-default)]`,children:u?i(`assistantUpgrades.loading`):f&&d?vi(d,t,f):i(`assistantUpgrades.noReleases`)})]})]}),(0,Q.jsx)(n,{variant:`primary`,className:`min-w-[160px]`,leftIcon:m.isPending?(0,Q.jsx)(Y,{className:`animate-spin`}):(0,Q.jsx)(Fn,{}),onClick:()=>o(!0),disabled:m.isPending||u||!f||!p,children:m.isPending?i(`assistantUpgrades.updating`):f?i(`assistantUpgrades.updateToVersion`,{version:f}):i(`assistantUpgrades.update`)}),s&&(0,Q.jsx)(`p`,{className:`text-body-medium-lighter text-[var(--system-positive-strong)]`,children:s}),!s&&!p&&f&&!u&&(0,Q.jsx)(`p`,{className:`text-body-medium-lighter text-[var(--system-positive-strong)]`,children:i(`assistantUpgrades.alreadyOnVersion`)}),(0,Q.jsx)(I,{open:a,title:i(`assistantUpgrades.confirmUpdateTitle`),message:i(`assistantUpgrades.confirmUpdateMessage`,{version:f??i(`assistantUpgrades.latest`)}),confirmLabel:i(`assistantUpgrades.update`),onConfirm:async()=>{o(!1),c(null);try{c(i(`assistantUpgrades.successUpdated`,{version:(await m.upgrade()).version??f??i(`assistantUpgrades.latest`)})),L.success(i(`assistantUpgrades.toastUpdateComplete`),{id:`runtime-upgrade-complete`,tone:`strong`}),r?.()}catch(e){L.error(e instanceof Error?e.message:i(`assistantUpgrades.toastUpdateFailed`))}},onCancel:()=>o(!1)})]})}function Ci(){let{t:e}=J(`settings`),t=Qt({platformHostedOnly:!0}),r=f(),i=h.use.user()?.id??null,a=h.use.logout(),[o,s]=(0,Z.useState)(!1),c=It({onSuccess:async()=>{L.success(e(`deleteAccountSection.toastRequested`)),P(i),await a(),pe(v.account.login)},onError:()=>{L.error(e(`deleteAccountSection.toastFailed`))}}),l=t===`full`&&r;return(0,Z.useEffect)(()=>{l&&o&&s(!1)},[l,o]),t===`gated`?null:(0,Q.jsxs)(Q.Fragment,{children:[(0,Q.jsxs)(`section`,{className:`flex flex-col gap-2`,children:[(0,Q.jsx)(`h3`,{className:`text-title-small text-[var(--content-emphasised)]`,children:e(`deleteAccountSection.title`)}),(0,Q.jsx)(`p`,{className:`text-body-medium-default text-[var(--content-tertiary)]`,children:e(`deleteAccountSection.description`)}),(0,Q.jsx)(`div`,{className:`mt-1`,children:t===`disabled`?(0,Q.jsx)(W,{children:e(`deleteAccountSection.platformLoginNotice`)}):(0,Q.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,Q.jsx)(n,{variant:`dangerOutline`,onClick:()=>s(!0),disabled:c.isPending||l,className:`self-start`,children:e(`deleteAccountSection.deleteMyAccount`)}),l&&(0,Q.jsx)(Y,{className:`h-4 w-4 animate-spin text-[var(--content-tertiary)]`})]})})]}),(0,Q.jsx)(I,{open:o,title:e(`deleteAccountSection.confirmTitle`),message:e(`deleteAccountSection.confirmMessage`),confirmLabel:e(`deleteAccountSection.confirmLabel`),destructive:!0,onConfirm:()=>{if(l){s(!1);return}s(!1),c.mutate({})},onCancel:()=>s(!1)})]})}function wi({title:e,subtitle:t,benefits:r,ctaLabel:i,ctaLeftIcon:a,onAction:o}){return(0,Q.jsx)(X,{title:e,subtitle:t,children:(0,Q.jsxs)(`div`,{className:`flex flex-col gap-4`,children:[(0,Q.jsx)(`ul`,{className:`space-y-3`,children:r.map(({icon:e,text:t})=>(0,Q.jsxs)(`li`,{className:`flex items-center gap-3`,children:[(0,Q.jsx)(`span`,{className:`flex size-7 shrink-0 items-center justify-center rounded-md`,style:{background:`var(--surface-base)`},children:(0,Q.jsx)(e,{size:14,style:{color:`var(--content-secondary)`},"aria-hidden":!0})}),(0,Q.jsx)(`span`,{className:`text-body-medium-lighter text-[color:var(--content-secondary)]`,children:t})]},t))}),(0,Q.jsx)(n,{variant:`primary`,size:`regular`,leftIcon:a,onClick:o,className:`self-start`,children:i})]})})}function Ti({promotion:e}){let{t}=J(`settings`),{appName:n,target:i}=e;return(0,Z.useEffect)(()=>{wt(`settings`,i)},[i]),(0,Q.jsx)(wi,{title:n===null?t(`nativeAppCard.titleGeneric`):t(`nativeAppCard.title`,{appName:n}),subtitle:n===null?t(`nativeAppCard.subtitleGeneric`):t(`nativeAppCard.subtitle`,{appName:n}),benefits:[{icon:xn,text:t(`nativeAppCard.benefitPush`)},{icon:nr,text:t(`nativeAppCard.benefitBiometric`)},{icon:ir,text:t(`nativeAppCard.benefitHaptics`)},{icon:In,text:t(`nativeAppCard.benefitHomeScreen`)}],ctaLabel:t(`nativeAppCard.download`),ctaLeftIcon:(0,Q.jsx)(In,{size:16}),onAction:()=>{qe(`click`,`settings`,i),ie(i),r(i)}})}function Ei(){let e=gt(),t=Bt(),n=At(),r=Ue();return!e&&!t&&!n&&!r?null:(0,Q.jsx)(Ti,{promotion:_t(e||t?`ios`:n?`android`:null)})}var Di=`0.10.0`;function Oi(){return it(Di)}var ki=`/v1/remote-web/pairing-challenge`,Ai=`/v1/remote-web/pairing-verification`,ji=`/v1/remote-web/pairing-requests`,Mi=`${ji}/approve`,Ni=`${ji}/deny`;function Pi(){return G(`settings:pairDeviceClient.connectivityHint`)}var Fi=class extends Error{hint;status;code;constructor(e,t={}){super(e),this.name=`PairDeviceError`,this.hint=t.hint,this.status=t.status,this.code=t.code}},Ii=5e3;function Li(){if(typeof window>`u`)return null;let e=me(),t=_(e);return t?{base:`${window.location.origin}${t}`,assistantName:e?.name?.trim()||null,ingressUrl:e?.ingressUrl?.trim()||null}:null}function Ri(e){let t=e?.error?.message;return typeof t==`string`&&t.trim()?t:null}function zi(e){let t=e?.error?.code;return typeof t==`string`&&t?t:void 0}async function Bi(e,t,n,r){let i;try{i=await fetch(e,{...t,signal:n})}catch(e){throw x(e)?e:new Fi(G(`settings:pairDeviceClient.networkError`))}let a=await i.json().catch(()=>null);if(!i.ok)throw new Fi(Ri(a)??G(`settings:pairDeviceClient.httpError`,{status:i.status}),{hint:r,status:i.status,code:zi(a)});if(typeof a!=`object`||!a)throw new Fi(G(`settings:pairDeviceClient.unexpectedResponse`));return a}function Vi(e,t,n,r){return Bi(e,{method:`POST`,headers:{"Content-Type":`application/json`},body:JSON.stringify(t)},n,r)}async function Hi(e){let{base:t,publicBaseUrl:n,signal:r}=e,i=await Vi(`${t}${ki}`,{publicBaseUrl:n},r,Pi());try{await Vi(`${t}${Ai}`,{userCode:i.userCode},r,Pi())}catch(e){let n=AbortSignal.timeout(Ii);throw x(e)?Ui(t,i.userCode,n):await Ui(t,i.userCode,r?AbortSignal.any([r,n]):n),e}return{pairUrl:We(i),expiresAt:i.expiresAt}}async function Ui(e,t,n){try{let r=(await Wi({base:e,signal:n})).find(e=>e.userCode===t);r&&await qi({base:e,requestId:r.requestId,signal:n})}catch(e){if(x(e))return;B(e,{context:`pair-device-orphan-cleanup`,bestEffort:!0})}}async function Wi(e){let t=await Bi(`${e.base}${ji}`,{method:`GET`},e.signal);return Array.isArray(t.requests)?t.requests:[]}async function Gi(e,t){await Vi(`${t.base}${e}`,{requestId:t.requestId},t.signal)}function Ki(e){return Gi(Mi,e)}function qi(e){return Gi(Ni,e)}var Ji=Object.defineProperty,Yi=Object.getOwnPropertySymbols,Xi=Object.prototype.hasOwnProperty,Zi=Object.prototype.propertyIsEnumerable,Qi=(e,t,n)=>t in e?Ji(e,t,{enumerable:!0,configurable:!0,writable:!0,value:n}):e[t]=n,$i=(e,t)=>{for(var n in t||={})Xi.call(t,n)&&Qi(e,n,t[n]);if(Yi)for(var n of Yi(t))Zi.call(t,n)&&Qi(e,n,t[n]);return e},ea=(e,t)=>{var n={};for(var r in e)Xi.call(e,r)&&t.indexOf(r)<0&&(n[r]=e[r]);if(e!=null&&Yi)for(var r of Yi(e))t.indexOf(r)<0&&Zi.call(e,r)&&(n[r]=e[r]);return n},ta;(e=>{let t=class t{constructor(e,n,r,a){if(this.version=e,this.errorCorrectionLevel=n,this.modules=[],this.isFunction=[],e<t.MIN_VERSION||e>t.MAX_VERSION)throw RangeError(`Version value out of range`);if(a<-1||a>7)throw RangeError(`Mask value out of range`);this.size=e*4+17;let o=[];for(let e=0;e<this.size;e++)o.push(!1);for(let e=0;e<this.size;e++)this.modules.push(o.slice()),this.isFunction.push(o.slice());this.drawFunctionPatterns();let s=this.addEccAndInterleave(r);if(this.drawCodewords(s),a==-1){let e=1e9;for(let t=0;t<8;t++){this.applyMask(t),this.drawFormatBits(t);let n=this.getPenaltyScore();n<e&&(a=t,e=n),this.applyMask(t)}}i(0<=a&&a<=7),this.mask=a,this.applyMask(a),this.drawFormatBits(a),this.isFunction=[]}static encodeText(n,r){let i=e.QrSegment.makeSegments(n);return t.encodeSegments(i,r)}static encodeBinary(n,r){let i=e.QrSegment.makeBytes(n);return t.encodeSegments([i],r)}static encodeSegments(e,r,a=1,s=40,c=-1,l=!0){if(!(t.MIN_VERSION<=a&&a<=s&&s<=t.MAX_VERSION)||c<-1||c>7)throw RangeError(`Invalid value`);let u,d;for(u=a;;u++){let n=t.getNumDataCodewords(u,r)*8,i=o.getTotalBits(e,u);if(i<=n){d=i;break}if(u>=s)throw RangeError(`Data too long`)}for(let e of[t.Ecc.MEDIUM,t.Ecc.QUARTILE,t.Ecc.HIGH])l&&d<=t.getNumDataCodewords(u,e)*8&&(r=e);let f=[];for(let t of e){n(t.mode.modeBits,4,f),n(t.numChars,t.mode.numCharCountBits(u),f);for(let e of t.getData())f.push(e)}i(f.length==d);let p=t.getNumDataCodewords(u,r)*8;i(f.length<=p),n(0,Math.min(4,p-f.length),f),n(0,(8-f.length%8)%8,f),i(f.length%8==0);for(let e=236;f.length<p;e^=253)n(e,8,f);let m=[];for(;m.length*8<f.length;)m.push(0);return f.forEach((e,t)=>m[t>>>3]|=e<<7-(t&7)),new t(u,r,m,c)}getModule(e,t){return 0<=e&&e<this.size&&0<=t&&t<this.size&&this.modules[t][e]}getModules(){return this.modules}drawFunctionPatterns(){for(let e=0;e<this.size;e++)this.setFunctionModule(6,e,e%2==0),this.setFunctionModule(e,6,e%2==0);this.drawFinderPattern(3,3),this.drawFinderPattern(this.size-4,3),this.drawFinderPattern(3,this.size-4);let e=this.getAlignmentPatternPositions(),t=e.length;for(let n=0;n<t;n++)for(let r=0;r<t;r++)n==0&&r==0||n==0&&r==t-1||n==t-1&&r==0||this.drawAlignmentPattern(e[n],e[r]);this.drawFormatBits(0),this.drawVersion()}drawFormatBits(e){let t=this.errorCorrectionLevel.formatBits<<3|e,n=t;for(let e=0;e<10;e++)n=n<<1^(n>>>9)*1335;let a=(t<<10|n)^21522;i(a>>>15==0);for(let e=0;e<=5;e++)this.setFunctionModule(8,e,r(a,e));this.setFunctionModule(8,7,r(a,6)),this.setFunctionModule(8,8,r(a,7)),this.setFunctionModule(7,8,r(a,8));for(let e=9;e<15;e++)this.setFunctionModule(14-e,8,r(a,e));for(let e=0;e<8;e++)this.setFunctionModule(this.size-1-e,8,r(a,e));for(let e=8;e<15;e++)this.setFunctionModule(8,this.size-15+e,r(a,e));this.setFunctionModule(8,this.size-8,!0)}drawVersion(){if(this.version<7)return;let e=this.version;for(let t=0;t<12;t++)e=e<<1^(e>>>11)*7973;let t=this.version<<12|e;i(t>>>18==0);for(let e=0;e<18;e++){let n=r(t,e),i=this.size-11+e%3,a=Math.floor(e/3);this.setFunctionModule(i,a,n),this.setFunctionModule(a,i,n)}}drawFinderPattern(e,t){for(let n=-4;n<=4;n++)for(let r=-4;r<=4;r++){let i=Math.max(Math.abs(r),Math.abs(n)),a=e+r,o=t+n;0<=a&&a<this.size&&0<=o&&o<this.size&&this.setFunctionModule(a,o,i!=2&&i!=4)}}drawAlignmentPattern(e,t){for(let n=-2;n<=2;n++)for(let r=-2;r<=2;r++)this.setFunctionModule(e+r,t+n,Math.max(Math.abs(r),Math.abs(n))!=1)}setFunctionModule(e,t,n){this.modules[t][e]=n,this.isFunction[t][e]=!0}addEccAndInterleave(e){let n=this.version,r=this.errorCorrectionLevel;if(e.length!=t.getNumDataCodewords(n,r))throw RangeError(`Invalid argument`);let a=t.NUM_ERROR_CORRECTION_BLOCKS[r.ordinal][n],o=t.ECC_CODEWORDS_PER_BLOCK[r.ordinal][n],s=Math.floor(t.getNumRawDataModules(n)/8),c=a-s%a,l=Math.floor(s/a),u=[],d=t.reedSolomonComputeDivisor(o);for(let n=0,r=0;n<a;n++){let i=e.slice(r,r+l-o+(n<c?0:1));r+=i.length;let a=t.reedSolomonComputeRemainder(i,d);n<c&&i.push(0),u.push(i.concat(a))}let f=[];for(let e=0;e<u[0].length;e++)u.forEach((t,n)=>{(e!=l-o||n>=c)&&f.push(t[e])});return i(f.length==s),f}drawCodewords(e){if(e.length!=Math.floor(t.getNumRawDataModules(this.version)/8))throw RangeError(`Invalid argument`);let n=0;for(let t=this.size-1;t>=1;t-=2){t==6&&(t=5);for(let i=0;i<this.size;i++)for(let a=0;a<2;a++){let o=t-a,s=t+1&2?i:this.size-1-i;!this.isFunction[s][o]&&n<e.length*8&&(this.modules[s][o]=r(e[n>>>3],7-(n&7)),n++)}}i(n==e.length*8)}applyMask(e){if(e<0||e>7)throw RangeError(`Mask value out of range`);for(let t=0;t<this.size;t++)for(let n=0;n<this.size;n++){let r;switch(e){case 0:r=(n+t)%2==0;break;case 1:r=t%2==0;break;case 2:r=n%3==0;break;case 3:r=(n+t)%3==0;break;case 4:r=(Math.floor(n/3)+Math.floor(t/2))%2==0;break;case 5:r=n*t%2+n*t%3==0;break;case 6:r=(n*t%2+n*t%3)%2==0;break;case 7:r=((n+t)%2+n*t%3)%2==0;break;default:throw Error(`Unreachable`)}!this.isFunction[t][n]&&r&&(this.modules[t][n]=!this.modules[t][n])}}getPenaltyScore(){let e=0;for(let n=0;n<this.size;n++){let r=!1,i=0,a=[0,0,0,0,0,0,0];for(let o=0;o<this.size;o++)this.modules[n][o]==r?(i++,i==5?e+=t.PENALTY_N1:i>5&&e++):(this.finderPenaltyAddHistory(i,a),r||(e+=this.finderPenaltyCountPatterns(a)*t.PENALTY_N3),r=this.modules[n][o],i=1);e+=this.finderPenaltyTerminateAndCount(r,i,a)*t.PENALTY_N3}for(let n=0;n<this.size;n++){let r=!1,i=0,a=[0,0,0,0,0,0,0];for(let o=0;o<this.size;o++)this.modules[o][n]==r?(i++,i==5?e+=t.PENALTY_N1:i>5&&e++):(this.finderPenaltyAddHistory(i,a),r||(e+=this.finderPenaltyCountPatterns(a)*t.PENALTY_N3),r=this.modules[o][n],i=1);e+=this.finderPenaltyTerminateAndCount(r,i,a)*t.PENALTY_N3}for(let n=0;n<this.size-1;n++)for(let r=0;r<this.size-1;r++){let i=this.modules[n][r];i==this.modules[n][r+1]&&i==this.modules[n+1][r]&&i==this.modules[n+1][r+1]&&(e+=t.PENALTY_N2)}let n=0;for(let e of this.modules)n=e.reduce((e,t)=>e+ +!!t,n);let r=this.size*this.size,a=Math.ceil(Math.abs(n*20-r*10)/r)-1;return i(0<=a&&a<=9),e+=a*t.PENALTY_N4,i(0<=e&&e<=2568888),e}getAlignmentPatternPositions(){if(this.version==1)return[];{let e=Math.floor(this.version/7)+2,t=this.version==32?26:Math.ceil((this.version*4+4)/(e*2-2))*2,n=[6];for(let r=this.size-7;n.length<e;r-=t)n.splice(1,0,r);return n}}static getNumRawDataModules(e){if(e<t.MIN_VERSION||e>t.MAX_VERSION)throw RangeError(`Version number out of range`);let n=(16*e+128)*e+64;if(e>=2){let t=Math.floor(e/7)+2;n-=(25*t-10)*t-55,e>=7&&(n-=36)}return i(208<=n&&n<=29648),n}static getNumDataCodewords(e,n){return Math.floor(t.getNumRawDataModules(e)/8)-t.ECC_CODEWORDS_PER_BLOCK[n.ordinal][e]*t.NUM_ERROR_CORRECTION_BLOCKS[n.ordinal][e]}static reedSolomonComputeDivisor(e){if(e<1||e>255)throw RangeError(`Degree out of range`);let n=[];for(let t=0;t<e-1;t++)n.push(0);n.push(1);let r=1;for(let i=0;i<e;i++){for(let e=0;e<n.length;e++)n[e]=t.reedSolomonMultiply(n[e],r),e+1<n.length&&(n[e]^=n[e+1]);r=t.reedSolomonMultiply(r,2)}return n}static reedSolomonComputeRemainder(e,n){let r=n.map(e=>0);for(let i of e){let e=i^r.shift();r.push(0),n.forEach((n,i)=>r[i]^=t.reedSolomonMultiply(n,e))}return r}static reedSolomonMultiply(e,t){if(e>>>8||t>>>8)throw RangeError(`Byte out of range`);let n=0;for(let r=7;r>=0;r--)n=n<<1^(n>>>7)*285,n^=(t>>>r&1)*e;return i(n>>>8==0),n}finderPenaltyCountPatterns(e){let t=e[1];i(t<=this.size*3);let n=t>0&&e[2]==t&&e[3]==t*3&&e[4]==t&&e[5]==t;return(n&&e[0]>=t*4&&e[6]>=t?1:0)+(n&&e[6]>=t*4&&e[0]>=t?1:0)}finderPenaltyTerminateAndCount(e,t,n){return e&&(this.finderPenaltyAddHistory(t,n),t=0),t+=this.size,this.finderPenaltyAddHistory(t,n),this.finderPenaltyCountPatterns(n)}finderPenaltyAddHistory(e,t){t[0]==0&&(e+=this.size),t.pop(),t.unshift(e)}};t.MIN_VERSION=1,t.MAX_VERSION=40,t.PENALTY_N1=3,t.PENALTY_N2=3,t.PENALTY_N3=40,t.PENALTY_N4=10,t.ECC_CODEWORDS_PER_BLOCK=[[-1,7,10,15,20,26,18,20,24,30,18,20,24,26,30,22,24,28,30,28,28,28,28,30,30,26,28,30,30,30,30,30,30,30,30,30,30,30,30,30,30],[-1,10,16,26,18,24,16,18,22,22,26,30,22,22,24,24,28,28,26,26,26,26,28,28,28,28,28,28,28,28,28,28,28,28,28,28,28,28,28,28,28],[-1,13,22,18,26,18,24,18,22,20,24,28,26,24,20,30,24,28,28,26,30,28,30,30,30,30,28,30,30,30,30,30,30,30,30,30,30,30,30,30,30],[-1,17,28,22,16,22,28,26,26,24,28,24,28,22,24,24,30,28,28,26,28,30,24,30,30,30,30,30,30,30,30,30,30,30,30,30,30,30,30,30,30]],t.NUM_ERROR_CORRECTION_BLOCKS=[[-1,1,1,1,1,1,2,2,2,2,4,4,4,4,4,6,6,6,6,7,8,8,9,9,10,12,12,12,13,14,15,16,17,18,19,19,20,21,22,24,25],[-1,1,1,1,2,2,4,4,4,5,5,5,8,9,9,10,10,11,13,14,16,17,17,18,20,21,23,25,26,28,29,31,33,35,37,38,40,43,45,47,49],[-1,1,1,2,2,4,4,6,6,8,8,8,10,12,16,12,17,16,18,21,20,23,23,25,27,29,34,34,35,38,40,43,45,48,51,53,56,59,62,65,68],[-1,1,1,2,4,4,4,5,6,8,8,11,11,16,16,18,16,19,21,25,25,25,34,30,32,35,37,40,42,45,48,51,54,57,60,63,66,70,74,77,81]],e.QrCode=t;function n(e,t,n){if(t<0||t>31||e>>>t)throw RangeError(`Value out of range`);for(let r=t-1;r>=0;r--)n.push(e>>>r&1)}function r(e,t){return(e>>>t&1)!=0}function i(e){if(!e)throw Error(`Assertion error`)}let a=class e{constructor(e,t,n){if(this.mode=e,this.numChars=t,this.bitData=n,t<0)throw RangeError(`Invalid argument`);this.bitData=n.slice()}static makeBytes(t){let r=[];for(let e of t)n(e,8,r);return new e(e.Mode.BYTE,t.length,r)}static makeNumeric(t){if(!e.isNumeric(t))throw RangeError(`String contains non-numeric characters`);let r=[];for(let e=0;e<t.length;){let i=Math.min(t.length-e,3);n(parseInt(t.substring(e,e+i),10),i*3+1,r),e+=i}return new e(e.Mode.NUMERIC,t.length,r)}static makeAlphanumeric(t){if(!e.isAlphanumeric(t))throw RangeError(`String contains unencodable characters in alphanumeric mode`);let r=[],i;for(i=0;i+2<=t.length;i+=2){let a=e.ALPHANUMERIC_CHARSET.indexOf(t.charAt(i))*45;a+=e.ALPHANUMERIC_CHARSET.indexOf(t.charAt(i+1)),n(a,11,r)}return i<t.length&&n(e.ALPHANUMERIC_CHARSET.indexOf(t.charAt(i)),6,r),new e(e.Mode.ALPHANUMERIC,t.length,r)}static makeSegments(t){return t==``?[]:e.isNumeric(t)?[e.makeNumeric(t)]:e.isAlphanumeric(t)?[e.makeAlphanumeric(t)]:[e.makeBytes(e.toUtf8ByteArray(t))]}static makeEci(t){let r=[];if(t<0)throw RangeError(`ECI assignment value out of range`);if(t<128)n(t,8,r);else if(t<16384)n(2,2,r),n(t,14,r);else if(t<1e6)n(6,3,r),n(t,21,r);else throw RangeError(`ECI assignment value out of range`);return new e(e.Mode.ECI,0,r)}static isNumeric(t){return e.NUMERIC_REGEX.test(t)}static isAlphanumeric(t){return e.ALPHANUMERIC_REGEX.test(t)}getData(){return this.bitData.slice()}static getTotalBits(e,t){let n=0;for(let r of e){let e=r.mode.numCharCountBits(t);if(r.numChars>=1<<e)return 1/0;n+=4+e+r.bitData.length}return n}static toUtf8ByteArray(e){e=encodeURI(e);let t=[];for(let n=0;n<e.length;n++)e.charAt(n)==`%`?(t.push(parseInt(e.substring(n+1,n+3),16)),n+=2):t.push(e.charCodeAt(n));return t}};a.NUMERIC_REGEX=/^[0-9]*$/,a.ALPHANUMERIC_REGEX=/^[A-Z0-9 $%*+.\/:-]*$/,a.ALPHANUMERIC_CHARSET=`0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ $%*+-./:`;let o=a;e.QrSegment=a})(ta||={}),(e=>{(e=>{let t=class{constructor(e,t){this.ordinal=e,this.formatBits=t}};t.LOW=new t(0,1),t.MEDIUM=new t(1,0),t.QUARTILE=new t(2,3),t.HIGH=new t(3,2),e.Ecc=t})(e.QrCode||={})})(ta||={}),(e=>{(e=>{let t=class{constructor(e,t){this.modeBits=e,this.numBitsCharCount=t}numCharCountBits(e){return this.numBitsCharCount[Math.floor((e+7)/17)]}};t.NUMERIC=new t(1,[10,12,14]),t.ALPHANUMERIC=new t(2,[9,11,13]),t.BYTE=new t(4,[8,16,16]),t.KANJI=new t(8,[8,10,12]),t.ECI=new t(7,[0,0,0]),e.Mode=t})(e.QrSegment||={})})(ta||={});var na=ta,ra={L:na.QrCode.Ecc.LOW,M:na.QrCode.Ecc.MEDIUM,Q:na.QrCode.Ecc.QUARTILE,H:na.QrCode.Ecc.HIGH},ia=128,aa=`L`,oa=`#FFFFFF`,sa=`#000000`,ca=!1,la=1,ua=4,da=0,fa=.1;function pa(e,t=0){let n=[];return e.forEach(function(e,r){let i=null;e.forEach(function(a,o){if(!a&&i!==null){n.push(`M${i+t} ${r+t}h${o-i}v1H${i+t}z`),i=null;return}if(o===e.length-1){if(!a)return;i===null?n.push(`M${o+t},${r+t} h1v1H${o+t}z`):n.push(`M${i+t},${r+t} h${o+1-i}v1H${i+t}z`);return}a&&i===null&&(i=o)})}),n.join(``)}function ma(e,t){return e.slice().map((e,n)=>n<t.y||n>=t.y+t.h?e:e.map((e,n)=>n<t.x||n>=t.x+t.w?e:!1))}function ha(e,t,n,r){if(r==null)return null;let i=e.length+n*2,a=Math.floor(t*fa),o=i/t,s=(r.width||a)*o,c=(r.height||a)*o,l=r.x==null?e.length/2-s/2:r.x*o,u=r.y==null?e.length/2-c/2:r.y*o,d=r.opacity==null?1:r.opacity,f=null;if(r.excavate){let e=Math.floor(l),t=Math.floor(u);f={x:e,y:t,w:Math.ceil(s+l-e),h:Math.ceil(c+u-t)}}let p=r.crossOrigin;return{x:l,y:u,h:c,w:s,excavation:f,opacity:d,crossOrigin:p}}function ga(e,t){return t==null?e?ua:da:Math.max(Math.floor(t),0)}function _a({value:e,level:t,minVersion:n,includeMargin:r,marginSize:i,imageSettings:a,size:o,boostLevel:s}){let c=Z.useMemo(()=>{let r=(Array.isArray(e)?e:[e]).reduce((e,t)=>(e.push(...na.QrSegment.makeSegments(t)),e),[]);return na.QrCode.encodeSegments(r,ra[t],n,void 0,void 0,s)},[e,t,n,s]),{cells:l,margin:u,numCells:d,calculatedImageSettings:f}=Z.useMemo(()=>{let e=c.getModules(),t=ga(r,i);return{cells:e,margin:t,numCells:e.length+t*2,calculatedImageSettings:ha(e,o,t,a)}},[c,o,a,r,i]);return{qrcode:c,margin:u,cells:l,numCells:d,calculatedImageSettings:f}}var va=function(){try{new Path2D().addPath(new Path2D)}catch{return!1}return!0}(),ya=Z.forwardRef(function(e,t){let n=e,{value:r,size:i=ia,level:a=aa,bgColor:o=oa,fgColor:s=sa,includeMargin:c=ca,minVersion:l=la,boostLevel:u,marginSize:d,imageSettings:f}=n,p=ea(n,[`value`,`size`,`level`,`bgColor`,`fgColor`,`includeMargin`,`minVersion`,`boostLevel`,`marginSize`,`imageSettings`]),{style:m}=p,h=ea(p,[`style`]),g=f?.src,_=Z.useRef(null),v=Z.useRef(null),y=Z.useCallback(e=>{_.current=e,typeof t==`function`?t(e):t&&(t.current=e)},[t]),[b,x]=Z.useState(!1),{margin:S,cells:C,numCells:w,calculatedImageSettings:T}=_a({value:r,level:a,minVersion:l,boostLevel:u,includeMargin:c,marginSize:d,imageSettings:f,size:i});Z.useEffect(()=>{if(_.current!=null){let e=_.current,t=e.getContext(`2d`);if(!t)return;let n=C,r=v.current,a=T!=null&&r!==null&&r.complete&&r.naturalHeight!==0&&r.naturalWidth!==0;a&&T.excavation!=null&&(n=ma(C,T.excavation));let c=window.devicePixelRatio||1;e.height=e.width=i*c;let l=i/w*c;t.scale(l,l),t.fillStyle=o,t.fillRect(0,0,w,w),t.fillStyle=s,va?t.fill(new Path2D(pa(n,S))):C.forEach(function(e,n){e.forEach(function(e,r){e&&t.fillRect(r+S,n+S,1,1)})}),T&&(t.globalAlpha=T.opacity),a&&t.drawImage(r,T.x+S,T.y+S,T.w,T.h)}}),Z.useEffect(()=>{x(!1)},[g]);let E=$i({height:i,width:i},m),D=null;return g!=null&&(D=Z.createElement(`img`,{src:g,key:g,style:{display:`none`},onLoad:()=>{x(!0)},ref:v,crossOrigin:T?.crossOrigin})),Z.createElement(Z.Fragment,null,Z.createElement(`canvas`,$i({style:E,height:i,width:i,ref:y,role:`img`},h)),D)});ya.displayName=`QRCodeCanvas`;var ba=Z.forwardRef(function(e,t){let n=e,{value:r,size:i=ia,level:a=aa,bgColor:o=oa,fgColor:s=sa,includeMargin:c=ca,minVersion:l=la,boostLevel:u,title:d,marginSize:f,imageSettings:p}=n,m=ea(n,[`value`,`size`,`level`,`bgColor`,`fgColor`,`includeMargin`,`minVersion`,`boostLevel`,`title`,`marginSize`,`imageSettings`]),{margin:h,cells:g,numCells:_,calculatedImageSettings:v}=_a({value:r,level:a,minVersion:l,boostLevel:u,includeMargin:c,marginSize:f,imageSettings:p,size:i}),y=g,b=null;p!=null&&v!=null&&(v.excavation!=null&&(y=ma(g,v.excavation)),b=Z.createElement(`image`,{href:p.src,height:v.h,width:v.w,x:v.x+h,y:v.y+h,preserveAspectRatio:`none`,opacity:v.opacity,crossOrigin:v.crossOrigin}));let x=pa(y,h);return Z.createElement(`svg`,$i({height:i,width:i,viewBox:`0 0 ${_} ${_}`,ref:t,role:`img`},m),!!d&&Z.createElement(`title`,null,d),Z.createElement(`path`,{fill:o,d:`M0,0 h${_}v${_}H0z`,shapeRendering:`crispEdges`}),Z.createElement(`path`,{fill:s,d:x,shapeRendering:`crispEdges`}),b)});ba.displayName=`QRCodeSVG`;function xa(e,t){return!Number.isFinite(t)||t<=0?e(`pairDeviceReady.singleUse`):e(`pairDeviceReady.expiresIn`,{time:Gn(t)})}function Sa({pairUrl:e,remainingMs:t,expired:r,copied:i,onCopy:a}){let{t:o}=J(`settings`);return r?(0,Q.jsx)(V,{tone:`warning`,title:o(`pairDeviceReady.expiredTitle`),children:o(`pairDeviceReady.expiredBody`)}):(0,Q.jsxs)(`div`,{className:`flex flex-col gap-3`,children:[(0,Q.jsx)(`div`,{className:`w-fit rounded-lg bg-white p-3`,children:(0,Q.jsx)(ba,{value:e,size:192,level:`M`,title:o(`pairDeviceReady.qrTitle`)})}),(0,Q.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,Q.jsx)(`code`,{"data-testid":`pair-device-url`,className:`min-w-0 flex-1 truncate rounded-md bg-[var(--surface-active)] px-2.5 py-1.5 text-body-small-default text-[var(--content-secondary)]`,children:e}),(0,Q.jsx)(n,{variant:`outlined`,size:`compact`,leftIcon:i?(0,Q.jsx)(Ln,{}):(0,Q.jsx)(Mn,{}),onClick:()=>a(e),children:o(i?`pairDeviceReady.copiedButton`:`pairDeviceReady.copyButton`)})]}),(0,Q.jsx)(`p`,{className:`text-body-small-default text-[var(--content-tertiary)]`,children:xa(o,t)})]})}function Ca(e){return/iPhone|iPod/.test(e)?`iPhone`:/iPad/.test(e)||/Macintosh/.test(e)&&/Mobile/.test(e)?`iPad`:/Android/.test(e)?`Android`:/Macintosh|Mac OS X/.test(e)?`macOS`:/Windows/.test(e)?`Windows`:/CrOS/.test(e)?`ChromeOS`:/Linux/.test(e)?`Linux`:null}function wa(e){return/Edg\/|EdgA\/|EdgiOS\//.test(e)?`Edge`:/OPR\/|OPiOS\//.test(e)?`Opera`:/Firefox\/|FxiOS\//.test(e)?`Firefox`:/Chrome\/|CriOS\//.test(e)?`Chrome`:/Safari\//.test(e)?`Safari`:null}function Ta(e){if(!e||e.trim()===``)return null;let t=Ca(e),n=wa(e);return t===null&&n===null?null:{browser:n,os:t}}var Ea=5e3,Da=6e4;function Oa({pollWhilePairing:e=!1,revalidateKey:t,isExpanded:n=!1}={}){let[r,i]=(0,Z.useState)(null),[a,o]=(0,Z.useState)(null),[s,c]=(0,Z.useState)(!1),[l,u]=(0,Z.useState)(null),d=(0,Z.useRef)(!0),f=(0,Z.useRef)(0);(0,Z.useEffect)(()=>(d.current=!0,()=>{d.current=!1}),[]);let p=(0,Z.useCallback)((e=me()?.assistantId)=>{if(!e)return;i(t=>t&&t.assistantId!==e?null:t);let t=++f.current;Pt(e).then(n=>{!d.current||t!==f.current||i(n.ok?{assistantId:e,devices:n.devices}:null)})},[]),m=Be.use.selectedAssistantId()??me()?.assistantId;(0,Z.useEffect)(()=>{o(null),u(null),p(m)},[m,p]);let h=(0,Z.useRef)(t);(0,Z.useEffect)(()=>{t!==h.current&&(h.current=t,p(m))},[t,m,p]);let g=(0,Z.useRef)(!1);(0,Z.useEffect)(()=>{if(e&&!s){g.current=!0;let e=setInterval(()=>p(),Ea);return()=>clearInterval(e)}!e&&g.current&&(g.current=!1,p())},[e,s,p]);let _=(r?.devices.length??0)>0;(0,Z.useEffect)(()=>{if(!n||!_||e||s)return;let t=setInterval(()=>p(),Da);return()=>clearInterval(t)},[n,_,e,s,p]);let v=(0,Z.useCallback)(e=>{u(null),o(e)},[]),y=(0,Z.useCallback)(()=>{o(null),u(null)},[]),b=(0,Z.useCallback)(()=>{!r||!a||s||(c(!0),u(null),ot(r.assistantId,a.hashedDeviceId).then(e=>{d.current&&(c(!1),e.ok?(o(null),p()):u(e.error))}))},[r,a,s,p]);return{devices:r?.devices??null,confirmTarget:a,isRevoking:s,revokeError:l,requestRevoke:v,cancelRevoke:y,confirmRevoke:b}}var ka=600*1e3,Aa=`paired-devices`;function ja(e){return e.slice(0,12)}function Ma(e,t){return t?t.charAt(0).toUpperCase()+t.slice(1):e(`pairedDevicesSection.platformUnknown`)}function Na(e,t){if(typeof t.clientReportedName==`string`&&t.clientReportedName.trim()!==``)return{name:t.clientReportedName,isRealIdentity:!0};let n=Ta(t.pairingUserAgent);if(n!==null){let{browser:t,os:r}=n;return t!==null&&r!==null?{name:e(`pairedDevicesSection.browserOnOs`,{browser:t,os:r}),isRealIdentity:!0}:{name:t??r??``,isRealIdentity:!0}}return{name:Ma(e,t.platform),isRealIdentity:!1}}function Pa(e,t){return t===null?e(`pairedDevicesSection.dateUnknown`):new Date(t).toLocaleDateString(ne())}function Fa(e,t){let n=Pa(e,t.issuedAt);return t.lastUsedAt===null?e(`pairedDevicesSection.pairedLine`,{paired:n}):Date.now()-t.lastUsedAt<=ka?e(`pairedDevicesSection.pairedActiveLine`,{paired:n}):e(`pairedDevicesSection.pairedAndUsedLine`,{paired:n,lastUsed:Qn(t.lastUsedAt)})}function Ia({pollWhilePairing:e=!1,revalidateKey:t}={}){let{t:r}=J(`settings`),[i,a]=(0,Z.useState)(!1),o=Oa({pollWhilePairing:e,revalidateKey:t,isExpanded:i}),{devices:s,confirmTarget:c}=o;$n(s?.some(e=>e.lastUsedAt!==null)??!1);let l=(0,Z.useMemo)(()=>s===null?null:[...s].sort((e,t)=>(t.lastUsedAt??0)-(e.lastUsedAt??0)),[s]);return l===null||l.length===0?null:(0,Q.jsxs)(Q.Fragment,{children:[(0,Q.jsx)(H.Root,{type:`multiple`,value:i?[Aa]:[],onValueChange:e=>a(e.includes(Aa)),children:(0,Q.jsxs)(H.Item,{value:Aa,children:[(0,Q.jsxs)(H.Trigger,{className:`group flex w-full items-center justify-between gap-3`,children:[(0,Q.jsx)(`span`,{className:`text-body-medium-default text-[var(--content-secondary)]`,children:r(`pairedDevicesSection.title`,{count:l.length})}),(0,Q.jsx)(En,{className:`h-4 w-4 shrink-0 text-[var(--content-tertiary)] transition-transform group-data-[state=open]:rotate-180`})]}),(0,Q.jsx)(H.Content,{children:(0,Q.jsx)(`div`,{className:`mt-3 flex flex-col gap-3`,children:l.map(e=>{let t=Na(r,e);return(0,Q.jsxs)(`div`,{className:`flex items-center justify-between gap-3`,children:[(0,Q.jsxs)(`div`,{className:`flex min-w-0 flex-col`,children:[(0,Q.jsxs)(`span`,{className:`flex min-w-0 items-baseline gap-1 text-body-medium-default text-[var(--content-secondary)]`,children:[(0,Q.jsx)(`span`,{className:`min-w-0 truncate`,title:t.isRealIdentity?e.hashedDeviceId:void 0,children:t.name}),!t.isRealIdentity&&(0,Q.jsx)(`span`,{className:`shrink-0 font-mono text-[var(--content-tertiary)]`,title:e.hashedDeviceId,children:ja(e.hashedDeviceId)}),e.isCurrentHost&&(0,Q.jsx)(`span`,{className:`shrink-0 text-[var(--content-tertiary)]`,children:`· ${r(`pairedDevicesSection.thisMachine`)}`})]}),(0,Q.jsx)(`span`,{className:`text-body-medium-default text-[var(--content-tertiary)]`,children:Fa(r,e)})]}),(0,Q.jsx)(n,{variant:`dangerOutline`,size:`compact`,className:`shrink-0`,disabled:e.isCurrentHost===!0,title:e.isCurrentHost?r(`pairedDevicesSection.hostRevokeDisabledTitle`):void 0,onClick:()=>o.requestRevoke(e),children:r(`pairedDevicesSection.revokeButton`)})]},e.hashedDeviceId)})})})]})}),(0,Q.jsx)(I,{open:c!==null,title:r(`pairedDevicesSection.confirmTitle`),message:c&&(0,Q.jsxs)(Q.Fragment,{children:[r(`pairedDevicesSection.confirmMessageNamed`,{name:Na(r,c).name,hash:ja(c.hashedDeviceId)}),o.revokeError&&(0,Q.jsx)(`span`,{className:`mt-2 block text-[var(--system-negative-strong)]`,children:o.revokeError})]}),confirmLabel:r(`pairedDevicesSection.revokeButton`),destructive:!0,isPending:o.isRevoking,onConfirm:o.confirmRevoke,onCancel:o.cancelRevoke})]})}var La=5e3;function Ra(e,t){return e.length===t.length&&t.every((t,n)=>e[n]?.requestId===t.requestId)}function za(e,t){let[n,r]=(0,Z.useState)([]),[i,a]=(0,Z.useState)(null),[o,s]=(0,Z.useState)(null),[c,l]=(0,Z.useState)(null),u=(0,Z.useRef)(null),d=(0,Z.useRef)(null),[f,p]=(0,Z.useState)(e);e!==f&&(p(e),r([]),a(null),s(null),l(null)),(0,Z.useEffect)(()=>()=>{d.current?.abort(),d.current=null},[e]),(0,Z.useEffect)(()=>{let t=async()=>{u.current?.abort();let t=new AbortController;u.current=t;try{let n=await Wi({base:e,signal:t.signal});if(t.signal.aborted)return;r(e=>Ra(e,n)?e:n),l(e=>e&&!e.sticky&&!n.some(t=>t.requestId===e.requestId)?null:e),s(null)}catch(e){if(t.signal.aborted)return;if(e instanceof Fi){s(e.message);return}B(e,{context:`pair-device-pending-requests-poll`}),s(G(`settings:usePendingPairingRequests.pollErrorFallback`))}};t();let n=setInterval(()=>void t(),La);return()=>{clearInterval(n),u.current?.abort()}},[e]);let m=(0,Z.useCallback)(async(n,i)=>{if(d.current)return;let o=new AbortController;d.current=o,a({requestId:n,action:i}),l(null);let s=()=>{u.current?.abort(),r(e=>e.filter(e=>e.requestId!==n))};try{if(await(i===`approve`?Ki:qi)({base:e,requestId:n,signal:o.signal}),o.signal.aborted)return;s(),i===`approve`&&t?.()}catch(e){if(o.signal.aborted)return;e instanceof Fi?i===`deny`&&e.status===409&&e.code===`ALREADY_APPROVED`?(s(),t?.(),l({requestId:n,message:G(`settings:usePendingPairingRequests.denyAlreadyApproved`),sticky:!0})):e.status===404||e.status===410?s():l({requestId:n,message:e.message}):(B(e,{context:`pair-device-pending-request-action`}),l({requestId:n,message:G(`settings:usePendingPairingRequests.actionErrorFallback`)}))}finally{d.current===o&&(d.current=null),o.signal.aborted||a(null)}},[e,t]),h=(0,Z.useCallback)(e=>m(e,`approve`),[m]),g=(0,Z.useCallback)(e=>m(e,`deny`),[m]);return{requests:n,actingOn:i,error:c?.message??o,approve:h,deny:g}}function Ba({base:e,onApproved:t}){let{t:r}=J(`settings`),{requests:i,actingOn:a,error:o,approve:s,deny:c}=za(e,t);return $n(i.length>0),i.length===0&&!o?null:(0,Q.jsxs)(`section`,{className:`flex flex-col gap-3 border-t border-[var(--border-element)] pt-4`,children:[(0,Q.jsxs)(`div`,{className:`flex flex-col gap-1`,children:[(0,Q.jsx)(`h3`,{className:`text-title-small text-[var(--content-emphasised)]`,children:r(`pendingPairingRequests.title`)}),(0,Q.jsx)(`p`,{className:`text-body-small-default text-[var(--content-tertiary)]`,children:r(`pendingPairingRequests.instruction`)})]}),o&&(0,Q.jsx)(V,{tone:`error`,title:o}),i.length>0&&(0,Q.jsx)(`ul`,{className:`flex flex-col gap-2`,children:i.map(e=>{let t=a!==null&&a.requestId===e.requestId?a.action:null,i=t===`approve`,o=t===`deny`;return(0,Q.jsxs)(`li`,{className:`flex flex-col gap-2 rounded-lg border border-[var(--border-element)] p-3`,children:[(0,Q.jsx)(`code`,{className:kt(`rounded-md bg-[var(--surface-active)] text-body-small-default text-[color:var(--content-primary)]`,`w-fit px-2.5 py-1.5 text-title-medium tracking-wide text-[color:var(--content-emphasised)]`),children:e.userCode}),(0,Q.jsxs)(`div`,{className:`flex flex-col gap-0.5`,children:[(0,Q.jsx)(`p`,{className:`text-body-small-default text-[var(--content-tertiary)]`,children:e.viaEdgeProxy===!1?r(`pendingPairingRequests.requestedMetaHost`,{when:Qn(e.requestedAt)}):r(`pendingPairingRequests.requestedMeta`,{when:Qn(e.requestedAt),ip:e.requesterIp})}),e.requesterUserAgent&&(0,Q.jsx)(`p`,{className:`truncate text-body-small-default text-[var(--content-tertiary)]`,title:e.requesterUserAgent,children:e.requesterUserAgent})]}),(0,Q.jsxs)(`div`,{className:`flex gap-2`,children:[(0,Q.jsx)(n,{variant:`primary`,size:`compact`,disabled:a!==null,"aria-busy":i||void 0,leftIcon:i?(0,Q.jsx)(Y,{className:`animate-spin`}):void 0,onClick:()=>void s(e.requestId),children:r(`pendingPairingRequests.approveButton`)}),(0,Q.jsx)(n,{variant:`dangerOutline`,size:`compact`,disabled:a!==null,"aria-busy":o||void 0,leftIcon:o?(0,Q.jsx)(Y,{className:`animate-spin`}):void 0,onClick:()=>void c(e.requestId),children:r(`pendingPairingRequests.denyButton`)})]})]},e.requestId)})})]})}function Va({onRefresh:e,isRefreshing:t,labelled:r=!1}){let{t:i}=J(`settings`),a=i(`tunnelStatusRow.refreshLabel`),o=(0,Q.jsx)(Fn,{className:t?`animate-spin`:void 0});return r?(0,Q.jsx)(n,{variant:`outlined`,size:`compact`,leftIcon:o,disabled:t,onClick:e,children:a}):(0,Q.jsx)(n,{variant:`ghost`,size:`compact`,iconOnly:o,"aria-label":a,disabled:t,onClick:e})}function Ha(e){return`publicBaseUrl`in e&&e.publicBaseUrl?e.publicBaseUrl:null}function Ua(e){return`checkedAt`in e&&e.checkedAt?e.checkedAt:null}function Wa(e,t){let n=t?.trim();return n?`vellum tunnel ${Ka(n)} --provider ${e}`:`vellum tunnel --provider ${e}`}var Ga=/^[A-Za-z0-9._-]+$/;function Ka(e){return Ga.test(e)?e:`'${e.replace(/'/g,`'\\''`)}'`}var qa={checking:`var(--content-tertiary)`,stopped:`var(--content-tertiary)`,healthy:`var(--system-positive-strong)`,unpairable:`var(--system-mid-strong)`,unreachable:`var(--system-mid-strong)`,foreign:`var(--system-negative-strong)`},Ja=`text-body-small-default text-[var(--content-tertiary)]`,Ya=`truncate ${Ja}`;function Xa({status:e,onRefresh:t,isRefreshing:n,assistantName:r=null}){let{t:i}=J(`settings`);if(e.kind===`unconfigured`||e.kind===`unavailable`)return null;let a=Ua(e),o=Ha(e),s=`provider`in e?e.provider:void 0,c=`detail`in e?e.detail:void 0;return(0,Q.jsxs)(`div`,{className:`flex items-start gap-2.5 rounded-lg border border-[var(--border-element)] px-3 py-2.5`,children:[(0,Q.jsx)(`span`,{"aria-hidden":!0,className:`mt-1.5 inline-block h-2 w-2 shrink-0 rounded-full`,style:{backgroundColor:qa[e.kind]}}),(0,Q.jsxs)(`div`,{className:`flex min-w-0 flex-1 flex-col gap-1`,children:[(0,Q.jsx)(`p`,{className:`text-body-small-default text-[var(--content-default)]`,children:Za(e,i)}),c&&(0,Q.jsx)(`p`,{className:Ya,title:c,children:c}),s&&(0,Q.jsx)(`p`,{className:Ja,children:(0,Q.jsx)(cn,{i18nKey:e.kind===`stopped`?`tunnelStatusRow.stoppedRestart`:`tunnelStatusRow.restartHint`,ns:`settings`,values:{command:Wa(s,r)},components:{code:(0,Q.jsx)(`code`,{className:kt(`rounded-md bg-[var(--surface-active)] text-body-small-default text-[color:var(--content-primary)]`,`px-1.5 py-0.5`)})}})}),o&&(0,Q.jsx)(`p`,{className:Ya,title:o,children:o}),a&&(0,Q.jsx)(`p`,{className:Ja,children:i(`tunnelStatusRow.checkedAt`,{when:Qn(a)})})]}),(0,Q.jsx)(Va,{onRefresh:t,isRefreshing:n})]})}function Za(e,t){switch(e.kind){case`checking`:return t(`tunnelStatusRow.checkingStatus`);case`stopped`:return t(`tunnelStatusRow.stoppedStatus`);case`healthy`:return t(`tunnelStatusRow.healthyStatus`);case`unpairable`:return t(`tunnelStatusRow.unpairableStatus`);case`unreachable`:return t(`tunnelStatusRow.unreachableStatus`);case`foreign`:return e.servingAssistantName?t(`tunnelStatusRow.foreignStatusNamed`,{name:e.servingAssistantName}):t(`tunnelStatusRow.foreignStatus`)}}var Qa=`vellum:pair-device:public-base-url`;function $a(e){let t=e?.trim();if(t)return{url:t,source:`tunnel`};let n=nt(Qa,``).trim();return n?{url:n,source:`stored`}:{url:``,source:`none`}}function eo(e,t){let n=(0,Z.useMemo)(()=>$a(t),[t]),[r,i]=(0,Z.useState)(null),a=r??n.url,[o,s]=(0,Z.useState)(null),[c,l]=(0,Z.useState)({kind:`idle`}),[u,d]=(0,Z.useState)(()=>Date.now()),f=(0,Z.useRef)(null);(0,Z.useEffect)(()=>()=>f.current?.abort(),[]),(0,Z.useEffect)(()=>{if(c.kind!==`ready`)return;d(Date.now());let e=setInterval(()=>d(Date.now()),1e3);return()=>clearInterval(e)},[c]);let p=(0,Z.useCallback)(e=>{i(e),s(null)},[]),m=(0,Z.useCallback)(()=>{if(!e)return;let t=a.trim(),n=Tt(t);if(!n.ok){s(bt(n.reason,t));return}s(null),f.current?.abort();let r=new AbortController;f.current=r,l({kind:`minting`}),(async()=>{try{let t=await Hi({base:e,publicBaseUrl:n.url,signal:r.signal});if(r.signal.aborted)return;Ht(Qa,n.url),l({kind:`ready`,pairUrl:t.pairUrl,expiresAtMs:Date.parse(t.expiresAt)})}catch(e){if(r.signal.aborted)return;if(e instanceof Fi){l({kind:`error`,message:e.message,hint:e.hint});return}B(e,{context:`pair-device-mint`}),l({kind:`error`,message:G(`settings:usePairDevice.mintErrorFallback`)})}})()},[e,a]),h=c.kind===`ready`?Math.max(0,c.expiresAtMs-u):0,g=c.kind===`ready`&&h<=0;return{publicBaseUrl:a,setPublicBaseUrl:p,prefillSource:n.source,inputError:o,phase:c,remainingMs:h,expired:g,generate:m}}var to=`0.11.6`;function no(e){return Ze(to,e)}function ro(e){let t=tt(),n=no(t),r=m(),i=e&&n&&r,{data:a,isFetching:o,refetch:s}=K({...zt({path:{assistant_id:t}}),enabled:i,staleTime:0,refetchOnWindowFocus:!1}),c=(0,Z.useCallback)(()=>{i&&s()},[i,s]);return{status:io(a,o),isRefreshing:o,refresh:c}}function io(e,t){if(!e)return t?{kind:`checking`}:{kind:`unavailable`};let{lastTunnel:n}=e,r=e.publicBaseUrl??``,i=e.checkedAt??``,a=n?{provider:n.provider}:{};switch(e.state){case`unconfigured`:return{kind:`unconfigured`};case`stopped`:return{kind:`stopped`,...a,...n?{publicBaseUrl:n.publicBaseUrl}:{}};case`healthy`:return{kind:`healthy`,publicBaseUrl:r,checkedAt:i};case`unpairable`:case`unreachable`:return{kind:e.state,publicBaseUrl:r,checkedAt:i,...e.detail?{detail:e.detail}:{},...a};case`foreign`:return{kind:`foreign`,publicBaseUrl:r,checkedAt:i,...e.servingAssistantName?{servingAssistantName:e.servingAssistantName}:{},...a};default:return{kind:`unavailable`}}}var ao=`tailscale`,oo=`public-url`,so=new Set([`unpairable`,`unreachable`,`foreign`]),co=`vellum tunnel --help`,lo=ae(v.docs.pairADevice);function uo(){let{t:e}=J(`settings`),t=Li(),r=Oi(),i=R.use.pairedDevicesUI(),a=ro(r&&t!==null),s=a.status.kind!==`unavailable`;o(`app.resume`,()=>{a.refresh()}),$n(Ua(a.status)!==null);let c=a.status.kind===`stopped`?null:Ha(a.status),l=eo(t?.base??null,s?c:t?.ingressUrl??null),[u,d]=(0,Z.useState)(0),[f,p]=(0,Z.useState)(!1),{copy:m,copied:h}=he({errorMessage:e(`pairDeviceCard.copyError`)});if(!t||!r)return null;let g=t.assistantName??e(`pairDeviceCard.subtitleFallbackName`),{phase:_}=l,v=_.kind===`minting`,y=_.kind===`ready`,b=l.prefillSource===`tunnel`,x=s?a.status.kind===`unconfigured`:l.prefillSource===`none`&&l.publicBaseUrl.trim()===``,S=x&&s,C=s&&so.has(a.status.kind),w=e(v?`pairDeviceCard.generateButtonMinting`:y?`pairDeviceCard.generateButtonRegenerate`:C?`pairDeviceCard.generateButtonWarned`:`pairDeviceCard.generateButton`),T=s&&c!==null,E=f||l.inputError!==null,D=(0,Q.jsx)(n,{variant:C?`outlined`:`primary`,className:`self-start`,disabled:v||l.publicBaseUrl.trim()===``,onClick:l.generate,children:w}),O=(0,Q.jsx)(z,{label:e(`pairDeviceCard.publicUrlLabel`),fullWidth:!0,placeholder:e(`pairDeviceCard.publicUrlPlaceholder`),helperText:e(b?`pairDeviceCard.publicUrlHelperTunnel`:`pairDeviceCard.publicUrlHelper`),value:l.publicBaseUrl,errorText:l.inputError??void 0,disabled:v,onChange:e=>{p(!0),l.setPublicBaseUrl(e.target.value)},onKeyDown:e=>{e.key===`Enter`&&(e.preventDefault(),l.generate())}});return(0,Q.jsx)(X,{title:e(`pairDeviceCard.title`),subtitle:e(`pairDeviceCard.subtitle`,{name:g}),children:(0,Q.jsxs)(`div`,{className:`flex flex-col gap-4`,children:[x&&(0,Q.jsx)(V,{tone:`info`,title:e(`pairDeviceCard.noTunnelTitle`),actions:S?(0,Q.jsx)(Va,{onRefresh:a.refresh,isRefreshing:a.isRefreshing,labelled:!0}):void 0,children:(0,Q.jsxs)(`div`,{className:`flex flex-col gap-2`,children:[(0,Q.jsx)(`p`,{children:e(`pairDeviceCard.noTunnelWhy`,{name:g})}),(0,Q.jsx)(`code`,{className:kt(`rounded-md bg-[var(--surface-active)] text-body-small-default text-[color:var(--content-primary)]`,`w-fit max-w-full overflow-x-auto px-2.5 py-1.5`),children:Wa(ao,t.assistantName)}),(0,Q.jsx)(`p`,{children:e(`pairDeviceCard.noTunnelNext`)}),(0,Q.jsx)(`p`,{children:(0,Q.jsx)(cn,{i18nKey:`pairDeviceCard.noTunnelMore`,ns:`settings`,values:{command:co},components:{code:(0,Q.jsx)(`code`,{className:kt(`rounded-md bg-[var(--surface-active)] text-body-small-default text-[color:var(--content-primary)]`,`px-1.5 py-0.5`)})}})})]})}),(0,Q.jsx)(Xa,{status:a.status,onRefresh:a.refresh,isRefreshing:a.isRefreshing,assistantName:t.assistantName}),(0,Q.jsx)(`div`,{className:`flex flex-col gap-3`,children:T?(0,Q.jsxs)(Q.Fragment,{children:[D,(0,Q.jsx)(H.Root,{type:`single`,collapsible:!0,value:E?oo:``,onValueChange:e=>p(e===oo),children:(0,Q.jsxs)(H.Item,{value:oo,children:[(0,Q.jsxs)(H.Trigger,{className:`group flex w-full items-center justify-between gap-3`,children:[(0,Q.jsx)(`span`,{className:`text-body-medium-default text-[var(--content-secondary)]`,children:e(`pairDeviceCard.publicUrlDisclosure`)}),(0,Q.jsx)(En,{className:`h-4 w-4 shrink-0 text-[var(--content-tertiary)] transition-transform group-data-[state=open]:rotate-180`})]}),(0,Q.jsx)(H.Content,{children:(0,Q.jsx)(`div`,{className:`mt-3`,children:O})})]})})]}):(0,Q.jsxs)(Q.Fragment,{children:[O,D]})}),_.kind===`error`&&(0,Q.jsx)(V,{tone:`error`,title:_.message,children:_.hint}),y&&(0,Q.jsx)(Sa,{pairUrl:_.pairUrl,remainingMs:l.remainingMs,expired:l.expired,copied:h,onCopy:m}),(0,Q.jsx)(Ba,{base:t.base,onApproved:()=>d(e=>e+1)}),i&&(0,Q.jsx)(Ia,{pollWhilePairing:y&&!l.expired,revalidateKey:u}),(0,Q.jsx)(`a`,{href:lo,target:`_blank`,rel:`noopener noreferrer`,onClick:e=>jt(e,lo),className:`self-start text-body-medium-default text-[var(--content-tertiary)] underline hover:text-[var(--content-default)]`,children:e(`pairDeviceCard.learnMore`)})]})})}function fo(e){return[{scope:`global`,title:e(`shortcutsSections.globalTitle`),description:e(`shortcutsSections.globalDescription`)},{scope:`menu`,title:e(`shortcutsSections.appTitle`),description:e(`shortcutsSections.appDescription`)}]}function po({hotkey:e,recording:t,conflictLabel:r,alternateBinding:i,onStartRecording:a,onCancelRecording:o,onReset:s,onRemove:c}){let{t:l}=J(`settings`),u=e.accelerator===``,d=e.override!==null;return(0,Q.jsxs)(`div`,{className:`flex items-center justify-between gap-3 py-2`,children:[(0,Q.jsxs)(`div`,{className:`min-w-0`,children:[(0,Q.jsx)(`div`,{className:`truncate text-body-medium-lighter text-[var(--content-default)]`,children:e.label}),r!==null&&(0,Q.jsx)(`div`,{className:`text-body-small-default text-[var(--system-negative-strong)]`,children:l(`shortcutsSections.alreadyUsedBy`,{label:r})})]}),(0,Q.jsxs)(`div`,{className:`flex shrink-0 items-center gap-2`,children:[i,t?(0,Q.jsx)(`span`,{className:`text-body-small-default text-[var(--content-secondary)]`,children:l(`shortcutsSections.recordingHint`)}):u?(0,Q.jsx)(`span`,{className:`text-body-small-default italic text-[var(--content-disabled)]`,children:l(`shortcutsSections.none`)}):(0,Q.jsx)(Ct,{accelerator:e.accelerator}),t?(0,Q.jsx)(n,{variant:`ghost`,size:`compact`,onClick:o,children:l(`shortcutsSections.cancel`)}):(0,Q.jsx)(n,{variant:`outlined`,size:`compact`,onClick:a,"aria-label":l(`shortcutsSections.recordShortcutAriaLabel`,{label:e.label}),children:l(`shortcutsSections.record`)}),(0,Q.jsx)(n,{variant:`ghost`,size:`compact`,disabled:!d,leftIcon:(0,Q.jsx)(kn,{className:`h-3.5 w-3.5`}),onClick:s,"aria-label":l(`shortcutsSections.resetShortcutAriaLabel`,{label:e.label})}),(0,Q.jsx)(n,{variant:`ghost`,size:`compact`,disabled:u,leftIcon:(0,Q.jsx)(Pn,{className:`h-3.5 w-3.5`}),onClick:c,"aria-label":l(`shortcutsSections.removeBindingAriaLabel`,{label:e.label})})]})]})}function mo(){let{t:e}=J(`settings`),{catalog:t,recordingKey:n,conflict:r,startRecording:i,stopRecording:a,resetHotkey:o,removeHotkey:s}=tr(),c=(0,Z.useMemo)(()=>fo(e).map(e=>({...e,commands:t.filter(t=>t.rebindable&&t.scope===e.scope)})).filter(e=>e.commands.length>0),[t,e]);return(0,Q.jsxs)(`div`,{className:`space-y-4`,children:[r!==null&&(0,Q.jsxs)(V,{tone:`warning`,children:[e(`shortcutsSections.conflictNoticePrefix`,{label:r.label}),` `,e(n===null?`shortcutsSections.conflictResetHint`:`shortcutsSections.conflictRecordingHint`)]}),c.map(e=>(0,Q.jsxs)(Ie,{bordered:!0,children:[(0,Q.jsxs)(`div`,{className:`mb-2`,children:[(0,Q.jsx)(`div`,{className:`text-body-medium-default text-[var(--content-default)]`,children:e.title}),(0,Q.jsx)(`div`,{className:`text-body-small-default text-[var(--content-tertiary)]`,children:e.description})]}),(0,Q.jsx)(`div`,{className:`divide-y divide-[var(--border-base)]`,children:e.commands.map(e=>(0,Q.jsx)(po,{hotkey:e,recording:n===e.key,conflictLabel:r!==null&&r.key===e.key?r.label:null,onStartRecording:()=>i(e.key),onCancelRecording:a,onReset:()=>o(e.key),onRemove:()=>s(e.key)},e.key))})]},e.scope))]})}async function ho(){if(!E())return!1;let e=window.vellum;return e?.launchAtLogin?e.launchAtLogin.get():!1}async function go(e){if(!E())return;let t=window.vellum;t?.launchAtLogin&&await t.launchAtLogin.set(e)}function _o(){let{t:e}=J(`settings`),t=ve.useValue(),n=rn.useValue(),r=!Kt(),i=_e();return(0,Q.jsxs)(`section`,{children:[(0,Q.jsx)(`h3`,{className:`text-title-small text-[var(--content-emphasised)]`,children:e(`preferencesModal.composerTitle`)}),(0,Q.jsxs)(`div`,{className:`mt-2 space-y-4`,children:[r&&(0,Q.jsx)(T,{checked:t,onChange:ve.save,label:e(i?`preferencesModal.sendWithCmdEnter`:`preferencesModal.sendWithCtrlEnter`),helperText:e(i?`preferencesModal.sendWithCmdEnterHelper`:`preferencesModal.sendWithCtrlEnterHelper`)}),(0,Q.jsx)(T,{checked:n,onChange:rn.save,label:e(`preferencesModal.showContextWindow`),helperText:e(`preferencesModal.showContextWindowHelper`)})]})]})}function vo(){let{t:e}=J(`settings`),[t,n]=(0,Z.useState)(!1);(0,Z.useEffect)(()=>{ho().then(n)},[]);let r=async e=>{n(e);try{await go(e)}catch{n(!e)}};return(0,Q.jsxs)(`section`,{children:[(0,Q.jsx)(`h3`,{className:`text-title-small text-[var(--content-emphasised)]`,children:e(`preferencesModal.launchAtLoginTitle`)}),(0,Q.jsx)(`p`,{className:`text-body-medium-default text-[var(--content-tertiary)]`,children:e(Gt()===`windows`?`preferencesModal.launchAtLoginDescriptionWindows`:`preferencesModal.launchAtLoginDescription`)}),(0,Q.jsx)(`div`,{className:`mt-2`,children:(0,Q.jsx)(T,{checked:t,onChange:e=>void r(e),"aria-label":e(`preferencesModal.launchAtLoginAriaLabel`)})})]})}function yo({open:e,onClose:t}){let{t:n}=J(`settings`);return(0,Q.jsx)(b.Root,{open:e,onOpenChange:e=>{e||t()},children:(0,Q.jsxs)(b.Content,{size:`lg`,children:[(0,Q.jsxs)(b.Header,{children:[(0,Q.jsx)(b.Title,{children:n(`preferencesModal.title`)}),(0,Q.jsx)(b.Description,{children:n(`preferencesModal.description`)})]}),(0,Q.jsx)(b.Body,{children:(0,Q.jsxs)(`div`,{className:`space-y-6`,children:[E()&&(0,Q.jsxs)(`section`,{children:[(0,Q.jsx)(`h3`,{className:`text-title-small text-[var(--content-emphasised)]`,children:n(`preferencesModal.keyboardShortcutsTitle`)}),(0,Q.jsx)(`p`,{className:`text-body-medium-default text-[var(--content-tertiary)]`,children:n(`preferencesModal.keyboardShortcutsDescription`)}),(0,Q.jsx)(`div`,{className:`mt-2`,children:(0,Q.jsx)(mo,{})})]}),(0,Q.jsx)(_o,{}),E()&&(0,Q.jsx)(vo,{})]})})]})})}function bo(e){return e===`preview`?`preview`:`stable`}function xo(e,t){if(!e)return t;let n=new Date(e);return Number.isNaN(n.getTime())?t:n.toLocaleString(void 0,{year:`numeric`,month:`short`,day:`numeric`,hour:`numeric`,minute:`2-digit`})}function So(e){return e.filter(e=>e.ready_to_use)}function Co(e){return e?.feature_enabled===!1}function wo({assistantId:e,onComplete:t}){let{t:n}=J(`settings`),r=R.use.previewChannel(),i=q(),[a,o]=(0,Z.useState)(),[s,c]=(0,Z.useState)(!1),[l,u]=(0,Z.useState)(!1),[d,f]=(0,Z.useState)(`restore_backup`),[p,m]=(0,Z.useState)(``),h=Et({path:{assistant_id:e}}),g=pt({path:{assistant_id:e}}),_=Re({path:{id:e}}),{data:v,isLoading:y,isError:b}=K({...h,enabled:r,retry:!1}),x=(0,Z.useMemo)(()=>So(v?.preview_backups??[]),[v?.preview_backups]),S=x[0],C=x.find(e=>e.snapshot_name===p)??S,w=()=>{i.invalidateQueries({queryKey:g}),i.invalidateQueries({queryKey:_}),t?.()},T=sn(at()),E=sn(Ft()),D=bo(v?.current_channel),O=T.isPending||E.isPending,k=O||Co(v)||!v?.latest_preview_release,A=d===`restore_backup`&&!C;if((0,Z.useEffect)(()=>{o(D===`preview`?`release-channel`:void 0)},[D]),!r)return null;let j=v?.standard_upgrade_available??!1;return(0,Q.jsxs)(Q.Fragment,{children:[(0,Q.jsx)(H.Root,{type:`single`,collapsible:!0,value:a,onValueChange:e=>o(e||void 0),className:`mt-5 border-t border-[var(--border-base)] pt-5`,children:(0,Q.jsxs)(H.Item,{value:`release-channel`,id:`preview-release-channel`,children:[(0,Q.jsxs)(H.Trigger,{className:`group justify-between gap-3`,children:[(0,Q.jsxs)(`span`,{className:`flex min-w-0 items-center gap-2`,children:[(0,Q.jsx)(`span`,{className:`text-body-medium-default text-[var(--content-secondary)]`,children:n(`previewReleaseChannel.title`)}),v&&(0,Q.jsx)(N,{tone:D===`preview`?`warning`:`neutral`,children:n(D===`preview`?`previewReleaseChannel.preview`:`previewReleaseChannel.stable`)})]}),(0,Q.jsx)(En,{className:`h-4 w-4 shrink-0 text-[var(--content-tertiary)] transition-transform group-data-[state=open]:rotate-180`})]}),(0,Q.jsx)(H.Content,{children:(0,Q.jsxs)(`div`,{className:`mt-4 space-y-4`,children:[y&&(0,Q.jsxs)(`div`,{className:`flex items-center gap-2 text-body-medium-lighter text-[var(--content-tertiary)]`,children:[(0,Q.jsx)(Y,{className:`h-4 w-4 animate-spin`}),n(`previewReleaseChannel.loading`)]}),b&&(0,Q.jsx)(V,{tone:`error`,title:n(`previewReleaseChannel.loadErrorTitle`),children:n(`previewReleaseChannel.loadErrorBody`)}),v&&(0,Q.jsxs)(Q.Fragment,{children:[Co(v)&&(0,Q.jsx)(V,{tone:`neutral`,title:n(`previewReleaseChannel.unavailableTitle`),children:n(`previewReleaseChannel.unavailableBody`)}),D===`stable`?(0,Q.jsx)(To,{status:v,isChangingChannel:O,optInDisabled:k,onOptIn:()=>c(!0)}):(0,Q.jsx)(Eo,{status:v,isChangingChannel:O,onOptOut:()=>{let e=S;m(e?.snapshot_name??``),f(e?`restore_backup`:j?`standard_upgrade`:`restore_backup`),u(!0)}})]})]})})]})}),(0,Q.jsx)(Oo,{open:s,isPending:T.isPending,previewVersion:v?.latest_preview_release?.version,onConfirm:async()=>{try{let t=await T.mutateAsync({path:{assistant_id:e}});L.success(t.detail||n(`previewReleaseChannel.previewEnabledToast`)),c(!1),w()}catch(e){L.error(Pe(e,void 0,n(`previewReleaseChannel.previewEnableFailedToast`)))}},onCancel:()=>c(!1)}),(0,Q.jsx)(ko,{open:l,backups:x,mode:d,selectedSnapshotName:C?.snapshot_name??``,isPending:E.isPending,restoreModeDisabled:A,standardUpgradeAvailable:j,onModeChange:f,onSnapshotChange:m,onConfirm:async()=>{if(!A)try{let t=await E.mutateAsync({path:{assistant_id:e},body:d===`restore_backup`?{mode:`restore_backup`,snapshot_name:C?.snapshot_name}:{mode:`standard_upgrade`}});L.success(t.detail||n(`previewReleaseChannel.stableEnabledToast`)),u(!1),w()}catch(e){L.error(Pe(e,void 0,`Could not switch to Stable.`))}},onCancel:()=>u(!1)})]})}function To({status:e,isChangingChannel:t,optInDisabled:r,onOptIn:i}){let{t:a}=J(`settings`);return(0,Q.jsxs)(`div`,{className:`space-y-4`,children:[(0,Q.jsx)(Do,{status:e}),!e.latest_preview_release&&(0,Q.jsx)(V,{tone:`neutral`,title:a(`previewReleaseChannel.noPreviewTitle`),children:a(`previewReleaseChannel.noPreviewBody`)}),(0,Q.jsx)(n,{variant:`outlined`,leftIcon:t?(0,Q.jsx)(Y,{className:`animate-spin`}):(0,Q.jsx)(Cn,{}),disabled:r,onClick:i,children:a(`previewReleaseChannel.optIn`)})]})}function Eo({status:e,isChangingChannel:t,onOptOut:r}){let{t:i}=J(`settings`);return(0,Q.jsxs)(`div`,{className:`space-y-4`,children:[(0,Q.jsx)(Do,{status:e}),(0,Q.jsx)(n,{variant:`outlined`,leftIcon:t?(0,Q.jsx)(Y,{className:`animate-spin`}):(0,Q.jsx)(kn,{}),disabled:t,onClick:r,children:i(`previewReleaseChannel.switchBack`)})]})}function Do({status:e}){let{t}=J(`settings`);return(0,Q.jsxs)(`dl`,{className:`grid gap-3 text-body-medium-lighter sm:grid-cols-2`,children:[(0,Q.jsxs)(`div`,{children:[(0,Q.jsx)(`dt`,{className:`text-[var(--content-tertiary)]`,children:t(`previewReleaseChannel.latestStable`)}),(0,Q.jsx)(`dd`,{className:`break-all text-[var(--content-default)]`,children:e.latest_stable_release?.version??t(`previewReleaseChannel.none`)})]}),(0,Q.jsxs)(`div`,{children:[(0,Q.jsx)(`dt`,{className:`text-[var(--content-tertiary)]`,children:t(`previewReleaseChannel.latestPreview`)}),(0,Q.jsx)(`dd`,{className:`break-all text-[var(--content-default)]`,children:e.latest_preview_release?.version??t(`previewReleaseChannel.none`)})]})]})}function Oo({open:e,isPending:t,previewVersion:r,onConfirm:i,onCancel:a}){let{t:o}=J(`settings`);return(0,Q.jsx)(b.Root,{open:e,onOpenChange:e=>!e&&a(),children:(0,Q.jsxs)(b.Content,{size:`md`,hideCloseButton:t,children:[(0,Q.jsxs)(b.Header,{icon:Sn,children:[(0,Q.jsx)(b.Title,{children:o(`previewReleaseChannel.optInTitle`)}),(0,Q.jsx)(b.Description,{children:o(`previewReleaseChannel.optInDescription`)})]}),(0,Q.jsx)(b.Body,{children:(0,Q.jsxs)(`div`,{className:`space-y-3`,children:[(0,Q.jsx)(V,{tone:`warning`,title:o(`previewReleaseChannel.dataLossTitle`),children:o(`previewReleaseChannel.dataLossBody`)}),(0,Q.jsxs)(`ol`,{className:`list-decimal space-y-2 pl-5 text-body-medium-lighter text-[var(--content-secondary)]`,children:[(0,Q.jsx)(`li`,{children:o(`previewReleaseChannel.optInStep1`)}),(0,Q.jsx)(`li`,{children:o(`previewReleaseChannel.optInStep2`,{version:r??o(`previewReleaseChannel.latest`)})}),(0,Q.jsx)(`li`,{children:o(`previewReleaseChannel.optInStep3`)})]})]})}),(0,Q.jsxs)(b.Footer,{children:[(0,Q.jsx)(n,{variant:`outlined`,disabled:t,onClick:a,children:o(`previewReleaseChannel.cancel`)}),(0,Q.jsx)(n,{variant:`primary`,disabled:t,leftIcon:t?(0,Q.jsx)(Y,{className:`animate-spin`}):(0,Q.jsx)(Cn,{}),onClick:i,children:o(t?`previewReleaseChannel.switching`:`previewReleaseChannel.takeBackupAndSwitch`)})]})]})})}function ko({open:e,backups:t,mode:r,selectedSnapshotName:i,isPending:a,restoreModeDisabled:o,standardUpgradeAvailable:s,onModeChange:c,onSnapshotChange:l,onConfirm:d,onCancel:f}){let{t:m}=J(`settings`),h=m(`previewReleaseChannel.unknownDate`);return(0,Q.jsx)(b.Root,{open:e,onOpenChange:e=>!e&&f(),children:(0,Q.jsxs)(b.Content,{size:`md`,hideCloseButton:a,children:[(0,Q.jsxs)(b.Header,{icon:Sn,children:[(0,Q.jsx)(b.Title,{children:m(`previewReleaseChannel.optOutTitle`)}),(0,Q.jsx)(b.Description,{children:m(`previewReleaseChannel.optOutDescription`)})]}),(0,Q.jsx)(b.Body,{children:(0,Q.jsxs)(`div`,{className:`space-y-4`,children:[(0,Q.jsxs)(u,{value:r,onValueChange:c,disabled:a,"aria-label":m(`previewReleaseChannel.returnMethodAriaLabel`),children:[(0,Q.jsx)(an,{value:`restore_backup`,disabled:t.length===0,label:m(`previewReleaseChannel.restoreBackupLabel`),helperText:m(`previewReleaseChannel.restoreBackupHelper`)}),(0,Q.jsx)(an,{value:`standard_upgrade`,disabled:!s,label:m(`previewReleaseChannel.standardUpgradeLabel`),helperText:m(s?`previewReleaseChannel.standardUpgradeHelper`:`previewReleaseChannel.standardUpgradeUnavailable`)})]}),r===`restore_backup`&&t.length>0&&(0,Q.jsxs)(`label`,{className:`flex flex-col gap-1 text-body-medium-default text-[var(--content-secondary)]`,children:[m(`previewReleaseChannel.safetyBackup`),(0,Q.jsx)(p,{value:i,onChange:l,disabled:a,options:t.map(e=>{let t=e.source_release_version?m(`previewReleaseChannel.stableBackupLabel`,{version:e.source_release_version}):e.snapshot_name;return{value:e.snapshot_name,label:m(`previewReleaseChannel.backupOptionLabel`,{name:t,date:xo(e.created_at,h)})}})})]}),r===`restore_backup`&&t.length===0&&!s&&(0,Q.jsx)(V,{tone:`error`,title:m(`previewReleaseChannel.requiresBackupTitle`),children:m(`previewReleaseChannel.requiresBackupBody`)}),r===`standard_upgrade`&&(0,Q.jsx)(V,{tone:`error`,title:m(`previewReleaseChannel.mayNotSurviveTitle`),children:m(`previewReleaseChannel.mayNotSurviveBody`)})]})}),(0,Q.jsxs)(b.Footer,{children:[(0,Q.jsx)(n,{variant:`outlined`,disabled:a,onClick:f,children:m(`previewReleaseChannel.cancel`)}),(0,Q.jsx)(n,{variant:r===`standard_upgrade`?`danger`:`primary`,disabled:a||o||r===`standard_upgrade`&&!s,leftIcon:a?(0,Q.jsx)(Y,{className:`animate-spin`}):(0,Q.jsx)(Fn,{}),onClick:d,children:m(a?`previewReleaseChannel.switching`:`previewReleaseChannel.switchToStable`)})]})]})})}function Ao(){let{t:e}=J(`settings`),t=h.use.user(),n=(0,Z.useCallback)(e=>{j(e),window.location.reload()},[]);if(!Me(t))return null;let r=Lt(),i=te(),a=i.version??e(`previewUiChannel.versionUnknown`);return(0,Q.jsxs)(`div`,{className:`flex items-start justify-between gap-4`,children:[(0,Q.jsxs)(`div`,{className:`min-w-0`,children:[(0,Q.jsx)(`p`,{className:`text-body-medium-default text-[var(--content-default)]`,children:e(`previewUiChannel.title`)}),(0,Q.jsx)(`p`,{className:`text-body-small-lighter text-[var(--content-tertiary)]`,children:e(`previewUiChannel.description`)}),(0,Q.jsx)(`p`,{className:`text-body-small-lighter text-[var(--content-tertiary)]`,children:e(i.channel===`preview`?`previewUiChannel.runningPreview`:`previewUiChannel.runningStable`,{version:a})}),r&&i.channel===`stable`&&(0,Q.jsx)(`p`,{className:`text-body-small-lighter text-[var(--content-tertiary)]`,children:e(`previewUiChannel.unavailableHint`)})]}),(0,Q.jsx)(`div`,{className:`shrink-0`,children:(0,Q.jsx)(T,{checked:r,onChange:n,"aria-label":e(r?`previewUiChannel.onAriaLabel`:`previewUiChannel.offAriaLabel`)})})]})}var jo=new Set([`exceeds_machine_tier`,`exceeds_storage_tier`]);function Mo(e,t){return e&&typeof e==`object`&&!Array.isArray(e)&&`error`in e&&typeof e.error==`string`&&jo.has(e.error)?`That size isn't available on your plan.`:Pe(e,void 0,t)}function No({assistant:e,healthz:t,healthzLoading:r,healthzFetching:i,healthzPolling:a,refetch:o,refetchUntilResized:s}){let{t:c}=J(`settings`),l=hn(),u=K(A()),d=u.data,f=!e.is_local,m=d?.plan_id===`pro`,h=K({...ee(),enabled:m}),g=e.machine_size||`small`,_=Vn(h.data?.max_machine_tier??null),y=(0,Z.useMemo)(()=>Wn(_,g,(0,Q.jsx)(N,{tone:`positive`,children:c(`resizeCard.current`)})),[_,g,c]),x=h.data?.selected_storage_gib??null,[S,C]=(0,Z.useState)(!1),w=_.length>0?_[_.length-1]:null,[T,E]=(0,Z.useState)(null),D=T??w??g,[O,k]=(0,Z.useState)(!1),[j,M]=(0,Z.useState)(null),te=Wt({onSuccess:(e,n)=>{L.success(c(`resizeCard.toastStarted`),{id:`assistant-resize`}),M(null),E(null),C(!1),n.body?.machine_size==null?o():s(t)},onError:e=>{M(Mo(e,c(`resizeCard.resizeFailed`)))}});if(u.isError&&d==null)return(0,Q.jsx)(X,{id:`storage-resources`,title:c(`resizeCard.title`),subtitle:c(`resizeCard.subtitle`),children:(0,Q.jsx)(V,{tone:`error`,children:c(`resizeCard.subscriptionLoadError`)})});let ne=m&&_.includes(D)&&D!==g?D:null,P=m&&x!=null&&!0,re=m&&_.length>0&&Un(g)<Un(_[_.length-1]),F=te.isPending||a,ie=x==null?t?.disk?.totalMb??null:x*1024,I=t?.disk&&ie!=null?{value:t.disk.usedMb,max:ie,caption:c(`resizeCard.usedOf`,{used:Xn(t.disk.usedMb),total:Xn(ie)})}:null,ae=t?.cpu?{value:t.cpu.currentPercent,max:100,caption:`${t.cpu.currentPercent.toFixed(1)}%`}:null,oe=t?.memory?{value:t.memory.currentMb,max:t.memory.maxMb,caption:c(`resizeCard.usedOf`,{used:Xn(t.memory.currentMb),total:Xn(t.memory.maxMb)})}:null,se=(0,Q.jsx)(n,{variant:`ghost`,size:`compact`,onClick:()=>k(!0),children:c(`resizeCard.resize`)}),ce=f?m?P?(0,Q.jsxs)(`button`,{type:`button`,disabled:F,onClick:()=>C(!0),className:`flex items-center gap-1.5 rounded-lg border border-amber-500/30 bg-amber-500/15 px-3 py-1.5 text-body-small-default font-medium text-amber-400 transition-colors hover:bg-amber-500/25 disabled:opacity-50`,children:[(0,Q.jsx)(Dn,{className:`h-3.5 w-3.5`}),c(`resizeCard.increaseStorage`)]}):(0,Q.jsx)(n,{variant:`ghost`,size:`compact`,disabled:F,onClick:()=>C(!0),children:c(`resizeCard.resize`)}):se:null,le=f?m?re?(0,Q.jsxs)(`button`,{type:`button`,disabled:F,onClick:()=>C(!0),className:`flex items-center gap-1.5 rounded-lg border border-amber-500/30 bg-amber-500/15 px-3 py-1.5 text-body-small-default font-medium text-amber-400 transition-colors hover:bg-amber-500/25 disabled:opacity-50`,children:[(0,Q.jsx)(Dn,{className:`h-3.5 w-3.5`}),c(`resizeCard.increaseSize`)]}):(0,Q.jsx)(n,{variant:`ghost`,size:`compact`,disabled:F,onClick:()=>C(!0),children:c(`resizeCard.resize`)}):se:null;return(0,Q.jsxs)(Q.Fragment,{children:[(0,Q.jsx)(X,{id:`storage-resources`,title:c(`resizeCard.title`),subtitle:c(`resizeCard.subtitle`),compactAccessory:!0,accessory:(0,Q.jsx)(n,{variant:`ghost`,size:`compact`,iconOnly:i||a?(0,Q.jsx)(Y,{className:`animate-spin`}):(0,Q.jsx)(Fn,{}),tooltip:c(a?`resizeCard.applyingResize`:`resizeCard.refreshMetrics`),"aria-label":c(`resizeCard.refreshMetrics`),disabled:i||a,onClick:()=>void o()}),children:(0,Q.jsxs)(`div`,{className:`grid grid-cols-1 gap-2 sm:grid-cols-[1fr_2fr]`,children:[(0,Q.jsxs)(`div`,{className:`flex flex-col rounded-lg bg-[var(--surface-base)] p-3`,children:[(0,Q.jsxs)(`div`,{className:`flex items-center justify-between`,children:[(0,Q.jsxs)(`div`,{className:`flex items-center gap-1.5`,children:[(0,Q.jsx)(`span`,{className:`text-[var(--content-tertiary)]`,children:(0,Q.jsx)(jn,{className:`h-3.5 w-3.5`})}),(0,Q.jsx)(`span`,{className:`text-label-medium-default text-[var(--content-tertiary)]`,children:c(`resizeCard.disk`)})]}),ce]}),(0,Q.jsxs)(`div`,{className:`mt-auto flex flex-col gap-1 pt-3`,children:[(0,Q.jsx)(`span`,{className:`text-label-medium-default text-[var(--content-tertiary)]`,children:c(`resizeCard.storage`)}),I?(0,Q.jsx)(Kn,{value:I.value,max:I.max,caption:I.caption}):r?(0,Q.jsx)(`div`,{className:`flex items-center gap-2 text-[var(--content-tertiary)]`,children:(0,Q.jsx)(Y,{className:`h-3 w-3 animate-spin`})}):(0,Q.jsx)(`span`,{className:`text-label-medium-default text-[var(--content-tertiary)]`,children:c(`resizeCard.unavailable`)})]})]}),(0,Q.jsxs)(`div`,{className:`flex flex-col rounded-lg bg-[var(--surface-base)] p-3`,children:[(0,Q.jsxs)(`div`,{className:`flex items-center justify-between`,children:[(0,Q.jsxs)(`div`,{className:`flex items-center gap-1.5`,children:[(0,Q.jsx)(`span`,{className:`text-[var(--content-tertiary)]`,children:(0,Q.jsx)(rr,{className:`h-3.5 w-3.5`})}),(0,Q.jsx)(`span`,{className:`text-label-medium-default text-[var(--content-tertiary)]`,children:c(`resizeCard.machine`)}),(0,Q.jsx)(N,{tone:`neutral`,children:Hn[g]})]}),le]}),(0,Q.jsxs)(`div`,{className:`mt-auto grid grid-cols-2 gap-3 pt-3`,children:[(0,Q.jsxs)(`div`,{className:`flex flex-col gap-1`,children:[(0,Q.jsx)(`span`,{className:`text-label-medium-default text-[var(--content-tertiary)]`,children:c(`resizeCard.cpu`)}),ae?(0,Q.jsx)(Kn,{value:ae.value,max:ae.max,caption:ae.caption}):r?(0,Q.jsx)(`div`,{className:`flex items-center gap-2 text-[var(--content-tertiary)]`,children:(0,Q.jsx)(Y,{className:`h-3 w-3 animate-spin`})}):(0,Q.jsx)(`span`,{className:`text-label-medium-default text-[var(--content-tertiary)]`,children:`—`})]}),(0,Q.jsxs)(`div`,{className:`flex flex-col gap-1`,children:[(0,Q.jsx)(`span`,{className:`text-label-medium-default text-[var(--content-tertiary)]`,children:c(`resizeCard.memory`)}),oe?(0,Q.jsx)(Kn,{value:oe.value,max:oe.max,caption:oe.caption}):r?(0,Q.jsx)(`div`,{className:`flex items-center gap-2 text-[var(--content-tertiary)]`,children:(0,Q.jsx)(Y,{className:`h-3 w-3 animate-spin`})}):(0,Q.jsx)(`span`,{className:`text-label-medium-default text-[var(--content-tertiary)]`,children:`—`})]})]})]})]})}),(0,Q.jsx)(b.Root,{open:O,onOpenChange:e=>{e||k(!1)},children:(0,Q.jsxs)(b.Content,{size:`sm`,children:[(0,Q.jsxs)(b.Header,{children:[(0,Q.jsx)(b.Title,{children:c(`resizeCard.upgradeTitle`)}),(0,Q.jsx)(b.Description,{children:c(`resizeCard.upgradeDescription`)})]}),(0,Q.jsxs)(b.Footer,{children:[(0,Q.jsx)(n,{variant:`ghost`,onClick:()=>k(!1),children:c(`resizeCard.cancel`)}),(0,Q.jsx)(n,{onClick:()=>{k(!1),l(v.plans)},children:c(`resizeCard.upgrade`)})]})]})}),(0,Q.jsx)(b.Root,{open:S,onOpenChange:e=>{e||(C(!1),E(null),M(null))},children:(0,Q.jsxs)(b.Content,{size:`sm`,children:[(0,Q.jsxs)(b.Header,{icon:rr,children:[(0,Q.jsx)(b.Title,{children:c(`resizeCard.modalTitle`)}),(0,Q.jsx)(b.Description,{children:c(`resizeCard.modalDescription`)})]}),(0,Q.jsx)(b.Body,{children:(0,Q.jsxs)(`div`,{className:`flex flex-col gap-3`,children:[_.length===0?(0,Q.jsx)(V,{tone:`warning`,children:c(`resizeCard.noMachineTier`)}):(0,Q.jsxs)(`div`,{className:`flex flex-col gap-1.5`,children:[(0,Q.jsx)(`span`,{className:`text-label-medium-default text-[var(--content-secondary)]`,children:c(`resizeCard.machineSize`)}),(0,Q.jsx)(p,{options:y,value:D,onChange:E,"aria-label":c(`resizeCard.machineSizeAriaLabel`),"data-testid":`resize-machine-size`})]}),P?(0,Q.jsx)(V,{tone:`info`,children:c(`resizeCard.storageExpandTo`,{to:x})}):(0,Q.jsx)(V,{tone:`neutral`,children:c(`resizeCard.storageUnchanged`)}),j&&(0,Q.jsx)(V,{tone:`error`,children:j})]})}),(0,Q.jsxs)(b.Footer,{className:`items-center justify-between`,children:[(0,Q.jsx)(`span`,{className:`text-label-small-default text-[var(--content-tertiary)]`,children:(0,Q.jsx)(cn,{ns:`settings`,i18nKey:`resizeCard.needMore`,components:{upgradeLink:(0,Q.jsx)(gn,{to:v.plans,className:`text-[var(--content-secondary)] underline decoration-[var(--border-element)] underline-offset-2 transition-colors hover:text-[var(--content-default)]`,onClick:()=>C(!1)})}})}),(0,Q.jsxs)(`div`,{className:`flex gap-2`,children:[(0,Q.jsx)(n,{variant:`ghost`,onClick:()=>{C(!1),E(null),M(null)},children:c(`resizeCard.cancel`)}),(0,Q.jsx)(n,{disabled:ne==null&&!P||F,leftIcon:F?(0,Q.jsx)(Y,{className:`animate-spin`}):void 0,onClick:()=>{M(null);let t={};ne!=null&&(t.machine_size=ne),P&&x!=null&&(t.storage_gib=x),te.mutate({path:{id:e.id},body:t})},children:c(j?`resizeCard.retry`:`resizeCard.apply`)})]})]})]})})]})}function Po({assistantId:e}){let{t}=J(`settings`),r=hn(),i=q(),[a,o]=(0,Z.useState)(!1),[c,l]=(0,Z.useState)(!1);return(0,Q.jsxs)(Q.Fragment,{children:[(0,Q.jsx)(n,{variant:`dangerOutline`,onClick:()=>o(!0),className:`shrink-0`,children:t(`retireAssistant.button`)}),(0,Q.jsx)(ye,{open:a,isPending:c,onConfirm:async()=>{l(!0);let t=await s(i,e);if(t.ok){o(!1),r(t.nextRoute,{replace:!0});return}L.error(t.error),l(!1),o(!1)},onCancel:()=>o(!1)})]})}var Fo=`UTC.Africa/Cairo.Africa/Johannesburg.Africa/Lagos.Africa/Nairobi.America/Anchorage.America/Argentina/Buenos_Aires.America/Bogota.America/Chicago.America/Denver.America/Halifax.America/Lima.America/Los_Angeles.America/Mexico_City.America/New_York.America/Phoenix.America/Santiago.America/Sao_Paulo.America/Toronto.America/Vancouver.Asia/Bangkok.Asia/Dubai.Asia/Hong_Kong.Asia/Jakarta.Asia/Jerusalem.Asia/Karachi.Asia/Kolkata.Asia/Kuala_Lumpur.Asia/Manila.Asia/Seoul.Asia/Shanghai.Asia/Singapore.Asia/Taipei.Asia/Tokyo.Australia/Melbourne.Australia/Perth.Australia/Sydney.Europe/Amsterdam.Europe/Athens.Europe/Berlin.Europe/Brussels.Europe/Dublin.Europe/Istanbul.Europe/Lisbon.Europe/London.Europe/Madrid.Europe/Moscow.Europe/Paris.Europe/Rome.Europe/Stockholm.Europe/Vienna.Europe/Warsaw.Europe/Zurich.Pacific/Auckland.Pacific/Honolulu`.split(`.`);function Io(){let e=Intl;if(typeof e.supportedValuesOf==`function`)try{let t=e.supportedValuesOf(`timeZone`);if(t.length>0)return[...t].sort()}catch{}return[...Fo].sort()}function Lo(e,t,n){let r=parseInt(n??`0`,10);if(r>59)return null;let i=parseInt(t??`0`,10)*60+r;return(e===`-`?-1:1)*i}function Ro(e){let t=e.split(`/`),n=(t[t.length-1]??e).replace(/_/g,` `),r=t.length>1?(t[0]??``).replace(/_/g,` `):``,i=0,a=``;try{let t=new Intl.DateTimeFormat(`en-US`,{timeZone:e,timeZoneName:`shortOffset`}).formatToParts(new Date).find(e=>e.type===`timeZoneName`)?.value??`GMT`;a=t.startsWith(`GMT`)||t.startsWith(`UTC`)?t:`GMT ${t}`;let n=t.match(/([+-])(\d{1,2})(?::(\d{2}))?/);n&&(i=Lo(n[1],n[2],n[3])??0)}catch{return null}return{identifier:e,city:n,region:r,offsetLabel:a,offsetMinutes:i}}function zo(){return Io().map(e=>Ro(e)).filter(e=>e!==null)}function Bo(e){try{return new Intl.DateTimeFormat(`en-US`,{timeZone:e,hour:`numeric`,minute:`2-digit`,hour12:!0}).format(new Date)}catch{return``}}function Vo(e,t){if(!e)return t;try{let t=new Intl.DateTimeFormat(`en-US`,{timeZone:e,timeZoneName:`long`}).formatToParts(new Date).find(e=>e.type===`timeZoneName`)?.value;if(t)return t}catch{}return e.replace(/_/g,` `)}function Ho(e){if(e===`utc`||e===`gmt`)return 0;let t=e.match(/^(?:utc|gmt)?\s*([+-])(\d{1,2})(?::?(\d{2}))?$/);if(!t)return null;let n=Lo(t[1],t[2],t[3]);return n!==null&&Math.abs(n)<=840?n:null}var Uo=200,Wo=[];function Go({value:e,onChange:t}){let{t:n}=J(`settings`),[r,i]=(0,Z.useState)(``),[a,o]=(0,Z.useState)(!1),s=(0,Z.useMemo)(()=>a?zo():Wo,[a]),c=r.trim().toLowerCase(),l=(0,Z.useMemo)(()=>{let e=Ho(c);return(c?s.filter(t=>e===null?t.city.toLowerCase().includes(c)||t.region.toLowerCase().includes(c)||t.offsetLabel.toLowerCase().includes(c)||t.identifier.toLowerCase().includes(c):t.offsetMinutes===e):s).slice(0,Uo)},[s,c]),u=(0,Z.useMemo)(()=>l.map(e=>e.identifier),[l]),d=(0,Z.useMemo)(()=>{if(!e)return``;let t=e.split(`/`);return(t[t.length-1]??e).replace(/_/g,` `)},[e]);return(0,Q.jsxs)(`div`,{className:`space-y-3`,children:[(0,Q.jsxs)(`div`,{className:`flex flex-col gap-1.5 md:flex-row md:items-center md:justify-between md:gap-4`,children:[(0,Q.jsx)(`span`,{className:`text-body-medium-lighter text-[var(--content-tertiary)]`,children:n(`timezonePicker.timezone`)}),(0,Q.jsxs)(Ot.Root,{className:`w-full md:max-w-[280px]`,options:u,value:e,onSelect:t,onOpenChange:e=>{if(e){o(!0);return}i(``)},autoActivateFirst:c.length>0,children:[(0,Q.jsx)(Ot.Input,{type:`text`,"aria-label":n(`timezonePicker.timezone`),value:r,placeholder:d||n(`timezonePicker.searchPlaceholder`),onChange:e=>i(e.target.value),fullWidth:!0}),(0,Q.jsx)(Ot.List,{"aria-label":n(`timezonePicker.timezonesAriaLabel`),className:`absolute left-0 right-0 top-full z-20 mt-1 max-h-[240px] rounded-md border border-[var(--border-base)] bg-[var(--surface-lift)] shadow-lg`,emptyState:(0,Q.jsx)(`p`,{className:`px-3 py-2 text-body-medium-lighter text-[var(--content-tertiary)]`,children:n(`timezonePicker.noMatches`)}),children:l.map(e=>(0,Q.jsxs)(Ot.Option,{value:e.identifier,className:kt(`flex w-full items-center justify-between gap-3 px-3 py-2`,`text-body-medium-lighter text-[var(--content-default)] transition-colors`,`hover:bg-[var(--surface-active)]`,`data-[active]:bg-[var(--surface-active)] aria-selected:bg-[var(--surface-active)]`),children:[(0,Q.jsxs)(`div`,{className:`min-w-0 flex-1`,children:[(0,Q.jsx)(`div`,{className:`truncate text-body-medium-default`,children:e.city}),e.region&&(0,Q.jsx)(`div`,{className:`truncate text-body-small-default text-[var(--content-tertiary)]`,children:e.region})]}),(0,Q.jsxs)(`div`,{className:`flex shrink-0 flex-col items-end gap-0.5 text-body-small-default text-[var(--content-tertiary)]`,children:[(0,Q.jsx)(`span`,{children:Bo(e.identifier)}),(0,Q.jsx)(`span`,{children:e.offsetLabel})]})]},e.identifier))})]})]}),(0,Q.jsx)(er,{}),(0,Q.jsxs)(`div`,{className:`flex items-center justify-between gap-4`,children:[(0,Q.jsx)(`span`,{className:`text-body-medium-lighter text-[var(--content-tertiary)]`,children:n(`timezonePicker.zoneName`)}),(0,Q.jsx)(`span`,{className:`text-body-medium-lighter text-[var(--content-default)]`,children:Vo(e,n(`timezonePicker.notSet`))})]})]})}function Ko(){let{t:e}=J(`settings`),t=Be.use.activeAssistantId(),[n,r]=(0,Z.useState)(()=>c(`timezone`,``)),i=(0,Z.useRef)(t);(0,Z.useEffect)(()=>{i.current=t},[t]);let a=(0,Z.useRef)(!1),o=(0,Z.useRef)(null),s=(0,Z.useRef)(()=>{}),l=e=>{if(a.current){o.current=e;return}let t=i.current;if(!t){o.current=null;return}a.current=!0,o.current=null,U.patch({url:`/v1/assistants/{assistant_id}/config`,path:{assistant_id:t},body:{ui:{userTimezone:e}},throwOnError:!0}).catch(e=>{B(e,{context:`settings-timezone-override`})}).finally(()=>{a.current=!1;let e=o.current;o.current=null,e!==null&&s.current(e)})};return(0,Z.useEffect)(()=>{s.current=l}),(0,Q.jsxs)(`section`,{className:`flex flex-col gap-2`,children:[(0,Q.jsx)(`h3`,{className:`text-title-small text-[var(--content-emphasised)]`,children:e(`timezoneSection.title`)}),(0,Q.jsx)(`p`,{className:`text-body-medium-default text-[var(--content-tertiary)]`,children:e(`timezoneSection.description`)}),(0,Q.jsx)(`div`,{className:`mt-1`,children:(0,Q.jsx)(Go,{value:n,onChange:e=>{r(e),C(`timezone`,e),l(e)}})})]})}var qo=[0,1,2,3,4,5,6];function Jo(e){let[t,n]=e.split(`:`).map(Number),r=new Date,i=new Date(Date.UTC(r.getUTCFullYear(),r.getUTCMonth(),r.getUTCDate(),t,n));return`${i.getHours().toString().padStart(2,`0`)}:${i.getMinutes().toString().padStart(2,`0`)}`}function Yo(e){let[t,n]=e.split(`:`).map(Number),r=new Date,i=new Date(r.getFullYear(),r.getMonth(),r.getDate(),t,n);return`${i.getUTCHours().toString().padStart(2,`0`)}:${i.getUTCMinutes().toString().padStart(2,`0`)}`}function Xo(){return Intl.DateTimeFormat(void 0,{timeZoneName:`short`}).formatToParts(new Date).find(e=>e.type===`timeZoneName`)?.value??``}function Zo(e){let t=e?.schedule?.window.start??`06:00`,n=e?.schedule?.window.end??`08:00`;return{enabled:e?.enabled??!0,timezone:`UTC`,frequency:e?.schedule?.frequency??`weekly`,daysOfWeek:e?.schedule?.days_of_week??[0],daysOfMonth:e?.schedule?.days_of_month??[],windowStart:Jo(t),windowEnd:Jo(n)}}function Qo({assistantId:e}){let{t}=J(`settings`),r=q(),i=[t(`updateWindowPolicy.dayMon`),t(`updateWindowPolicy.dayTue`),t(`updateWindowPolicy.dayWed`),t(`updateWindowPolicy.dayThu`),t(`updateWindowPolicy.dayFri`),t(`updateWindowPolicy.daySat`),t(`updateWindowPolicy.daySun`)],{data:a,isLoading:o,isError:s}=K(en({path:{id:e}})),c=(0,Z.useMemo)(()=>Zo(a),[a]),[l,u]=(0,Z.useState)(null),f=l??c,p=l!==null,m=(0,Z.useMemo)(()=>Xo(),[]),[h,g]=(0,Z.useState)(null),_=h??f.daysOfMonth.join(`, `),v=sn({mutationFn:async t=>{let{data:n}=await d({path:{id:e},body:t,throwOnError:!0});return n}}),y=e=>{u(t=>({...t??c,...e}))},b=e=>{y({daysOfWeek:f.daysOfWeek.includes(e)?f.daysOfWeek.filter(t=>t!==e):[...f.daysOfWeek,e].sort((e,t)=>e-t)})},x=e=>e.split(`,`).map(e=>parseInt(e.trim(),10)).filter(e=>!isNaN(e)&&e>=1&&e<=31);return o?(0,Q.jsxs)(`div`,{className:`flex items-center gap-2 text-body-medium-lighter text-[var(--content-tertiary)]`,children:[(0,Q.jsx)(Y,{className:`h-4 w-4 animate-spin`}),t(`updateWindowPolicy.loading`)]}):s?(0,Q.jsx)(`p`,{className:`text-body-medium-lighter text-[var(--system-negative-strong)]`,children:t(`updateWindowPolicy.loadError`)}):(0,Q.jsxs)(`div`,{className:`space-y-6`,children:[(0,Q.jsx)(T,{checked:f.enabled,onChange:e=>y({enabled:e}),label:t(`updateWindowPolicy.automaticUpdates`),helperText:t(`updateWindowPolicy.automaticUpdatesHelper`)}),f.enabled&&(0,Q.jsxs)(`div`,{className:`space-y-5`,children:[(0,Q.jsxs)(`div`,{className:`space-y-2`,children:[(0,Q.jsx)(`label`,{className:`block text-body-small-default text-[var(--content-secondary)]`,children:t(`updateWindowPolicy.frequency`)}),(0,Q.jsx)(`div`,{className:`max-w-[400px]`,children:(0,Q.jsx)(re,{ariaLabel:t(`updateWindowPolicy.frequency`),value:f.frequency,onChange:e=>{e!==`monthly`&&g(null),y({frequency:e})},items:[{value:`daily`,label:t(`updateWindowPolicy.daily`)},{value:`weekly`,label:t(`updateWindowPolicy.weekly`)},{value:`monthly`,label:t(`updateWindowPolicy.monthly`)}]})})]}),f.frequency===`weekly`&&(0,Q.jsxs)(`div`,{className:`space-y-2`,children:[(0,Q.jsx)(`label`,{className:`block text-body-small-default text-[var(--content-secondary)]`,children:t(`updateWindowPolicy.daysOfWeek`)}),(0,Q.jsx)(`div`,{className:`flex flex-wrap gap-1.5`,children:qo.map(e=>(0,Q.jsx)(n,{variant:`outlined`,size:`compact`,active:f.daysOfWeek.includes(e),onClick:()=>b(e),children:i[e]},e))})]}),f.frequency===`monthly`&&(0,Q.jsx)(z,{label:t(`updateWindowPolicy.daysOfMonth`),type:`text`,value:_,onChange:e=>g(e.target.value),onBlur:e=>{let t=x(e.target.value);y({daysOfMonth:t}),g(t.join(`, `))},placeholder:t(`updateWindowPolicy.daysOfMonthPlaceholder`),helperText:t(`updateWindowPolicy.daysOfMonthHelper`),className:`w-48`}),(0,Q.jsxs)(`div`,{className:`space-y-2`,children:[(0,Q.jsx)(`label`,{className:`block text-body-small-default text-[var(--content-secondary)]`,children:m?t(`updateWindowPolicy.updateWindowWithTz`,{tz:m}):t(`updateWindowPolicy.updateWindow`)}),(0,Q.jsxs)(`div`,{className:`flex items-center gap-3`,children:[(0,Q.jsx)(z,{type:`time`,value:f.windowStart,onChange:e=>y({windowStart:e.target.value})}),(0,Q.jsx)(`span`,{className:`text-body-medium-lighter text-[var(--content-tertiary)]`,children:t(`updateWindowPolicy.to`)}),(0,Q.jsx)(z,{type:`time`,value:f.windowEnd,onChange:e=>y({windowEnd:e.target.value})})]})]})]}),(0,Q.jsx)(n,{variant:`primary`,leftIcon:v.isPending?(0,Q.jsx)(Y,{className:`animate-spin`}):void 0,onClick:async()=>{let n=f.frequency===`monthly`&&h!==null?x(h):f.daysOfMonth;try{await v.mutateAsync({enabled:f.enabled,timezone:`UTC`,schedule:{frequency:f.frequency,days_of_week:f.frequency===`weekly`?f.daysOfWeek:[],days_of_month:f.frequency===`monthly`?n:[],window:{start:Yo(f.windowStart),end:Yo(f.windowEnd)}}}),L.success(t(`updateWindowPolicy.toastSaved`)),u(null),g(null),r.invalidateQueries({queryKey:Se({path:{id:e}})})}catch{L.error(t(`updateWindowPolicy.toastSaveFailed`))}},disabled:v.isPending||!p,children:t(`updateWindowPolicy.savePolicy`)})]})}function $o({assistantId:e,open:t,onClose:n}){let{t:r}=J(`settings`);return(0,Q.jsx)(b.Root,{open:t,onOpenChange:e=>{e||n()},children:(0,Q.jsxs)(b.Content,{size:`md`,children:[(0,Q.jsxs)(b.Header,{children:[(0,Q.jsx)(b.Title,{children:r(`updateWindowModal.title`)}),(0,Q.jsx)(b.Description,{children:r(`updateWindowModal.description`)})]}),(0,Q.jsx)(b.Body,{children:(0,Q.jsx)(Qo,{assistantId:e})})]})})}function es(e){if(typeof e==`object`&&e&&`code`in e){let t=e.code;if(typeof t==`string`)return t}}function ts({open:e,onOpenChange:r}){let{t:a}=J(`settings`),o=q(),[s,c]=(0,Z.useState)(null),[l,u]=(0,Z.useState)(``),[d,f]=(0,Z.useState)(null),p=(0,Z.useRef)(!1),m=(0,Z.useRef)(e),h=()=>o.invalidateQueries({queryKey:Xt()}),g=e=>{i({path:{id:e}}).catch(()=>void 0).finally(()=>void h())},_=Dt({onSuccess:e=>{if(!m.current){g(e.factor_id);return}c(e)},onError:e=>{let t=es(e);t===`no_workos_account`?L.error(a(`enrollTotpModal.toastNoWorkosAccount`)):t===`throttled`||t===`workos_rate_limited`?L.error(a(`enrollTotpModal.toastThrottled`)):t===`factor_limit_reached`?L.error(a(`enrollTotpModal.toastFactorLimitReached`)):L.error(a(`enrollTotpModal.toastStartFailed`)),r(!1)}}),v=ut({onSuccess:e=>{e.valid?(p.current=!0,L.success(a(`enrollTotpModal.toastEnabled`)),h(),r(!1)):f(a(`enrollTotpModal.errorCodeMismatch`))},onError:e=>{let t=es(e);if(t===`challenge_already_verified`){p.current=!0,L.success(a(`enrollTotpModal.toastEnabled`)),h(),r(!1);return}if(t===`challenge_expired`||t===`challenge_not_found`){s&&g(s.factor_id),c(null),u(``),f(a(`enrollTotpModal.errorSessionExpired`)),_.mutate({});return}if(t===`throttled`||t===`workos_rate_limited`){f(a(`enrollTotpModal.errorThrottledInline`));return}f(a(`enrollTotpModal.errorVerifyFailed`))}});(0,Z.useEffect)(()=>{m.current=e,e&&(p.current=!1,c(null),u(``),f(null),_.mutate({}))},[e]);let y=e=>{!e&&v.isPending||(!e&&s&&!p.current&&g(s.factor_id),r(e))},x=()=>{s&&t(s.secret,{successMessage:a(`enrollTotpModal.copySuccess`),errorMessage:a(`enrollTotpModal.copyError`)})},S=()=>{!s||l.length!==6||v.isPending||(f(null),v.mutate({body:{challenge_id:s.challenge_id,code:l}}))};return(0,Q.jsx)(b.Root,{open:e,onOpenChange:y,children:(0,Q.jsxs)(b.Content,{size:`sm`,children:[(0,Q.jsxs)(b.Header,{children:[(0,Q.jsx)(b.Title,{children:a(`enrollTotpModal.title`)}),(0,Q.jsx)(b.Description,{children:a(`enrollTotpModal.description`)})]}),(0,Q.jsx)(b.Body,{children:s===null?(0,Q.jsx)(`div`,{className:`flex items-center justify-center py-10`,children:(0,Q.jsx)(Y,{className:`h-5 w-5 animate-spin text-[var(--content-tertiary)]`})}):(0,Q.jsxs)(`form`,{className:`flex flex-col items-center gap-4`,onSubmit:e=>{e.preventDefault(),S()},children:[(0,Q.jsx)(`img`,{src:s.qr_code,alt:a(`enrollTotpModal.qrCodeAlt`),className:`h-44 w-44 rounded-lg bg-white p-2`}),(0,Q.jsxs)(`div`,{className:`flex w-full flex-col gap-1`,children:[(0,Q.jsx)(`span`,{className:`text-body-small-default text-[var(--content-tertiary)]`,children:a(`enrollTotpModal.manualKeyHint`)}),(0,Q.jsxs)(`button`,{type:`button`,onClick:x,className:`flex cursor-pointer items-center gap-2 self-start font-mono text-body-small-default text-[var(--content-default)] hover:text-[var(--content-emphasised)]`,children:[(0,Q.jsx)(`span`,{className:`break-all text-left`,children:s.secret}),(0,Q.jsx)(Mn,{className:`h-3.5 w-3.5 shrink-0`})]})]}),(0,Q.jsxs)(`div`,{className:`flex w-full flex-col gap-1`,children:[(0,Q.jsx)(`label`,{htmlFor:`totp-code`,className:`text-body-small-default text-[var(--content-tertiary)]`,children:a(`enrollTotpModal.codeLabel`)}),(0,Q.jsx)(z,{id:`totp-code`,inputMode:`numeric`,autoComplete:`one-time-code`,maxLength:6,placeholder:a(`enrollTotpModal.codePlaceholder`),value:l,onChange:e=>u(e.target.value.replace(/\D/g,``).slice(0,6))}),d&&(0,Q.jsx)(`p`,{role:`alert`,className:`text-body-small-default text-[var(--system-negative-strong)]`,children:d})]})]})}),(0,Q.jsxs)(b.Footer,{children:[(0,Q.jsx)(n,{variant:`outlined`,onClick:()=>y(!1),disabled:v.isPending,children:a(`enrollTotpModal.cancel`)}),(0,Q.jsx)(n,{onClick:S,disabled:s===null||l.length!==6||v.isPending,children:v.isPending?a(`enrollTotpModal.verifying`):a(`enrollTotpModal.verify`)})]})]})})}function ns(e){let t=new Date(e);return Number.isNaN(t.getTime())?``:t.toLocaleDateString(void 0,{month:`short`,day:`numeric`,year:`numeric`})}function rs(){let{t:e}=J(`settings`),t=q(),[r,i]=(0,Z.useState)(!1),[a,o]=(0,Z.useState)(null),s=K({...ze()}),c=s.data??[],l=()=>t.invalidateQueries({queryKey:Xt()}),u=mt({onSuccess:()=>{L.success(e(`twoFactorSection.toastRemoved`)),l()},onError:t=>{if(es(t)===`factor_not_found`){l();return}L.error(e(`twoFactorSection.toastRemoveFailed`))}});return(0,Q.jsxs)(`div`,{className:`flex flex-col gap-4`,children:[s.isPending?(0,Q.jsxs)(`div`,{className:`flex items-center gap-2 text-[var(--content-tertiary)]`,children:[(0,Q.jsx)(Y,{className:`h-4 w-4 animate-spin`}),(0,Q.jsx)(`span`,{className:`text-body-medium-default`,children:e(`twoFactorSection.loading`)})]}):s.isError?(0,Q.jsx)(V,{tone:`error`,children:(0,Q.jsx)(cn,{ns:`settings`,i18nKey:`twoFactorSection.loadError`,components:{retryButton:(0,Q.jsx)(`button`,{type:`button`,className:`cursor-pointer underline`,onClick:()=>void s.refetch()})}})}):c.length===0?(0,Q.jsx)(`p`,{className:`text-body-medium-default text-[var(--content-tertiary)]`,children:e(`twoFactorSection.emptyDescription`)}):(0,Q.jsx)(`ul`,{className:`flex flex-col divide-y divide-[var(--border-base)]`,children:c.map(t=>(0,Q.jsxs)(`li`,{className:`flex items-center justify-between gap-3 py-3`,children:[(0,Q.jsxs)(`div`,{className:`flex min-w-0 items-center gap-3`,children:[(0,Q.jsx)(In,{className:`h-5 w-5 shrink-0 text-[var(--content-tertiary)]`}),(0,Q.jsxs)(`div`,{className:`min-w-0`,children:[(0,Q.jsx)(`div`,{className:`text-body-medium-default text-[var(--content-default)]`,children:e(`twoFactorSection.authenticatorApp`)}),(0,Q.jsxs)(`div`,{className:`truncate text-body-small-default text-[var(--content-tertiary)]`,children:[t.user,t.created_at?e(`twoFactorSection.addedOn`,{date:ns(t.created_at)}):``]})]})]}),(0,Q.jsx)(n,{variant:`dangerOutline`,onClick:()=>o(t),disabled:u.isPending,children:e(`twoFactorSection.remove`)})]},t.id))}),!s.isPending&&!s.isError&&c.length===0&&(0,Q.jsx)(n,{onClick:()=>i(!0),className:`self-start`,children:e(`twoFactorSection.addAuthenticatorApp`)}),(0,Q.jsx)(ts,{open:r,onOpenChange:i}),(0,Q.jsx)(I,{open:a!==null,title:e(`twoFactorSection.removeDialogTitle`),message:e(`twoFactorSection.removeDialogMessage`),confirmLabel:e(`twoFactorSection.removeDialogConfirm`),destructive:!0,onConfirm:()=>{a&&u.mutate({path:{id:a.id}}),o(null)},onCancel:()=>o(null)})]})}var $=class extends Error{code;constructor(e,t){super(t),this.name=`TeleportError`,this.code=e}},is=`local`,as=`docker`,os=`vellum`;function ss(e){switch((e??``).toLowerCase()){case is:return`local`;case as:return`docker`;case os:return`managed`;default:return`other`}}function cs(e){let t=ss(e);return t===`managed`?`local`:t===`local`?`platform`:null}function ls(e){switch(e){case`docker`:return`teleportCard.moveToDocker`;case`platform`:return`teleportCard.moveToPlatform`;case`local`:return`teleportCard.moveToLocal`}}var us={macos:`Macos`,windows:`Windows`,linux:`Linux`};function ds(e,t=`macos`){switch(e){case`docker`:return`teleportCard.dockerDescription${us[t]}`;case`platform`:return`teleportCard.platformDescription`;case`local`:return`teleportCard.localDescription${us[t]}`}}function fs(e){if(!e||typeof e!=`object`)return null;let t=e;if(t.reason!==`version_mismatch`)return null;let n=t.bundle_compat,r=t.target_runtime_version;if(!n||typeof n!=`object`||typeof r!=`string`)return null;let i=n,a=i.min_runtime_version;if(typeof a!=`string`)return null;let o=typeof i.max_runtime_version==`string`?i.max_runtime_version:null;return`Cannot import: bundle requires runtime ${o?`${a}–${o}`:`${a}+`}, but this local runtime is ${r}. Update your local runtime before importing.`}var ps=3600*1e3;function ms(e,t=Date.now(),n=ps){for(let r of e){if(!r)continue;let e=Date.parse(r);if(Number.isNaN(e))continue;let i=t-e;if(i>=0&&i<=n)return!0}return!1}function hs(e){return e.filter(e=>e.ready_to_use!==!1).map(e=>e.created_at)}function gs(e,t){return e.some(e=>e.snapshot_name===t&&e.ready_to_use===!0)}async function _s(e,t){let n=Number(e.headers.get(`Content-Length`)??0);if(!e.body||!t||n<=0){let n=await e.arrayBuffer();return t?.(1),n}let r=e.body.getReader(),i=[],a=0;for(;;){let{done:e,value:o}=await r.read();if(e)break;i.push(o),a+=o.length,t(a/n)}let o=new Uint8Array(a),s=0;for(let e of i)o.set(e,s),s+=e.length;return t(1),o.buffer}function vs(e){let t=_(e);if(!t)throw new $(`local_assistant_not_found`,`Assistant ${e.assistantId} has no resolved local gateway.`);return`${window.location.origin}${t}`}async function ys(e,t){let n=await qt(e.assistantId),r=await fetch(`${t}/auth/token`,{method:`POST`,headers:{Authorization:`Bearer ${n}`}});if(!r.ok)throw new $(`not_signed_in`,`Gateway token request failed (HTTP ${r.status}).`);let{token:i}=await r.json();return i}async function bs(e,t){let n=vs(e),r=await ys(e,n),i=await fetch(`${n}/v1/migrations/export`,{method:`POST`,headers:{Authorization:`Bearer ${r}`}});if(!i.ok)throw new $(`export_failed`,`Export failed (HTTP ${i.status}).`);return _s(i,t)}async function xs(e,t){let n=vs(e),r=await ys(e,n),i=await fetch(`${n}/v1/migrations/import`,{method:`POST`,headers:{Authorization:`Bearer ${r}`},body:new Blob([t],{type:`application/octet-stream`})});if(!i.ok)throw new $(`import_failed`,`Import failed (HTTP ${i.status}).`);let a=await Ts(i);if(a&&a.success===!1)throw new $(`import_failed`,a.error??`Import reported failure`)}async function Ss(e){let t=vs(e),n=await ys(e,t),r=await fetch(`${t}/v1/backups/create`,{method:`POST`,headers:{Authorization:`Bearer ${n}`}});if(!r.ok)throw new $(`backup_failed`,G(`settings:teleportCard.backupLocalFailed`,{status:r.status}));let i=await Ts(r);if(i&&i.success===!1)throw new $(`backup_failed`,G(`settings:teleportCard.backupLocalReportedFailure`))}async function Cs(e,t){let{data:n,response:r}=await U.post({url:`/v1/assistants/{assistant_id}/migrations/export-to-gcs/`,path:{assistant_id:e},body:{upload_url:t},throwOnError:!1}),i=r?.status??0;if(!(r?.ok??!1)&&i!==202)throw new $(`export_failed`,`Export failed (HTTP ${i}).`);let a=n?.job_id;if(!a)throw new $(`export_failed`,`Export accepted but no job ID was returned.`);return a}async function ws(e,t){let{data:n,response:r}=await U.get({url:`/v1/assistants/{assistant_id}/migrations/jobs/{job_id}`,path:{assistant_id:e,job_id:t},throwOnError:!1}),i=r?.status??0;if(i>=500)return`processing`;if(!(r?.ok??!1))throw new $(`export_job_failed`,`Job status check failed (HTTP ${i})`);let a=n;if(a?.status===`failed`)throw new $(`export_job_failed`,a.error??`Export job failed`);return a?.status??`processing`}async function Ts(e){try{return await e.json()}catch{return null}}async function Es(e,t={}){let n=ss(e.cloud);if(n===`managed`)return ks(e.assistantId,t);if(n===`local`)return Ss(e);throw new $(`backup_failed`,G(`settings:teleportCard.backupUnsupported`))}async function Ds(e){let t=await He({path:{assistant_id:e},throwOnError:!1});if(!(t.response?.ok??!1))throw new $(`backup_failed`,G(`settings:teleportCard.backupListFailed`,{status:t.response?.status??0}));let n=t.data?.backups;return Array.isArray(n)?n:[]}var Os=e=>new Promise(t=>setTimeout(t,e));async function ks(e,t){if(ms(hs(await Ds(e))))return;let n=await ht({path:{assistant_id:e},throwOnError:!1});if(!(n.response?.ok??!1))throw new $(`backup_failed`,G(`settings:teleportCard.backupCreateFailed`,{status:n.response?.status??0}));let r=n.data,i=r?.snapshot_name;if(!i)throw new $(`backup_failed`,G(`settings:teleportCard.backupNoSnapshotName`));if(r?.ready_to_use===!0)return;let a=t.readyTimeoutMs??6e5,o=t.readyPollIntervalMs??5e3,s=Date.now()+a;for(;Date.now()<s;)if(await Os(o),gs(await Ds(e),i))return;throw new $(`backup_failed`,G(`settings:teleportCard.backupNotReady`,{snapshot:i,seconds:Math.round(a/1e3)}))}var As=new Set([500,502,503,504]),js=3,Ms=e=>new Promise(t=>setTimeout(t,e));async function Ns(e,t=new Set){for(let n=0;n<=js;n++){let{response:r,data:i,error:a}=await e(),o=r?.status??0;if(n<js&&As.has(o)&&!t.has(o)){await Ms(2**n*1e3);continue}return{status:o,data:i,error:a}}throw new $(`unknown`,`Unexpected retry loop exit`)}async function Ps(e,t){let n={operation:`upload`};e&&(n.min_runtime_version=e,n.max_runtime_version=null),t&&(n.consumer=t);let{status:r,data:i}=await Ns(()=>U.post({url:`/v1/migrations/signed-url/`,body:n,throwOnError:!1}),new Set([404,503]));if(r===503||r===404)throw new $(`export_failed`,`Signed URL uploads are not available — the platform may not support this feature yet.`);if(r!==201)throw new $(`export_failed`,`Migration request failed (HTTP ${r}).`);let a=i;return{url:a.url,bundleKey:a.bundle_key,expiresAt:a.expires_at}}async function Fs(e,t){let{status:n,data:r,error:i}=await Ns(()=>U.post({url:`/v1/migrations/signed-url/`,body:{operation:`download`,bundle_key:e,target_runtime_version:t},throwOnError:!1}),new Set([422]));if(n===422){let e=fs(i);if(e)throw new $(`version_mismatch`,e)}if(n!==200&&n!==201)throw new $(`import_failed`,`Migration request failed (HTTP ${n}).`);return r.url}async function Is(e,t,n){for(let r=0;r<=js;r++){let i=await Ls(e,t,n);if(r<js&&As.has(i)){await Ms(2**r*1e3),n?.(0);continue}if(i<200||i>=300)throw new $(`export_failed`,`Bundle upload failed (HTTP ${i}).`);return}}function Ls(e,t,n){return new Promise((r,i)=>{let a=new XMLHttpRequest;a.open(`PUT`,e),a.setRequestHeader(`Content-Type`,`application/octet-stream`),a.timeout=36e5,n&&(a.upload.onprogress=e=>{e.lengthComputable&&n(e.loaded/e.total)}),a.onload=()=>{n?.(1),r(a.status)},a.onerror=()=>i(new $(`export_failed`,`Bundle upload failed.`)),a.ontimeout=()=>i(new $(`export_timed_out`,`Bundle upload timed out.`)),a.send(t)})}async function Rs(e,t){for(let n=0;n<=js;n++){let r=await fetch(e,{method:`GET`});if(n<js&&As.has(r.status)){await Ms(2**n*1e3),t?.(0);continue}if(!r.ok)throw new $(`import_failed`,`Bundle download failed (HTTP ${r.status}).`);return _s(r,t)}throw new $(`import_failed`,`Unexpected retry loop exit`)}async function zs(e){let{status:t,data:n,error:r}=await Ns(()=>U.post({url:`/v1/migrations/import-from-gcs/`,body:{bundle_key:e},throwOnError:!1}));return{status:t,body:n??r??null}}async function Bs(e){let{status:t,data:n}=await Ns(()=>U.get({url:`/v1/migrations/jobs/{job_id}/`,path:{job_id:e},throwOnError:!1}));if(t!==200)throw new $(`import_failed`,`Job status check failed (HTTP ${t})`);let r=n??{};return{status:typeof r.status==`string`?r.status:`unknown`,jobId:typeof r.job_id==`string`?r.job_id:null,error:typeof r.error==`string`?r.error:null}}var Vs=5e3,Hs=36e5,Us=5*6e4,Ws=30,Gs=e=>new Promise(t=>setTimeout(t,e));function Ks(){let e=hn(),t=q(),n=me(),r=cs(n?.cloud),[i,a]=(0,Z.useState)({kind:`idle`}),[o,c]=(0,Z.useState)(!1),l=(0,Z.useRef)(null),u=(0,Z.useRef)(null),d=(0,Z.useCallback)(e=>{a({kind:`transferring`,step:e,progress:null})},[]),f=(0,Z.useCallback)(e=>{a(t=>t.kind===`transferring`?{...t,progress:e}:t)},[]),p=(0,Z.useCallback)(async()=>{if(!(!n||!r)){u.current={id:n.assistantId,kind:ss(n.cloud)===`managed`?`managed`:`local`,createdFresh:!1};try{if(d(G(`settings:teleportCard.backupStep`)),await Es(n),r===`platform`)await qs(n,d,f,l);else if(r===`local`)await Js(n,d,f,l);else throw new $(`unknown`,G(`settings:teleportCard.unsupportedDestination`));a({kind:`verifying`})}catch(e){a({kind:`failed`,error:G(`settings:teleportCard.teleportFailed`,{message:e instanceof $||e instanceof Error?e.message:G(`settings:teleportCard.teleportFailedUnknown`)})}),B(e,{context:`teleport-execute`}),await Xs(t,l.current,u.current,`teleport-execute-cleanup`),l.current=null}}},[n,r,d,f,t]),m=(0,Z.useCallback)(()=>c(!0),[]),g=(0,Z.useCallback)(()=>c(!1),[]),_=(0,Z.useCallback)(()=>{c(!1),p()},[p]),y=(0,Z.useCallback)(()=>{l.current=null,u.current=null,a({kind:`idle`})},[]);return{destination:r,phase:i,confirmOpen:o,requestTeleport:m,cancelConfirm:g,confirm:_,confirmAndSwitch:(0,Z.useCallback)(()=>{let n=l.current,r=u.current;n&&(async()=>{try{let e=h.getState();n.kind===`managed`?await e.connectPlatformAssistant(n.id):(await e.connectLocalAssistant(n.id),M(n.id,{onError:e=>B(e,{context:`teleport-inject-platform-identity`})}))}catch(e){a({kind:`failed`,error:G(`settings:teleportCard.switchFailed`,{message:e instanceof Error?e.message:G(`settings:teleportCard.switchFailedUnknown`)})}),B(e,{context:`teleport-confirm-switch`});return}r&&s(t,r.id).then(e=>{e.ok||B(Error(e.error),{context:`teleport-retire-source`})}),y(),e(v.assistant,{replace:!0})})()},[e,y,t]),cancelTeleport:(0,Z.useCallback)(()=>{let e=l.current,n=u.current;l.current=null,u.current=null,a({kind:`idle`}),Xs(t,e,n,`teleport-cancel-retire-target`)},[t]),reset:y}}async function qs(e,t,n,r){t(G(`settings:teleportCard.stepExportingLocal`));let i=await bs(e,n);t(G(`settings:teleportCard.stepResolvingOrganization`));let a=await Qs();t(G(`settings:teleportCard.stepCheckingExisting`));let o=(await rt({query:{hosting:`platform`},throwOnError:!1})).data?.results?.[0];if(o)throw new $(`existing_platform_assistant`,G(`settings:teleportCard.existingPlatformAssistant`,{id:o.id}));t(G(`settings:teleportCard.stepUploading`));let s=await Ps(e.resources?.runtimeVersion);await Is(s.url,i,n),t(G(`settings:teleportCard.stepSettingUpCloud`));let c=await ge(void 0,`create`);if(!c.ok)throw new $(`import_failed`,G(`settings:teleportCard.cloudSetupFailed`));if(c.status===200)throw new $(`existing_platform_assistant`,G(`settings:teleportCard.existingPlatformAssistant`,{id:c.data.id}));let l=c.data.id;await Rt({assistantId:l,name:c.data.name,cloud:`vellum`,runtimeUrl:$t(),hatchedAt:c.data.created??new Date().toISOString(),organizationId:a}),await Ve(e.assistantId),r.current={id:l,kind:`managed`,createdFresh:!0},t(G(`settings:teleportCard.stepFinalizingCloud`)),await $s(l),t(G(`settings:teleportCard.stepImportingToCloud`));let u=await zs(s.bundleKey);if(u.status<200||u.status>=300){let e=u.body;throw new $(`import_failed`,e?.error??G(`settings:teleportCard.importFailedHttp`,{status:u.status}))}if(u.status===202){let e=u.body?.job_id;if(!e)throw new $(`import_failed`,G(`settings:teleportCard.importNoJobId`));await ec(e)}else{let e=u.body;if(e&&e.success===!1)throw new $(`import_failed`,e.error??G(`settings:teleportCard.importReportedFailure`))}}async function Js(e,t,n,r){t(G(`settings:teleportCard.stepPreparingExport`));let i=await Ps(await Zs(e.assistantId),`runtime`);t(G(`settings:teleportCard.stepExportingCloud`));let a=await Cs(e.assistantId,i.url);await tc(e.assistantId,a),t(G(`settings:teleportCard.stepPreparingLocal`));let{assistant:o,createdFresh:s}=await nc();r.current={id:o.assistantId,kind:`local`,createdFresh:s};let c=await Ys(o,s);if(!c)throw new $(`local_assistant_not_found`,G(`settings:teleportCard.localRuntimeVersionUnknown`));t(G(`settings:teleportCard.stepPreparingImport`));let l=await Fs(i.bundleKey,c);t(G(`settings:teleportCard.stepDownloading`));let u=await Rs(l,n);t(G(`settings:teleportCard.stepImporting`)),await ic(o,u),await Ve(e.assistantId)}async function Ys(e,t){if(e.resources?.runtimeVersion)return e.resources.runtimeVersion;if(t)return(await Bn())?.version??void 0}async function Xs(e,t,n,r){if(t?.createdFresh){let n=await s(e,t.id);n.ok||B(Error(n.error),{context:r})}n&&await Ve(n.id)}async function Zs(e){let t=await Fe(e);return t.ok?t.data.version??void 0:void 0}async function Qs(){let e=ue.getState();e.organizations.length===0&&await e.fetchOrganizations();let t=ue.getState().organizations,n=oe();if(n&&t.some(e=>e.id===n))return n;if(t.length===0)throw new $(`no_organizations`,G(`settings:teleportCard.noOrganizations`));if(t.length>1)throw new $(`multiple_organizations`,G(`settings:teleportCard.multipleOrganizations`));let r=t[0].id;return ue.getState().setCurrentOrganizationId(r),r}async function $s(e){let t=Date.now();for(;Date.now()-t<Us;){let{data:t,response:n}=await dt({path:{id:e},throwOnError:!1});if(n?.ok&&t?.state===`active`)return;await Gs(Vs)}}async function ec(e){let t=Date.now();for(;Date.now()-t<Hs;){await Gs(Vs);let t=await Bs(e);if(t.status===`complete`)return;if(t.status===`failed`)throw new $(`import_failed`,t.error??G(`settings:teleportCard.importJobFailed`))}throw new $(`import_failed`,G(`settings:teleportCard.importTimedOut`))}async function tc(e,t){let n=Date.now();for(;Date.now()-n<Hs;)if(await Gs(Vs),await ws(e,t)===`complete`)return;throw new $(`export_timed_out`,G(`settings:teleportCard.exportTimedOut`))}async function nc(){let e=await Ye(void 0,void 0);if(!e.ok)throw new $(`local_assistant_not_found`,e.error??G(`settings:teleportCard.localCreateFailed`));await S();let t=e.assistantId?we().find(t=>t.assistantId===e.assistantId):rc();if(!t)throw new $(`local_assistant_not_found`,G(`settings:teleportCard.localNotFound`));return{assistant:t,createdFresh:!0}}function rc(){return we().slice().sort((e,t)=>(t.hatchedAt??``).localeCompare(e.hatchedAt??``))[0]}async function ic(e,t){let n;for(let r=0;r<Ws;r++)try{await xs(e,t);return}catch(e){n=e,await Gs(1e3)}throw n instanceof Error?n:new $(`import_failed`,G(`settings:teleportCard.importFailed`))}function ac(){let{t:e}=J(`settings`),t=Ks(),{destination:r,phase:i}=t,a=R.use.teleport(),o=Qt();return!r||o===`gated`||i.kind===`idle`&&r===`platform`&&!a?null:(0,Q.jsxs)(X,{title:e(`teleportCard.title`),subtitle:e(`teleportCard.subtitle`),children:[i.kind===`idle`&&o===`disabled`&&(0,Q.jsx)(W,{children:e(`teleportCard.loginNotice`)}),i.kind===`idle`&&o===`full`&&(0,Q.jsxs)(`div`,{className:`flex flex-col gap-2`,children:[(0,Q.jsx)(`p`,{className:`text-body-medium-default text-[var(--content-tertiary)]`,children:e(ds(r,Gt()))}),(0,Q.jsx)(n,{variant:`outlined`,className:`self-start`,onClick:t.requestTeleport,children:e(ls(r))})]}),i.kind===`transferring`&&(0,Q.jsxs)(`div`,{className:`flex flex-col gap-2`,children:[(0,Q.jsxs)(`div`,{className:`flex items-center gap-2`,children:[i.progress==null&&(0,Q.jsx)(Y,{className:`h-4 w-4 animate-spin text-[var(--content-tertiary)]`}),(0,Q.jsx)(`span`,{className:`text-body-medium-default text-[var(--content-tertiary)]`,children:i.step})]}),i.progress!=null&&(0,Q.jsx)(Ne,{value:i.progress,"aria-label":e(`teleportCard.progressAriaLabel`),className:`max-w-[240px]`})]}),i.kind===`verifying`&&(0,Q.jsx)(V,{tone:`success`,icon:(0,Q.jsx)(On,{className:`h-4 w-4`}),title:e(`teleportCard.verifyTitle`),actions:(0,Q.jsxs)(`div`,{className:`flex gap-2`,children:[(0,Q.jsx)(n,{variant:`primary`,onClick:t.confirmAndSwitch,children:e(`teleportCard.confirmAndSwitch`)}),(0,Q.jsx)(n,{variant:`outlined`,onClick:t.cancelTeleport,children:e(`teleportCard.cancel`)})]})}),i.kind===`failed`&&(0,Q.jsx)(V,{tone:`error`,title:i.error,actions:(0,Q.jsx)(n,{variant:`outlined`,onClick:t.reset,children:e(`teleportCard.tryAgain`)})}),(0,Q.jsx)(I,{open:t.confirmOpen,title:e(ls(r)),message:e(`teleportCard.confirmMessage`),confirmLabel:e(`teleportCard.confirmLabel`),onConfirm:t.confirm,onCancel:t.cancelConfirm})]})}function oc(){let{t:e}=J(`settings`),{assistant:t,healthz:r,healthzLoading:i,healthzFetching:o,healthzPolling:s,refetch:c,refetchUntilResized:l}=Jn(),u=R.use.multiPlatformAssistant(),d=R.use.accountMfa(),f=Ge.use.settingsSleepPolicy(),p=a(),m=Ke(),h=be()||p||Ee()||m,g=hn(),_=Qt(),y=Qt({platformHostedOnly:!0}),b=Ce(),x=St({assistantId:t?.id??null,enabled:y===`full`&&b}),[S,C]=(0,Z.useState)(!1),[w,T]=(0,Z.useState)(!1),[D,O]=mn();(0,Z.useEffect)(()=>{if(D.get(`preferences`)!==`open`)return;let e=new URLSearchParams(D);e.delete(`preferences`),O(e,{replace:!0}),T(!0)},[D,O]);let k=t?.is_local&&!be()?null:t,A=me(),j=be()&&!!t&&!!A&&F(A),ee=j,M=j&&!Ee(),te=y===`full`&&!!k||M&&!!t;(0,Z.useEffect)(()=>{!t||window.location.hash!==`#storage-resources`||requestAnimationFrame(()=>{document.getElementById(`storage-resources`)?.scrollIntoView({block:`start`})})},[t]);let N=r?.version??t?.current_release_version??null,ne=()=>{let e=ce();if(Ee()&&!m&&e){let t=new URLSearchParams({register:Oe()}),n=yt();n&&t.set(`name`,n);let r=new URL(e).origin;window.location.assign(`${r}${v.selectAssistant}?${t.toString()}`);return}g(`${v.selectAssistant}?noAutoSkip=1`)},P=(_===`full`||ee)&&!!k||_===`disabled`&&!ee,re=y!==`gated`;return(0,Q.jsxs)(`div`,{className:`space-y-4`,children:[x.status&&x.mode!==`inactive`&&(0,Q.jsx)(Qe,{status:x.status,mode:x.mode,isAcknowledging:x.isAcknowledging,acknowledgeError:x.acknowledgeError?.message??null,onAcknowledge:()=>void x.acknowledge(),onReviewWorkspaceData:()=>void g(`${v.workspace}?sort=size`),onUpgradeStorage:y===`full`?()=>void g(v.plans):null}),(0,Q.jsxs)(vr,{assistant:b?k:null,showHandles:p&&_===`full`,children:[(0,Q.jsx)(Ko,{}),d&&_!==`gated`&&(0,Q.jsxs)(Q.Fragment,{children:[(0,Q.jsx)(`div`,{className:`border-t border-[var(--border-subtle)]`}),(0,Q.jsxs)(`section`,{className:`flex flex-col gap-2`,children:[(0,Q.jsx)(`h3`,{className:`text-title-small text-[var(--content-emphasised)]`,children:e(`generalPage.twoFactorTitle`)}),(0,Q.jsx)(`p`,{className:`text-body-medium-default text-[var(--content-tertiary)]`,children:e(`generalPage.twoFactorDescription`)}),(0,Q.jsx)(`div`,{className:`mt-1`,children:_===`disabled`?(0,Q.jsx)(W,{children:e(`generalPage.twoFactorLoginNotice`)}):(0,Q.jsx)(rs,{})})]})]})]}),(0,Q.jsx)(X,{title:e(`generalPage.versionTitle`),subtitle:e(`generalPage.versionSubtitle`),accessory:y===`full`&&k?(0,Q.jsx)(n,{variant:`outlined`,onClick:()=>C(!0),children:e(`generalPage.updateWindow`)}):void 0,children:(0,Q.jsxs)(`div`,{className:`flex flex-col gap-4`,children:[y===`full`&&k&&(0,Q.jsxs)(Q.Fragment,{children:[(0,Q.jsx)(xi,{assistantId:k.id,currentVersion:N,releaseChannel:k.release_channel,onUpgradeComplete:()=>{c()}}),(0,Q.jsx)(wo,{assistantId:k.id,onComplete:()=>{c()}})]}),M&&t&&(0,Q.jsx)(Si,{assistantId:t.id,currentVersion:N,onUpgradeComplete:()=>{c()}}),!te&&t&&(0,Q.jsxs)(`div`,{className:`grid grid-cols-[140px_minmax(0,1fr)] gap-y-3`,children:[(0,Q.jsx)(`span`,{className:`text-body-medium-default text-[var(--content-tertiary)]`,children:e(`generalPage.current`)}),(0,Q.jsx)(Yn,{version:N,loading:i&&!t.current_release_version,assistantId:t.id??null})]}),y===`disabled`&&!M&&(0,Q.jsx)(W,{children:e(`generalPage.updatesLoginNotice`)}),(0,Q.jsx)(Ao,{})]})}),y===`full`&&k&&(0,Q.jsx)($o,{assistantId:k.id,open:S,onClose:()=>C(!1)}),y===`full`&&t&&(0,Q.jsx)(No,{assistant:t,healthz:r,healthzLoading:i,healthzFetching:o,healthzPolling:s,refetch:c,refetchUntilResized:l}),y===`disabled`&&(0,Q.jsx)(X,{id:`storage-resources`,title:e(`generalPage.computeResourcesTitle`),subtitle:e(`generalPage.computeResourcesSubtitle`),children:(0,Q.jsx)(W,{children:e(`generalPage.computeResourcesLoginNotice`)})}),(0,Q.jsx)(X,{title:e(`generalPage.preferencesTitle`),subtitle:e(`generalPage.preferencesSubtitle`),accessory:(0,Q.jsx)(n,{variant:`outlined`,onClick:()=>T(!0),children:e(`generalPage.customize`)}),children:(0,Q.jsxs)(`div`,{className:`flex flex-col gap-5`,children:[(0,Q.jsx)(ar,{}),(0,Q.jsx)(li,{})]})}),(0,Q.jsx)(yo,{open:w,onClose:()=>T(!1)}),(0,Q.jsx)(Ei,{}),(0,Q.jsx)(uo,{}),y===`full`&&k&&f&&(0,Q.jsx)(X,{title:e(`generalPage.sleepPolicyTitle`),subtitle:e(`generalPage.sleepPolicySubtitle`),children:(0,Q.jsx)(_i,{assistantId:k.id})}),y===`disabled`&&f&&(0,Q.jsx)(X,{title:e(`generalPage.sleepPolicyTitle`),subtitle:e(`generalPage.sleepPolicySubtitle`),children:(0,Q.jsx)(W,{children:e(`generalPage.sleepPolicyLoginNotice`)})}),u&&!h&&(0,Q.jsx)(fi,{}),h&&(0,Q.jsx)(X,{title:e(`generalPage.switchAssistantTitle`),subtitle:e(`generalPage.switchAssistantSubtitle`),accessory:(0,Q.jsx)(n,{variant:`outlined`,onClick:ne,children:e(`generalPage.chooseAssistant`)})}),E()&&(0,Q.jsx)(ac,{}),(P||re)&&(0,Q.jsx)(X,{variant:`danger`,title:e(`generalPage.dangerZoneTitle`),children:(0,Q.jsxs)(`div`,{className:`flex flex-col gap-6`,children:[P&&(0,Q.jsxs)(`section`,{className:`flex flex-col gap-2`,children:[(0,Q.jsx)(`h3`,{className:`text-title-small text-[var(--content-emphasised)]`,children:e(`generalPage.retireAssistantTitle`)}),(0,Q.jsx)(`p`,{className:`text-body-medium-default text-[var(--content-tertiary)]`,children:e(`generalPage.retireAssistantDescription`)}),(0,Q.jsx)(`div`,{className:`mt-1`,children:(_===`full`||ee)&&k?(0,Q.jsx)(Po,{assistantId:k.id}):(0,Q.jsx)(W,{children:e(`generalPage.retireAssistantLoginNotice`)})})]}),P&&re&&(0,Q.jsx)(`div`,{className:`border-t border-[var(--border-subtle)]`}),(0,Q.jsx)(Ci,{})]})})]})}export{oc as GeneralPage};
2
+ import{o as e}from"./rolldown-runtime-BM3Ffeng.js";import{$_ as t,$x as n,A as r,Ag as i,Ap as a,Au as o,Ba as s,Bb as c,Bm as l,Bx as u,Cg as d,Cp as f,Cx as p,Dm as m,Dp as h,Ei as g,Ey as _,Fb as v,Fi as y,Fx as b,Gb as x,Gy as S,Hb as C,Hm as w,Hx as T,Ib as E,Ii as D,Jb as O,Jc as k,Jl as A,Ju as j,Kl as ee,Km as M,Ku as te,Kx as N,Lb as ne,Lm as P,Lx as re,Ly as F,M as ie,Mx as I,Nb as ae,Nh as oe,Ni as se,Nx as L,Ny as ce,Oi as le,Ph as ue,Pi as de,Pm as fe,Ps as pe,Py as me,Q_ as he,Qh as ge,Qm as _e,R as ve,Ra as ye,Rg as R,Ry as be,Sg as xe,Sl as Se,Sp as Ce,Ty as we,Um as Te,Ux as z,Uy as Ee,Vm as De,Wb as B,Wh as Oe,Wm as ke,Xx as V,Yb as Ae,Yr as je,Yu as Me,Yx as Ne,Zb as Pe,Zh as Fe,Zx as Ie,_g as Le,_l as Re,_u as ze,_y as Be,ab as Ve,ag as He,ah as Ue,ax as We,cd as Ge,ch as Ke,cn as qe,cu as Je,db as Ye,dg as Xe,dh as Ze,dn as Qe,dx as $e,eh as et,et as tt,ex as nt,fg as rt,fh as it,fl as at,gb as ot,gg as st,gh as ct,gl as lt,gu as ut,hg as dt,hh as ft,hl as pt,hu as mt,hx as H,ig as ht,ih as gt,j as _t,jg as U,jh as vt,jy as yt,kb as bt,ki as xt,kr as St,kx as Ct,ln as wt,lx as Tt,ml as Et,mn as W,mu as Dt,mx as Ot,nS as kt,nh as At,nv as jt,oh as Mt,ol as Nt,pb as Pt,pl as Ft,pu as It,qu as Lt,rb as Rt,rf as zt,rh as Bt,ru as Vt,rx as Ht,sh as Ut,su as Wt,th as Gt,to as Kt,ub as qt,ui as Jt,vl as Yt,vu as Xt,vx as Zt,wp as Qt,xb as $t,xl as en,yl as tn,ym as nn,z as rn,zx as an}from"./app-Bevxq2OH.js";import{E as on,I as G,Jn as sn,N as cn,Q as ln,Zn as K,_ as un,er as q,f as dn,g as fn,j as J,k as pn}from"./vendor-CtuA73w5.js";import{_ as mn,f as hn,n as gn,t as _n,v as vn,x as yn}from"./react-B9IgSVeK.js";import{B as bn,Ca as xn,E as Sn,Et as Cn,Hi as wn,Ja as Tn,Jn as Y,Ki as En,Q as Dn,Ri as On,Tt as kn,_n as An,br as jn,ci as Mn,gr as Nn,i as Pn,kt as Fn,nt as In,qi as Ln,vn as Rn}from"./icons-DxrLl-Dj.js";import{t as X}from"./detail-card-BwHvhGMs.js";import{t as zn}from"./environment-store-gXJzyQ9n.js";import{t as Bn}from"./app-info-CLe39i6W.js";import{a as Vn,i as Hn,l as Un,o as Wn}from"./machine-sizes--PLzvcMG.js";import{t as Gn}from"./format-countdown-Dceq8qd-.js";import{a as Kn,i as qn,n as Jn,r as Yn,t as Xn}from"./assistant-status-panel-D0GMw4-F.js";import{t as Zn}from"./trait-cycle-row-DxnV3-Yt.js";import{n as Qn,r as $n,t as er}from"./settings-divider-CqLEhf9T.js";import{t as tr}from"./use-hotkey-recorder-D_xoveSa.js";var nr=Tn(`fingerprint-pattern`,[[`path`,{d:`M12 10a2 2 0 0 0-2 2c0 1.02-.1 2.51-.26 4`,key:`1nerag`}],[`path`,{d:`M14 13.12c0 2.38 0 6.38-1 8.88`,key:`o46ks0`}],[`path`,{d:`M17.29 21.02c.12-.6.43-2.3.5-3.02`,key:`ptglia`}],[`path`,{d:`M2 12a10 10 0 0 1 18-6`,key:`ydlgp0`}],[`path`,{d:`M2 16h.01`,key:`1gqxmh`}],[`path`,{d:`M21.8 16c.2-2 .131-5.354 0-6`,key:`drycrb`}],[`path`,{d:`M5 19.5C5.5 18 6 15 6 12a6 6 0 0 1 .34-2`,key:`1tidbn`}],[`path`,{d:`M8.65 22c.21-.66.45-1.32.57-2`,key:`13wd9y`}],[`path`,{d:`M9 6.8a6 6 0 0 1 9 5.2v2`,key:`1fr1j5`}]]),rr=Tn(`server`,[[`rect`,{width:`20`,height:`8`,x:`2`,y:`2`,rx:`2`,ry:`2`,key:`ngkwjq`}],[`rect`,{width:`20`,height:`8`,x:`2`,y:`14`,rx:`2`,ry:`2`,key:`iecqi9`}],[`line`,{x1:`6`,x2:`6.01`,y1:`6`,y2:`6`,key:`16zg32`}],[`line`,{x1:`6`,x2:`6.01`,y1:`18`,y2:`18`,key:`nzw8ys`}]]),ir=Tn(`vibrate`,[[`path`,{d:`m2 8 2 2-2 2 2 2-2 2`,key:`sv1b1`}],[`path`,{d:`m22 8-2 2 2 2-2 2 2 2`,key:`101i4y`}],[`rect`,{width:`8`,height:`14`,x:`8`,y:`5`,rx:`1`,key:`1oyrl4`}]]),Z=e(yn(),1),Q=_n();function ar(){let{t:e}=J(`settings`),t=R.use.velvet(),{theme:n,setThemePreference:r}=Jt(),i=[{value:`system`,label:e(`themePicker.system`),icon:(0,Q.jsx)(Rn,{className:`h-4 w-4`})},{value:`light`,label:e(`themePicker.light`),icon:(0,Q.jsx)(bn,{className:`h-4 w-4`})},{value:`dark`,label:e(`themePicker.dark`),icon:(0,Q.jsx)(An,{className:`h-4 w-4`})},...t?[{value:`velvet`,label:e(`themePicker.velvet`),icon:(0,Q.jsx)(Nn,{className:`h-4 w-4`})}]:[]];return(0,Q.jsxs)(`section`,{children:[(0,Q.jsx)(`h3`,{className:`text-title-small text-[var(--content-emphasised)]`,children:e(`themePicker.title`)}),(0,Q.jsx)(`div`,{className:`mt-2 max-w-[360px]`,children:(0,Q.jsx)(re,{ariaLabel:e(`themePicker.ariaLabel`),value:n,onChange:r,items:i})})]})}var or=l,sr=`Please choose a different handle.`;async function cr(e,t){let{data:n,error:r,response:i}=await st({path:{id:e},body:{handle:t},throwOnError:!1});if(!i)return{kind:`error`,message:Pe(r,void 0,`Failed to save handle.`)??`Failed to save handle.`};if(i.ok&&n)return{kind:`ok`,data:n};if(i.status===409){let{message:e}=ke(r,`handle`,or.taken);return{kind:`taken`,message:e}}if(i.status===400){let{code:e,message:t}=ke(r,`handle`,sr);return{kind:`invalid`,code:e,message:t}}return{kind:`error`,message:Pe(r,i,`Failed to save handle.`)}}async function lr(e,t,n){let{data:r,error:i,response:a}=await Xe({path:{assistant_id:e},query:{handle:t},signal:n,throwOnError:!1});if(Ae(a,i,`Failed to check handle availability.`),!a.ok||!r)throw new O(a.status,a.status===429?`Too many checks — try again in a moment.`:Pe(i,a,`Failed to check handle availability.`));return{available:r.available,code:r.code??null,message:r.message??null}}function ur(e){return/\d{2,}$/.test(e)}var dr=300,fr=1400;function pr({initialHandle:e,inputLabel:t,helperText:r,idleHelperText:i,checkAvailable:a,save:o,onSaved:s,saveSuccessToast:c,fieldId:l}){let{t:u}=J(),[d,f]=(0,Z.useState)(e),[p,m]=(0,Z.useState)(null),[h,g]=(0,Z.useState)(!1),[_,v]=(0,Z.useState)(`idle`),[y,b]=(0,Z.useState)(null),x=dn(),S=(0,Z.useRef)(null),C=(0,Z.useMemo)(()=>d.trim().toLowerCase(),[d]),w=C===e.toLowerCase();(0,Z.useEffect)(()=>{if(w||C.length===0){g(!1),S.current?.abort();return}let e=new AbortController;S.current?.abort(),S.current=e,g(!0);let t=window.setTimeout(async()=>{try{let t=await a(C,e.signal);e.signal.aborted||m(t)}catch(t){e.signal.aborted||b(t instanceof Error?t.message:u(`profileCard.checkAvailabilityFailed`))}finally{e.signal.aborted||g(!1)}},dr);return()=>{window.clearTimeout(t),e.abort()}},[C,w,a,u]);let T=(()=>{if(y)return y;if(p&&!p.available){let e=p.code;return p.message??(e?or[e]:u(`profileCard.chooseDifferentHandle`))}return null})(),E=T?r:w?i??null:h?u(`profileCard.checkingAvailability`):p?.available?u(`profileCard.availableHelper`):null,D=!w&&!h&&p?.available!==!1&&_!==`saving`,O=(0,Z.useCallback)(async()=>{if(!D)return;v(`saving`),b(null);let e=await o(C);if(e.kind===`ok`){v(`saved`),s(e.data),L.success(c),window.setTimeout(()=>v(`idle`),fr);return}if(e.kind===`taken`){v(`idle`),m({available:!1,code:`taken`,message:e.message});return}if(e.kind===`invalid`){v(`idle`),m({available:!1,code:e.code,message:e.message});return}v(`error`),b(e.message),L.error(e.message)},[D,C,s,o,c]),k=(()=>{if(w&&d.length>0||d.length===0)return null;let e=h?`checking`:p?.available?`available`:p?.available===!1?`invalid`:null;return e?(0,Q.jsx)(un,{mode:`wait`,initial:!1,children:(0,Q.jsxs)(fn.span,{initial:x?!1:{opacity:0,scale:.85},animate:{opacity:1,scale:1},exit:x?void 0:{opacity:0,scale:.85},transition:{duration:.14,ease:`easeOut`},className:`flex items-center`,"aria-hidden":e!==`available`&&e!==`invalid`,children:[e===`checking`&&(0,Q.jsx)(Y,{className:`h-4 w-4 animate-spin text-[var(--content-tertiary)]`}),e===`available`&&(0,Q.jsx)(Ln,{className:`h-4 w-4 text-[var(--system-positive-strong)]`,"aria-label":u(`profileCard.available`)}),e===`invalid`&&(0,Q.jsx)(wn,{className:`h-4 w-4 text-[var(--system-negative-strong)]`,"aria-label":u(`profileCard.notAvailable`)})]},e)}):null})(),A=(()=>{switch(_){case`saving`:return(0,Q.jsxs)(`span`,{className:`inline-flex items-center gap-1.5`,children:[(0,Q.jsx)(Y,{className:`h-3.5 w-3.5 animate-spin`,"aria-hidden":!0}),u(`profileCard.saving`)]});case`saved`:return(0,Q.jsxs)(`span`,{className:`inline-flex items-center gap-1.5`,children:[(0,Q.jsx)(Ln,{className:`h-3.5 w-3.5`,"aria-hidden":!0}),u(`profileCard.saved`)]});default:return u(`profileCard.save`)}})();return(0,Q.jsxs)(`div`,{className:`flex flex-col gap-4`,children:[(0,Q.jsx)(z,{label:t,value:d,onChange:e=>{f(e.target.value.replace(/\s+/g,``)),m(null),b(null)},autoCorrect:`off`,autoCapitalize:`none`,spellCheck:!1,maxLength:30,leftIcon:(0,Q.jsx)(`span`,{className:`select-none font-mono text-[var(--content-tertiary)]`,"aria-hidden":!0,children:`@`}),rightIcon:k,errorText:T??void 0,helperText:E??void 0,"aria-invalid":!!T,fullWidth:!0,"data-testid":`${l}-input`}),(!w||_!==`idle`)&&(0,Q.jsx)(`div`,{className:`flex justify-end`,children:(0,Q.jsx)(n,{variant:`primary`,size:`compact`,onClick:O,disabled:!D,"aria-live":`polite`,"data-testid":`${l}-save`,children:A})})]})}function mr({initial:e,onSaved:t}){let{t:n}=J(),r=h.use.refreshSession(),i=ur(e.username)?n(`profileCard.userHandleIdleAutoGenerated`):void 0,a=(0,Z.useCallback)(async e=>await Te({username:e}),[]),o=(0,Z.useCallback)((e,t)=>De(e,t),[]),s=(0,Z.useCallback)(e=>{t(e),r()},[t,r]);return(0,Q.jsx)(pr,{initialHandle:e.username,inputLabel:n(`profileCard.userHandleLabel`),helperText:n(`profileCard.handleHelper`),idleHelperText:i,checkAvailable:o,save:a,onSaved:s,saveSuccessToast:n(`profileCard.profileUpdated`),fieldId:`user-handle`})}function hr({assistant:e,onSaved:t}){let{t:n}=J(),r=e.handle??``,i=K({...k({path:{assistant_id:e.id}})}).data?.results?.[0],a=!!i&&i.subdomain.toLowerCase()===r.toLowerCase(),o=r.length===0?n(`profileCard.assistantHandleIdleEmpty`):void 0,s=(0,Z.useCallback)(async t=>await cr(e.id,t),[e.id]),c=(0,Z.useCallback)((t,n)=>lr(e.id,t,n),[e.id]);return a?(0,Q.jsxs)(`div`,{className:`flex flex-col gap-2`,children:[(0,Q.jsx)(z,{label:n(`profileCard.assistantHandleLabel`),value:r,readOnly:!0,disabled:!0,leftIcon:(0,Q.jsx)(`span`,{className:`select-none font-mono text-[var(--content-tertiary)]`,"aria-hidden":!0,children:`@`}),fullWidth:!0,"data-testid":`assistant-handle-input`}),(0,Q.jsx)(`p`,{className:`text-body-small-default text-[var(--content-tertiary)]`,children:(0,Q.jsx)(cn,{i18nKey:`profileCard.handleLocked`,components:{releaseLink:(0,Q.jsx)(gn,{to:`${v.channels}?setup=email&release=1`,className:`text-[var(--content-link)] underline hover:text-[var(--content-link-hover)]`})}})})]}):(0,Q.jsx)(pr,{initialHandle:r,inputLabel:n(`profileCard.assistantHandleLabel`),helperText:n(`profileCard.handleHelper`),idleHelperText:o,checkAvailable:c,save:s,onSaved:t,saveSuccessToast:n(`profileCard.assistantHandleUpdated`),fieldId:`assistant-handle`})}function gr(){let{t:e}=J();return(0,Q.jsxs)(`div`,{className:`flex flex-col gap-4`,"aria-busy":!0,"aria-live":`polite`,children:[(0,Q.jsxs)(`div`,{className:`flex flex-col gap-2`,children:[(0,Q.jsx)(Zt,{className:`h-3 w-16`}),(0,Q.jsx)(Zt,{className:`h-9 w-full rounded-md`}),(0,Q.jsx)(Zt,{className:`h-3 w-72`})]}),(0,Q.jsx)(Zt,{className:`h-9 w-full rounded-md`}),(0,Q.jsxs)(`div`,{className:`flex items-center justify-between gap-3`,children:[(0,Q.jsx)(Zt,{className:`h-3 w-60`}),(0,Q.jsx)(Zt,{className:`h-7 w-16 rounded-md`})]}),(0,Q.jsx)(`span`,{className:`sr-only`,children:e(`profileCard.loading`)})]})}function _r(){return(0,Q.jsx)(`div`,{className:`border-t border-[var(--border-subtle)]`})}function vr({assistant:e,showHandles:t=!0,children:n}={}){let{t:r}=J(),i=h.use.user?.()?.email??null;return(0,Q.jsx)(X,{title:r(`profileCard.title`),subtitle:r(`profileCard.subtitle`),children:(0,Q.jsxs)(`div`,{className:`flex flex-col gap-6`,children:[i&&(0,Q.jsx)(`div`,{className:`max-w-[420px]`,children:(0,Q.jsx)(z,{label:r(`profileCard.emailLabel`),value:i,disabled:!0,readOnly:!0})}),t&&(0,Q.jsxs)(Q.Fragment,{children:[i&&(0,Q.jsx)(_r,{}),(0,Q.jsx)(yr,{assistant:e})]}),n!=null&&(0,Q.jsxs)(Q.Fragment,{children:[(i||t)&&(0,Q.jsx)(_r,{}),n]})]})})}function yr({assistant:e}){let[t,n]=(0,Z.useState)(null),[r,i]=(0,Z.useState)(null),a=dn(),[o,s]=(0,Z.useState)(e??null);return(0,Z.useEffect)(()=>{s(e??null)},[e]),(0,Z.useEffect)(()=>{let e=!1;return w().then(t=>{e||n(t)}).catch(t=>{e||i(t instanceof Error?t.message:`Failed to load profile.`)}),()=>{e=!0}},[]),r?(0,Q.jsx)(`p`,{className:`text-body-small-default text-[var(--system-negative-strong)]`,children:r}):t?(0,Q.jsxs)(fn.div,{initial:a?!1:{opacity:0,y:4},animate:{opacity:1,y:0},transition:{duration:.22,ease:`easeOut`},className:`flex flex-col gap-6`,children:[(0,Q.jsx)(mr,{initial:t,onSaved:n}),o&&(0,Q.jsxs)(Q.Fragment,{children:[(0,Q.jsx)(`div`,{className:`border-t border-[var(--border-subtle)]`}),(0,Q.jsx)(hr,{assistant:o,onSaved:s})]})]}):(0,Q.jsx)(gr,{})}var br=.5,xr={dazed:.55,bashful:.4},Sr=.224,Cr=`var(--surface-sunken)`,wr=64;function Tr(e){return xr[e]??br}function Er(e,t,n,r){let i=e?.eyeStyles.find(e=>e.id===t);if(!i||i.paths.length===0)return null;let a=xt(i.paths.map(e=>le(e.svgPath)));if(a.w<=0||a.h<=0)return null;let o=n*(r?br:Tr(t)),s=Math.min(o/a.w,o/a.h),c=n/2-(a.x+a.w/2)*s,l=n/2-(a.y+a.h/2)*s;return{paths:i.paths,transform:`matrix(${s},0,0,${s},${c},${l})`}}function Dr({components:e,eyeStyle:t,color:n,primary:r=!1,fieldColor:i,size:a=wr,className:o}){let s=(0,Z.useMemo)(()=>Er(e,t,a,r),[e,t,a,r]),c=e?.colors.find(e=>e.id===n)?.hex,l=i??c,u=a*Sr;return(0,Q.jsxs)(`svg`,{"aria-hidden":`true`,"data-testid":`app-icon-preview`,className:o,width:a,height:a,viewBox:`0 0 ${a} ${a}`,style:{display:`block`,flexShrink:0},children:[(0,Q.jsx)(`rect`,{"data-testid":`app-icon-preview-field`,width:a,height:a,rx:u,ry:u,fill:l??Cr}),s?(0,Q.jsx)(`g`,{"data-testid":`app-icon-preview-eyes`,transform:s.transform,children:s.paths.map((e,t)=>(0,Q.jsx)(`path`,{d:e.svgPath,fill:e.color},t))}):null]})}var Or={production:`#4C9B50`,staging:`#E9C91A`,dev:`#FF88C9`};g.eyeStyles.find(e=>e.id===`quirky`);var kr=`avatar-eyes-`,Ar={eyeStyle:`quirky`,color:`green`};function jr(e,t){return`${kr}${e}-${t}`}function Mr(e){if(e===null||e.kind!==`character`)return null;let t=e.traits;return fe(t)?jr(t.eyeStyle,t.color):null}function Nr(e){return e!==null&&e.startsWith(kr)}function Pr(e){if(e===null||!Nr(e))return null;let t=e.slice(12),n=t.indexOf(`-`);return n<=0||n===t.length-1?null:{eyeStyle:t.slice(0,n),color:t.slice(n+1)}}function Fr(e,t){let n=Mr(e);return{target:n,availableMatch:t.supported&&n!==null&&t.available.includes(n)}}var Ir=160;function Lr(e,t,n){return t<=0?0:(e+n+t)%t}function Rr(e,t){let n=e?.findIndex(e=>e.id===t)??-1;return n>=0?n:0}function zr({open:e,onClose:t,components:r,currentIcon:i,targetIcon:a,canSyncAvatar:o,availableIcons:s,onApply:c,onReset:l}){let{t:u}=J(`settings`),d=Mt(),[f,p]=(0,Z.useState)(0),[m,h]=(0,Z.useState)(0),[g,_]=(0,Z.useState)(!1),[v,y]=(0,Z.useState)(!1),x=o?Pr(a):null;(0,Z.useEffect)(()=>{if(!e)return;let t=Pr(i)??Pr(a)??Ar;p(Rr(r?.eyeStyles,t.eyeStyle)),h(Rr(r?.colors,t.color)),y(!1)},[e,r,i,a]);let S=r?.eyeStyles[f],C=r?.colors[m],w=S?.id??Ar.eyeStyle,T=C?.id??Ar.color,E=jr(w,T),D=E!==i&&s.includes(E),O=async e=>{_(!0),y(!1);try{await e()?t():y(!0)}finally{_(!1)}};return(0,Q.jsx)(b.Root,{open:e,onOpenChange:e=>{e||t()},children:(0,Q.jsxs)(b.Content,{size:`sm`,"data-testid":`app-icon-modal`,children:[(0,Q.jsx)(b.Header,{children:(0,Q.jsx)(b.Title,{children:u(`appIcon.title`)})}),(0,Q.jsxs)(b.Body,{className:`space-y-4`,children:[(0,Q.jsx)(`div`,{className:`flex justify-center`,children:(0,Q.jsx)(`div`,{className:`rounded-2xl bg-[var(--surface-sunken)] p-6`,children:(0,Q.jsx)(Dr,{components:r,eyeStyle:w,color:T,size:Ir})})}),(0,Q.jsxs)(`div`,{className:`space-y-3`,children:[(0,Q.jsx)(Zn,{label:u(`appIcon.eyes`),value:w,onPrev:()=>p(Lr(f,r?.eyeStyles.length??0,-1)),onNext:()=>p(Lr(f,r?.eyeStyles.length??0,1))}),(0,Q.jsx)(Zn,{label:u(`appIcon.color`),value:T,colorHex:C?.hex,onPrev:()=>h(Lr(m,r?.colors.length??0,-1)),onNext:()=>h(Lr(m,r?.colors.length??0,1))})]}),x===null?null:(0,Q.jsx)(n,{type:`button`,variant:`outlined`,fullWidth:!0,disabled:g,onClick:()=>{x!==null&&(p(Rr(r?.eyeStyles,x.eyeStyle)),h(Rr(r?.colors,x.color)),y(!1))},children:u(`appIcon.matchAvatar`)}),(0,Q.jsx)(`p`,{className:`text-body-small-lighter text-[var(--content-tertiary)]`,children:u(d?`appIcon.androidApplyNote`:`appIcon.note`)}),v?(0,Q.jsx)(`p`,{role:`alert`,className:`text-body-small-lighter text-[color:var(--content-negative)]`,children:u(d?`appIcon.androidError`:`appIcon.error`)}):null]}),(0,Q.jsxs)(b.Footer,{children:[i===null?null:(0,Q.jsx)(n,{type:`button`,variant:`outlined`,disabled:g,onClick:()=>void O(l),children:u(`appIcon.reset`)}),(0,Q.jsx)(n,{type:`button`,variant:`primary`,disabled:g||!D,onClick:()=>void O(()=>c(E)),children:u(`appIcon.apply`)})]})]})})}var Br=`AppIcon`,Vr=pn(Br);function Hr(){return{supported:!1,current:null,available:[]}}function Ur(){return et()&&on.isPluginAvailable(Br)}async function Wr(){if(!Ur())return Hr();try{let{supported:e,current:t,available:n}=await Vr.getState();return{supported:e===!0,current:typeof t==`string`?t:null,available:n??[]}}catch(e){return B(e,{context:`app_icon_get_state`,bestEffort:!0}),Hr()}}async function Gr(e){if(!Ur())return!1;try{let{ok:t,error:n}=await Vr.set({name:e});return t===!0?!0:(B(Error(n??`setAlternateIconName failed`),{context:`app_icon_set`,bestEffort:!0}),!1)}catch(e){return B(e,{context:`app_icon_set`,bestEffort:!0}),!1}}var Kr={supported:!1,current:null,available:[]};function qr(e,t){return e.supported===t.supported&&e.current===t.current&&e.available.length===t.available.length&&e.available.every((e,n)=>e===t.available[n])}var Jr=$e(ln()((e,t)=>({snapshot:Kr,setSnapshot:n=>{qr(t().snapshot,n)||e({snapshot:n})}}))),Yr=[];function Xr(e){let t=Ut(),n=Mt(),r=R.use.androidAvatarAppIcon(),i=t||n&&r,{state:a}=nn(e),s=Jr.use.snapshot(),c=Jr.use.setSnapshot(),l=(0,Z.useCallback)(async()=>{if(!i)return c(Kr),Kr;let e=await Wr();return c(e),e},[i,c]);(0,Z.useEffect)(()=>{l()},[l]),o(`app.resume`,()=>{l()});let u=i&&s.supported,{target:d,availableMatch:f}=Fr(a,s),p=f&&d!==s.current,m=s.available,h=(0,Z.useCallback)(async e=>{if(!u||!m.includes(e))return!1;await Gr(e);let t=await l();return t.supported&&t.current===e},[u,m,l]),g=(0,Z.useCallback)(async()=>{if(!u)return!1;await Gr(null);let e=await l();return e.supported&&e.current===null},[u,l]);return{enabled:u,currentIcon:u?s.current:null,targetIcon:u?d:null,availableIcons:u?m:Yr,canSyncAvatar:p,apply:h,reset:g}}var Zr=[`ai.vocify-inc.vellum-assistant-ios`,`ai.vellum.assistant`],Qr={"":`production`,".staging":`staging`,".dev":`dev`};function $r(e){for(let t of Zr){if(!e.startsWith(t))continue;let n=Qr[e.slice(t.length)];if(n)return n}return null}async function ei(){try{let{App:e}=await vn(async()=>{let{App:e}=await import(`./esm-DNzQmwtL.js`);return{App:e}},__vite__mapDeps([0,1,2,3])),{id:t}=await e.getInfo();return $r(t)}catch(e){return console.debug(`[shell-environment] no native shell identity:`,e),null}}function ti(){let[e,t]=(0,Z.useState)();return(0,Z.useEffect)(()=>{let e=!0;return ei().then(n=>{e&&t(n)}),()=>{e=!1}},[]),e}var ni=32,ri={dev:{displayP3:`color(display-p3 0.9387 0.55755 0.7777)`,srgb:Or.dev},staging:{displayP3:`color(display-p3 0.89313 0.79283 0.2841)`,srgb:Or.staging}},ii={local:`dev`,dev:`dev`,staging:`staging`};function ai(){return typeof CSS>`u`||typeof CSS.supports!=`function`?!1:CSS.supports(`color`,`color(display-p3 1 1 1)`)}function oi(e){if(e)return ai()?e.displayP3:e.srgb}function si(e){if(e)return e;if(e===null)return ii.local}function ci(e,t){let n=si(e);if(!n)return;let r=ri[n];return t?r?.srgb:oi(r)}function li(){let e=Be.use.activeAssistantId(),t=Xr(e);return t.enabled?(0,Q.jsx)(ui,{assistantId:e,sync:t}):null}function ui({assistantId:e,sync:t}){let{t:r}=J(`settings`),{components:i}=nn(e),a=je(),o=ti(),s=Mt(),[c,l]=(0,Z.useState)(!1),u=i??a,d=Pr(t.currentIcon),f=d??Ar,p=d===null;return(0,Q.jsxs)(Q.Fragment,{children:[(0,Q.jsxs)(`div`,{className:`flex items-center justify-between gap-3`,children:[(0,Q.jsxs)(`div`,{className:`flex min-w-0 flex-col gap-0.5`,children:[(0,Q.jsx)(`div`,{className:`text-body-medium-lighter text-[var(--content-default)]`,children:r(`appIcon.title`)}),(0,Q.jsx)(`p`,{className:`text-body-small-lighter text-[var(--content-tertiary)]`,children:r(`appIcon.description`)})]}),(0,Q.jsxs)(`div`,{className:`flex shrink-0 items-center gap-3`,children:[(0,Q.jsx)(Dr,{components:u,eyeStyle:f.eyeStyle,color:f.color,primary:p,fieldColor:p?ci(o,s):void 0,size:ni}),(0,Q.jsx)(n,{variant:`outlined`,onClick:()=>l(!0),children:r(`appIcon.change`)})]})]}),(0,Q.jsx)(zr,{open:c,onClose:()=>l(!1),components:u,currentIcon:t.currentIcon,targetIcon:t.targetIcon,canSyncAvatar:t.canSyncAvatar,availableIcons:t.availableIcons,onApply:t.apply,onReset:t.reset})]})}var di=Nt({query:{hosting:`platform`}});function fi(){let{t:e}=J(`settings`),t=tt(),r=K(di),i=r.data?.results??[];return r.isPending||i.length<2?null:(0,Q.jsx)(X,{title:e(`assistantPicker.title`),subtitle:e(`assistantPicker.subtitle`),children:(0,Q.jsx)(`div`,{className:`space-y-2`,children:i.map(r=>{let i=r.id===t;return(0,Q.jsxs)(`div`,{className:`flex items-center justify-between gap-4 rounded-lg border px-4 py-3 ${i?`border-[var(--border-focus)] bg-[var(--surface-lift)]`:`border-[var(--border-base)] bg-[var(--surface-default)]`}`,children:[(0,Q.jsxs)(`div`,{className:`flex min-w-0 items-center gap-3`,children:[(0,Q.jsx)(Rn,{className:`h-4 w-4 shrink-0 text-[var(--content-tertiary)]`}),(0,Q.jsx)(`div`,{className:`min-w-0`,children:(0,Q.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,Q.jsx)(`span`,{className:`truncate text-body-medium-default text-[var(--content-default)]`,children:r.name||e(`assistantPicker.unnamed`)}),r.status!==`active`&&(0,Q.jsx)(N,{tone:`warning`,children:r.status})]})})]}),(0,Q.jsx)(`div`,{className:`shrink-0`,children:i?(0,Q.jsxs)(`span`,{className:`flex items-center gap-1.5 text-body-small-default text-[var(--system-positive-default)]`,children:[(0,Q.jsx)(Ln,{className:`h-4 w-4`}),e(`assistantPicker.active`)]}):(0,Q.jsx)(n,{variant:`outlined`,size:`compact`,disabled:r.status!==`active`,onClick:()=>{vt(r.id),L.success(e(`assistantPicker.switchedToast`))},children:e(`assistantPicker.switch`)})})]},r.id)})})})}var pi=[0,300,600,3600,10800,86400,259200,604800,1209600,2592e3],mi=new Set([300,600]);function hi(e,t){if(e===0)return t(`assistantSleepPolicy.neverSleep`);let n=Math.floor(e/86400),r=Math.floor(e%86400/3600);if(n>0&&r>0)return t(`assistantSleepPolicy.daysHours`,{days:n,hours:r});if(n>0)return t(`assistantSleepPolicy.days`,{days:n});if(r>0)return t(`assistantSleepPolicy.hours`,{hours:r});let i=Math.floor(e/60);return i>0?t(`assistantSleepPolicy.minutes`,{minutes:i}):t(`assistantSleepPolicy.seconds`,{seconds:e})}function gi(e,t){switch(e){case 0:return t(`assistantSleepPolicy.presetNever`);case 300:return t(`assistantSleepPolicy.preset5Min`);case 600:return t(`assistantSleepPolicy.preset10Min`);case 3600:return t(`assistantSleepPolicy.preset1Hour`);case 10800:return t(`assistantSleepPolicy.preset3Hours`);case 86400:return t(`assistantSleepPolicy.preset1Day`);case 259200:return t(`assistantSleepPolicy.preset3Days`);case 604800:return t(`assistantSleepPolicy.preset7Days`);case 1209600:return t(`assistantSleepPolicy.preset14Days`);case 2592e3:return t(`assistantSleepPolicy.preset30Days`);default:return hi(e,t)}}function _i({assistantId:e}){let{t}=J(`settings`),r=q(),i=zn.use.isNonProduction(),a=(0,Z.useMemo)(()=>pi.filter(e=>!mi.has(e)||i),[i]),{data:o,isLoading:s,isError:c}=K(Yt({path:{id:e}})),l=(0,Z.useMemo)(()=>o?.idle_timeout_seconds??259200,[o]),[u,d]=(0,Z.useState)(null),f=u??l,p=u!==null,m=Je({onSuccess:()=>{L.success(t(`assistantSleepPolicy.savedToast`)),d(null),r.invalidateQueries({queryKey:tn({path:{id:e}})})},onError:()=>{L.error(t(`assistantSleepPolicy.saveErrorToast`))}});return s?(0,Q.jsxs)(`div`,{className:`flex items-center gap-2 text-body-medium-lighter text-[var(--content-tertiary)]`,children:[(0,Q.jsx)(Y,{className:`h-4 w-4 animate-spin`}),t(`assistantSleepPolicy.loading`)]}):c?(0,Q.jsx)(`p`,{className:`text-body-medium-lighter text-[var(--system-negative-strong)]`,children:t(`assistantSleepPolicy.loadError`)}):(0,Q.jsxs)(`div`,{className:`space-y-4`,children:[(0,Q.jsxs)(`div`,{children:[(0,Q.jsx)(`label`,{className:`block text-body-medium-default text-[var(--content-default)]`,children:t(`assistantSleepPolicy.idleTimeout`)}),(0,Q.jsx)(`p`,{className:`text-body-small-lighter text-[var(--content-tertiary)]`,children:t(`assistantSleepPolicy.idleTimeoutDescription`)}),(0,Q.jsx)(`div`,{className:`mt-2 flex flex-wrap gap-2`,children:a.map(e=>(0,Q.jsx)(n,{variant:`outlined`,active:f===e,onClick:()=>d(e),children:gi(e,t)},e))}),(0,Q.jsx)(`p`,{className:`mt-2 text-body-small-default text-[var(--content-tertiary)]`,children:t(`assistantSleepPolicy.current`,{duration:hi(f,t)})})]}),p&&(0,Q.jsxs)(`div`,{className:`flex items-center gap-3`,children:[(0,Q.jsx)(n,{variant:`primary`,leftIcon:m.isPending?(0,Q.jsx)(Y,{className:`animate-spin`}):void 0,onClick:()=>m.mutate({path:{id:e},body:{idle_timeout_seconds:f}}),disabled:m.isPending,children:t(`assistantSleepPolicy.save`)}),(0,Q.jsx)(n,{variant:`outlined`,onClick:()=>d(null),disabled:m.isPending,children:t(`assistantSleepPolicy.cancel`)})]})]})}function vi(e,t,n){let r=[e.version];return e.version===n&&r.push(G(`settings:assistantUpgrades.latestSuffix`)),t&&e.version===t&&r.push(G(`settings:assistantUpgrades.currentSuffix`)),r.join(` `)}var yi=3e3;function bi({version:e,assistantId:t}){let{onTap:n,message:r}=qn(t);return(0,Q.jsxs)(`div`,{className:`min-w-0`,children:[(0,Q.jsx)(`button`,{type:`button`,className:`block min-w-0 break-all text-left text-body-medium-lighter text-[var(--content-default)]`,onClick:n,children:e??`—`}),r&&(0,Q.jsx)(`p`,{className:`mt-1 text-body-small-default text-[var(--content-accent)]`,children:r})]})}function xi({assistantId:e,currentVersion:t,releaseChannel:r,onUpgradeComplete:i}){let{t:a}=J(`settings`),o=Ge.use.rollbackEnabled(),s=R.use.previewChannel(),c=q(),l=de(r,s),u=l===`preview`,[d,f]=(0,Z.useState)(!1),m=(0,Z.useRef)(null),[h,g]=(0,Z.useState)(null),[_,v]=(0,Z.useState)(!1),[y,b]=(0,Z.useState)(!1),[x,S]=(0,Z.useState)(null),C=e=>e&&m.current&&e===m.current?(queueMicrotask(()=>{S(a(y?`assistantUpgrades.successRolledBack`:`assistantUpgrades.successUpdated`,{version:m.current})),f(!1),m.current=null,g(null),L.success(a(y?`assistantUpgrades.toastRollbackComplete`:`assistantUpgrades.toastUpdateComplete`),{id:`runtime-upgrade-complete`,tone:`strong`}),i?.()}),!1):yi;K({...lt({path:{id:e}}),refetchInterval:d?e=>C(e.state.data?.current_release_version):!1});let{data:w,isLoading:T}=K(Vt({query:{channel:l}})),E=w?.find(e=>e.is_stable!==!1)??w?.[0],D=h??E?.version??null,O=(0,Z.useMemo)(()=>{if(!o||!D||!t)return!1;let e=ct(D),n=ct(t);return!e||!n?!1:ft(e,n)<0},[o,D,t]),k=(0,Z.useMemo)(()=>{if(!D)return!1;if(!t)return!0;let e=ct(D),n=ct(t);if(!e||!n)return D!==t;let r=ft(e,n);return o?r!==0:r>0},[o,D,t]),A=sn({mutationFn:async t=>{let{data:n}=await xe({path:{id:e},body:t,throwOnError:!0});return n}}),j=sn({mutationFn:async t=>{let{data:n}=await Le({path:{id:e},body:t,throwOnError:!0});return n}}),ee=async()=>{v(!1),S(null);let t=o?D??void 0:void 0;try{if(O){let e=await j.mutateAsync({version:t});m.current=e.version??t??null,L.success(e.detail||a(`assistantUpgrades.toastRollbackInitiated`,{version:t}))}else{let e=await A.mutateAsync({version:t});if(e.detail?.includes(`Already on the latest`)){L.warning(e.detail);return}m.current=e.version??t??null,L.success(e.detail||a(`assistantUpgrades.toastUpdateInitiated`,{version:e.version??t??a(`assistantUpgrades.latest`)}))}b(O),f(!0),c.invalidateQueries({queryKey:Re({path:{id:e}})})}catch{L.error(a(O?`assistantUpgrades.toastRollbackFailed`:`assistantUpgrades.toastUpdateFailed`))}},M=a(u?`assistantUpgrades.previewRelease`:k?O?`assistantUpgrades.rollbackTo`:`assistantUpgrades.updateTo`:`assistantUpgrades.selected`);return(0,Q.jsxs)(`div`,{className:`space-y-5`,children:[(0,Q.jsxs)(`div`,{className:`flex flex-col gap-4 md:grid md:grid-cols-[auto_minmax(0,1fr)] md:items-center md:gap-x-8 md:gap-y-4`,children:[(0,Q.jsxs)(`div`,{className:`flex flex-col gap-1 md:contents`,children:[(0,Q.jsx)(`span`,{className:`text-body-medium-default text-[var(--content-tertiary)]`,children:a(`assistantUpgrades.current`)}),(0,Q.jsx)(bi,{version:t,assistantId:e})]}),(0,Q.jsxs)(`div`,{className:`flex flex-col gap-1 md:contents`,children:[(0,Q.jsx)(`span`,{className:`text-body-medium-default text-[var(--content-tertiary)]`,children:M}),(0,Q.jsxs)(`div`,{className:`flex min-w-0 flex-col gap-3 md:flex-row md:items-center md:gap-4`,children:[(0,Q.jsx)(`span`,{className:`block min-w-0 flex-1`,children:T?(0,Q.jsxs)(`span`,{className:`flex items-center gap-1 text-body-medium-lighter text-[var(--content-tertiary)]`,children:[(0,Q.jsx)(Y,{className:`h-3 w-3 animate-spin`}),a(`assistantUpgrades.loading`)]}):w&&w.length>0?o?(0,Q.jsx)(p,{value:D??``,onChange:e=>g(e===E?.version?null:e),disabled:d||A.isPending||j.isPending,options:w.map(e=>({value:e.version,label:vi(e,t,E?.version)}))}):(0,Q.jsx)(`span`,{className:`block min-w-0 break-all text-body-medium-lighter text-[var(--content-default)]`,children:E?vi(E,t,E.version):`—`}):a(`assistantUpgrades.noReleases`)}),(0,Q.jsx)(n,{variant:O?`outlined`:`primary`,className:`min-w-[160px] shrink-0`,leftIcon:A.isPending||j.isPending||d?(0,Q.jsx)(Y,{className:`animate-spin`}):(0,Q.jsx)(Fn,{}),onClick:()=>v(!0),disabled:!k||A.isPending||j.isPending||d||T||!w?.length,children:a(d?y?`assistantUpgrades.rollingBack`:`assistantUpgrades.updating`:O?`assistantUpgrades.rollback`:u?`assistantUpgrades.updatePreview`:`assistantUpgrades.update`)})]})]})]}),u&&(0,Q.jsx)(`p`,{className:`text-body-small-default text-[var(--content-tertiary)]`,children:(0,Q.jsx)(cn,{ns:`settings`,i18nKey:`assistantUpgrades.usingPreviewReleases`,components:{stableLink:(0,Q.jsx)(`a`,{href:`#preview-release-channel`,className:`text-[var(--primary-base)] underline-offset-2 hover:underline`})}})}),!k&&t&&D&&!T&&(0,Q.jsx)(`p`,{className:`text-body-medium-lighter text-[var(--system-positive-strong)]`,children:x??a(`assistantUpgrades.alreadyOnVersion`)}),(0,Q.jsx)(I,{open:_,title:a(O?`assistantUpgrades.confirmRollbackTitle`:u?`assistantUpgrades.confirmPreviewTitle`:`assistantUpgrades.confirmUpdateTitle`),message:O?a(`assistantUpgrades.confirmRollbackMessage`,{version:D??a(`assistantUpgrades.unknown`)}):a(u?`assistantUpgrades.confirmPreviewMessage`:`assistantUpgrades.confirmUpdateMessage`,{version:D??a(`assistantUpgrades.latest`)}),confirmLabel:a(O?`assistantUpgrades.rollback`:u?`assistantUpgrades.updatePreview`:`assistantUpgrades.update`),onConfirm:ee,onCancel:()=>v(!1)})]})}function Si({assistantId:e,currentVersion:t,onUpgradeComplete:r}){let{t:i}=J(`settings`),[a,o]=(0,Z.useState)(!1),[s,c]=(0,Z.useState)(null),{data:l,isLoading:u}=K(Vt({query:{stable:!0,limit:100}})),d=(0,Z.useMemo)(()=>se(l),[l]),f=d?.version,p=t?y(t,f):!!f,m=D({assistantId:e,targetVersion:f});return(0,Q.jsxs)(`div`,{className:`space-y-5`,children:[(0,Q.jsxs)(`div`,{className:`flex flex-col gap-4 md:grid md:grid-cols-[auto_minmax(0,1fr)] md:items-center md:gap-x-8 md:gap-y-4`,children:[(0,Q.jsxs)(`div`,{className:`flex flex-col gap-1 md:contents`,children:[(0,Q.jsx)(`span`,{className:`text-body-medium-default text-[var(--content-tertiary)]`,children:i(`assistantUpgrades.current`)}),(0,Q.jsx)(bi,{version:t,assistantId:e})]}),(0,Q.jsxs)(`div`,{className:`flex flex-col gap-1 md:contents`,children:[(0,Q.jsx)(`span`,{className:`text-body-medium-default text-[var(--content-tertiary)]`,children:i(`assistantUpgrades.updateTo`)}),(0,Q.jsx)(`span`,{className:`block min-w-0 break-all text-body-medium-lighter text-[var(--content-default)]`,children:u?i(`assistantUpgrades.loading`):f&&d?vi(d,t,f):i(`assistantUpgrades.noReleases`)})]})]}),(0,Q.jsx)(n,{variant:`primary`,className:`min-w-[160px]`,leftIcon:m.isPending?(0,Q.jsx)(Y,{className:`animate-spin`}):(0,Q.jsx)(Fn,{}),onClick:()=>o(!0),disabled:m.isPending||u||!f||!p,children:m.isPending?i(`assistantUpgrades.updating`):f?i(`assistantUpgrades.updateToVersion`,{version:f}):i(`assistantUpgrades.update`)}),s&&(0,Q.jsx)(`p`,{className:`text-body-medium-lighter text-[var(--system-positive-strong)]`,children:s}),!s&&!p&&f&&!u&&(0,Q.jsx)(`p`,{className:`text-body-medium-lighter text-[var(--system-positive-strong)]`,children:i(`assistantUpgrades.alreadyOnVersion`)}),(0,Q.jsx)(I,{open:a,title:i(`assistantUpgrades.confirmUpdateTitle`),message:i(`assistantUpgrades.confirmUpdateMessage`,{version:f??i(`assistantUpgrades.latest`)}),confirmLabel:i(`assistantUpgrades.update`),onConfirm:async()=>{o(!1),c(null);try{c(i(`assistantUpgrades.successUpdated`,{version:(await m.upgrade()).version??f??i(`assistantUpgrades.latest`)})),L.success(i(`assistantUpgrades.toastUpdateComplete`),{id:`runtime-upgrade-complete`,tone:`strong`}),r?.()}catch(e){L.error(e instanceof Error?e.message:i(`assistantUpgrades.toastUpdateFailed`))}},onCancel:()=>o(!1)})]})}function Ci(){let{t:e}=J(`settings`),t=Qt({platformHostedOnly:!0}),r=f(),i=h.use.user()?.id??null,a=h.use.logout(),[o,s]=(0,Z.useState)(!1),c=It({onSuccess:async()=>{L.success(e(`deleteAccountSection.toastRequested`)),P(i),await a(),pe(v.account.login)},onError:()=>{L.error(e(`deleteAccountSection.toastFailed`))}}),l=t===`full`&&r;return(0,Z.useEffect)(()=>{l&&o&&s(!1)},[l,o]),t===`gated`?null:(0,Q.jsxs)(Q.Fragment,{children:[(0,Q.jsxs)(`section`,{className:`flex flex-col gap-2`,children:[(0,Q.jsx)(`h3`,{className:`text-title-small text-[var(--content-emphasised)]`,children:e(`deleteAccountSection.title`)}),(0,Q.jsx)(`p`,{className:`text-body-medium-default text-[var(--content-tertiary)]`,children:e(`deleteAccountSection.description`)}),(0,Q.jsx)(`div`,{className:`mt-1`,children:t===`disabled`?(0,Q.jsx)(W,{children:e(`deleteAccountSection.platformLoginNotice`)}):(0,Q.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,Q.jsx)(n,{variant:`dangerOutline`,onClick:()=>s(!0),disabled:c.isPending||l,className:`self-start`,children:e(`deleteAccountSection.deleteMyAccount`)}),l&&(0,Q.jsx)(Y,{className:`h-4 w-4 animate-spin text-[var(--content-tertiary)]`})]})})]}),(0,Q.jsx)(I,{open:o,title:e(`deleteAccountSection.confirmTitle`),message:e(`deleteAccountSection.confirmMessage`),confirmLabel:e(`deleteAccountSection.confirmLabel`),destructive:!0,onConfirm:()=>{if(l){s(!1);return}s(!1),c.mutate({})},onCancel:()=>s(!1)})]})}function wi({title:e,subtitle:t,benefits:r,ctaLabel:i,ctaLeftIcon:a,onAction:o}){return(0,Q.jsx)(X,{title:e,subtitle:t,children:(0,Q.jsxs)(`div`,{className:`flex flex-col gap-4`,children:[(0,Q.jsx)(`ul`,{className:`space-y-3`,children:r.map(({icon:e,text:t})=>(0,Q.jsxs)(`li`,{className:`flex items-center gap-3`,children:[(0,Q.jsx)(`span`,{className:`flex size-7 shrink-0 items-center justify-center rounded-md`,style:{background:`var(--surface-base)`},children:(0,Q.jsx)(e,{size:14,style:{color:`var(--content-secondary)`},"aria-hidden":!0})}),(0,Q.jsx)(`span`,{className:`text-body-medium-lighter text-[color:var(--content-secondary)]`,children:t})]},t))}),(0,Q.jsx)(n,{variant:`primary`,size:`regular`,leftIcon:a,onClick:o,className:`self-start`,children:i})]})})}function Ti({promotion:e}){let{t}=J(`settings`),{appName:n,target:i}=e;return(0,Z.useEffect)(()=>{wt(`settings`,i)},[i]),(0,Q.jsx)(wi,{title:n===null?t(`nativeAppCard.titleGeneric`):t(`nativeAppCard.title`,{appName:n}),subtitle:n===null?t(`nativeAppCard.subtitleGeneric`):t(`nativeAppCard.subtitle`,{appName:n}),benefits:[{icon:xn,text:t(`nativeAppCard.benefitPush`)},{icon:nr,text:t(`nativeAppCard.benefitBiometric`)},{icon:ir,text:t(`nativeAppCard.benefitHaptics`)},{icon:In,text:t(`nativeAppCard.benefitHomeScreen`)}],ctaLabel:t(`nativeAppCard.download`),ctaLeftIcon:(0,Q.jsx)(In,{size:16}),onAction:()=>{qe(`click`,`settings`,i),ie(i),r(i)}})}function Ei(){let e=gt(),t=Bt(),n=At(),r=Ue();return!e&&!t&&!n&&!r?null:(0,Q.jsx)(Ti,{promotion:_t(e||t?`ios`:n?`android`:null)})}var Di=`0.10.0`;function Oi(){return it(Di)}var ki=`/v1/remote-web/pairing-challenge`,Ai=`/v1/remote-web/pairing-verification`,ji=`/v1/remote-web/pairing-requests`,Mi=`${ji}/approve`,Ni=`${ji}/deny`;function Pi(){return G(`settings:pairDeviceClient.connectivityHint`)}var Fi=class extends Error{hint;status;code;constructor(e,t={}){super(e),this.name=`PairDeviceError`,this.hint=t.hint,this.status=t.status,this.code=t.code}},Ii=5e3;function Li(){if(typeof window>`u`)return null;let e=me(),t=_(e);return t?{base:`${window.location.origin}${t}`,assistantName:e?.name?.trim()||null,ingressUrl:e?.ingressUrl?.trim()||null}:null}function Ri(e){let t=e?.error?.message;return typeof t==`string`&&t.trim()?t:null}function zi(e){let t=e?.error?.code;return typeof t==`string`&&t?t:void 0}async function Bi(e,t,n,r){let i;try{i=await fetch(e,{...t,signal:n})}catch(e){throw x(e)?e:new Fi(G(`settings:pairDeviceClient.networkError`))}let a=await i.json().catch(()=>null);if(!i.ok)throw new Fi(Ri(a)??G(`settings:pairDeviceClient.httpError`,{status:i.status}),{hint:r,status:i.status,code:zi(a)});if(typeof a!=`object`||!a)throw new Fi(G(`settings:pairDeviceClient.unexpectedResponse`));return a}function Vi(e,t,n,r){return Bi(e,{method:`POST`,headers:{"Content-Type":`application/json`},body:JSON.stringify(t)},n,r)}async function Hi(e){let{base:t,publicBaseUrl:n,signal:r}=e,i=await Vi(`${t}${ki}`,{publicBaseUrl:n},r,Pi());try{await Vi(`${t}${Ai}`,{userCode:i.userCode},r,Pi())}catch(e){let n=AbortSignal.timeout(Ii);throw x(e)?Ui(t,i.userCode,n):await Ui(t,i.userCode,r?AbortSignal.any([r,n]):n),e}return{pairUrl:We(i),expiresAt:i.expiresAt}}async function Ui(e,t,n){try{let r=(await Wi({base:e,signal:n})).find(e=>e.userCode===t);r&&await qi({base:e,requestId:r.requestId,signal:n})}catch(e){if(x(e))return;B(e,{context:`pair-device-orphan-cleanup`,bestEffort:!0})}}async function Wi(e){let t=await Bi(`${e.base}${ji}`,{method:`GET`},e.signal);return Array.isArray(t.requests)?t.requests:[]}async function Gi(e,t){await Vi(`${t.base}${e}`,{requestId:t.requestId},t.signal)}function Ki(e){return Gi(Mi,e)}function qi(e){return Gi(Ni,e)}var Ji=Object.defineProperty,Yi=Object.getOwnPropertySymbols,Xi=Object.prototype.hasOwnProperty,Zi=Object.prototype.propertyIsEnumerable,Qi=(e,t,n)=>t in e?Ji(e,t,{enumerable:!0,configurable:!0,writable:!0,value:n}):e[t]=n,$i=(e,t)=>{for(var n in t||={})Xi.call(t,n)&&Qi(e,n,t[n]);if(Yi)for(var n of Yi(t))Zi.call(t,n)&&Qi(e,n,t[n]);return e},ea=(e,t)=>{var n={};for(var r in e)Xi.call(e,r)&&t.indexOf(r)<0&&(n[r]=e[r]);if(e!=null&&Yi)for(var r of Yi(e))t.indexOf(r)<0&&Zi.call(e,r)&&(n[r]=e[r]);return n},ta;(e=>{let t=class t{constructor(e,n,r,a){if(this.version=e,this.errorCorrectionLevel=n,this.modules=[],this.isFunction=[],e<t.MIN_VERSION||e>t.MAX_VERSION)throw RangeError(`Version value out of range`);if(a<-1||a>7)throw RangeError(`Mask value out of range`);this.size=e*4+17;let o=[];for(let e=0;e<this.size;e++)o.push(!1);for(let e=0;e<this.size;e++)this.modules.push(o.slice()),this.isFunction.push(o.slice());this.drawFunctionPatterns();let s=this.addEccAndInterleave(r);if(this.drawCodewords(s),a==-1){let e=1e9;for(let t=0;t<8;t++){this.applyMask(t),this.drawFormatBits(t);let n=this.getPenaltyScore();n<e&&(a=t,e=n),this.applyMask(t)}}i(0<=a&&a<=7),this.mask=a,this.applyMask(a),this.drawFormatBits(a),this.isFunction=[]}static encodeText(n,r){let i=e.QrSegment.makeSegments(n);return t.encodeSegments(i,r)}static encodeBinary(n,r){let i=e.QrSegment.makeBytes(n);return t.encodeSegments([i],r)}static encodeSegments(e,r,a=1,s=40,c=-1,l=!0){if(!(t.MIN_VERSION<=a&&a<=s&&s<=t.MAX_VERSION)||c<-1||c>7)throw RangeError(`Invalid value`);let u,d;for(u=a;;u++){let n=t.getNumDataCodewords(u,r)*8,i=o.getTotalBits(e,u);if(i<=n){d=i;break}if(u>=s)throw RangeError(`Data too long`)}for(let e of[t.Ecc.MEDIUM,t.Ecc.QUARTILE,t.Ecc.HIGH])l&&d<=t.getNumDataCodewords(u,e)*8&&(r=e);let f=[];for(let t of e){n(t.mode.modeBits,4,f),n(t.numChars,t.mode.numCharCountBits(u),f);for(let e of t.getData())f.push(e)}i(f.length==d);let p=t.getNumDataCodewords(u,r)*8;i(f.length<=p),n(0,Math.min(4,p-f.length),f),n(0,(8-f.length%8)%8,f),i(f.length%8==0);for(let e=236;f.length<p;e^=253)n(e,8,f);let m=[];for(;m.length*8<f.length;)m.push(0);return f.forEach((e,t)=>m[t>>>3]|=e<<7-(t&7)),new t(u,r,m,c)}getModule(e,t){return 0<=e&&e<this.size&&0<=t&&t<this.size&&this.modules[t][e]}getModules(){return this.modules}drawFunctionPatterns(){for(let e=0;e<this.size;e++)this.setFunctionModule(6,e,e%2==0),this.setFunctionModule(e,6,e%2==0);this.drawFinderPattern(3,3),this.drawFinderPattern(this.size-4,3),this.drawFinderPattern(3,this.size-4);let e=this.getAlignmentPatternPositions(),t=e.length;for(let n=0;n<t;n++)for(let r=0;r<t;r++)n==0&&r==0||n==0&&r==t-1||n==t-1&&r==0||this.drawAlignmentPattern(e[n],e[r]);this.drawFormatBits(0),this.drawVersion()}drawFormatBits(e){let t=this.errorCorrectionLevel.formatBits<<3|e,n=t;for(let e=0;e<10;e++)n=n<<1^(n>>>9)*1335;let a=(t<<10|n)^21522;i(a>>>15==0);for(let e=0;e<=5;e++)this.setFunctionModule(8,e,r(a,e));this.setFunctionModule(8,7,r(a,6)),this.setFunctionModule(8,8,r(a,7)),this.setFunctionModule(7,8,r(a,8));for(let e=9;e<15;e++)this.setFunctionModule(14-e,8,r(a,e));for(let e=0;e<8;e++)this.setFunctionModule(this.size-1-e,8,r(a,e));for(let e=8;e<15;e++)this.setFunctionModule(8,this.size-15+e,r(a,e));this.setFunctionModule(8,this.size-8,!0)}drawVersion(){if(this.version<7)return;let e=this.version;for(let t=0;t<12;t++)e=e<<1^(e>>>11)*7973;let t=this.version<<12|e;i(t>>>18==0);for(let e=0;e<18;e++){let n=r(t,e),i=this.size-11+e%3,a=Math.floor(e/3);this.setFunctionModule(i,a,n),this.setFunctionModule(a,i,n)}}drawFinderPattern(e,t){for(let n=-4;n<=4;n++)for(let r=-4;r<=4;r++){let i=Math.max(Math.abs(r),Math.abs(n)),a=e+r,o=t+n;0<=a&&a<this.size&&0<=o&&o<this.size&&this.setFunctionModule(a,o,i!=2&&i!=4)}}drawAlignmentPattern(e,t){for(let n=-2;n<=2;n++)for(let r=-2;r<=2;r++)this.setFunctionModule(e+r,t+n,Math.max(Math.abs(r),Math.abs(n))!=1)}setFunctionModule(e,t,n){this.modules[t][e]=n,this.isFunction[t][e]=!0}addEccAndInterleave(e){let n=this.version,r=this.errorCorrectionLevel;if(e.length!=t.getNumDataCodewords(n,r))throw RangeError(`Invalid argument`);let a=t.NUM_ERROR_CORRECTION_BLOCKS[r.ordinal][n],o=t.ECC_CODEWORDS_PER_BLOCK[r.ordinal][n],s=Math.floor(t.getNumRawDataModules(n)/8),c=a-s%a,l=Math.floor(s/a),u=[],d=t.reedSolomonComputeDivisor(o);for(let n=0,r=0;n<a;n++){let i=e.slice(r,r+l-o+(n<c?0:1));r+=i.length;let a=t.reedSolomonComputeRemainder(i,d);n<c&&i.push(0),u.push(i.concat(a))}let f=[];for(let e=0;e<u[0].length;e++)u.forEach((t,n)=>{(e!=l-o||n>=c)&&f.push(t[e])});return i(f.length==s),f}drawCodewords(e){if(e.length!=Math.floor(t.getNumRawDataModules(this.version)/8))throw RangeError(`Invalid argument`);let n=0;for(let t=this.size-1;t>=1;t-=2){t==6&&(t=5);for(let i=0;i<this.size;i++)for(let a=0;a<2;a++){let o=t-a,s=t+1&2?i:this.size-1-i;!this.isFunction[s][o]&&n<e.length*8&&(this.modules[s][o]=r(e[n>>>3],7-(n&7)),n++)}}i(n==e.length*8)}applyMask(e){if(e<0||e>7)throw RangeError(`Mask value out of range`);for(let t=0;t<this.size;t++)for(let n=0;n<this.size;n++){let r;switch(e){case 0:r=(n+t)%2==0;break;case 1:r=t%2==0;break;case 2:r=n%3==0;break;case 3:r=(n+t)%3==0;break;case 4:r=(Math.floor(n/3)+Math.floor(t/2))%2==0;break;case 5:r=n*t%2+n*t%3==0;break;case 6:r=(n*t%2+n*t%3)%2==0;break;case 7:r=((n+t)%2+n*t%3)%2==0;break;default:throw Error(`Unreachable`)}!this.isFunction[t][n]&&r&&(this.modules[t][n]=!this.modules[t][n])}}getPenaltyScore(){let e=0;for(let n=0;n<this.size;n++){let r=!1,i=0,a=[0,0,0,0,0,0,0];for(let o=0;o<this.size;o++)this.modules[n][o]==r?(i++,i==5?e+=t.PENALTY_N1:i>5&&e++):(this.finderPenaltyAddHistory(i,a),r||(e+=this.finderPenaltyCountPatterns(a)*t.PENALTY_N3),r=this.modules[n][o],i=1);e+=this.finderPenaltyTerminateAndCount(r,i,a)*t.PENALTY_N3}for(let n=0;n<this.size;n++){let r=!1,i=0,a=[0,0,0,0,0,0,0];for(let o=0;o<this.size;o++)this.modules[o][n]==r?(i++,i==5?e+=t.PENALTY_N1:i>5&&e++):(this.finderPenaltyAddHistory(i,a),r||(e+=this.finderPenaltyCountPatterns(a)*t.PENALTY_N3),r=this.modules[o][n],i=1);e+=this.finderPenaltyTerminateAndCount(r,i,a)*t.PENALTY_N3}for(let n=0;n<this.size-1;n++)for(let r=0;r<this.size-1;r++){let i=this.modules[n][r];i==this.modules[n][r+1]&&i==this.modules[n+1][r]&&i==this.modules[n+1][r+1]&&(e+=t.PENALTY_N2)}let n=0;for(let e of this.modules)n=e.reduce((e,t)=>e+ +!!t,n);let r=this.size*this.size,a=Math.ceil(Math.abs(n*20-r*10)/r)-1;return i(0<=a&&a<=9),e+=a*t.PENALTY_N4,i(0<=e&&e<=2568888),e}getAlignmentPatternPositions(){if(this.version==1)return[];{let e=Math.floor(this.version/7)+2,t=this.version==32?26:Math.ceil((this.version*4+4)/(e*2-2))*2,n=[6];for(let r=this.size-7;n.length<e;r-=t)n.splice(1,0,r);return n}}static getNumRawDataModules(e){if(e<t.MIN_VERSION||e>t.MAX_VERSION)throw RangeError(`Version number out of range`);let n=(16*e+128)*e+64;if(e>=2){let t=Math.floor(e/7)+2;n-=(25*t-10)*t-55,e>=7&&(n-=36)}return i(208<=n&&n<=29648),n}static getNumDataCodewords(e,n){return Math.floor(t.getNumRawDataModules(e)/8)-t.ECC_CODEWORDS_PER_BLOCK[n.ordinal][e]*t.NUM_ERROR_CORRECTION_BLOCKS[n.ordinal][e]}static reedSolomonComputeDivisor(e){if(e<1||e>255)throw RangeError(`Degree out of range`);let n=[];for(let t=0;t<e-1;t++)n.push(0);n.push(1);let r=1;for(let i=0;i<e;i++){for(let e=0;e<n.length;e++)n[e]=t.reedSolomonMultiply(n[e],r),e+1<n.length&&(n[e]^=n[e+1]);r=t.reedSolomonMultiply(r,2)}return n}static reedSolomonComputeRemainder(e,n){let r=n.map(e=>0);for(let i of e){let e=i^r.shift();r.push(0),n.forEach((n,i)=>r[i]^=t.reedSolomonMultiply(n,e))}return r}static reedSolomonMultiply(e,t){if(e>>>8||t>>>8)throw RangeError(`Byte out of range`);let n=0;for(let r=7;r>=0;r--)n=n<<1^(n>>>7)*285,n^=(t>>>r&1)*e;return i(n>>>8==0),n}finderPenaltyCountPatterns(e){let t=e[1];i(t<=this.size*3);let n=t>0&&e[2]==t&&e[3]==t*3&&e[4]==t&&e[5]==t;return(n&&e[0]>=t*4&&e[6]>=t?1:0)+(n&&e[6]>=t*4&&e[0]>=t?1:0)}finderPenaltyTerminateAndCount(e,t,n){return e&&(this.finderPenaltyAddHistory(t,n),t=0),t+=this.size,this.finderPenaltyAddHistory(t,n),this.finderPenaltyCountPatterns(n)}finderPenaltyAddHistory(e,t){t[0]==0&&(e+=this.size),t.pop(),t.unshift(e)}};t.MIN_VERSION=1,t.MAX_VERSION=40,t.PENALTY_N1=3,t.PENALTY_N2=3,t.PENALTY_N3=40,t.PENALTY_N4=10,t.ECC_CODEWORDS_PER_BLOCK=[[-1,7,10,15,20,26,18,20,24,30,18,20,24,26,30,22,24,28,30,28,28,28,28,30,30,26,28,30,30,30,30,30,30,30,30,30,30,30,30,30,30],[-1,10,16,26,18,24,16,18,22,22,26,30,22,22,24,24,28,28,26,26,26,26,28,28,28,28,28,28,28,28,28,28,28,28,28,28,28,28,28,28,28],[-1,13,22,18,26,18,24,18,22,20,24,28,26,24,20,30,24,28,28,26,30,28,30,30,30,30,28,30,30,30,30,30,30,30,30,30,30,30,30,30,30],[-1,17,28,22,16,22,28,26,26,24,28,24,28,22,24,24,30,28,28,26,28,30,24,30,30,30,30,30,30,30,30,30,30,30,30,30,30,30,30,30,30]],t.NUM_ERROR_CORRECTION_BLOCKS=[[-1,1,1,1,1,1,2,2,2,2,4,4,4,4,4,6,6,6,6,7,8,8,9,9,10,12,12,12,13,14,15,16,17,18,19,19,20,21,22,24,25],[-1,1,1,1,2,2,4,4,4,5,5,5,8,9,9,10,10,11,13,14,16,17,17,18,20,21,23,25,26,28,29,31,33,35,37,38,40,43,45,47,49],[-1,1,1,2,2,4,4,6,6,8,8,8,10,12,16,12,17,16,18,21,20,23,23,25,27,29,34,34,35,38,40,43,45,48,51,53,56,59,62,65,68],[-1,1,1,2,4,4,4,5,6,8,8,11,11,16,16,18,16,19,21,25,25,25,34,30,32,35,37,40,42,45,48,51,54,57,60,63,66,70,74,77,81]],e.QrCode=t;function n(e,t,n){if(t<0||t>31||e>>>t)throw RangeError(`Value out of range`);for(let r=t-1;r>=0;r--)n.push(e>>>r&1)}function r(e,t){return(e>>>t&1)!=0}function i(e){if(!e)throw Error(`Assertion error`)}let a=class e{constructor(e,t,n){if(this.mode=e,this.numChars=t,this.bitData=n,t<0)throw RangeError(`Invalid argument`);this.bitData=n.slice()}static makeBytes(t){let r=[];for(let e of t)n(e,8,r);return new e(e.Mode.BYTE,t.length,r)}static makeNumeric(t){if(!e.isNumeric(t))throw RangeError(`String contains non-numeric characters`);let r=[];for(let e=0;e<t.length;){let i=Math.min(t.length-e,3);n(parseInt(t.substring(e,e+i),10),i*3+1,r),e+=i}return new e(e.Mode.NUMERIC,t.length,r)}static makeAlphanumeric(t){if(!e.isAlphanumeric(t))throw RangeError(`String contains unencodable characters in alphanumeric mode`);let r=[],i;for(i=0;i+2<=t.length;i+=2){let a=e.ALPHANUMERIC_CHARSET.indexOf(t.charAt(i))*45;a+=e.ALPHANUMERIC_CHARSET.indexOf(t.charAt(i+1)),n(a,11,r)}return i<t.length&&n(e.ALPHANUMERIC_CHARSET.indexOf(t.charAt(i)),6,r),new e(e.Mode.ALPHANUMERIC,t.length,r)}static makeSegments(t){return t==``?[]:e.isNumeric(t)?[e.makeNumeric(t)]:e.isAlphanumeric(t)?[e.makeAlphanumeric(t)]:[e.makeBytes(e.toUtf8ByteArray(t))]}static makeEci(t){let r=[];if(t<0)throw RangeError(`ECI assignment value out of range`);if(t<128)n(t,8,r);else if(t<16384)n(2,2,r),n(t,14,r);else if(t<1e6)n(6,3,r),n(t,21,r);else throw RangeError(`ECI assignment value out of range`);return new e(e.Mode.ECI,0,r)}static isNumeric(t){return e.NUMERIC_REGEX.test(t)}static isAlphanumeric(t){return e.ALPHANUMERIC_REGEX.test(t)}getData(){return this.bitData.slice()}static getTotalBits(e,t){let n=0;for(let r of e){let e=r.mode.numCharCountBits(t);if(r.numChars>=1<<e)return 1/0;n+=4+e+r.bitData.length}return n}static toUtf8ByteArray(e){e=encodeURI(e);let t=[];for(let n=0;n<e.length;n++)e.charAt(n)==`%`?(t.push(parseInt(e.substring(n+1,n+3),16)),n+=2):t.push(e.charCodeAt(n));return t}};a.NUMERIC_REGEX=/^[0-9]*$/,a.ALPHANUMERIC_REGEX=/^[A-Z0-9 $%*+.\/:-]*$/,a.ALPHANUMERIC_CHARSET=`0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ $%*+-./:`;let o=a;e.QrSegment=a})(ta||={}),(e=>{(e=>{let t=class{constructor(e,t){this.ordinal=e,this.formatBits=t}};t.LOW=new t(0,1),t.MEDIUM=new t(1,0),t.QUARTILE=new t(2,3),t.HIGH=new t(3,2),e.Ecc=t})(e.QrCode||={})})(ta||={}),(e=>{(e=>{let t=class{constructor(e,t){this.modeBits=e,this.numBitsCharCount=t}numCharCountBits(e){return this.numBitsCharCount[Math.floor((e+7)/17)]}};t.NUMERIC=new t(1,[10,12,14]),t.ALPHANUMERIC=new t(2,[9,11,13]),t.BYTE=new t(4,[8,16,16]),t.KANJI=new t(8,[8,10,12]),t.ECI=new t(7,[0,0,0]),e.Mode=t})(e.QrSegment||={})})(ta||={});var na=ta,ra={L:na.QrCode.Ecc.LOW,M:na.QrCode.Ecc.MEDIUM,Q:na.QrCode.Ecc.QUARTILE,H:na.QrCode.Ecc.HIGH},ia=128,aa=`L`,oa=`#FFFFFF`,sa=`#000000`,ca=!1,la=1,ua=4,da=0,fa=.1;function pa(e,t=0){let n=[];return e.forEach(function(e,r){let i=null;e.forEach(function(a,o){if(!a&&i!==null){n.push(`M${i+t} ${r+t}h${o-i}v1H${i+t}z`),i=null;return}if(o===e.length-1){if(!a)return;i===null?n.push(`M${o+t},${r+t} h1v1H${o+t}z`):n.push(`M${i+t},${r+t} h${o+1-i}v1H${i+t}z`);return}a&&i===null&&(i=o)})}),n.join(``)}function ma(e,t){return e.slice().map((e,n)=>n<t.y||n>=t.y+t.h?e:e.map((e,n)=>n<t.x||n>=t.x+t.w?e:!1))}function ha(e,t,n,r){if(r==null)return null;let i=e.length+n*2,a=Math.floor(t*fa),o=i/t,s=(r.width||a)*o,c=(r.height||a)*o,l=r.x==null?e.length/2-s/2:r.x*o,u=r.y==null?e.length/2-c/2:r.y*o,d=r.opacity==null?1:r.opacity,f=null;if(r.excavate){let e=Math.floor(l),t=Math.floor(u);f={x:e,y:t,w:Math.ceil(s+l-e),h:Math.ceil(c+u-t)}}let p=r.crossOrigin;return{x:l,y:u,h:c,w:s,excavation:f,opacity:d,crossOrigin:p}}function ga(e,t){return t==null?e?ua:da:Math.max(Math.floor(t),0)}function _a({value:e,level:t,minVersion:n,includeMargin:r,marginSize:i,imageSettings:a,size:o,boostLevel:s}){let c=Z.useMemo(()=>{let r=(Array.isArray(e)?e:[e]).reduce((e,t)=>(e.push(...na.QrSegment.makeSegments(t)),e),[]);return na.QrCode.encodeSegments(r,ra[t],n,void 0,void 0,s)},[e,t,n,s]),{cells:l,margin:u,numCells:d,calculatedImageSettings:f}=Z.useMemo(()=>{let e=c.getModules(),t=ga(r,i);return{cells:e,margin:t,numCells:e.length+t*2,calculatedImageSettings:ha(e,o,t,a)}},[c,o,a,r,i]);return{qrcode:c,margin:u,cells:l,numCells:d,calculatedImageSettings:f}}var va=function(){try{new Path2D().addPath(new Path2D)}catch{return!1}return!0}(),ya=Z.forwardRef(function(e,t){let n=e,{value:r,size:i=ia,level:a=aa,bgColor:o=oa,fgColor:s=sa,includeMargin:c=ca,minVersion:l=la,boostLevel:u,marginSize:d,imageSettings:f}=n,p=ea(n,[`value`,`size`,`level`,`bgColor`,`fgColor`,`includeMargin`,`minVersion`,`boostLevel`,`marginSize`,`imageSettings`]),{style:m}=p,h=ea(p,[`style`]),g=f?.src,_=Z.useRef(null),v=Z.useRef(null),y=Z.useCallback(e=>{_.current=e,typeof t==`function`?t(e):t&&(t.current=e)},[t]),[b,x]=Z.useState(!1),{margin:S,cells:C,numCells:w,calculatedImageSettings:T}=_a({value:r,level:a,minVersion:l,boostLevel:u,includeMargin:c,marginSize:d,imageSettings:f,size:i});Z.useEffect(()=>{if(_.current!=null){let e=_.current,t=e.getContext(`2d`);if(!t)return;let n=C,r=v.current,a=T!=null&&r!==null&&r.complete&&r.naturalHeight!==0&&r.naturalWidth!==0;a&&T.excavation!=null&&(n=ma(C,T.excavation));let c=window.devicePixelRatio||1;e.height=e.width=i*c;let l=i/w*c;t.scale(l,l),t.fillStyle=o,t.fillRect(0,0,w,w),t.fillStyle=s,va?t.fill(new Path2D(pa(n,S))):C.forEach(function(e,n){e.forEach(function(e,r){e&&t.fillRect(r+S,n+S,1,1)})}),T&&(t.globalAlpha=T.opacity),a&&t.drawImage(r,T.x+S,T.y+S,T.w,T.h)}}),Z.useEffect(()=>{x(!1)},[g]);let E=$i({height:i,width:i},m),D=null;return g!=null&&(D=Z.createElement(`img`,{src:g,key:g,style:{display:`none`},onLoad:()=>{x(!0)},ref:v,crossOrigin:T?.crossOrigin})),Z.createElement(Z.Fragment,null,Z.createElement(`canvas`,$i({style:E,height:i,width:i,ref:y,role:`img`},h)),D)});ya.displayName=`QRCodeCanvas`;var ba=Z.forwardRef(function(e,t){let n=e,{value:r,size:i=ia,level:a=aa,bgColor:o=oa,fgColor:s=sa,includeMargin:c=ca,minVersion:l=la,boostLevel:u,title:d,marginSize:f,imageSettings:p}=n,m=ea(n,[`value`,`size`,`level`,`bgColor`,`fgColor`,`includeMargin`,`minVersion`,`boostLevel`,`title`,`marginSize`,`imageSettings`]),{margin:h,cells:g,numCells:_,calculatedImageSettings:v}=_a({value:r,level:a,minVersion:l,boostLevel:u,includeMargin:c,marginSize:f,imageSettings:p,size:i}),y=g,b=null;p!=null&&v!=null&&(v.excavation!=null&&(y=ma(g,v.excavation)),b=Z.createElement(`image`,{href:p.src,height:v.h,width:v.w,x:v.x+h,y:v.y+h,preserveAspectRatio:`none`,opacity:v.opacity,crossOrigin:v.crossOrigin}));let x=pa(y,h);return Z.createElement(`svg`,$i({height:i,width:i,viewBox:`0 0 ${_} ${_}`,ref:t,role:`img`},m),!!d&&Z.createElement(`title`,null,d),Z.createElement(`path`,{fill:o,d:`M0,0 h${_}v${_}H0z`,shapeRendering:`crispEdges`}),Z.createElement(`path`,{fill:s,d:x,shapeRendering:`crispEdges`}),b)});ba.displayName=`QRCodeSVG`;function xa(e,t){return!Number.isFinite(t)||t<=0?e(`pairDeviceReady.singleUse`):e(`pairDeviceReady.expiresIn`,{time:Gn(t)})}function Sa({pairUrl:e,remainingMs:t,expired:r,copied:i,onCopy:a}){let{t:o}=J(`settings`);return r?(0,Q.jsx)(V,{tone:`warning`,title:o(`pairDeviceReady.expiredTitle`),children:o(`pairDeviceReady.expiredBody`)}):(0,Q.jsxs)(`div`,{className:`flex flex-col gap-3`,children:[(0,Q.jsx)(`div`,{className:`w-fit rounded-lg bg-white p-3`,children:(0,Q.jsx)(ba,{value:e,size:192,level:`M`,title:o(`pairDeviceReady.qrTitle`)})}),(0,Q.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,Q.jsx)(`code`,{"data-testid":`pair-device-url`,className:`min-w-0 flex-1 truncate rounded-md bg-[var(--surface-active)] px-2.5 py-1.5 text-body-small-default text-[var(--content-secondary)]`,children:e}),(0,Q.jsx)(n,{variant:`outlined`,size:`compact`,leftIcon:i?(0,Q.jsx)(Ln,{}):(0,Q.jsx)(Mn,{}),onClick:()=>a(e),children:o(i?`pairDeviceReady.copiedButton`:`pairDeviceReady.copyButton`)})]}),(0,Q.jsx)(`p`,{className:`text-body-small-default text-[var(--content-tertiary)]`,children:xa(o,t)})]})}function Ca(e){return/iPhone|iPod/.test(e)?`iPhone`:/iPad/.test(e)||/Macintosh/.test(e)&&/Mobile/.test(e)?`iPad`:/Android/.test(e)?`Android`:/Macintosh|Mac OS X/.test(e)?`macOS`:/Windows/.test(e)?`Windows`:/CrOS/.test(e)?`ChromeOS`:/Linux/.test(e)?`Linux`:null}function wa(e){return/Edg\/|EdgA\/|EdgiOS\//.test(e)?`Edge`:/OPR\/|OPiOS\//.test(e)?`Opera`:/Firefox\/|FxiOS\//.test(e)?`Firefox`:/Chrome\/|CriOS\//.test(e)?`Chrome`:/Safari\//.test(e)?`Safari`:null}function Ta(e){if(!e||e.trim()===``)return null;let t=Ca(e),n=wa(e);return t===null&&n===null?null:{browser:n,os:t}}var Ea=5e3,Da=6e4;function Oa({pollWhilePairing:e=!1,revalidateKey:t,isExpanded:n=!1}={}){let[r,i]=(0,Z.useState)(null),[a,o]=(0,Z.useState)(null),[s,c]=(0,Z.useState)(!1),[l,u]=(0,Z.useState)(null),d=(0,Z.useRef)(!0),f=(0,Z.useRef)(0);(0,Z.useEffect)(()=>(d.current=!0,()=>{d.current=!1}),[]);let p=(0,Z.useCallback)((e=me()?.assistantId)=>{if(!e)return;i(t=>t&&t.assistantId!==e?null:t);let t=++f.current;Pt(e).then(n=>{!d.current||t!==f.current||i(n.ok?{assistantId:e,devices:n.devices}:null)})},[]),m=Be.use.selectedAssistantId()??me()?.assistantId;(0,Z.useEffect)(()=>{o(null),u(null),p(m)},[m,p]);let h=(0,Z.useRef)(t);(0,Z.useEffect)(()=>{t!==h.current&&(h.current=t,p(m))},[t,m,p]);let g=(0,Z.useRef)(!1);(0,Z.useEffect)(()=>{if(e&&!s){g.current=!0;let e=setInterval(()=>p(),Ea);return()=>clearInterval(e)}!e&&g.current&&(g.current=!1,p())},[e,s,p]);let _=(r?.devices.length??0)>0;(0,Z.useEffect)(()=>{if(!n||!_||e||s)return;let t=setInterval(()=>p(),Da);return()=>clearInterval(t)},[n,_,e,s,p]);let v=(0,Z.useCallback)(e=>{u(null),o(e)},[]),y=(0,Z.useCallback)(()=>{o(null),u(null)},[]),b=(0,Z.useCallback)(()=>{!r||!a||s||(c(!0),u(null),ot(r.assistantId,a.hashedDeviceId).then(e=>{d.current&&(c(!1),e.ok?(o(null),p()):u(e.error))}))},[r,a,s,p]);return{devices:r?.devices??null,confirmTarget:a,isRevoking:s,revokeError:l,requestRevoke:v,cancelRevoke:y,confirmRevoke:b}}var ka=600*1e3,Aa=`paired-devices`;function ja(e){return e.slice(0,12)}function Ma(e,t){return t?t.charAt(0).toUpperCase()+t.slice(1):e(`pairedDevicesSection.platformUnknown`)}function Na(e,t){if(typeof t.clientReportedName==`string`&&t.clientReportedName.trim()!==``)return{name:t.clientReportedName,isRealIdentity:!0};let n=Ta(t.pairingUserAgent);if(n!==null){let{browser:t,os:r}=n;return t!==null&&r!==null?{name:e(`pairedDevicesSection.browserOnOs`,{browser:t,os:r}),isRealIdentity:!0}:{name:t??r??``,isRealIdentity:!0}}return{name:Ma(e,t.platform),isRealIdentity:!1}}function Pa(e,t){return t===null?e(`pairedDevicesSection.dateUnknown`):new Date(t).toLocaleDateString(ne())}function Fa(e,t){let n=Pa(e,t.issuedAt);return t.lastUsedAt===null?e(`pairedDevicesSection.pairedLine`,{paired:n}):Date.now()-t.lastUsedAt<=ka?e(`pairedDevicesSection.pairedActiveLine`,{paired:n}):e(`pairedDevicesSection.pairedAndUsedLine`,{paired:n,lastUsed:Qn(t.lastUsedAt)})}function Ia({pollWhilePairing:e=!1,revalidateKey:t}={}){let{t:r}=J(`settings`),[i,a]=(0,Z.useState)(!1),o=Oa({pollWhilePairing:e,revalidateKey:t,isExpanded:i}),{devices:s,confirmTarget:c}=o;$n(s?.some(e=>e.lastUsedAt!==null)??!1);let l=(0,Z.useMemo)(()=>s===null?null:[...s].sort((e,t)=>(t.lastUsedAt??0)-(e.lastUsedAt??0)),[s]);return l===null||l.length===0?null:(0,Q.jsxs)(Q.Fragment,{children:[(0,Q.jsx)(H.Root,{type:`multiple`,value:i?[Aa]:[],onValueChange:e=>a(e.includes(Aa)),children:(0,Q.jsxs)(H.Item,{value:Aa,children:[(0,Q.jsxs)(H.Trigger,{className:`group flex w-full items-center justify-between gap-3`,children:[(0,Q.jsx)(`span`,{className:`text-body-medium-default text-[var(--content-secondary)]`,children:r(`pairedDevicesSection.title`,{count:l.length})}),(0,Q.jsx)(En,{className:`h-4 w-4 shrink-0 text-[var(--content-tertiary)] transition-transform group-data-[state=open]:rotate-180`})]}),(0,Q.jsx)(H.Content,{children:(0,Q.jsx)(`div`,{className:`mt-3 flex flex-col gap-3`,children:l.map(e=>{let t=Na(r,e);return(0,Q.jsxs)(`div`,{className:`flex items-center justify-between gap-3`,children:[(0,Q.jsxs)(`div`,{className:`flex min-w-0 flex-col`,children:[(0,Q.jsxs)(`span`,{className:`flex min-w-0 items-baseline gap-1 text-body-medium-default text-[var(--content-secondary)]`,children:[(0,Q.jsx)(`span`,{className:`min-w-0 truncate`,title:t.isRealIdentity?e.hashedDeviceId:void 0,children:t.name}),!t.isRealIdentity&&(0,Q.jsx)(`span`,{className:`shrink-0 font-mono text-[var(--content-tertiary)]`,title:e.hashedDeviceId,children:ja(e.hashedDeviceId)}),e.isCurrentHost&&(0,Q.jsx)(`span`,{className:`shrink-0 text-[var(--content-tertiary)]`,children:`· ${r(`pairedDevicesSection.thisMachine`)}`})]}),(0,Q.jsx)(`span`,{className:`text-body-medium-default text-[var(--content-tertiary)]`,children:Fa(r,e)})]}),(0,Q.jsx)(n,{variant:`dangerOutline`,size:`compact`,className:`shrink-0`,disabled:e.isCurrentHost===!0,title:e.isCurrentHost?r(`pairedDevicesSection.hostRevokeDisabledTitle`):void 0,onClick:()=>o.requestRevoke(e),children:r(`pairedDevicesSection.revokeButton`)})]},e.hashedDeviceId)})})})]})}),(0,Q.jsx)(I,{open:c!==null,title:r(`pairedDevicesSection.confirmTitle`),message:c&&(0,Q.jsxs)(Q.Fragment,{children:[r(`pairedDevicesSection.confirmMessageNamed`,{name:Na(r,c).name,hash:ja(c.hashedDeviceId)}),o.revokeError&&(0,Q.jsx)(`span`,{className:`mt-2 block text-[var(--system-negative-strong)]`,children:o.revokeError})]}),confirmLabel:r(`pairedDevicesSection.revokeButton`),destructive:!0,isPending:o.isRevoking,onConfirm:o.confirmRevoke,onCancel:o.cancelRevoke})]})}var La=5e3;function Ra(e,t){return e.length===t.length&&t.every((t,n)=>e[n]?.requestId===t.requestId)}function za(e,t){let[n,r]=(0,Z.useState)([]),[i,a]=(0,Z.useState)(null),[o,s]=(0,Z.useState)(null),[c,l]=(0,Z.useState)(null),u=(0,Z.useRef)(null),d=(0,Z.useRef)(null),[f,p]=(0,Z.useState)(e);e!==f&&(p(e),r([]),a(null),s(null),l(null)),(0,Z.useEffect)(()=>()=>{d.current?.abort(),d.current=null},[e]),(0,Z.useEffect)(()=>{let t=async()=>{u.current?.abort();let t=new AbortController;u.current=t;try{let n=await Wi({base:e,signal:t.signal});if(t.signal.aborted)return;r(e=>Ra(e,n)?e:n),l(e=>e&&!e.sticky&&!n.some(t=>t.requestId===e.requestId)?null:e),s(null)}catch(e){if(t.signal.aborted)return;if(e instanceof Fi){s(e.message);return}B(e,{context:`pair-device-pending-requests-poll`}),s(G(`settings:usePendingPairingRequests.pollErrorFallback`))}};t();let n=setInterval(()=>void t(),La);return()=>{clearInterval(n),u.current?.abort()}},[e]);let m=(0,Z.useCallback)(async(n,i)=>{if(d.current)return;let o=new AbortController;d.current=o,a({requestId:n,action:i}),l(null);let s=()=>{u.current?.abort(),r(e=>e.filter(e=>e.requestId!==n))};try{if(await(i===`approve`?Ki:qi)({base:e,requestId:n,signal:o.signal}),o.signal.aborted)return;s(),i===`approve`&&t?.()}catch(e){if(o.signal.aborted)return;e instanceof Fi?i===`deny`&&e.status===409&&e.code===`ALREADY_APPROVED`?(s(),t?.(),l({requestId:n,message:G(`settings:usePendingPairingRequests.denyAlreadyApproved`),sticky:!0})):e.status===404||e.status===410?s():l({requestId:n,message:e.message}):(B(e,{context:`pair-device-pending-request-action`}),l({requestId:n,message:G(`settings:usePendingPairingRequests.actionErrorFallback`)}))}finally{d.current===o&&(d.current=null),o.signal.aborted||a(null)}},[e,t]),h=(0,Z.useCallback)(e=>m(e,`approve`),[m]),g=(0,Z.useCallback)(e=>m(e,`deny`),[m]);return{requests:n,actingOn:i,error:c?.message??o,approve:h,deny:g}}function Ba({base:e,onApproved:t}){let{t:r}=J(`settings`),{requests:i,actingOn:a,error:o,approve:s,deny:c}=za(e,t);return $n(i.length>0),i.length===0&&!o?null:(0,Q.jsxs)(`section`,{className:`flex flex-col gap-3 border-t border-[var(--border-element)] pt-4`,children:[(0,Q.jsxs)(`div`,{className:`flex flex-col gap-1`,children:[(0,Q.jsx)(`h3`,{className:`text-title-small text-[var(--content-emphasised)]`,children:r(`pendingPairingRequests.title`)}),(0,Q.jsx)(`p`,{className:`text-body-small-default text-[var(--content-tertiary)]`,children:r(`pendingPairingRequests.instruction`)})]}),o&&(0,Q.jsx)(V,{tone:`error`,title:o}),i.length>0&&(0,Q.jsx)(`ul`,{className:`flex flex-col gap-2`,children:i.map(e=>{let t=a!==null&&a.requestId===e.requestId?a.action:null,i=t===`approve`,o=t===`deny`;return(0,Q.jsxs)(`li`,{className:`flex flex-col gap-2 rounded-lg border border-[var(--border-element)] p-3`,children:[(0,Q.jsx)(`code`,{className:kt(`rounded-md bg-[var(--surface-active)] text-body-small-default text-[color:var(--content-primary)]`,`w-fit px-2.5 py-1.5 text-title-medium tracking-wide text-[color:var(--content-emphasised)]`),children:e.userCode}),(0,Q.jsxs)(`div`,{className:`flex flex-col gap-0.5`,children:[(0,Q.jsx)(`p`,{className:`text-body-small-default text-[var(--content-tertiary)]`,children:e.viaEdgeProxy===!1?r(`pendingPairingRequests.requestedMetaHost`,{when:Qn(e.requestedAt)}):r(`pendingPairingRequests.requestedMeta`,{when:Qn(e.requestedAt),ip:e.requesterIp})}),e.requesterUserAgent&&(0,Q.jsx)(`p`,{className:`truncate text-body-small-default text-[var(--content-tertiary)]`,title:e.requesterUserAgent,children:e.requesterUserAgent})]}),(0,Q.jsxs)(`div`,{className:`flex gap-2`,children:[(0,Q.jsx)(n,{variant:`primary`,size:`compact`,disabled:a!==null,"aria-busy":i||void 0,leftIcon:i?(0,Q.jsx)(Y,{className:`animate-spin`}):void 0,onClick:()=>void s(e.requestId),children:r(`pendingPairingRequests.approveButton`)}),(0,Q.jsx)(n,{variant:`dangerOutline`,size:`compact`,disabled:a!==null,"aria-busy":o||void 0,leftIcon:o?(0,Q.jsx)(Y,{className:`animate-spin`}):void 0,onClick:()=>void c(e.requestId),children:r(`pendingPairingRequests.denyButton`)})]})]},e.requestId)})})]})}function Va({onRefresh:e,isRefreshing:t,labelled:r=!1}){let{t:i}=J(`settings`),a=i(`tunnelStatusRow.refreshLabel`),o=(0,Q.jsx)(Fn,{className:t?`animate-spin`:void 0});return r?(0,Q.jsx)(n,{variant:`outlined`,size:`compact`,leftIcon:o,disabled:t,onClick:e,children:a}):(0,Q.jsx)(n,{variant:`ghost`,size:`compact`,iconOnly:o,"aria-label":a,disabled:t,onClick:e})}function Ha(e){return`publicBaseUrl`in e&&e.publicBaseUrl?e.publicBaseUrl:null}function Ua(e){return`checkedAt`in e&&e.checkedAt?e.checkedAt:null}function Wa(e,t){let n=t?.trim();return n?`vellum tunnel ${Ka(n)} --provider ${e}`:`vellum tunnel --provider ${e}`}var Ga=/^[A-Za-z0-9._-]+$/;function Ka(e){return Ga.test(e)?e:`'${e.replace(/'/g,`'\\''`)}'`}var qa={checking:`var(--content-tertiary)`,stopped:`var(--content-tertiary)`,healthy:`var(--system-positive-strong)`,unpairable:`var(--system-mid-strong)`,unreachable:`var(--system-mid-strong)`,foreign:`var(--system-negative-strong)`},Ja=`text-body-small-default text-[var(--content-tertiary)]`,Ya=`truncate ${Ja}`;function Xa({status:e,onRefresh:t,isRefreshing:n,assistantName:r=null}){let{t:i}=J(`settings`);if(e.kind===`unconfigured`||e.kind===`unavailable`)return null;let a=Ua(e),o=Ha(e),s=`provider`in e?e.provider:void 0,c=`detail`in e?e.detail:void 0;return(0,Q.jsxs)(`div`,{className:`flex items-start gap-2.5 rounded-lg border border-[var(--border-element)] px-3 py-2.5`,children:[(0,Q.jsx)(`span`,{"aria-hidden":!0,className:`mt-1.5 inline-block h-2 w-2 shrink-0 rounded-full`,style:{backgroundColor:qa[e.kind]}}),(0,Q.jsxs)(`div`,{className:`flex min-w-0 flex-1 flex-col gap-1`,children:[(0,Q.jsx)(`p`,{className:`text-body-small-default text-[var(--content-default)]`,children:Za(e,i)}),c&&(0,Q.jsx)(`p`,{className:Ya,title:c,children:c}),s&&(0,Q.jsx)(`p`,{className:Ja,children:(0,Q.jsx)(cn,{i18nKey:e.kind===`stopped`?`tunnelStatusRow.stoppedRestart`:`tunnelStatusRow.restartHint`,ns:`settings`,values:{command:Wa(s,r)},components:{code:(0,Q.jsx)(`code`,{className:kt(`rounded-md bg-[var(--surface-active)] text-body-small-default text-[color:var(--content-primary)]`,`px-1.5 py-0.5`)})}})}),o&&(0,Q.jsx)(`p`,{className:Ya,title:o,children:o}),a&&(0,Q.jsx)(`p`,{className:Ja,children:i(`tunnelStatusRow.checkedAt`,{when:Qn(a)})})]}),(0,Q.jsx)(Va,{onRefresh:t,isRefreshing:n})]})}function Za(e,t){switch(e.kind){case`checking`:return t(`tunnelStatusRow.checkingStatus`);case`stopped`:return t(`tunnelStatusRow.stoppedStatus`);case`healthy`:return t(`tunnelStatusRow.healthyStatus`);case`unpairable`:return t(`tunnelStatusRow.unpairableStatus`);case`unreachable`:return t(`tunnelStatusRow.unreachableStatus`);case`foreign`:return e.servingAssistantName?t(`tunnelStatusRow.foreignStatusNamed`,{name:e.servingAssistantName}):t(`tunnelStatusRow.foreignStatus`)}}var Qa=`vellum:pair-device:public-base-url`;function $a(e){let t=e?.trim();if(t)return{url:t,source:`tunnel`};let n=nt(Qa,``).trim();return n?{url:n,source:`stored`}:{url:``,source:`none`}}function eo(e,t){let n=(0,Z.useMemo)(()=>$a(t),[t]),[r,i]=(0,Z.useState)(null),a=r??n.url,[o,s]=(0,Z.useState)(null),[c,l]=(0,Z.useState)({kind:`idle`}),[u,d]=(0,Z.useState)(()=>Date.now()),f=(0,Z.useRef)(null);(0,Z.useEffect)(()=>()=>f.current?.abort(),[]),(0,Z.useEffect)(()=>{if(c.kind!==`ready`)return;d(Date.now());let e=setInterval(()=>d(Date.now()),1e3);return()=>clearInterval(e)},[c]);let p=(0,Z.useCallback)(e=>{i(e),s(null)},[]),m=(0,Z.useCallback)(()=>{if(!e)return;let t=a.trim(),n=Tt(t);if(!n.ok){s(bt(n.reason,t));return}s(null),f.current?.abort();let r=new AbortController;f.current=r,l({kind:`minting`}),(async()=>{try{let t=await Hi({base:e,publicBaseUrl:n.url,signal:r.signal});if(r.signal.aborted)return;Ht(Qa,n.url),l({kind:`ready`,pairUrl:t.pairUrl,expiresAtMs:Date.parse(t.expiresAt)})}catch(e){if(r.signal.aborted)return;if(e instanceof Fi){l({kind:`error`,message:e.message,hint:e.hint});return}B(e,{context:`pair-device-mint`}),l({kind:`error`,message:G(`settings:usePairDevice.mintErrorFallback`)})}})()},[e,a]),h=c.kind===`ready`?Math.max(0,c.expiresAtMs-u):0,g=c.kind===`ready`&&h<=0;return{publicBaseUrl:a,setPublicBaseUrl:p,prefillSource:n.source,inputError:o,phase:c,remainingMs:h,expired:g,generate:m}}var to=`0.11.6`;function no(e){return Ze(to,e)}function ro(e){let t=tt(),n=no(t),r=m(),i=e&&n&&r,{data:a,isFetching:o,refetch:s}=K({...zt({path:{assistant_id:t}}),enabled:i,staleTime:0,refetchOnWindowFocus:!1}),c=(0,Z.useCallback)(()=>{i&&s()},[i,s]);return{status:io(a,o),isRefreshing:o,refresh:c}}function io(e,t){if(!e)return t?{kind:`checking`}:{kind:`unavailable`};let{lastTunnel:n}=e,r=e.publicBaseUrl??``,i=e.checkedAt??``,a=n?{provider:n.provider}:{};switch(e.state){case`unconfigured`:return{kind:`unconfigured`};case`stopped`:return{kind:`stopped`,...a,...n?{publicBaseUrl:n.publicBaseUrl}:{}};case`healthy`:return{kind:`healthy`,publicBaseUrl:r,checkedAt:i};case`unpairable`:case`unreachable`:return{kind:e.state,publicBaseUrl:r,checkedAt:i,...e.detail?{detail:e.detail}:{},...a};case`foreign`:return{kind:`foreign`,publicBaseUrl:r,checkedAt:i,...e.servingAssistantName?{servingAssistantName:e.servingAssistantName}:{},...a};default:return{kind:`unavailable`}}}var ao=`tailscale`,oo=`public-url`,so=new Set([`unpairable`,`unreachable`,`foreign`]),co=`vellum tunnel --help`,lo=ae(v.docs.pairADevice);function uo(){let{t:e}=J(`settings`),t=Li(),r=Oi(),i=R.use.pairedDevicesUI(),a=ro(r&&t!==null),s=a.status.kind!==`unavailable`;o(`app.resume`,()=>{a.refresh()}),$n(Ua(a.status)!==null);let c=a.status.kind===`stopped`?null:Ha(a.status),l=eo(t?.base??null,s?c:t?.ingressUrl??null),[u,d]=(0,Z.useState)(0),[f,p]=(0,Z.useState)(!1),{copy:m,copied:h}=he({errorMessage:e(`pairDeviceCard.copyError`)});if(!t||!r)return null;let g=t.assistantName??e(`pairDeviceCard.subtitleFallbackName`),{phase:_}=l,v=_.kind===`minting`,y=_.kind===`ready`,b=l.prefillSource===`tunnel`,x=s?a.status.kind===`unconfigured`:l.prefillSource===`none`&&l.publicBaseUrl.trim()===``,S=x&&s,C=s&&so.has(a.status.kind),w=e(v?`pairDeviceCard.generateButtonMinting`:y?`pairDeviceCard.generateButtonRegenerate`:C?`pairDeviceCard.generateButtonWarned`:`pairDeviceCard.generateButton`),T=s&&c!==null,E=f||l.inputError!==null,D=(0,Q.jsx)(n,{variant:C?`outlined`:`primary`,className:`self-start`,disabled:v||l.publicBaseUrl.trim()===``,onClick:l.generate,children:w}),O=(0,Q.jsx)(z,{label:e(`pairDeviceCard.publicUrlLabel`),fullWidth:!0,placeholder:e(`pairDeviceCard.publicUrlPlaceholder`),helperText:e(b?`pairDeviceCard.publicUrlHelperTunnel`:`pairDeviceCard.publicUrlHelper`),value:l.publicBaseUrl,errorText:l.inputError??void 0,disabled:v,onChange:e=>{p(!0),l.setPublicBaseUrl(e.target.value)},onKeyDown:e=>{e.key===`Enter`&&(e.preventDefault(),l.generate())}});return(0,Q.jsx)(X,{title:e(`pairDeviceCard.title`),subtitle:e(`pairDeviceCard.subtitle`,{name:g}),children:(0,Q.jsxs)(`div`,{className:`flex flex-col gap-4`,children:[x&&(0,Q.jsx)(V,{tone:`info`,title:e(`pairDeviceCard.noTunnelTitle`),actions:S?(0,Q.jsx)(Va,{onRefresh:a.refresh,isRefreshing:a.isRefreshing,labelled:!0}):void 0,children:(0,Q.jsxs)(`div`,{className:`flex flex-col gap-2`,children:[(0,Q.jsx)(`p`,{children:e(`pairDeviceCard.noTunnelWhy`,{name:g})}),(0,Q.jsx)(`code`,{className:kt(`rounded-md bg-[var(--surface-active)] text-body-small-default text-[color:var(--content-primary)]`,`w-fit max-w-full overflow-x-auto px-2.5 py-1.5`),children:Wa(ao,t.assistantName)}),(0,Q.jsx)(`p`,{children:e(`pairDeviceCard.noTunnelNext`)}),(0,Q.jsx)(`p`,{children:(0,Q.jsx)(cn,{i18nKey:`pairDeviceCard.noTunnelMore`,ns:`settings`,values:{command:co},components:{code:(0,Q.jsx)(`code`,{className:kt(`rounded-md bg-[var(--surface-active)] text-body-small-default text-[color:var(--content-primary)]`,`px-1.5 py-0.5`)})}})})]})}),(0,Q.jsx)(Xa,{status:a.status,onRefresh:a.refresh,isRefreshing:a.isRefreshing,assistantName:t.assistantName}),(0,Q.jsx)(`div`,{className:`flex flex-col gap-3`,children:T?(0,Q.jsxs)(Q.Fragment,{children:[D,(0,Q.jsx)(H.Root,{type:`single`,collapsible:!0,value:E?oo:``,onValueChange:e=>p(e===oo),children:(0,Q.jsxs)(H.Item,{value:oo,children:[(0,Q.jsxs)(H.Trigger,{className:`group flex w-full items-center justify-between gap-3`,children:[(0,Q.jsx)(`span`,{className:`text-body-medium-default text-[var(--content-secondary)]`,children:e(`pairDeviceCard.publicUrlDisclosure`)}),(0,Q.jsx)(En,{className:`h-4 w-4 shrink-0 text-[var(--content-tertiary)] transition-transform group-data-[state=open]:rotate-180`})]}),(0,Q.jsx)(H.Content,{children:(0,Q.jsx)(`div`,{className:`mt-3`,children:O})})]})})]}):(0,Q.jsxs)(Q.Fragment,{children:[O,D]})}),_.kind===`error`&&(0,Q.jsx)(V,{tone:`error`,title:_.message,children:_.hint}),y&&(0,Q.jsx)(Sa,{pairUrl:_.pairUrl,remainingMs:l.remainingMs,expired:l.expired,copied:h,onCopy:m}),(0,Q.jsx)(Ba,{base:t.base,onApproved:()=>d(e=>e+1)}),i&&(0,Q.jsx)(Ia,{pollWhilePairing:y&&!l.expired,revalidateKey:u}),(0,Q.jsx)(`a`,{href:lo,target:`_blank`,rel:`noopener noreferrer`,onClick:e=>jt(e,lo),className:`self-start text-body-medium-default text-[var(--content-tertiary)] underline hover:text-[var(--content-default)]`,children:e(`pairDeviceCard.learnMore`)})]})})}function fo(e){return[{scope:`global`,title:e(`shortcutsSections.globalTitle`),description:e(`shortcutsSections.globalDescription`)},{scope:`menu`,title:e(`shortcutsSections.appTitle`),description:e(`shortcutsSections.appDescription`)}]}function po({hotkey:e,recording:t,conflictLabel:r,alternateBinding:i,onStartRecording:a,onCancelRecording:o,onReset:s,onRemove:c}){let{t:l}=J(`settings`),u=e.accelerator===``,d=e.override!==null;return(0,Q.jsxs)(`div`,{className:`flex items-center justify-between gap-3 py-2`,children:[(0,Q.jsxs)(`div`,{className:`min-w-0`,children:[(0,Q.jsx)(`div`,{className:`truncate text-body-medium-lighter text-[var(--content-default)]`,children:e.label}),r!==null&&(0,Q.jsx)(`div`,{className:`text-body-small-default text-[var(--system-negative-strong)]`,children:l(`shortcutsSections.alreadyUsedBy`,{label:r})})]}),(0,Q.jsxs)(`div`,{className:`flex shrink-0 items-center gap-2`,children:[i,t?(0,Q.jsx)(`span`,{className:`text-body-small-default text-[var(--content-secondary)]`,children:l(`shortcutsSections.recordingHint`)}):u?(0,Q.jsx)(`span`,{className:`text-body-small-default italic text-[var(--content-disabled)]`,children:l(`shortcutsSections.none`)}):(0,Q.jsx)(Ct,{accelerator:e.accelerator}),t?(0,Q.jsx)(n,{variant:`ghost`,size:`compact`,onClick:o,children:l(`shortcutsSections.cancel`)}):(0,Q.jsx)(n,{variant:`outlined`,size:`compact`,onClick:a,"aria-label":l(`shortcutsSections.recordShortcutAriaLabel`,{label:e.label}),children:l(`shortcutsSections.record`)}),(0,Q.jsx)(n,{variant:`ghost`,size:`compact`,disabled:!d,leftIcon:(0,Q.jsx)(kn,{className:`h-3.5 w-3.5`}),onClick:s,"aria-label":l(`shortcutsSections.resetShortcutAriaLabel`,{label:e.label})}),(0,Q.jsx)(n,{variant:`ghost`,size:`compact`,disabled:u,leftIcon:(0,Q.jsx)(Pn,{className:`h-3.5 w-3.5`}),onClick:c,"aria-label":l(`shortcutsSections.removeBindingAriaLabel`,{label:e.label})})]})]})}function mo(){let{t:e}=J(`settings`),{catalog:t,recordingKey:n,conflict:r,startRecording:i,stopRecording:a,resetHotkey:o,removeHotkey:s}=tr(),c=(0,Z.useMemo)(()=>fo(e).map(e=>({...e,commands:t.filter(t=>t.rebindable&&t.scope===e.scope)})).filter(e=>e.commands.length>0),[t,e]);return(0,Q.jsxs)(`div`,{className:`space-y-4`,children:[r!==null&&(0,Q.jsxs)(V,{tone:`warning`,children:[e(`shortcutsSections.conflictNoticePrefix`,{label:r.label}),` `,e(n===null?`shortcutsSections.conflictResetHint`:`shortcutsSections.conflictRecordingHint`)]}),c.map(e=>(0,Q.jsxs)(Ie,{bordered:!0,children:[(0,Q.jsxs)(`div`,{className:`mb-2`,children:[(0,Q.jsx)(`div`,{className:`text-body-medium-default text-[var(--content-default)]`,children:e.title}),(0,Q.jsx)(`div`,{className:`text-body-small-default text-[var(--content-tertiary)]`,children:e.description})]}),(0,Q.jsx)(`div`,{className:`divide-y divide-[var(--border-base)]`,children:e.commands.map(e=>(0,Q.jsx)(po,{hotkey:e,recording:n===e.key,conflictLabel:r!==null&&r.key===e.key?r.label:null,onStartRecording:()=>i(e.key),onCancelRecording:a,onReset:()=>o(e.key),onRemove:()=>s(e.key)},e.key))})]},e.scope))]})}async function ho(){if(!E())return!1;let e=window.vellum;return e?.launchAtLogin?e.launchAtLogin.get():!1}async function go(e){if(!E())return;let t=window.vellum;t?.launchAtLogin&&await t.launchAtLogin.set(e)}function _o(){let{t:e}=J(`settings`),t=ve.useValue(),n=rn.useValue(),r=!Kt(),i=_e();return(0,Q.jsxs)(`section`,{children:[(0,Q.jsx)(`h3`,{className:`text-title-small text-[var(--content-emphasised)]`,children:e(`preferencesModal.composerTitle`)}),(0,Q.jsxs)(`div`,{className:`mt-2 space-y-4`,children:[r&&(0,Q.jsx)(T,{checked:t,onChange:ve.save,label:e(i?`preferencesModal.sendWithCmdEnter`:`preferencesModal.sendWithCtrlEnter`),helperText:e(i?`preferencesModal.sendWithCmdEnterHelper`:`preferencesModal.sendWithCtrlEnterHelper`)}),(0,Q.jsx)(T,{checked:n,onChange:rn.save,label:e(`preferencesModal.showContextWindow`),helperText:e(`preferencesModal.showContextWindowHelper`)})]})]})}function vo(){let{t:e}=J(`settings`),[t,n]=(0,Z.useState)(!1);(0,Z.useEffect)(()=>{ho().then(n)},[]);let r=async e=>{n(e);try{await go(e)}catch{n(!e)}};return(0,Q.jsxs)(`section`,{children:[(0,Q.jsx)(`h3`,{className:`text-title-small text-[var(--content-emphasised)]`,children:e(`preferencesModal.launchAtLoginTitle`)}),(0,Q.jsx)(`p`,{className:`text-body-medium-default text-[var(--content-tertiary)]`,children:e(Gt()===`windows`?`preferencesModal.launchAtLoginDescriptionWindows`:`preferencesModal.launchAtLoginDescription`)}),(0,Q.jsx)(`div`,{className:`mt-2`,children:(0,Q.jsx)(T,{checked:t,onChange:e=>void r(e),"aria-label":e(`preferencesModal.launchAtLoginAriaLabel`)})})]})}function yo({open:e,onClose:t}){let{t:n}=J(`settings`);return(0,Q.jsx)(b.Root,{open:e,onOpenChange:e=>{e||t()},children:(0,Q.jsxs)(b.Content,{size:`lg`,children:[(0,Q.jsxs)(b.Header,{children:[(0,Q.jsx)(b.Title,{children:n(`preferencesModal.title`)}),(0,Q.jsx)(b.Description,{children:n(`preferencesModal.description`)})]}),(0,Q.jsx)(b.Body,{children:(0,Q.jsxs)(`div`,{className:`space-y-6`,children:[E()&&(0,Q.jsxs)(`section`,{children:[(0,Q.jsx)(`h3`,{className:`text-title-small text-[var(--content-emphasised)]`,children:n(`preferencesModal.keyboardShortcutsTitle`)}),(0,Q.jsx)(`p`,{className:`text-body-medium-default text-[var(--content-tertiary)]`,children:n(`preferencesModal.keyboardShortcutsDescription`)}),(0,Q.jsx)(`div`,{className:`mt-2`,children:(0,Q.jsx)(mo,{})})]}),(0,Q.jsx)(_o,{}),E()&&(0,Q.jsx)(vo,{})]})})]})})}function bo(e){return e===`preview`?`preview`:`stable`}function xo(e,t){if(!e)return t;let n=new Date(e);return Number.isNaN(n.getTime())?t:n.toLocaleString(void 0,{year:`numeric`,month:`short`,day:`numeric`,hour:`numeric`,minute:`2-digit`})}function So(e){return e.filter(e=>e.ready_to_use)}function Co(e){return e?.feature_enabled===!1}function wo({assistantId:e,onComplete:t}){let{t:n}=J(`settings`),r=R.use.previewChannel(),i=q(),[a,o]=(0,Z.useState)(),[s,c]=(0,Z.useState)(!1),[l,u]=(0,Z.useState)(!1),[d,f]=(0,Z.useState)(`restore_backup`),[p,m]=(0,Z.useState)(``),h=Et({path:{assistant_id:e}}),g=pt({path:{assistant_id:e}}),_=Re({path:{id:e}}),{data:v,isLoading:y,isError:b}=K({...h,enabled:r,retry:!1}),x=(0,Z.useMemo)(()=>So(v?.preview_backups??[]),[v?.preview_backups]),S=x[0],C=x.find(e=>e.snapshot_name===p)??S,w=()=>{i.invalidateQueries({queryKey:g}),i.invalidateQueries({queryKey:_}),t?.()},T=sn(at()),E=sn(Ft()),D=bo(v?.current_channel),O=T.isPending||E.isPending,k=O||Co(v)||!v?.latest_preview_release,A=d===`restore_backup`&&!C;if((0,Z.useEffect)(()=>{o(D===`preview`?`release-channel`:void 0)},[D]),!r)return null;let j=v?.standard_upgrade_available??!1;return(0,Q.jsxs)(Q.Fragment,{children:[(0,Q.jsx)(H.Root,{type:`single`,collapsible:!0,value:a,onValueChange:e=>o(e||void 0),className:`mt-5 border-t border-[var(--border-base)] pt-5`,children:(0,Q.jsxs)(H.Item,{value:`release-channel`,id:`preview-release-channel`,children:[(0,Q.jsxs)(H.Trigger,{className:`group justify-between gap-3`,children:[(0,Q.jsxs)(`span`,{className:`flex min-w-0 items-center gap-2`,children:[(0,Q.jsx)(`span`,{className:`text-body-medium-default text-[var(--content-secondary)]`,children:n(`previewReleaseChannel.title`)}),v&&(0,Q.jsx)(N,{tone:D===`preview`?`warning`:`neutral`,children:n(D===`preview`?`previewReleaseChannel.preview`:`previewReleaseChannel.stable`)})]}),(0,Q.jsx)(En,{className:`h-4 w-4 shrink-0 text-[var(--content-tertiary)] transition-transform group-data-[state=open]:rotate-180`})]}),(0,Q.jsx)(H.Content,{children:(0,Q.jsxs)(`div`,{className:`mt-4 space-y-4`,children:[y&&(0,Q.jsxs)(`div`,{className:`flex items-center gap-2 text-body-medium-lighter text-[var(--content-tertiary)]`,children:[(0,Q.jsx)(Y,{className:`h-4 w-4 animate-spin`}),n(`previewReleaseChannel.loading`)]}),b&&(0,Q.jsx)(V,{tone:`error`,title:n(`previewReleaseChannel.loadErrorTitle`),children:n(`previewReleaseChannel.loadErrorBody`)}),v&&(0,Q.jsxs)(Q.Fragment,{children:[Co(v)&&(0,Q.jsx)(V,{tone:`neutral`,title:n(`previewReleaseChannel.unavailableTitle`),children:n(`previewReleaseChannel.unavailableBody`)}),D===`stable`?(0,Q.jsx)(To,{status:v,isChangingChannel:O,optInDisabled:k,onOptIn:()=>c(!0)}):(0,Q.jsx)(Eo,{status:v,isChangingChannel:O,onOptOut:()=>{let e=S;m(e?.snapshot_name??``),f(e?`restore_backup`:j?`standard_upgrade`:`restore_backup`),u(!0)}})]})]})})]})}),(0,Q.jsx)(Oo,{open:s,isPending:T.isPending,previewVersion:v?.latest_preview_release?.version,onConfirm:async()=>{try{let t=await T.mutateAsync({path:{assistant_id:e}});L.success(t.detail||n(`previewReleaseChannel.previewEnabledToast`)),c(!1),w()}catch(e){L.error(Pe(e,void 0,n(`previewReleaseChannel.previewEnableFailedToast`)))}},onCancel:()=>c(!1)}),(0,Q.jsx)(ko,{open:l,backups:x,mode:d,selectedSnapshotName:C?.snapshot_name??``,isPending:E.isPending,restoreModeDisabled:A,standardUpgradeAvailable:j,onModeChange:f,onSnapshotChange:m,onConfirm:async()=>{if(!A)try{let t=await E.mutateAsync({path:{assistant_id:e},body:d===`restore_backup`?{mode:`restore_backup`,snapshot_name:C?.snapshot_name}:{mode:`standard_upgrade`}});L.success(t.detail||n(`previewReleaseChannel.stableEnabledToast`)),u(!1),w()}catch(e){L.error(Pe(e,void 0,`Could not switch to Stable.`))}},onCancel:()=>u(!1)})]})}function To({status:e,isChangingChannel:t,optInDisabled:r,onOptIn:i}){let{t:a}=J(`settings`);return(0,Q.jsxs)(`div`,{className:`space-y-4`,children:[(0,Q.jsx)(Do,{status:e}),!e.latest_preview_release&&(0,Q.jsx)(V,{tone:`neutral`,title:a(`previewReleaseChannel.noPreviewTitle`),children:a(`previewReleaseChannel.noPreviewBody`)}),(0,Q.jsx)(n,{variant:`outlined`,leftIcon:t?(0,Q.jsx)(Y,{className:`animate-spin`}):(0,Q.jsx)(Cn,{}),disabled:r,onClick:i,children:a(`previewReleaseChannel.optIn`)})]})}function Eo({status:e,isChangingChannel:t,onOptOut:r}){let{t:i}=J(`settings`);return(0,Q.jsxs)(`div`,{className:`space-y-4`,children:[(0,Q.jsx)(Do,{status:e}),(0,Q.jsx)(n,{variant:`outlined`,leftIcon:t?(0,Q.jsx)(Y,{className:`animate-spin`}):(0,Q.jsx)(kn,{}),disabled:t,onClick:r,children:i(`previewReleaseChannel.switchBack`)})]})}function Do({status:e}){let{t}=J(`settings`);return(0,Q.jsxs)(`dl`,{className:`grid gap-3 text-body-medium-lighter sm:grid-cols-2`,children:[(0,Q.jsxs)(`div`,{children:[(0,Q.jsx)(`dt`,{className:`text-[var(--content-tertiary)]`,children:t(`previewReleaseChannel.latestStable`)}),(0,Q.jsx)(`dd`,{className:`break-all text-[var(--content-default)]`,children:e.latest_stable_release?.version??t(`previewReleaseChannel.none`)})]}),(0,Q.jsxs)(`div`,{children:[(0,Q.jsx)(`dt`,{className:`text-[var(--content-tertiary)]`,children:t(`previewReleaseChannel.latestPreview`)}),(0,Q.jsx)(`dd`,{className:`break-all text-[var(--content-default)]`,children:e.latest_preview_release?.version??t(`previewReleaseChannel.none`)})]})]})}function Oo({open:e,isPending:t,previewVersion:r,onConfirm:i,onCancel:a}){let{t:o}=J(`settings`);return(0,Q.jsx)(b.Root,{open:e,onOpenChange:e=>!e&&a(),children:(0,Q.jsxs)(b.Content,{size:`md`,hideCloseButton:t,children:[(0,Q.jsxs)(b.Header,{icon:Sn,children:[(0,Q.jsx)(b.Title,{children:o(`previewReleaseChannel.optInTitle`)}),(0,Q.jsx)(b.Description,{children:o(`previewReleaseChannel.optInDescription`)})]}),(0,Q.jsx)(b.Body,{children:(0,Q.jsxs)(`div`,{className:`space-y-3`,children:[(0,Q.jsx)(V,{tone:`warning`,title:o(`previewReleaseChannel.dataLossTitle`),children:o(`previewReleaseChannel.dataLossBody`)}),(0,Q.jsxs)(`ol`,{className:`list-decimal space-y-2 pl-5 text-body-medium-lighter text-[var(--content-secondary)]`,children:[(0,Q.jsx)(`li`,{children:o(`previewReleaseChannel.optInStep1`)}),(0,Q.jsx)(`li`,{children:o(`previewReleaseChannel.optInStep2`,{version:r??o(`previewReleaseChannel.latest`)})}),(0,Q.jsx)(`li`,{children:o(`previewReleaseChannel.optInStep3`)})]})]})}),(0,Q.jsxs)(b.Footer,{children:[(0,Q.jsx)(n,{variant:`outlined`,disabled:t,onClick:a,children:o(`previewReleaseChannel.cancel`)}),(0,Q.jsx)(n,{variant:`primary`,disabled:t,leftIcon:t?(0,Q.jsx)(Y,{className:`animate-spin`}):(0,Q.jsx)(Cn,{}),onClick:i,children:o(t?`previewReleaseChannel.switching`:`previewReleaseChannel.takeBackupAndSwitch`)})]})]})})}function ko({open:e,backups:t,mode:r,selectedSnapshotName:i,isPending:a,restoreModeDisabled:o,standardUpgradeAvailable:s,onModeChange:c,onSnapshotChange:l,onConfirm:d,onCancel:f}){let{t:m}=J(`settings`),h=m(`previewReleaseChannel.unknownDate`);return(0,Q.jsx)(b.Root,{open:e,onOpenChange:e=>!e&&f(),children:(0,Q.jsxs)(b.Content,{size:`md`,hideCloseButton:a,children:[(0,Q.jsxs)(b.Header,{icon:Sn,children:[(0,Q.jsx)(b.Title,{children:m(`previewReleaseChannel.optOutTitle`)}),(0,Q.jsx)(b.Description,{children:m(`previewReleaseChannel.optOutDescription`)})]}),(0,Q.jsx)(b.Body,{children:(0,Q.jsxs)(`div`,{className:`space-y-4`,children:[(0,Q.jsxs)(u,{value:r,onValueChange:c,disabled:a,"aria-label":m(`previewReleaseChannel.returnMethodAriaLabel`),children:[(0,Q.jsx)(an,{value:`restore_backup`,disabled:t.length===0,label:m(`previewReleaseChannel.restoreBackupLabel`),helperText:m(`previewReleaseChannel.restoreBackupHelper`)}),(0,Q.jsx)(an,{value:`standard_upgrade`,disabled:!s,label:m(`previewReleaseChannel.standardUpgradeLabel`),helperText:m(s?`previewReleaseChannel.standardUpgradeHelper`:`previewReleaseChannel.standardUpgradeUnavailable`)})]}),r===`restore_backup`&&t.length>0&&(0,Q.jsxs)(`label`,{className:`flex flex-col gap-1 text-body-medium-default text-[var(--content-secondary)]`,children:[m(`previewReleaseChannel.safetyBackup`),(0,Q.jsx)(p,{value:i,onChange:l,disabled:a,options:t.map(e=>{let t=e.source_release_version?m(`previewReleaseChannel.stableBackupLabel`,{version:e.source_release_version}):e.snapshot_name;return{value:e.snapshot_name,label:m(`previewReleaseChannel.backupOptionLabel`,{name:t,date:xo(e.created_at,h)})}})})]}),r===`restore_backup`&&t.length===0&&!s&&(0,Q.jsx)(V,{tone:`error`,title:m(`previewReleaseChannel.requiresBackupTitle`),children:m(`previewReleaseChannel.requiresBackupBody`)}),r===`standard_upgrade`&&(0,Q.jsx)(V,{tone:`error`,title:m(`previewReleaseChannel.mayNotSurviveTitle`),children:m(`previewReleaseChannel.mayNotSurviveBody`)})]})}),(0,Q.jsxs)(b.Footer,{children:[(0,Q.jsx)(n,{variant:`outlined`,disabled:a,onClick:f,children:m(`previewReleaseChannel.cancel`)}),(0,Q.jsx)(n,{variant:r===`standard_upgrade`?`danger`:`primary`,disabled:a||o||r===`standard_upgrade`&&!s,leftIcon:a?(0,Q.jsx)(Y,{className:`animate-spin`}):(0,Q.jsx)(Fn,{}),onClick:d,children:m(a?`previewReleaseChannel.switching`:`previewReleaseChannel.switchToStable`)})]})]})})}function Ao(){let{t:e}=J(`settings`),t=h.use.user(),n=(0,Z.useCallback)(e=>{j(e),window.location.reload()},[]);if(!Me(t))return null;let r=Lt(),i=te(),a=i.version??e(`previewUiChannel.versionUnknown`);return(0,Q.jsxs)(`div`,{className:`flex items-start justify-between gap-4`,children:[(0,Q.jsxs)(`div`,{className:`min-w-0`,children:[(0,Q.jsx)(`p`,{className:`text-body-medium-default text-[var(--content-default)]`,children:e(`previewUiChannel.title`)}),(0,Q.jsx)(`p`,{className:`text-body-small-lighter text-[var(--content-tertiary)]`,children:e(`previewUiChannel.description`)}),(0,Q.jsx)(`p`,{className:`text-body-small-lighter text-[var(--content-tertiary)]`,children:e(i.channel===`preview`?`previewUiChannel.runningPreview`:`previewUiChannel.runningStable`,{version:a})}),r&&i.channel===`stable`&&(0,Q.jsx)(`p`,{className:`text-body-small-lighter text-[var(--content-tertiary)]`,children:e(`previewUiChannel.unavailableHint`)})]}),(0,Q.jsx)(`div`,{className:`shrink-0`,children:(0,Q.jsx)(T,{checked:r,onChange:n,"aria-label":e(r?`previewUiChannel.onAriaLabel`:`previewUiChannel.offAriaLabel`)})})]})}var jo=new Set([`exceeds_machine_tier`,`exceeds_storage_tier`]);function Mo(e,t){return e&&typeof e==`object`&&!Array.isArray(e)&&`error`in e&&typeof e.error==`string`&&jo.has(e.error)?`That size isn't available on your plan.`:Pe(e,void 0,t)}function No({assistant:e,healthz:t,healthzLoading:r,healthzFetching:i,healthzPolling:a,refetch:o,refetchUntilResized:s}){let{t:c}=J(`settings`),l=hn(),u=K(A()),d=u.data,f=!e.is_local,m=d?.plan_id===`pro`,h=K({...ee(),enabled:m}),g=e.machine_size||`small`,_=Vn(h.data?.max_machine_tier??null),y=(0,Z.useMemo)(()=>Wn(_,g,(0,Q.jsx)(N,{tone:`positive`,children:c(`resizeCard.current`)})),[_,g,c]),x=h.data?.selected_storage_gib??null,[S,C]=(0,Z.useState)(!1),w=_.length>0?_[_.length-1]:null,[T,E]=(0,Z.useState)(null),D=T??w??g,[O,k]=(0,Z.useState)(!1),[j,M]=(0,Z.useState)(null),te=Wt({onSuccess:(e,n)=>{L.success(c(`resizeCard.toastStarted`),{id:`assistant-resize`}),M(null),E(null),C(!1),n.body?.machine_size==null?o():s(t)},onError:e=>{M(Mo(e,c(`resizeCard.resizeFailed`)))}});if(u.isError&&d==null)return(0,Q.jsx)(X,{id:`storage-resources`,title:c(`resizeCard.title`),subtitle:c(`resizeCard.subtitle`),children:(0,Q.jsx)(V,{tone:`error`,children:c(`resizeCard.subscriptionLoadError`)})});let ne=m&&_.includes(D)&&D!==g?D:null,P=m&&x!=null&&!0,re=m&&_.length>0&&Un(g)<Un(_[_.length-1]),F=te.isPending||a,ie=x==null?t?.disk?.totalMb??null:x*1024,I=t?.disk&&ie!=null?{value:t.disk.usedMb,max:ie,caption:c(`resizeCard.usedOf`,{used:Xn(t.disk.usedMb),total:Xn(ie)})}:null,ae=t?.cpu?{value:t.cpu.currentPercent,max:100,caption:`${t.cpu.currentPercent.toFixed(1)}%`}:null,oe=t?.memory?{value:t.memory.currentMb,max:t.memory.maxMb,caption:c(`resizeCard.usedOf`,{used:Xn(t.memory.currentMb),total:Xn(t.memory.maxMb)})}:null,se=(0,Q.jsx)(n,{variant:`ghost`,size:`compact`,onClick:()=>k(!0),children:c(`resizeCard.resize`)}),ce=f?m?P?(0,Q.jsxs)(`button`,{type:`button`,disabled:F,onClick:()=>C(!0),className:`flex items-center gap-1.5 rounded-lg border border-amber-500/30 bg-amber-500/15 px-3 py-1.5 text-body-small-default font-medium text-amber-400 transition-colors hover:bg-amber-500/25 disabled:opacity-50`,children:[(0,Q.jsx)(Dn,{className:`h-3.5 w-3.5`}),c(`resizeCard.increaseStorage`)]}):(0,Q.jsx)(n,{variant:`ghost`,size:`compact`,disabled:F,onClick:()=>C(!0),children:c(`resizeCard.resize`)}):se:null,le=f?m?re?(0,Q.jsxs)(`button`,{type:`button`,disabled:F,onClick:()=>C(!0),className:`flex items-center gap-1.5 rounded-lg border border-amber-500/30 bg-amber-500/15 px-3 py-1.5 text-body-small-default font-medium text-amber-400 transition-colors hover:bg-amber-500/25 disabled:opacity-50`,children:[(0,Q.jsx)(Dn,{className:`h-3.5 w-3.5`}),c(`resizeCard.increaseSize`)]}):(0,Q.jsx)(n,{variant:`ghost`,size:`compact`,disabled:F,onClick:()=>C(!0),children:c(`resizeCard.resize`)}):se:null;return(0,Q.jsxs)(Q.Fragment,{children:[(0,Q.jsx)(X,{id:`storage-resources`,title:c(`resizeCard.title`),subtitle:c(`resizeCard.subtitle`),compactAccessory:!0,accessory:(0,Q.jsx)(n,{variant:`ghost`,size:`compact`,iconOnly:i||a?(0,Q.jsx)(Y,{className:`animate-spin`}):(0,Q.jsx)(Fn,{}),tooltip:c(a?`resizeCard.applyingResize`:`resizeCard.refreshMetrics`),"aria-label":c(`resizeCard.refreshMetrics`),disabled:i||a,onClick:()=>void o()}),children:(0,Q.jsxs)(`div`,{className:`grid grid-cols-1 gap-2 sm:grid-cols-[1fr_2fr]`,children:[(0,Q.jsxs)(`div`,{className:`flex flex-col rounded-lg bg-[var(--surface-base)] p-3`,children:[(0,Q.jsxs)(`div`,{className:`flex items-center justify-between`,children:[(0,Q.jsxs)(`div`,{className:`flex items-center gap-1.5`,children:[(0,Q.jsx)(`span`,{className:`text-[var(--content-tertiary)]`,children:(0,Q.jsx)(jn,{className:`h-3.5 w-3.5`})}),(0,Q.jsx)(`span`,{className:`text-label-medium-default text-[var(--content-tertiary)]`,children:c(`resizeCard.disk`)})]}),ce]}),(0,Q.jsxs)(`div`,{className:`mt-auto flex flex-col gap-1 pt-3`,children:[(0,Q.jsx)(`span`,{className:`text-label-medium-default text-[var(--content-tertiary)]`,children:c(`resizeCard.storage`)}),I?(0,Q.jsx)(Kn,{value:I.value,max:I.max,caption:I.caption}):r?(0,Q.jsx)(`div`,{className:`flex items-center gap-2 text-[var(--content-tertiary)]`,children:(0,Q.jsx)(Y,{className:`h-3 w-3 animate-spin`})}):(0,Q.jsx)(`span`,{className:`text-label-medium-default text-[var(--content-tertiary)]`,children:c(`resizeCard.unavailable`)})]})]}),(0,Q.jsxs)(`div`,{className:`flex flex-col rounded-lg bg-[var(--surface-base)] p-3`,children:[(0,Q.jsxs)(`div`,{className:`flex items-center justify-between`,children:[(0,Q.jsxs)(`div`,{className:`flex items-center gap-1.5`,children:[(0,Q.jsx)(`span`,{className:`text-[var(--content-tertiary)]`,children:(0,Q.jsx)(rr,{className:`h-3.5 w-3.5`})}),(0,Q.jsx)(`span`,{className:`text-label-medium-default text-[var(--content-tertiary)]`,children:c(`resizeCard.machine`)}),(0,Q.jsx)(N,{tone:`neutral`,children:Hn[g]})]}),le]}),(0,Q.jsxs)(`div`,{className:`mt-auto grid grid-cols-2 gap-3 pt-3`,children:[(0,Q.jsxs)(`div`,{className:`flex flex-col gap-1`,children:[(0,Q.jsx)(`span`,{className:`text-label-medium-default text-[var(--content-tertiary)]`,children:c(`resizeCard.cpu`)}),ae?(0,Q.jsx)(Kn,{value:ae.value,max:ae.max,caption:ae.caption}):r?(0,Q.jsx)(`div`,{className:`flex items-center gap-2 text-[var(--content-tertiary)]`,children:(0,Q.jsx)(Y,{className:`h-3 w-3 animate-spin`})}):(0,Q.jsx)(`span`,{className:`text-label-medium-default text-[var(--content-tertiary)]`,children:`—`})]}),(0,Q.jsxs)(`div`,{className:`flex flex-col gap-1`,children:[(0,Q.jsx)(`span`,{className:`text-label-medium-default text-[var(--content-tertiary)]`,children:c(`resizeCard.memory`)}),oe?(0,Q.jsx)(Kn,{value:oe.value,max:oe.max,caption:oe.caption}):r?(0,Q.jsx)(`div`,{className:`flex items-center gap-2 text-[var(--content-tertiary)]`,children:(0,Q.jsx)(Y,{className:`h-3 w-3 animate-spin`})}):(0,Q.jsx)(`span`,{className:`text-label-medium-default text-[var(--content-tertiary)]`,children:`—`})]})]})]})]})}),(0,Q.jsx)(b.Root,{open:O,onOpenChange:e=>{e||k(!1)},children:(0,Q.jsxs)(b.Content,{size:`sm`,children:[(0,Q.jsxs)(b.Header,{children:[(0,Q.jsx)(b.Title,{children:c(`resizeCard.upgradeTitle`)}),(0,Q.jsx)(b.Description,{children:c(`resizeCard.upgradeDescription`)})]}),(0,Q.jsxs)(b.Footer,{children:[(0,Q.jsx)(n,{variant:`ghost`,onClick:()=>k(!1),children:c(`resizeCard.cancel`)}),(0,Q.jsx)(n,{onClick:()=>{k(!1),l(v.plans)},children:c(`resizeCard.upgrade`)})]})]})}),(0,Q.jsx)(b.Root,{open:S,onOpenChange:e=>{e||(C(!1),E(null),M(null))},children:(0,Q.jsxs)(b.Content,{size:`sm`,children:[(0,Q.jsxs)(b.Header,{icon:rr,children:[(0,Q.jsx)(b.Title,{children:c(`resizeCard.modalTitle`)}),(0,Q.jsx)(b.Description,{children:c(`resizeCard.modalDescription`)})]}),(0,Q.jsx)(b.Body,{children:(0,Q.jsxs)(`div`,{className:`flex flex-col gap-3`,children:[_.length===0?(0,Q.jsx)(V,{tone:`warning`,children:c(`resizeCard.noMachineTier`)}):(0,Q.jsxs)(`div`,{className:`flex flex-col gap-1.5`,children:[(0,Q.jsx)(`span`,{className:`text-label-medium-default text-[var(--content-secondary)]`,children:c(`resizeCard.machineSize`)}),(0,Q.jsx)(p,{options:y,value:D,onChange:E,"aria-label":c(`resizeCard.machineSizeAriaLabel`),"data-testid":`resize-machine-size`})]}),P?(0,Q.jsx)(V,{tone:`info`,children:c(`resizeCard.storageExpandTo`,{to:x})}):(0,Q.jsx)(V,{tone:`neutral`,children:c(`resizeCard.storageUnchanged`)}),j&&(0,Q.jsx)(V,{tone:`error`,children:j})]})}),(0,Q.jsxs)(b.Footer,{className:`items-center justify-between`,children:[(0,Q.jsx)(`span`,{className:`text-label-small-default text-[var(--content-tertiary)]`,children:(0,Q.jsx)(cn,{ns:`settings`,i18nKey:`resizeCard.needMore`,components:{upgradeLink:(0,Q.jsx)(gn,{to:v.plans,className:`text-[var(--content-secondary)] underline decoration-[var(--border-element)] underline-offset-2 transition-colors hover:text-[var(--content-default)]`,onClick:()=>C(!1)})}})}),(0,Q.jsxs)(`div`,{className:`flex gap-2`,children:[(0,Q.jsx)(n,{variant:`ghost`,onClick:()=>{C(!1),E(null),M(null)},children:c(`resizeCard.cancel`)}),(0,Q.jsx)(n,{disabled:ne==null&&!P||F,leftIcon:F?(0,Q.jsx)(Y,{className:`animate-spin`}):void 0,onClick:()=>{M(null);let t={};ne!=null&&(t.machine_size=ne),P&&x!=null&&(t.storage_gib=x),te.mutate({path:{id:e.id},body:t})},children:c(j?`resizeCard.retry`:`resizeCard.apply`)})]})]})]})})]})}function Po({assistantId:e}){let{t}=J(`settings`),r=hn(),i=q(),[a,o]=(0,Z.useState)(!1),[c,l]=(0,Z.useState)(!1);return(0,Q.jsxs)(Q.Fragment,{children:[(0,Q.jsx)(n,{variant:`dangerOutline`,onClick:()=>o(!0),className:`shrink-0`,children:t(`retireAssistant.button`)}),(0,Q.jsx)(ye,{open:a,isPending:c,onConfirm:async()=>{l(!0);let t=await s(i,e);if(t.ok){o(!1),r(t.nextRoute,{replace:!0});return}L.error(t.error),l(!1),o(!1)},onCancel:()=>o(!1)})]})}var Fo=`UTC.Africa/Cairo.Africa/Johannesburg.Africa/Lagos.Africa/Nairobi.America/Anchorage.America/Argentina/Buenos_Aires.America/Bogota.America/Chicago.America/Denver.America/Halifax.America/Lima.America/Los_Angeles.America/Mexico_City.America/New_York.America/Phoenix.America/Santiago.America/Sao_Paulo.America/Toronto.America/Vancouver.Asia/Bangkok.Asia/Dubai.Asia/Hong_Kong.Asia/Jakarta.Asia/Jerusalem.Asia/Karachi.Asia/Kolkata.Asia/Kuala_Lumpur.Asia/Manila.Asia/Seoul.Asia/Shanghai.Asia/Singapore.Asia/Taipei.Asia/Tokyo.Australia/Melbourne.Australia/Perth.Australia/Sydney.Europe/Amsterdam.Europe/Athens.Europe/Berlin.Europe/Brussels.Europe/Dublin.Europe/Istanbul.Europe/Lisbon.Europe/London.Europe/Madrid.Europe/Moscow.Europe/Paris.Europe/Rome.Europe/Stockholm.Europe/Vienna.Europe/Warsaw.Europe/Zurich.Pacific/Auckland.Pacific/Honolulu`.split(`.`);function Io(){let e=Intl;if(typeof e.supportedValuesOf==`function`)try{let t=e.supportedValuesOf(`timeZone`);if(t.length>0)return[...t].sort()}catch{}return[...Fo].sort()}function Lo(e,t,n){let r=parseInt(n??`0`,10);if(r>59)return null;let i=parseInt(t??`0`,10)*60+r;return(e===`-`?-1:1)*i}function Ro(e){let t=e.split(`/`),n=(t[t.length-1]??e).replace(/_/g,` `),r=t.length>1?(t[0]??``).replace(/_/g,` `):``,i=0,a=``;try{let t=new Intl.DateTimeFormat(`en-US`,{timeZone:e,timeZoneName:`shortOffset`}).formatToParts(new Date).find(e=>e.type===`timeZoneName`)?.value??`GMT`;a=t.startsWith(`GMT`)||t.startsWith(`UTC`)?t:`GMT ${t}`;let n=t.match(/([+-])(\d{1,2})(?::(\d{2}))?/);n&&(i=Lo(n[1],n[2],n[3])??0)}catch{return null}return{identifier:e,city:n,region:r,offsetLabel:a,offsetMinutes:i}}function zo(){return Io().map(e=>Ro(e)).filter(e=>e!==null)}function Bo(e){try{return new Intl.DateTimeFormat(`en-US`,{timeZone:e,hour:`numeric`,minute:`2-digit`,hour12:!0}).format(new Date)}catch{return``}}function Vo(e,t){if(!e)return t;try{let t=new Intl.DateTimeFormat(`en-US`,{timeZone:e,timeZoneName:`long`}).formatToParts(new Date).find(e=>e.type===`timeZoneName`)?.value;if(t)return t}catch{}return e.replace(/_/g,` `)}function Ho(e){if(e===`utc`||e===`gmt`)return 0;let t=e.match(/^(?:utc|gmt)?\s*([+-])(\d{1,2})(?::?(\d{2}))?$/);if(!t)return null;let n=Lo(t[1],t[2],t[3]);return n!==null&&Math.abs(n)<=840?n:null}var Uo=200,Wo=[];function Go({value:e,onChange:t}){let{t:n}=J(`settings`),[r,i]=(0,Z.useState)(``),[a,o]=(0,Z.useState)(!1),s=(0,Z.useMemo)(()=>a?zo():Wo,[a]),c=r.trim().toLowerCase(),l=(0,Z.useMemo)(()=>{let e=Ho(c);return(c?s.filter(t=>e===null?t.city.toLowerCase().includes(c)||t.region.toLowerCase().includes(c)||t.offsetLabel.toLowerCase().includes(c)||t.identifier.toLowerCase().includes(c):t.offsetMinutes===e):s).slice(0,Uo)},[s,c]),u=(0,Z.useMemo)(()=>l.map(e=>e.identifier),[l]),d=(0,Z.useMemo)(()=>{if(!e)return``;let t=e.split(`/`);return(t[t.length-1]??e).replace(/_/g,` `)},[e]);return(0,Q.jsxs)(`div`,{className:`space-y-3`,children:[(0,Q.jsxs)(`div`,{className:`flex flex-col gap-1.5 md:flex-row md:items-center md:justify-between md:gap-4`,children:[(0,Q.jsx)(`span`,{className:`text-body-medium-lighter text-[var(--content-tertiary)]`,children:n(`timezonePicker.timezone`)}),(0,Q.jsxs)(Ot.Root,{className:`w-full md:max-w-[280px]`,options:u,value:e,onSelect:t,onOpenChange:e=>{if(e){o(!0);return}i(``)},autoActivateFirst:c.length>0,children:[(0,Q.jsx)(Ot.Input,{type:`text`,"aria-label":n(`timezonePicker.timezone`),value:r,placeholder:d||n(`timezonePicker.searchPlaceholder`),onChange:e=>i(e.target.value),fullWidth:!0}),(0,Q.jsx)(Ot.List,{"aria-label":n(`timezonePicker.timezonesAriaLabel`),className:`absolute left-0 right-0 top-full z-20 mt-1 max-h-[240px] rounded-md border border-[var(--border-base)] bg-[var(--surface-lift)] shadow-lg`,emptyState:(0,Q.jsx)(`p`,{className:`px-3 py-2 text-body-medium-lighter text-[var(--content-tertiary)]`,children:n(`timezonePicker.noMatches`)}),children:l.map(e=>(0,Q.jsxs)(Ot.Option,{value:e.identifier,className:kt(`flex w-full items-center justify-between gap-3 px-3 py-2`,`text-body-medium-lighter text-[var(--content-default)] transition-colors`,`hover:bg-[var(--surface-active)]`,`data-[active]:bg-[var(--surface-active)] aria-selected:bg-[var(--surface-active)]`),children:[(0,Q.jsxs)(`div`,{className:`min-w-0 flex-1`,children:[(0,Q.jsx)(`div`,{className:`truncate text-body-medium-default`,children:e.city}),e.region&&(0,Q.jsx)(`div`,{className:`truncate text-body-small-default text-[var(--content-tertiary)]`,children:e.region})]}),(0,Q.jsxs)(`div`,{className:`flex shrink-0 flex-col items-end gap-0.5 text-body-small-default text-[var(--content-tertiary)]`,children:[(0,Q.jsx)(`span`,{children:Bo(e.identifier)}),(0,Q.jsx)(`span`,{children:e.offsetLabel})]})]},e.identifier))})]})]}),(0,Q.jsx)(er,{}),(0,Q.jsxs)(`div`,{className:`flex items-center justify-between gap-4`,children:[(0,Q.jsx)(`span`,{className:`text-body-medium-lighter text-[var(--content-tertiary)]`,children:n(`timezonePicker.zoneName`)}),(0,Q.jsx)(`span`,{className:`text-body-medium-lighter text-[var(--content-default)]`,children:Vo(e,n(`timezonePicker.notSet`))})]})]})}function Ko(){let{t:e}=J(`settings`),t=Be.use.activeAssistantId(),[n,r]=(0,Z.useState)(()=>c(`timezone`,``)),i=(0,Z.useRef)(t);(0,Z.useEffect)(()=>{i.current=t},[t]);let a=(0,Z.useRef)(!1),o=(0,Z.useRef)(null),s=(0,Z.useRef)(()=>{}),l=e=>{if(a.current){o.current=e;return}let t=i.current;if(!t){o.current=null;return}a.current=!0,o.current=null,U.patch({url:`/v1/assistants/{assistant_id}/config`,path:{assistant_id:t},body:{ui:{userTimezone:e}},throwOnError:!0}).catch(e=>{B(e,{context:`settings-timezone-override`})}).finally(()=>{a.current=!1;let e=o.current;o.current=null,e!==null&&s.current(e)})};return(0,Z.useEffect)(()=>{s.current=l}),(0,Q.jsxs)(`section`,{className:`flex flex-col gap-2`,children:[(0,Q.jsx)(`h3`,{className:`text-title-small text-[var(--content-emphasised)]`,children:e(`timezoneSection.title`)}),(0,Q.jsx)(`p`,{className:`text-body-medium-default text-[var(--content-tertiary)]`,children:e(`timezoneSection.description`)}),(0,Q.jsx)(`div`,{className:`mt-1`,children:(0,Q.jsx)(Go,{value:n,onChange:e=>{r(e),C(`timezone`,e),l(e)}})})]})}var qo=[0,1,2,3,4,5,6];function Jo(e){let[t,n]=e.split(`:`).map(Number),r=new Date,i=new Date(Date.UTC(r.getUTCFullYear(),r.getUTCMonth(),r.getUTCDate(),t,n));return`${i.getHours().toString().padStart(2,`0`)}:${i.getMinutes().toString().padStart(2,`0`)}`}function Yo(e){let[t,n]=e.split(`:`).map(Number),r=new Date,i=new Date(r.getFullYear(),r.getMonth(),r.getDate(),t,n);return`${i.getUTCHours().toString().padStart(2,`0`)}:${i.getUTCMinutes().toString().padStart(2,`0`)}`}function Xo(){return Intl.DateTimeFormat(void 0,{timeZoneName:`short`}).formatToParts(new Date).find(e=>e.type===`timeZoneName`)?.value??``}function Zo(e){let t=e?.schedule?.window.start??`06:00`,n=e?.schedule?.window.end??`08:00`;return{enabled:e?.enabled??!0,timezone:`UTC`,frequency:e?.schedule?.frequency??`weekly`,daysOfWeek:e?.schedule?.days_of_week??[0],daysOfMonth:e?.schedule?.days_of_month??[],windowStart:Jo(t),windowEnd:Jo(n)}}function Qo({assistantId:e}){let{t}=J(`settings`),r=q(),i=[t(`updateWindowPolicy.dayMon`),t(`updateWindowPolicy.dayTue`),t(`updateWindowPolicy.dayWed`),t(`updateWindowPolicy.dayThu`),t(`updateWindowPolicy.dayFri`),t(`updateWindowPolicy.daySat`),t(`updateWindowPolicy.daySun`)],{data:a,isLoading:o,isError:s}=K(en({path:{id:e}})),c=(0,Z.useMemo)(()=>Zo(a),[a]),[l,u]=(0,Z.useState)(null),f=l??c,p=l!==null,m=(0,Z.useMemo)(()=>Xo(),[]),[h,g]=(0,Z.useState)(null),_=h??f.daysOfMonth.join(`, `),v=sn({mutationFn:async t=>{let{data:n}=await d({path:{id:e},body:t,throwOnError:!0});return n}}),y=e=>{u(t=>({...t??c,...e}))},b=e=>{y({daysOfWeek:f.daysOfWeek.includes(e)?f.daysOfWeek.filter(t=>t!==e):[...f.daysOfWeek,e].sort((e,t)=>e-t)})},x=e=>e.split(`,`).map(e=>parseInt(e.trim(),10)).filter(e=>!isNaN(e)&&e>=1&&e<=31);return o?(0,Q.jsxs)(`div`,{className:`flex items-center gap-2 text-body-medium-lighter text-[var(--content-tertiary)]`,children:[(0,Q.jsx)(Y,{className:`h-4 w-4 animate-spin`}),t(`updateWindowPolicy.loading`)]}):s?(0,Q.jsx)(`p`,{className:`text-body-medium-lighter text-[var(--system-negative-strong)]`,children:t(`updateWindowPolicy.loadError`)}):(0,Q.jsxs)(`div`,{className:`space-y-6`,children:[(0,Q.jsx)(T,{checked:f.enabled,onChange:e=>y({enabled:e}),label:t(`updateWindowPolicy.automaticUpdates`),helperText:t(`updateWindowPolicy.automaticUpdatesHelper`)}),f.enabled&&(0,Q.jsxs)(`div`,{className:`space-y-5`,children:[(0,Q.jsxs)(`div`,{className:`space-y-2`,children:[(0,Q.jsx)(`label`,{className:`block text-body-small-default text-[var(--content-secondary)]`,children:t(`updateWindowPolicy.frequency`)}),(0,Q.jsx)(`div`,{className:`max-w-[400px]`,children:(0,Q.jsx)(re,{ariaLabel:t(`updateWindowPolicy.frequency`),value:f.frequency,onChange:e=>{e!==`monthly`&&g(null),y({frequency:e})},items:[{value:`daily`,label:t(`updateWindowPolicy.daily`)},{value:`weekly`,label:t(`updateWindowPolicy.weekly`)},{value:`monthly`,label:t(`updateWindowPolicy.monthly`)}]})})]}),f.frequency===`weekly`&&(0,Q.jsxs)(`div`,{className:`space-y-2`,children:[(0,Q.jsx)(`label`,{className:`block text-body-small-default text-[var(--content-secondary)]`,children:t(`updateWindowPolicy.daysOfWeek`)}),(0,Q.jsx)(`div`,{className:`flex flex-wrap gap-1.5`,children:qo.map(e=>(0,Q.jsx)(n,{variant:`outlined`,size:`compact`,active:f.daysOfWeek.includes(e),onClick:()=>b(e),children:i[e]},e))})]}),f.frequency===`monthly`&&(0,Q.jsx)(z,{label:t(`updateWindowPolicy.daysOfMonth`),type:`text`,value:_,onChange:e=>g(e.target.value),onBlur:e=>{let t=x(e.target.value);y({daysOfMonth:t}),g(t.join(`, `))},placeholder:t(`updateWindowPolicy.daysOfMonthPlaceholder`),helperText:t(`updateWindowPolicy.daysOfMonthHelper`),className:`w-48`}),(0,Q.jsxs)(`div`,{className:`space-y-2`,children:[(0,Q.jsx)(`label`,{className:`block text-body-small-default text-[var(--content-secondary)]`,children:m?t(`updateWindowPolicy.updateWindowWithTz`,{tz:m}):t(`updateWindowPolicy.updateWindow`)}),(0,Q.jsxs)(`div`,{className:`flex items-center gap-3`,children:[(0,Q.jsx)(z,{type:`time`,value:f.windowStart,onChange:e=>y({windowStart:e.target.value})}),(0,Q.jsx)(`span`,{className:`text-body-medium-lighter text-[var(--content-tertiary)]`,children:t(`updateWindowPolicy.to`)}),(0,Q.jsx)(z,{type:`time`,value:f.windowEnd,onChange:e=>y({windowEnd:e.target.value})})]})]})]}),(0,Q.jsx)(n,{variant:`primary`,leftIcon:v.isPending?(0,Q.jsx)(Y,{className:`animate-spin`}):void 0,onClick:async()=>{let n=f.frequency===`monthly`&&h!==null?x(h):f.daysOfMonth;try{await v.mutateAsync({enabled:f.enabled,timezone:`UTC`,schedule:{frequency:f.frequency,days_of_week:f.frequency===`weekly`?f.daysOfWeek:[],days_of_month:f.frequency===`monthly`?n:[],window:{start:Yo(f.windowStart),end:Yo(f.windowEnd)}}}),L.success(t(`updateWindowPolicy.toastSaved`)),u(null),g(null),r.invalidateQueries({queryKey:Se({path:{id:e}})})}catch{L.error(t(`updateWindowPolicy.toastSaveFailed`))}},disabled:v.isPending||!p,children:t(`updateWindowPolicy.savePolicy`)})]})}function $o({assistantId:e,open:t,onClose:n}){let{t:r}=J(`settings`);return(0,Q.jsx)(b.Root,{open:t,onOpenChange:e=>{e||n()},children:(0,Q.jsxs)(b.Content,{size:`md`,children:[(0,Q.jsxs)(b.Header,{children:[(0,Q.jsx)(b.Title,{children:r(`updateWindowModal.title`)}),(0,Q.jsx)(b.Description,{children:r(`updateWindowModal.description`)})]}),(0,Q.jsx)(b.Body,{children:(0,Q.jsx)(Qo,{assistantId:e})})]})})}function es(e){if(typeof e==`object`&&e&&`code`in e){let t=e.code;if(typeof t==`string`)return t}}function ts({open:e,onOpenChange:r}){let{t:a}=J(`settings`),o=q(),[s,c]=(0,Z.useState)(null),[l,u]=(0,Z.useState)(``),[d,f]=(0,Z.useState)(null),p=(0,Z.useRef)(!1),m=(0,Z.useRef)(e),h=()=>o.invalidateQueries({queryKey:Xt()}),g=e=>{i({path:{id:e}}).catch(()=>void 0).finally(()=>void h())},_=Dt({onSuccess:e=>{if(!m.current){g(e.factor_id);return}c(e)},onError:e=>{let t=es(e);t===`no_workos_account`?L.error(a(`enrollTotpModal.toastNoWorkosAccount`)):t===`throttled`||t===`workos_rate_limited`?L.error(a(`enrollTotpModal.toastThrottled`)):t===`factor_limit_reached`?L.error(a(`enrollTotpModal.toastFactorLimitReached`)):L.error(a(`enrollTotpModal.toastStartFailed`)),r(!1)}}),v=ut({onSuccess:e=>{e.valid?(p.current=!0,L.success(a(`enrollTotpModal.toastEnabled`)),h(),r(!1)):f(a(`enrollTotpModal.errorCodeMismatch`))},onError:e=>{let t=es(e);if(t===`challenge_already_verified`){p.current=!0,L.success(a(`enrollTotpModal.toastEnabled`)),h(),r(!1);return}if(t===`challenge_expired`||t===`challenge_not_found`){s&&g(s.factor_id),c(null),u(``),f(a(`enrollTotpModal.errorSessionExpired`)),_.mutate({});return}if(t===`throttled`||t===`workos_rate_limited`){f(a(`enrollTotpModal.errorThrottledInline`));return}f(a(`enrollTotpModal.errorVerifyFailed`))}});(0,Z.useEffect)(()=>{m.current=e,e&&(p.current=!1,c(null),u(``),f(null),_.mutate({}))},[e]);let y=e=>{!e&&v.isPending||(!e&&s&&!p.current&&g(s.factor_id),r(e))},x=()=>{s&&t(s.secret,{successMessage:a(`enrollTotpModal.copySuccess`),errorMessage:a(`enrollTotpModal.copyError`)})},S=()=>{!s||l.length!==6||v.isPending||(f(null),v.mutate({body:{challenge_id:s.challenge_id,code:l}}))};return(0,Q.jsx)(b.Root,{open:e,onOpenChange:y,children:(0,Q.jsxs)(b.Content,{size:`sm`,children:[(0,Q.jsxs)(b.Header,{children:[(0,Q.jsx)(b.Title,{children:a(`enrollTotpModal.title`)}),(0,Q.jsx)(b.Description,{children:a(`enrollTotpModal.description`)})]}),(0,Q.jsx)(b.Body,{children:s===null?(0,Q.jsx)(`div`,{className:`flex items-center justify-center py-10`,children:(0,Q.jsx)(Y,{className:`h-5 w-5 animate-spin text-[var(--content-tertiary)]`})}):(0,Q.jsxs)(`form`,{className:`flex flex-col items-center gap-4`,onSubmit:e=>{e.preventDefault(),S()},children:[(0,Q.jsx)(`img`,{src:s.qr_code,alt:a(`enrollTotpModal.qrCodeAlt`),className:`h-44 w-44 rounded-lg bg-white p-2`}),(0,Q.jsxs)(`div`,{className:`flex w-full flex-col gap-1`,children:[(0,Q.jsx)(`span`,{className:`text-body-small-default text-[var(--content-tertiary)]`,children:a(`enrollTotpModal.manualKeyHint`)}),(0,Q.jsxs)(`button`,{type:`button`,onClick:x,className:`flex cursor-pointer items-center gap-2 self-start font-mono text-body-small-default text-[var(--content-default)] hover:text-[var(--content-emphasised)]`,children:[(0,Q.jsx)(`span`,{className:`break-all text-left`,children:s.secret}),(0,Q.jsx)(Mn,{className:`h-3.5 w-3.5 shrink-0`})]})]}),(0,Q.jsxs)(`div`,{className:`flex w-full flex-col gap-1`,children:[(0,Q.jsx)(`label`,{htmlFor:`totp-code`,className:`text-body-small-default text-[var(--content-tertiary)]`,children:a(`enrollTotpModal.codeLabel`)}),(0,Q.jsx)(z,{id:`totp-code`,inputMode:`numeric`,autoComplete:`one-time-code`,maxLength:6,placeholder:a(`enrollTotpModal.codePlaceholder`),value:l,onChange:e=>u(e.target.value.replace(/\D/g,``).slice(0,6))}),d&&(0,Q.jsx)(`p`,{role:`alert`,className:`text-body-small-default text-[var(--system-negative-strong)]`,children:d})]})]})}),(0,Q.jsxs)(b.Footer,{children:[(0,Q.jsx)(n,{variant:`outlined`,onClick:()=>y(!1),disabled:v.isPending,children:a(`enrollTotpModal.cancel`)}),(0,Q.jsx)(n,{onClick:S,disabled:s===null||l.length!==6||v.isPending,children:v.isPending?a(`enrollTotpModal.verifying`):a(`enrollTotpModal.verify`)})]})]})})}function ns(e){let t=new Date(e);return Number.isNaN(t.getTime())?``:t.toLocaleDateString(void 0,{month:`short`,day:`numeric`,year:`numeric`})}function rs(){let{t:e}=J(`settings`),t=q(),[r,i]=(0,Z.useState)(!1),[a,o]=(0,Z.useState)(null),s=K({...ze()}),c=s.data??[],l=()=>t.invalidateQueries({queryKey:Xt()}),u=mt({onSuccess:()=>{L.success(e(`twoFactorSection.toastRemoved`)),l()},onError:t=>{if(es(t)===`factor_not_found`){l();return}L.error(e(`twoFactorSection.toastRemoveFailed`))}});return(0,Q.jsxs)(`div`,{className:`flex flex-col gap-4`,children:[s.isPending?(0,Q.jsxs)(`div`,{className:`flex items-center gap-2 text-[var(--content-tertiary)]`,children:[(0,Q.jsx)(Y,{className:`h-4 w-4 animate-spin`}),(0,Q.jsx)(`span`,{className:`text-body-medium-default`,children:e(`twoFactorSection.loading`)})]}):s.isError?(0,Q.jsx)(V,{tone:`error`,children:(0,Q.jsx)(cn,{ns:`settings`,i18nKey:`twoFactorSection.loadError`,components:{retryButton:(0,Q.jsx)(`button`,{type:`button`,className:`cursor-pointer underline`,onClick:()=>void s.refetch()})}})}):c.length===0?(0,Q.jsx)(`p`,{className:`text-body-medium-default text-[var(--content-tertiary)]`,children:e(`twoFactorSection.emptyDescription`)}):(0,Q.jsx)(`ul`,{className:`flex flex-col divide-y divide-[var(--border-base)]`,children:c.map(t=>(0,Q.jsxs)(`li`,{className:`flex items-center justify-between gap-3 py-3`,children:[(0,Q.jsxs)(`div`,{className:`flex min-w-0 items-center gap-3`,children:[(0,Q.jsx)(In,{className:`h-5 w-5 shrink-0 text-[var(--content-tertiary)]`}),(0,Q.jsxs)(`div`,{className:`min-w-0`,children:[(0,Q.jsx)(`div`,{className:`text-body-medium-default text-[var(--content-default)]`,children:e(`twoFactorSection.authenticatorApp`)}),(0,Q.jsxs)(`div`,{className:`truncate text-body-small-default text-[var(--content-tertiary)]`,children:[t.user,t.created_at?e(`twoFactorSection.addedOn`,{date:ns(t.created_at)}):``]})]})]}),(0,Q.jsx)(n,{variant:`dangerOutline`,onClick:()=>o(t),disabled:u.isPending,children:e(`twoFactorSection.remove`)})]},t.id))}),!s.isPending&&!s.isError&&c.length===0&&(0,Q.jsx)(n,{onClick:()=>i(!0),className:`self-start`,children:e(`twoFactorSection.addAuthenticatorApp`)}),(0,Q.jsx)(ts,{open:r,onOpenChange:i}),(0,Q.jsx)(I,{open:a!==null,title:e(`twoFactorSection.removeDialogTitle`),message:e(`twoFactorSection.removeDialogMessage`),confirmLabel:e(`twoFactorSection.removeDialogConfirm`),destructive:!0,onConfirm:()=>{a&&u.mutate({path:{id:a.id}}),o(null)},onCancel:()=>o(null)})]})}var $=class extends Error{code;constructor(e,t){super(t),this.name=`TeleportError`,this.code=e}},is=`local`,as=`docker`,os=`vellum`;function ss(e){switch((e??``).toLowerCase()){case is:return`local`;case as:return`docker`;case os:return`managed`;default:return`other`}}function cs(e){let t=ss(e);return t===`managed`?`local`:t===`local`?`platform`:null}function ls(e){switch(e){case`docker`:return`teleportCard.moveToDocker`;case`platform`:return`teleportCard.moveToPlatform`;case`local`:return`teleportCard.moveToLocal`}}var us={macos:`Macos`,windows:`Windows`,linux:`Linux`};function ds(e,t=`macos`){switch(e){case`docker`:return`teleportCard.dockerDescription${us[t]}`;case`platform`:return`teleportCard.platformDescription`;case`local`:return`teleportCard.localDescription${us[t]}`}}function fs(e){if(!e||typeof e!=`object`)return null;let t=e;if(t.reason!==`version_mismatch`)return null;let n=t.bundle_compat,r=t.target_runtime_version;if(!n||typeof n!=`object`||typeof r!=`string`)return null;let i=n,a=i.min_runtime_version;if(typeof a!=`string`)return null;let o=typeof i.max_runtime_version==`string`?i.max_runtime_version:null;return`Cannot import: bundle requires runtime ${o?`${a}–${o}`:`${a}+`}, but this local runtime is ${r}. Update your local runtime before importing.`}var ps=3600*1e3;function ms(e,t=Date.now(),n=ps){for(let r of e){if(!r)continue;let e=Date.parse(r);if(Number.isNaN(e))continue;let i=t-e;if(i>=0&&i<=n)return!0}return!1}function hs(e){return e.filter(e=>e.ready_to_use!==!1).map(e=>e.created_at)}function gs(e,t){return e.some(e=>e.snapshot_name===t&&e.ready_to_use===!0)}async function _s(e,t){let n=Number(e.headers.get(`Content-Length`)??0);if(!e.body||!t||n<=0){let n=await e.arrayBuffer();return t?.(1),n}let r=e.body.getReader(),i=[],a=0;for(;;){let{done:e,value:o}=await r.read();if(e)break;i.push(o),a+=o.length,t(a/n)}let o=new Uint8Array(a),s=0;for(let e of i)o.set(e,s),s+=e.length;return t(1),o.buffer}function vs(e){let t=_(e);if(!t)throw new $(`local_assistant_not_found`,`Assistant ${e.assistantId} has no resolved local gateway.`);return`${window.location.origin}${t}`}async function ys(e,t){let n=await qt(e.assistantId),r=await fetch(`${t}/auth/token`,{method:`POST`,headers:{Authorization:`Bearer ${n}`}});if(!r.ok)throw new $(`not_signed_in`,`Gateway token request failed (HTTP ${r.status}).`);let{token:i}=await r.json();return i}async function bs(e,t){let n=vs(e),r=await ys(e,n),i=await fetch(`${n}/v1/migrations/export`,{method:`POST`,headers:{Authorization:`Bearer ${r}`}});if(!i.ok)throw new $(`export_failed`,`Export failed (HTTP ${i.status}).`);return _s(i,t)}async function xs(e,t){let n=vs(e),r=await ys(e,n),i=await fetch(`${n}/v1/migrations/import`,{method:`POST`,headers:{Authorization:`Bearer ${r}`},body:new Blob([t],{type:`application/octet-stream`})});if(!i.ok)throw new $(`import_failed`,`Import failed (HTTP ${i.status}).`);let a=await Ts(i);if(a&&a.success===!1)throw new $(`import_failed`,a.error??`Import reported failure`)}async function Ss(e){let t=vs(e),n=await ys(e,t),r=await fetch(`${t}/v1/backups/create`,{method:`POST`,headers:{Authorization:`Bearer ${n}`}});if(!r.ok)throw new $(`backup_failed`,G(`settings:teleportCard.backupLocalFailed`,{status:r.status}));let i=await Ts(r);if(i&&i.success===!1)throw new $(`backup_failed`,G(`settings:teleportCard.backupLocalReportedFailure`))}async function Cs(e,t){let{data:n,response:r}=await U.post({url:`/v1/assistants/{assistant_id}/migrations/export-to-gcs/`,path:{assistant_id:e},body:{upload_url:t},throwOnError:!1}),i=r?.status??0;if(!(r?.ok??!1)&&i!==202)throw new $(`export_failed`,`Export failed (HTTP ${i}).`);let a=n?.job_id;if(!a)throw new $(`export_failed`,`Export accepted but no job ID was returned.`);return a}async function ws(e,t){let{data:n,response:r}=await U.get({url:`/v1/assistants/{assistant_id}/migrations/jobs/{job_id}`,path:{assistant_id:e,job_id:t},throwOnError:!1}),i=r?.status??0;if(i>=500)return`processing`;if(!(r?.ok??!1))throw new $(`export_job_failed`,`Job status check failed (HTTP ${i})`);let a=n;if(a?.status===`failed`)throw new $(`export_job_failed`,a.error??`Export job failed`);return a?.status??`processing`}async function Ts(e){try{return await e.json()}catch{return null}}async function Es(e,t={}){let n=ss(e.cloud);if(n===`managed`)return ks(e.assistantId,t);if(n===`local`)return Ss(e);throw new $(`backup_failed`,G(`settings:teleportCard.backupUnsupported`))}async function Ds(e){let t=await He({path:{assistant_id:e},throwOnError:!1});if(!(t.response?.ok??!1))throw new $(`backup_failed`,G(`settings:teleportCard.backupListFailed`,{status:t.response?.status??0}));let n=t.data?.backups;return Array.isArray(n)?n:[]}var Os=e=>new Promise(t=>setTimeout(t,e));async function ks(e,t){if(ms(hs(await Ds(e))))return;let n=await ht({path:{assistant_id:e},throwOnError:!1});if(!(n.response?.ok??!1))throw new $(`backup_failed`,G(`settings:teleportCard.backupCreateFailed`,{status:n.response?.status??0}));let r=n.data,i=r?.snapshot_name;if(!i)throw new $(`backup_failed`,G(`settings:teleportCard.backupNoSnapshotName`));if(r?.ready_to_use===!0)return;let a=t.readyTimeoutMs??6e5,o=t.readyPollIntervalMs??5e3,s=Date.now()+a;for(;Date.now()<s;)if(await Os(o),gs(await Ds(e),i))return;throw new $(`backup_failed`,G(`settings:teleportCard.backupNotReady`,{snapshot:i,seconds:Math.round(a/1e3)}))}var As=new Set([500,502,503,504]),js=3,Ms=e=>new Promise(t=>setTimeout(t,e));async function Ns(e,t=new Set){for(let n=0;n<=js;n++){let{response:r,data:i,error:a}=await e(),o=r?.status??0;if(n<js&&As.has(o)&&!t.has(o)){await Ms(2**n*1e3);continue}return{status:o,data:i,error:a}}throw new $(`unknown`,`Unexpected retry loop exit`)}async function Ps(e,t){let n={operation:`upload`};e&&(n.min_runtime_version=e,n.max_runtime_version=null),t&&(n.consumer=t);let{status:r,data:i}=await Ns(()=>U.post({url:`/v1/migrations/signed-url/`,body:n,throwOnError:!1}),new Set([404,503]));if(r===503||r===404)throw new $(`export_failed`,`Signed URL uploads are not available — the platform may not support this feature yet.`);if(r!==201)throw new $(`export_failed`,`Migration request failed (HTTP ${r}).`);let a=i;return{url:a.url,bundleKey:a.bundle_key,expiresAt:a.expires_at}}async function Fs(e,t){let{status:n,data:r,error:i}=await Ns(()=>U.post({url:`/v1/migrations/signed-url/`,body:{operation:`download`,bundle_key:e,target_runtime_version:t},throwOnError:!1}),new Set([422]));if(n===422){let e=fs(i);if(e)throw new $(`version_mismatch`,e)}if(n!==200&&n!==201)throw new $(`import_failed`,`Migration request failed (HTTP ${n}).`);return r.url}async function Is(e,t,n){for(let r=0;r<=js;r++){let i=await Ls(e,t,n);if(r<js&&As.has(i)){await Ms(2**r*1e3),n?.(0);continue}if(i<200||i>=300)throw new $(`export_failed`,`Bundle upload failed (HTTP ${i}).`);return}}function Ls(e,t,n){return new Promise((r,i)=>{let a=new XMLHttpRequest;a.open(`PUT`,e),a.setRequestHeader(`Content-Type`,`application/octet-stream`),a.timeout=36e5,n&&(a.upload.onprogress=e=>{e.lengthComputable&&n(e.loaded/e.total)}),a.onload=()=>{n?.(1),r(a.status)},a.onerror=()=>i(new $(`export_failed`,`Bundle upload failed.`)),a.ontimeout=()=>i(new $(`export_timed_out`,`Bundle upload timed out.`)),a.send(t)})}async function Rs(e,t){for(let n=0;n<=js;n++){let r=await fetch(e,{method:`GET`});if(n<js&&As.has(r.status)){await Ms(2**n*1e3),t?.(0);continue}if(!r.ok)throw new $(`import_failed`,`Bundle download failed (HTTP ${r.status}).`);return _s(r,t)}throw new $(`import_failed`,`Unexpected retry loop exit`)}async function zs(e){let{status:t,data:n,error:r}=await Ns(()=>U.post({url:`/v1/migrations/import-from-gcs/`,body:{bundle_key:e},throwOnError:!1}));return{status:t,body:n??r??null}}async function Bs(e){let{status:t,data:n}=await Ns(()=>U.get({url:`/v1/migrations/jobs/{job_id}/`,path:{job_id:e},throwOnError:!1}));if(t!==200)throw new $(`import_failed`,`Job status check failed (HTTP ${t})`);let r=n??{};return{status:typeof r.status==`string`?r.status:`unknown`,jobId:typeof r.job_id==`string`?r.job_id:null,error:typeof r.error==`string`?r.error:null}}var Vs=5e3,Hs=36e5,Us=5*6e4,Ws=30,Gs=e=>new Promise(t=>setTimeout(t,e));function Ks(){let e=hn(),t=q(),n=me(),r=cs(n?.cloud),[i,a]=(0,Z.useState)({kind:`idle`}),[o,c]=(0,Z.useState)(!1),l=(0,Z.useRef)(null),u=(0,Z.useRef)(null),d=(0,Z.useCallback)(e=>{a({kind:`transferring`,step:e,progress:null})},[]),f=(0,Z.useCallback)(e=>{a(t=>t.kind===`transferring`?{...t,progress:e}:t)},[]),p=(0,Z.useCallback)(async()=>{if(!(!n||!r)){u.current={id:n.assistantId,kind:ss(n.cloud)===`managed`?`managed`:`local`,createdFresh:!1};try{if(d(G(`settings:teleportCard.backupStep`)),await Es(n),r===`platform`)await qs(n,d,f,l);else if(r===`local`)await Js(n,d,f,l);else throw new $(`unknown`,G(`settings:teleportCard.unsupportedDestination`));a({kind:`verifying`})}catch(e){a({kind:`failed`,error:G(`settings:teleportCard.teleportFailed`,{message:e instanceof $||e instanceof Error?e.message:G(`settings:teleportCard.teleportFailedUnknown`)})}),B(e,{context:`teleport-execute`}),await Xs(t,l.current,u.current,`teleport-execute-cleanup`),l.current=null}}},[n,r,d,f,t]),m=(0,Z.useCallback)(()=>c(!0),[]),g=(0,Z.useCallback)(()=>c(!1),[]),_=(0,Z.useCallback)(()=>{c(!1),p()},[p]),y=(0,Z.useCallback)(()=>{l.current=null,u.current=null,a({kind:`idle`})},[]);return{destination:r,phase:i,confirmOpen:o,requestTeleport:m,cancelConfirm:g,confirm:_,confirmAndSwitch:(0,Z.useCallback)(()=>{let n=l.current,r=u.current;n&&(async()=>{try{let e=h.getState();n.kind===`managed`?await e.connectPlatformAssistant(n.id):(await e.connectLocalAssistant(n.id),M(n.id,{onError:e=>B(e,{context:`teleport-inject-platform-identity`})}))}catch(e){a({kind:`failed`,error:G(`settings:teleportCard.switchFailed`,{message:e instanceof Error?e.message:G(`settings:teleportCard.switchFailedUnknown`)})}),B(e,{context:`teleport-confirm-switch`});return}r&&s(t,r.id).then(e=>{e.ok||B(Error(e.error),{context:`teleport-retire-source`})}),y(),e(v.assistant,{replace:!0})})()},[e,y,t]),cancelTeleport:(0,Z.useCallback)(()=>{let e=l.current,n=u.current;l.current=null,u.current=null,a({kind:`idle`}),Xs(t,e,n,`teleport-cancel-retire-target`)},[t]),reset:y}}async function qs(e,t,n,r){t(G(`settings:teleportCard.stepExportingLocal`));let i=await bs(e,n);t(G(`settings:teleportCard.stepResolvingOrganization`));let a=await Qs();t(G(`settings:teleportCard.stepCheckingExisting`));let o=(await rt({query:{hosting:`platform`},throwOnError:!1})).data?.results?.[0];if(o)throw new $(`existing_platform_assistant`,G(`settings:teleportCard.existingPlatformAssistant`,{id:o.id}));t(G(`settings:teleportCard.stepUploading`));let s=await Ps(e.resources?.runtimeVersion);await Is(s.url,i,n),t(G(`settings:teleportCard.stepSettingUpCloud`));let c=await ge(void 0,`create`);if(!c.ok)throw new $(`import_failed`,G(`settings:teleportCard.cloudSetupFailed`));if(c.status===200)throw new $(`existing_platform_assistant`,G(`settings:teleportCard.existingPlatformAssistant`,{id:c.data.id}));let l=c.data.id;await Rt({assistantId:l,name:c.data.name,cloud:`vellum`,runtimeUrl:$t(),hatchedAt:c.data.created??new Date().toISOString(),organizationId:a}),await Ve(e.assistantId),r.current={id:l,kind:`managed`,createdFresh:!0},t(G(`settings:teleportCard.stepFinalizingCloud`)),await $s(l),t(G(`settings:teleportCard.stepImportingToCloud`));let u=await zs(s.bundleKey);if(u.status<200||u.status>=300){let e=u.body;throw new $(`import_failed`,e?.error??G(`settings:teleportCard.importFailedHttp`,{status:u.status}))}if(u.status===202){let e=u.body?.job_id;if(!e)throw new $(`import_failed`,G(`settings:teleportCard.importNoJobId`));await ec(e)}else{let e=u.body;if(e&&e.success===!1)throw new $(`import_failed`,e.error??G(`settings:teleportCard.importReportedFailure`))}}async function Js(e,t,n,r){t(G(`settings:teleportCard.stepPreparingExport`));let i=await Ps(await Zs(e.assistantId),`runtime`);t(G(`settings:teleportCard.stepExportingCloud`));let a=await Cs(e.assistantId,i.url);await tc(e.assistantId,a),t(G(`settings:teleportCard.stepPreparingLocal`));let{assistant:o,createdFresh:s}=await nc();r.current={id:o.assistantId,kind:`local`,createdFresh:s};let c=await Ys(o,s);if(!c)throw new $(`local_assistant_not_found`,G(`settings:teleportCard.localRuntimeVersionUnknown`));t(G(`settings:teleportCard.stepPreparingImport`));let l=await Fs(i.bundleKey,c);t(G(`settings:teleportCard.stepDownloading`));let u=await Rs(l,n);t(G(`settings:teleportCard.stepImporting`)),await ic(o,u),await Ve(e.assistantId)}async function Ys(e,t){if(e.resources?.runtimeVersion)return e.resources.runtimeVersion;if(t)return(await Bn())?.version??void 0}async function Xs(e,t,n,r){if(t?.createdFresh){let n=await s(e,t.id);n.ok||B(Error(n.error),{context:r})}n&&await Ve(n.id)}async function Zs(e){let t=await Fe(e);return t.ok?t.data.version??void 0:void 0}async function Qs(){let e=ue.getState();e.organizations.length===0&&await e.fetchOrganizations();let t=ue.getState().organizations,n=oe();if(n&&t.some(e=>e.id===n))return n;if(t.length===0)throw new $(`no_organizations`,G(`settings:teleportCard.noOrganizations`));if(t.length>1)throw new $(`multiple_organizations`,G(`settings:teleportCard.multipleOrganizations`));let r=t[0].id;return ue.getState().setCurrentOrganizationId(r),r}async function $s(e){let t=Date.now();for(;Date.now()-t<Us;){let{data:t,response:n}=await dt({path:{id:e},throwOnError:!1});if(n?.ok&&t?.state===`active`)return;await Gs(Vs)}}async function ec(e){let t=Date.now();for(;Date.now()-t<Hs;){await Gs(Vs);let t=await Bs(e);if(t.status===`complete`)return;if(t.status===`failed`)throw new $(`import_failed`,t.error??G(`settings:teleportCard.importJobFailed`))}throw new $(`import_failed`,G(`settings:teleportCard.importTimedOut`))}async function tc(e,t){let n=Date.now();for(;Date.now()-n<Hs;)if(await Gs(Vs),await ws(e,t)===`complete`)return;throw new $(`export_timed_out`,G(`settings:teleportCard.exportTimedOut`))}async function nc(){let e=await Ye(void 0,void 0);if(!e.ok)throw new $(`local_assistant_not_found`,e.error??G(`settings:teleportCard.localCreateFailed`));await S();let t=e.assistantId?we().find(t=>t.assistantId===e.assistantId):rc();if(!t)throw new $(`local_assistant_not_found`,G(`settings:teleportCard.localNotFound`));return{assistant:t,createdFresh:!0}}function rc(){return we().slice().sort((e,t)=>(t.hatchedAt??``).localeCompare(e.hatchedAt??``))[0]}async function ic(e,t){let n;for(let r=0;r<Ws;r++)try{await xs(e,t);return}catch(e){n=e,await Gs(1e3)}throw n instanceof Error?n:new $(`import_failed`,G(`settings:teleportCard.importFailed`))}function ac(){let{t:e}=J(`settings`),t=Ks(),{destination:r,phase:i}=t,a=R.use.teleport(),o=Qt();return!r||o===`gated`||i.kind===`idle`&&r===`platform`&&!a?null:(0,Q.jsxs)(X,{title:e(`teleportCard.title`),subtitle:e(`teleportCard.subtitle`),children:[i.kind===`idle`&&o===`disabled`&&(0,Q.jsx)(W,{children:e(`teleportCard.loginNotice`)}),i.kind===`idle`&&o===`full`&&(0,Q.jsxs)(`div`,{className:`flex flex-col gap-2`,children:[(0,Q.jsx)(`p`,{className:`text-body-medium-default text-[var(--content-tertiary)]`,children:e(ds(r,Gt()))}),(0,Q.jsx)(n,{variant:`outlined`,className:`self-start`,onClick:t.requestTeleport,children:e(ls(r))})]}),i.kind===`transferring`&&(0,Q.jsxs)(`div`,{className:`flex flex-col gap-2`,children:[(0,Q.jsxs)(`div`,{className:`flex items-center gap-2`,children:[i.progress==null&&(0,Q.jsx)(Y,{className:`h-4 w-4 animate-spin text-[var(--content-tertiary)]`}),(0,Q.jsx)(`span`,{className:`text-body-medium-default text-[var(--content-tertiary)]`,children:i.step})]}),i.progress!=null&&(0,Q.jsx)(Ne,{value:i.progress,"aria-label":e(`teleportCard.progressAriaLabel`),className:`max-w-[240px]`})]}),i.kind===`verifying`&&(0,Q.jsx)(V,{tone:`success`,icon:(0,Q.jsx)(On,{className:`h-4 w-4`}),title:e(`teleportCard.verifyTitle`),actions:(0,Q.jsxs)(`div`,{className:`flex gap-2`,children:[(0,Q.jsx)(n,{variant:`primary`,onClick:t.confirmAndSwitch,children:e(`teleportCard.confirmAndSwitch`)}),(0,Q.jsx)(n,{variant:`outlined`,onClick:t.cancelTeleport,children:e(`teleportCard.cancel`)})]})}),i.kind===`failed`&&(0,Q.jsx)(V,{tone:`error`,title:i.error,actions:(0,Q.jsx)(n,{variant:`outlined`,onClick:t.reset,children:e(`teleportCard.tryAgain`)})}),(0,Q.jsx)(I,{open:t.confirmOpen,title:e(ls(r)),message:e(`teleportCard.confirmMessage`),confirmLabel:e(`teleportCard.confirmLabel`),onConfirm:t.confirm,onCancel:t.cancelConfirm})]})}function oc(){let{t:e}=J(`settings`),{assistant:t,healthz:r,healthzLoading:i,healthzFetching:o,healthzPolling:s,refetch:c,refetchUntilResized:l}=Jn(),u=R.use.multiPlatformAssistant(),d=R.use.accountMfa(),f=Ge.use.settingsSleepPolicy(),p=a(),m=Ke(),h=be()||p||Ee()||m,g=hn(),_=Qt(),y=Qt({platformHostedOnly:!0}),b=Ce(),x=St({assistantId:t?.id??null,enabled:y===`full`&&b}),[S,C]=(0,Z.useState)(!1),[w,T]=(0,Z.useState)(!1),[D,O]=mn();(0,Z.useEffect)(()=>{if(D.get(`preferences`)!==`open`)return;let e=new URLSearchParams(D);e.delete(`preferences`),O(e,{replace:!0}),T(!0)},[D,O]);let k=t?.is_local&&!be()?null:t,A=me(),j=be()&&!!t&&!!A&&F(A),ee=j,M=j&&!Ee(),te=y===`full`&&!!k||M&&!!t;(0,Z.useEffect)(()=>{!t||window.location.hash!==`#storage-resources`||requestAnimationFrame(()=>{document.getElementById(`storage-resources`)?.scrollIntoView({block:`start`})})},[t]);let N=r?.version??t?.current_release_version??null,ne=()=>{let e=ce();if(Ee()&&!m&&e){let t=new URLSearchParams({register:Oe()}),n=yt();n&&t.set(`name`,n);let r=new URL(e).origin;window.location.assign(`${r}${v.selectAssistant}?${t.toString()}`);return}g(`${v.selectAssistant}?noAutoSkip=1`)},P=(_===`full`||ee)&&!!k||_===`disabled`&&!ee,re=y!==`gated`;return(0,Q.jsxs)(`div`,{className:`space-y-4`,children:[x.status&&x.mode!==`inactive`&&(0,Q.jsx)(Qe,{status:x.status,mode:x.mode,isAcknowledging:x.isAcknowledging,acknowledgeError:x.acknowledgeError?.message??null,onAcknowledge:()=>void x.acknowledge(),onReviewWorkspaceData:()=>void g(`${v.workspace}?sort=size`),onUpgradeStorage:y===`full`?()=>void g(v.plans):null}),(0,Q.jsxs)(vr,{assistant:b?k:null,showHandles:p&&_===`full`,children:[(0,Q.jsx)(Ko,{}),d&&_!==`gated`&&(0,Q.jsxs)(Q.Fragment,{children:[(0,Q.jsx)(`div`,{className:`border-t border-[var(--border-subtle)]`}),(0,Q.jsxs)(`section`,{className:`flex flex-col gap-2`,children:[(0,Q.jsx)(`h3`,{className:`text-title-small text-[var(--content-emphasised)]`,children:e(`generalPage.twoFactorTitle`)}),(0,Q.jsx)(`p`,{className:`text-body-medium-default text-[var(--content-tertiary)]`,children:e(`generalPage.twoFactorDescription`)}),(0,Q.jsx)(`div`,{className:`mt-1`,children:_===`disabled`?(0,Q.jsx)(W,{children:e(`generalPage.twoFactorLoginNotice`)}):(0,Q.jsx)(rs,{})})]})]})]}),(0,Q.jsx)(X,{title:e(`generalPage.versionTitle`),subtitle:e(`generalPage.versionSubtitle`),accessory:y===`full`&&k?(0,Q.jsx)(n,{variant:`outlined`,onClick:()=>C(!0),children:e(`generalPage.updateWindow`)}):void 0,children:(0,Q.jsxs)(`div`,{className:`flex flex-col gap-4`,children:[y===`full`&&k&&(0,Q.jsxs)(Q.Fragment,{children:[(0,Q.jsx)(xi,{assistantId:k.id,currentVersion:N,releaseChannel:k.release_channel,onUpgradeComplete:()=>{c()}}),(0,Q.jsx)(wo,{assistantId:k.id,onComplete:()=>{c()}})]}),M&&t&&(0,Q.jsx)(Si,{assistantId:t.id,currentVersion:N,onUpgradeComplete:()=>{c()}}),!te&&t&&(0,Q.jsxs)(`div`,{className:`grid grid-cols-[140px_minmax(0,1fr)] gap-y-3`,children:[(0,Q.jsx)(`span`,{className:`text-body-medium-default text-[var(--content-tertiary)]`,children:e(`generalPage.current`)}),(0,Q.jsx)(Yn,{version:N,loading:i&&!t.current_release_version,assistantId:t.id??null})]}),y===`disabled`&&!M&&(0,Q.jsx)(W,{children:e(`generalPage.updatesLoginNotice`)}),(0,Q.jsx)(Ao,{})]})}),y===`full`&&k&&(0,Q.jsx)($o,{assistantId:k.id,open:S,onClose:()=>C(!1)}),y===`full`&&t&&(0,Q.jsx)(No,{assistant:t,healthz:r,healthzLoading:i,healthzFetching:o,healthzPolling:s,refetch:c,refetchUntilResized:l}),y===`disabled`&&(0,Q.jsx)(X,{id:`storage-resources`,title:e(`generalPage.computeResourcesTitle`),subtitle:e(`generalPage.computeResourcesSubtitle`),children:(0,Q.jsx)(W,{children:e(`generalPage.computeResourcesLoginNotice`)})}),(0,Q.jsx)(X,{title:e(`generalPage.preferencesTitle`),subtitle:e(`generalPage.preferencesSubtitle`),accessory:(0,Q.jsx)(n,{variant:`outlined`,onClick:()=>T(!0),children:e(`generalPage.customize`)}),children:(0,Q.jsxs)(`div`,{className:`flex flex-col gap-5`,children:[(0,Q.jsx)(ar,{}),(0,Q.jsx)(li,{})]})}),(0,Q.jsx)(yo,{open:w,onClose:()=>T(!1)}),(0,Q.jsx)(Ei,{}),(0,Q.jsx)(uo,{}),y===`full`&&k&&f&&(0,Q.jsx)(X,{title:e(`generalPage.sleepPolicyTitle`),subtitle:e(`generalPage.sleepPolicySubtitle`),children:(0,Q.jsx)(_i,{assistantId:k.id})}),y===`disabled`&&f&&(0,Q.jsx)(X,{title:e(`generalPage.sleepPolicyTitle`),subtitle:e(`generalPage.sleepPolicySubtitle`),children:(0,Q.jsx)(W,{children:e(`generalPage.sleepPolicyLoginNotice`)})}),u&&!h&&(0,Q.jsx)(fi,{}),h&&(0,Q.jsx)(X,{title:e(`generalPage.switchAssistantTitle`),subtitle:e(`generalPage.switchAssistantSubtitle`),accessory:(0,Q.jsx)(n,{variant:`outlined`,onClick:ne,children:e(`generalPage.chooseAssistant`)})}),E()&&(0,Q.jsx)(ac,{}),(P||re)&&(0,Q.jsx)(X,{variant:`danger`,title:e(`generalPage.dangerZoneTitle`),children:(0,Q.jsxs)(`div`,{className:`flex flex-col gap-6`,children:[P&&(0,Q.jsxs)(`section`,{className:`flex flex-col gap-2`,children:[(0,Q.jsx)(`h3`,{className:`text-title-small text-[var(--content-emphasised)]`,children:e(`generalPage.retireAssistantTitle`)}),(0,Q.jsx)(`p`,{className:`text-body-medium-default text-[var(--content-tertiary)]`,children:e(`generalPage.retireAssistantDescription`)}),(0,Q.jsx)(`div`,{className:`mt-1`,children:(_===`full`||ee)&&k?(0,Q.jsx)(Po,{assistantId:k.id}):(0,Q.jsx)(W,{children:e(`generalPage.retireAssistantLoginNotice`)})})]}),P&&re&&(0,Q.jsx)(`div`,{className:`border-t border-[var(--border-subtle)]`}),(0,Q.jsx)(Ci,{})]})})]})}export{oc as GeneralPage};