@seira-bot/seira 0.1.180 → 0.1.181

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 (173) hide show
  1. package/dist/assets/{ActivityPanel-DpipGqnm.js → ActivityPanel-tZLxRHYi.js} +1 -1
  2. package/dist/assets/{AnnouncementsPage-GCXia4xK.js → AnnouncementsPage-BrGYAaS0.js} +1 -1
  3. package/dist/assets/{App-BIllYA_e.js → App-h8WTNY4l.js} +136 -136
  4. package/dist/assets/{AppEventEditor-DYdUkpiM.js → AppEventEditor-CLpZ2lyb.js} +1 -1
  5. package/dist/assets/{BotSettingsDialog-DxRMUwAP.js → BotSettingsDialog-COjDhP9V.js} +1 -1
  6. package/dist/assets/{BrowserPanel-Cu_GqDA1.js → BrowserPanel-D_kPeSZ3.js} +1 -1
  7. package/dist/assets/{BrowserProfilesManager-CL3TIl73.js → BrowserProfilesManager-haN8RgPf.js} +1 -1
  8. package/dist/assets/{CloudAddDialog-DUk6i4df.js → CloudAddDialog-vwGwJIYN.js} +1 -1
  9. package/dist/assets/{ComputerFilesPane-HvpeAXhL.js → ComputerFilesPane-DJu1k1Ap.js} +1 -1
  10. package/dist/assets/{ComputerPanel-CozzFQeF.js → ComputerPanel-D9bTedHq.js} +2 -2
  11. package/dist/assets/{DataPanel-DGqcWB1O.js → DataPanel-CsuS_ybT.js} +1 -1
  12. package/dist/assets/{DesktopViewer-BoBSIDfB.js → DesktopViewer-YvIV04Lf.js} +1 -1
  13. package/dist/assets/{EnginesSettings-D643-yZk.js → EnginesSettings-C27xDaBN.js} +1 -1
  14. package/dist/assets/{FilesView-b5DFlMDt.js → FilesView-Dsxj73nW.js} +1 -1
  15. package/dist/assets/{GrokMoveDialog-gGTLfrGg.js → GrokMoveDialog-DEgRQW9G.js} +1 -1
  16. package/dist/assets/{ImportDialog-Bu5X6qOF.js → ImportDialog-DLVTgN-h.js} +1 -1
  17. package/dist/assets/{InspectorPanel-DU7_iwQR.js → InspectorPanel-gvFj5wfe.js} +1 -1
  18. package/dist/assets/{KeyboardShortcutsModal-Wxnn1d66.js → KeyboardShortcutsModal-aF0vhD29.js} +1 -1
  19. package/dist/assets/{LiveDesktop-D9PC-iAT.js → LiveDesktop-Bca91cEb.js} +1 -1
  20. package/dist/assets/{LocalVmWorkspace-0YxB-I-X.js → LocalVmWorkspace-CVLDY3ws.js} +1 -1
  21. package/dist/assets/{MacLocalControl-DoEGcs3V.js → MacLocalControl-BeNWQ9oY.js} +1 -1
  22. package/dist/assets/{MarkdownFilePreview-CAlARwd0.js → MarkdownFilePreview-CYw3CQ3T.js} +1 -1
  23. package/dist/assets/{MenuMotion-DfjnHTCi.js → MenuMotion-CHp-hB40.js} +1 -1
  24. package/dist/assets/{NewBotDialog-D3i7j_KP.js → NewBotDialog-BxeQktoI.js} +1 -1
  25. package/dist/assets/{PhoneAppDialog-OeXLO0Wb.js → PhoneAppDialog-CIlw_m5U.js} +1 -1
  26. package/dist/assets/{PlacesRail-3RaNlpug.js → PlacesRail-Df-jNTHn.js} +1 -1
  27. package/dist/assets/PluginsPanel-CMqZcDkC.js +8 -0
  28. package/dist/assets/{ProIntroduction-B3phUWnc.js → ProIntroduction-D8hWm9R5.js} +1 -1
  29. package/dist/assets/{PublishedAppsPage-BXWDYkhG.js → PublishedAppsPage-BMn3C64O.js} +1 -1
  30. package/dist/assets/{RemoteAgentSettingsPanel-vgrEf5B7.js → RemoteAgentSettingsPanel-B7QJizjx.js} +1 -1
  31. package/dist/assets/{RoomPanel-BmXypXPv.js → RoomPanel-CyWZ4kkq.js} +1 -1
  32. package/dist/assets/RoutinesPage-B9kKyfFp.js +2 -0
  33. package/dist/assets/{ServerPairingCard-c2fKq1gh.js → ServerPairingCard-D21dP5Bc.js} +1 -1
  34. package/dist/assets/SettingsModal-afRPXeYI.js +2 -0
  35. package/dist/assets/{ShareDepartmentDialog-CJITsmAd.js → ShareDepartmentDialog-CwErWDth.js} +1 -1
  36. package/dist/assets/{SignedInSites-B2pCMdic.js → SignedInSites-CFyvOLSc.js} +1 -1
  37. package/dist/assets/{TeamFilesPage-B10cdbwa.js → TeamFilesPage-BvhXs2O5.js} +1 -1
  38. package/dist/assets/{TeamLibraryPanel-CRmTfBOI.js → TeamLibraryPanel-Dm8wjNB4.js} +1 -1
  39. package/dist/assets/{TeamMapPage-BoTNppEy.js → TeamMapPage-jCSzFPvB.js} +1 -1
  40. package/dist/assets/{ToolPageShell-BPd_nyJ8.js → ToolPageShell-DKZUregg.js} +1 -1
  41. package/dist/assets/{TriggersPage-DDxtJMT4.js → TriggersPage-wSB6z1cp.js} +1 -1
  42. package/dist/assets/{VisibilitySection-Cd3TZvS_.js → VisibilitySection-CFr6fOzq.js} +1 -1
  43. package/dist/assets/{WebhookTrigger-AJduidiC.js → WebhookTrigger-BJN-V-bx.js} +1 -1
  44. package/dist/assets/{WorksOnGrid-DHo10o0j.js → WorksOnGrid-B3wYro9M.js} +1 -1
  45. package/dist/assets/{abnfDiagram-YUKMZFIV-DnIZyeSK.js → abnfDiagram-YUKMZFIV-DRhWKTiz.js} +1 -1
  46. package/dist/assets/{activity-DrX2_Hm9.js → activity-l0oTqbd6.js} +1 -1
  47. package/dist/assets/{architectureDiagram-47P4ROYG-DHdulT2e.js → architectureDiagram-47P4ROYG-C_qnTvJF.js} +1 -1
  48. package/dist/assets/{blockDiagram-E7TT5TSB-BGReDH4k.js → blockDiagram-E7TT5TSB-DzLSloVY.js} +1 -1
  49. package/dist/assets/{c4Diagram-CRA5TL53-BV9zDZsL.js → c4Diagram-CRA5TL53-BzVViHCA.js} +1 -1
  50. package/dist/assets/{calendar-days-Ddhxf1PV.js → calendar-days-DFd3GKf_.js} +1 -1
  51. package/dist/assets/channel-B2D6cAE5.js +1 -0
  52. package/dist/assets/{chunk-2Q5K7J3B-DAj16syq.js → chunk-2Q5K7J3B-hR-bQJHo.js} +1 -1
  53. package/dist/assets/{chunk-5VM5RSS4-CMyoXW_3.js → chunk-5VM5RSS4-BWmBW1XC.js} +1 -1
  54. package/dist/assets/{chunk-7TKQ45FW--z54G8Jv.js → chunk-7TKQ45FW-DuUk7RXl.js} +1 -1
  55. package/dist/assets/{chunk-AW2ZBBNX-CPPbUHIj.js → chunk-AW2ZBBNX-Madgl1uv.js} +1 -1
  56. package/dist/assets/{chunk-FVRAUYC3-pKEz9wbK.js → chunk-FVRAUYC3-WSgsvIGA.js} +2 -2
  57. package/dist/assets/{chunk-HTAEGDNF-DIOqwx2X.js → chunk-HTAEGDNF-CfoPR2yG.js} +1 -1
  58. package/dist/assets/{chunk-JWPE2WC7-BW474-Li.js → chunk-JWPE2WC7-tLRHdBom.js} +1 -1
  59. package/dist/assets/{chunk-KQW6MTUR-DjAEB-Df.js → chunk-KQW6MTUR-BqwuNuVY.js} +1 -1
  60. package/dist/assets/{chunk-XXDRQBXY-CMZz2xNV.js → chunk-XXDRQBXY-BOeb8xE4.js} +1 -1
  61. package/dist/assets/{classDiagram-v2-K4WV4PDN-7GYDWs2n.js → classDiagram-v2-K4WV4PDN-CFeH5trZ.js} +1 -1
  62. package/dist/assets/{core-Dq4LUz6X.js → core-CnInZb-o.js} +1 -1
  63. package/dist/assets/{cose-bilkent-JH36ORCC-Dy2zOVu3.js → cose-bilkent-JH36ORCC-BEg68hhI.js} +1 -1
  64. package/dist/assets/{cynefin-EF2NZ3EQ-C7I3qmqf.js → cynefin-EF2NZ3EQ-B_Xq3hQ3.js} +1 -1
  65. package/dist/assets/{cynefinDiagram-3GCD6N5R-CsPcUXHD.js → cynefinDiagram-3GCD6N5R-DN1o2ihW.js} +1 -1
  66. package/dist/assets/{dagre-W4DXFKR2-DxvGlifm.js → dagre-W4DXFKR2-BFf83-nP.js} +1 -1
  67. package/dist/assets/{de-CrlnmnfQ.js → de-BpsYkrLY.js} +1 -1
  68. package/dist/assets/{desktop-connection-Df-k5QBM.js → desktop-connection-CU6jsy2e.js} +1 -1
  69. package/dist/assets/{diagram-2UJZ2QOL-Qz2-e2_u.js → diagram-2UJZ2QOL-_qwbS5JH.js} +1 -1
  70. package/dist/assets/{diagram-OVF4WLC6-D1u4ioUX.js → diagram-OVF4WLC6-9sq9EfiF.js} +1 -1
  71. package/dist/assets/{diagram-PFPMY2P6-DZiCtcMI.js → diagram-PFPMY2P6-Ow1v5ZhK.js} +1 -1
  72. package/dist/assets/{diagram-UMYRVEAY-DmVn9h1H.js → diagram-UMYRVEAY-DDTBFPls.js} +1 -1
  73. package/dist/assets/{diagram-YEKJPTXX-CJK2ajcB.js → diagram-YEKJPTXX-D1zZ8KqI.js} +1 -1
  74. package/dist/assets/{diagram-ZIFT7M5P-NoYT_JX9.js → diagram-ZIFT7M5P-C_vZWUw8.js} +1 -1
  75. package/dist/assets/{ebnfDiagram-VR2GEFS7-BooF3Pem.js → ebnfDiagram-VR2GEFS7-D_1GvBDx.js} +1 -1
  76. package/dist/assets/{elk-IJKZMXRS-4Ai0igvq.js → elk-IJKZMXRS-CV-PzspH.js} +1 -1
  77. package/dist/assets/{erDiagram-O2IAPWRE-CdhhzqVX.js → erDiagram-O2IAPWRE-CnKVd0av.js} +1 -1
  78. package/dist/assets/{es-BIPy8tP9.js → es-COLCGADa.js} +1 -1
  79. package/dist/assets/{file-up-Bs5NWcjw.js → file-up-Bjx5Vcmk.js} +1 -1
  80. package/dist/assets/{flowDiagram-OXPTDLAJ-SeyZJAiT.js → flowDiagram-OXPTDLAJ-CGJh171P.js} +1 -1
  81. package/dist/assets/{fr-CCbXz1Dc.js → fr-CJ1x1iRl.js} +1 -1
  82. package/dist/assets/{ganttDiagram-R7TSEDQI-rmA_SJlC.js → ganttDiagram-R7TSEDQI-CygoACFs.js} +1 -1
  83. package/dist/assets/{gitGraphDiagram-XJZIOB7I-Coc2oeHo.js → gitGraphDiagram-XJZIOB7I-ByxErzHV.js} +1 -1
  84. package/dist/assets/{hi-DmCL9a_Y.js → hi-BC0iO7jD.js} +1 -1
  85. package/dist/assets/{index-uiyAwyX1.js → index-BRfvYRb5.js} +1 -1
  86. package/dist/assets/{index-D69O3YiA.js → index-DQZxP2c4.js} +2 -2
  87. package/dist/assets/{index-C1PEx1tc.js → index-DtDQrExn.js} +3 -3
  88. package/dist/assets/{infoDiagram-5W2HQ5XZ-DScYPtht.js → infoDiagram-5W2HQ5XZ-BlzjfTwq.js} +1 -1
  89. package/dist/assets/{ishikawaDiagram-K3B6WC7H-Cf7mJB_l.js → ishikawaDiagram-K3B6WC7H-2rf_4lR_.js} +1 -1
  90. package/dist/assets/{it-BWkdcVfm.js → it-BIwsqdpz.js} +2 -2
  91. package/dist/assets/{ja-BaOL6cSA.js → ja-BJYXkO5E.js} +2 -2
  92. package/dist/assets/{journeyDiagram-COXZFDF6-Dtmolw3A.js → journeyDiagram-COXZFDF6-mGgPoETt.js} +1 -1
  93. package/dist/assets/{kanban-definition-P3RFRI5V-CSL1-s5L.js → kanban-definition-P3RFRI5V-j2hU8Bw4.js} +1 -1
  94. package/dist/assets/{kit-Cjq8TV0N.js → kit-qjammJR4.js} +1 -1
  95. package/dist/assets/{ko-ebMBLBXv.js → ko-7QtaPFvf.js} +2 -2
  96. package/dist/assets/{livekit-KT4NEVZO-B3DA1PsD.js → livekit-KT4NEVZO-DbFoU2r9.js} +1 -1
  97. package/dist/assets/{mcp-servers-DoMFsds6.js → mcp-servers-Tb2cnkiM.js} +1 -1
  98. package/dist/assets/{memory-BR-ujoQY.js → memory-BNaMRI5v.js} +1 -1
  99. package/dist/assets/{mermaid.core-BK1qxlD4.js → mermaid.core-B1mlFiOp.js} +4 -4
  100. package/dist/assets/{mindmap-definition-LZFPQGKD-Cb7ESZ0y.js → mindmap-definition-LZFPQGKD-C7XLkIzZ.js} +1 -1
  101. package/dist/assets/{minimize-msM7mbil.js → minimize-Dga3UCb8.js} +1 -1
  102. package/dist/assets/{monitor-DpsqT1_R.js → monitor-DMPjQDZP.js} +1 -1
  103. package/dist/assets/{org-library-alRyzCTE.js → org-library-IKFXm7D6.js} +1 -1
  104. package/dist/assets/{package-format-BFXbXHk8.js → package-format-COujx3jP.js} +1 -1
  105. package/dist/assets/{pegDiagram-BGZESJAR-CqmJQKhe.js → pegDiagram-BGZESJAR-BS2zKH6g.js} +1 -1
  106. package/dist/assets/{phones-J7mYR-fY.js → phones-CINpTjZv.js} +1 -1
  107. package/dist/assets/{pieDiagram-CAPJLFHJ-w_QuumOv.js → pieDiagram-CAPJLFHJ-DVAuLXem.js} +1 -1
  108. package/dist/assets/{pl-CSbinyb5.js → pl-CLa2ta1_.js} +2 -2
  109. package/dist/assets/{pt-br-BkWykL5e.js → pt-br-8RQzCbpg.js} +3 -3
  110. package/dist/assets/{quadrantDiagram-GDMTTRAM-248q9C3h.js → quadrantDiagram-GDMTTRAM-H7QRxmHt.js} +1 -1
  111. package/dist/assets/{rail-DRr_33Fe.js → rail-DNpLzOxa.js} +1 -1
  112. package/dist/assets/{railroadDiagram-SM67HX2B-BLzQ_5t7.js → railroadDiagram-SM67HX2B-dq6Rokc9.js} +1 -1
  113. package/dist/assets/{remote-desktop-panel-BPK6Q0O6.js → remote-desktop-panel-Cxv6Qt3x.js} +1 -1
  114. package/dist/assets/{requirementDiagram-X7JNWC4A-Bgi1TLdN.js → requirementDiagram-X7JNWC4A-BeWeL_-r.js} +1 -1
  115. package/dist/assets/{ru-DD01Hb1S.js → ru-CIdzvRVZ.js} +2 -2
  116. package/dist/assets/{sankeyDiagram-UM26HJRW-CrZgn-Cf.js → sankeyDiagram-UM26HJRW-BmJ-9lt-.js} +1 -1
  117. package/dist/assets/{sequenceDiagram-ZO4K6R2Y-gAwq1ZfG.js → sequenceDiagram-ZO4K6R2Y-Uuh1hEOh.js} +1 -1
  118. package/dist/assets/{sizeCapture-INFHLROL-BlXmG_DJ.js → sizeCapture-INFHLROL-mKDf6lys.js} +1 -1
  119. package/dist/assets/{stateDiagram-v2-TBUQTH76-CEFB1Iaq.js → stateDiagram-v2-TBUQTH76-BaEihzov.js} +1 -1
  120. package/dist/assets/{styles-DOJOOIp4.js → styles-3g-ZPS7M.js} +5 -5
  121. package/dist/assets/styles-CsrDURJH.css +1 -0
  122. package/dist/assets/{swimlanes-N4OXWK64-BtJmWAOz.js → swimlanes-N4OXWK64-CpP-NKGz.js} +1 -1
  123. package/dist/assets/swimlanesDiagram-K3J5GTZL-C50Dm6LQ.js +8 -0
  124. package/dist/assets/{template-add-BcTS64TG.js → template-add-CHwGLPet.js} +1 -1
  125. package/dist/assets/{timeline-definition-YOQAKGHF-BZ270zxf.js → timeline-definition-YOQAKGHF-Ca3rjetv.js} +1 -1
  126. package/dist/assets/{tr-Bw35A32w.js → tr-BhclavHM.js} +1 -1
  127. package/dist/assets/{uk-DsPsCgp4.js → uk-Or5wmf6s.js} +1 -1
  128. package/dist/assets/{usecaseDiagram-VIAY4XPW-D5yZb3KQ.js → usecaseDiagram-VIAY4XPW-BuuYl689.js} +1 -1
  129. package/dist/assets/{vennDiagram-BLWOH2XV-OFx2qTzp.js → vennDiagram-BLWOH2XV-C__pWnnE.js} +1 -1
  130. package/dist/assets/{vi-DhPdzwW-.js → vi-CYbGVqh-.js} +1 -1
  131. package/dist/assets/{wardleyDiagram-YMQ3BMBF-DzSmrVKa.js → wardleyDiagram-YMQ3BMBF-yWcEHD-N.js} +1 -1
  132. package/dist/assets/{xychartDiagram-TAQBALBS-UP1H1u5V.js → xychartDiagram-TAQBALBS-CvcdOA7A.js} +1 -1
  133. package/dist/assets/{zh-CzC3CUQA.js → zh-iptM1e_T.js} +2 -2
  134. package/dist/assets/{zh-tw-DeXHnAvy.js → zh-tw-BaO1c--E.js} +2 -2
  135. package/dist/index.html +3 -3
  136. package/dist/rail.html +5 -5
  137. package/dist-server/container-mcp.js +18 -17
  138. package/dist-server/index.js +1136 -1114
  139. package/dist-server/openmausbot.js +182 -180
  140. package/dist-server/package.json +1 -1
  141. package/dist-server/pair-cli.js +182 -180
  142. package/dist-server/server/ai-pool.js +72 -0
  143. package/dist-server/server/cloud-connected-apps.js +33 -16
  144. package/dist-server/server/composio-broker-access.js +1 -1
  145. package/dist-server/server/composio.js +3 -2
  146. package/dist-server/server/config.js +5 -7
  147. package/dist-server/server/connector-auth-config-hint.js +5 -0
  148. package/dist-server/server/drivers/claude.js +14 -11
  149. package/dist-server/server/flatpak-host.js +5 -2
  150. package/dist-server/server/host/ai-pool.js +109 -0
  151. package/dist-server/server/host/app-suggestions.js +2 -1
  152. package/dist-server/server/host/limit-takeover.js +11 -4
  153. package/dist-server/server/index.js +33 -26
  154. package/dist-server/server/limit-failover.js +3 -0
  155. package/dist-server/server/model-selection-schema.js +9 -0
  156. package/dist-server/server/routes/ai-pool-patch.js +24 -0
  157. package/dist-server/server/routes/config.js +8 -1
  158. package/dist-server/server/routine-dispatch.js +21 -0
  159. package/dist-server/server/routines.js +4 -18
  160. package/dist-server/server/tailscale.js +16 -6
  161. package/dist-server/server/workspace-backup-http.js +2 -2
  162. package/dist-server/shared/limit-backup.js +1 -1
  163. package/dist-server/shared/settings-places.js +1 -0
  164. package/dist-server/shared/toolkit-card.js +1 -0
  165. package/dist-server/vps-container-mcp.js +18 -17
  166. package/dist-server/workspace-backup.worker.js +18 -17
  167. package/package.json +1 -1
  168. package/dist/assets/PluginsPanel-B5Q70eO8.js +0 -8
  169. package/dist/assets/RoutinesPage-CLXohizn.js +0 -2
  170. package/dist/assets/SettingsModal-BlX9XoBu.js +0 -2
  171. package/dist/assets/channel-DZM5KU--.js +0 -1
  172. package/dist/assets/styles-9UFSdSaJ.css +0 -1
  173. package/dist/assets/swimlanesDiagram-K3J5GTZL-pBTtzroP.js +0 -8
@@ -1,3 +1,3 @@
1
- import{dd as W,de as A,df as k,dg as C,dh as $,di as q,dj as z,dk as U,dl as X}from"./App-BIllYA_e.js";import j from"./katex-HP8lGamR.js";import"./styles-DOJOOIp4.js";import"./index-C1PEx1tc.js";import"./PlacesRail-3RaNlpug.js";import"./placement-BKtVnQht.js";import"./monitor-DpsqT1_R.js";import"./MenuMotion-DfjnHTCi.js";const T=/[#.]/g;function Y(e,t){const r=e||"",n={};let o=0,i,s;for(;o<r.length;){T.lastIndex=o;const a=T.exec(r),c=r.slice(o,a?a.index:r.length);c&&(i?i==="#"?n.id=c:Array.isArray(n.className)?n.className.push(c):n.className=[c]:s=c,o+=c.length),a&&(i=a[0],o++)}return{type:"element",tagName:s||t||"div",properties:n,children:[]}}function B(e,t,r){const n=r?v(r):void 0;function o(i,s,...a){let c;if(i==null){c={type:"root",children:[]};const f=s;a.unshift(f)}else{c=Y(i,t);const f=c.tagName.toLowerCase(),l=n?n.get(f):void 0;if(c.tagName=l||f,J(s))a.unshift(s);else for(const[u,d]of Object.entries(s))Q(e,c.properties,u,d)}for(const f of a)w(c.children,f);return c.type==="element"&&c.tagName==="template"&&(c.content={type:"root",children:c.children},c.children=[]),c}return o}function J(e){if(e===null||typeof e!="object"||Array.isArray(e))return!0;if(typeof e.type!="string")return!1;const t=e,r=Object.keys(e);for(const n of r){const o=t[n];if(o&&typeof o=="object"){if(!Array.isArray(o))return!0;const i=o;for(const s of i)if(typeof s!="number"&&typeof s!="string")return!0}}return!!("children"in e&&Array.isArray(e.children))}function Q(e,t,r,n){const o=W(e,r);let i;if(n!=null){if(typeof n=="number"){if(Number.isNaN(n))return;i=n}else typeof n=="boolean"?i=n:typeof n=="string"?o.spaceSeparated?i=A(n):o.commaSeparated?i=k(n):o.commaOrSpaceSeparated?i=A(k(n).join(" ")):i=E(o,o.property,n):Array.isArray(n)?i=[...n]:i=o.property==="style"?Z(n):String(n);if(Array.isArray(i)){const s=[];for(const a of i)s.push(E(o,o.property,a));i=s}o.property==="className"&&Array.isArray(t.className)&&(i=t.className.concat(i)),t[o.property]=i}}function w(e,t){if(t!=null)if(typeof t=="number"||typeof t=="string")e.push({type:"text",value:String(t)});else if(Array.isArray(t))for(const r of t)w(e,r);else if(typeof t=="object"&&"type"in t)t.type==="root"?w(e,t.children):e.push(t);else throw new Error("Expected node, nodes, or string, got `"+t+"`")}function E(e,t,r){if(typeof r=="string"){if(e.number&&r&&!Number.isNaN(Number(r)))return Number(r);if((e.boolean||e.overloadedBoolean)&&(r===""||C(r)===C(t)))return!0}return r}function Z(e){const t=[];for(const[r,n]of Object.entries(e))t.push([r,n].join(": "));return t.join("; ")}function v(e){const t=new Map;for(const r of e)t.set(r.toLowerCase(),r);return t}const ee=["altGlyph","altGlyphDef","altGlyphItem","animateColor","animateMotion","animateTransform","clipPath","feBlend","feColorMatrix","feComponentTransfer","feComposite","feConvolveMatrix","feDiffuseLighting","feDisplacementMap","feDistantLight","feDropShadow","feFlood","feFuncA","feFuncB","feFuncG","feFuncR","feGaussianBlur","feImage","feMerge","feMergeNode","feMorphology","feOffset","fePointLight","feSpecularLighting","feSpotLight","feTile","feTurbulence","foreignObject","glyphRef","linearGradient","radialGradient","solidColor","textArea","textPath"],te=B($,"div"),re=B(q,"g",ee),y={html:"http://www.w3.org/1999/xhtml",svg:"http://www.w3.org/2000/svg"};function ne(e,t){return P(e,{})||{type:"root",children:[]}}function P(e,t){const r=oe(e,t);return r&&t.afterTransform&&t.afterTransform(e,r),r}function oe(e,t){switch(e.nodeType){case 1:return ae(e,t);case 3:return se(e);case 8:return ce(e);case 9:return S(e,t);case 10:return ie();case 11:return S(e,t);default:return}}function S(e,t){return{type:"root",children:D(e,t)}}function ie(){return{type:"doctype"}}function se(e){return{type:"text",value:e.nodeValue||""}}function ce(e){return{type:"comment",value:e.nodeValue||""}}function ae(e,t){const r=e.namespaceURI,n=r===y.svg?re:te,o=r===y.html?e.tagName.toLowerCase():e.tagName,i=r===y.html&&o==="template"?e.content:e,s=e.getAttributeNames(),a={};let c=-1;for(;++c<s.length;)a[s[c]]=e.getAttribute(s[c])||"";return n(o,a,D(i,t))}function D(e,t){const r=e.childNodes,n=[];let o=-1;for(;++o<r.length;){const i=P(r[o],t);i!==void 0&&n.push(i)}return n}new DOMParser;function fe(e,t){const r=le(e);return ne(r)}function le(e){const t=document.createElement("template");return t.innerHTML=e,t.content}const I=(function(e,t,r){const n=z(r);if(!e||!e.type||!e.children)throw new Error("Expected parent node");if(typeof t=="number"){if(t<0||t===Number.POSITIVE_INFINITY)throw new Error("Expected positive finite number as index")}else if(t=e.children.indexOf(t),t<0)throw new Error("Expected child node or index");for(;++t<e.children.length;)if(n(e.children[t],t,e))return e.children[t]}),h=(function(e){if(e==null)return he;if(typeof e=="string")return pe(e);if(typeof e=="object")return ue(e);if(typeof e=="function")return b(e);throw new Error("Expected function, string, or array as `test`")});function ue(e){const t=[];let r=-1;for(;++r<e.length;)t[r]=h(e[r]);return b(n);function n(...o){let i=-1;for(;++i<t.length;)if(t[i].apply(this,o))return!0;return!1}}function pe(e){return b(t);function t(r){return r.tagName===e}}function b(e){return t;function t(r,n,o){return!!(de(r)&&e.call(this,r,typeof n=="number"?n:void 0,o||void 0))}}function he(e){return!!(e&&typeof e=="object"&&"type"in e&&e.type==="element"&&"tagName"in e&&typeof e.tagName=="string")}function de(e){return e!==null&&typeof e=="object"&&"type"in e&&"tagName"in e}const O=/\n/g,M=/[\t ]+/g,N=h("br"),F=h(Ae),me=h("p"),L=h("tr"),ge=h(["datalist","head","noembed","noframes","noscript","rp","script","style","template","title",xe,ke]),G=h(["address","article","aside","blockquote","body","caption","center","dd","dialog","dir","dl","dt","div","figure","figcaption","footer","form,","h1","h2","h3","h4","h5","h6","header","hgroup","hr","html","legend","li","listing","main","menu","nav","ol","p","plaintext","pre","section","ul","xmp"]);function ye(e,t){const r=t||{},n="children"in e?e.children:[],o=G(e),i=H(e,{whitespace:r.whitespace||"normal"}),s=[];(e.type==="text"||e.type==="comment")&&s.push(..._(e,{breakBefore:!0,breakAfter:!0}));let a=-1;for(;++a<n.length;)s.push(...R(n[a],e,{whitespace:i,breakBefore:a?void 0:o,breakAfter:a<n.length-1?N(n[a+1]):o}));const c=[];let f;for(a=-1;++a<s.length;){const l=s[a];typeof l=="number"?f!==void 0&&l>f&&(f=l):l&&(f!==void 0&&f>-1&&c.push(`
1
+ import{dd as W,de as A,df as k,dg as C,dh as $,di as q,dj as z,dk as U,dl as X}from"./App-h8WTNY4l.js";import j from"./katex-HP8lGamR.js";import"./styles-3g-ZPS7M.js";import"./index-DtDQrExn.js";import"./PlacesRail-Df-jNTHn.js";import"./placement-BKtVnQht.js";import"./monitor-DMPjQDZP.js";import"./MenuMotion-CHp-hB40.js";const T=/[#.]/g;function Y(e,t){const r=e||"",n={};let o=0,i,s;for(;o<r.length;){T.lastIndex=o;const a=T.exec(r),c=r.slice(o,a?a.index:r.length);c&&(i?i==="#"?n.id=c:Array.isArray(n.className)?n.className.push(c):n.className=[c]:s=c,o+=c.length),a&&(i=a[0],o++)}return{type:"element",tagName:s||t||"div",properties:n,children:[]}}function B(e,t,r){const n=r?v(r):void 0;function o(i,s,...a){let c;if(i==null){c={type:"root",children:[]};const f=s;a.unshift(f)}else{c=Y(i,t);const f=c.tagName.toLowerCase(),l=n?n.get(f):void 0;if(c.tagName=l||f,J(s))a.unshift(s);else for(const[u,d]of Object.entries(s))Q(e,c.properties,u,d)}for(const f of a)w(c.children,f);return c.type==="element"&&c.tagName==="template"&&(c.content={type:"root",children:c.children},c.children=[]),c}return o}function J(e){if(e===null||typeof e!="object"||Array.isArray(e))return!0;if(typeof e.type!="string")return!1;const t=e,r=Object.keys(e);for(const n of r){const o=t[n];if(o&&typeof o=="object"){if(!Array.isArray(o))return!0;const i=o;for(const s of i)if(typeof s!="number"&&typeof s!="string")return!0}}return!!("children"in e&&Array.isArray(e.children))}function Q(e,t,r,n){const o=W(e,r);let i;if(n!=null){if(typeof n=="number"){if(Number.isNaN(n))return;i=n}else typeof n=="boolean"?i=n:typeof n=="string"?o.spaceSeparated?i=A(n):o.commaSeparated?i=k(n):o.commaOrSpaceSeparated?i=A(k(n).join(" ")):i=E(o,o.property,n):Array.isArray(n)?i=[...n]:i=o.property==="style"?Z(n):String(n);if(Array.isArray(i)){const s=[];for(const a of i)s.push(E(o,o.property,a));i=s}o.property==="className"&&Array.isArray(t.className)&&(i=t.className.concat(i)),t[o.property]=i}}function w(e,t){if(t!=null)if(typeof t=="number"||typeof t=="string")e.push({type:"text",value:String(t)});else if(Array.isArray(t))for(const r of t)w(e,r);else if(typeof t=="object"&&"type"in t)t.type==="root"?w(e,t.children):e.push(t);else throw new Error("Expected node, nodes, or string, got `"+t+"`")}function E(e,t,r){if(typeof r=="string"){if(e.number&&r&&!Number.isNaN(Number(r)))return Number(r);if((e.boolean||e.overloadedBoolean)&&(r===""||C(r)===C(t)))return!0}return r}function Z(e){const t=[];for(const[r,n]of Object.entries(e))t.push([r,n].join(": "));return t.join("; ")}function v(e){const t=new Map;for(const r of e)t.set(r.toLowerCase(),r);return t}const ee=["altGlyph","altGlyphDef","altGlyphItem","animateColor","animateMotion","animateTransform","clipPath","feBlend","feColorMatrix","feComponentTransfer","feComposite","feConvolveMatrix","feDiffuseLighting","feDisplacementMap","feDistantLight","feDropShadow","feFlood","feFuncA","feFuncB","feFuncG","feFuncR","feGaussianBlur","feImage","feMerge","feMergeNode","feMorphology","feOffset","fePointLight","feSpecularLighting","feSpotLight","feTile","feTurbulence","foreignObject","glyphRef","linearGradient","radialGradient","solidColor","textArea","textPath"],te=B($,"div"),re=B(q,"g",ee),y={html:"http://www.w3.org/1999/xhtml",svg:"http://www.w3.org/2000/svg"};function ne(e,t){return P(e,{})||{type:"root",children:[]}}function P(e,t){const r=oe(e,t);return r&&t.afterTransform&&t.afterTransform(e,r),r}function oe(e,t){switch(e.nodeType){case 1:return ae(e,t);case 3:return se(e);case 8:return ce(e);case 9:return S(e,t);case 10:return ie();case 11:return S(e,t);default:return}}function S(e,t){return{type:"root",children:D(e,t)}}function ie(){return{type:"doctype"}}function se(e){return{type:"text",value:e.nodeValue||""}}function ce(e){return{type:"comment",value:e.nodeValue||""}}function ae(e,t){const r=e.namespaceURI,n=r===y.svg?re:te,o=r===y.html?e.tagName.toLowerCase():e.tagName,i=r===y.html&&o==="template"?e.content:e,s=e.getAttributeNames(),a={};let c=-1;for(;++c<s.length;)a[s[c]]=e.getAttribute(s[c])||"";return n(o,a,D(i,t))}function D(e,t){const r=e.childNodes,n=[];let o=-1;for(;++o<r.length;){const i=P(r[o],t);i!==void 0&&n.push(i)}return n}new DOMParser;function fe(e,t){const r=le(e);return ne(r)}function le(e){const t=document.createElement("template");return t.innerHTML=e,t.content}const I=(function(e,t,r){const n=z(r);if(!e||!e.type||!e.children)throw new Error("Expected parent node");if(typeof t=="number"){if(t<0||t===Number.POSITIVE_INFINITY)throw new Error("Expected positive finite number as index")}else if(t=e.children.indexOf(t),t<0)throw new Error("Expected child node or index");for(;++t<e.children.length;)if(n(e.children[t],t,e))return e.children[t]}),h=(function(e){if(e==null)return he;if(typeof e=="string")return pe(e);if(typeof e=="object")return ue(e);if(typeof e=="function")return b(e);throw new Error("Expected function, string, or array as `test`")});function ue(e){const t=[];let r=-1;for(;++r<e.length;)t[r]=h(e[r]);return b(n);function n(...o){let i=-1;for(;++i<t.length;)if(t[i].apply(this,o))return!0;return!1}}function pe(e){return b(t);function t(r){return r.tagName===e}}function b(e){return t;function t(r,n,o){return!!(de(r)&&e.call(this,r,typeof n=="number"?n:void 0,o||void 0))}}function he(e){return!!(e&&typeof e=="object"&&"type"in e&&e.type==="element"&&"tagName"in e&&typeof e.tagName=="string")}function de(e){return e!==null&&typeof e=="object"&&"type"in e&&"tagName"in e}const O=/\n/g,M=/[\t ]+/g,N=h("br"),F=h(Ae),me=h("p"),L=h("tr"),ge=h(["datalist","head","noembed","noframes","noscript","rp","script","style","template","title",xe,ke]),G=h(["address","article","aside","blockquote","body","caption","center","dd","dialog","dir","dl","dt","div","figure","figcaption","footer","form,","h1","h2","h3","h4","h5","h6","header","hgroup","hr","html","legend","li","listing","main","menu","nav","ol","p","plaintext","pre","section","ul","xmp"]);function ye(e,t){const r=t||{},n="children"in e?e.children:[],o=G(e),i=H(e,{whitespace:r.whitespace||"normal"}),s=[];(e.type==="text"||e.type==="comment")&&s.push(..._(e,{breakBefore:!0,breakAfter:!0}));let a=-1;for(;++a<n.length;)s.push(...R(n[a],e,{whitespace:i,breakBefore:a?void 0:o,breakAfter:a<n.length-1?N(n[a+1]):o}));const c=[];let f;for(a=-1;++a<s.length;){const l=s[a];typeof l=="number"?f!==void 0&&l>f&&(f=l):l&&(f!==void 0&&f>-1&&c.push(`
2
2
  `.repeat(f)||" "),f=-1,c.push(l))}return c.join("")}function R(e,t,r){return e.type==="element"?we(e,t,r):e.type==="text"?r.whitespace==="normal"?_(e,r):Ne(e):[]}function we(e,t,r){const n=H(e,r),o=e.children||[];let i=-1,s=[];if(ge(e))return s;let a,c;for(N(e)||L(e)&&I(t,e,L)?c=`
3
3
  `:me(e)?(a=2,c=2):G(e)&&(a=1,c=1);++i<o.length;)s=s.concat(R(o[i],e,{whitespace:n,breakBefore:i?void 0:a,breakAfter:i<o.length-1?N(o[i+1]):c}));return F(e)&&I(t,e,F)&&s.push(" "),a&&s.unshift(a),c&&s.push(c),s}function _(e,t){const r=String(e.value),n=[],o=[];let i=0;for(;i<=r.length;){O.lastIndex=i;const c=O.exec(r),f=c&&"index"in c?c.index:r.length;n.push(be(r.slice(i,f).replace(/[\u061C\u200E\u200F\u202A-\u202E\u2066-\u2069]/g,""),i===0?t.breakBefore:!0,f===r.length?t.breakAfter:!0)),i=f+1}let s=-1,a;for(;++s<n.length;)n[s].charCodeAt(n[s].length-1)===8203||s<n.length-1&&n[s+1].charCodeAt(0)===8203?(o.push(n[s]),a=void 0):n[s]?(typeof a=="number"&&o.push(a),o.push(n[s]),a=0):(s===0||s===n.length-1)&&o.push(0);return o}function Ne(e){return[String(e.value)]}function be(e,t,r){const n=[];let o=0,i;for(;o<e.length;){M.lastIndex=o;const s=M.exec(e);i=s?s.index:e.length,!o&&!i&&s&&!t&&n.push(""),o!==i&&n.push(e.slice(o,i)),o=s?i+s[0].length:i}return o!==i&&!r&&n.push(""),n.join(" ")}function H(e,t){if(e.type==="element"){const r=e.properties||{};switch(e.tagName){case"listing":case"plaintext":case"xmp":return"pre";case"nobr":return"nowrap";case"pre":return r.wrap?"pre-wrap":"pre";case"td":case"th":return r.noWrap?"nowrap":t.whitespace;case"textarea":return"pre-wrap"}}return t.whitespace}function xe(e){return!!(e.properties||{}).hidden}function Ae(e){return e.tagName==="td"||e.tagName==="th"}function ke(e){return e.tagName==="dialog"&&!(e.properties||{}).open}const Ce={},je=[];function Be(e){const t=e||Ce;return function(r,n){U(r,"element",function(o,i){const s=Array.isArray(o.properties.className)?o.properties.className:je,a=s.includes("language-math"),c=s.includes("math-display"),f=s.includes("math-inline");let l=c;if(!a&&!c&&!f)return;let u=i[i.length-1],d=o;if(o.tagName==="code"&&a&&u&&u.type==="element"&&u.tagName==="pre"&&(d=u,u=i[i.length-2],l=!0),!u)return;const m=ye(d,{whitespace:"pre"});let p;try{p=j.renderToString(m,{...t,displayMode:l,throwOnError:!0})}catch(g){const x=g,V=x.name.toLowerCase();n.message("Could not render math with KaTeX",{ancestors:[...i,o],cause:x,place:o.position,ruleId:V,source:"rehype-katex"});try{p=j.renderToString(m,{...t,displayMode:l,strict:"ignore",throwOnError:!1})}catch{p=[{type:"element",tagName:"span",properties:{className:["katex-error"],style:"color:"+(t.errorColor||"#cc0000"),title:String(g)},children:[{type:"text",value:m}]}]}}typeof p=="string"&&(p=fe(p).children);const K=u.children.indexOf(d);return u.children.splice(K,1,...p),X})}}export{Be as default};
@@ -1,2 +1,2 @@
1
- const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["assets/livekit-KT4NEVZO-B3DA1PsD.js","assets/styles-DOJOOIp4.js","assets/styles-9UFSdSaJ.css"])))=>i.map(i=>d[i]);
2
- import{_ as we}from"./styles-DOJOOIp4.js";var se=e=>{throw TypeError(e)},Q=(e,t,i)=>t.has(e)||se("Cannot "+i),n=(e,t,i)=>(Q(e,t,"read from private field"),i?i.call(e):t.get(e)),u=(e,t,i)=>t.has(e)?se("Cannot add the same private member more than once"):t instanceof WeakSet?t.add(e):t.set(e,i),d=(e,t,i,s)=>(Q(e,t,"write to private field"),t.set(e,i),i),a=(e,t,i)=>(Q(e,t,"access private method"),i),ye=(e,t,i,s)=>({set _(r){d(e,t,r)},get _(){return n(e,t,s)}}),c=class extends Error{constructor(e,t,i){super(t,i?.cause!==void 0?{cause:i.cause}:void 0),this.name="FishAgentError",this.code=e,this.statusCode=i?.statusCode,this.stage=i?.stage,this.recovered=i?.recovered}},ze="agent-event",je="client-event",Ge="fish.agent.ready",Be="fish.client.audio_ready",Ke="pending",Ee="livekit";function re(){if(typeof HTMLMediaElement>"u"||!("setSinkId"in HTMLMediaElement.prototype))throw new c("device_change_failed","This browser does not support selecting an audio output device")}var Se=class{constructor(e={}){this.options=e,this.elements=new Map,this.volume=1}createElement(){if(typeof document>"u")return;const e=document.createElement("audio");return e.autoplay=!0,e.setAttribute("playsinline",""),e.volume=this.volume,this.sinkId!==void 0&&e.setSinkId(this.sinkId).catch(()=>{}),e}allElements(){const e=[...this.elements.values()];return this.spare&&e.push(this.spare),e}setStream(e,t,i=!1){let s=this.elements.get(e);if(!s){if(s=this.spare??this.createElement(),this.spare=void 0,!s)return;this.elements.set(e,s)}i&&(this.voiceId=e),s.srcObject=t,this.play(e,s).catch(()=>{})}removeStream(e){const t=this.elements.get(e);t&&(t.srcObject=null,t.remove(),this.elements.delete(e)),this.voiceId===e&&(this.voiceId=void 0)}async startAudio(){await Promise.all([...this.elements].map(([e,t])=>this.play(e,t)))}async play(e,t){const i=t.srcObject;await t.play(),e===this.voiceId&&this.elements.get(e)===t&&i!==null&&t.srcObject===i&&this.options.onPlaybackStarted?.()}async setSinkId(e){re(),this.elements.size===0&&(this.spare??(this.spare=this.createElement()));try{await Promise.all(this.allElements().map(t=>t.setSinkId(e)))}catch(t){throw new c("device_change_failed","Could not switch to the requested audio output device",{cause:t})}this.sinkId=e}setVolume(e){this.volume=Math.min(1,Math.max(0,e));for(const t of this.allElements())t.volume=this.volume}getVolume(){return this.volume}dispose(){for(const e of this.allElements())e.srcObject=null,e.remove();this.elements.clear(),this.spare=void 0,this.voiceId=void 0}},ie=class{setStream(e){typeof AudioContext>"u"||(this.context??(this.context=new AudioContext),this.analyser??(this.analyser=this.context.createAnalyser()),this.source?.disconnect(),this.source=this.context.createMediaStreamSource(e),this.source.connect(this.analyser),this.resume())}resume(){this.context?.state==="suspended"&&this.context.resume().catch(()=>{})}getVolume(){if(!this.analyser)return 0;const e=new Uint8Array(this.analyser.fftSize);this.analyser.getByteTimeDomainData(e);let t=0;for(const i of e){const s=(i-128)/128;t+=s*s}return Math.sqrt(t/e.length)}getFrequencyData(){if(!this.analyser)return new Uint8Array(0);const e=new Uint8Array(this.analyser.frequencyBinCount);return this.analyser.getByteFrequencyData(e),e}dispose(){this.source?.disconnect(),this.analyser?.disconnect(),this.context?.close().catch(()=>{}),this.source=void 0,this.analyser=void 0,this.context=void 0}},ae=["connect","disconnect","statusChange","modeChange","userTranscript","agentResponseDelta","agentResponse","message","toolCallStarted","toolCallCompleted","toolCallFailed","error"],Te="1.0.0",oe="https://api.fish.audio",ke=[Ee];function ne(e){const t=e.transport;if(!ke.includes(t))throw new c("unsupported_transport",`Session token uses transport "${t}" which this SDK version does not support; please upgrade @fishaudio/agent-client`);const i=Date.parse(e.expires_at);if(!Number.isNaN(i)&&i<=Date.now())throw new c("session_expired","The session token's join deadline has passed; request a new session");return e}async function Ie(e){if([e.agentId,e.sessionToken].filter(i=>i!==void 0).length!==1)throw new TypeError("Exactly one of `agentId` or `sessionToken` must be provided to start a session");return e.sessionToken?ne(e.sessionToken):ne(await Ae(e))}function Me(){try{return Intl.DateTimeFormat().resolvedOptions().timeZone||void 0}catch{return}}async function Ae(e){const t=(e.serverUrl??oe).replace(/\/$/,""),i=Me(),s=e.language||e.overrides?{...e.language?{language:e.language}:{},...e.overrides}:void 0,r={agent_id:e.agentId,...e.timezone?{timezone:e.timezone}:{},...i?{client_timezone:i}:{},...e.context?.currentTime!==void 0?{context:{current_time:e.context.currentTime}}:e.worldContext!==void 0?{world_context:e.worldContext}:{},...s?{overrides:s}:{},...e.dynamicVariables?{dynamic_variables:e.dynamicVariables}:{},...e.endUserId?{end_user_id:e.endUserId}:{},...e.metadata?{metadata:e.metadata}:{},...e.toolEvents!==void 0?{tool_events:e.toolEvents}:{}};let f;try{f=await fetch(`${t}/v1/agent/sessions`,{method:"POST",headers:{"Content-Type":"application/json","X-Fish-SDK":`agent-client/${Te}`},body:JSON.stringify(r)})}catch(p){throw new c("session_request_failed","Could not reach the session endpoint",{cause:p})}if(!f.ok)throw await Ce(f);return await f.json()}async function Ce(e){let t=`Session request failed with HTTP ${e.status}`,i;try{const r=await e.json();t=r.message??r.error??t,i=r.code}catch{}const s={statusCode:e.status};return e.status===409&&i==="unsupported_transport"?new c("unsupported_transport",`${t}; please upgrade @fishaudio/agent-client`,s):e.status===402?new c("insufficient_credit",t,s):e.status===403?/origin/i.test(t)?new c("origin_forbidden",t,s):new c("agent_not_public",t,s):new c("session_request_failed",t,s)}var Ne=class{constructor(){this.listeners=new Map}on(e,t){let i=this.listeners.get(e);return i||(i=new Set,this.listeners.set(e,i)),i.add(t),this}off(e,t){return this.listeners.get(e)?.delete(t),this}once(e,t){const i=((...s)=>{this.off(e,i),t(...s)});return this.on(e,i)}emit(e,...t){const i=this.listeners.get(e);if(i)for(const s of[...i])try{s(...t)}catch(r){console.error("[fish-agent] listener error",r)}}},Oe=15e3,Y=6e4,be=new TextEncoder,xe=class{constructor(e,t,i,s){this.timeoutMs=t,this.send=i,this.onError=s,this.tools=new Map;for(const[r,f]of Object.entries(e??{}))this.tools.set(r,f)}register(e,t){this.tools.set(e,t)}async dispatch(e){const t=this.tools.get(e.toolName);if(!t){this.onError(new c("tool_failed",`Client tool "${e.toolName}" is not registered`)),e.expectsResponse&&await this.reply(e.callId,{isError:!0,result:"Tool is not registered"});return}try{const i=await this.withTimeout(Promise.resolve(t(e.params,{callId:e.callId,toolName:e.toolName})),e.toolName);e.expectsResponse&&await this.reply(e.callId,i===void 0?{}:{result:i})}catch(i){this.onError(i instanceof c?i:new c("tool_failed",`Client tool "${e.toolName}" threw`,{cause:i})),e.expectsResponse&&await this.reply(e.callId,{isError:!0,result:String(i)})}}async reply(e,t){const i={type:"client_tool.result",callId:e,...t},s=this.undeliverable(i);if(s!==void 0){this.onError(new c("tool_failed",s)),await this.deliver({type:"client_tool.result",callId:e,isError:!0,result:s});return}try{await this.send(i)}catch(r){if(this.onError(new c("tool_failed","Failed to deliver a client tool result",{cause:r})),t.isError)return;await this.deliver({type:"client_tool.result",callId:e,isError:!0,result:`Client tool result could not be delivered: ${String(r)}`})}}undeliverable(e){let t;try{t=JSON.stringify(e)}catch(s){return`Client tool result is not JSON-serializable: ${String(s)}`}const i=be.encode(t).byteLength;if(i>Y)return`Client tool result is too large to send (${i} bytes serialized; limit ${Y}). Return a summary or a reference instead.`}async deliver(e){try{await this.send(e)}catch(t){this.onError(new c("tool_failed","Failed to deliver a client tool error result",{cause:t}))}}withTimeout(e,t){return new Promise((i,s)=>{const r=setTimeout(()=>{s(new c("tool_timeout",`Client tool "${t}" timed out after ${this.timeoutMs}ms`))},this.timeoutMs);e.then(f=>{clearTimeout(r),i(f)},f=>{clearTimeout(r),s(f instanceof Error?f:new Error(String(f)))})})}},A,E,F,V,X,De=class{constructor(){u(this,V),u(this,A),u(this,E,!1),u(this,F,()=>{document.visibilityState==="visible"&&a(this,V,X).call(this)})}acquire(){n(this,E)||typeof document>"u"||typeof navigator>"u"||!navigator.wakeLock||(d(this,E,!0),document.addEventListener("visibilitychange",n(this,F)),a(this,V,X).call(this))}release(){n(this,E)&&(d(this,E,!1),document.removeEventListener("visibilitychange",n(this,F)),n(this,A)?.release().catch(()=>{}),d(this,A,void 0))}};A=new WeakMap;E=new WeakMap;F=new WeakMap;V=new WeakSet;X=async function(){if(n(this,E))try{const e=await navigator.wakeLock.request("screen");if(!n(this,E)){e.release().catch(()=>{});return}const t=n(this,A);d(this,A,e),t&&t!==e&&t.release().catch(()=>{})}catch{}};var Re=15e3,We=1e4,Le=new Set(["user_hangup","agent_hangup","conversation_timeout","escalated","llm_endpoint_failure","internal_error"]),Ue=new Set(["llm","stt","tts","runtime"]);function $e(e,t){const i=e==="provider_error"?"An upstream provider failed during the session":"The agent runtime hit an internal error";return t===!0?`${i}, the agent is retrying this turn`:i}var Pe=new Set(ae);function Fe(e){const t=[];for(const[i,s]of Object.entries(e??{})){if(s===void 0)continue;const r=/^on[A-Z]/.test(i)?i.charAt(2).toLowerCase()+i.slice(3):void 0;if(r===void 0||!Pe.has(r)){const f=ae.map(p=>`on${p.charAt(0).toUpperCase()}${p.slice(1)}`).join(", ");throw new TypeError(`Unknown callback "${i}". Callback keys are event names prefixed with "on": ${f}.`)}if(typeof s!="function")throw new TypeError(`Callback "${i}" must be a function, got ${typeof s}.`);t.push([r,s])}return t}var _,C,z,N,O,R,T,K,S,m,U,g,k,I,H,W,b,j,ee,M,$,w,h,ce,x,le,he,ue,de,L,P,te,Z,fe,ve,D,_e,me,G,pe,ge,B=class q extends Ne{constructor(t){super(),u(this,h),u(this,_,"connecting"),u(this,C,"listening"),u(this,z),u(this,N),u(this,O),u(this,R),u(this,T,!1),u(this,K,!1),u(this,S),u(this,m),u(this,U),u(this,g,new Se({onPlaybackStarted:()=>n(this,m).markAudioReady?.()})),u(this,k,new ie),u(this,I,new ie),u(this,H,new De),u(this,W,new Map),u(this,b,[]),u(this,j,new Map),u(this,ee,0),u(this,M,!1),u(this,$,[]),u(this,w),d(this,R,t.session_id)}static async start(t){var i;const{LiveKitTransport:s}=await we(async()=>{const{LiveKitTransport:r}=await import("./livekit-KT4NEVZO-B3DA1PsD.js");return{LiveKitTransport:r}},__vite__mapDeps([0,1,2]));return a(i=q,x,le).call(i,t,()=>new s)}get sessionId(){return n(this,R)}get status(){return n(this,_)}get mode(){return n(this,C)}get isSpeaking(){return n(this,C)==="speaking"}get micMuted(){return n(this,T)}get endReason(){return n(this,z)}getTranscript(){return n(this,b).map(t=>({...t}))}sendUserMessage(t,i){const s=t.trim();if(!s)return;const r=i?.audio===!0?{type:"user.message",text:s}:{type:"user.message",text:s,audio:!1};n(this,M)?a(this,h,L).call(this,r):n(this,$).push(r),a(this,h,ge).call(this,s)}sendUserActivity(){a(this,h,L).call(this,{type:"user.activity"})}interrupt(){a(this,h,L).call(this,{type:"user.interrupt"})}registerClientTool(t,i){n(this,U).register(t,i)}async setMicMuted(t){var i;const s=n(this,T);d(this,T,t);try{await n(this,m).setMicEnabled(!t)}catch(r){throw d(this,T,s),a(i=q,x,ue).call(i,r)}}async startAudio(){n(this,k).resume(),n(this,I).resume(),await n(this,g).startAudio()}async setInputDevice(t){var i;try{await n(this,m).setInputDevice(t)}catch(s){throw a(i=q,x,de).call(i,s,"Could not switch the microphone")}}async setOutputDevice(t){await n(this,g).setSinkId(t)}setOutputVolume(t){n(this,g).setVolume(t)}getOutputVolume(){return n(this,k).getVolume()}getInputVolume(){return n(this,I).getVolume()}getOutputFrequencyData(){return n(this,k).getFrequencyData()}getInputFrequencyData(){return n(this,I).getFrequencyData()}getRoom(){return n(this,m).getRoom?.()}end(){if(n(this,S))return n(this,S);if(n(this,_)==="ended")return Promise.resolve();const t=a(this,h,ce).call(this);return d(this,S,t),t.catch(()=>{n(this,S)===t&&d(this,S,void 0)}),t}};_=new WeakMap;C=new WeakMap;z=new WeakMap;N=new WeakMap;O=new WeakMap;R=new WeakMap;T=new WeakMap;K=new WeakMap;S=new WeakMap;m=new WeakMap;U=new WeakMap;g=new WeakMap;k=new WeakMap;I=new WeakMap;H=new WeakMap;W=new WeakMap;b=new WeakMap;j=new WeakMap;ee=new WeakMap;M=new WeakMap;$=new WeakMap;w=new WeakMap;h=new WeakSet;ce=async function(){d(this,K,!0);try{await n(this,m).sendClientEvent({type:"user.hangup"})}catch{}await n(this,m).disconnect(),a(this,h,D).call(this,"user_hangup")};x=new WeakSet;le=async function(e,t){var i,s,r;e.audio?.outputDeviceId!==void 0&&re();const f=Fe(e.callbacks),p=t();e.microphone!==!1&&p.prepareMicrophone?.({inputDeviceId:e.audio?.inputDeviceId});let J,o;try{J=await Ie(e),o=new B(J),e.audio?.outputDeviceId!==void 0&&await n(o,g).setSinkId(e.audio.outputDeviceId)}catch(l){throw await p.disconnect().catch(()=>{}),l}for(const[l,v]of f)o.on(l,v);d(o,m,p),e.microphone===!1&&d(o,T,!0),d(o,U,new xe(e.clientTools,e.clientToolTimeoutMs??Oe,l=>p.sendClientEvent(l),l=>o.emit("error",l)));try{await p.connect(J,{inputDeviceId:e.audio?.inputDeviceId,microphone:e.microphone,callbacks:{onAgentEvent:l=>{var v;return a(v=o,h,me).call(v,l)},onAgentReady:()=>{var l;return a(l=o,h,Z).call(l)},onAgentState:l=>{var v,y;a(v=o,h,Z).call(v),l==="thinking"&&a(y=o,h,te).call(y,"thinking")},onTranscription:l=>{var v;return a(v=o,h,pe).call(v,l)},onOutputStream:(l,v,y)=>{n(o,g).setStream(l,v,y),y&&n(o,k).setStream(v)},onOutputStreamEnded:l=>n(o,g).removeStream(l),onInputStream:l=>n(o,I).setStream(l),onConnectionState:(l,v)=>{var y;return a(y=o,h,ve).call(y,l,v)}}})}catch(l){throw await n(o,m).disconnect().catch(()=>{}),a(i=o,h,D).call(i,"connection_lost"),a(s=B,x,he).call(s,l)}return n(o,_)==="connecting"&&(a(r=o,h,P).call(r,"connected"),o.emit("connect",{sessionId:n(o,R)})),n(o,_)!=="ended"&&e.wakeLock!==!1&&n(o,H).acquire(),!n(o,M)&&n(o,_)==="connected"&&d(o,w,setTimeout(()=>{var l;return a(l=o,h,fe).call(l)},Re)),o};he=function(e){return e instanceof c?e:e instanceof Error&&e.name==="NotAllowedError"?new c("mic_permission_denied","Microphone permission was denied",{cause:e}):new c("connection_failed","Could not establish the realtime session",{cause:e})};ue=function(e){return e instanceof c?e:e instanceof Error&&e.name==="NotAllowedError"?new c("mic_permission_denied","Microphone permission was denied",{cause:e}):e instanceof Error&&(e.name==="OverconstrainedError"||e.name==="NotFoundError")?new c("device_change_failed","No usable microphone could be activated",{cause:e}):new c("connection_failed","Could not toggle the microphone",{cause:e})};de=function(e,t){return e instanceof c?e:new c("device_change_failed",t,{cause:e})};L=function(e){n(this,m).sendClientEvent(e).catch(t=>{this.emit("error",new c("connection_failed","Failed to send to the agent",{cause:t}))})};P=function(e){n(this,_)!==e&&(d(this,_,e),this.emit("statusChange",e))};te=function(e){n(this,C)!==e&&(d(this,C,e),this.emit("modeChange",e))};Z=function(){if(n(this,M))return;d(this,M,!0),n(this,w)&&(clearTimeout(n(this,w)),d(this,w,void 0));const e=n(this,$);d(this,$,[]);for(const t of e)a(this,h,L).call(this,t)};fe=function(){n(this,_)==="ended"||n(this,M)||(this.emit("error",new c("connection_failed","The agent did not join the session")),n(this,m).disconnect().catch(()=>{}),a(this,h,D).call(this,"connection_lost"))};ve=function(e,t){if(n(this,_)==="ended")return;if(e==="reconnecting"){a(this,h,P).call(this,"reconnecting");return}if(e==="connected"){n(this,_)==="reconnecting"&&a(this,h,P).call(this,"connected");return}const i=n(this,K)?"user_hangup":n(this,N)??(t==="AGENT_LEFT"||t==="ROOM_DELETED"||t==="ROOM_CLOSED"?"agent_hangup":"connection_lost");a(this,h,D).call(this,i)};D=function(e){n(this,_)!=="ended"&&(n(this,w)&&(clearTimeout(n(this,w)),d(this,w,void 0)),n(this,O)&&(clearTimeout(n(this,O)),d(this,O,void 0)),d(this,z,e),a(this,h,P).call(this,"ended"),n(this,H).release(),n(this,g).dispose(),n(this,k).dispose(),n(this,I).dispose(),this.emit("disconnect",{reason:e}))};_e=function(e){if(n(this,_)==="ended"||n(this,N)!==void 0||!Le.has(e))return;d(this,N,e);const t=n(this,N);d(this,O,setTimeout(()=>{n(this,m).disconnect().catch(()=>{}),a(this,h,D).call(this,t)},We))};me=function(e){switch(e.type){case"client_tool.call":n(this,U).dispatch(e);return;case"tool.started":this.emit("toolCallStarted",{callId:e.callId,toolName:e.toolName,source:e.toolSource,input:e.input,inputTruncated:e.inputTruncated===!0});return;case"tool.completed":this.emit("toolCallCompleted",{callId:e.callId,toolName:e.toolName,source:e.toolSource,output:e.output,outputTruncated:e.outputTruncated===!0});return;case"tool.failed":this.emit("toolCallFailed",{callId:e.callId,toolName:e.toolName,source:e.toolSource,error:e.error,...typeof e.httpStatus=="number"?{httpStatus:e.httpStatus}:{}});return;case"session.ended":a(this,h,_e).call(this,e.reason);return;case"error":{const t=e.code==="provider_error"?"provider_error":"internal_error",i=typeof e.stage=="string"&&Ue.has(e.stage)?e.stage:void 0,s=typeof e.recovered=="boolean"?e.recovered:void 0;this.emit("error",new c(t,$e(t,s),{stage:i,recovered:s}));return}default:return}};G=function(e,t,i,s){const r=`${e}:${t}`,f=n(this,j).get(r);f===void 0?(n(this,j).set(r,n(this,b).length),n(this,b).push({segmentId:t,role:e,text:i,final:s})):n(this,b)[f]={segmentId:t,role:e,text:i,final:s}};pe=function(e){if(e.role==="user"){a(this,h,G).call(this,"user",e.segmentId,e.text,e.final),this.emit("userTranscript",{segmentId:e.segmentId,text:e.text,final:e.final}),e.final&&this.emit("message",{role:"user",text:e.text});return}a(this,h,te).call(this,e.final?"listening":"speaking"),a(this,h,G).call(this,"agent",e.segmentId,e.text,e.final);const t=n(this,W).get(e.segmentId)??"",i=e.text.startsWith(t)?e.text.slice(t.length):e.text;n(this,W).set(e.segmentId,e.text),i&&this.emit("agentResponseDelta",{segmentId:e.segmentId,delta:i,text:e.text}),e.final&&(n(this,W).delete(e.segmentId),this.emit("agentResponse",{segmentId:e.segmentId,text:e.text}),this.emit("message",{role:"agent",text:e.text}))};ge=function(e){const t=`typed_${++ye(this,ee)._}`;a(this,h,G).call(this,"user",t,e,!0),this.emit("userTranscript",{segmentId:t,text:e,final:!0}),this.emit("message",{role:"user",text:e})};u(B,x);var Ve=B;const He=Object.freeze(Object.defineProperty({__proto__:null,AgentSession:Ve,DEFAULT_SERVER_URL:oe,FishAgentError:c,MAX_CLIENT_TOOL_RESULT_BYTES:Y},Symbol.toStringTag,{value:"Module"}));export{ze as A,Ke as C,c as F,Ge as a,je as b,Be as c,He as i};
1
+ const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["assets/livekit-KT4NEVZO-DbFoU2r9.js","assets/styles-3g-ZPS7M.js","assets/styles-CsrDURJH.css"])))=>i.map(i=>d[i]);
2
+ import{_ as we}from"./styles-3g-ZPS7M.js";var se=e=>{throw TypeError(e)},Q=(e,t,i)=>t.has(e)||se("Cannot "+i),n=(e,t,i)=>(Q(e,t,"read from private field"),i?i.call(e):t.get(e)),u=(e,t,i)=>t.has(e)?se("Cannot add the same private member more than once"):t instanceof WeakSet?t.add(e):t.set(e,i),d=(e,t,i,s)=>(Q(e,t,"write to private field"),t.set(e,i),i),a=(e,t,i)=>(Q(e,t,"access private method"),i),ye=(e,t,i,s)=>({set _(r){d(e,t,r)},get _(){return n(e,t,s)}}),c=class extends Error{constructor(e,t,i){super(t,i?.cause!==void 0?{cause:i.cause}:void 0),this.name="FishAgentError",this.code=e,this.statusCode=i?.statusCode,this.stage=i?.stage,this.recovered=i?.recovered}},ze="agent-event",je="client-event",Ge="fish.agent.ready",Be="fish.client.audio_ready",Ke="pending",Ee="livekit";function re(){if(typeof HTMLMediaElement>"u"||!("setSinkId"in HTMLMediaElement.prototype))throw new c("device_change_failed","This browser does not support selecting an audio output device")}var Se=class{constructor(e={}){this.options=e,this.elements=new Map,this.volume=1}createElement(){if(typeof document>"u")return;const e=document.createElement("audio");return e.autoplay=!0,e.setAttribute("playsinline",""),e.volume=this.volume,this.sinkId!==void 0&&e.setSinkId(this.sinkId).catch(()=>{}),e}allElements(){const e=[...this.elements.values()];return this.spare&&e.push(this.spare),e}setStream(e,t,i=!1){let s=this.elements.get(e);if(!s){if(s=this.spare??this.createElement(),this.spare=void 0,!s)return;this.elements.set(e,s)}i&&(this.voiceId=e),s.srcObject=t,this.play(e,s).catch(()=>{})}removeStream(e){const t=this.elements.get(e);t&&(t.srcObject=null,t.remove(),this.elements.delete(e)),this.voiceId===e&&(this.voiceId=void 0)}async startAudio(){await Promise.all([...this.elements].map(([e,t])=>this.play(e,t)))}async play(e,t){const i=t.srcObject;await t.play(),e===this.voiceId&&this.elements.get(e)===t&&i!==null&&t.srcObject===i&&this.options.onPlaybackStarted?.()}async setSinkId(e){re(),this.elements.size===0&&(this.spare??(this.spare=this.createElement()));try{await Promise.all(this.allElements().map(t=>t.setSinkId(e)))}catch(t){throw new c("device_change_failed","Could not switch to the requested audio output device",{cause:t})}this.sinkId=e}setVolume(e){this.volume=Math.min(1,Math.max(0,e));for(const t of this.allElements())t.volume=this.volume}getVolume(){return this.volume}dispose(){for(const e of this.allElements())e.srcObject=null,e.remove();this.elements.clear(),this.spare=void 0,this.voiceId=void 0}},ie=class{setStream(e){typeof AudioContext>"u"||(this.context??(this.context=new AudioContext),this.analyser??(this.analyser=this.context.createAnalyser()),this.source?.disconnect(),this.source=this.context.createMediaStreamSource(e),this.source.connect(this.analyser),this.resume())}resume(){this.context?.state==="suspended"&&this.context.resume().catch(()=>{})}getVolume(){if(!this.analyser)return 0;const e=new Uint8Array(this.analyser.fftSize);this.analyser.getByteTimeDomainData(e);let t=0;for(const i of e){const s=(i-128)/128;t+=s*s}return Math.sqrt(t/e.length)}getFrequencyData(){if(!this.analyser)return new Uint8Array(0);const e=new Uint8Array(this.analyser.frequencyBinCount);return this.analyser.getByteFrequencyData(e),e}dispose(){this.source?.disconnect(),this.analyser?.disconnect(),this.context?.close().catch(()=>{}),this.source=void 0,this.analyser=void 0,this.context=void 0}},ae=["connect","disconnect","statusChange","modeChange","userTranscript","agentResponseDelta","agentResponse","message","toolCallStarted","toolCallCompleted","toolCallFailed","error"],Te="1.0.0",oe="https://api.fish.audio",ke=[Ee];function ne(e){const t=e.transport;if(!ke.includes(t))throw new c("unsupported_transport",`Session token uses transport "${t}" which this SDK version does not support; please upgrade @fishaudio/agent-client`);const i=Date.parse(e.expires_at);if(!Number.isNaN(i)&&i<=Date.now())throw new c("session_expired","The session token's join deadline has passed; request a new session");return e}async function Ie(e){if([e.agentId,e.sessionToken].filter(i=>i!==void 0).length!==1)throw new TypeError("Exactly one of `agentId` or `sessionToken` must be provided to start a session");return e.sessionToken?ne(e.sessionToken):ne(await Ae(e))}function Me(){try{return Intl.DateTimeFormat().resolvedOptions().timeZone||void 0}catch{return}}async function Ae(e){const t=(e.serverUrl??oe).replace(/\/$/,""),i=Me(),s=e.language||e.overrides?{...e.language?{language:e.language}:{},...e.overrides}:void 0,r={agent_id:e.agentId,...e.timezone?{timezone:e.timezone}:{},...i?{client_timezone:i}:{},...e.context?.currentTime!==void 0?{context:{current_time:e.context.currentTime}}:e.worldContext!==void 0?{world_context:e.worldContext}:{},...s?{overrides:s}:{},...e.dynamicVariables?{dynamic_variables:e.dynamicVariables}:{},...e.endUserId?{end_user_id:e.endUserId}:{},...e.metadata?{metadata:e.metadata}:{},...e.toolEvents!==void 0?{tool_events:e.toolEvents}:{}};let f;try{f=await fetch(`${t}/v1/agent/sessions`,{method:"POST",headers:{"Content-Type":"application/json","X-Fish-SDK":`agent-client/${Te}`},body:JSON.stringify(r)})}catch(p){throw new c("session_request_failed","Could not reach the session endpoint",{cause:p})}if(!f.ok)throw await Ce(f);return await f.json()}async function Ce(e){let t=`Session request failed with HTTP ${e.status}`,i;try{const r=await e.json();t=r.message??r.error??t,i=r.code}catch{}const s={statusCode:e.status};return e.status===409&&i==="unsupported_transport"?new c("unsupported_transport",`${t}; please upgrade @fishaudio/agent-client`,s):e.status===402?new c("insufficient_credit",t,s):e.status===403?/origin/i.test(t)?new c("origin_forbidden",t,s):new c("agent_not_public",t,s):new c("session_request_failed",t,s)}var Ne=class{constructor(){this.listeners=new Map}on(e,t){let i=this.listeners.get(e);return i||(i=new Set,this.listeners.set(e,i)),i.add(t),this}off(e,t){return this.listeners.get(e)?.delete(t),this}once(e,t){const i=((...s)=>{this.off(e,i),t(...s)});return this.on(e,i)}emit(e,...t){const i=this.listeners.get(e);if(i)for(const s of[...i])try{s(...t)}catch(r){console.error("[fish-agent] listener error",r)}}},Oe=15e3,Y=6e4,be=new TextEncoder,xe=class{constructor(e,t,i,s){this.timeoutMs=t,this.send=i,this.onError=s,this.tools=new Map;for(const[r,f]of Object.entries(e??{}))this.tools.set(r,f)}register(e,t){this.tools.set(e,t)}async dispatch(e){const t=this.tools.get(e.toolName);if(!t){this.onError(new c("tool_failed",`Client tool "${e.toolName}" is not registered`)),e.expectsResponse&&await this.reply(e.callId,{isError:!0,result:"Tool is not registered"});return}try{const i=await this.withTimeout(Promise.resolve(t(e.params,{callId:e.callId,toolName:e.toolName})),e.toolName);e.expectsResponse&&await this.reply(e.callId,i===void 0?{}:{result:i})}catch(i){this.onError(i instanceof c?i:new c("tool_failed",`Client tool "${e.toolName}" threw`,{cause:i})),e.expectsResponse&&await this.reply(e.callId,{isError:!0,result:String(i)})}}async reply(e,t){const i={type:"client_tool.result",callId:e,...t},s=this.undeliverable(i);if(s!==void 0){this.onError(new c("tool_failed",s)),await this.deliver({type:"client_tool.result",callId:e,isError:!0,result:s});return}try{await this.send(i)}catch(r){if(this.onError(new c("tool_failed","Failed to deliver a client tool result",{cause:r})),t.isError)return;await this.deliver({type:"client_tool.result",callId:e,isError:!0,result:`Client tool result could not be delivered: ${String(r)}`})}}undeliverable(e){let t;try{t=JSON.stringify(e)}catch(s){return`Client tool result is not JSON-serializable: ${String(s)}`}const i=be.encode(t).byteLength;if(i>Y)return`Client tool result is too large to send (${i} bytes serialized; limit ${Y}). Return a summary or a reference instead.`}async deliver(e){try{await this.send(e)}catch(t){this.onError(new c("tool_failed","Failed to deliver a client tool error result",{cause:t}))}}withTimeout(e,t){return new Promise((i,s)=>{const r=setTimeout(()=>{s(new c("tool_timeout",`Client tool "${t}" timed out after ${this.timeoutMs}ms`))},this.timeoutMs);e.then(f=>{clearTimeout(r),i(f)},f=>{clearTimeout(r),s(f instanceof Error?f:new Error(String(f)))})})}},A,E,F,V,X,De=class{constructor(){u(this,V),u(this,A),u(this,E,!1),u(this,F,()=>{document.visibilityState==="visible"&&a(this,V,X).call(this)})}acquire(){n(this,E)||typeof document>"u"||typeof navigator>"u"||!navigator.wakeLock||(d(this,E,!0),document.addEventListener("visibilitychange",n(this,F)),a(this,V,X).call(this))}release(){n(this,E)&&(d(this,E,!1),document.removeEventListener("visibilitychange",n(this,F)),n(this,A)?.release().catch(()=>{}),d(this,A,void 0))}};A=new WeakMap;E=new WeakMap;F=new WeakMap;V=new WeakSet;X=async function(){if(n(this,E))try{const e=await navigator.wakeLock.request("screen");if(!n(this,E)){e.release().catch(()=>{});return}const t=n(this,A);d(this,A,e),t&&t!==e&&t.release().catch(()=>{})}catch{}};var Re=15e3,We=1e4,Le=new Set(["user_hangup","agent_hangup","conversation_timeout","escalated","llm_endpoint_failure","internal_error"]),Ue=new Set(["llm","stt","tts","runtime"]);function $e(e,t){const i=e==="provider_error"?"An upstream provider failed during the session":"The agent runtime hit an internal error";return t===!0?`${i}, the agent is retrying this turn`:i}var Pe=new Set(ae);function Fe(e){const t=[];for(const[i,s]of Object.entries(e??{})){if(s===void 0)continue;const r=/^on[A-Z]/.test(i)?i.charAt(2).toLowerCase()+i.slice(3):void 0;if(r===void 0||!Pe.has(r)){const f=ae.map(p=>`on${p.charAt(0).toUpperCase()}${p.slice(1)}`).join(", ");throw new TypeError(`Unknown callback "${i}". Callback keys are event names prefixed with "on": ${f}.`)}if(typeof s!="function")throw new TypeError(`Callback "${i}" must be a function, got ${typeof s}.`);t.push([r,s])}return t}var _,C,z,N,O,R,T,K,S,m,U,g,k,I,H,W,b,j,ee,M,$,w,h,ce,x,le,he,ue,de,L,P,te,Z,fe,ve,D,_e,me,G,pe,ge,B=class q extends Ne{constructor(t){super(),u(this,h),u(this,_,"connecting"),u(this,C,"listening"),u(this,z),u(this,N),u(this,O),u(this,R),u(this,T,!1),u(this,K,!1),u(this,S),u(this,m),u(this,U),u(this,g,new Se({onPlaybackStarted:()=>n(this,m).markAudioReady?.()})),u(this,k,new ie),u(this,I,new ie),u(this,H,new De),u(this,W,new Map),u(this,b,[]),u(this,j,new Map),u(this,ee,0),u(this,M,!1),u(this,$,[]),u(this,w),d(this,R,t.session_id)}static async start(t){var i;const{LiveKitTransport:s}=await we(async()=>{const{LiveKitTransport:r}=await import("./livekit-KT4NEVZO-DbFoU2r9.js");return{LiveKitTransport:r}},__vite__mapDeps([0,1,2]));return a(i=q,x,le).call(i,t,()=>new s)}get sessionId(){return n(this,R)}get status(){return n(this,_)}get mode(){return n(this,C)}get isSpeaking(){return n(this,C)==="speaking"}get micMuted(){return n(this,T)}get endReason(){return n(this,z)}getTranscript(){return n(this,b).map(t=>({...t}))}sendUserMessage(t,i){const s=t.trim();if(!s)return;const r=i?.audio===!0?{type:"user.message",text:s}:{type:"user.message",text:s,audio:!1};n(this,M)?a(this,h,L).call(this,r):n(this,$).push(r),a(this,h,ge).call(this,s)}sendUserActivity(){a(this,h,L).call(this,{type:"user.activity"})}interrupt(){a(this,h,L).call(this,{type:"user.interrupt"})}registerClientTool(t,i){n(this,U).register(t,i)}async setMicMuted(t){var i;const s=n(this,T);d(this,T,t);try{await n(this,m).setMicEnabled(!t)}catch(r){throw d(this,T,s),a(i=q,x,ue).call(i,r)}}async startAudio(){n(this,k).resume(),n(this,I).resume(),await n(this,g).startAudio()}async setInputDevice(t){var i;try{await n(this,m).setInputDevice(t)}catch(s){throw a(i=q,x,de).call(i,s,"Could not switch the microphone")}}async setOutputDevice(t){await n(this,g).setSinkId(t)}setOutputVolume(t){n(this,g).setVolume(t)}getOutputVolume(){return n(this,k).getVolume()}getInputVolume(){return n(this,I).getVolume()}getOutputFrequencyData(){return n(this,k).getFrequencyData()}getInputFrequencyData(){return n(this,I).getFrequencyData()}getRoom(){return n(this,m).getRoom?.()}end(){if(n(this,S))return n(this,S);if(n(this,_)==="ended")return Promise.resolve();const t=a(this,h,ce).call(this);return d(this,S,t),t.catch(()=>{n(this,S)===t&&d(this,S,void 0)}),t}};_=new WeakMap;C=new WeakMap;z=new WeakMap;N=new WeakMap;O=new WeakMap;R=new WeakMap;T=new WeakMap;K=new WeakMap;S=new WeakMap;m=new WeakMap;U=new WeakMap;g=new WeakMap;k=new WeakMap;I=new WeakMap;H=new WeakMap;W=new WeakMap;b=new WeakMap;j=new WeakMap;ee=new WeakMap;M=new WeakMap;$=new WeakMap;w=new WeakMap;h=new WeakSet;ce=async function(){d(this,K,!0);try{await n(this,m).sendClientEvent({type:"user.hangup"})}catch{}await n(this,m).disconnect(),a(this,h,D).call(this,"user_hangup")};x=new WeakSet;le=async function(e,t){var i,s,r;e.audio?.outputDeviceId!==void 0&&re();const f=Fe(e.callbacks),p=t();e.microphone!==!1&&p.prepareMicrophone?.({inputDeviceId:e.audio?.inputDeviceId});let J,o;try{J=await Ie(e),o=new B(J),e.audio?.outputDeviceId!==void 0&&await n(o,g).setSinkId(e.audio.outputDeviceId)}catch(l){throw await p.disconnect().catch(()=>{}),l}for(const[l,v]of f)o.on(l,v);d(o,m,p),e.microphone===!1&&d(o,T,!0),d(o,U,new xe(e.clientTools,e.clientToolTimeoutMs??Oe,l=>p.sendClientEvent(l),l=>o.emit("error",l)));try{await p.connect(J,{inputDeviceId:e.audio?.inputDeviceId,microphone:e.microphone,callbacks:{onAgentEvent:l=>{var v;return a(v=o,h,me).call(v,l)},onAgentReady:()=>{var l;return a(l=o,h,Z).call(l)},onAgentState:l=>{var v,y;a(v=o,h,Z).call(v),l==="thinking"&&a(y=o,h,te).call(y,"thinking")},onTranscription:l=>{var v;return a(v=o,h,pe).call(v,l)},onOutputStream:(l,v,y)=>{n(o,g).setStream(l,v,y),y&&n(o,k).setStream(v)},onOutputStreamEnded:l=>n(o,g).removeStream(l),onInputStream:l=>n(o,I).setStream(l),onConnectionState:(l,v)=>{var y;return a(y=o,h,ve).call(y,l,v)}}})}catch(l){throw await n(o,m).disconnect().catch(()=>{}),a(i=o,h,D).call(i,"connection_lost"),a(s=B,x,he).call(s,l)}return n(o,_)==="connecting"&&(a(r=o,h,P).call(r,"connected"),o.emit("connect",{sessionId:n(o,R)})),n(o,_)!=="ended"&&e.wakeLock!==!1&&n(o,H).acquire(),!n(o,M)&&n(o,_)==="connected"&&d(o,w,setTimeout(()=>{var l;return a(l=o,h,fe).call(l)},Re)),o};he=function(e){return e instanceof c?e:e instanceof Error&&e.name==="NotAllowedError"?new c("mic_permission_denied","Microphone permission was denied",{cause:e}):new c("connection_failed","Could not establish the realtime session",{cause:e})};ue=function(e){return e instanceof c?e:e instanceof Error&&e.name==="NotAllowedError"?new c("mic_permission_denied","Microphone permission was denied",{cause:e}):e instanceof Error&&(e.name==="OverconstrainedError"||e.name==="NotFoundError")?new c("device_change_failed","No usable microphone could be activated",{cause:e}):new c("connection_failed","Could not toggle the microphone",{cause:e})};de=function(e,t){return e instanceof c?e:new c("device_change_failed",t,{cause:e})};L=function(e){n(this,m).sendClientEvent(e).catch(t=>{this.emit("error",new c("connection_failed","Failed to send to the agent",{cause:t}))})};P=function(e){n(this,_)!==e&&(d(this,_,e),this.emit("statusChange",e))};te=function(e){n(this,C)!==e&&(d(this,C,e),this.emit("modeChange",e))};Z=function(){if(n(this,M))return;d(this,M,!0),n(this,w)&&(clearTimeout(n(this,w)),d(this,w,void 0));const e=n(this,$);d(this,$,[]);for(const t of e)a(this,h,L).call(this,t)};fe=function(){n(this,_)==="ended"||n(this,M)||(this.emit("error",new c("connection_failed","The agent did not join the session")),n(this,m).disconnect().catch(()=>{}),a(this,h,D).call(this,"connection_lost"))};ve=function(e,t){if(n(this,_)==="ended")return;if(e==="reconnecting"){a(this,h,P).call(this,"reconnecting");return}if(e==="connected"){n(this,_)==="reconnecting"&&a(this,h,P).call(this,"connected");return}const i=n(this,K)?"user_hangup":n(this,N)??(t==="AGENT_LEFT"||t==="ROOM_DELETED"||t==="ROOM_CLOSED"?"agent_hangup":"connection_lost");a(this,h,D).call(this,i)};D=function(e){n(this,_)!=="ended"&&(n(this,w)&&(clearTimeout(n(this,w)),d(this,w,void 0)),n(this,O)&&(clearTimeout(n(this,O)),d(this,O,void 0)),d(this,z,e),a(this,h,P).call(this,"ended"),n(this,H).release(),n(this,g).dispose(),n(this,k).dispose(),n(this,I).dispose(),this.emit("disconnect",{reason:e}))};_e=function(e){if(n(this,_)==="ended"||n(this,N)!==void 0||!Le.has(e))return;d(this,N,e);const t=n(this,N);d(this,O,setTimeout(()=>{n(this,m).disconnect().catch(()=>{}),a(this,h,D).call(this,t)},We))};me=function(e){switch(e.type){case"client_tool.call":n(this,U).dispatch(e);return;case"tool.started":this.emit("toolCallStarted",{callId:e.callId,toolName:e.toolName,source:e.toolSource,input:e.input,inputTruncated:e.inputTruncated===!0});return;case"tool.completed":this.emit("toolCallCompleted",{callId:e.callId,toolName:e.toolName,source:e.toolSource,output:e.output,outputTruncated:e.outputTruncated===!0});return;case"tool.failed":this.emit("toolCallFailed",{callId:e.callId,toolName:e.toolName,source:e.toolSource,error:e.error,...typeof e.httpStatus=="number"?{httpStatus:e.httpStatus}:{}});return;case"session.ended":a(this,h,_e).call(this,e.reason);return;case"error":{const t=e.code==="provider_error"?"provider_error":"internal_error",i=typeof e.stage=="string"&&Ue.has(e.stage)?e.stage:void 0,s=typeof e.recovered=="boolean"?e.recovered:void 0;this.emit("error",new c(t,$e(t,s),{stage:i,recovered:s}));return}default:return}};G=function(e,t,i,s){const r=`${e}:${t}`,f=n(this,j).get(r);f===void 0?(n(this,j).set(r,n(this,b).length),n(this,b).push({segmentId:t,role:e,text:i,final:s})):n(this,b)[f]={segmentId:t,role:e,text:i,final:s}};pe=function(e){if(e.role==="user"){a(this,h,G).call(this,"user",e.segmentId,e.text,e.final),this.emit("userTranscript",{segmentId:e.segmentId,text:e.text,final:e.final}),e.final&&this.emit("message",{role:"user",text:e.text});return}a(this,h,te).call(this,e.final?"listening":"speaking"),a(this,h,G).call(this,"agent",e.segmentId,e.text,e.final);const t=n(this,W).get(e.segmentId)??"",i=e.text.startsWith(t)?e.text.slice(t.length):e.text;n(this,W).set(e.segmentId,e.text),i&&this.emit("agentResponseDelta",{segmentId:e.segmentId,delta:i,text:e.text}),e.final&&(n(this,W).delete(e.segmentId),this.emit("agentResponse",{segmentId:e.segmentId,text:e.text}),this.emit("message",{role:"agent",text:e.text}))};ge=function(e){const t=`typed_${++ye(this,ee)._}`;a(this,h,G).call(this,"user",t,e,!0),this.emit("userTranscript",{segmentId:t,text:e,final:!0}),this.emit("message",{role:"user",text:e})};u(B,x);var Ve=B;const He=Object.freeze(Object.defineProperty({__proto__:null,AgentSession:Ve,DEFAULT_SERVER_URL:oe,FishAgentError:c,MAX_CLIENT_TOOL_RESULT_BYTES:Y},Symbol.toStringTag,{value:"Module"}));export{ze as A,Ke as C,c as F,Ge as a,je as b,Be as c,He as i};
@@ -1,3 +1,3 @@
1
- const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["assets/App-BIllYA_e.js","assets/styles-DOJOOIp4.js","assets/styles-9UFSdSaJ.css","assets/PlacesRail-3RaNlpug.js","assets/placement-BKtVnQht.js","assets/monitor-DpsqT1_R.js","assets/MenuMotion-DfjnHTCi.js","assets/DesktopViewer-BoBSIDfB.js","assets/desktop-connection-Df-k5QBM.js","assets/desktop-viewer-CF-OpSo0.js","assets/minimize-msM7mbil.js"])))=>i.map(i=>d[i]);
2
- import{t as s,s as wt,k as I,as as St,m as vt,h as be,at as jt,au as Nt,av as Et,r as u,aw as Ct,F as ye,ax as Te,D as _e,ay as Ae,az as re,aA as Pt,aB as It,j as r,d as Tt,X as _t,a as $,aC as At,aD as Ot,v as K,L as Lt,ae,Q as se,an as Oe,ad as Rt,g as $t,aE as Ht,q as H,aF as Mt,S as qe,b as Dt,E as Ft,G as Bt,H as zt,I as Ut,aG as Wt,aH as Kt,K as Vt,J as Gt,M as Xt,P as Yt,_ as Je}from"./styles-DOJOOIp4.js";function bo(e,t){if(!t)return;if(t.kind!=="session")return t.kind==="loopback"?e:void 0;if(t.team||t.scopes.includes("admin"))return e;const n=t.email;if(n?.trim())return e?.email?.trim().toLowerCase()===n.trim().toLowerCase()?e:{email:n}}const Ze="omb.team-sign-in";function qt(e){try{e&&globalThis.localStorage?.setItem(Ze,e)}catch{}}function Jt(){try{return globalThis.localStorage?.getItem(Ze)??null}catch{return null}}async function ke(e=fetch){let t;try{t=await e("/api/auth/session",{credentials:"same-origin"})}catch(a){return{kind:"unreachable",error:a instanceof Error?a.message:String(a)}}const n=await t.json().catch(()=>({})),o=Object(n);return t.status===401||t.status===403?{kind:"unauthenticated",error:typeof o.error=="string"?o.error:`${t.status}`}:t.ok?o.kind==="session"&&typeof o.id=="string"?{kind:"session",id:o.id,label:typeof o.label=="string"?o.label:"",...typeof o.email=="string"?{email:o.email}:{},scopes:Array.isArray(o.scopes)?o.scopes.filter(a=>typeof a=="string"):[],expiresAt:typeof o.expiresAt=="number"?o.expiresAt:0,...typeof o.reactor=="string"?{reactor:o.reactor}:{},...typeof o.teamSignIn=="string"?{teamSignIn:o.teamSignIn}:{},...Le(o.team)?{team:Le(o.team),openedThreads:Array.isArray(o.openedThreads)?o.openedThreads.filter(a=>typeof a=="string"):[]}:{},...o.cloudGuest===!0?{cloudGuest:!0,openedThreads:Array.isArray(o.openedThreads)?o.openedThreads.filter(a=>typeof a=="string"):[]}:{}}:o.trust==="service"?{kind:"loopback",trust:"service"}:{kind:"loopback"}:{kind:"unreachable",error:`${t.status} ${t.statusText}`}}function Le(e){const t=Object(e);return typeof t.id=="string"&&typeof t.name=="string"&&typeof t.role=="string"?{id:t.id,name:t.name,role:t.role}:null}function Zt(e){return e?.kind==="session"||e?.kind==="loopback"&&e.trust!=="service"}function yo(e){return e?e.kind==="loopback"?e.trust!=="service":e.kind==="session"&&e.scopes.includes("admin"):!1}function Qt(){const e=/[#&]code=([^&]+)/.exec(location.hash);return e?(history.replaceState(null,"",location.pathname+location.search),decodeURIComponent(e[1])):null}function en(){if(!/[#&]signin=/.test(location.hash))return null;const e=/[#&]signin=(omb_pair_[A-Za-z0-9_-]{43})(?:&|$)/.exec(location.hash);return history.replaceState(null,"",location.pathname+location.search),e?e[1]:null}function tn(){const e=new URLSearchParams(location.search),t=e.get("email")?.trim().toLowerCase()??"";if(!t)return null;e.delete("email");const n=e.toString();return history.replaceState(null,"",location.pathname+(n?`?${n}`:"")+location.hash),/^[^@\s]+@[^@\s]+\.[^@\s]+$/.test(t)?t:null}function Qe(e=navigator.userAgent){const t=/Edg\//.test(e)?"Edge":/OPR\//.test(e)?"Opera":/Chrome\//.test(e)?"Chrome":/Firefox\//.test(e)?"Firefox":/Safari\//.test(e)?"Safari":"Browser",n=/iPhone/.test(e)?"iPhone":/iPad/.test(e)?"iPad":/Android/.test(e)?"Android":/Mac OS X/.test(e)?"Mac":/Windows/.test(e)?"Windows":/Linux/.test(e)?"Linux":"";return n?`${t} on ${n}`:t}function Z(){return typeof crypto?.randomUUID=="function"?crypto.randomUUID():`${Date.now().toString(36)}-${Math.random().toString(36).slice(2,14)}`}function et(e,t){const n=Reflect.get(Object(e),"error");return wt(e,typeof n=="string"?n:`${t.status} ${t.statusText}`)}async function ue(e,t=fetch){let n;try{n=await t("/api/auth/pair",{method:"POST",credentials:"same-origin",headers:{"content-type":"application/json"},body:JSON.stringify({code:e.code,label:e.label,cookie:!0,attemptId:e.attemptId??Z(),...e.browser?{browser:!0}:{}})})}catch(a){return{ok:!1,error:s("pair.unreachable",{error:a instanceof Error?a.message:String(a)})}}const o=await n.json().catch(()=>({}));return n.ok?{ok:!0}:{ok:!1,error:et(o,n)}}async function nn(e,t=fetch){try{const n=await t("/api/auth/pair",{method:"POST",credentials:"same-origin",headers:{"content-type":"application/json"},body:JSON.stringify({code:e,browser:!0,preview:!0})}),o=Object(await n.json().catch(()=>({}))),a=Reflect.get(o,"owner"),i=Reflect.get(o,"team");return n.ok&&typeof a=="string"&&a?{owner:a,...typeof i=="string"&&i.trim()?{team:i.trim()}:{}}:null}catch{return null}}function on(e,t,n=fetch){return ue({code:e,label:Qe(),attemptId:t,browser:!0},n)}function ko(e){const t=Object(e);return t.cloudHome===!0&&typeof t.owner=="string"&&t.owner?t.owner:null}async function tt(e,t,n){let o;try{o=await n(e,{method:"POST",credentials:"same-origin",headers:{"content-type":"application/json"},body:JSON.stringify(t)})}catch(i){return{ok:!1,error:s("pair.unreachable",{error:i instanceof Error?i.message:String(i)})}}const a=await o.json().catch(()=>({}));return o.ok?{ok:!0}:{ok:!1,error:et(a,o)}}function rn(e,t=fetch){return tt("/api/auth/email/start",{email:e},t)}function an(e,t=fetch){return tt("/api/auth/email/verify",{email:e.email,code:e.code,label:e.label},t)}function Re(e){return!e||/through a proxy|loopback host required|cross-origin request|^40[13]$/i.test(e)?null:e}function sn(){window.ogb?.softwareRendering===!0&&(document.documentElement.dataset.softwareRendering="")}const ln="/api/theme-assets/",cn="safe-look",nt={cssChars:1e5,assetBytes:10*1024*1024},un=/^[a-z0-9][a-z0-9-]{0,47}$/,dn=/^[a-z0-9][a-z0-9_-]{0,79}\.(png|jpe?g|webp|gif|avif|svg|woff2?|ttf|otf)$/,mn=/^\/api\/theme-assets\/[a-z0-9][a-z0-9-]{0,47}\/[a-z0-9][a-z0-9_-]{0,79}\.[a-z0-9]{2,5}$/,ot=["app","panel","frame","raised","raised-hover","card","inset","control","composer","composer-ring","menu","menu-hover","menu-active","hairline","edge","scrollbar","ink","ink-secondary","ink-tertiary","accent","accent-border","accent-text","accent-ink","focus","bubble-user","bubble-user-ink","success","success-ink","danger","danger-ink","warning"],Q=I().trim().regex(/^#(?:[0-9a-f]{3}|[0-9a-f]{6})$/i,"a hex colour such as #1a2b3c"),pn=I().trim().min(1).max(120).regex(/^[#a-z0-9(),.%\s/+-]+$/i,"a CSS colour such as #1a2b3c, rgb(…) or color-mix(…)").refine(e=>!/url|image|src|attr/i.test(e),"a colour, not a file"),rt=St(vt(ot),pn),$e=be({canvas:Q.optional(),accent:Q.optional(),colors:rt.optional()}).strict(),we=be({name:I().trim().min(1).max(60),skin:jt.optional(),canvas:Q.optional(),accent:Q.optional(),colors:rt.optional(),light:$e.optional(),dark:$e.optional(),font:I().trim().max(300).regex(/^[\w\s"',.-]*$/,'a font-family list such as "Inter Variable", serif').optional(),css:I().max(nt.cssChars).optional()}).strict(),fn=1;be({mausbotTheme:Et(fn),id:I().regex(un).optional(),theme:we,assets:Nt(I().regex(dn),I().max(Math.ceil(nt.assetBytes*1.4)).regex(/^data:[\w/+.-]+;base64,[A-Za-z0-9+/=]+$/)).optional()}).strict();function at(e){return/^data:/i.test(e)||e.startsWith("#")||mn.test(e)&&!e.includes("..")}function st(e){const t=e.toLowerCase(),n=[];for(let o=t.indexOf("url(");o!==-1;o=t.indexOf("url(",o+4)){let a=o+4;for(;/\s/.test(e[a]??"");)a++;const i=e[a];let c;if(i==='"'||i==="'"){const l=e.indexOf(i,a+1);if(l===-1)return null;for(c=e.slice(a+1,l),a=l+1;/\s/.test(e[a]??"");)a++;if(e[a]!==")")return null}else{const l=e.indexOf(")",a);if(l===-1||(c=e.slice(a,l).trim(),/[\s"'(]/.test(c)))return null}n.push(c.trim())}return n}const it=/image-set\(|\bimage\(|\bsrc\(/i;function lt(e){if(e.includes("\\")||it.test(e))return!0;const t=st(e);return t===null||t.some(n=>!at(n))}function hn(e){let t="";for(let n=0;n<e.length;n++){const o=e[n];if(o==="/"&&e[n+1]==="*"){const a=e.indexOf("*/",n+2);n=a===-1?e.length:a+1,t+=" "}else if(o==='"'||o==="'"){let a=n+1;for(;a<e.length&&e[a]!==o&&e[a]!==`
3
- `;)a+=e[a]==="\\"?2:1;t+=`${o}${" ".repeat(Math.max(0,a-n-1))}${o}`,n=a}else t+=o}return t}function wo(e){const t=hn(e);if(/@import/i.test(t))return"@import is not allowed: themes cannot load other stylesheets.";if(t.includes("\\"))return"Backslash escapes are only allowed inside quoted strings.";if(it.test(t))return"image-set(), image() and src() are not allowed: use url() with a theme file or a data: address.";const n=e.replace(/\/\*[\s\S]*?\*\//g," "),o=st(n);if(o===null)return'A url() could not be read. Write url("/api/theme-assets/<theme>/<file>").';const a=o.find(i=>!at(i));return a!==void 0?`url(${a.slice(0,80)}) is not allowed: themes load only their own files (${ln}<theme>/<file>), data: addresses or #ids, never the internet.`:null}function de(e=typeof document>"u"?null:document.documentElement){if(!e||typeof window>"u"||typeof window.getComputedStyle!="function")return"dark";try{return window.getComputedStyle(e).getPropertyValue("--code-color-scheme").trim()==="light"?"light":"dark"}catch{return"dark"}}function So(){const[e,t]=u.useState(()=>de());return u.useEffect(()=>{const n=()=>t(de());if(n(),typeof MutationObserver>"u")return;const o=new MutationObserver(n);return o.observe(document.documentElement,{attributes:!0,attributeFilter:["data-skin"]}),()=>o.disconnect()},[]),e}const N=[255,255,255],P=[0,0,0];function ee(e){const t=e.trim().replace(/^#/,""),n=t.length===3?[...t].map(a=>a+a).join(""):t,o=Number.parseInt(n.slice(0,6),16);return Number.isFinite(o)?[o>>16&255,o>>8&255,o&255]:P}const V=e=>Math.round(Math.min(255,Math.max(0,e))).toString(16).padStart(2,"0"),m=([e,t,n],o)=>`#${V(e)}${V(t)}${V(n)}${o===void 0?"":V(o*255)}`,S=(e,t,n)=>[0,1,2].map(o=>e[o]+(t[o]-e[o])*n);function te([e,t,n]){const o=a=>{const i=a/255;return i<=.03928?i/12.92:((i+.055)/1.055)**2.4};return .2126*o(e)+.7152*o(t)+.0722*o(n)}function me(e,t){const[n,o]=[te(e),te(t)].sort((a,i)=>i-a);return(n+.05)/(o+.05)}const He=e=>te(ee(e))<.2?"dark":"light";function X(e,t,n){const o=te(t)<.2?N:P;let a=e;for(let i=1;i<=20&&me(a,t)<n;i++)a=S(e,o,i/20);return a}const ct=e=>me(N,e)>=me(P,e)?N:[17,17,17];function xn(e,t){const n=ee(e),o=t==="dark",a=f=>S(n,o?N:P,f),i=o?a(.08):S(n,N,.85),c=a(o?.14:.06),l=X(S(o?N:P,n,o?.04:.1),n,12),x=a(o?.22:.07);return{app:m(n),panel:m(o?S(n,P,.25):S(n,N,.45)),frame:m(o?S(n,P,.25):S(n,N,.45)),raised:m(i),"raised-hover":m(c),card:m(o?a(.07):i),inset:m(o?a(.04):n),control:m(a(o?.12:.07)),composer:m(o?a(.07):i),"composer-ring":m(a(o?.14:.12)),menu:m(i),"menu-hover":m(l,.06),"menu-active":m(l,.09),hairline:m(a(.2)),edge:m(l,.08),scrollbar:m(a(o?.25:.22)),ink:m(l),"ink-secondary":m(X(S(l,n,o?.3:.4),c,4.5)),"ink-tertiary":m(X(S(l,n,o?.42:.5),c,4.5)),"bubble-user":m(x),"bubble-user-ink":m(o?ct(x):l)}}function gn(e,t,n){const o=ee(e),a=X(o,ee(n),4.5);return{accent:m(o),"accent-ink":m(ct(o)),"accent-border":m(t==="dark"?S(o,N,.2):S(o,P,.1)),"accent-text":m(a),focus:m(a)}}class bn extends Error{}function Y(e,t){const n=globalThis[t];return typeof n=="function"&&e instanceof n}function Me(e){const t=e.style;return t&&typeof t=="object"&&typeof t.getPropertyValue=="function"?t:null}function De(e){for(let t=e.length-1;t>=0;t--){const n=e.item(t);lt(e.getPropertyValue(n))&&e.removeProperty(n)}}const yn=e=>"cssRules"in e&&typeof e.deleteRule=="function";function Fe(e,t,n){try{e.deleteRule(t)}catch{if(!Y(n,"CSSNamespaceRule"))throw new bn}}function ut(e){for(let t=e.cssRules.length-1;t>=0;t--){const n=e.cssRules[t];if(!n)continue;if(Y(n,"CSSKeyframesRule")){for(const a of Array.from(n.cssRules)){const i=Me(a);i&&De(i)}continue}if(Y(n,"CSSPropertyRule")){lt(n.initialValue??"")&&Fe(e,t,n);continue}const o=Me(n);o&&De(o),yn(n)?ut(n):!o&&!Y(n,"CSSLayerStatementRule")&&Fe(e,t,n)}}let R=null,Be="";function ze(e){if(!(typeof document>"u"||typeof CSSStyleSheet>"u"||!("adoptedStyleSheets"in document))&&e!==Be){Be=e,R||(R=new CSSStyleSheet,document.adoptedStyleSheets=[...document.adoptedStyleSheets,R]);try{R.replaceSync(e),ut(R)}catch{R.replaceSync("")}}}const pe="omb-theme",Ue="omb-safe-look";let A=null,z=[],ie=!1;const fe=new Set;function U(e){try{return typeof window>"u"?void 0:window[e]}catch{return}}function kn(){try{return typeof location<"u"&&new URLSearchParams(location.search).has(cn)&&U("sessionStorage")?.setItem(Ue,"1"),U("sessionStorage")?.getItem(Ue)==="1"}catch{return!1}}function vo(){return A}function jo(e){return fe.add(e),()=>{fe.delete(e)}}function wn(e){for(const t of z)e.style.removeProperty(t);z=[]}function q(){if(!(typeof document>"u"||ie)){ie=!0;try{const e=document.documentElement;wn(e);const t=kn()?null:A?.theme;if(!t){delete e.dataset.theme,ze(""),_e(Ae());return}const n=!t.skin||t.skin==="system"||t.skin===re.light||t.skin===re.dark,a=!!(t.light&&t.dark)&&n?void 0:t.skin??(t.canvas?re[He(t.canvas)]:void 0);_e(a?Pt(a):Ae());const i=de(e),c=t[i],l=c?.canvas??(t.canvas&&He(t.canvas)===i?t.canvas:void 0),x=c?.accent??t.accent,f={...l?xn(l,i):{},...x?gn(x,i,l??(i==="dark"?"#121212":"#ffffff")):{},...t.colors,...c?.colors};for(const b of ot){const d=f[b];d&&(e.style.setProperty(`--color-${b}`,d),z.push(`--color-${b}`))}l&&(e.style.setProperty("--code-color-scheme",i),z.push("--code-color-scheme")),t.font&&(e.style.setProperty("--font-sans",t.font),z.push("--font-sans")),e.dataset.theme=A.id,ze(t.css??"")}finally{ie=!1;for(const e of fe)e()}}}function Se(e){A=e;try{e?U("localStorage")?.setItem(pe,JSON.stringify(e)):U("localStorage")?.removeItem(pe)}catch{}q()}function Sn(){try{const e=JSON.parse(U("localStorage")?.getItem(pe)??"null"),t=we.safeParse(e?.theme);return typeof e?.id=="string"&&t.success?{id:e.id,theme:t.data}:null}catch{return null}}async function ve(){try{const e=await fetch("/api/themes/active",{headers:{accept:"application/json"}});if(!e.ok)return;const t=await e.json(),n=t.theme?we.safeParse(t.theme):null;Se(t.id&&n?.success?{id:t.id,theme:n.data}:null)}catch{}}function No(e){const t=e.skin;(t==="system"||It.includes(t))&&ye(t),ve()}const je=(e,t)=>fetch("/api/themes/active",{method:"PUT",headers:{"content-type":"application/json"},body:JSON.stringify({id:e,...t?{skin:t}:{}})}).then(n=>n.ok,()=>!1);function Eo(){A&&(Se(null),je(null))}async function Co(e){const t=await je(e);return t&&await ve(),t}function vn(){ye(Te),Se(null),je(null,Te)}const jn=e=>e.code==="KeyR"&&e.altKey&&e.shiftKey&&(e.metaKey||e.ctrlKey);function Nn(){if(!(typeof window>"u")){if(window.addEventListener("keydown",e=>{jn(e)&&(e.preventDefault(),e.stopPropagation(),vn())},{capture:!0}),Ct(q),typeof matchMedia=="function")try{matchMedia("(prefers-color-scheme: dark)").addEventListener("change",q)}catch{}A=Sn(),A&&q()}}function En({credential:e,owner:t,team:n}){const[o]=u.useState(()=>Z()),[a,i]=u.useState(!1),[c,l]=u.useState(null);async function x(){i(!0),l(null);const f=await on(e,o);if(f.ok){location.replace("/");return}i(!1),l(f.error)}return r.jsx("main",{className:"flex min-h-screen items-center justify-center bg-app px-6 text-ink",children:r.jsxs("div",{className:"w-full max-w-[420px]",children:[r.jsx("h1",{className:"text-[20px] font-semibold",children:n?s("pair.browser.teamTitle",{team:n,owner:t}):s("pair.browser.title",{owner:t})}),r.jsx("p",{className:"mt-1.5 text-[14px] text-ink-secondary",children:s("pair.browser.notYou")}),c?r.jsx("p",{role:"alert",className:"mt-3 text-[13px] text-danger",children:c}):null,r.jsx("button",{type:"button",onClick:()=>{x()},disabled:a,className:"mt-5 w-full rounded-md bg-accent px-4 py-2 text-[14px] font-medium text-accent-ink disabled:opacity-50",children:s(a?"pair.signingIn":"pair.continue")})]})})}const Ne="bg-composer ring-1 ring-inset ring-ink/[0.07]",Cn="bg-composer ring-[0.5px] ring-ink/10",Po=`${Cn} shadow-(--shadow-float)`,dt="transition-colors duration-[120ms] hover:bg-[color-mix(in_srgb,var(--color-composer),var(--color-ink)_7%)]",Pn=`${dt} aria-expanded:bg-[color-mix(in_srgb,var(--color-composer),var(--color-ink)_7%)]`,Io="bg-[color-mix(in_srgb,var(--color-composer),var(--color-ink)_7%)]",To="focus-visible:outline-2 focus-visible:-outline-offset-2! focus-visible:outline-focus",mt="flex size-9 shrink-0 items-center justify-center rounded-full text-ink/90",pt="focus-visible:outline focus-visible:outline-2 focus-visible:outline-offset-2 focus-visible:outline-focus",_o=`${mt} ${Ne} ${Pn} ${pt}`,Ao=`${mt} ${Ne} ${dt} ${pt}`,Oo="flex size-10 shrink-0 items-center justify-center rounded-full border border-hairline bg-card text-ink hover:bg-raised focus-visible:outline focus-visible:outline-2 focus-visible:outline-offset-2 focus-visible:outline-focus",In="flex size-9 shrink-0 items-center justify-center rounded-xl text-ink-secondary hover:bg-raised/60 hover:text-ink focus-visible:outline focus-visible:outline-2 focus-visible:outline-offset-2 focus-visible:outline-focus";function Lo({query:e,onQuery:t,onClose:n}){return r.jsx("div",{"data-sidebar-search-pill":!0,className:"px-3 pb-2 pt-0.5",children:r.jsxs("div",{className:$("flex h-[34px] items-center gap-2 rounded-full pl-3 pr-1.5 text-ink-secondary focus-within:ring-focus",Ne),children:[r.jsx(Tt,{size:15,"aria-hidden":"true",className:"shrink-0"}),r.jsx("input",{autoFocus:!0,value:e,onChange:o=>t(o.target.value),onKeyDown:o=>{o.key==="Escape"&&(o.preventDefault(),n())},placeholder:s("sidebar.searchAria"),"aria-label":s("sidebar.searchAria"),className:"min-w-0 flex-1 bg-transparent text-[13px] text-ink placeholder:text-ink-tertiary focus:outline-none"}),r.jsx("button",{type:"button",onClick:n,"aria-label":s("sidebar.searchClose"),title:s("sidebar.searchClose"),className:"flex size-6 shrink-0 items-center justify-center rounded-full text-ink-tertiary hover:bg-raised hover:text-ink focus-visible:outline focus-visible:outline-2 focus-visible:outline-focus",children:r.jsx(_t,{size:14,"aria-hidden":"true"})})]})})}function Tn(e,{howTo:t=!1,onClosed:n}={}){return e.menu(t?{from:"howto"}:void 0).finally(()=>{t&&n?.()})}function Ro(e){Rt("cloud_howto",{result:"closed"}),e({type:"cloudHowTo",open:!1})}function We({text:e}){return r.jsxs("span",{className:"font-normal text-ink-secondary",children:[" · ",e]})}function _n(e){return e?.sleeps===!0?!0:e?.status==="paid"?!1:null}function An(e){const t=e&&!window.ogb?.remoteClient?.active?window.ogb?.cloudPlan:void 0,n=e||window.ogb?.remoteClient?.active?void 0:window.ogb?.cloudAccount,[o,a]=u.useState(null),[i,c]=u.useState(!1);return u.useEffect(()=>{if(!t)return;let l=!0;return t.state().then(x=>{l&&a(_n(x))}).catch(()=>{}),()=>{l=!1}},[t]),u.useEffect(()=>n?.onState(l=>c(l.waking===!0)),[n]),{sleeps:t?o:null,waking:i}}function On({cloudHome:e=!1,howTo:t=!1,onMenuClosed:n}){const o=window.ogb?.workspaces,[a,i]=u.useState(null),[c,l]=u.useState(!1),[x,f]=u.useState("");u.useEffect(()=>{let p=!0;const w=()=>{o?.state().then(E=>{p&&i(E)}).catch(()=>{})};w();const T=o?.onChanged?.(w);return()=>{p=!1,T?.()}},[o]);const b=An(e||a?.home===!0),d=b.sleeps===null?"":s(b.sleeps?"cloudSetup.sleepsWhenIdle":"cloudSetup.alwaysOn"),y=b.waking?s("cloudHome.waking"):"";return{bridge:o,current:a,cloudHome:e,open:c,error:x,onLine:d,waking:y,openMenu:()=>{!o||c||(f(""),l(!0),Tn(o,{howTo:t,onClosed:n}).catch(()=>f(s("sidebar.switchServerError"))).finally(()=>l(!1)))},switchable:!!o&&a?.home!==!0}}function Ln(e){const t=At(),n=r.jsx(Rn,{...e});return Ot(t)?r.jsx("div",{"data-switcher-beside-rail":!0,className:t.beside?"hidden":"contents md:hidden",children:n}):n}function Rn({compact:e=!1,inline:t=!1,pill:n=!1,rail:o=!1,cloudHome:a=!1,owner:i=null,howTo:c=!1,place:l,onMenuClosed:x}){const f=l||s("cloudSetup.myCloud"),{bridge:b,current:d,open:y,error:k,onLine:p,waking:w,openMenu:T}=On({cloudHome:a,howTo:c,onMenuClosed:x}),E=g=>p?`${g} · ${p}`:g;if(!b||d?.home===!0){if(!a&&!d?.home)return null;const g=i?s("sidebar.cloudOwner",{email:i}):"",j=`${E(f)}${g?` · ${g}`:""}`;return o?r.jsx("div",{"data-cloud-home-indicator":!0,"data-workspace-switcher":"rail",role:"img","aria-label":j,title:j,className:"flex size-9 items-center justify-center text-ink-secondary",children:r.jsx(K,{size:18,"aria-hidden":"true"})}):t?r.jsxs("div",{"data-cloud-home-indicator":!0,"data-workspace-switcher":"inline",title:j,className:n?"flex h-8 min-w-0 items-center gap-1 rounded-full bg-raised/50 px-3 text-[13px] font-medium text-ink":"flex min-w-0 items-center gap-1.5 px-1.5 text-[13px] font-medium text-ink",children:[r.jsx(K,{size:n?15:14,"aria-hidden":"true",className:n?"hidden shrink-0 text-ink-secondary @max-[124px]/sidebar-top:block":"shrink-0 text-ink-secondary"}),r.jsx("span",{className:n?"min-w-0 truncate @max-[124px]/sidebar-top:hidden":"min-w-0 truncate",children:f}),(p||g)&&r.jsxs("span",{className:"sr-only",children:[p?` · ${p}`:"",g?` · ${g}`:""]})]}):r.jsx("div",{"data-cloud-home-indicator":!0,className:$("py-1.5",e?"px-2":"px-3"),children:r.jsxs("div",{title:j,className:$("flex items-center gap-2 py-2 text-[13px] font-medium text-ink",e?"justify-center px-1":"px-2"),children:[r.jsx(K,{size:16,"aria-hidden":"true",className:"shrink-0 text-ink-secondary"}),e?r.jsx("span",{className:"sr-only",children:j}):r.jsxs("span",{className:"min-w-0 flex-1 truncate",children:[f,p&&r.jsx(We,{text:p}),g&&r.jsx("span",{className:"block truncate text-[12px] font-normal text-ink-secondary",children:g})]})]})})}const O=d?.profileName??(d?.local&&!d.localPath?s("place.local"):d?.name)??(a?f:s("sidebar.servers")),v=d?.local===!1||a&&!d?K:Lt,M=a?E(O):O,_=d?.origin?`${M} · ${d.origin}`:M,L=s("sidebar.switchServer",{name:M});return o?r.jsxs("div",{"data-workspace-switcher":"rail",className:"relative",children:[r.jsx("button",{type:"button","aria-label":L,"aria-haspopup":"menu","aria-expanded":y,"data-cloud-home-indicator":a||void 0,"data-tour":"server-switcher",title:_,onClick:T,className:$(In,"aria-expanded:bg-raised"),style:{WebkitAppRegion:"no-drag"},children:ae(d?.color)?r.jsx(se,{color:d?.color,size:18}):r.jsx(v,{size:18,"aria-hidden":"true"})}),k&&r.jsx("p",{role:"alert",className:"absolute bottom-0 left-full z-40 ml-2 w-56 rounded-md bg-menu px-2 py-1 text-[11px] text-danger shadow-lg",children:k}),w&&!k&&r.jsx("p",{role:"status","data-cloud-waking":!0,className:"absolute bottom-0 left-full z-40 ml-2 w-56 rounded-md bg-menu px-2 py-1 text-[11px] text-ink-secondary shadow-lg",children:w})]}):t?r.jsxs("div",{"data-workspace-switcher":"inline",className:"flex min-w-0",children:[r.jsxs("button",{type:"button","aria-label":L,"aria-haspopup":"menu","aria-expanded":y,"data-cloud-home-indicator":a||void 0,"data-tour":"server-switcher",title:_,onClick:T,className:n?"flex h-8 min-w-0 max-w-full items-center gap-1 overflow-hidden rounded-full bg-raised/50 pl-2.5 pr-1.5 text-left text-[13px] font-medium text-ink hover:bg-raised aria-expanded:bg-raised focus-visible:outline focus-visible:outline-2 focus-visible:outline-offset-2 focus-visible:outline-focus":"flex h-7 min-w-0 max-w-full items-center gap-1.5 overflow-hidden rounded-md px-1.5 text-left text-[13px] font-medium text-ink hover:bg-control focus-visible:outline focus-visible:outline-2 focus-visible:outline-offset-2 focus-visible:outline-focus",style:{WebkitAppRegion:"no-drag"},children:[ae(d?.color)?r.jsx(se,{color:d?.color,size:16}):r.jsx(v,{size:n?15:14,"aria-hidden":"true","data-switcher-icon":!0,className:n?"hidden shrink-0 text-ink-secondary @max-[124px]/sidebar-top:block":"shrink-0 text-ink-secondary"}),r.jsx("span",{className:n?"min-w-0 truncate @max-[124px]/sidebar-top:hidden":"min-w-0 truncate @max-[96px]/sidebar-top:hidden",children:O}),r.jsx(Oe,{size:n?12:11,"aria-hidden":"true",className:n?"shrink-0 text-ink-tertiary":"shrink-0 text-ink-secondary"})]}),k&&r.jsx("p",{role:"alert",className:"absolute right-2 top-full z-40 mt-1 w-56 max-w-[calc(100%-1rem)] rounded-md bg-menu px-2 py-1 text-[11px] text-danger shadow-lg",children:k}),w&&!k&&r.jsx("p",{role:"status","data-cloud-waking":!0,className:"absolute right-2 top-full z-40 mt-1 w-56 max-w-[calc(100%-1rem)] rounded-md bg-menu px-2 py-1 text-[11px] text-ink-secondary shadow-lg",children:w})]}):r.jsxs("div",{className:$("py-1.5",e?"px-2":"px-3"),children:[r.jsxs("button",{type:"button","aria-label":L,"aria-haspopup":"menu","aria-expanded":y,"data-cloud-home-indicator":a||void 0,"data-tour":"server-switcher",title:_,onClick:T,className:$("flex w-full items-center gap-2 rounded-lg py-2 text-left text-[13px] font-medium text-ink hover:bg-control focus-visible:outline focus-visible:outline-2 focus-visible:outline-offset-2 focus-visible:outline-focus",e?"justify-center px-1":"px-2"),style:{WebkitAppRegion:"no-drag"},children:[ae(d?.color)?r.jsx(se,{color:d?.color,size:20}):r.jsx(v,{size:16,className:"shrink-0 text-ink-secondary"}),!e&&r.jsxs(r.Fragment,{children:[r.jsxs("span",{className:"min-w-0 flex-1 truncate",children:[O,a&&p&&r.jsx(We,{text:p})]}),r.jsx(Oe,{size:13,className:"shrink-0 text-ink-secondary"})]})]}),k&&r.jsx("p",{role:"alert",className:"mt-1 text-[11px] text-danger",children:k}),w&&!k&&r.jsx("p",{role:"status","data-cloud-waking":!0,className:"mt-1 text-[11px] text-ink-secondary",children:w})]})}function $n(e,t,n="start",o=0){const a=t.getBoundingClientRect().top-e.getBoundingClientRect().top+e.scrollTop;e.scrollTop=Math.max(0,n==="center"?a-(e.clientHeight-(t.offsetHeight??0))/2:a-o)}function $o(e){for(let t=e.parentElement;t;t=t.parentElement){const n=getComputedStyle(t).overflowY;if((n==="auto"||n==="scroll")&&t.scrollHeight>t.clientHeight)return t}return null}const Ho=()=>({type:"toggleAppSettings",open:!0,section:"phone",phonePairing:!0});function Mo(e){return $t(e).kind!=="paid"||Ht(e)?null:e?.status==="connected"&&e.machine?.status==="ready"?"ready":"not-ready"}const Hn="data-phone-pairing-action";function Do(e,t=n=>window.requestAnimationFrame(n)){return e?(t(()=>{const n=e.closest?.("[data-settings-scroll]");n&&$n(n,e,"start",(n.querySelector("[data-settings-header]")?.offsetHeight??96)+8),(e.querySelector(`[${Hn}]:not([disabled])`)??e).focus({preventScroll:!0})}),!0):!1}let he=!1;function Fo(e,t=typeof window<"u"&&!!window.ogb){const n=new URL(e);return n.searchParams.get("desktop-settings")!=="phone"?null:(he=t&&n.searchParams.get("pair")==="open",n.searchParams.delete("desktop-settings"),n.searchParams.delete("pair"),`${n.pathname}${n.search}${n.hash}`)}function Bo(){const e=he;return he=!1,e}function le(e){const t=new URLSearchParams(e);if(t.get("desktop-settings")==="phone")return t.get("pair")==="open"?"/?desktop-settings=phone&pair=open":"/?desktop-settings=phone";const n=t.get("next");if(n&&/^\/(?!\/)/.test(n)&&!n.startsWith("/pair")&&!/[\\\s]/.test(n))return n;const o=t.get("thread");if(o===null)return"/";const a=new URLSearchParams({thread:o}),i=t.get("bot");return i!==null&&a.set("bot",i),`/?${a}`}const Mn="23456789ABCDEFGHJKLMNPQRSTUVWXYZ",Dn=12,Fn="omb_pair_",Bn=/^omb_pair_[A-Za-z0-9_-]{43}$/;function ft(e){return e.toUpperCase().replace(/[^A-Z0-9]/g,"").replace(/0/g,"O").replace(/1/g,"I")}function zn(e){return ft(e).match(/.{1,4}/g)?.join("-")??e}const Un={emailCode:"serverError.pair.emailCode",oldCode:"serverError.pair.oldCode",scriptKey:"serverError.pair.scriptKey",notACode:"serverError.pair.notACode"};function Wn(e){let t;try{t=new URL(e)}catch{return null}const n=new URLSearchParams(t.hash.replace(/^#/,""));return t.searchParams.get("token")??t.searchParams.get("code")??n.get("code")}function Ee(e){let t=e.trim();if(!t)return{kind:"empty"};if(/^[a-z][a-z0-9+.-]*:\/\//i.test(t)){const a=Wn(t);if(!a)return{kind:"wrong",problem:"notACode"};t=a.trim()}if(t.startsWith("omb_sess_"))return{kind:"wrong",problem:"scriptKey"};if(t.startsWith(Fn))return Bn.test(t)?{kind:"credential",credential:t}:{kind:"wrong",problem:"notACode"};const n=t.replace(/[\s-]/g,"");if(/^\d{8}$/.test(n))return{kind:"wrong",problem:"emailCode"};if(/^\d{6}$/.test(n))return{kind:"wrong",problem:"oldCode"};const o=ft(t);return o.length!==Dn||[...o].some(a=>!Mn.includes(a))?{kind:"wrong",problem:"notACode"}:{kind:"code",code:o}}const F="mt-1 w-full rounded-md border border-hairline/40 bg-inset px-3 py-2 text-[14px] text-ink outline-none focus:border-accent-border",Ke="mt-5 w-full rounded-md bg-accent px-4 py-2 text-[14px] font-medium text-accent-ink disabled:opacity-50",B="mt-4 block text-[12px] font-medium text-ink-secondary";function Kn(e,t=typeof window<"u"&&!!window.ogb?.workspaces){return!!e&&t}function Vn({mode:e,sent:t,email:n,cloudHome:o}){return e==="email"?t?s("pair.intro.emailSent",{email:n}):s("pair.intro.email"):o?s("pair.intro.cloud",{app:H(),open:s("cloudHome.connect"),section:s("settings.section.cloudAccount")}):s("pair.intro.code")}function Gn(e){const t=Ee(e);return t.kind==="wrong"&&t.problem!=="notACode"?s(Un[t.problem]):null}function Xn(e){const t=Ee(e).kind;return t==="code"||t==="credential"}function Yn(e,t){const n=Ee(t),o=n.kind==="code"?`&code=${encodeURIComponent(zn(n.code))}`:"";return`openmausbot://pair?address=${encodeURIComponent(e)}${o}`}function qn(e){return e.protocol==="http:"&&!Mt(e.hostname)}function Ve(e,t=Jt()){if(!e?.capabilities.cloudTeam||typeof t!="string")return null;try{const n=new URL(t),o=n.protocol==="http:"&&["127.0.0.1","localhost","[::1]"].includes(n.hostname);return(n.protocol==="https:"||o)&&!n.username&&!n.password&&!n.hash?n.href:null}catch{return null}}function Jn(e,t){return e?.capabilities.cloudTeam?e.label:e?.capabilities.cloudHome?s("pair.myCloud"):s(t==="email"?"pair.signInTo":"pair.connectTo",{name:e?.label??s("pair.thisOpenMausBot",{app:H()})})}function Zn({team:e}){return r.jsx("main",{"data-team-left":!0,className:"flex min-h-screen items-center justify-center bg-app px-6 text-ink",children:r.jsx("p",{role:"status",className:"max-w-[420px] text-[16px]",children:s("homeLine.left",{name:e??s("pair.thisOpenMausBot",{app:H()})})})})}function G({initialCode:e,initialEmail:t=null,reason:n}){const[o,a]=u.useState(e??""),[i,c]=u.useState(Qe()),[l,x]=u.useState(null),[f,b]=u.useState(null),[d,y]=u.useState(!1),[k,p]=u.useState(null),[w,T]=u.useState(()=>Z()),[E,O]=u.useState(t&&!e?"email":"code"),[v,M]=u.useState(t??""),[_,L]=u.useState(""),[g,j]=u.useState(!1),[ne,xt]=u.useState(()=>Kn(e));u.useEffect(()=>{if(!ne||!e)return;let h=!0;return ue({code:e,label:i,attemptId:w}).then(C=>{if(h){if(C.ok){location.replace(le(location.search));return}xt(!1),p(C.error)}}),()=>{h=!1}},[]),u.useEffect(()=>{fetch("/.well-known/openmausbot/environment").then(h=>h.ok?h.json():null).then(h=>{x(h)}).catch(()=>{x(null)}),ke().then(b)},[]);const oe=Zt(f),gt=l?.capabilities.emailSignIn===!0,D=l?.capabilities.cloudHome===!0,bt=!D&&l?.capabilities.cloudTeam!==!0,Pe=Gn(o),W=typeof location<"u"&&typeof location.protocol=="string"?location:null;async function yt(h){h.preventDefault(),y(!0),p(null);const C=await ue({code:o,label:i,attemptId:w});if(y(!1),C.ok){location.replace(le(location.search));return}p(C.error)}async function kt(h){h.preventDefault(),y(!0),p(null);const C=g?await an({email:v,code:_,label:i}):await rn(v);if(y(!1),!C.ok){p(C.error);return}if(g){location.replace(le(location.search));return}j(!0)}function Ie(h){O(h),p(null)}return r.jsxs("main",{className:"flex min-h-screen items-center justify-center bg-app px-6 text-ink",children:[r.jsx("div",{className:"absolute left-3 top-12 max-w-[280px]",children:r.jsx(Ln,{})}),r.jsxs("div",{className:"w-full max-w-[420px]",children:[W&&qn(W)?r.jsx("p",{role:"alert",className:"mb-4 rounded-md border border-warning/30 bg-warning/10 px-3 py-2 text-[13px] text-warning",children:s("pair.notEncrypted")}):null,ne?r.jsx("p",{role:"status",className:"text-[20px] font-semibold",children:D?s("pair.openingCloud"):s("pair.connectingTo",{name:l?.label??s("pair.thisOpenMausBot")})}):r.jsxs(r.Fragment,{children:[r.jsx("h1",{className:"text-[20px] font-semibold",children:Jn(l,E)}),r.jsxs("p",{className:"mt-1.5 text-[14px] leading-relaxed text-ink-secondary",children:[l&&!D?`${s("pair.version",{version:l.version,platform:l.platform})} `:"",Vn({mode:E,sent:g,email:v,cloudHome:D})]}),Re(n)&&!oe?r.jsx("p",{className:"mt-3 text-[13px] text-ink-secondary",children:Re(n)}):null,k&&D&&e?r.jsx("p",{className:"mt-3 text-[13px] text-ink-secondary",children:s("pair.expired",{app:H(),open:s("cloudHome.connect"),section:s("settings.section.cloudAccount")})}):null,!oe&&Ve(l)?r.jsxs("div",{"data-team-sign-in":!0,className:"mt-4 flex flex-col items-start gap-1.5",children:[r.jsx("a",{href:Ve(l),className:"rounded-md bg-accent px-4 py-2 text-[14px] font-medium text-accent-ink",children:s("pair.team.open",{team:l.label})}),r.jsx("p",{className:"text-[13px] text-ink-secondary",children:s("pair.team.openHint")})]}):null]}),ne?null:oe?r.jsxs("p",{className:"mt-4 text-[14px]",children:[s("pair.alreadyConnected")," ",r.jsx("a",{href:"/",className:"text-accent underline",children:s("pair.openApp")})]}):E==="email"?r.jsxs("form",{onSubmit:kt,children:[r.jsx("label",{className:B,htmlFor:"signin-email",children:s("cloudBuy.signIn.email")}),r.jsx("input",{id:"signin-email",type:"email",value:v,onChange:h=>{M(h.target.value),j(!1),L("")},autoComplete:"email",inputMode:"email",spellCheck:!1,className:F}),g?r.jsxs(r.Fragment,{children:[r.jsx("label",{className:B,htmlFor:"signin-code",children:s("pair.emailCode")}),r.jsx("input",{id:"signin-code",value:_,onChange:h=>L(h.target.value),placeholder:"12345678",autoComplete:"one-time-code",inputMode:"numeric",spellCheck:!1,className:`${F} font-mono text-[15px] tracking-[0.12em]`}),r.jsx("label",{className:B,htmlFor:"signin-label",children:s("pair.deviceLabel")}),r.jsx("input",{id:"signin-label",value:i,onChange:h=>c(h.target.value),maxLength:80,className:F})]}):null,k?r.jsx("p",{className:"mt-3 text-[13px] text-danger",children:k}):null,r.jsx("button",{type:"submit",disabled:d||!v.includes("@")||g&&_.replace(/\D/g,"").length<8,className:Ke,children:s(d?g?"pair.signingIn":"pair.sending":g?"pair.signIn":"cloudBuy.signIn.send")}),g?r.jsx("button",{type:"button",onClick:()=>j(!1),className:"mt-3 w-full text-[13px] text-ink-secondary underline",children:s("pair.resend")}):null,r.jsx("button",{type:"button",onClick:()=>Ie("code"),className:"mt-3 w-full text-[13px] text-ink-secondary underline",children:s("pair.useCode")})]}):r.jsxs("form",{onSubmit:yt,children:[r.jsx("label",{className:B,htmlFor:"pair-code",children:s("pair.code")}),r.jsx("input",{id:"pair-code",value:o,onChange:h=>{a(h.target.value),T(Z())},placeholder:"XXXX-XXXX-XXXX","aria-describedby":e&&o===e?"pair-code-from-link":void 0,autoComplete:"one-time-code",autoCapitalize:"characters",spellCheck:!1,className:`${F} font-mono text-[15px] tracking-[0.12em]`}),e&&o===e?r.jsx("p",{id:"pair-code-from-link",className:"mt-1 text-[12px] text-ink-secondary",children:s("pair.fromLink")}):null,r.jsx("label",{className:B,htmlFor:"pair-label",children:s("pair.deviceLabel")}),r.jsx("input",{id:"pair-label",value:i,onChange:h=>c(h.target.value),maxLength:80,className:F}),Pe?r.jsx("p",{role:"alert",className:"mt-3 text-[13px] text-danger",children:Pe}):k?r.jsx("p",{className:"mt-3 text-[13px] text-danger",children:k}):null,r.jsx("button",{type:"submit",disabled:d||!Xn(o),className:Ke,children:s(d?"pair.connecting":"pair.connect")}),W?.origin?r.jsxs("p",{className:"mt-3 text-[13px] text-ink-secondary",children:[s("pair.onPhone")," ",r.jsx("a",{href:Yn(W.origin,o),className:"text-accent underline",children:s("pair.openInApp",{app:H()})})]}):null,bt?r.jsxs("p",{className:"mt-3 text-[13px] text-ink-secondary",children:[s("pair.noCode")," ",r.jsx("code",{className:"select-all rounded bg-inset px-1.5 py-0.5 text-[12px] text-ink",children:"npx @seira-bot/seira pair"})]}):null,gt?r.jsxs("p",{className:"mt-5 border-t border-hairline/40 pt-4 text-[13px] text-ink-secondary",children:[s("pair.invitedByEmail")," ",r.jsx("button",{type:"button",onClick:()=>Ie("email"),className:"text-accent underline",children:s("pair.useEmail")})]}):null]})]})]})}const zo="cloud-welcome-done",Qn="unauthorized: you are no longer in this team",eo=/^announcements-read-(\d{1,16})$/;function Uo(e){let t=null;for(const n of e){const o=Number(eo.exec(n)?.[1]??NaN);Number.isSafeInteger(o)&&(t===null||o>t)&&(t=o)}return t}const Ge=[["reserving","cloudHome.step.reserving"],["storage","cloudHome.step.storage"],["starting","cloudHome.step.starting"],["checking","cloudHome.step.checking"]];function to({step:e}){const t=Ge.findIndex(([n])=>n===e);return r.jsx("ol",{"data-cloud-setup":e,className:"flex flex-col gap-1 text-[13px]",children:Ge.map(([n,o],a)=>r.jsx("li",{"aria-current":a===t?"step":void 0,className:a===t?"font-medium text-ink":a<t?"text-ink-secondary line-through decoration-ink-secondary/40":"text-ink-secondary",children:s(o)},n))})}const no={stopped:"cloudHome.stopped","payment-problem":"cloudHome.paymentProblem",failed:"cloudHome.failed"},Xe={host:"cloudHome.unreachableHost",no_answer:"cloudHome.unreachable"};function oo(e,t=Date.now()){const n=new Date(e).getFullYear()!==new Date(t).getFullYear();return new Intl.DateTimeFormat(Dt(),{day:"numeric",month:"long",...n?{year:"numeric"}:{}}).format(new Date(e))}function ro(e,t=Date.now()){const n=e?.name??null,o=(a,i)=>n?s(i,{name:n}):s(a);return e?.screen==="setup"?{title:o("homeScreen.setup","homeScreen.setupNamed"),body:s(e.slow?"cloudHome.slow":"homeScreen.setupBody"),reason:null,action:null,busy:!0}:e?.screen==="offline"?{title:o("homeScreen.offline","homeScreen.offlineNamed"),body:s("homeScreen.offlineBack"),reason:e.cause&&Object.hasOwn(Xe,e.cause)?s(Xe[e.cause]):e.reason??null,action:"retry",busy:!1}:e?.screen==="signin"?{title:o("homeScreen.signIn","homeScreen.signInNamed"),body:s(e.other?"homeScreen.signInOther":"homeScreen.signInEnded"),reason:null,action:"sign-in",busy:!1}:e?.screen==="plan"&&e.member&&e.machine!=="failed"?{title:o("homeScreen.plan","homeScreen.planNamed"),body:s("cloudHome.stoppedMember"),reason:null,action:null,busy:!1}:e?.screen==="plan"?{title:o("homeScreen.plan","homeScreen.planNamed"),body:s(no[e.machine]??"cloudHome.failed"),reason:null,action:e.machine==="failed"?null:"manage",busy:!1}:e?.screen==="ended"?{title:o("cloudHome.ended","cloudHome.endedNamed"),body:e.deleteAt?s("cloudHome.endedFiles",{date:oo(e.deleteAt,t)}):null,reason:null,action:"buy",busy:!1}:e?.screen==="checkout"?{title:o("cloudHome.checkout","cloudHome.checkoutNamed"),body:null,reason:null,action:"continue",busy:!1}:e?.screen==="payment"?{title:o("cloudHome.payment","cloudHome.paymentNamed"),body:s("cloudHome.paymentBody"),reason:null,action:"card",busy:!1}:e?.screen==="waking"?{title:s("homeScreen.waking"),body:null,reason:null,action:null,busy:!0}:e?.screen==="moving"?{title:o("homeScreen.moving","homeScreen.movingNamed"),body:null,reason:null,action:null,busy:!0}:{title:o("homeScreen.opening","homeScreen.openingNamed"),body:null,reason:null,action:null,busy:!0}}function ao(e,t){return e?.screen==="offline"?"sad":t.busy?"working":t.action?"attention":"idle"}const so={retry:"cloudHome.tryAgain",buy:"cloudHome.buyAgain",continue:"cloudHome.continue",card:"cloudHome.updateCard"};function io({name:e,remove:t}){const[n,o]=u.useState(!1),[a,i]=u.useState(!1),[c,l]=u.useState(null),x=()=>{i(!0),l(null),t().then(f=>{i(!1),f!=="removed"&&f!=="gone"&&(o(!1),l(f==="refused"?"refused":"failed"))},()=>{i(!1),o(!1),l("failed")})};return r.jsxs("div",{"data-home-remove":!0,className:"flex flex-col items-start gap-2",children:[n?r.jsxs("div",{role:"alertdialog","aria-label":s("rail.remove"),className:"flex flex-col gap-2 rounded-xl border border-hairline/70 bg-card/70 px-4 py-3",children:[r.jsx("p",{className:"text-[13px] leading-relaxed text-ink",children:s("rail.removeAsk",{name:e})}),r.jsxs("div",{className:"flex gap-2",children:[r.jsx("button",{type:"button","data-home-remove-confirm":!0,className:"ui-button ui-button-primary",disabled:a,onClick:x,children:s("rail.removeYes")}),r.jsx("button",{type:"button",className:"ui-button",disabled:a,onClick:()=>o(!1),children:s("rail.removeNo")})]})]}):r.jsx("button",{type:"button","data-home-remove-ask":!0,className:"text-[13px] text-ink-secondary underline-offset-2 hover:text-ink hover:underline",onClick:()=>{l(null),o(!0)},children:s("rail.remove")}),c&&r.jsx("p",{role:"alert",className:"text-[13px] text-danger",children:s(c==="refused"?"rail.removeRefused":"rail.removeFailed")})]})}function lo({bridge:e,manage:t}){const[n,o]=u.useState(null),[a,i]=u.useState(!1);u.useEffect(()=>{let y=!0;const k=e.onState(w=>o(w)),p=()=>{e.retry().then(w=>{y&&o(w)}).catch(()=>{})};return e.state().then(w=>{y&&o(w)}).catch(()=>{}).then(p),window.addEventListener("online",p),window.addEventListener("focus",p),()=>{y=!1,k(),window.removeEventListener("online",p),window.removeEventListener("focus",p)}},[e]);const c=ro(n),l=y=>{i(!1),y().catch(()=>i(!0))},x=window.ogb?.cloudAdd?.reopen,f={retry:()=>e.retry().then(y=>o(y)),...t?{manage:t,buy:t,card:t,continue:async()=>{x&&await x().catch(()=>!1)||await t()}}:{}},b=c.action&&c.action!=="sign-in"&&c.action!=="manage"?c.action:null,d=(n?.screen==="ended"||n?.screen==="payment")&&n.removable===!0&&typeof e.remove=="function";return r.jsx("main",{"data-home-screen":n?.screen??"opening",className:"flex min-h-screen items-center justify-center bg-app px-6 text-ink",style:{WebkitAppRegion:"drag"},children:r.jsxs("div",{className:"flex w-full max-w-[420px] flex-col items-start gap-3",style:{WebkitAppRegion:"no-drag"},children:[r.jsx(qe,{state:ao(n,c),size:96}),r.jsx("p",{role:"status",className:"text-[20px] font-semibold",children:c.title}),c.body&&r.jsx("p",{className:"text-[14px] leading-relaxed text-ink-secondary",children:c.body}),n?.screen==="setup"&&r.jsx(to,{step:n.step??"reserving"}),c.reason&&r.jsx("p",{"data-home-reason":!0,className:"text-[13px] leading-relaxed text-ink-secondary",children:c.reason}),c.action==="sign-in"&&r.jsx("button",{type:"button",className:"ui-button ui-button-primary mt-2",onClick:()=>l(()=>e.signIn()),children:s("homeScreen.signInButton")}),c.action==="manage"&&t&&r.jsx("button",{type:"button",className:"ui-button mt-2",onClick:()=>l(t),children:s("cloudAccount.manageInBrowser")}),b&&f[b]&&r.jsx("button",{type:"button","data-home-action":b,className:b==="retry"?"ui-button mt-2":"ui-button ui-button-primary mt-2",onClick:()=>l(f[b]),children:s(so[b])}),d&&r.jsx(io,{name:n.name??s("cloudSetup.myCloud"),remove:()=>e.remove()}),a&&r.jsx("p",{role:"alert",className:"text-[13px] text-danger",children:s("cloudAccount.actionFailed")})]})})}function co({bridge:e,fallback:t}){const[n,o]=u.useState(!1);return u.useEffect(()=>{e.repair().catch(()=>o(!0))},[e]),n?r.jsx(r.Fragment,{children:t}):r.jsx("main",{"data-home-screen":"opening",className:"flex min-h-screen items-center justify-center bg-app px-6 text-ink",children:r.jsxs("div",{className:"flex w-full max-w-[420px] flex-col items-start gap-3",children:[r.jsx(qe,{state:"working",size:96}),r.jsx("p",{role:"status",className:"text-[20px] font-semibold",children:s("homeScreen.opening")})]})})}const Ce="omb.session-ended";let xe=!1,ce=null;const ge=new Set;function Wo(){xe||ce||(ce=ke().then(e=>{if(e.kind==="unauthenticated"){xe=!0;try{sessionStorage.setItem(Ce,"1")}catch{}for(const t of ge)t()}}).finally(()=>{ce=null}))}function Ye(){return xe}function Ko(){return u.useSyncExternalStore(e=>(ge.add(e),()=>ge.delete(e)),Ye,Ye)}function uo(){try{return sessionStorage.getItem(Ce)==="1"}catch{return!1}}function mo(){try{sessionStorage.removeItem(Ce)}catch{}}Ft();ye(Bt());zt(Ut());sn();Wt(Kt());Nn();const J=Vt(),po=new Set(["/home","/pair","/desktop-viewer"]),ht=()=>Je(()=>import("./App-BIllYA_e.js").then(e=>e.l3),__vite__mapDeps([0,1,2,3,4,5,6])).catch(e=>({default:()=>{throw e}})),fo=po.has(location.pathname)?null:ht(),ho=()=>fetch("/.well-known/openmausbot/environment").then(e=>e.json()).then(e=>e.capabilities?.cloudTeam===!0&&typeof e.label=="string"?e.label:null,()=>null);async function xo(){const e=window.ogb?.home;if(location.pathname==="/home"&&e)return r.jsx(lo,{bridge:e,manage:window.ogb?.cloudPlan?.manage});if(location.pathname==="/pair"){const o=en();if(o){const a=await nn(o);return await J,a?r.jsx(En,{credential:o,owner:a.owner,team:a.team}):r.jsx(G,{initialCode:null,reason:s("pair.browser.signInFailed")})}return r.jsx(G,{initialCode:Qt(),initialEmail:tn()})}const t=await ke();if(t.kind==="unauthenticated"){if(await J,t.error===Qn)return r.jsx(Zn,{team:await ho()});const o=r.jsx(G,{initialCode:null,reason:uo()?s("pair.sessionEnded"):t.error});return e?r.jsx(co,{bridge:e,fallback:o}):o}if(mo(),t.kind==="session"&&qt(t.teamSignIn),t.kind==="loopback"&&t.trust==="service")return await J,r.jsx(G,{initialCode:null,reason:s("pair.serviceTrust")});if(location.pathname==="/desktop-viewer"){const{DesktopViewer:o}=await Je(async()=>{const{DesktopViewer:a}=await import("./DesktopViewer-BoBSIDfB.js");return{DesktopViewer:a}},__vite__mapDeps([7,1,2,8,9,6,5,10]));return r.jsx(o,{})}const{default:n}=await(fo??ht());return ve(),r.jsx(n,{})}document.title=H();Promise.all([Gt(),xo(),J]).then(([,e])=>{Xt.createRoot(document.getElementById("root")).render(r.jsx(u.StrictMode,{children:r.jsx(Yt,{children:e})}))});export{eo as A,Ao as B,to as C,ko as D,Po as E,Ln as F,Lo as G,Cn as H,de as I,Io as J,zo as K,Ko as L,G as M,Fo as N,Oo as P,_o as S,nt as T,Do as a,kn as b,vn as c,wo as d,Co as e,Eo as f,$o as g,$n as h,yo as i,No as j,Pn as k,ve as l,Ne as m,Wo as n,To as o,Ho as p,bo as q,ke as r,jo as s,Bo as t,So as u,Uo as v,vo as w,Mo as x,On as y,Ro as z};
1
+ const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["assets/App-h8WTNY4l.js","assets/styles-3g-ZPS7M.js","assets/styles-CsrDURJH.css","assets/PlacesRail-Df-jNTHn.js","assets/placement-BKtVnQht.js","assets/monitor-DMPjQDZP.js","assets/MenuMotion-CHp-hB40.js","assets/DesktopViewer-YvIV04Lf.js","assets/desktop-connection-CU6jsy2e.js","assets/desktop-viewer-CF-OpSo0.js","assets/minimize-Dga3UCb8.js"])))=>i.map(i=>d[i]);
2
+ import{t as s,s as wt,k as I,as as St,m as vt,h as be,at as jt,au as Nt,av as Et,r as u,aw as Ct,F as ye,ax as Te,D as _e,ay as Ae,az as re,aA as Pt,aB as It,j as r,d as Tt,X as _t,a as $,aC as At,aD as Ot,v as K,L as Lt,ae,Q as se,an as Oe,ad as Rt,g as $t,aE as Ht,q as H,aF as Mt,S as qe,b as Dt,E as Ft,G as Bt,H as zt,I as Ut,aG as Wt,aH as Kt,K as Vt,J as Gt,M as Xt,P as Yt,_ as Je}from"./styles-3g-ZPS7M.js";function bo(e,t){if(!t)return;if(t.kind!=="session")return t.kind==="loopback"?e:void 0;if(t.team||t.scopes.includes("admin"))return e;const n=t.email;if(n?.trim())return e?.email?.trim().toLowerCase()===n.trim().toLowerCase()?e:{email:n}}const Ze="omb.team-sign-in";function qt(e){try{e&&globalThis.localStorage?.setItem(Ze,e)}catch{}}function Jt(){try{return globalThis.localStorage?.getItem(Ze)??null}catch{return null}}async function ke(e=fetch){let t;try{t=await e("/api/auth/session",{credentials:"same-origin"})}catch(a){return{kind:"unreachable",error:a instanceof Error?a.message:String(a)}}const n=await t.json().catch(()=>({})),o=Object(n);return t.status===401||t.status===403?{kind:"unauthenticated",error:typeof o.error=="string"?o.error:`${t.status}`}:t.ok?o.kind==="session"&&typeof o.id=="string"?{kind:"session",id:o.id,label:typeof o.label=="string"?o.label:"",...typeof o.email=="string"?{email:o.email}:{},scopes:Array.isArray(o.scopes)?o.scopes.filter(a=>typeof a=="string"):[],expiresAt:typeof o.expiresAt=="number"?o.expiresAt:0,...typeof o.reactor=="string"?{reactor:o.reactor}:{},...typeof o.teamSignIn=="string"?{teamSignIn:o.teamSignIn}:{},...Le(o.team)?{team:Le(o.team),openedThreads:Array.isArray(o.openedThreads)?o.openedThreads.filter(a=>typeof a=="string"):[]}:{},...o.cloudGuest===!0?{cloudGuest:!0,openedThreads:Array.isArray(o.openedThreads)?o.openedThreads.filter(a=>typeof a=="string"):[]}:{}}:o.trust==="service"?{kind:"loopback",trust:"service"}:{kind:"loopback"}:{kind:"unreachable",error:`${t.status} ${t.statusText}`}}function Le(e){const t=Object(e);return typeof t.id=="string"&&typeof t.name=="string"&&typeof t.role=="string"?{id:t.id,name:t.name,role:t.role}:null}function Zt(e){return e?.kind==="session"||e?.kind==="loopback"&&e.trust!=="service"}function yo(e){return e?e.kind==="loopback"?e.trust!=="service":e.kind==="session"&&e.scopes.includes("admin"):!1}function Qt(){const e=/[#&]code=([^&]+)/.exec(location.hash);return e?(history.replaceState(null,"",location.pathname+location.search),decodeURIComponent(e[1])):null}function en(){if(!/[#&]signin=/.test(location.hash))return null;const e=/[#&]signin=(omb_pair_[A-Za-z0-9_-]{43})(?:&|$)/.exec(location.hash);return history.replaceState(null,"",location.pathname+location.search),e?e[1]:null}function tn(){const e=new URLSearchParams(location.search),t=e.get("email")?.trim().toLowerCase()??"";if(!t)return null;e.delete("email");const n=e.toString();return history.replaceState(null,"",location.pathname+(n?`?${n}`:"")+location.hash),/^[^@\s]+@[^@\s]+\.[^@\s]+$/.test(t)?t:null}function Qe(e=navigator.userAgent){const t=/Edg\//.test(e)?"Edge":/OPR\//.test(e)?"Opera":/Chrome\//.test(e)?"Chrome":/Firefox\//.test(e)?"Firefox":/Safari\//.test(e)?"Safari":"Browser",n=/iPhone/.test(e)?"iPhone":/iPad/.test(e)?"iPad":/Android/.test(e)?"Android":/Mac OS X/.test(e)?"Mac":/Windows/.test(e)?"Windows":/Linux/.test(e)?"Linux":"";return n?`${t} on ${n}`:t}function Z(){return typeof crypto?.randomUUID=="function"?crypto.randomUUID():`${Date.now().toString(36)}-${Math.random().toString(36).slice(2,14)}`}function et(e,t){const n=Reflect.get(Object(e),"error");return wt(e,typeof n=="string"?n:`${t.status} ${t.statusText}`)}async function ue(e,t=fetch){let n;try{n=await t("/api/auth/pair",{method:"POST",credentials:"same-origin",headers:{"content-type":"application/json"},body:JSON.stringify({code:e.code,label:e.label,cookie:!0,attemptId:e.attemptId??Z(),...e.browser?{browser:!0}:{}})})}catch(a){return{ok:!1,error:s("pair.unreachable",{error:a instanceof Error?a.message:String(a)})}}const o=await n.json().catch(()=>({}));return n.ok?{ok:!0}:{ok:!1,error:et(o,n)}}async function nn(e,t=fetch){try{const n=await t("/api/auth/pair",{method:"POST",credentials:"same-origin",headers:{"content-type":"application/json"},body:JSON.stringify({code:e,browser:!0,preview:!0})}),o=Object(await n.json().catch(()=>({}))),a=Reflect.get(o,"owner"),i=Reflect.get(o,"team");return n.ok&&typeof a=="string"&&a?{owner:a,...typeof i=="string"&&i.trim()?{team:i.trim()}:{}}:null}catch{return null}}function on(e,t,n=fetch){return ue({code:e,label:Qe(),attemptId:t,browser:!0},n)}function ko(e){const t=Object(e);return t.cloudHome===!0&&typeof t.owner=="string"&&t.owner?t.owner:null}async function tt(e,t,n){let o;try{o=await n(e,{method:"POST",credentials:"same-origin",headers:{"content-type":"application/json"},body:JSON.stringify(t)})}catch(i){return{ok:!1,error:s("pair.unreachable",{error:i instanceof Error?i.message:String(i)})}}const a=await o.json().catch(()=>({}));return o.ok?{ok:!0}:{ok:!1,error:et(a,o)}}function rn(e,t=fetch){return tt("/api/auth/email/start",{email:e},t)}function an(e,t=fetch){return tt("/api/auth/email/verify",{email:e.email,code:e.code,label:e.label},t)}function Re(e){return!e||/through a proxy|loopback host required|cross-origin request|^40[13]$/i.test(e)?null:e}function sn(){window.ogb?.softwareRendering===!0&&(document.documentElement.dataset.softwareRendering="")}const ln="/api/theme-assets/",cn="safe-look",nt={cssChars:1e5,assetBytes:10*1024*1024},un=/^[a-z0-9][a-z0-9-]{0,47}$/,dn=/^[a-z0-9][a-z0-9_-]{0,79}\.(png|jpe?g|webp|gif|avif|svg|woff2?|ttf|otf)$/,mn=/^\/api\/theme-assets\/[a-z0-9][a-z0-9-]{0,47}\/[a-z0-9][a-z0-9_-]{0,79}\.[a-z0-9]{2,5}$/,ot=["app","panel","frame","raised","raised-hover","card","inset","control","composer","composer-ring","menu","menu-hover","menu-active","hairline","edge","scrollbar","ink","ink-secondary","ink-tertiary","accent","accent-border","accent-text","accent-ink","focus","bubble-user","bubble-user-ink","success","success-ink","danger","danger-ink","warning"],Q=I().trim().regex(/^#(?:[0-9a-f]{3}|[0-9a-f]{6})$/i,"a hex colour such as #1a2b3c"),pn=I().trim().min(1).max(120).regex(/^[#a-z0-9(),.%\s/+-]+$/i,"a CSS colour such as #1a2b3c, rgb(…) or color-mix(…)").refine(e=>!/url|image|src|attr/i.test(e),"a colour, not a file"),rt=St(vt(ot),pn),$e=be({canvas:Q.optional(),accent:Q.optional(),colors:rt.optional()}).strict(),we=be({name:I().trim().min(1).max(60),skin:jt.optional(),canvas:Q.optional(),accent:Q.optional(),colors:rt.optional(),light:$e.optional(),dark:$e.optional(),font:I().trim().max(300).regex(/^[\w\s"',.-]*$/,'a font-family list such as "Inter Variable", serif').optional(),css:I().max(nt.cssChars).optional()}).strict(),fn=1;be({mausbotTheme:Et(fn),id:I().regex(un).optional(),theme:we,assets:Nt(I().regex(dn),I().max(Math.ceil(nt.assetBytes*1.4)).regex(/^data:[\w/+.-]+;base64,[A-Za-z0-9+/=]+$/)).optional()}).strict();function at(e){return/^data:/i.test(e)||e.startsWith("#")||mn.test(e)&&!e.includes("..")}function st(e){const t=e.toLowerCase(),n=[];for(let o=t.indexOf("url(");o!==-1;o=t.indexOf("url(",o+4)){let a=o+4;for(;/\s/.test(e[a]??"");)a++;const i=e[a];let c;if(i==='"'||i==="'"){const l=e.indexOf(i,a+1);if(l===-1)return null;for(c=e.slice(a+1,l),a=l+1;/\s/.test(e[a]??"");)a++;if(e[a]!==")")return null}else{const l=e.indexOf(")",a);if(l===-1||(c=e.slice(a,l).trim(),/[\s"'(]/.test(c)))return null}n.push(c.trim())}return n}const it=/image-set\(|\bimage\(|\bsrc\(/i;function lt(e){if(e.includes("\\")||it.test(e))return!0;const t=st(e);return t===null||t.some(n=>!at(n))}function hn(e){let t="";for(let n=0;n<e.length;n++){const o=e[n];if(o==="/"&&e[n+1]==="*"){const a=e.indexOf("*/",n+2);n=a===-1?e.length:a+1,t+=" "}else if(o==='"'||o==="'"){let a=n+1;for(;a<e.length&&e[a]!==o&&e[a]!==`
3
+ `;)a+=e[a]==="\\"?2:1;t+=`${o}${" ".repeat(Math.max(0,a-n-1))}${o}`,n=a}else t+=o}return t}function wo(e){const t=hn(e);if(/@import/i.test(t))return"@import is not allowed: themes cannot load other stylesheets.";if(t.includes("\\"))return"Backslash escapes are only allowed inside quoted strings.";if(it.test(t))return"image-set(), image() and src() are not allowed: use url() with a theme file or a data: address.";const n=e.replace(/\/\*[\s\S]*?\*\//g," "),o=st(n);if(o===null)return'A url() could not be read. Write url("/api/theme-assets/<theme>/<file>").';const a=o.find(i=>!at(i));return a!==void 0?`url(${a.slice(0,80)}) is not allowed: themes load only their own files (${ln}<theme>/<file>), data: addresses or #ids, never the internet.`:null}function de(e=typeof document>"u"?null:document.documentElement){if(!e||typeof window>"u"||typeof window.getComputedStyle!="function")return"dark";try{return window.getComputedStyle(e).getPropertyValue("--code-color-scheme").trim()==="light"?"light":"dark"}catch{return"dark"}}function So(){const[e,t]=u.useState(()=>de());return u.useEffect(()=>{const n=()=>t(de());if(n(),typeof MutationObserver>"u")return;const o=new MutationObserver(n);return o.observe(document.documentElement,{attributes:!0,attributeFilter:["data-skin"]}),()=>o.disconnect()},[]),e}const N=[255,255,255],P=[0,0,0];function ee(e){const t=e.trim().replace(/^#/,""),n=t.length===3?[...t].map(a=>a+a).join(""):t,o=Number.parseInt(n.slice(0,6),16);return Number.isFinite(o)?[o>>16&255,o>>8&255,o&255]:P}const V=e=>Math.round(Math.min(255,Math.max(0,e))).toString(16).padStart(2,"0"),m=([e,t,n],o)=>`#${V(e)}${V(t)}${V(n)}${o===void 0?"":V(o*255)}`,S=(e,t,n)=>[0,1,2].map(o=>e[o]+(t[o]-e[o])*n);function te([e,t,n]){const o=a=>{const i=a/255;return i<=.03928?i/12.92:((i+.055)/1.055)**2.4};return .2126*o(e)+.7152*o(t)+.0722*o(n)}function me(e,t){const[n,o]=[te(e),te(t)].sort((a,i)=>i-a);return(n+.05)/(o+.05)}const He=e=>te(ee(e))<.2?"dark":"light";function X(e,t,n){const o=te(t)<.2?N:P;let a=e;for(let i=1;i<=20&&me(a,t)<n;i++)a=S(e,o,i/20);return a}const ct=e=>me(N,e)>=me(P,e)?N:[17,17,17];function xn(e,t){const n=ee(e),o=t==="dark",a=f=>S(n,o?N:P,f),i=o?a(.08):S(n,N,.85),c=a(o?.14:.06),l=X(S(o?N:P,n,o?.04:.1),n,12),x=a(o?.22:.07);return{app:m(n),panel:m(o?S(n,P,.25):S(n,N,.45)),frame:m(o?S(n,P,.25):S(n,N,.45)),raised:m(i),"raised-hover":m(c),card:m(o?a(.07):i),inset:m(o?a(.04):n),control:m(a(o?.12:.07)),composer:m(o?a(.07):i),"composer-ring":m(a(o?.14:.12)),menu:m(i),"menu-hover":m(l,.06),"menu-active":m(l,.09),hairline:m(a(.2)),edge:m(l,.08),scrollbar:m(a(o?.25:.22)),ink:m(l),"ink-secondary":m(X(S(l,n,o?.3:.4),c,4.5)),"ink-tertiary":m(X(S(l,n,o?.42:.5),c,4.5)),"bubble-user":m(x),"bubble-user-ink":m(o?ct(x):l)}}function gn(e,t,n){const o=ee(e),a=X(o,ee(n),4.5);return{accent:m(o),"accent-ink":m(ct(o)),"accent-border":m(t==="dark"?S(o,N,.2):S(o,P,.1)),"accent-text":m(a),focus:m(a)}}class bn extends Error{}function Y(e,t){const n=globalThis[t];return typeof n=="function"&&e instanceof n}function Me(e){const t=e.style;return t&&typeof t=="object"&&typeof t.getPropertyValue=="function"?t:null}function De(e){for(let t=e.length-1;t>=0;t--){const n=e.item(t);lt(e.getPropertyValue(n))&&e.removeProperty(n)}}const yn=e=>"cssRules"in e&&typeof e.deleteRule=="function";function Fe(e,t,n){try{e.deleteRule(t)}catch{if(!Y(n,"CSSNamespaceRule"))throw new bn}}function ut(e){for(let t=e.cssRules.length-1;t>=0;t--){const n=e.cssRules[t];if(!n)continue;if(Y(n,"CSSKeyframesRule")){for(const a of Array.from(n.cssRules)){const i=Me(a);i&&De(i)}continue}if(Y(n,"CSSPropertyRule")){lt(n.initialValue??"")&&Fe(e,t,n);continue}const o=Me(n);o&&De(o),yn(n)?ut(n):!o&&!Y(n,"CSSLayerStatementRule")&&Fe(e,t,n)}}let R=null,Be="";function ze(e){if(!(typeof document>"u"||typeof CSSStyleSheet>"u"||!("adoptedStyleSheets"in document))&&e!==Be){Be=e,R||(R=new CSSStyleSheet,document.adoptedStyleSheets=[...document.adoptedStyleSheets,R]);try{R.replaceSync(e),ut(R)}catch{R.replaceSync("")}}}const pe="omb-theme",Ue="omb-safe-look";let A=null,z=[],ie=!1;const fe=new Set;function U(e){try{return typeof window>"u"?void 0:window[e]}catch{return}}function kn(){try{return typeof location<"u"&&new URLSearchParams(location.search).has(cn)&&U("sessionStorage")?.setItem(Ue,"1"),U("sessionStorage")?.getItem(Ue)==="1"}catch{return!1}}function vo(){return A}function jo(e){return fe.add(e),()=>{fe.delete(e)}}function wn(e){for(const t of z)e.style.removeProperty(t);z=[]}function q(){if(!(typeof document>"u"||ie)){ie=!0;try{const e=document.documentElement;wn(e);const t=kn()?null:A?.theme;if(!t){delete e.dataset.theme,ze(""),_e(Ae());return}const n=!t.skin||t.skin==="system"||t.skin===re.light||t.skin===re.dark,a=!!(t.light&&t.dark)&&n?void 0:t.skin??(t.canvas?re[He(t.canvas)]:void 0);_e(a?Pt(a):Ae());const i=de(e),c=t[i],l=c?.canvas??(t.canvas&&He(t.canvas)===i?t.canvas:void 0),x=c?.accent??t.accent,f={...l?xn(l,i):{},...x?gn(x,i,l??(i==="dark"?"#121212":"#ffffff")):{},...t.colors,...c?.colors};for(const b of ot){const d=f[b];d&&(e.style.setProperty(`--color-${b}`,d),z.push(`--color-${b}`))}l&&(e.style.setProperty("--code-color-scheme",i),z.push("--code-color-scheme")),t.font&&(e.style.setProperty("--font-sans",t.font),z.push("--font-sans")),e.dataset.theme=A.id,ze(t.css??"")}finally{ie=!1;for(const e of fe)e()}}}function Se(e){A=e;try{e?U("localStorage")?.setItem(pe,JSON.stringify(e)):U("localStorage")?.removeItem(pe)}catch{}q()}function Sn(){try{const e=JSON.parse(U("localStorage")?.getItem(pe)??"null"),t=we.safeParse(e?.theme);return typeof e?.id=="string"&&t.success?{id:e.id,theme:t.data}:null}catch{return null}}async function ve(){try{const e=await fetch("/api/themes/active",{headers:{accept:"application/json"}});if(!e.ok)return;const t=await e.json(),n=t.theme?we.safeParse(t.theme):null;Se(t.id&&n?.success?{id:t.id,theme:n.data}:null)}catch{}}function No(e){const t=e.skin;(t==="system"||It.includes(t))&&ye(t),ve()}const je=(e,t)=>fetch("/api/themes/active",{method:"PUT",headers:{"content-type":"application/json"},body:JSON.stringify({id:e,...t?{skin:t}:{}})}).then(n=>n.ok,()=>!1);function Eo(){A&&(Se(null),je(null))}async function Co(e){const t=await je(e);return t&&await ve(),t}function vn(){ye(Te),Se(null),je(null,Te)}const jn=e=>e.code==="KeyR"&&e.altKey&&e.shiftKey&&(e.metaKey||e.ctrlKey);function Nn(){if(!(typeof window>"u")){if(window.addEventListener("keydown",e=>{jn(e)&&(e.preventDefault(),e.stopPropagation(),vn())},{capture:!0}),Ct(q),typeof matchMedia=="function")try{matchMedia("(prefers-color-scheme: dark)").addEventListener("change",q)}catch{}A=Sn(),A&&q()}}function En({credential:e,owner:t,team:n}){const[o]=u.useState(()=>Z()),[a,i]=u.useState(!1),[c,l]=u.useState(null);async function x(){i(!0),l(null);const f=await on(e,o);if(f.ok){location.replace("/");return}i(!1),l(f.error)}return r.jsx("main",{className:"flex min-h-screen items-center justify-center bg-app px-6 text-ink",children:r.jsxs("div",{className:"w-full max-w-[420px]",children:[r.jsx("h1",{className:"text-[20px] font-semibold",children:n?s("pair.browser.teamTitle",{team:n,owner:t}):s("pair.browser.title",{owner:t})}),r.jsx("p",{className:"mt-1.5 text-[14px] text-ink-secondary",children:s("pair.browser.notYou")}),c?r.jsx("p",{role:"alert",className:"mt-3 text-[13px] text-danger",children:c}):null,r.jsx("button",{type:"button",onClick:()=>{x()},disabled:a,className:"mt-5 w-full rounded-md bg-accent px-4 py-2 text-[14px] font-medium text-accent-ink disabled:opacity-50",children:s(a?"pair.signingIn":"pair.continue")})]})})}const Ne="bg-composer ring-1 ring-inset ring-ink/[0.07]",Cn="bg-composer ring-[0.5px] ring-ink/10",Po=`${Cn} shadow-(--shadow-float)`,dt="transition-colors duration-[120ms] hover:bg-[color-mix(in_srgb,var(--color-composer),var(--color-ink)_7%)]",Pn=`${dt} aria-expanded:bg-[color-mix(in_srgb,var(--color-composer),var(--color-ink)_7%)]`,Io="bg-[color-mix(in_srgb,var(--color-composer),var(--color-ink)_7%)]",To="focus-visible:outline-2 focus-visible:-outline-offset-2! focus-visible:outline-focus",mt="flex size-9 shrink-0 items-center justify-center rounded-full text-ink/90",pt="focus-visible:outline focus-visible:outline-2 focus-visible:outline-offset-2 focus-visible:outline-focus",_o=`${mt} ${Ne} ${Pn} ${pt}`,Ao=`${mt} ${Ne} ${dt} ${pt}`,Oo="flex size-10 shrink-0 items-center justify-center rounded-full border border-hairline bg-card text-ink hover:bg-raised focus-visible:outline focus-visible:outline-2 focus-visible:outline-offset-2 focus-visible:outline-focus",In="flex size-9 shrink-0 items-center justify-center rounded-xl text-ink-secondary hover:bg-raised/60 hover:text-ink focus-visible:outline focus-visible:outline-2 focus-visible:outline-offset-2 focus-visible:outline-focus";function Lo({query:e,onQuery:t,onClose:n}){return r.jsx("div",{"data-sidebar-search-pill":!0,className:"px-3 pb-2 pt-0.5",children:r.jsxs("div",{className:$("flex h-[34px] items-center gap-2 rounded-full pl-3 pr-1.5 text-ink-secondary focus-within:ring-focus",Ne),children:[r.jsx(Tt,{size:15,"aria-hidden":"true",className:"shrink-0"}),r.jsx("input",{autoFocus:!0,value:e,onChange:o=>t(o.target.value),onKeyDown:o=>{o.key==="Escape"&&(o.preventDefault(),n())},placeholder:s("sidebar.searchAria"),"aria-label":s("sidebar.searchAria"),className:"min-w-0 flex-1 bg-transparent text-[13px] text-ink placeholder:text-ink-tertiary focus:outline-none"}),r.jsx("button",{type:"button",onClick:n,"aria-label":s("sidebar.searchClose"),title:s("sidebar.searchClose"),className:"flex size-6 shrink-0 items-center justify-center rounded-full text-ink-tertiary hover:bg-raised hover:text-ink focus-visible:outline focus-visible:outline-2 focus-visible:outline-focus",children:r.jsx(_t,{size:14,"aria-hidden":"true"})})]})})}function Tn(e,{howTo:t=!1,onClosed:n}={}){return e.menu(t?{from:"howto"}:void 0).finally(()=>{t&&n?.()})}function Ro(e){Rt("cloud_howto",{result:"closed"}),e({type:"cloudHowTo",open:!1})}function We({text:e}){return r.jsxs("span",{className:"font-normal text-ink-secondary",children:[" · ",e]})}function _n(e){return e?.sleeps===!0?!0:e?.status==="paid"?!1:null}function An(e){const t=e&&!window.ogb?.remoteClient?.active?window.ogb?.cloudPlan:void 0,n=e||window.ogb?.remoteClient?.active?void 0:window.ogb?.cloudAccount,[o,a]=u.useState(null),[i,c]=u.useState(!1);return u.useEffect(()=>{if(!t)return;let l=!0;return t.state().then(x=>{l&&a(_n(x))}).catch(()=>{}),()=>{l=!1}},[t]),u.useEffect(()=>n?.onState(l=>c(l.waking===!0)),[n]),{sleeps:t?o:null,waking:i}}function On({cloudHome:e=!1,howTo:t=!1,onMenuClosed:n}){const o=window.ogb?.workspaces,[a,i]=u.useState(null),[c,l]=u.useState(!1),[x,f]=u.useState("");u.useEffect(()=>{let p=!0;const w=()=>{o?.state().then(E=>{p&&i(E)}).catch(()=>{})};w();const T=o?.onChanged?.(w);return()=>{p=!1,T?.()}},[o]);const b=An(e||a?.home===!0),d=b.sleeps===null?"":s(b.sleeps?"cloudSetup.sleepsWhenIdle":"cloudSetup.alwaysOn"),y=b.waking?s("cloudHome.waking"):"";return{bridge:o,current:a,cloudHome:e,open:c,error:x,onLine:d,waking:y,openMenu:()=>{!o||c||(f(""),l(!0),Tn(o,{howTo:t,onClosed:n}).catch(()=>f(s("sidebar.switchServerError"))).finally(()=>l(!1)))},switchable:!!o&&a?.home!==!0}}function Ln(e){const t=At(),n=r.jsx(Rn,{...e});return Ot(t)?r.jsx("div",{"data-switcher-beside-rail":!0,className:t.beside?"hidden":"contents md:hidden",children:n}):n}function Rn({compact:e=!1,inline:t=!1,pill:n=!1,rail:o=!1,cloudHome:a=!1,owner:i=null,howTo:c=!1,place:l,onMenuClosed:x}){const f=l||s("cloudSetup.myCloud"),{bridge:b,current:d,open:y,error:k,onLine:p,waking:w,openMenu:T}=On({cloudHome:a,howTo:c,onMenuClosed:x}),E=g=>p?`${g} · ${p}`:g;if(!b||d?.home===!0){if(!a&&!d?.home)return null;const g=i?s("sidebar.cloudOwner",{email:i}):"",j=`${E(f)}${g?` · ${g}`:""}`;return o?r.jsx("div",{"data-cloud-home-indicator":!0,"data-workspace-switcher":"rail",role:"img","aria-label":j,title:j,className:"flex size-9 items-center justify-center text-ink-secondary",children:r.jsx(K,{size:18,"aria-hidden":"true"})}):t?r.jsxs("div",{"data-cloud-home-indicator":!0,"data-workspace-switcher":"inline",title:j,className:n?"flex h-8 min-w-0 items-center gap-1 rounded-full bg-raised/50 px-3 text-[13px] font-medium text-ink":"flex min-w-0 items-center gap-1.5 px-1.5 text-[13px] font-medium text-ink",children:[r.jsx(K,{size:n?15:14,"aria-hidden":"true",className:n?"hidden shrink-0 text-ink-secondary @max-[124px]/sidebar-top:block":"shrink-0 text-ink-secondary"}),r.jsx("span",{className:n?"min-w-0 truncate @max-[124px]/sidebar-top:hidden":"min-w-0 truncate",children:f}),(p||g)&&r.jsxs("span",{className:"sr-only",children:[p?` · ${p}`:"",g?` · ${g}`:""]})]}):r.jsx("div",{"data-cloud-home-indicator":!0,className:$("py-1.5",e?"px-2":"px-3"),children:r.jsxs("div",{title:j,className:$("flex items-center gap-2 py-2 text-[13px] font-medium text-ink",e?"justify-center px-1":"px-2"),children:[r.jsx(K,{size:16,"aria-hidden":"true",className:"shrink-0 text-ink-secondary"}),e?r.jsx("span",{className:"sr-only",children:j}):r.jsxs("span",{className:"min-w-0 flex-1 truncate",children:[f,p&&r.jsx(We,{text:p}),g&&r.jsx("span",{className:"block truncate text-[12px] font-normal text-ink-secondary",children:g})]})]})})}const O=d?.profileName??(d?.local&&!d.localPath?s("place.local"):d?.name)??(a?f:s("sidebar.servers")),v=d?.local===!1||a&&!d?K:Lt,M=a?E(O):O,_=d?.origin?`${M} · ${d.origin}`:M,L=s("sidebar.switchServer",{name:M});return o?r.jsxs("div",{"data-workspace-switcher":"rail",className:"relative",children:[r.jsx("button",{type:"button","aria-label":L,"aria-haspopup":"menu","aria-expanded":y,"data-cloud-home-indicator":a||void 0,"data-tour":"server-switcher",title:_,onClick:T,className:$(In,"aria-expanded:bg-raised"),style:{WebkitAppRegion:"no-drag"},children:ae(d?.color)?r.jsx(se,{color:d?.color,size:18}):r.jsx(v,{size:18,"aria-hidden":"true"})}),k&&r.jsx("p",{role:"alert",className:"absolute bottom-0 left-full z-40 ml-2 w-56 rounded-md bg-menu px-2 py-1 text-[11px] text-danger shadow-lg",children:k}),w&&!k&&r.jsx("p",{role:"status","data-cloud-waking":!0,className:"absolute bottom-0 left-full z-40 ml-2 w-56 rounded-md bg-menu px-2 py-1 text-[11px] text-ink-secondary shadow-lg",children:w})]}):t?r.jsxs("div",{"data-workspace-switcher":"inline",className:"flex min-w-0",children:[r.jsxs("button",{type:"button","aria-label":L,"aria-haspopup":"menu","aria-expanded":y,"data-cloud-home-indicator":a||void 0,"data-tour":"server-switcher",title:_,onClick:T,className:n?"flex h-8 min-w-0 max-w-full items-center gap-1 overflow-hidden rounded-full bg-raised/50 pl-2.5 pr-1.5 text-left text-[13px] font-medium text-ink hover:bg-raised aria-expanded:bg-raised focus-visible:outline focus-visible:outline-2 focus-visible:outline-offset-2 focus-visible:outline-focus":"flex h-7 min-w-0 max-w-full items-center gap-1.5 overflow-hidden rounded-md px-1.5 text-left text-[13px] font-medium text-ink hover:bg-control focus-visible:outline focus-visible:outline-2 focus-visible:outline-offset-2 focus-visible:outline-focus",style:{WebkitAppRegion:"no-drag"},children:[ae(d?.color)?r.jsx(se,{color:d?.color,size:16}):r.jsx(v,{size:n?15:14,"aria-hidden":"true","data-switcher-icon":!0,className:n?"hidden shrink-0 text-ink-secondary @max-[124px]/sidebar-top:block":"shrink-0 text-ink-secondary"}),r.jsx("span",{className:n?"min-w-0 truncate @max-[124px]/sidebar-top:hidden":"min-w-0 truncate @max-[96px]/sidebar-top:hidden",children:O}),r.jsx(Oe,{size:n?12:11,"aria-hidden":"true",className:n?"shrink-0 text-ink-tertiary":"shrink-0 text-ink-secondary"})]}),k&&r.jsx("p",{role:"alert",className:"absolute right-2 top-full z-40 mt-1 w-56 max-w-[calc(100%-1rem)] rounded-md bg-menu px-2 py-1 text-[11px] text-danger shadow-lg",children:k}),w&&!k&&r.jsx("p",{role:"status","data-cloud-waking":!0,className:"absolute right-2 top-full z-40 mt-1 w-56 max-w-[calc(100%-1rem)] rounded-md bg-menu px-2 py-1 text-[11px] text-ink-secondary shadow-lg",children:w})]}):r.jsxs("div",{className:$("py-1.5",e?"px-2":"px-3"),children:[r.jsxs("button",{type:"button","aria-label":L,"aria-haspopup":"menu","aria-expanded":y,"data-cloud-home-indicator":a||void 0,"data-tour":"server-switcher",title:_,onClick:T,className:$("flex w-full items-center gap-2 rounded-lg py-2 text-left text-[13px] font-medium text-ink hover:bg-control focus-visible:outline focus-visible:outline-2 focus-visible:outline-offset-2 focus-visible:outline-focus",e?"justify-center px-1":"px-2"),style:{WebkitAppRegion:"no-drag"},children:[ae(d?.color)?r.jsx(se,{color:d?.color,size:20}):r.jsx(v,{size:16,className:"shrink-0 text-ink-secondary"}),!e&&r.jsxs(r.Fragment,{children:[r.jsxs("span",{className:"min-w-0 flex-1 truncate",children:[O,a&&p&&r.jsx(We,{text:p})]}),r.jsx(Oe,{size:13,className:"shrink-0 text-ink-secondary"})]})]}),k&&r.jsx("p",{role:"alert",className:"mt-1 text-[11px] text-danger",children:k}),w&&!k&&r.jsx("p",{role:"status","data-cloud-waking":!0,className:"mt-1 text-[11px] text-ink-secondary",children:w})]})}function $n(e,t,n="start",o=0){const a=t.getBoundingClientRect().top-e.getBoundingClientRect().top+e.scrollTop;e.scrollTop=Math.max(0,n==="center"?a-(e.clientHeight-(t.offsetHeight??0))/2:a-o)}function $o(e){for(let t=e.parentElement;t;t=t.parentElement){const n=getComputedStyle(t).overflowY;if((n==="auto"||n==="scroll")&&t.scrollHeight>t.clientHeight)return t}return null}const Ho=()=>({type:"toggleAppSettings",open:!0,section:"phone",phonePairing:!0});function Mo(e){return $t(e).kind!=="paid"||Ht(e)?null:e?.status==="connected"&&e.machine?.status==="ready"?"ready":"not-ready"}const Hn="data-phone-pairing-action";function Do(e,t=n=>window.requestAnimationFrame(n)){return e?(t(()=>{const n=e.closest?.("[data-settings-scroll]");n&&$n(n,e,"start",(n.querySelector("[data-settings-header]")?.offsetHeight??96)+8),(e.querySelector(`[${Hn}]:not([disabled])`)??e).focus({preventScroll:!0})}),!0):!1}let he=!1;function Fo(e,t=typeof window<"u"&&!!window.ogb){const n=new URL(e);return n.searchParams.get("desktop-settings")!=="phone"?null:(he=t&&n.searchParams.get("pair")==="open",n.searchParams.delete("desktop-settings"),n.searchParams.delete("pair"),`${n.pathname}${n.search}${n.hash}`)}function Bo(){const e=he;return he=!1,e}function le(e){const t=new URLSearchParams(e);if(t.get("desktop-settings")==="phone")return t.get("pair")==="open"?"/?desktop-settings=phone&pair=open":"/?desktop-settings=phone";const n=t.get("next");if(n&&/^\/(?!\/)/.test(n)&&!n.startsWith("/pair")&&!/[\\\s]/.test(n))return n;const o=t.get("thread");if(o===null)return"/";const a=new URLSearchParams({thread:o}),i=t.get("bot");return i!==null&&a.set("bot",i),`/?${a}`}const Mn="23456789ABCDEFGHJKLMNPQRSTUVWXYZ",Dn=12,Fn="omb_pair_",Bn=/^omb_pair_[A-Za-z0-9_-]{43}$/;function ft(e){return e.toUpperCase().replace(/[^A-Z0-9]/g,"").replace(/0/g,"O").replace(/1/g,"I")}function zn(e){return ft(e).match(/.{1,4}/g)?.join("-")??e}const Un={emailCode:"serverError.pair.emailCode",oldCode:"serverError.pair.oldCode",scriptKey:"serverError.pair.scriptKey",notACode:"serverError.pair.notACode"};function Wn(e){let t;try{t=new URL(e)}catch{return null}const n=new URLSearchParams(t.hash.replace(/^#/,""));return t.searchParams.get("token")??t.searchParams.get("code")??n.get("code")}function Ee(e){let t=e.trim();if(!t)return{kind:"empty"};if(/^[a-z][a-z0-9+.-]*:\/\//i.test(t)){const a=Wn(t);if(!a)return{kind:"wrong",problem:"notACode"};t=a.trim()}if(t.startsWith("omb_sess_"))return{kind:"wrong",problem:"scriptKey"};if(t.startsWith(Fn))return Bn.test(t)?{kind:"credential",credential:t}:{kind:"wrong",problem:"notACode"};const n=t.replace(/[\s-]/g,"");if(/^\d{8}$/.test(n))return{kind:"wrong",problem:"emailCode"};if(/^\d{6}$/.test(n))return{kind:"wrong",problem:"oldCode"};const o=ft(t);return o.length!==Dn||[...o].some(a=>!Mn.includes(a))?{kind:"wrong",problem:"notACode"}:{kind:"code",code:o}}const F="mt-1 w-full rounded-md border border-hairline/40 bg-inset px-3 py-2 text-[14px] text-ink outline-none focus:border-accent-border",Ke="mt-5 w-full rounded-md bg-accent px-4 py-2 text-[14px] font-medium text-accent-ink disabled:opacity-50",B="mt-4 block text-[12px] font-medium text-ink-secondary";function Kn(e,t=typeof window<"u"&&!!window.ogb?.workspaces){return!!e&&t}function Vn({mode:e,sent:t,email:n,cloudHome:o}){return e==="email"?t?s("pair.intro.emailSent",{email:n}):s("pair.intro.email"):o?s("pair.intro.cloud",{app:H(),open:s("cloudHome.connect"),section:s("settings.section.cloudAccount")}):s("pair.intro.code")}function Gn(e){const t=Ee(e);return t.kind==="wrong"&&t.problem!=="notACode"?s(Un[t.problem]):null}function Xn(e){const t=Ee(e).kind;return t==="code"||t==="credential"}function Yn(e,t){const n=Ee(t),o=n.kind==="code"?`&code=${encodeURIComponent(zn(n.code))}`:"";return`openmausbot://pair?address=${encodeURIComponent(e)}${o}`}function qn(e){return e.protocol==="http:"&&!Mt(e.hostname)}function Ve(e,t=Jt()){if(!e?.capabilities.cloudTeam||typeof t!="string")return null;try{const n=new URL(t),o=n.protocol==="http:"&&["127.0.0.1","localhost","[::1]"].includes(n.hostname);return(n.protocol==="https:"||o)&&!n.username&&!n.password&&!n.hash?n.href:null}catch{return null}}function Jn(e,t){return e?.capabilities.cloudTeam?e.label:e?.capabilities.cloudHome?s("pair.myCloud"):s(t==="email"?"pair.signInTo":"pair.connectTo",{name:e?.label??s("pair.thisOpenMausBot",{app:H()})})}function Zn({team:e}){return r.jsx("main",{"data-team-left":!0,className:"flex min-h-screen items-center justify-center bg-app px-6 text-ink",children:r.jsx("p",{role:"status",className:"max-w-[420px] text-[16px]",children:s("homeLine.left",{name:e??s("pair.thisOpenMausBot",{app:H()})})})})}function G({initialCode:e,initialEmail:t=null,reason:n}){const[o,a]=u.useState(e??""),[i,c]=u.useState(Qe()),[l,x]=u.useState(null),[f,b]=u.useState(null),[d,y]=u.useState(!1),[k,p]=u.useState(null),[w,T]=u.useState(()=>Z()),[E,O]=u.useState(t&&!e?"email":"code"),[v,M]=u.useState(t??""),[_,L]=u.useState(""),[g,j]=u.useState(!1),[ne,xt]=u.useState(()=>Kn(e));u.useEffect(()=>{if(!ne||!e)return;let h=!0;return ue({code:e,label:i,attemptId:w}).then(C=>{if(h){if(C.ok){location.replace(le(location.search));return}xt(!1),p(C.error)}}),()=>{h=!1}},[]),u.useEffect(()=>{fetch("/.well-known/openmausbot/environment").then(h=>h.ok?h.json():null).then(h=>{x(h)}).catch(()=>{x(null)}),ke().then(b)},[]);const oe=Zt(f),gt=l?.capabilities.emailSignIn===!0,D=l?.capabilities.cloudHome===!0,bt=!D&&l?.capabilities.cloudTeam!==!0,Pe=Gn(o),W=typeof location<"u"&&typeof location.protocol=="string"?location:null;async function yt(h){h.preventDefault(),y(!0),p(null);const C=await ue({code:o,label:i,attemptId:w});if(y(!1),C.ok){location.replace(le(location.search));return}p(C.error)}async function kt(h){h.preventDefault(),y(!0),p(null);const C=g?await an({email:v,code:_,label:i}):await rn(v);if(y(!1),!C.ok){p(C.error);return}if(g){location.replace(le(location.search));return}j(!0)}function Ie(h){O(h),p(null)}return r.jsxs("main",{className:"flex min-h-screen items-center justify-center bg-app px-6 text-ink",children:[r.jsx("div",{className:"absolute left-3 top-12 max-w-[280px]",children:r.jsx(Ln,{})}),r.jsxs("div",{className:"w-full max-w-[420px]",children:[W&&qn(W)?r.jsx("p",{role:"alert",className:"mb-4 rounded-md border border-warning/30 bg-warning/10 px-3 py-2 text-[13px] text-warning",children:s("pair.notEncrypted")}):null,ne?r.jsx("p",{role:"status",className:"text-[20px] font-semibold",children:D?s("pair.openingCloud"):s("pair.connectingTo",{name:l?.label??s("pair.thisOpenMausBot")})}):r.jsxs(r.Fragment,{children:[r.jsx("h1",{className:"text-[20px] font-semibold",children:Jn(l,E)}),r.jsxs("p",{className:"mt-1.5 text-[14px] leading-relaxed text-ink-secondary",children:[l&&!D?`${s("pair.version",{version:l.version,platform:l.platform})} `:"",Vn({mode:E,sent:g,email:v,cloudHome:D})]}),Re(n)&&!oe?r.jsx("p",{className:"mt-3 text-[13px] text-ink-secondary",children:Re(n)}):null,k&&D&&e?r.jsx("p",{className:"mt-3 text-[13px] text-ink-secondary",children:s("pair.expired",{app:H(),open:s("cloudHome.connect"),section:s("settings.section.cloudAccount")})}):null,!oe&&Ve(l)?r.jsxs("div",{"data-team-sign-in":!0,className:"mt-4 flex flex-col items-start gap-1.5",children:[r.jsx("a",{href:Ve(l),className:"rounded-md bg-accent px-4 py-2 text-[14px] font-medium text-accent-ink",children:s("pair.team.open",{team:l.label})}),r.jsx("p",{className:"text-[13px] text-ink-secondary",children:s("pair.team.openHint")})]}):null]}),ne?null:oe?r.jsxs("p",{className:"mt-4 text-[14px]",children:[s("pair.alreadyConnected")," ",r.jsx("a",{href:"/",className:"text-accent underline",children:s("pair.openApp")})]}):E==="email"?r.jsxs("form",{onSubmit:kt,children:[r.jsx("label",{className:B,htmlFor:"signin-email",children:s("cloudBuy.signIn.email")}),r.jsx("input",{id:"signin-email",type:"email",value:v,onChange:h=>{M(h.target.value),j(!1),L("")},autoComplete:"email",inputMode:"email",spellCheck:!1,className:F}),g?r.jsxs(r.Fragment,{children:[r.jsx("label",{className:B,htmlFor:"signin-code",children:s("pair.emailCode")}),r.jsx("input",{id:"signin-code",value:_,onChange:h=>L(h.target.value),placeholder:"12345678",autoComplete:"one-time-code",inputMode:"numeric",spellCheck:!1,className:`${F} font-mono text-[15px] tracking-[0.12em]`}),r.jsx("label",{className:B,htmlFor:"signin-label",children:s("pair.deviceLabel")}),r.jsx("input",{id:"signin-label",value:i,onChange:h=>c(h.target.value),maxLength:80,className:F})]}):null,k?r.jsx("p",{className:"mt-3 text-[13px] text-danger",children:k}):null,r.jsx("button",{type:"submit",disabled:d||!v.includes("@")||g&&_.replace(/\D/g,"").length<8,className:Ke,children:s(d?g?"pair.signingIn":"pair.sending":g?"pair.signIn":"cloudBuy.signIn.send")}),g?r.jsx("button",{type:"button",onClick:()=>j(!1),className:"mt-3 w-full text-[13px] text-ink-secondary underline",children:s("pair.resend")}):null,r.jsx("button",{type:"button",onClick:()=>Ie("code"),className:"mt-3 w-full text-[13px] text-ink-secondary underline",children:s("pair.useCode")})]}):r.jsxs("form",{onSubmit:yt,children:[r.jsx("label",{className:B,htmlFor:"pair-code",children:s("pair.code")}),r.jsx("input",{id:"pair-code",value:o,onChange:h=>{a(h.target.value),T(Z())},placeholder:"XXXX-XXXX-XXXX","aria-describedby":e&&o===e?"pair-code-from-link":void 0,autoComplete:"one-time-code",autoCapitalize:"characters",spellCheck:!1,className:`${F} font-mono text-[15px] tracking-[0.12em]`}),e&&o===e?r.jsx("p",{id:"pair-code-from-link",className:"mt-1 text-[12px] text-ink-secondary",children:s("pair.fromLink")}):null,r.jsx("label",{className:B,htmlFor:"pair-label",children:s("pair.deviceLabel")}),r.jsx("input",{id:"pair-label",value:i,onChange:h=>c(h.target.value),maxLength:80,className:F}),Pe?r.jsx("p",{role:"alert",className:"mt-3 text-[13px] text-danger",children:Pe}):k?r.jsx("p",{className:"mt-3 text-[13px] text-danger",children:k}):null,r.jsx("button",{type:"submit",disabled:d||!Xn(o),className:Ke,children:s(d?"pair.connecting":"pair.connect")}),W?.origin?r.jsxs("p",{className:"mt-3 text-[13px] text-ink-secondary",children:[s("pair.onPhone")," ",r.jsx("a",{href:Yn(W.origin,o),className:"text-accent underline",children:s("pair.openInApp",{app:H()})})]}):null,bt?r.jsxs("p",{className:"mt-3 text-[13px] text-ink-secondary",children:[s("pair.noCode")," ",r.jsx("code",{className:"select-all rounded bg-inset px-1.5 py-0.5 text-[12px] text-ink",children:"npx @seira-bot/seira pair"})]}):null,gt?r.jsxs("p",{className:"mt-5 border-t border-hairline/40 pt-4 text-[13px] text-ink-secondary",children:[s("pair.invitedByEmail")," ",r.jsx("button",{type:"button",onClick:()=>Ie("email"),className:"text-accent underline",children:s("pair.useEmail")})]}):null]})]})]})}const zo="cloud-welcome-done",Qn="unauthorized: you are no longer in this team",eo=/^announcements-read-(\d{1,16})$/;function Uo(e){let t=null;for(const n of e){const o=Number(eo.exec(n)?.[1]??NaN);Number.isSafeInteger(o)&&(t===null||o>t)&&(t=o)}return t}const Ge=[["reserving","cloudHome.step.reserving"],["storage","cloudHome.step.storage"],["starting","cloudHome.step.starting"],["checking","cloudHome.step.checking"]];function to({step:e}){const t=Ge.findIndex(([n])=>n===e);return r.jsx("ol",{"data-cloud-setup":e,className:"flex flex-col gap-1 text-[13px]",children:Ge.map(([n,o],a)=>r.jsx("li",{"aria-current":a===t?"step":void 0,className:a===t?"font-medium text-ink":a<t?"text-ink-secondary line-through decoration-ink-secondary/40":"text-ink-secondary",children:s(o)},n))})}const no={stopped:"cloudHome.stopped","payment-problem":"cloudHome.paymentProblem",failed:"cloudHome.failed"},Xe={host:"cloudHome.unreachableHost",no_answer:"cloudHome.unreachable"};function oo(e,t=Date.now()){const n=new Date(e).getFullYear()!==new Date(t).getFullYear();return new Intl.DateTimeFormat(Dt(),{day:"numeric",month:"long",...n?{year:"numeric"}:{}}).format(new Date(e))}function ro(e,t=Date.now()){const n=e?.name??null,o=(a,i)=>n?s(i,{name:n}):s(a);return e?.screen==="setup"?{title:o("homeScreen.setup","homeScreen.setupNamed"),body:s(e.slow?"cloudHome.slow":"homeScreen.setupBody"),reason:null,action:null,busy:!0}:e?.screen==="offline"?{title:o("homeScreen.offline","homeScreen.offlineNamed"),body:s("homeScreen.offlineBack"),reason:e.cause&&Object.hasOwn(Xe,e.cause)?s(Xe[e.cause]):e.reason??null,action:"retry",busy:!1}:e?.screen==="signin"?{title:o("homeScreen.signIn","homeScreen.signInNamed"),body:s(e.other?"homeScreen.signInOther":"homeScreen.signInEnded"),reason:null,action:"sign-in",busy:!1}:e?.screen==="plan"&&e.member&&e.machine!=="failed"?{title:o("homeScreen.plan","homeScreen.planNamed"),body:s("cloudHome.stoppedMember"),reason:null,action:null,busy:!1}:e?.screen==="plan"?{title:o("homeScreen.plan","homeScreen.planNamed"),body:s(no[e.machine]??"cloudHome.failed"),reason:null,action:e.machine==="failed"?null:"manage",busy:!1}:e?.screen==="ended"?{title:o("cloudHome.ended","cloudHome.endedNamed"),body:e.deleteAt?s("cloudHome.endedFiles",{date:oo(e.deleteAt,t)}):null,reason:null,action:"buy",busy:!1}:e?.screen==="checkout"?{title:o("cloudHome.checkout","cloudHome.checkoutNamed"),body:null,reason:null,action:"continue",busy:!1}:e?.screen==="payment"?{title:o("cloudHome.payment","cloudHome.paymentNamed"),body:s("cloudHome.paymentBody"),reason:null,action:"card",busy:!1}:e?.screen==="waking"?{title:s("homeScreen.waking"),body:null,reason:null,action:null,busy:!0}:e?.screen==="moving"?{title:o("homeScreen.moving","homeScreen.movingNamed"),body:null,reason:null,action:null,busy:!0}:{title:o("homeScreen.opening","homeScreen.openingNamed"),body:null,reason:null,action:null,busy:!0}}function ao(e,t){return e?.screen==="offline"?"sad":t.busy?"working":t.action?"attention":"idle"}const so={retry:"cloudHome.tryAgain",buy:"cloudHome.buyAgain",continue:"cloudHome.continue",card:"cloudHome.updateCard"};function io({name:e,remove:t}){const[n,o]=u.useState(!1),[a,i]=u.useState(!1),[c,l]=u.useState(null),x=()=>{i(!0),l(null),t().then(f=>{i(!1),f!=="removed"&&f!=="gone"&&(o(!1),l(f==="refused"?"refused":"failed"))},()=>{i(!1),o(!1),l("failed")})};return r.jsxs("div",{"data-home-remove":!0,className:"flex flex-col items-start gap-2",children:[n?r.jsxs("div",{role:"alertdialog","aria-label":s("rail.remove"),className:"flex flex-col gap-2 rounded-xl border border-hairline/70 bg-card/70 px-4 py-3",children:[r.jsx("p",{className:"text-[13px] leading-relaxed text-ink",children:s("rail.removeAsk",{name:e})}),r.jsxs("div",{className:"flex gap-2",children:[r.jsx("button",{type:"button","data-home-remove-confirm":!0,className:"ui-button ui-button-primary",disabled:a,onClick:x,children:s("rail.removeYes")}),r.jsx("button",{type:"button",className:"ui-button",disabled:a,onClick:()=>o(!1),children:s("rail.removeNo")})]})]}):r.jsx("button",{type:"button","data-home-remove-ask":!0,className:"text-[13px] text-ink-secondary underline-offset-2 hover:text-ink hover:underline",onClick:()=>{l(null),o(!0)},children:s("rail.remove")}),c&&r.jsx("p",{role:"alert",className:"text-[13px] text-danger",children:s(c==="refused"?"rail.removeRefused":"rail.removeFailed")})]})}function lo({bridge:e,manage:t}){const[n,o]=u.useState(null),[a,i]=u.useState(!1);u.useEffect(()=>{let y=!0;const k=e.onState(w=>o(w)),p=()=>{e.retry().then(w=>{y&&o(w)}).catch(()=>{})};return e.state().then(w=>{y&&o(w)}).catch(()=>{}).then(p),window.addEventListener("online",p),window.addEventListener("focus",p),()=>{y=!1,k(),window.removeEventListener("online",p),window.removeEventListener("focus",p)}},[e]);const c=ro(n),l=y=>{i(!1),y().catch(()=>i(!0))},x=window.ogb?.cloudAdd?.reopen,f={retry:()=>e.retry().then(y=>o(y)),...t?{manage:t,buy:t,card:t,continue:async()=>{x&&await x().catch(()=>!1)||await t()}}:{}},b=c.action&&c.action!=="sign-in"&&c.action!=="manage"?c.action:null,d=(n?.screen==="ended"||n?.screen==="payment")&&n.removable===!0&&typeof e.remove=="function";return r.jsx("main",{"data-home-screen":n?.screen??"opening",className:"flex min-h-screen items-center justify-center bg-app px-6 text-ink",style:{WebkitAppRegion:"drag"},children:r.jsxs("div",{className:"flex w-full max-w-[420px] flex-col items-start gap-3",style:{WebkitAppRegion:"no-drag"},children:[r.jsx(qe,{state:ao(n,c),size:96}),r.jsx("p",{role:"status",className:"text-[20px] font-semibold",children:c.title}),c.body&&r.jsx("p",{className:"text-[14px] leading-relaxed text-ink-secondary",children:c.body}),n?.screen==="setup"&&r.jsx(to,{step:n.step??"reserving"}),c.reason&&r.jsx("p",{"data-home-reason":!0,className:"text-[13px] leading-relaxed text-ink-secondary",children:c.reason}),c.action==="sign-in"&&r.jsx("button",{type:"button",className:"ui-button ui-button-primary mt-2",onClick:()=>l(()=>e.signIn()),children:s("homeScreen.signInButton")}),c.action==="manage"&&t&&r.jsx("button",{type:"button",className:"ui-button mt-2",onClick:()=>l(t),children:s("cloudAccount.manageInBrowser")}),b&&f[b]&&r.jsx("button",{type:"button","data-home-action":b,className:b==="retry"?"ui-button mt-2":"ui-button ui-button-primary mt-2",onClick:()=>l(f[b]),children:s(so[b])}),d&&r.jsx(io,{name:n.name??s("cloudSetup.myCloud"),remove:()=>e.remove()}),a&&r.jsx("p",{role:"alert",className:"text-[13px] text-danger",children:s("cloudAccount.actionFailed")})]})})}function co({bridge:e,fallback:t}){const[n,o]=u.useState(!1);return u.useEffect(()=>{e.repair().catch(()=>o(!0))},[e]),n?r.jsx(r.Fragment,{children:t}):r.jsx("main",{"data-home-screen":"opening",className:"flex min-h-screen items-center justify-center bg-app px-6 text-ink",children:r.jsxs("div",{className:"flex w-full max-w-[420px] flex-col items-start gap-3",children:[r.jsx(qe,{state:"working",size:96}),r.jsx("p",{role:"status",className:"text-[20px] font-semibold",children:s("homeScreen.opening")})]})})}const Ce="omb.session-ended";let xe=!1,ce=null;const ge=new Set;function Wo(){xe||ce||(ce=ke().then(e=>{if(e.kind==="unauthenticated"){xe=!0;try{sessionStorage.setItem(Ce,"1")}catch{}for(const t of ge)t()}}).finally(()=>{ce=null}))}function Ye(){return xe}function Ko(){return u.useSyncExternalStore(e=>(ge.add(e),()=>ge.delete(e)),Ye,Ye)}function uo(){try{return sessionStorage.getItem(Ce)==="1"}catch{return!1}}function mo(){try{sessionStorage.removeItem(Ce)}catch{}}Ft();ye(Bt());zt(Ut());sn();Wt(Kt());Nn();const J=Vt(),po=new Set(["/home","/pair","/desktop-viewer"]),ht=()=>Je(()=>import("./App-h8WTNY4l.js").then(e=>e.l3),__vite__mapDeps([0,1,2,3,4,5,6])).catch(e=>({default:()=>{throw e}})),fo=po.has(location.pathname)?null:ht(),ho=()=>fetch("/.well-known/openmausbot/environment").then(e=>e.json()).then(e=>e.capabilities?.cloudTeam===!0&&typeof e.label=="string"?e.label:null,()=>null);async function xo(){const e=window.ogb?.home;if(location.pathname==="/home"&&e)return r.jsx(lo,{bridge:e,manage:window.ogb?.cloudPlan?.manage});if(location.pathname==="/pair"){const o=en();if(o){const a=await nn(o);return await J,a?r.jsx(En,{credential:o,owner:a.owner,team:a.team}):r.jsx(G,{initialCode:null,reason:s("pair.browser.signInFailed")})}return r.jsx(G,{initialCode:Qt(),initialEmail:tn()})}const t=await ke();if(t.kind==="unauthenticated"){if(await J,t.error===Qn)return r.jsx(Zn,{team:await ho()});const o=r.jsx(G,{initialCode:null,reason:uo()?s("pair.sessionEnded"):t.error});return e?r.jsx(co,{bridge:e,fallback:o}):o}if(mo(),t.kind==="session"&&qt(t.teamSignIn),t.kind==="loopback"&&t.trust==="service")return await J,r.jsx(G,{initialCode:null,reason:s("pair.serviceTrust")});if(location.pathname==="/desktop-viewer"){const{DesktopViewer:o}=await Je(async()=>{const{DesktopViewer:a}=await import("./DesktopViewer-YvIV04Lf.js");return{DesktopViewer:a}},__vite__mapDeps([7,1,2,8,9,6,5,10]));return r.jsx(o,{})}const{default:n}=await(fo??ht());return ve(),r.jsx(n,{})}document.title=H();Promise.all([Gt(),xo(),J]).then(([,e])=>{Xt.createRoot(document.getElementById("root")).render(r.jsx(u.StrictMode,{children:r.jsx(Yt,{children:e})}))});export{eo as A,Ao as B,to as C,ko as D,Po as E,Ln as F,Lo as G,Cn as H,de as I,Io as J,zo as K,Ko as L,G as M,Fo as N,Oo as P,_o as S,nt as T,Do as a,kn as b,vn as c,wo as d,Co as e,Eo as f,$o as g,$n as h,yo as i,No as j,Pn as k,ve as l,Ne as m,Wo as n,To as o,Ho as p,bo as q,ke as r,jo as s,Bo as t,So as u,Uo as v,vo as w,Mo as x,On as y,Ro as z};
@@ -1,2 +1,2 @@
1
- import{_ as e,l as s,T as n,d as i}from"./mermaid.core-BK1qxlD4.js";import{p}from"./cynefin-EF2NZ3EQ-C7I3qmqf.js";import"./styles-DOJOOIp4.js";import"./step-CkmJJ7wq.js";var g={parse:e(async r=>{const a=await p("info",r);s.debug(a)},"parse")},d={version:"12.1.0"},v=e(()=>d.version,"getVersion"),m={getVersion:v},c=e((r,a,o)=>{s.debug(`rendering info diagram
1
+ import{_ as e,l as s,T as n,d as i}from"./mermaid.core-B1mlFiOp.js";import{p}from"./cynefin-EF2NZ3EQ-B_Xq3hQ3.js";import"./styles-3g-ZPS7M.js";import"./step-CkmJJ7wq.js";var g={parse:e(async r=>{const a=await p("info",r);s.debug(a)},"parse")},d={version:"12.1.0"},v=e(()=>d.version,"getVersion"),m={getVersion:v},c=e((r,a,o)=>{s.debug(`rendering info diagram
2
2
  `+r);const t=n(a);i(t,100,400,!0),t.append("g").append("text").attr("x",100).attr("y",40).attr("class","version").attr("font-size",32).style("text-anchor","middle").text(`v${o}`)},"draw"),l={draw:c},w={parser:g,db:m,renderer:l};export{w as diagram};
@@ -1,4 +1,4 @@
1
- import{_ as o,c as ot,Y as ut,T as dt,ae as yt,D as ft,m as pt,v as it,a as gt,b as kt,g as mt,s as wt,x as _t,d as bt}from"./mermaid.core-BK1qxlD4.js";import"./styles-DOJOOIp4.js";import"./step-CkmJJ7wq.js";var J=(function(){var e=o(function(T,t,s,i){for(s=s||{},i=T.length;i--;s[T[i]]=t);return s},"o"),h=[1,4],r=[1,14],a=[1,12],l=[1,13],y=[6,7,8],f=[1,20],d=[1,18],m=[1,19],u=[6,7,11],k=[1,6,13,14],g=[1,23],_=[1,24],x=[1,6,7,11,13,14],D={trace:o(function(){},"trace"),yy:{},symbols_:{error:2,start:3,ishikawa:4,spaceLines:5,SPACELINE:6,NL:7,ISHIKAWA:8,document:9,stop:10,EOF:11,statement:12,SPACELIST:13,TEXT:14,$accept:0,$end:1},terminals_:{2:"error",6:"SPACELINE",7:"NL",8:"ISHIKAWA",11:"EOF",13:"SPACELIST",14:"TEXT"},productions_:[0,[3,1],[3,2],[5,1],[5,2],[5,2],[4,2],[4,3],[10,1],[10,1],[10,1],[10,2],[10,2],[9,3],[9,2],[12,2],[12,1],[12,1],[12,1]],performAction:o(function(t,s,i,c,p,n,v){var w=n.length-1;switch(p){case 6:case 7:return c;case 15:c.addNode(n[w-1].length,n[w].trim());break;case 16:c.addNode(0,n[w].trim());break}},"anonymous"),table:[{3:1,4:2,5:3,6:[1,5],8:h},{1:[3]},{1:[2,1]},{4:6,6:[1,7],7:[1,8],8:h},{6:r,7:[1,10],9:9,12:11,13:a,14:l},e(y,[2,3]),{1:[2,2]},e(y,[2,4]),e(y,[2,5]),{1:[2,6],6:r,12:15,13:a,14:l},{6:r,9:16,12:11,13:a,14:l},{6:f,7:d,10:17,11:m},e(u,[2,18],{14:[1,21]}),e(u,[2,16]),e(u,[2,17]),{6:f,7:d,10:22,11:m},{1:[2,7],6:r,12:15,13:a,14:l},e(k,[2,14],{7:g,11:_}),e(x,[2,8]),e(x,[2,9]),e(x,[2,10]),e(u,[2,15]),e(k,[2,13],{7:g,11:_}),e(x,[2,11]),e(x,[2,12])],defaultActions:{2:[2,1],6:[2,2]},parseError:o(function(t,s){if(s.recoverable)this.trace(t);else{var i=new Error(t);throw i.hash=s,i}},"parseError"),parse:o(function(t){var s=this,i=[0],c=[],p=[null],n=[],v=this.table,w="",I=0,$=0,L=2,A=1,C=n.slice.call(arguments,1),b=Object.create(this.lexer),S={yy:{}};for(var P in this.yy)Object.prototype.hasOwnProperty.call(this.yy,P)&&(S.yy[P]=this.yy[P]);b.setInput(t,S.yy),S.yy.lexer=b,S.yy.parser=this,typeof b.yylloc>"u"&&(b.yylloc={});var R=b.yylloc;n.push(R);var G=b.options&&b.options.ranges;typeof S.yy.parseError=="function"?this.parseError=S.yy.parseError:this.parseError=Object.getPrototypeOf(this).parseError;function X(B){i.length=i.length-2*B,p.length=p.length-B,n.length=n.length-B}o(X,"popStack");function tt(){var B;return B=c.pop()||b.lex()||A,typeof B!="number"&&(B instanceof Array&&(c=B,B=c.pop()),B=s.symbols_[B]||B),B}o(tt,"lex");for(var M,W,N,K,F={},U,V,et,Y;;){if(W=i[i.length-1],this.defaultActions[W]?N=this.defaultActions[W]:((M===null||typeof M>"u")&&(M=tt()),N=v[W]&&v[W][M]),typeof N>"u"||!N.length||!N[0]){var q="";Y=[];for(U in v[W])this.terminals_[U]&&U>L&&Y.push("'"+this.terminals_[U]+"'");b.showPosition?q="Parse error on line "+(I+1)+`:
1
+ import{_ as o,c as ot,Y as ut,T as dt,ae as yt,D as ft,m as pt,v as it,a as gt,b as kt,g as mt,s as wt,x as _t,d as bt}from"./mermaid.core-B1mlFiOp.js";import"./styles-3g-ZPS7M.js";import"./step-CkmJJ7wq.js";var J=(function(){var e=o(function(T,t,s,i){for(s=s||{},i=T.length;i--;s[T[i]]=t);return s},"o"),h=[1,4],r=[1,14],a=[1,12],l=[1,13],y=[6,7,8],f=[1,20],d=[1,18],m=[1,19],u=[6,7,11],k=[1,6,13,14],g=[1,23],_=[1,24],x=[1,6,7,11,13,14],D={trace:o(function(){},"trace"),yy:{},symbols_:{error:2,start:3,ishikawa:4,spaceLines:5,SPACELINE:6,NL:7,ISHIKAWA:8,document:9,stop:10,EOF:11,statement:12,SPACELIST:13,TEXT:14,$accept:0,$end:1},terminals_:{2:"error",6:"SPACELINE",7:"NL",8:"ISHIKAWA",11:"EOF",13:"SPACELIST",14:"TEXT"},productions_:[0,[3,1],[3,2],[5,1],[5,2],[5,2],[4,2],[4,3],[10,1],[10,1],[10,1],[10,2],[10,2],[9,3],[9,2],[12,2],[12,1],[12,1],[12,1]],performAction:o(function(t,s,i,c,p,n,v){var w=n.length-1;switch(p){case 6:case 7:return c;case 15:c.addNode(n[w-1].length,n[w].trim());break;case 16:c.addNode(0,n[w].trim());break}},"anonymous"),table:[{3:1,4:2,5:3,6:[1,5],8:h},{1:[3]},{1:[2,1]},{4:6,6:[1,7],7:[1,8],8:h},{6:r,7:[1,10],9:9,12:11,13:a,14:l},e(y,[2,3]),{1:[2,2]},e(y,[2,4]),e(y,[2,5]),{1:[2,6],6:r,12:15,13:a,14:l},{6:r,9:16,12:11,13:a,14:l},{6:f,7:d,10:17,11:m},e(u,[2,18],{14:[1,21]}),e(u,[2,16]),e(u,[2,17]),{6:f,7:d,10:22,11:m},{1:[2,7],6:r,12:15,13:a,14:l},e(k,[2,14],{7:g,11:_}),e(x,[2,8]),e(x,[2,9]),e(x,[2,10]),e(u,[2,15]),e(k,[2,13],{7:g,11:_}),e(x,[2,11]),e(x,[2,12])],defaultActions:{2:[2,1],6:[2,2]},parseError:o(function(t,s){if(s.recoverable)this.trace(t);else{var i=new Error(t);throw i.hash=s,i}},"parseError"),parse:o(function(t){var s=this,i=[0],c=[],p=[null],n=[],v=this.table,w="",I=0,$=0,L=2,A=1,C=n.slice.call(arguments,1),b=Object.create(this.lexer),S={yy:{}};for(var P in this.yy)Object.prototype.hasOwnProperty.call(this.yy,P)&&(S.yy[P]=this.yy[P]);b.setInput(t,S.yy),S.yy.lexer=b,S.yy.parser=this,typeof b.yylloc>"u"&&(b.yylloc={});var R=b.yylloc;n.push(R);var G=b.options&&b.options.ranges;typeof S.yy.parseError=="function"?this.parseError=S.yy.parseError:this.parseError=Object.getPrototypeOf(this).parseError;function X(B){i.length=i.length-2*B,p.length=p.length-B,n.length=n.length-B}o(X,"popStack");function tt(){var B;return B=c.pop()||b.lex()||A,typeof B!="number"&&(B instanceof Array&&(c=B,B=c.pop()),B=s.symbols_[B]||B),B}o(tt,"lex");for(var M,W,N,K,F={},U,V,et,Y;;){if(W=i[i.length-1],this.defaultActions[W]?N=this.defaultActions[W]:((M===null||typeof M>"u")&&(M=tt()),N=v[W]&&v[W][M]),typeof N>"u"||!N.length||!N[0]){var q="";Y=[];for(U in v[W])this.terminals_[U]&&U>L&&Y.push("'"+this.terminals_[U]+"'");b.showPosition?q="Parse error on line "+(I+1)+`:
2
2
  `+b.showPosition()+`
3
3
  Expecting `+Y.join(", ")+", got '"+(this.terminals_[M]||M)+"'":q="Parse error on line "+(I+1)+": Unexpected "+(M==A?"end of input":"'"+(this.terminals_[M]||M)+"'"),this.parseError(q,{text:b.match,token:this.terminals_[M]||M,line:b.yylineno,loc:R,expected:Y})}if(N[0]instanceof Array&&N.length>1)throw new Error("Parse Error: multiple actions possible at state: "+W+", token: "+M);switch(N[0]){case 1:i.push(M),p.push(b.yytext),n.push(b.yylloc),i.push(N[1]),M=null,$=b.yyleng,w=b.yytext,I=b.yylineno,R=b.yylloc;break;case 2:if(V=this.productions_[N[1]][1],F.$=p[p.length-V],F._$={first_line:n[n.length-(V||1)].first_line,last_line:n[n.length-1].last_line,first_column:n[n.length-(V||1)].first_column,last_column:n[n.length-1].last_column},G&&(F._$.range=[n[n.length-(V||1)].range[0],n[n.length-1].range[1]]),K=this.performAction.apply(F,[w,$,I,S.yy,N[1],p,n].concat(C)),typeof K<"u")return K;V&&(i=i.slice(0,-1*V*2),p=p.slice(0,-1*V),n=n.slice(0,-1*V)),i.push(this.productions_[N[1]][0]),p.push(F.$),n.push(F._$),et=v[i[i.length-2]][i[i.length-1]],i.push(et);break;case 3:return!0}}return!0},"parse")},O=(function(){var T={EOF:1,parseError:o(function(s,i){if(this.yy.parser)this.yy.parser.parseError(s,i);else throw new Error(s)},"parseError"),setInput:o(function(t,s){return this.yy=s||this.yy||{},this._input=t,this._more=this._backtrack=this.done=!1,this.yylineno=this.yyleng=0,this.yytext=this.matched=this.match="",this.conditionStack=["INITIAL"],this.yylloc={first_line:1,first_column:0,last_line:1,last_column:0},this.options.ranges&&(this.yylloc.range=[0,0]),this.offset=0,this},"setInput"),input:o(function(){var t=this._input[0];this.yytext+=t,this.yyleng++,this.offset++,this.match+=t,this.matched+=t;var s=t.match(/(?:\r\n?|\n).*/g);return s?(this.yylineno++,this.yylloc.last_line++):this.yylloc.last_column++,this.options.ranges&&this.yylloc.range[1]++,this._input=this._input.slice(1),t},"input"),unput:o(function(t){var s=t.length,i=t.split(/(?:\r\n?|\n)/g);this._input=t+this._input,this.yytext=this.yytext.substr(0,this.yytext.length-s),this.offset-=s;var c=this.match.split(/(?:\r\n?|\n)/g);this.match=this.match.substr(0,this.match.length-1),this.matched=this.matched.substr(0,this.matched.length-1),i.length-1&&(this.yylineno-=i.length-1);var p=this.yylloc.range;return this.yylloc={first_line:this.yylloc.first_line,last_line:this.yylineno+1,first_column:this.yylloc.first_column,last_column:i?(i.length===c.length?this.yylloc.first_column:0)+c[c.length-i.length].length-i[0].length:this.yylloc.first_column-s},this.options.ranges&&(this.yylloc.range=[p[0],p[0]+this.yyleng-s]),this.yyleng=this.yytext.length,this},"unput"),more:o(function(){return this._more=!0,this},"more"),reject:o(function(){if(this.options.backtrack_lexer)this._backtrack=!0;else return this.parseError("Lexical error on line "+(this.yylineno+1)+`. You can only invoke reject() in the lexer when the lexer is of the backtracking persuasion (options.backtrack_lexer = true).
4
4
  `+this.showPosition(),{text:"",token:null,line:this.yylineno});return this},"reject"),less:o(function(t){this.unput(this.match.slice(t))},"less"),pastInput:o(function(){var t=this.matched.substr(0,this.matched.length-this.match.length);return(t.length>20?"...":"")+t.substr(-20).replace(/\n/g,"")},"pastInput"),upcomingInput:o(function(){var t=this.match;return t.length<20&&(t+=this._input.substr(0,20-t.length)),(t.substr(0,20)+(t.length>20?"...":"")).replace(/\n/g,"")},"upcomingInput"),showPosition:o(function(){var t=this.pastInput(),s=new Array(t.length+1).join("-");return t+this.upcomingInput()+`