@xopcai/xopc 0.0.423 → 0.0.424

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 (308) hide show
  1. package/dist/browser-ext/dist/assets/{page-context-BKnEwsOO.js → page-context-b-rB5vJC.js} +1 -1
  2. package/dist/browser-ext/dist/background.js +1 -1
  3. package/dist/browser-ext/dist/sidepanel.html +1 -1
  4. package/dist/browser-ext/dist/sidepanel.js +29 -1
  5. package/dist/browser-ext/manifest.json +1 -1
  6. package/dist/extensions/telegram/xopc.extension.json +1 -1
  7. package/dist/gateway/static/root/assets/{activity-store-DNkXnatd.js → activity-store-AI081rxe.js} +1 -1
  8. package/dist/gateway/static/root/assets/{agent-avatar-dicebear-DOnHjAY_.js → agent-avatar-dicebear-DupnTbL7.js} +1 -1
  9. package/dist/gateway/static/root/assets/{agent-avatar-display-C9Lu9LVl.js → agent-avatar-display-CmEj6Uqy.js} +2 -2
  10. package/dist/gateway/static/root/assets/agent-defaults-settings-panel-IEV5yKuu.js +1 -0
  11. package/dist/gateway/static/root/assets/{agent-plugin-dialog-sQNbqsGL.js → agent-plugin-dialog-D_njOuFA.js} +1 -1
  12. package/dist/gateway/static/root/assets/{agents-DZ77luyw.js → agents-B_yg9nA3.js} +4 -4
  13. package/dist/gateway/static/root/assets/{agents-admin-api-DIm_IHQL.js → agents-admin-api-CUZUolwG.js} +1 -1
  14. package/dist/gateway/static/root/assets/{api-By0yX3z1.js → api-CWWEVThO.js} +1 -1
  15. package/dist/gateway/static/root/assets/{api-BUJQiCoX.js → api-bpQ7yR10.js} +1 -1
  16. package/dist/gateway/static/root/assets/{app-management-settings-panel-PPgc1xaD.js → app-management-settings-panel-C0_hxwgg.js} +1 -1
  17. package/dist/gateway/static/root/assets/{appearance-settings-DbI9t4GS.js → appearance-settings-CLh-qnCC.js} +1 -1
  18. package/dist/gateway/static/root/assets/{apps-page-DIC28vl4.js → apps-page-Bjtm3Rgi.js} +1 -1
  19. package/dist/gateway/static/root/assets/{archive-plugin-B5ZSQVw2.js → archive-plugin-dGnstkhB.js} +1 -1
  20. package/dist/gateway/static/root/assets/{automation-api-CfjICuJK.js → automation-api-MB2xCoFF.js} +1 -1
  21. package/dist/gateway/static/root/assets/{automation-result-state-DpQSVGNY.js → automation-result-state-DJQflY78.js} +1 -1
  22. package/dist/gateway/static/root/assets/automation-task-card-DXgBxVE2.js +3 -0
  23. package/dist/gateway/static/root/assets/{automations-page-1NCQMSK1.js → automations-page-D3O7M2FH.js} +1 -1
  24. package/dist/gateway/static/root/assets/automations-workspace-Dk3FVWoX.js +9 -0
  25. package/dist/gateway/static/root/assets/{binary-plugins-_riZg0hb.js → binary-plugins-BrVJXmYf.js} +1 -1
  26. package/dist/gateway/static/root/assets/{block-editor-BpYTVDaG.js → block-editor-Dok4sfT3.js} +2 -2
  27. package/dist/gateway/static/root/assets/{browser-automation-inputs-DLbHyWE5.js → browser-automation-inputs-PJbT3CxW.js} +1 -1
  28. package/dist/gateway/static/root/assets/{browser-automations-page-BfOHr7er.js → browser-automations-page-kkpX1Q7K.js} +1 -1
  29. package/dist/gateway/static/root/assets/{browser-control-api-CqjIQdQ4.js → browser-control-api-Bg4wnkeA.js} +1 -1
  30. package/dist/gateway/static/root/assets/{browser-settings-page-CqjLefvt.js → browser-settings-page-BrgX_Yb2.js} +1 -1
  31. package/dist/gateway/static/root/assets/{capabilities-CTu4Y4Gc.js → capabilities-BMaJizw4.js} +1 -1
  32. package/dist/gateway/static/root/assets/{capabilities-BQ0bsu6d.js → capabilities-Cs6Jt5Gl.js} +1 -1
  33. package/dist/gateway/static/root/assets/capabilities-page-D5hvAG6D.js +2 -0
  34. package/dist/gateway/static/root/assets/{capabilities-settings-panel-Cq28kvMr.js → capabilities-settings-panel-BrEvm4IH.js} +3 -3
  35. package/dist/gateway/static/root/assets/{channels-BPVkbqBI.js → channels-1jQgGVc9.js} +1 -1
  36. package/dist/gateway/static/root/assets/{chat-agents-api-XnegLpGF.js → chat-agents-api-BAOWaUJf.js} +1 -1
  37. package/dist/gateway/static/root/assets/{chat-chart-block-BJFCFZz2.js → chat-chart-block-DeWrb9XR.js} +1 -1
  38. package/dist/gateway/static/root/assets/{chat-page-BpvlJdEr.js → chat-page-CafkCKOj.js} +30 -30
  39. package/dist/gateway/static/root/assets/{chat-terminal-dock-B9KlHa8j.js → chat-terminal-dock-C544n0-R.js} +1 -1
  40. package/dist/gateway/static/root/assets/{command-palette-api-DW7O6fME.js → command-palette-api-D9PXzY8b.js} +1 -1
  41. package/dist/gateway/static/root/assets/{composer-payload-handoff-qheyxoAD.js → composer-payload-handoff-CYXfjpem.js} +1 -1
  42. package/dist/gateway/static/root/assets/{computer-settings-page-KmaJ2UVz.js → computer-settings-page-DJmod8-w.js} +1 -1
  43. package/dist/gateway/static/root/assets/connected-providers-grid-b46VH4uy.js +1 -0
  44. package/dist/gateway/static/root/assets/{connector-service-page-BgexZyHR.js → connector-service-page-BqDbTOTp.js} +1 -1
  45. package/dist/gateway/static/root/assets/{connectors-api-DEYdFCdS.js → connectors-api-CwRuUnH4.js} +1 -1
  46. package/dist/gateway/static/root/assets/connectors-page-Mq9Bvoax.js +1 -0
  47. package/dist/gateway/static/root/assets/{date-picker-CSuiNiPU.js → date-picker-DWaT0IC0.js} +1 -1
  48. package/dist/gateway/static/root/assets/{dependency-picker-DHFVFI74.js → dependency-picker-DV9XAt6F.js} +1 -1
  49. package/dist/gateway/static/root/assets/{desktop-pet-DK3tV5PW.js → desktop-pet-Dffq2NxL.js} +1 -1
  50. package/dist/gateway/static/root/assets/{desktop-pet-settings-BKIcBnfQ.js → desktop-pet-settings-CrB1ICax.js} +1 -1
  51. package/dist/gateway/static/root/assets/{dev-view-store-ZgXvR5Sl.js → dev-view-store-liRgSkcT.js} +1 -1
  52. package/dist/gateway/static/root/assets/{device-pairing-wizard-ZY_cdq5I.js → device-pairing-wizard-1du1hfi5.js} +1 -1
  53. package/dist/gateway/static/root/assets/{directory-picker-path-field-C4N_kXUX.js → directory-picker-path-field-EKqQLQrE.js} +1 -1
  54. package/dist/gateway/static/root/assets/{discussion-annotation-sync-CdbkKHiR.js → discussion-annotation-sync-D-b1X6ro.js} +1 -1
  55. package/dist/gateway/static/root/assets/{extension-debug-page-vdSyb_US.js → extension-debug-page-wD97GeG0.js} +1 -1
  56. package/dist/gateway/static/root/assets/{extension-iframe-host-D4w7-mf1.js → extension-iframe-host-B4Q1CjvW.js} +1 -1
  57. package/dist/gateway/static/root/assets/{extension-marketplace-api-BVMU-5FO.js → extension-marketplace-api-ak1_K3u8.js} +1 -1
  58. package/dist/gateway/static/root/assets/{extension-page-BE7FHMek.js → extension-page-DWFI4iIh.js} +1 -1
  59. package/dist/gateway/static/root/assets/{extension-provider-8RM98QmD.js → extension-provider-BZwcaU5Y.js} +1 -1
  60. package/dist/gateway/static/root/assets/{extension-settings-page--SP1Dy2l.js → extension-settings-page-cn4KS42C.js} +1 -1
  61. package/dist/gateway/static/root/assets/{file-preview-surface-CFFuUQVY.js → file-preview-surface-c3gDD9sM.js} +1 -1
  62. package/dist/gateway/static/root/assets/{gateway-config-swr-i6wzzdws.js → gateway-config-swr-Dmt5JhZU.js} +1 -1
  63. package/dist/gateway/static/root/assets/{gateway-realtime-B1CCUrsG.js → gateway-realtime-CJtDXQCt.js} +1 -1
  64. package/dist/gateway/static/root/assets/gateway-realtime-store-DcsZyYEa.js +1 -0
  65. package/dist/gateway/static/root/assets/{gateway-restart-B3Odfu1z.js → gateway-restart-DInvvT5u.js} +1 -1
  66. package/dist/gateway/static/root/assets/{gateway-settings-QIwB2Ld0.js → gateway-settings-BZXdv2FE.js} +1 -1
  67. package/dist/gateway/static/root/assets/{gateway-startup-retry-DBpCoigO.js → gateway-startup-retry-s2KcWekp.js} +1 -1
  68. package/dist/gateway/static/root/assets/{global-defaults-api-GQG-5G20.js → global-defaults-api-DtnmDd87.js} +1 -1
  69. package/dist/gateway/static/root/assets/{home-page-BsfeSXsZ.js → home-page-CAVjA5rO.js} +2 -2
  70. package/dist/gateway/static/root/assets/{image-generation-api-CaiTrM7V.js → image-generation-api-RQQokgE9.js} +1 -1
  71. package/dist/gateway/static/root/assets/{imports-page-CLkhwelO.js → imports-page-BP_4TubV.js} +1 -1
  72. package/dist/gateway/static/root/assets/index-BS9mjvSL.js +11 -0
  73. package/dist/gateway/static/root/assets/index-pT-m6l6b.css +1 -0
  74. package/dist/gateway/static/root/assets/{install-connector-dialog-B9YBBGhs.js → install-connector-dialog-BNzNuXJ8.js} +1 -1
  75. package/dist/gateway/static/root/assets/{keyboard-shortcuts-settings-DrZQukhN.js → keyboard-shortcuts-settings-DNRQFepg.js} +1 -1
  76. package/dist/gateway/static/root/assets/{local-app-workbench-page-CecbOjks.js → local-app-workbench-page-CvY5XxbX.js} +1 -1
  77. package/dist/gateway/static/root/assets/{local-apps-page-CkVtgVlJ.js → local-apps-page-DfwEvd8G.js} +1 -1
  78. package/dist/gateway/static/root/assets/local-session-drafts-CuDdIyxR.js +4 -0
  79. package/dist/gateway/static/root/assets/{locale-store-_-_QzAV0.js → locale-store-TQcz_Vjt.js} +1 -1
  80. package/dist/gateway/static/root/assets/{logs-page-Dok7TpJ0.js → logs-page-eq49F1Rt.js} +1 -1
  81. package/dist/gateway/static/root/assets/{management-settings-CNbeHUKa.js → management-settings-BaYXDMOJ.js} +1 -1
  82. package/dist/gateway/static/root/assets/{markdown-view-CFWJhIqU.js → markdown-view-D4nII6Zv.js} +1 -1
  83. package/dist/gateway/static/root/assets/{media-plugins-BEcCzwnv.js → media-plugins-MvlAY405.js} +1 -1
  84. package/dist/gateway/static/root/assets/messages-DaLmc4W1.js +3 -0
  85. package/dist/gateway/static/root/assets/model-selector-nsoNHqif.js +1 -0
  86. package/dist/gateway/static/root/assets/{models-hub-cache-B1dBNhhc.js → models-hub-cache-CFIazNIF.js} +1 -1
  87. package/dist/gateway/static/root/assets/note-detail-panel-KPzbHiEW.js +5 -0
  88. package/dist/gateway/static/root/assets/note-image-lightbox-DticJxxh.js +1 -0
  89. package/dist/gateway/static/root/assets/{notes-api-ja_AMIh6.js → notes-api-HVxR5bRD.js} +1 -1
  90. package/dist/gateway/static/root/assets/{notes-page-_IG1mwIH.js → notes-page-yShJeR3i.js} +1 -1
  91. package/dist/gateway/static/root/assets/{oauth-api-C0NG7Hgs.js → oauth-api-CfKjRVnb.js} +1 -1
  92. package/dist/gateway/static/root/assets/{oauth-provider-connect-DLQ6Jhjc.js → oauth-provider-connect-D4uqONWr.js} +1 -1
  93. package/dist/gateway/static/root/assets/{page-context-capture-button-DBlILV5t.js → page-context-capture-button-B98nlKTc.js} +1 -1
  94. package/dist/gateway/static/root/assets/{page-context-draft-CcZSjlMa.js → page-context-draft-HcuK45iu.js} +1 -1
  95. package/dist/gateway/static/root/assets/page-header-store-D6SzJ9Ch.js +1 -0
  96. package/dist/gateway/static/root/assets/{personal-avatar-D3tjI4rK.js → personal-avatar-_d72UP_d.js} +1 -1
  97. package/dist/gateway/static/root/assets/{personal-page-C1gIYjQo.js → personal-page-B19h_3WQ.js} +1 -1
  98. package/dist/gateway/static/root/assets/{personal-settings-panel-Nm03jL4v.js → personal-settings-panel-CfwtGyue.js} +1 -1
  99. package/dist/gateway/static/root/assets/{phone-dependencies-card-72RGs4eb.js → phone-dependencies-card-D8bqsDk_.js} +1 -1
  100. package/dist/gateway/static/root/assets/{phone-model-picker-CNxK_l_B.js → phone-model-picker-CL_Zn6Xd.js} +1 -1
  101. package/dist/gateway/static/root/assets/{phone-settings-page-D5PodpGU.js → phone-settings-page-C5Jia8eQ.js} +1 -1
  102. package/dist/gateway/static/root/assets/{phone-workspace-store-Ci43KRd6.js → phone-workspace-store-FBfrfkYq.js} +1 -1
  103. package/dist/gateway/static/root/assets/plugin-details-dialog-gAq2KPzK.js +1 -0
  104. package/dist/gateway/static/root/assets/{preference-select-fields-CyFvi9Es.js → preference-select-fields-Ck8GAX_y.js} +1 -1
  105. package/dist/gateway/static/root/assets/{product-automation-feedback-BRdOheLC.js → product-automation-feedback-BJ9oTnNs.js} +2 -2
  106. package/dist/gateway/static/root/assets/{product-open-page-CIZj7rh-.js → product-open-page-Dw9hUdxP.js} +1 -1
  107. package/dist/gateway/static/root/assets/{product-preview-content-yK-9po5S.js → product-preview-content-C0iPzmSm.js} +1 -1
  108. package/dist/gateway/static/root/assets/{product-preview-modal-CkdKPk-W.js → product-preview-modal-COFtHoh6.js} +2 -2
  109. package/dist/gateway/static/root/assets/{project-detail-page-D_Kft8au.js → project-detail-page-C5Amjah-.js} +3 -3
  110. package/dist/gateway/static/root/assets/{project-understanding-6raciQr0.js → project-understanding-DpL9ADQU.js} +1 -1
  111. package/dist/gateway/static/root/assets/{projects-page-CNCw6Q5o.js → projects-page-gGg9nM2t.js} +1 -1
  112. package/dist/gateway/static/root/assets/{providers-api-DGeFqpPL.js → providers-api-D6JJRlJb.js} +1 -1
  113. package/dist/gateway/static/root/assets/{recording-upload-rA0Z6W2g.js → recording-upload-DxX1xKyt.js} +1 -1
  114. package/dist/gateway/static/root/assets/{registry-api-5LqCHY-I.js → registry-api-BfXzBR1D.js} +1 -1
  115. package/dist/gateway/static/root/assets/{remote-access-hub-DftT6xNt.js → remote-access-hub-BZA4StwC.js} +1 -1
  116. package/dist/gateway/static/root/assets/{resource-unavailable-CqP8gARc.js → resource-unavailable-X-SIrZYI.js} +1 -1
  117. package/dist/gateway/static/root/assets/route-preload-CWRb0UCt.js +2 -0
  118. package/dist/gateway/static/root/assets/{runtime-tools-api-CUzfEj0z.js → runtime-tools-api-1DjsPyQ5.js} +1 -1
  119. package/dist/gateway/static/root/assets/runtime-tools-settings-panel-BnCtyORj.js +1 -0
  120. package/dist/gateway/static/root/assets/{service-recommendation-list-Bo46zqXR.js → service-recommendation-list-ChSOfHHh.js} +1 -1
  121. package/dist/gateway/static/root/assets/{session-api-CZQ-wpwx.js → session-api-rvY5aWw8.js} +1 -1
  122. package/dist/gateway/static/root/assets/session-manager-D2rbRfX3.js +23 -0
  123. package/dist/gateway/static/root/assets/sessions-page-DAS2IUGT.js +1 -0
  124. package/dist/gateway/static/root/assets/settings-advanced-gate-CYDQybNF.js +1 -0
  125. package/dist/gateway/static/root/assets/{settings-advanced-section-CrqVxpan.js → settings-advanced-section-ZKRIuk7h.js} +1 -1
  126. package/dist/gateway/static/root/assets/{settings-mode-store-D4AZlZDq.js → settings-mode-store-CtJ8pEfm.js} +1 -1
  127. package/dist/gateway/static/root/assets/{settings-page-D-X2rL2k.js → settings-page-B3pUce-_.js} +1 -1
  128. package/dist/gateway/static/root/assets/{settings-page-header-CoPd_JDb.js → settings-page-header-DuNCn8i-.js} +1 -1
  129. package/dist/gateway/static/root/assets/{settings-page-layout-D39EvFvm.js → settings-page-layout-DeNC8YHJ.js} +1 -1
  130. package/dist/gateway/static/root/assets/setup-status-panel-Fc3vuz_h.js +1 -0
  131. package/dist/gateway/static/root/assets/{share-link-dialog-D4oGzmxA.js → share-link-dialog-B3hwjVAx.js} +1 -1
  132. package/dist/gateway/static/root/assets/{share-preview-page-CArPpOZz.js → share-preview-page-D_9oFzGS.js} +1 -1
  133. package/dist/gateway/static/root/assets/{shares-api-DbJOyf2K.js → shares-api-BoUpXmxq.js} +1 -1
  134. package/dist/gateway/static/root/assets/shares-settings-Drfuvepz.js +1 -0
  135. package/dist/gateway/static/root/assets/{skill-api-CQxLO0sy.js → skill-api-By2HhJ9O.js} +1 -1
  136. package/dist/gateway/static/root/assets/{skill-list-api-BkahlC5N.js → skill-list-api-TaUCzS8Y.js} +1 -1
  137. package/dist/gateway/static/root/assets/{skill-reload-api-DZQLAkSr.js → skill-reload-api-CN2fpS1n.js} +1 -1
  138. package/dist/gateway/static/root/assets/{skills-page-BBlJMOZU.js → skills-page-LzGLique.js} +1 -1
  139. package/dist/gateway/static/root/assets/{system-settings-panel-b2h_YWsq.js → system-settings-panel-Cuyg8Ml3.js} +1 -1
  140. package/dist/gateway/static/root/assets/{task-detail-page-BkvjB6fd.js → task-detail-page-6A9337pK.js} +2 -2
  141. package/dist/gateway/static/root/assets/{task-result-evidence-DLnPVj6x.js → task-result-evidence-DDubAU_5.js} +1 -1
  142. package/dist/gateway/static/root/assets/{terminal-panel-store-Xmw-UfZa.js → terminal-panel-store-BNs75Wdr.js} +1 -1
  143. package/dist/gateway/static/root/assets/{theme-store-DU_07f3M.js → theme-store-DB1ZfBUm.js} +1 -1
  144. package/dist/gateway/static/root/assets/tracing-settings-page-TvtX4Goh.js +1 -0
  145. package/dist/gateway/static/root/assets/{tunnel-api-DD2HgB7G.js → tunnel-api-COoVEdV9.js} +1 -1
  146. package/dist/gateway/static/root/assets/{understanding-activity-store-CyQMYQhD.js → understanding-activity-store-Dr_MLgYe.js} +1 -1
  147. package/dist/gateway/static/root/assets/{understanding-refresh-store-CTgQYLOe.js → understanding-refresh-store-DGmLGEqw.js} +1 -1
  148. package/dist/gateway/static/root/assets/{usage-page-BUZLOZLg.js → usage-page-DP6eb6ed.js} +1 -1
  149. package/dist/gateway/static/root/assets/{use-autosave-BqTpwsvF.js → use-autosave-itwjDYUb.js} +1 -1
  150. package/dist/gateway/static/root/assets/{use-composer-attachments-DfP3JrD6.js → use-composer-attachments-hjIGlI_2.js} +1 -1
  151. package/dist/gateway/static/root/assets/{use-file-preview-expanded-D2m6BZLU.js → use-file-preview-expanded-ClLa0g8D.js} +2 -2
  152. package/dist/gateway/static/root/assets/{use-personal-profile-CmLuBSVu.js → use-personal-profile-vhWk6tTU.js} +1 -1
  153. package/dist/gateway/static/root/assets/{use-workspace-tree-DBvuHcas.js → use-workspace-tree-dfXXjA2-.js} +1 -1
  154. package/dist/gateway/static/root/assets/user-model-page-D8dswPWd.js +2 -0
  155. package/dist/gateway/static/root/assets/{voice-api-key-field-DGyL8PYB.js → voice-api-key-field-BIfBySnN.js} +1 -1
  156. package/dist/gateway/static/root/assets/{voice-config-api-CIRG9O8T.js → voice-config-api-J4o59ICE.js} +1 -1
  157. package/dist/gateway/static/root/assets/{voice-input-shortcut-events-DrVMpqDV.js → voice-input-shortcut-events-B1mlpUdC.js} +1 -1
  158. package/dist/gateway/static/root/assets/{voice-transcribe-api-H8o-xLEf.js → voice-transcribe-api-xxaSOOmq.js} +1 -1
  159. package/dist/gateway/static/root/assets/{work-discovery-overlay-CobALTh0.js → work-discovery-overlay-DqwT1E5u.js} +1 -1
  160. package/dist/gateway/static/root/assets/{work-discovery-page-Dxf_Hrwx.js → work-discovery-page-BzYQmPLT.js} +1 -1
  161. package/dist/gateway/static/root/assets/{working-directory-picker-modal-E9f8G3se.js → working-directory-picker-modal-D2Zf3GOG.js} +1 -1
  162. package/dist/gateway/static/root/assets/{workspace-api-N7bfM4a1.js → workspace-api-Bnx3eS2M.js} +2 -2
  163. package/dist/gateway/static/root/assets/workspace-editor-agent-store-COUVwj-p.js +1 -0
  164. package/dist/gateway/static/root/assets/{workspace-file-preview-dialog-BTQfAXNK.js → workspace-file-preview-dialog-D13qHzVr.js} +1 -1
  165. package/dist/gateway/static/root/assets/{workspace-open-location-menu-BOGOi-Ck.js → workspace-open-location-menu-Cou-ig1H.js} +1 -1
  166. package/dist/gateway/static/root/assets/{xopc-cloud-account-card-Dqfy4Lwy.js → xopc-cloud-account-card-DQGPKxHA.js} +1 -1
  167. package/dist/gateway/static/root/index.html +80 -80
  168. package/dist/package.js +1 -1
  169. package/dist/packages/gateway-contract/src/clarification-questions.js +86 -0
  170. package/dist/packages/gateway-contract/src/clarifications.js +19 -0
  171. package/dist/packages/gateway-contract/src/index.js +1 -0
  172. package/dist/packages/gateway-contract/src/session-input-command.js +3 -0
  173. package/dist/src/agent/agent-manager.js +2 -2
  174. package/dist/src/agent/background-review/run-background-review.js +2 -2
  175. package/dist/src/agent/coding/repository-instructions.js +1 -1
  176. package/dist/src/agent/embedded/index.js +1 -1
  177. package/dist/src/agent/embedded/run-for-session.js +1 -1
  178. package/dist/src/agent/embedded/run-turn.js +3 -3
  179. package/dist/src/agent/embedded/session-tool-result-guard.js +2 -2
  180. package/dist/src/agent/embedded/tool-result-truncation.js +1 -1
  181. package/dist/src/agent/external-tools/cliProvider.js +2 -2
  182. package/dist/src/agent/external-tools/composio-provider.js +2 -2
  183. package/dist/src/agent/external-tools/endpoint-provider.js +2 -2
  184. package/dist/src/agent/inbound/attachment-pipeline.js +1 -1
  185. package/dist/src/agent/memory/compaction.js +1 -1
  186. package/dist/src/agent/memory/context-budget.js +1 -1
  187. package/dist/src/agent/memory/context-recovery.js +1 -1
  188. package/dist/src/agent/memory/user-message-text.js +1 -1
  189. package/dist/src/agent/service/btw-query.js +1 -1
  190. package/dist/src/agent/service/direct-turn-helpers.js +1 -1
  191. package/dist/src/agent/service/process-direct-streaming.js +2 -2
  192. package/dist/src/agent/service.js +1 -1
  193. package/dist/src/agent/skills/index.js +1 -1
  194. package/dist/src/agent/skills/managed-store.js +1 -1
  195. package/dist/src/agent/skills/skill-manage-ops.js +1 -1
  196. package/dist/src/agent/source-context/types.d.ts +1 -0
  197. package/dist/src/agent/tools/clarify-tool.js +43 -5
  198. package/dist/src/agent/tools/cli-clarify.js +1 -0
  199. package/dist/src/agent/tools/dataBatch.js +1 -1
  200. package/dist/src/agent/tools/personal-read-tool.js +1 -1
  201. package/dist/src/agent/tools/personal-task-tool.d.ts +1 -1
  202. package/dist/src/agent/tools/phone-use-tool.js +2 -2
  203. package/dist/src/agent/tools/session-search-tool.js +1 -1
  204. package/dist/src/agent/tools/xopc-use-tool.js +2 -2
  205. package/dist/src/agent-catalog/capabilities.js +2 -2
  206. package/dist/src/agent-catalog/repository.js +1 -1
  207. package/dist/src/automations/api/routes.js +2 -2
  208. package/dist/src/automations/capabilities/drafts.js +1 -1
  209. package/dist/src/automations/capabilities/write.js +1 -1
  210. package/dist/src/automations/configuration-conversation.js +1 -1
  211. package/dist/src/browser/providers/browser-ext-install.js +1 -1
  212. package/dist/src/capabilities/runtime/dispatcher.js +1 -1
  213. package/dist/src/capabilities/runtime/product.js +1 -1
  214. package/dist/src/cli/commands/agent.js +1 -1
  215. package/dist/src/cli/commands/agents.js +1 -1
  216. package/dist/src/cli/commands/gateway/lifecycle.js +1 -1
  217. package/dist/src/cli/commands/models.js +2 -2
  218. package/dist/src/cli/commands/onboard/model.js +1 -1
  219. package/dist/src/cli/commands/onboard.js +1 -1
  220. package/dist/src/cli/commands/platform.js +1 -1
  221. package/dist/src/cli/commands/profile.js +1 -1
  222. package/dist/src/cli/commands/tunnel.js +1 -1
  223. package/dist/src/cli/commands/update.js +1 -1
  224. package/dist/src/cli/extension-cli-register.js +1 -1
  225. package/dist/src/cli/utils/init-workspace-core.js +1 -1
  226. package/dist/src/computer/diagnostics.d.ts +3 -3
  227. package/dist/src/computer/evaluation.d.ts +2 -2
  228. package/dist/src/config/agent-profile.js +1 -1
  229. package/dist/src/config/index.js +1 -1
  230. package/dist/src/connectors/learning-coordinator.js +1 -1
  231. package/dist/src/execution-environments/local-worktree-manager.js +1 -1
  232. package/dist/src/extensions/agent-plugins/skill-catalog.js +1 -1
  233. package/dist/src/extensions/agent-plugins/validation.js +1 -1
  234. package/dist/src/gateway/agents-admin.js +2 -2
  235. package/dist/src/gateway/ephemeral-clarification-waiter.js +1 -0
  236. package/dist/src/gateway/global-defaults-admin.js +1 -1
  237. package/dist/src/gateway/hono/routes/agents.js +1 -1
  238. package/dist/src/gateway/hono/routes/composer-history.js +1 -1
  239. package/dist/src/gateway/hono/routes/config-patch/misc.js +1 -1
  240. package/dist/src/gateway/hono/routes/connectors.js +1 -1
  241. package/dist/src/gateway/hono/routes/home.js +1 -1
  242. package/dist/src/gateway/hono/routes/notes.js +2 -2
  243. package/dist/src/gateway/hono/routes/phone-setup.js +1 -1
  244. package/dist/src/gateway/hono/routes/phone.js +31 -6
  245. package/dist/src/gateway/hono/routes/projects.js +2 -2
  246. package/dist/src/gateway/hono/routes/public-gateway.js +2 -1
  247. package/dist/src/gateway/hono/routes/session-command-handler.js +1 -0
  248. package/dist/src/gateway/hono/routes/session-input-handler.d.ts +6 -0
  249. package/dist/src/gateway/hono/routes/session-input-handler.js +1 -1
  250. package/dist/src/gateway/hono/routes/tasks.js +1 -1
  251. package/dist/src/gateway/hono/routes/user-model-refresh.js +1 -1
  252. package/dist/src/gateway/image-generation-setup.js +1 -1
  253. package/dist/src/gateway/next-turn-suggestions/snapshot.js +1 -1
  254. package/dist/src/gateway/service/agent-runner.js +8 -3
  255. package/dist/src/gateway/service/run-gateway-agent.js +1 -1
  256. package/dist/src/gateway/service/session-input-coordinator.js +5 -4
  257. package/dist/src/gateway/service.js +7 -7
  258. package/dist/src/gateway/xopc-cloud-capability-setup.js +1 -1
  259. package/dist/src/home-intelligence/host.js +2 -2
  260. package/dist/src/imports/importService.js +1 -1
  261. package/dist/src/local-apps/service.js +1 -1
  262. package/dist/src/personal-agent/service.js +1 -1
  263. package/dist/src/phone/assistance.js +3 -0
  264. package/dist/src/phone/contracts.d.ts +4 -0
  265. package/dist/src/phone/runtime.d.ts +7 -1
  266. package/dist/src/phone/runtime.js +31 -24
  267. package/dist/src/routing/agent-session-key.js +1 -1
  268. package/dist/src/runtime-tools/archive.js +1 -1
  269. package/dist/src/session/session-context-for-llm.js +1 -0
  270. package/dist/src/session/session-title.js +1 -1
  271. package/dist/src/storage/sqlite/clarification-wait-repository.js +45 -4
  272. package/dist/src/storage/sqlite/index.js +6 -6
  273. package/dist/src/storage/sqlite/session-creation-repository.js +1 -1
  274. package/dist/src/storage/sqlite/session-repository.js +1 -1
  275. package/dist/src/tasks/capabilities/read.js +2 -2
  276. package/dist/src/tasks/capabilities/write.js +1 -1
  277. package/dist/src/tasks/home-query-service.js +1 -1
  278. package/dist/src/tasks/task-allocation-repository.js +1 -1
  279. package/dist/src/tui/backends/embedded-backend.js +2 -2
  280. package/dist/src/voice/realtime/persona-context.js +1 -1
  281. package/package.json +2 -1
  282. package/dist/gateway/static/root/assets/agent-defaults-settings-panel-L6J-FYQS.js +0 -1
  283. package/dist/gateway/static/root/assets/automation-task-card-BV7hPwN1.js +0 -3
  284. package/dist/gateway/static/root/assets/automations-workspace-CPFYdI8m.js +0 -9
  285. package/dist/gateway/static/root/assets/capabilities-page-ljQTg4T5.js +0 -2
  286. package/dist/gateway/static/root/assets/connected-providers-grid-BIX82L4N.js +0 -1
  287. package/dist/gateway/static/root/assets/connectors-page-BawS0DUd.js +0 -1
  288. package/dist/gateway/static/root/assets/gateway-realtime-store-BFCA_TAU.js +0 -1
  289. package/dist/gateway/static/root/assets/index-Dv8mUlNN.css +0 -1
  290. package/dist/gateway/static/root/assets/index-GX_PTIj6.js +0 -11
  291. package/dist/gateway/static/root/assets/local-session-drafts-DVSVgTCK.js +0 -1
  292. package/dist/gateway/static/root/assets/messages-D1u8VsPq.js +0 -3
  293. package/dist/gateway/static/root/assets/model-selector-DKB20MJY.js +0 -1
  294. package/dist/gateway/static/root/assets/note-detail-panel-COp5zpe4.js +0 -5
  295. package/dist/gateway/static/root/assets/note-image-lightbox-DvtEn8dg.js +0 -1
  296. package/dist/gateway/static/root/assets/page-header-store-RgQRaRbH.js +0 -1
  297. package/dist/gateway/static/root/assets/plugin-details-dialog-D_Lkepqt.js +0 -1
  298. package/dist/gateway/static/root/assets/route-preload-Hr12PIMD.js +0 -2
  299. package/dist/gateway/static/root/assets/runtime-impact-DbySfhdp.js +0 -1
  300. package/dist/gateway/static/root/assets/runtime-tools-settings-panel-VIFAEKJi.js +0 -1
  301. package/dist/gateway/static/root/assets/session-manager-DhoRfUGE.js +0 -23
  302. package/dist/gateway/static/root/assets/sessions-page-BISYL6iE.js +0 -1
  303. package/dist/gateway/static/root/assets/settings-advanced-gate-BLnNiubD.js +0 -1
  304. package/dist/gateway/static/root/assets/setup-status-panel-DyzdCgrb.js +0 -1
  305. package/dist/gateway/static/root/assets/shares-settings-BFLomErf.js +0 -1
  306. package/dist/gateway/static/root/assets/tracing-settings-page-CemIMuec.js +0 -1
  307. package/dist/gateway/static/root/assets/user-model-page-BhX_Ahlu.js +0 -2
  308. package/dist/gateway/static/root/assets/workspace-editor-agent-store-Cb4TlnKX.js +0 -1
@@ -1 +1 @@
1
- import{p as e}from"./locale-store-_-_QzAV0.js";import{t}from"./middleware-Pd0e8Igk.js";var n=e(t(e=>({showRawToolData:!1,setShowRawToolData:t=>e({showRawToolData:t})}),{name:`xopc-web-dev-view`}));export{n as t};
1
+ import{p as e}from"./locale-store-TQcz_Vjt.js";import{t}from"./middleware-Pd0e8Igk.js";var n=e(t(e=>({showRawToolData:!1,setShowRawToolData:t=>e({showRawToolData:t})}),{name:`xopc-web-dev-view`}));export{n as t};
@@ -1 +1 @@
1
- import{i as e,n as t}from"./rolldown-runtime-aKtaBQYM.js";import{a as n,n as r,t as i}from"./vendor-react-BOUWij0V.js";import{u as a}from"./chunk-KS7C4IRE-CiwuuyV8.js";import{n as o}from"./locale-store-_-_QzAV0.js";import{t as s}from"./messages-D1u8VsPq.js";import{t as c}from"./chevron-right-BweFrslA.js";import{t as l}from"./circle-check-C23XjkUj.js";import{t as u}from"./clock-3-DnrAnuyZ.js";import{t as d}from"./download-Dk-ZjtO6.js";import{t as f}from"./external-link-DjqjBmc3.js";import{t as p}from"./laptop-CI3hBVrl.js";import{t as m}from"./panel-right-CFGrHTsD.js";import{t as h}from"./smartphone-DSSsQFqA.js";import{t as g}from"./x-B_N4OPjy.js";import{t as _}from"./cn-0WouolD0.js";import{i as v}from"./vendor-swr-CdRzEUwF.js";import{t as y}from"./button-CnRSIP6m.js";import{t as b}from"./skeleton-BI5TyibZ.js";import{a as x,i as ee,o as S,r as C,s as w,t as T}from"./dist-DfWfZ9iu.js";import{i as E,o as D}from"./settings-shell-dialog-layer-BU3UuiJr.js";import{n as O}from"./app-link-1j40sJ-z.js";import{t as k}from"./use-async-resource-BHFGZCY2.js";import{t as A}from"./copy-text-row-CYIv7RfP.js";import{a as j,n as M,r as N}from"./oauth-api-C0NG7Hgs.js";import{n as P,r as F,t as I}from"./oauth-authorization-window-o6URRos4.js";import{_ as L,a as te,b as ne,d as re,f as R,g as ie,h as ae,i as z,l as B,m as oe,n as V,p as se,r as H,s as ce,t as U,u as W,v as le,y as ue}from"./tunnel-api-DD2HgB7G.js";import{t as de}from"./mobile-pair-qr-CuIbmw5x.js";var G=r(),K=e(n(),1),q=i();function fe(){let e=s(o(e=>e.language)),t=e.endpointToolsSettings.deviceAccess.flow,n=e.tunnelSettings,{data:r,error:i,mutate:a}=v(`tunnel-status`,V,{refreshInterval:1500}),[c,l]=(0,K.useState)(!1),[u,d]=(0,K.useState)(!1),[p,m]=(0,K.useState)(!0),[h,g]=(0,K.useState)(`idle`),[_,x]=(0,K.useState)(null),[ee,S]=(0,K.useState)(``),[C,w]=(0,K.useState)(``),T=(0,K.useRef)(!0);(0,K.useEffect)(()=>(T.current=!0,()=>{T.current=!1}),[]),(0,K.useEffect)(()=>{r?.state===`connected`&&(x(null),S(``))},[r?.state]);let E=_?_===`registration-rejected`:r?.state===`error`&&R(Error(r.lastError??``)),D=_?_===`recovery-rejected`:r?.state===`error`&&re(Error(r.lastError??``)),k=async()=>{if(!r)return;if(r.consentRequired&&!c){d(!0);return}let e=E||!r.registrationSecret?.configured,t=e?F():null,n,i=!1;x(null),S(``);try{if(r.consentRequired&&await te(),e){g(`provisioning`),E&&await H({registrationSecret:null});let e=!1;try{await z()}catch(t){if(!W(t))throw t;e=!0}if(e){g(`authorizing`);let e=sessionStorage.getItem(`device-pairing-oauth`),r=e?JSON.parse(e):null;n=r&&r.expiresAt>Date.now()?r.sessionId:(await j(`xopc-tunnel`)).sessionId,sessionStorage.setItem(`device-pairing-oauth`,JSON.stringify({sessionId:n,expiresAt:r&&r.expiresAt>Date.now()?r.expiresAt:Date.now()+5*6e4}));let a=``,o=Date.now()+5*6e4,s=!1;for(;T.current&&Date.now()<o;){let e=await N(n);if(e.authUrl&&e.authUrl!==a&&(a=e.authUrl,await P(a,t)||w(a)),e.status===`completed`){s=!0,i=!0;break}if(e.status===`failed`||e.status===`cancelled`)throw Error(`Authorization cancelled`);await new Promise(e=>setTimeout(e,1e3))}if(!T.current)return;if(!s)throw Error(`Authorization expired`);await z()}await a()}if(!T.current)return;g(`starting`),await ce(D?{recoverActiveLease:!0}:void 0),p&&await H({autoStart:!0}),await a(),i=!0}catch(e){i=!0,T.current&&(x(B(e)===`tunnel_key_limit_reached`?`key-limit`:R(e)?`registration-rejected`:re(e)?`recovery-rejected`:`failed`),S(e instanceof Error?e.message:``))}finally{I(t),i&&(sessionStorage.removeItem(`device-pairing-oauth`),n&&M(n).catch(()=>{})),T.current&&(g(`idle`),w(``))}};if(!r&&!i)return(0,q.jsxs)(`div`,{className:`space-y-5`,children:[(0,q.jsx)(b,{className:`h-5 w-4/5`}),(0,q.jsx)(b,{className:`h-24 w-full`})]});let A=h===`provisioning`||h===`starting`||r?.state===`connecting`||r?.state===`reconnecting`,L=h===`idle`&&!A&&(_||i||r?.state===`error`),ne=ee||(i instanceof Error?i.message:``)||(r?.state===`error`?r.lastError:``);return(0,q.jsxs)(`div`,{className:`flex flex-col`,children:[(0,q.jsx)(`p`,{className:`text-sm leading-relaxed text-fg-muted`,children:A?t.preparingHint:h===`authorizing`?t.authorizing:t.enableHint}),C&&h===`authorizing`?(0,q.jsx)(`a`,{href:C,target:`_blank`,rel:`noopener noreferrer`,className:`mt-4 inline-flex min-h-11 items-center text-sm text-accent`,children:t.openAuthorization}):null,A?(0,q.jsxs)(`div`,{className:`mt-8 space-y-3`,"aria-label":t.preparing,children:[(0,q.jsx)(b,{className:`h-2 w-full`}),(0,q.jsx)(`p`,{className:`text-sm text-fg-muted`,children:t.preparing})]}):null,(u||r?.consentRequired)&&h===`idle`?(0,q.jsxs)(`div`,{className:`mt-6 space-y-4`,children:[(0,q.jsxs)(`details`,{open:u,className:`text-sm text-fg-muted`,children:[(0,q.jsx)(`summary`,{className:`cursor-pointer py-2`,children:t.details}),(0,q.jsx)(`p`,{className:`mt-2`,children:n.consentIntro}),(0,q.jsx)(`ul`,{className:`mt-3 list-disc space-y-2 pl-5`,children:[n.consentBullet1,n.consentBullet2,n.consentBullet3].map(e=>(0,q.jsx)(`li`,{children:e},e))})]}),(0,q.jsxs)(`label`,{className:`flex items-start gap-3 text-sm text-fg`,children:[(0,q.jsx)(`input`,{type:`checkbox`,checked:c,onChange:e=>l(e.target.checked),className:`mt-1 size-4 accent-accent`}),n.consentCheckbox]})]}):null,L&&_===`key-limit`?(0,q.jsxs)(`div`,{role:`alert`,className:`mt-4 rounded-lg border border-warning/30 bg-warning/5 p-4`,children:[(0,q.jsx)(`p`,{className:`text-sm font-medium text-fg`,children:t.routeKeyLimitTitle}),(0,q.jsx)(`p`,{className:`mt-1 text-xs leading-5 text-fg-muted`,children:t.routeKeyLimitHint}),(0,q.jsxs)(y,{variant:`secondary`,className:`mt-3`,onClick:()=>void O(U),children:[t.manageTunnelKeys,(0,q.jsx)(f,{className:`size-3`})]})]}):L?(0,q.jsxs)(`div`,{role:`alert`,className:`mt-4 text-sm text-danger`,children:[(0,q.jsx)(`p`,{children:i&&!r?t.readinessFailed:E?t.routeAuthorizationRequired:D?t.routeRecoveryRequired:t.routeSetupFailed}),ne?(0,q.jsxs)(`details`,{className:`mt-2 text-xs text-fg-muted`,children:[(0,q.jsx)(`summary`,{className:`cursor-pointer py-2`,children:t.details}),(0,q.jsx)(`p`,{className:`break-words whitespace-pre-wrap`,children:ne})]}):null]}):null,(0,q.jsxs)(`label`,{className:`my-5 flex items-center gap-3 text-sm text-fg-muted`,children:[(0,q.jsx)(`input`,{type:`checkbox`,checked:p,disabled:h!==`idle`,onChange:e=>m(e.target.checked),className:`size-4 accent-accent`}),t.autoStart]}),i&&!r?(0,q.jsx)(y,{className:`w-full`,variant:`primary`,onClick:()=>void a().catch(()=>{}),children:t.retry}):(0,q.jsx)(y,{className:`w-full`,variant:`primary`,disabled:!r||h!==`idle`||A||u&&!c,onClick:()=>void k(),children:h===`authorizing`?t.authorizing:A?t.preparing:E?t.authorize:D?t.recoverRoute:L?t.retry:t.enable})]})}var J=t({DevicePairingWizard:()=>Y});function Y(e){let t=(0,G.c)(16),{open:n,onOpenChange:r,onPaired:i,targetKind:o}=e,s=a(),[c,l]=(0,K.useState)(o),u,d;t[0]===o?(u=t[1],d=t[2]):(u=()=>{l(o)},d=[o],t[0]=o,t[1]=u,t[2]=d),(0,K.useEffect)(u,d);let f;t[3]!==r||t[4]!==o?(f=e=>{e||l(o),r(e)},t[3]=r,t[4]=o,t[5]=f):f=t[5];let p=f,m;t[6]!==p||t[7]!==s||t[8]!==i||t[9]!==n||t[10]!==c?(m=n?c?(0,q.jsx)(me,{targetKind:c,onClose:()=>p(!1),onPaired:i}):(0,q.jsx)(Z,{onChoose:l,onChooseLocalBrowser:()=>{p(!1),s(`/settings/agent-browser?driver=extension`)},onClose:()=>p(!1)}):null,t[6]=p,t[7]=s,t[8]=i,t[9]=n,t[10]=c,t[11]=m):m=t[11];let h;return t[12]!==p||t[13]!==n||t[14]!==m?(h=(0,q.jsx)(T,{open:n,onOpenChange:p,children:m}),t[12]=p,t[13]=n,t[14]=m,t[15]=h):h=t[15],h}function X(e){let t=(0,G.c)(14),{icon:n,title:r,hint:i,onClick:a}=e,o;t[0]===n?o=t[1]:(o=(0,q.jsx)(`span`,{className:`flex size-10 shrink-0 items-center justify-center rounded-xl bg-accent-soft text-accent-fg`,children:(0,q.jsx)(n,{className:`size-5`,"aria-hidden":`true`})}),t[0]=n,t[1]=o);let s;t[2]===r?s=t[3]:(s=(0,q.jsx)(`span`,{className:`block text-sm font-semibold text-fg`,children:r}),t[2]=r,t[3]=s);let l;t[4]===i?l=t[5]:(l=(0,q.jsx)(`span`,{className:`mt-0.5 block text-xs leading-5 text-fg-muted`,children:i}),t[4]=i,t[5]=l);let u;t[6]!==s||t[7]!==l?(u=(0,q.jsxs)(`span`,{className:`min-w-0 flex-1`,children:[s,l]}),t[6]=s,t[7]=l,t[8]=u):u=t[8];let d;t[9]===Symbol.for(`react.memo_cache_sentinel`)?(d=(0,q.jsx)(c,{className:`size-4 shrink-0 text-fg-disabled transition-transform group-hover:translate-x-0.5 group-hover:text-fg-muted`,"aria-hidden":`true`}),t[9]=d):d=t[9];let f;return t[10]!==a||t[11]!==o||t[12]!==u?(f=(0,q.jsxs)(`button`,{type:`button`,className:`group flex min-h-18 w-full cursor-pointer items-center gap-4 rounded-xl border border-edge bg-surface-panel px-4 py-3.5 text-left shadow-surface transition-[background-color,border-color,box-shadow,transform] hover:border-edge-strong hover:bg-surface-active hover:shadow-elevated active:translate-y-px active:bg-surface-hover focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-accent focus-visible:ring-offset-2 focus-visible:ring-offset-surface-panel motion-reduce:active:translate-y-0`,onClick:a,children:[o,u,d]}),t[10]=a,t[11]=o,t[12]=u,t[13]=f):f=t[13],f}function Z(e){let t=(0,G.c)(40),{onChoose:n,onChooseLocalBrowser:r,onClose:i}=e,a=o(pe),c;t[0]===a?c=t[1]:(c=s(a),t[0]=a,t[1]=c);let l=c.endpointToolsSettings.deviceAccess,u;t[2]===Symbol.for(`react.memo_cache_sentinel`)?(u=(0,q.jsx)(x,{className:_(`xopc-dialog-overlay fixed inset-0 bg-scrim backdrop-blur-[1px]`,D)}),t[2]=u):u=t[2];let d;t[3]===Symbol.for(`react.memo_cache_sentinel`)?(d=_(`xopc-dialog-content fixed left-1/2 top-1/2 flex h-[min(28rem,calc(100dvh-2rem))] w-[min(40rem,calc(100vw-2rem))] -translate-x-1/2 -translate-y-1/2 flex-col overflow-hidden rounded-xl border border-edge bg-surface-overlay`,E),t[3]=d):d=t[3];let f;t[4]===Symbol.for(`react.memo_cache_sentinel`)?(f=(0,q.jsx)(`span`,{className:`text-lg font-semibold tracking-tight text-fg`,children:`xopc`}),t[4]=f):f=t[4];let v;t[5]===Symbol.for(`react.memo_cache_sentinel`)?(v=(0,q.jsx)(g,{className:`size-4`}),t[5]=v):v=t[5];let y;t[6]!==l.cancel||t[7]!==i?(y=(0,q.jsxs)(`header`,{className:`flex shrink-0 items-center justify-between border-b border-edge-subtle px-6 py-3`,children:[f,(0,q.jsx)(`button`,{type:`button`,className:`flex size-10 items-center justify-center rounded-lg text-fg-muted hover:bg-surface-hover`,"aria-label":l.cancel,onClick:i,children:v})]}),t[6]=l.cancel,t[7]=i,t[8]=y):y=t[8];let b;t[9]===l.chooseTitle?b=t[10]:(b=(0,q.jsx)(w,{className:`text-lg font-semibold tracking-tight text-fg sm:text-xl`,children:l.chooseTitle}),t[9]=l.chooseTitle,t[10]=b);let T;t[11]===l.chooseHint?T=t[12]:(T=(0,q.jsx)(ee,{className:`mt-1.5 text-sm leading-6 text-fg-muted`,children:l.chooseHint}),t[11]=l.chooseHint,t[12]=T);let O;t[13]!==l.localBrowserHint||t[14]!==l.localBrowserTitle||t[15]!==r?(O=(0,q.jsx)(X,{icon:p,title:l.localBrowserTitle,hint:l.localBrowserHint,onClick:r}),t[13]=l.localBrowserHint,t[14]=l.localBrowserTitle,t[15]=r,t[16]=O):O=t[16];let k;t[17]===n?k=t[18]:(k=()=>n(`mobile`),t[17]=n,t[18]=k);let A;t[19]!==l.mobileHint||t[20]!==l.mobileTitle||t[21]!==k?(A=(0,q.jsx)(X,{icon:h,title:l.mobileTitle,hint:l.mobileHint,onClick:k}),t[19]=l.mobileHint,t[20]=l.mobileTitle,t[21]=k,t[22]=A):A=t[22];let j;t[23]===n?j=t[24]:(j=()=>n(`browser`),t[23]=n,t[24]=j);let M;t[25]!==l.remoteBrowserHint||t[26]!==l.remoteBrowserTitle||t[27]!==j?(M=(0,q.jsx)(X,{icon:m,title:l.remoteBrowserTitle,hint:l.remoteBrowserHint,onClick:j}),t[25]=l.remoteBrowserHint,t[26]=l.remoteBrowserTitle,t[27]=j,t[28]=M):M=t[28];let N;t[29]!==A||t[30]!==M||t[31]!==O?(N=(0,q.jsxs)(`div`,{className:`mt-5 flex flex-col gap-2.5`,children:[O,A,M]}),t[29]=A,t[30]=M,t[31]=O,t[32]=N):N=t[32];let P;t[33]!==N||t[34]!==b||t[35]!==T?(P=(0,q.jsxs)(`div`,{className:`min-h-0 flex-1 overflow-y-auto px-5 py-6 sm:px-8`,children:[b,T,N]}),t[33]=N,t[34]=b,t[35]=T,t[36]=P):P=t[36];let F;return t[37]!==P||t[38]!==y?(F=(0,q.jsxs)(S,{children:[u,(0,q.jsxs)(C,{className:d,children:[y,P]})]}),t[37]=P,t[38]=y,t[39]=F):F=t[39],F}function pe(e){return e.language}function me({targetKind:e,onClose:t,onPaired:n}){let r=o(e=>e.language),i=s(r),a=i.endpointToolsSettings.deviceAccess,p=a.flow,[m,h]=(0,K.useState)(!1),T=v(m?`device-pairing-readiness`:null,L,{refreshInterval:1500}),[j,M]=(0,K.useState)(),[N,P]=(0,K.useState)(null),[F,I]=(0,K.useState)(!1),[te,re]=(0,K.useState)(Date.now()),[R,z]=(0,K.useState)(null),B=(0,K.useRef)(!0),V=(0,K.useRef)(null),H=(0,K.useRef)(!1),ce=(0,K.useRef)(!1),U=v(j?[`device-pairing-setup`,j.id]:null,()=>le(j.id),{refreshInterval:1500}),W=U.data?.request,G=W?.status===`completed`,J=G&&W.connectedAt!==void 0,Y=v(J&&window.electronAPI?.system?`system-behavior`:null,()=>window.electronAPI.system.getBehavior()),X=j?.targetKind===`mobile`?j.universalLink:``,Z=k(()=>de(X),[X],{enabled:!!X,initial:null,errorData:null}),pe=r===`zh`?`https://xopc.ai/zh#download`:`https://xopc.ai/en#download`,me=r===`zh`?`https://xopcai.github.io/xopc/zh/browser-extension`:`https://xopcai.github.io/xopc/browser-extension`,he=k(()=>de(pe),[pe],{enabled:!m&&e===`mobile`,initial:null,errorData:null});(0,K.useEffect)(()=>{B.current=!0;let e=setInterval(()=>re(Date.now()),1e3);return()=>{B.current=!1,clearInterval(e),V.current&&se(V.current).catch(()=>{})}},[]);let ge=(0,K.useCallback)(async()=>{if(!H.current){H.current=!0,I(!0),P(null);try{V.current&&await se(V.current),V.current=null,M(void 0);let t=await oe(e);if(t.kind===`ready`){if(!B.current){await se(t.setup.id);return}V.current=t.setup.id,M(t.setup)}else await T.mutate()}catch{B.current&&P(`create`)}finally{H.current=!1,B.current&&I(!1)}}},[T,e]);(0,K.useEffect)(()=>{T.data?.ready&&!j&&N!==`create`&&!H.current&&ge()},[T.data,j,N,ge]),(0,K.useEffect)(()=>{J&&!ce.current&&(ce.current=!0,n?.())},[J,n]);let _e=async e=>{if(W){I(!0),P(null);try{await ae(W,e),await U.mutate()}catch{P(`decision`),await U.mutate()}finally{B.current&&I(!1)}}},ve=(0,K.useRef)(0);(0,K.useEffect)(()=>{U.data&&(ve.current=U.data.serverTime-Date.now())},[U.data]);let Q=te+ve.current,ye=j&&Q>=j.expiresAt&&!W,be=W&&[`expired`,`rejected`,`cancelled`].includes(W.status),xe=j?j.expiresAt-Q<6e4:!1,Se=j?xe?`${Math.max(0,Math.ceil((j.expiresAt-Q)/1e3))}s`:p.valid:``,$=e===`mobile`?{connect:a.mobileScan,connectHint:a.mobileScanHint,allowTitle:a.mobileAllowTitle,success:a.mobileSuccess,successHint:a.mobileSuccessHint}:{connect:a.browserConnect,connectHint:a.browserConnectHint,allowTitle:a.browserAllowTitle,success:a.browserSuccess,successHint:a.browserSuccessHint},Ce=e===`mobile`?a.mobilePrepareTitle:a.browserPrepareTitle,we=e===`mobile`?a.mobilePrepareHint:a.browserPrepareHint,Te=m?J?$.success:W?.status===`pending`?$.allowTitle:G||W?.status===`approved`?p.waiting:j?$.connect:p.title:Ce,Ee=N===`create`?p.createFailed:N===`decision`?p.decisionFailed:N===`background`?p.backgroundFailed:N===`download`?a.browserDownloadFailed:null,De=async()=>{I(!0),P(null);try{await ie()}catch{P(`download`)}finally{B.current&&I(!1)}};return(0,q.jsxs)(S,{children:[(0,q.jsx)(x,{className:_(`xopc-dialog-overlay fixed inset-0 bg-scrim backdrop-blur-[1px]`,D)}),(0,q.jsxs)(C,{className:_(`xopc-dialog-content fixed left-1/2 top-1/2 flex h-[min(600px,calc(100dvh-48px))] w-[min(560px,calc(100vw-32px))] -translate-x-1/2 -translate-y-1/2 flex-col overflow-hidden rounded-xl border border-edge bg-surface-overlay`,E),children:[(0,q.jsxs)(`header`,{className:`flex shrink-0 items-center justify-between border-b border-edge-subtle px-6 py-3`,children:[(0,q.jsx)(`span`,{className:`text-lg font-semibold tracking-tight text-fg`,children:`xopc`}),(0,q.jsx)(`button`,{type:`button`,className:`flex size-10 items-center justify-center rounded-lg text-fg-muted hover:bg-surface-hover`,"aria-label":p.cancel,onClick:t,children:(0,q.jsx)(g,{className:`size-4`})})]}),(0,q.jsxs)(`div`,{className:`flex min-h-0 flex-1 flex-col overflow-y-auto px-8 py-7`,children:[J?(0,q.jsx)(l,{className:`mb-5 size-7 text-success`}):null,(0,q.jsx)(w,{className:`text-xl font-semibold tracking-tight text-fg`,children:Te}),(0,q.jsx)(ee,{className:`mt-2 text-sm leading-relaxed text-fg-muted`,children:m?J?$.successHint:G?p.waitingForDevice:W?W.displayName:j?$.connectHint:p.intro:we}),Ee?(0,q.jsx)(`p`,{role:`alert`,className:`mt-4 text-sm text-danger`,children:Ee}):null,m&&T.error?(0,q.jsx)(`p`,{role:`alert`,className:`mt-4 text-sm text-danger`,children:p.readinessFailed}):null,m&&U.error?(0,q.jsx)(`p`,{role:`status`,className:`mt-4 text-sm text-warning`,children:p.statusUnavailable}):null,m?T.data?J?(0,q.jsxs)(q.Fragment,{children:[Y.data?(0,q.jsxs)(`label`,{className:`mt-8 flex items-center justify-between gap-4 border-y border-edge-subtle py-5 text-sm text-fg`,children:[a.background,(0,q.jsx)(`input`,{type:`checkbox`,role:`switch`,"aria-checked":Y.data.runInBackground??!1,disabled:!Y.data.backgroundSupported,checked:Y.data.runInBackground??!1,className:`size-5 accent-accent`,onChange:e=>{window.electronAPI.system.setBehavior({runInBackground:e.target.checked}).then(e=>Y.mutate(e.behavior)).catch(()=>P(`background`))}})]}):null,(0,q.jsx)(`p`,{className:`mt-4 text-xs text-fg-muted`,children:a.sleep})]}):be||ye?(0,q.jsxs)(`div`,{className:`mt-10 space-y-5`,children:[(0,q.jsx)(`p`,{className:`text-sm text-fg-muted`,children:ye||W?.status===`expired`?p.expired:p.declined}),(0,q.jsx)(y,{variant:`primary`,onClick:()=>void ge(),disabled:F,children:p.refresh})]}):W?(0,q.jsxs)(q.Fragment,{children:[(0,q.jsx)(`p`,{className:`mt-2 text-xs text-fg-muted`,children:p.scope}),(0,q.jsxs)(`p`,{className:`mt-10 font-mono text-4xl tracking-[0.16em] text-fg`,"aria-live":`polite`,children:[W.confirmationCode.slice(0,3),` `,W.confirmationCode.slice(3)]}),(0,q.jsx)(`p`,{className:`mt-3 text-xs text-fg-muted`,children:p.compare}),(0,q.jsxs)(`details`,{className:`mt-6 text-xs text-fg-muted`,children:[(0,q.jsx)(`summary`,{className:`cursor-pointer py-2`,children:p.access}),(0,q.jsx)(`p`,{children:p.accessHint})]})]}):j?.targetKind===`mobile`?(0,q.jsxs)(q.Fragment,{children:[(0,q.jsxs)(`div`,{className:`my-6 flex flex-col items-center`,children:[(0,q.jsx)(`div`,{className:`rounded-[1.75rem] border border-edge bg-surface-hover/55 p-2.5 shadow-surface`,children:(0,q.jsx)(`div`,{className:`rounded-[1.25rem] bg-white p-2 shadow-sm ring-1 ring-black/5`,children:Z.data?(0,q.jsx)(`img`,{src:Z.data,alt:a.qrAlt,width:240,height:240,className:`size-[240px] max-w-full rounded-xl bg-white`}):Z.error?null:(0,q.jsx)(b,{className:`size-[240px] rounded-xl`})})}),Z.error?null:(0,q.jsxs)(`p`,{className:_(`mt-4 inline-flex min-h-8 items-center gap-1.5 rounded-full px-3 text-xs font-medium`,xe?`bg-warning-soft text-warning`:`bg-surface-hover text-fg-muted`),"aria-live":`polite`,children:[(0,q.jsx)(u,{className:`size-3.5`,"aria-hidden":`true`}),Se]})]}),Z.error?(0,q.jsx)(`p`,{role:`status`,className:`text-center text-sm text-warning`,children:p.qrFailed}):null,Z.error?(0,q.jsx)(`div`,{className:`mt-5`,children:(0,q.jsx)(A,{text:j.universalLink,labels:{copy:a.copy,copied:a.copied,copyFailed:i.clipboard.copyFailed}})}):(0,q.jsxs)(`details`,{className:`group mx-auto mt-1 w-full max-w-sm rounded-xl border border-edge bg-surface-panel text-xs text-fg-muted`,children:[(0,q.jsxs)(`summary`,{className:`flex min-h-11 cursor-pointer list-none items-center justify-between gap-3 rounded-xl px-3.5 transition-colors hover:bg-surface-hover focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-accent [&::-webkit-details-marker]:hidden`,children:[(0,q.jsx)(`span`,{children:p.fallback}),(0,q.jsx)(c,{className:`size-3.5 shrink-0 transition-transform group-open:rotate-90`,"aria-hidden":`true`})]}),(0,q.jsx)(`div`,{className:`border-t border-edge-subtle p-3`,children:(0,q.jsx)(A,{text:j.universalLink,labels:{copy:a.copy,copied:a.copied,copyFailed:i.clipboard.copyFailed}})})]})]}):j?(0,q.jsxs)(q.Fragment,{children:[(0,q.jsxs)(`ol`,{className:`mt-7 space-y-2 text-sm leading-6 text-fg-muted`,children:[(0,q.jsxs)(`li`,{children:[(0,q.jsx)(`span`,{className:`mr-2 text-fg-subtle`,children:`1.`}),a.browserConnectStep1]}),(0,q.jsxs)(`li`,{children:[(0,q.jsx)(`span`,{className:`mr-2 text-fg-subtle`,children:`2.`}),a.browserConnectStep2]}),(0,q.jsxs)(`li`,{children:[(0,q.jsx)(`span`,{className:`mr-2 text-fg-subtle`,children:`3.`}),a.browserConnectStep3]})]}),(0,q.jsx)(`div`,{className:`mt-6`,children:(0,q.jsx)(A,{text:j.browserInvitation,labels:{copy:a.copy,copied:a.copied,copyFailed:i.clipboard.copyFailed}})}),(0,q.jsx)(`p`,{className:`mt-3 text-center text-xs text-fg-muted`,children:j.expiresAt-Q<6e4?`${Math.max(0,Math.ceil((j.expiresAt-Q)/1e3))}s`:p.valid})]}):T.data.ready?(0,q.jsx)(`div`,{className:`mt-8`,children:(0,q.jsx)(b,{className:`mx-auto size-[216px]`})}):(0,q.jsxs)(`div`,{className:`mt-6 flex flex-1 flex-col`,children:[R===`tailscale`?(0,q.jsx)(ne,{embedded:!0}):R===`https`?(0,q.jsx)(ue,{}):R===`choices`?(0,q.jsxs)(`div`,{className:`space-y-3`,children:[(0,q.jsx)(y,{variant:`secondary`,className:`w-full`,onClick:()=>z(`tailscale`),children:a.useTailscale}),(0,q.jsx)(y,{variant:`secondary`,className:`w-full`,onClick:()=>z(`https`),children:a.useOwnHttps})]}):(0,q.jsx)(fe,{}),(0,q.jsx)(y,{variant:`ghost`,className:`mt-3 w-full`,onClick:()=>z(R?null:`choices`),children:R?p.back:p.existing})]}):(0,q.jsxs)(`div`,{className:`mt-8 space-y-4`,children:[(0,q.jsx)(b,{className:`h-5 w-3/4`}),(0,q.jsx)(b,{className:`h-40 w-full`})]}):e===`mobile`?(0,q.jsxs)(`div`,{className:`mt-7 flex flex-col items-center`,children:[he.data?(0,q.jsx)(`img`,{src:he.data,alt:a.mobileDownloadQrAlt,width:144,height:144,className:`size-36 rounded-lg bg-white`}):(0,q.jsx)(b,{className:`size-36`}),(0,q.jsxs)(y,{variant:`secondary`,className:`mt-5 w-full`,onClick:()=>void O(pe),children:[(0,q.jsx)(f,{className:`size-4`}),a.mobileDownload]}),(0,q.jsx)(`p`,{className:`mt-3 text-center text-xs leading-5 text-fg-muted`,children:a.mobileDownloadHint})]}):(0,q.jsxs)(`div`,{className:`mt-7`,children:[(0,q.jsxs)(y,{variant:`secondary`,className:`w-full`,disabled:F,onClick:()=>void De(),children:[(0,q.jsx)(d,{className:`size-4`}),a.browserDownload]}),(0,q.jsxs)(`ol`,{className:`mt-5 space-y-3 text-sm leading-6 text-fg-muted`,children:[(0,q.jsxs)(`li`,{children:[(0,q.jsx)(`span`,{className:`mr-2 text-fg-subtle`,children:`1.`}),a.browserInstallStep1]}),(0,q.jsxs)(`li`,{children:[(0,q.jsx)(`span`,{className:`mr-2 text-fg-subtle`,children:`2.`}),a.browserInstallStep2]}),(0,q.jsxs)(`li`,{children:[(0,q.jsx)(`span`,{className:`mr-2 text-fg-subtle`,children:`3.`}),a.browserInstallStep3]})]}),(0,q.jsxs)(`button`,{type:`button`,className:`mt-5 inline-flex items-center gap-1 text-xs text-accent hover:underline`,onClick:()=>void O(me),children:[a.browserInstallHelp,(0,q.jsx)(f,{className:`size-3`})]})]})]}),!m||T.error||J||W?.status===`pending`||N===`create`||N===`decision`?(0,q.jsx)(`footer`,{className:`shrink-0 px-8 pb-6`,children:m?J?(0,q.jsx)(y,{className:`w-full`,variant:`primary`,onClick:t,children:p.done}):W?.status===`pending`?(0,q.jsxs)(`div`,{className:`flex flex-col gap-2`,children:[(0,q.jsx)(y,{className:`w-full`,variant:`primary`,disabled:F,onClick:()=>void _e(`approve`),children:p.allow}),(0,q.jsx)(y,{className:`w-full`,variant:`ghost`,disabled:F,onClick:()=>void _e(`reject`),children:p.cancel})]}):T.error?(0,q.jsx)(y,{className:`w-full`,variant:`primary`,onClick:()=>void T.mutate(),children:p.retry}):(0,q.jsx)(y,{className:`w-full`,variant:`primary`,disabled:F,onClick:()=>void ge(),children:p.retry}):(0,q.jsx)(y,{className:`w-full`,variant:`primary`,onClick:()=>{P(null),h(!0)},children:e===`mobile`?a.mobileReady:a.browserReady})}):null]})]})}export{J as n,Y as t};
1
+ import{i as e,n as t}from"./rolldown-runtime-aKtaBQYM.js";import{a as n,n as r,t as i}from"./vendor-react-BOUWij0V.js";import{u as a}from"./chunk-KS7C4IRE-CiwuuyV8.js";import{n as o}from"./locale-store-TQcz_Vjt.js";import{t as s}from"./messages-DaLmc4W1.js";import{t as c}from"./chevron-right-BweFrslA.js";import{t as l}from"./circle-check-C23XjkUj.js";import{t as u}from"./clock-3-DnrAnuyZ.js";import{t as d}from"./download-Dk-ZjtO6.js";import{t as f}from"./external-link-DjqjBmc3.js";import{t as p}from"./laptop-CI3hBVrl.js";import{t as m}from"./panel-right-CFGrHTsD.js";import{t as h}from"./smartphone-DSSsQFqA.js";import{t as g}from"./x-B_N4OPjy.js";import{t as _}from"./cn-0WouolD0.js";import{t as v}from"./button-CnRSIP6m.js";import{t as y}from"./skeleton-BI5TyibZ.js";import{a as b,i as ee,o as x,r as S,s as C,t as w}from"./dist-DfWfZ9iu.js";import{i as T,o as E}from"./settings-shell-dialog-layer-BU3UuiJr.js";import{i as D}from"./vendor-swr-CdRzEUwF.js";import{n as O}from"./app-link-1j40sJ-z.js";import{t as k}from"./use-async-resource-BHFGZCY2.js";import{t as A}from"./copy-text-row-CYIv7RfP.js";import{a as j,n as M,r as N}from"./oauth-api-CfKjRVnb.js";import{n as P,r as F,t as I}from"./oauth-authorization-window-o6URRos4.js";import{_ as L,a as te,b as ne,d as re,f as R,g as ie,h as ae,i as z,l as B,m as oe,n as V,p as se,r as H,s as ce,t as U,u as W,v as le,y as ue}from"./tunnel-api-COoVEdV9.js";import{t as de}from"./mobile-pair-qr-CuIbmw5x.js";var G=r(),K=e(n(),1),q=i();function fe(){let e=s(o(e=>e.language)),t=e.endpointToolsSettings.deviceAccess.flow,n=e.tunnelSettings,{data:r,error:i,mutate:a}=D(`tunnel-status`,V,{refreshInterval:1500}),[c,l]=(0,K.useState)(!1),[u,d]=(0,K.useState)(!1),[p,m]=(0,K.useState)(!0),[h,g]=(0,K.useState)(`idle`),[_,b]=(0,K.useState)(null),[ee,x]=(0,K.useState)(``),[S,C]=(0,K.useState)(``),w=(0,K.useRef)(!0);(0,K.useEffect)(()=>(w.current=!0,()=>{w.current=!1}),[]),(0,K.useEffect)(()=>{r?.state===`connected`&&(b(null),x(``))},[r?.state]);let T=_?_===`registration-rejected`:r?.state===`error`&&R(Error(r.lastError??``)),E=_?_===`recovery-rejected`:r?.state===`error`&&re(Error(r.lastError??``)),k=async()=>{if(!r)return;if(r.consentRequired&&!c){d(!0);return}let e=T||!r.registrationSecret?.configured,t=e?F():null,n,i=!1;b(null),x(``);try{if(r.consentRequired&&await te(),e){g(`provisioning`),T&&await H({registrationSecret:null});let e=!1;try{await z()}catch(t){if(!W(t))throw t;e=!0}if(e){g(`authorizing`);let e=sessionStorage.getItem(`device-pairing-oauth`),r=e?JSON.parse(e):null;n=r&&r.expiresAt>Date.now()?r.sessionId:(await j(`xopc-tunnel`)).sessionId,sessionStorage.setItem(`device-pairing-oauth`,JSON.stringify({sessionId:n,expiresAt:r&&r.expiresAt>Date.now()?r.expiresAt:Date.now()+5*6e4}));let a=``,o=Date.now()+5*6e4,s=!1;for(;w.current&&Date.now()<o;){let e=await N(n);if(e.authUrl&&e.authUrl!==a&&(a=e.authUrl,await P(a,t)||C(a)),e.status===`completed`){s=!0,i=!0;break}if(e.status===`failed`||e.status===`cancelled`)throw Error(`Authorization cancelled`);await new Promise(e=>setTimeout(e,1e3))}if(!w.current)return;if(!s)throw Error(`Authorization expired`);await z()}await a()}if(!w.current)return;g(`starting`),await ce(E?{recoverActiveLease:!0}:void 0),p&&await H({autoStart:!0}),await a(),i=!0}catch(e){i=!0,w.current&&(b(B(e)===`tunnel_key_limit_reached`?`key-limit`:R(e)?`registration-rejected`:re(e)?`recovery-rejected`:`failed`),x(e instanceof Error?e.message:``))}finally{I(t),i&&(sessionStorage.removeItem(`device-pairing-oauth`),n&&M(n).catch(()=>{})),w.current&&(g(`idle`),C(``))}};if(!r&&!i)return(0,q.jsxs)(`div`,{className:`space-y-5`,children:[(0,q.jsx)(y,{className:`h-5 w-4/5`}),(0,q.jsx)(y,{className:`h-24 w-full`})]});let A=h===`provisioning`||h===`starting`||r?.state===`connecting`||r?.state===`reconnecting`,L=h===`idle`&&!A&&(_||i||r?.state===`error`),ne=ee||(i instanceof Error?i.message:``)||(r?.state===`error`?r.lastError:``);return(0,q.jsxs)(`div`,{className:`flex flex-col`,children:[(0,q.jsx)(`p`,{className:`text-sm leading-relaxed text-fg-muted`,children:A?t.preparingHint:h===`authorizing`?t.authorizing:t.enableHint}),S&&h===`authorizing`?(0,q.jsx)(`a`,{href:S,target:`_blank`,rel:`noopener noreferrer`,className:`mt-4 inline-flex min-h-11 items-center text-sm text-accent`,children:t.openAuthorization}):null,A?(0,q.jsxs)(`div`,{className:`mt-8 space-y-3`,"aria-label":t.preparing,children:[(0,q.jsx)(y,{className:`h-2 w-full`}),(0,q.jsx)(`p`,{className:`text-sm text-fg-muted`,children:t.preparing})]}):null,(u||r?.consentRequired)&&h===`idle`?(0,q.jsxs)(`div`,{className:`mt-6 space-y-4`,children:[(0,q.jsxs)(`details`,{open:u,className:`text-sm text-fg-muted`,children:[(0,q.jsx)(`summary`,{className:`cursor-pointer py-2`,children:t.details}),(0,q.jsx)(`p`,{className:`mt-2`,children:n.consentIntro}),(0,q.jsx)(`ul`,{className:`mt-3 list-disc space-y-2 pl-5`,children:[n.consentBullet1,n.consentBullet2,n.consentBullet3].map(e=>(0,q.jsx)(`li`,{children:e},e))})]}),(0,q.jsxs)(`label`,{className:`flex items-start gap-3 text-sm text-fg`,children:[(0,q.jsx)(`input`,{type:`checkbox`,checked:c,onChange:e=>l(e.target.checked),className:`mt-1 size-4 accent-accent`}),n.consentCheckbox]})]}):null,L&&_===`key-limit`?(0,q.jsxs)(`div`,{role:`alert`,className:`mt-4 rounded-lg border border-warning/30 bg-warning/5 p-4`,children:[(0,q.jsx)(`p`,{className:`text-sm font-medium text-fg`,children:t.routeKeyLimitTitle}),(0,q.jsx)(`p`,{className:`mt-1 text-xs leading-5 text-fg-muted`,children:t.routeKeyLimitHint}),(0,q.jsxs)(v,{variant:`secondary`,className:`mt-3`,onClick:()=>void O(U),children:[t.manageTunnelKeys,(0,q.jsx)(f,{className:`size-3`})]})]}):L?(0,q.jsxs)(`div`,{role:`alert`,className:`mt-4 text-sm text-danger`,children:[(0,q.jsx)(`p`,{children:i&&!r?t.readinessFailed:T?t.routeAuthorizationRequired:E?t.routeRecoveryRequired:t.routeSetupFailed}),ne?(0,q.jsxs)(`details`,{className:`mt-2 text-xs text-fg-muted`,children:[(0,q.jsx)(`summary`,{className:`cursor-pointer py-2`,children:t.details}),(0,q.jsx)(`p`,{className:`break-words whitespace-pre-wrap`,children:ne})]}):null]}):null,(0,q.jsxs)(`label`,{className:`my-5 flex items-center gap-3 text-sm text-fg-muted`,children:[(0,q.jsx)(`input`,{type:`checkbox`,checked:p,disabled:h!==`idle`,onChange:e=>m(e.target.checked),className:`size-4 accent-accent`}),t.autoStart]}),i&&!r?(0,q.jsx)(v,{className:`w-full`,variant:`primary`,onClick:()=>void a().catch(()=>{}),children:t.retry}):(0,q.jsx)(v,{className:`w-full`,variant:`primary`,disabled:!r||h!==`idle`||A||u&&!c,onClick:()=>void k(),children:h===`authorizing`?t.authorizing:A?t.preparing:T?t.authorize:E?t.recoverRoute:L?t.retry:t.enable})]})}var J=t({DevicePairingWizard:()=>Y});function Y(e){let t=(0,G.c)(16),{open:n,onOpenChange:r,onPaired:i,targetKind:o}=e,s=a(),[c,l]=(0,K.useState)(o),u,d;t[0]===o?(u=t[1],d=t[2]):(u=()=>{l(o)},d=[o],t[0]=o,t[1]=u,t[2]=d),(0,K.useEffect)(u,d);let f;t[3]!==r||t[4]!==o?(f=e=>{e||l(o),r(e)},t[3]=r,t[4]=o,t[5]=f):f=t[5];let p=f,m;t[6]!==p||t[7]!==s||t[8]!==i||t[9]!==n||t[10]!==c?(m=n?c?(0,q.jsx)(me,{targetKind:c,onClose:()=>p(!1),onPaired:i}):(0,q.jsx)(Z,{onChoose:l,onChooseLocalBrowser:()=>{p(!1),s(`/settings/agent-browser?driver=extension`)},onClose:()=>p(!1)}):null,t[6]=p,t[7]=s,t[8]=i,t[9]=n,t[10]=c,t[11]=m):m=t[11];let h;return t[12]!==p||t[13]!==n||t[14]!==m?(h=(0,q.jsx)(w,{open:n,onOpenChange:p,children:m}),t[12]=p,t[13]=n,t[14]=m,t[15]=h):h=t[15],h}function X(e){let t=(0,G.c)(14),{icon:n,title:r,hint:i,onClick:a}=e,o;t[0]===n?o=t[1]:(o=(0,q.jsx)(`span`,{className:`flex size-10 shrink-0 items-center justify-center rounded-xl bg-accent-soft text-accent-fg`,children:(0,q.jsx)(n,{className:`size-5`,"aria-hidden":`true`})}),t[0]=n,t[1]=o);let s;t[2]===r?s=t[3]:(s=(0,q.jsx)(`span`,{className:`block text-sm font-semibold text-fg`,children:r}),t[2]=r,t[3]=s);let l;t[4]===i?l=t[5]:(l=(0,q.jsx)(`span`,{className:`mt-0.5 block text-xs leading-5 text-fg-muted`,children:i}),t[4]=i,t[5]=l);let u;t[6]!==s||t[7]!==l?(u=(0,q.jsxs)(`span`,{className:`min-w-0 flex-1`,children:[s,l]}),t[6]=s,t[7]=l,t[8]=u):u=t[8];let d;t[9]===Symbol.for(`react.memo_cache_sentinel`)?(d=(0,q.jsx)(c,{className:`size-4 shrink-0 text-fg-disabled transition-transform group-hover:translate-x-0.5 group-hover:text-fg-muted`,"aria-hidden":`true`}),t[9]=d):d=t[9];let f;return t[10]!==a||t[11]!==o||t[12]!==u?(f=(0,q.jsxs)(`button`,{type:`button`,className:`group flex min-h-18 w-full cursor-pointer items-center gap-4 rounded-xl border border-edge bg-surface-panel px-4 py-3.5 text-left shadow-surface transition-[background-color,border-color,box-shadow,transform] hover:border-edge-strong hover:bg-surface-active hover:shadow-elevated active:translate-y-px active:bg-surface-hover focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-accent focus-visible:ring-offset-2 focus-visible:ring-offset-surface-panel motion-reduce:active:translate-y-0`,onClick:a,children:[o,u,d]}),t[10]=a,t[11]=o,t[12]=u,t[13]=f):f=t[13],f}function Z(e){let t=(0,G.c)(40),{onChoose:n,onChooseLocalBrowser:r,onClose:i}=e,a=o(pe),c;t[0]===a?c=t[1]:(c=s(a),t[0]=a,t[1]=c);let l=c.endpointToolsSettings.deviceAccess,u;t[2]===Symbol.for(`react.memo_cache_sentinel`)?(u=(0,q.jsx)(b,{className:_(`xopc-dialog-overlay fixed inset-0 bg-scrim backdrop-blur-[1px]`,E)}),t[2]=u):u=t[2];let d;t[3]===Symbol.for(`react.memo_cache_sentinel`)?(d=_(`xopc-dialog-content fixed left-1/2 top-1/2 flex h-[min(28rem,calc(100dvh-2rem))] w-[min(40rem,calc(100vw-2rem))] -translate-x-1/2 -translate-y-1/2 flex-col overflow-hidden rounded-xl border border-edge bg-surface-overlay`,T),t[3]=d):d=t[3];let f;t[4]===Symbol.for(`react.memo_cache_sentinel`)?(f=(0,q.jsx)(`span`,{className:`text-lg font-semibold tracking-tight text-fg`,children:`xopc`}),t[4]=f):f=t[4];let v;t[5]===Symbol.for(`react.memo_cache_sentinel`)?(v=(0,q.jsx)(g,{className:`size-4`}),t[5]=v):v=t[5];let y;t[6]!==l.cancel||t[7]!==i?(y=(0,q.jsxs)(`header`,{className:`flex shrink-0 items-center justify-between border-b border-edge-subtle px-6 py-3`,children:[f,(0,q.jsx)(`button`,{type:`button`,className:`flex size-10 items-center justify-center rounded-lg text-fg-muted hover:bg-surface-hover`,"aria-label":l.cancel,onClick:i,children:v})]}),t[6]=l.cancel,t[7]=i,t[8]=y):y=t[8];let w;t[9]===l.chooseTitle?w=t[10]:(w=(0,q.jsx)(C,{className:`text-lg font-semibold tracking-tight text-fg sm:text-xl`,children:l.chooseTitle}),t[9]=l.chooseTitle,t[10]=w);let D;t[11]===l.chooseHint?D=t[12]:(D=(0,q.jsx)(ee,{className:`mt-1.5 text-sm leading-6 text-fg-muted`,children:l.chooseHint}),t[11]=l.chooseHint,t[12]=D);let O;t[13]!==l.localBrowserHint||t[14]!==l.localBrowserTitle||t[15]!==r?(O=(0,q.jsx)(X,{icon:p,title:l.localBrowserTitle,hint:l.localBrowserHint,onClick:r}),t[13]=l.localBrowserHint,t[14]=l.localBrowserTitle,t[15]=r,t[16]=O):O=t[16];let k;t[17]===n?k=t[18]:(k=()=>n(`mobile`),t[17]=n,t[18]=k);let A;t[19]!==l.mobileHint||t[20]!==l.mobileTitle||t[21]!==k?(A=(0,q.jsx)(X,{icon:h,title:l.mobileTitle,hint:l.mobileHint,onClick:k}),t[19]=l.mobileHint,t[20]=l.mobileTitle,t[21]=k,t[22]=A):A=t[22];let j;t[23]===n?j=t[24]:(j=()=>n(`browser`),t[23]=n,t[24]=j);let M;t[25]!==l.remoteBrowserHint||t[26]!==l.remoteBrowserTitle||t[27]!==j?(M=(0,q.jsx)(X,{icon:m,title:l.remoteBrowserTitle,hint:l.remoteBrowserHint,onClick:j}),t[25]=l.remoteBrowserHint,t[26]=l.remoteBrowserTitle,t[27]=j,t[28]=M):M=t[28];let N;t[29]!==A||t[30]!==M||t[31]!==O?(N=(0,q.jsxs)(`div`,{className:`mt-5 flex flex-col gap-2.5`,children:[O,A,M]}),t[29]=A,t[30]=M,t[31]=O,t[32]=N):N=t[32];let P;t[33]!==N||t[34]!==w||t[35]!==D?(P=(0,q.jsxs)(`div`,{className:`min-h-0 flex-1 overflow-y-auto px-5 py-6 sm:px-8`,children:[w,D,N]}),t[33]=N,t[34]=w,t[35]=D,t[36]=P):P=t[36];let F;return t[37]!==P||t[38]!==y?(F=(0,q.jsxs)(x,{children:[u,(0,q.jsxs)(S,{className:d,children:[y,P]})]}),t[37]=P,t[38]=y,t[39]=F):F=t[39],F}function pe(e){return e.language}function me({targetKind:e,onClose:t,onPaired:n}){let r=o(e=>e.language),i=s(r),a=i.endpointToolsSettings.deviceAccess,p=a.flow,[m,h]=(0,K.useState)(!1),w=D(m?`device-pairing-readiness`:null,L,{refreshInterval:1500}),[j,M]=(0,K.useState)(),[N,P]=(0,K.useState)(null),[F,I]=(0,K.useState)(!1),[te,re]=(0,K.useState)(Date.now()),[R,z]=(0,K.useState)(null),B=(0,K.useRef)(!0),V=(0,K.useRef)(null),H=(0,K.useRef)(!1),ce=(0,K.useRef)(!1),U=D(j?[`device-pairing-setup`,j.id]:null,()=>le(j.id),{refreshInterval:1500}),W=U.data?.request,G=W?.status===`completed`,J=G&&W.connectedAt!==void 0,Y=D(J&&window.electronAPI?.system?`system-behavior`:null,()=>window.electronAPI.system.getBehavior()),X=j?.targetKind===`mobile`?j.universalLink:``,Z=k(()=>de(X),[X],{enabled:!!X,initial:null,errorData:null}),pe=r===`zh`?`https://xopc.ai/zh#download`:`https://xopc.ai/en#download`,me=r===`zh`?`https://xopcai.github.io/xopc/zh/browser-extension`:`https://xopcai.github.io/xopc/browser-extension`,he=k(()=>de(pe),[pe],{enabled:!m&&e===`mobile`,initial:null,errorData:null});(0,K.useEffect)(()=>{B.current=!0;let e=setInterval(()=>re(Date.now()),1e3);return()=>{B.current=!1,clearInterval(e),V.current&&se(V.current).catch(()=>{})}},[]);let ge=(0,K.useCallback)(async()=>{if(!H.current){H.current=!0,I(!0),P(null);try{V.current&&await se(V.current),V.current=null,M(void 0);let t=await oe(e);if(t.kind===`ready`){if(!B.current){await se(t.setup.id);return}V.current=t.setup.id,M(t.setup)}else await w.mutate()}catch{B.current&&P(`create`)}finally{H.current=!1,B.current&&I(!1)}}},[w,e]);(0,K.useEffect)(()=>{w.data?.ready&&!j&&N!==`create`&&!H.current&&ge()},[w.data,j,N,ge]),(0,K.useEffect)(()=>{J&&!ce.current&&(ce.current=!0,n?.())},[J,n]);let _e=async e=>{if(W){I(!0),P(null);try{await ae(W,e),await U.mutate()}catch{P(`decision`),await U.mutate()}finally{B.current&&I(!1)}}},ve=(0,K.useRef)(0);(0,K.useEffect)(()=>{U.data&&(ve.current=U.data.serverTime-Date.now())},[U.data]);let Q=te+ve.current,ye=j&&Q>=j.expiresAt&&!W,be=W&&[`expired`,`rejected`,`cancelled`].includes(W.status),xe=j?j.expiresAt-Q<6e4:!1,Se=j?xe?`${Math.max(0,Math.ceil((j.expiresAt-Q)/1e3))}s`:p.valid:``,$=e===`mobile`?{connect:a.mobileScan,connectHint:a.mobileScanHint,allowTitle:a.mobileAllowTitle,success:a.mobileSuccess,successHint:a.mobileSuccessHint}:{connect:a.browserConnect,connectHint:a.browserConnectHint,allowTitle:a.browserAllowTitle,success:a.browserSuccess,successHint:a.browserSuccessHint},Ce=e===`mobile`?a.mobilePrepareTitle:a.browserPrepareTitle,we=e===`mobile`?a.mobilePrepareHint:a.browserPrepareHint,Te=m?J?$.success:W?.status===`pending`?$.allowTitle:G||W?.status===`approved`?p.waiting:j?$.connect:p.title:Ce,Ee=N===`create`?p.createFailed:N===`decision`?p.decisionFailed:N===`background`?p.backgroundFailed:N===`download`?a.browserDownloadFailed:null,De=async()=>{I(!0),P(null);try{await ie()}catch{P(`download`)}finally{B.current&&I(!1)}};return(0,q.jsxs)(x,{children:[(0,q.jsx)(b,{className:_(`xopc-dialog-overlay fixed inset-0 bg-scrim backdrop-blur-[1px]`,E)}),(0,q.jsxs)(S,{className:_(`xopc-dialog-content fixed left-1/2 top-1/2 flex h-[min(600px,calc(100dvh-48px))] w-[min(560px,calc(100vw-32px))] -translate-x-1/2 -translate-y-1/2 flex-col overflow-hidden rounded-xl border border-edge bg-surface-overlay`,T),children:[(0,q.jsxs)(`header`,{className:`flex shrink-0 items-center justify-between border-b border-edge-subtle px-6 py-3`,children:[(0,q.jsx)(`span`,{className:`text-lg font-semibold tracking-tight text-fg`,children:`xopc`}),(0,q.jsx)(`button`,{type:`button`,className:`flex size-10 items-center justify-center rounded-lg text-fg-muted hover:bg-surface-hover`,"aria-label":p.cancel,onClick:t,children:(0,q.jsx)(g,{className:`size-4`})})]}),(0,q.jsxs)(`div`,{className:`flex min-h-0 flex-1 flex-col overflow-y-auto px-8 py-7`,children:[J?(0,q.jsx)(l,{className:`mb-5 size-7 text-success`}):null,(0,q.jsx)(C,{className:`text-xl font-semibold tracking-tight text-fg`,children:Te}),(0,q.jsx)(ee,{className:`mt-2 text-sm leading-relaxed text-fg-muted`,children:m?J?$.successHint:G?p.waitingForDevice:W?W.displayName:j?$.connectHint:p.intro:we}),Ee?(0,q.jsx)(`p`,{role:`alert`,className:`mt-4 text-sm text-danger`,children:Ee}):null,m&&w.error?(0,q.jsx)(`p`,{role:`alert`,className:`mt-4 text-sm text-danger`,children:p.readinessFailed}):null,m&&U.error?(0,q.jsx)(`p`,{role:`status`,className:`mt-4 text-sm text-warning`,children:p.statusUnavailable}):null,m?w.data?J?(0,q.jsxs)(q.Fragment,{children:[Y.data?(0,q.jsxs)(`label`,{className:`mt-8 flex items-center justify-between gap-4 border-y border-edge-subtle py-5 text-sm text-fg`,children:[a.background,(0,q.jsx)(`input`,{type:`checkbox`,role:`switch`,"aria-checked":Y.data.runInBackground??!1,disabled:!Y.data.backgroundSupported,checked:Y.data.runInBackground??!1,className:`size-5 accent-accent`,onChange:e=>{window.electronAPI.system.setBehavior({runInBackground:e.target.checked}).then(e=>Y.mutate(e.behavior)).catch(()=>P(`background`))}})]}):null,(0,q.jsx)(`p`,{className:`mt-4 text-xs text-fg-muted`,children:a.sleep})]}):be||ye?(0,q.jsxs)(`div`,{className:`mt-10 space-y-5`,children:[(0,q.jsx)(`p`,{className:`text-sm text-fg-muted`,children:ye||W?.status===`expired`?p.expired:p.declined}),(0,q.jsx)(v,{variant:`primary`,onClick:()=>void ge(),disabled:F,children:p.refresh})]}):W?(0,q.jsxs)(q.Fragment,{children:[(0,q.jsx)(`p`,{className:`mt-2 text-xs text-fg-muted`,children:p.scope}),(0,q.jsxs)(`p`,{className:`mt-10 font-mono text-4xl tracking-[0.16em] text-fg`,"aria-live":`polite`,children:[W.confirmationCode.slice(0,3),` `,W.confirmationCode.slice(3)]}),(0,q.jsx)(`p`,{className:`mt-3 text-xs text-fg-muted`,children:p.compare}),(0,q.jsxs)(`details`,{className:`mt-6 text-xs text-fg-muted`,children:[(0,q.jsx)(`summary`,{className:`cursor-pointer py-2`,children:p.access}),(0,q.jsx)(`p`,{children:p.accessHint})]})]}):j?.targetKind===`mobile`?(0,q.jsxs)(q.Fragment,{children:[(0,q.jsxs)(`div`,{className:`my-6 flex flex-col items-center`,children:[(0,q.jsx)(`div`,{className:`rounded-[1.75rem] border border-edge bg-surface-hover/55 p-2.5 shadow-surface`,children:(0,q.jsx)(`div`,{className:`rounded-[1.25rem] bg-white p-2 shadow-sm ring-1 ring-black/5`,children:Z.data?(0,q.jsx)(`img`,{src:Z.data,alt:a.qrAlt,width:240,height:240,className:`size-[240px] max-w-full rounded-xl bg-white`}):Z.error?null:(0,q.jsx)(y,{className:`size-[240px] rounded-xl`})})}),Z.error?null:(0,q.jsxs)(`p`,{className:_(`mt-4 inline-flex min-h-8 items-center gap-1.5 rounded-full px-3 text-xs font-medium`,xe?`bg-warning-soft text-warning`:`bg-surface-hover text-fg-muted`),"aria-live":`polite`,children:[(0,q.jsx)(u,{className:`size-3.5`,"aria-hidden":`true`}),Se]})]}),Z.error?(0,q.jsx)(`p`,{role:`status`,className:`text-center text-sm text-warning`,children:p.qrFailed}):null,Z.error?(0,q.jsx)(`div`,{className:`mt-5`,children:(0,q.jsx)(A,{text:j.universalLink,labels:{copy:a.copy,copied:a.copied,copyFailed:i.clipboard.copyFailed}})}):(0,q.jsxs)(`details`,{className:`group mx-auto mt-1 w-full max-w-sm rounded-xl border border-edge bg-surface-panel text-xs text-fg-muted`,children:[(0,q.jsxs)(`summary`,{className:`flex min-h-11 cursor-pointer list-none items-center justify-between gap-3 rounded-xl px-3.5 transition-colors hover:bg-surface-hover focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-accent [&::-webkit-details-marker]:hidden`,children:[(0,q.jsx)(`span`,{children:p.fallback}),(0,q.jsx)(c,{className:`size-3.5 shrink-0 transition-transform group-open:rotate-90`,"aria-hidden":`true`})]}),(0,q.jsx)(`div`,{className:`border-t border-edge-subtle p-3`,children:(0,q.jsx)(A,{text:j.universalLink,labels:{copy:a.copy,copied:a.copied,copyFailed:i.clipboard.copyFailed}})})]})]}):j?(0,q.jsxs)(q.Fragment,{children:[(0,q.jsxs)(`ol`,{className:`mt-7 space-y-2 text-sm leading-6 text-fg-muted`,children:[(0,q.jsxs)(`li`,{children:[(0,q.jsx)(`span`,{className:`mr-2 text-fg-subtle`,children:`1.`}),a.browserConnectStep1]}),(0,q.jsxs)(`li`,{children:[(0,q.jsx)(`span`,{className:`mr-2 text-fg-subtle`,children:`2.`}),a.browserConnectStep2]}),(0,q.jsxs)(`li`,{children:[(0,q.jsx)(`span`,{className:`mr-2 text-fg-subtle`,children:`3.`}),a.browserConnectStep3]})]}),(0,q.jsx)(`div`,{className:`mt-6`,children:(0,q.jsx)(A,{text:j.browserInvitation,labels:{copy:a.copy,copied:a.copied,copyFailed:i.clipboard.copyFailed}})}),(0,q.jsx)(`p`,{className:`mt-3 text-center text-xs text-fg-muted`,children:j.expiresAt-Q<6e4?`${Math.max(0,Math.ceil((j.expiresAt-Q)/1e3))}s`:p.valid})]}):w.data.ready?(0,q.jsx)(`div`,{className:`mt-8`,children:(0,q.jsx)(y,{className:`mx-auto size-[216px]`})}):(0,q.jsxs)(`div`,{className:`mt-6 flex flex-1 flex-col`,children:[R===`tailscale`?(0,q.jsx)(ne,{embedded:!0}):R===`https`?(0,q.jsx)(ue,{}):R===`choices`?(0,q.jsxs)(`div`,{className:`space-y-3`,children:[(0,q.jsx)(v,{variant:`secondary`,className:`w-full`,onClick:()=>z(`tailscale`),children:a.useTailscale}),(0,q.jsx)(v,{variant:`secondary`,className:`w-full`,onClick:()=>z(`https`),children:a.useOwnHttps})]}):(0,q.jsx)(fe,{}),(0,q.jsx)(v,{variant:`ghost`,className:`mt-3 w-full`,onClick:()=>z(R?null:`choices`),children:R?p.back:p.existing})]}):(0,q.jsxs)(`div`,{className:`mt-8 space-y-4`,children:[(0,q.jsx)(y,{className:`h-5 w-3/4`}),(0,q.jsx)(y,{className:`h-40 w-full`})]}):e===`mobile`?(0,q.jsxs)(`div`,{className:`mt-7 flex flex-col items-center`,children:[he.data?(0,q.jsx)(`img`,{src:he.data,alt:a.mobileDownloadQrAlt,width:144,height:144,className:`size-36 rounded-lg bg-white`}):(0,q.jsx)(y,{className:`size-36`}),(0,q.jsxs)(v,{variant:`secondary`,className:`mt-5 w-full`,onClick:()=>void O(pe),children:[(0,q.jsx)(f,{className:`size-4`}),a.mobileDownload]}),(0,q.jsx)(`p`,{className:`mt-3 text-center text-xs leading-5 text-fg-muted`,children:a.mobileDownloadHint})]}):(0,q.jsxs)(`div`,{className:`mt-7`,children:[(0,q.jsxs)(v,{variant:`secondary`,className:`w-full`,disabled:F,onClick:()=>void De(),children:[(0,q.jsx)(d,{className:`size-4`}),a.browserDownload]}),(0,q.jsxs)(`ol`,{className:`mt-5 space-y-3 text-sm leading-6 text-fg-muted`,children:[(0,q.jsxs)(`li`,{children:[(0,q.jsx)(`span`,{className:`mr-2 text-fg-subtle`,children:`1.`}),a.browserInstallStep1]}),(0,q.jsxs)(`li`,{children:[(0,q.jsx)(`span`,{className:`mr-2 text-fg-subtle`,children:`2.`}),a.browserInstallStep2]}),(0,q.jsxs)(`li`,{children:[(0,q.jsx)(`span`,{className:`mr-2 text-fg-subtle`,children:`3.`}),a.browserInstallStep3]})]}),(0,q.jsxs)(`button`,{type:`button`,className:`mt-5 inline-flex items-center gap-1 text-xs text-accent hover:underline`,onClick:()=>void O(me),children:[a.browserInstallHelp,(0,q.jsx)(f,{className:`size-3`})]})]})]}),!m||w.error||J||W?.status===`pending`||N===`create`||N===`decision`?(0,q.jsx)(`footer`,{className:`shrink-0 px-8 pb-6`,children:m?J?(0,q.jsx)(v,{className:`w-full`,variant:`primary`,onClick:t,children:p.done}):W?.status===`pending`?(0,q.jsxs)(`div`,{className:`flex flex-col gap-2`,children:[(0,q.jsx)(v,{className:`w-full`,variant:`primary`,disabled:F,onClick:()=>void _e(`approve`),children:p.allow}),(0,q.jsx)(v,{className:`w-full`,variant:`ghost`,disabled:F,onClick:()=>void _e(`reject`),children:p.cancel})]}):w.error?(0,q.jsx)(v,{className:`w-full`,variant:`primary`,onClick:()=>void w.mutate(),children:p.retry}):(0,q.jsx)(v,{className:`w-full`,variant:`primary`,disabled:F,onClick:()=>void ge(),children:p.retry}):(0,q.jsx)(v,{className:`w-full`,variant:`primary`,onClick:()=>{P(null),h(!0)},children:e===`mobile`?a.mobileReady:a.browserReady})}):null]})]})}export{J as n,Y as t};
@@ -1 +1 @@
1
- import{n as e,t}from"./vendor-react-BOUWij0V.js";import{r as n,t as r}from"./working-directory-picker-modal-E9f8G3se.js";import{t as i}from"./cn-0WouolD0.js";import{n as a}from"./interaction-BdhHBbYa.js";import{n as o,t as s}from"./use-directory-picker-C4p7AgWY.js";var c=e(),l=t();function u(e){let t=(0,c.c)(27),{value:r,onPick:s,disabled:u,placeholder:d,title:f,className:p,maxWidthClass:m,compact:h,"aria-label":g}=e,_=m===void 0?`max-w-[min(12rem,40vw)]`:m,v=h!==void 0&&h,y,b;t[0]!==d||t[1]!==r?(b=r.trim(),y=b?o(b):d??``,t[0]=d,t[1]=r,t[2]=y,t[3]=b):(y=t[2],b=t[3]);let x=y,S=f??(b||void 0),C=g??f??x,w=v?`inline-flex size-9 shrink-0 items-center justify-center rounded-lg p-0`:`inline-flex min-h-8 min-w-0 shrink-0 items-center gap-1 rounded-lg px-2 py-1 text-xs`,T=!v&&_,E=u&&`cursor-not-allowed opacity-60`,D;t[4]!==p||t[5]!==w||t[6]!==T||t[7]!==E?(D=i(w,`border border-edge-subtle/80 bg-surface-hover/40 dark:border-edge-subtle`,a.transition,a.focusRingPanel,`cursor-pointer hover:bg-surface-hover/70 dark:hover:bg-surface-hover/50`,T,E,p),t[4]=p,t[5]=w,t[6]=T,t[7]=E,t[8]=D):D=t[8];let O;t[9]!==u||t[10]!==s?(O=e=>{e.stopPropagation(),u||s()},t[9]=u,t[10]=s,t[11]=O):O=t[11];let k=v?`size-4`:`size-3.5`,A;t[12]===k?A=t[13]:(A=i(`shrink-0 text-fg-muted`,k),t[12]=k,t[13]=A);let j;t[14]===A?j=t[15]:(j=(0,l.jsx)(n,{className:A,"aria-hidden":!0}),t[14]=A,t[15]=j);let M;t[16]!==v||t[17]!==x?(M=v?null:(0,l.jsx)(`span`,{className:`min-w-0 truncate text-left font-medium text-fg`,children:x}),t[16]=v,t[17]=x,t[18]=M):M=t[18];let N;return t[19]!==u||t[20]!==O||t[21]!==j||t[22]!==M||t[23]!==S||t[24]!==C||t[25]!==D?(N=(0,l.jsxs)(`button`,{type:`button`,disabled:u,title:S,"aria-label":C,className:D,onClick:O,children:[j,M]}),t[19]=u,t[20]=O,t[21]=j,t[22]=M,t[23]=S,t[24]=C,t[25]=D,t[26]=N):N=t[26],N}function d(e){let t=(0,c.c)(39),{value:n,onChange:a,disabled:o,wd:d,placeholder:f,inputAriaLabel:p,inputClassName:m,autoFocus:h,trailing:g}=e,_;t[0]!==a||t[1]!==n?(_={initialPath:n,onPicked:a},t[0]=a,t[1]=n,t[2]=_):_=t[2];let v=s(_),y;t[3]===n?y=t[4]:(y=n.trim(),t[3]=n,t[4]=y);let b=y,x=b?`${b}\n${d.chooseFolder}`:`${f??d.notSet}\n${d.selectWorkingDirectory}`,S;t[5]===m?S=t[6]:(S=i(`min-w-0 flex-1`,m),t[5]=m,t[6]=S);let C=o||v.picking,w;t[7]===a?w=t[8]:(w=e=>void a(e.target.value),t[7]=a,t[8]=w);let T=f??d.pathInputPlaceholder,E;t[9]!==h||t[10]!==p||t[11]!==S||t[12]!==C||t[13]!==w||t[14]!==T||t[15]!==n?(E=(0,l.jsx)(`input`,{type:`text`,className:S,value:n,disabled:C,onChange:w,placeholder:T,"aria-label":p,autoFocus:h,autoComplete:`off`,spellCheck:!1}),t[9]=h,t[10]=p,t[11]=S,t[12]=C,t[13]=w,t[14]=T,t[15]=n,t[16]=E):E=t[16];let D=o||v.picking,O;t[17]!==x||t[18]!==v.pick||t[19]!==D||t[20]!==n||t[21]!==d.selectWorkingDirectory?(O=(0,l.jsx)(u,{compact:!0,value:n,onPick:v.pick,disabled:D,title:x,"aria-label":d.selectWorkingDirectory}),t[17]=x,t[18]=v.pick,t[19]=D,t[20]=n,t[21]=d.selectWorkingDirectory,t[22]=O):O=t[22];let k;t[23]!==O||t[24]!==g?(k=(0,l.jsxs)(`div`,{className:`flex shrink-0 flex-wrap items-center gap-2`,children:[O,g]}),t[23]=O,t[24]=g,t[25]=k):k=t[25];let A;t[26]!==k||t[27]!==E?(A=(0,l.jsxs)(`div`,{className:`flex flex-col gap-2 sm:flex-row sm:items-center`,children:[E,k]}),t[26]=k,t[27]=E,t[28]=A):A=t[28];let j;t[29]!==v.confirmPick||t[30]!==v.hasNativePicker||t[31]!==v.modalOpen||t[32]!==v.setModalOpen||t[33]!==b||t[34]!==d?(j=v.hasNativePicker?null:(0,l.jsx)(r,{open:v.modalOpen,onOpenChange:v.setModalOpen,initialAbsolutePath:b||void 0,onConfirm:v.confirmPick,wd:d}),t[29]=v.confirmPick,t[30]=v.hasNativePicker,t[31]=v.modalOpen,t[32]=v.setModalOpen,t[33]=b,t[34]=d,t[35]=j):j=t[35];let M;return t[36]!==A||t[37]!==j?(M=(0,l.jsxs)(l.Fragment,{children:[A,j]}),t[36]=A,t[37]=j,t[38]=M):M=t[38],M}export{d as t};
1
+ import{n as e,t}from"./vendor-react-BOUWij0V.js";import{r as n,t as r}from"./working-directory-picker-modal-D2Zf3GOG.js";import{t as i}from"./cn-0WouolD0.js";import{n as a}from"./interaction-BdhHBbYa.js";import{n as o,t as s}from"./use-directory-picker-C4p7AgWY.js";var c=e(),l=t();function u(e){let t=(0,c.c)(27),{value:r,onPick:s,disabled:u,placeholder:d,title:f,className:p,maxWidthClass:m,compact:h,"aria-label":g}=e,_=m===void 0?`max-w-[min(12rem,40vw)]`:m,v=h!==void 0&&h,y,b;t[0]!==d||t[1]!==r?(b=r.trim(),y=b?o(b):d??``,t[0]=d,t[1]=r,t[2]=y,t[3]=b):(y=t[2],b=t[3]);let x=y,S=f??(b||void 0),C=g??f??x,w=v?`inline-flex size-9 shrink-0 items-center justify-center rounded-lg p-0`:`inline-flex min-h-8 min-w-0 shrink-0 items-center gap-1 rounded-lg px-2 py-1 text-xs`,T=!v&&_,E=u&&`cursor-not-allowed opacity-60`,D;t[4]!==p||t[5]!==w||t[6]!==T||t[7]!==E?(D=i(w,`border border-edge-subtle/80 bg-surface-hover/40 dark:border-edge-subtle`,a.transition,a.focusRingPanel,`cursor-pointer hover:bg-surface-hover/70 dark:hover:bg-surface-hover/50`,T,E,p),t[4]=p,t[5]=w,t[6]=T,t[7]=E,t[8]=D):D=t[8];let O;t[9]!==u||t[10]!==s?(O=e=>{e.stopPropagation(),u||s()},t[9]=u,t[10]=s,t[11]=O):O=t[11];let k=v?`size-4`:`size-3.5`,A;t[12]===k?A=t[13]:(A=i(`shrink-0 text-fg-muted`,k),t[12]=k,t[13]=A);let j;t[14]===A?j=t[15]:(j=(0,l.jsx)(n,{className:A,"aria-hidden":!0}),t[14]=A,t[15]=j);let M;t[16]!==v||t[17]!==x?(M=v?null:(0,l.jsx)(`span`,{className:`min-w-0 truncate text-left font-medium text-fg`,children:x}),t[16]=v,t[17]=x,t[18]=M):M=t[18];let N;return t[19]!==u||t[20]!==O||t[21]!==j||t[22]!==M||t[23]!==S||t[24]!==C||t[25]!==D?(N=(0,l.jsxs)(`button`,{type:`button`,disabled:u,title:S,"aria-label":C,className:D,onClick:O,children:[j,M]}),t[19]=u,t[20]=O,t[21]=j,t[22]=M,t[23]=S,t[24]=C,t[25]=D,t[26]=N):N=t[26],N}function d(e){let t=(0,c.c)(39),{value:n,onChange:a,disabled:o,wd:d,placeholder:f,inputAriaLabel:p,inputClassName:m,autoFocus:h,trailing:g}=e,_;t[0]!==a||t[1]!==n?(_={initialPath:n,onPicked:a},t[0]=a,t[1]=n,t[2]=_):_=t[2];let v=s(_),y;t[3]===n?y=t[4]:(y=n.trim(),t[3]=n,t[4]=y);let b=y,x=b?`${b}\n${d.chooseFolder}`:`${f??d.notSet}\n${d.selectWorkingDirectory}`,S;t[5]===m?S=t[6]:(S=i(`min-w-0 flex-1`,m),t[5]=m,t[6]=S);let C=o||v.picking,w;t[7]===a?w=t[8]:(w=e=>void a(e.target.value),t[7]=a,t[8]=w);let T=f??d.pathInputPlaceholder,E;t[9]!==h||t[10]!==p||t[11]!==S||t[12]!==C||t[13]!==w||t[14]!==T||t[15]!==n?(E=(0,l.jsx)(`input`,{type:`text`,className:S,value:n,disabled:C,onChange:w,placeholder:T,"aria-label":p,autoFocus:h,autoComplete:`off`,spellCheck:!1}),t[9]=h,t[10]=p,t[11]=S,t[12]=C,t[13]=w,t[14]=T,t[15]=n,t[16]=E):E=t[16];let D=o||v.picking,O;t[17]!==x||t[18]!==v.pick||t[19]!==D||t[20]!==n||t[21]!==d.selectWorkingDirectory?(O=(0,l.jsx)(u,{compact:!0,value:n,onPick:v.pick,disabled:D,title:x,"aria-label":d.selectWorkingDirectory}),t[17]=x,t[18]=v.pick,t[19]=D,t[20]=n,t[21]=d.selectWorkingDirectory,t[22]=O):O=t[22];let k;t[23]!==O||t[24]!==g?(k=(0,l.jsxs)(`div`,{className:`flex shrink-0 flex-wrap items-center gap-2`,children:[O,g]}),t[23]=O,t[24]=g,t[25]=k):k=t[25];let A;t[26]!==k||t[27]!==E?(A=(0,l.jsxs)(`div`,{className:`flex flex-col gap-2 sm:flex-row sm:items-center`,children:[E,k]}),t[26]=k,t[27]=E,t[28]=A):A=t[28];let j;t[29]!==v.confirmPick||t[30]!==v.hasNativePicker||t[31]!==v.modalOpen||t[32]!==v.setModalOpen||t[33]!==b||t[34]!==d?(j=v.hasNativePicker?null:(0,l.jsx)(r,{open:v.modalOpen,onOpenChange:v.setModalOpen,initialAbsolutePath:b||void 0,onConfirm:v.confirmPick,wd:d}),t[29]=v.confirmPick,t[30]=v.hasNativePicker,t[31]=v.modalOpen,t[32]=v.setModalOpen,t[33]=b,t[34]=d,t[35]=j):j=t[35];let M;return t[36]!==A||t[37]!==j?(M=(0,l.jsxs)(l.Fragment,{children:[A,j]}),t[36]=A,t[37]=j,t[38]=M):M=t[38],M}export{d as t};
@@ -1 +1 @@
1
- import{n as e,t}from"./vendor-react-BOUWij0V.js";import{i as n,o as r}from"./locale-store-_-_QzAV0.js";import{t as i}from"./createLucideIcon-DPHK1VkS.js";import{t as a}from"./chevron-down-ccbiQQz_.js";import{t as o}from"./button-CnRSIP6m.js";var s=i(`arrow-down-to-line`,[[`path`,{d:`M12 17V3`,key:`1cwfxf`}],[`path`,{d:`m6 11 6 6 6-6`,key:`12ii2o`}],[`path`,{d:`M19 21H5`,key:`150jfl`}]]),c=i(`bookmark`,[[`path`,{d:`M17 3a2 2 0 0 1 2 2v15a1 1 0 0 1-1.496.868l-4.512-2.578a2 2 0 0 0-1.984 0l-4.512 2.578A1 1 0 0 1 5 20V5a2 2 0 0 1 2-2z`,key:`oz39mx`}]]),l=i(`lightbulb`,[[`path`,{d:`M15 14c.2-1 .7-1.7 1.5-2.5 1-.9 1.5-2.2 1.5-3.5A6 6 0 0 0 6 8c0 1 .2 2.2 1.5 3.5.7.7 1.3 1.5 1.5 2.5`,key:`1gvzjb`}],[`path`,{d:`M9 18h6`,key:`x1upvd`}],[`path`,{d:`M10 22h4`,key:`ceow96`}]]);function u(e){let t=e.audioAvailable&&!e.audioDeleted,n=`sync_pending`,r=`none`;return e.audioDeleted?n=`audio_deleted`:e.localSave===`saving`?n=`local_saving`:e.localSave===`failed`?n=`save_failed`:e.localSave===`partial`?(n=`local_partial`,r=`recover`):t?e.serverStatus===`cancelled`?n=`cancelled`:e.serverStatus===`needs_attention`?(n=e.failureStage===`organization`?`analysis_failed`:`transcription_failed`,r=`pipeline`):e.serverStatus===`completed`?e.noteAvailable?e.analysisStale?(n=`analysis_stale`,r=`analyze`):n=`ready`:(n=`analysis_missing`,r=`regenerate`):n=e.serverStatus===`organizing`?e.retryScheduled?`analysis_retrying`:`organizing`:e.retryScheduled?`transcription_retrying`:`transcribing`:e.jobState===`failed`?(n=`verify_failed`,r=`pipeline`):e.jobState===`queued`||e.jobState===`running`||e.sync===`verifying`?n=`verifying`:e.sync===`offline`||e.sync===`failed`?(n=`sync_failed`,r=e.localSave===`complete`?`sync`:`none`):e.localSave!==`complete`&&e.serverStatus===`needs_attention`&&(n=`source_missing`),{stage:n,leave:e.localSave===`saving`?`hold`:t?`cloud`:e.localSave===`complete`?`local`:`hold`,retry:r,audio:t,text:e.textAvailable,note:e.noteAvailable,stale:e.analysisStale}}var d=`open-discussion-capture`;function f(e){window.dispatchEvent(new CustomEvent(d,{detail:e?{projectId:e}:{}}))}var p=e(),m={save_failed:[`录音未能保存`,`Recording could not be saved`,`尚未确认可恢复的原音。请检查麦克风权限和可用存储空间后重新录制。`,`No recoverable audio has been confirmed. Check microphone permission and available storage before recording again.`],cancelled:[`已停止整理`,`Processing stopped`,`已有原音、文字和笔记仍可使用。`,`Existing audio, text and notes remain available.`],local_saving:[`正在保存录音`,`Saving recording`,`请稍候,确认保存完成前请留在此页面。`,`Please stay on this page until saving is confirmed.`],local_partial:[`已保留部分录音`,`Part of the recording was retained`,`本次录音未完整保存。请先恢复或导出已保存部分,确认缺失范围。`,`This recording was not saved completely. Recover or export the saved portion and review the missing parts.`],sync_pending:[`正在同步原音`,`Syncing original audio`,`已完成的文字和笔记可先使用。原音确认可用后,会继续整理。`,`Available text and notes can be used now. Processing continues once the original audio is confirmed.`],sync_failed:[`原音同步未完成`,`Audio sync incomplete`,`已保存的内容仍保留在录制设备。连接网络后可重试同步,无需重新录音。`,`Saved content remains on the recording device. Reconnect and retry sync without recording again.`],verifying:[`原音已上传,正在确认`,`Confirming uploaded audio`,`上传完成后,还需确认原音可用。已有文字可以先查看。`,`Uploaded audio is being checked. Existing text can be read now.`],verify_failed:[`原音确认未完成`,`Audio confirmation incomplete`,`上传内容已保留,可重试确认原音。已有文字和笔记仍可使用。`,`Uploaded content is retained. Retry audio confirmation; existing text and notes remain available.`],transcribing:[`正在整理文字`,`Preparing transcript`,`原音已可回听,已完成的文字可先搜索和查看。文字完成后继续生成笔记。`,`Play the original audio and search available text now. Notes will follow the transcript.`],transcription_retrying:[`正在重试整理文字`,`Retrying transcription`,`原音和处理进度已保留,系统稍后自动重试。已有文字仍可使用。`,`Audio and progress are retained. An automatic retry is scheduled; existing text remains available.`],transcription_failed:[`文字整理未完成`,`Transcription incomplete`,`原音和已有文字均保留。重试会从已保存进度继续,无需重新录音。`,`Audio and existing text are retained. Retry from saved progress without recording again.`],organizing:[`正在生成笔记`,`Preparing notes`,`可以先回听原音、查找原话。笔记完成后可查看重点、结论和行动建议。`,`Play audio and find original statements now. Highlights, conclusions and suggested actions will follow.`],analysis_retrying:[`正在重试生成笔记`,`Retrying notes`,`原音、文字和已有笔记均保留,系统稍后自动重试。`,`Audio, text and existing notes are retained. An automatic retry is scheduled.`],analysis_failed:[`笔记生成未完成`,`Notes incomplete`,`原音、文字和已有笔记均保留。重试只继续整理,不会重新录音或创建重复笔记。`,`Audio, text and existing notes are retained. Retry continues processing without recording again or creating another note.`],ready:[`录音与笔记已就绪`,`Recording and notes are ready`,`现在可以回听原音、查找原话,并回顾重要信息。`,`Play the audio, find original statements and review important information.`],analysis_missing:[`暂未生成笔记`,`Notes are not available yet`,`原音和已有文字仍可使用,可以从原音重新生成文字与笔记。`,`Audio and existing text remain available. Regenerate text and notes from the original audio.`],analysis_stale:[`原文已更新`,`Transcript updated`,`当前笔记基于修改前的原文,可保留查看,也可按新版原文重新整理。`,`Existing notes use an earlier transcript. Keep them or generate notes from the updated text.`],source_missing:[`原音尚不可用`,`Original audio is not available yet`,`请到录制设备的待恢复录音中继续同步。已有文字和笔记仍可查看。`,`Continue sync from recoverable recordings on the recording device. Existing text and notes remain readable.`],audio_deleted:[`原音已删除`,`Original audio was deleted`,`已有文字和笔记仍可查看;重新生成需要重新导入原音。`,`Existing text and notes remain readable. Import the original audio again to regenerate.`]},h={leave_local:[`录音已在本机保存,可以离开当前页面。`,`Recording saved on this device. You can leave this page.`],leave_cloud:[`原音已同步,可以离开当前页面。`,`Original audio synced. You can leave this page.`],leave_hold:[`请先确认保存结果,再离开当前页面。`,`Confirm the recording is saved before leaving this page.`],local_hint:[`关闭应用后,可在待恢复录音中继续同步。请保留本机录音数据。`,`After closing the app, continue sync from recoverable recordings. Keep the recording data on this device.`],cloud_hint:[`后续转写与笔记整理在后台继续;失败时可在这条笔记中重试。`,`Transcription and notes continue on the server. Retry here if processing fails.`],retry_sync:[`重试同步`,`Retry sync`],retry_pipeline:[`继续处理`,`Resume processing`],retry_analysis_failed:[`重试生成笔记`,`Retry notes`],retry_transcription_failed:[`继续整理文字`,`Resume transcription`],retry_verify_failed:[`重试确认原音`,`Retry audio confirmation`],retry_recover:[`恢复已录内容`,`Recover saved audio`],retry_regenerate:[`从原音重新生成`,`Regenerate from audio`],retry_analyze:[`按新版原文整理`,`Update notes from transcript`],audio:[`原音`,`Audio`],text:[`文字`,`Transcript`],note:[`笔记`,`Notes`],available:[`可用`,`Available`],pending:[`尚未完成`,`Not ready`],old_note:[`旧版可用`,`Earlier version available`],open:[`打开笔记`,`Open note`],recover:[`待恢复录音`,`Recoverable recordings`],export:[`导出已录内容`,`Export saved audio`],close:[`稍后查看`,`View later`],annotation_failed:[`重点同步未完成,原音和笔记处理不受影响。`,`Highlights are not synced yet. Audio and note processing are unaffected.`],retry_annotation:[`重试重点同步`,`Retry highlights`]},g=t();function _(e,t=`unknown`,n=`pending`){return{localSave:t,sync:n,serverStatus:e?.discussion.status??``,failureStage:e?.discussion.failureStage??``,jobState:e?.recordingJob?.state??``,retryScheduled:!!e?.processing?.nextAttemptAt,audioAvailable:!!e?.discussion.audioAttachmentId,audioDeleted:!!e?.discussion.audioDeletedAt,textAvailable:!!e?.transcript?.text?.trim()||!!e?.discussion.canonicalTranscript?.trim(),noteAvailable:!!e?.organization?.organization,analysisStale:!!e?.organization&&e.organization.transcriptRevision!==e.transcript?.revision}}function v(e){let t=(0,p.c)(58),{input:n,zh:r,compact:i,busy:s,onRetry:c,children:l,context:d}=e,f=i!==void 0&&i,_=s!==void 0&&s,v=d===void 0?`capture`:d,y,b,x,S,C,w,T,E,D,O,k,A;if(t[0]!==v||t[1]!==n||t[2]!==r){S=u(n),x=m[S.stage];let e;t[15]===r?e=t[16]:(e=e=>h[e][+!r],t[15]=r,t[16]=e),y=e,b=`retry_${[`analysis_failed`,`transcription_failed`,`verify_failed`].includes(S.stage)?S.stage:S.retry}`,k=`polite`,A=S.stage,C=v===`note`?`text-fg`:`rounded-xl bg-surface-inset p-3 text-fg`,w=v===`capture`?(0,g.jsx)(`p`,{className:`mb-1 text-sm font-medium`,children:y(`leave_${S.leave}`)}):null,D=`group`,O=v,E=`flex min-h-11 cursor-pointer list-none items-center gap-2 rounded-lg text-sm focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-accent [&::-webkit-details-marker]:hidden`,T=S.stage.endsWith(`_failed`)||S.stage===`local_partial`?`bg-danger`:`bg-accent`,t[0]=v,t[1]=n,t[2]=r,t[3]=y,t[4]=b,t[5]=x,t[6]=S,t[7]=C,t[8]=w,t[9]=T,t[10]=E,t[11]=D,t[12]=O,t[13]=k,t[14]=A}else y=t[3],b=t[4],x=t[5],S=t[6],C=t[7],w=t[8],T=t[9],E=t[10],D=t[11],O=t[12],k=t[13],A=t[14];let j=`size-1.5 shrink-0 rounded-full ${T}`,M;t[17]===j?M=t[18]:(M=(0,g.jsx)(`span`,{className:j,"aria-hidden":!0}),t[17]=j,t[18]=M);let N=x[+!r],P;t[19]===N?P=t[20]:(P=(0,g.jsx)(`span`,{className:`min-w-0 flex-1`,children:N}),t[19]=N,t[20]=P);let F;t[21]===Symbol.for(`react.memo_cache_sentinel`)?(F=(0,g.jsx)(a,{className:`size-3.5 shrink-0 text-fg-muted transition-transform group-open:rotate-180 motion-reduce:transition-none`,"aria-hidden":!0}),t[21]=F):F=t[21];let I;t[22]!==M||t[23]!==P||t[24]!==E?(I=(0,g.jsxs)(`summary`,{className:E,children:[M,P,F]}),t[22]=M,t[23]=P,t[24]=E,t[25]=I):I=t[25];let L;t[26]!==v||t[27]!==y||t[28]!==S.leave?(L=v===`note`?(0,g.jsx)(`p`,{children:y(`leave_${S.leave}`)}):null,t[26]=v,t[27]=y,t[28]=S.leave,t[29]=L):L=t[29];let R;t[30]!==f||t[31]!==y||t[32]!==x||t[33]!==S||t[34]!==r?(R=f?null:(0,g.jsxs)(g.Fragment,{children:[(0,g.jsx)(`p`,{children:x[r?2:3]}),S.leave===`local`?(0,g.jsx)(`p`,{children:y(`local_hint`)}):null,(0,g.jsx)(`ul`,{className:`flex flex-wrap gap-x-4 gap-y-1`,"aria-label":r?`已可用内容`:`Available content`,children:[`audio`,`text`,`note`].map(e=>(0,g.jsxs)(`li`,{children:[y(e),` · `,e===`note`&&S.note&&S.stale?y(`old_note`):y(S[e]?`available`:`pending`)]},e))})]}),t[30]=f,t[31]=y,t[32]=x,t[33]=S,t[34]=r,t[35]=R):R=t[35];let z;t[36]!==L||t[37]!==R?(z=(0,g.jsxs)(`div`,{className:`space-y-2 pb-3 text-xs leading-5 text-fg-muted`,children:[L,R]}),t[36]=L,t[37]=R,t[38]=z):z=t[38];let B;t[39]!==I||t[40]!==z||t[41]!==D||t[42]!==O?(B=(0,g.jsxs)(`details`,{className:D,children:[I,z]},O),t[39]=I,t[40]=z,t[41]=D,t[42]=O,t[43]=B):B=t[43];let V;t[44]!==_||t[45]!==c||t[46]!==y||t[47]!==b||t[48]!==S.retry?(V=S.retry!==`none`&&c?(0,g.jsx)(o,{className:`min-h-11`,disabled:_,onClick:()=>c(S.retry),children:y(b)}):null,t[44]=_,t[45]=c,t[46]=y,t[47]=b,t[48]=S.retry,t[49]=V):V=t[49];let H;return t[50]!==l||t[51]!==C||t[52]!==w||t[53]!==B||t[54]!==V||t[55]!==k||t[56]!==A?(H=(0,g.jsxs)(`section`,{"aria-live":k,"data-recording-outcome":A,className:C,children:[w,B,V,l]}),t[50]=l,t[51]=C,t[52]=w,t[53]=B,t[54]=V,t[55]=k,t[56]=A,t[57]=H):H=t[57],H}function y(){return r(n(`/api/discussion-capture/settings`))}function b(e){return r(n(`/api/discussion-capture/settings`),{method:`PUT`,body:JSON.stringify({consentPolicyVersion:e})})}async function x(e){return r(n(`/api/discussions`),{method:`POST`,body:JSON.stringify(e)})}function S(e){return r(n(`/api/discussions/${encodeURIComponent(e)}`))}async function C(e){try{return await r(n(`/api/discussions/by-note/${encodeURIComponent(e)}`))}catch(e){if(e.status===404)return null;throw e}}function w(e){return r(n(`/api/discussions/${encodeURIComponent(e)}/transcript`))}function T(e,t,i){let a=new FormData;return a.set(`file`,i.blob,`segment-${t}.wav`),a.set(`startedAtMs`,String(i.startedAtMs)),a.set(`endedAtMs`,String(i.endedAtMs)),a.set(`sha256`,i.sha256),r(n(`/api/discussions/${encodeURIComponent(e)}/segments/${t}`),{method:`PUT`,body:a})}function E(e,t=`resume`){return r(n(`/api/discussions/${encodeURIComponent(e)}/retry`),{method:`POST`,body:JSON.stringify({mode:t})})}function D(e){return r(n(`/api/discussions/${encodeURIComponent(e)}/project`),{method:`DELETE`})}function O(e){return r(n(`/api/discussions/${encodeURIComponent(e)}/recording/chunks`))}function k(e,t,i,a){return r(n(`/api/discussions/${encodeURIComponent(e)}/recording/chunks/${t}`),{method:`PUT`,headers:{"Content-Type":`application/octet-stream`,"x-audio-sha256":a},body:i})}function A(e,t){return r(n(`/api/discussions/${encodeURIComponent(e)}/capture/seal`),{method:`POST`,body:JSON.stringify(t)})}function j(e){return r(n(`/api/discussions/${encodeURIComponent(e)}/recording/job`))}var M=()=>window.dispatchEvent(new Event(`discussion-annotations-changed`));async function N(){return new Promise((e,t)=>{let n=indexedDB.open(`xopc-note-annotations`,1);n.onupgradeneeded=()=>{n.result.createObjectStore(`annotations`,{keyPath:[`recordingId`,`annotation.id`]}).createIndex(`recordingId`,`recordingId`)},n.onsuccess=()=>e(n.result),n.onerror=()=>t(n.error)})}async function P(e,t){let n=await N();try{return await new Promise((r,i)=>{let a=n.transaction(`annotations`,e?`readwrite`:`readonly`,{durability:`strict`}),o,s;a.oncomplete=()=>r(o),a.onabort=()=>i(s??a.error??Error(`Annotation save failed`)),a.onerror=()=>i(a.error);try{t(a.objectStore(`annotations`),e=>{o=e},e=>{s=e,a.abort()})}catch(e){a.abort(),i(e)}})}finally{n.close()}}async function F(e){return P(!1,(t,n)=>{let r=t.index(`recordingId`).getAll(e);r.onsuccess=()=>n(r.result)})}async function I(e,t,n){await P(!0,(r,i,a)=>{let o=r.get([e,t.id]);o.onsuccess=()=>{let s=o.result;if(n!==void 0&&(n===null?s&&s.state!==`synced`:s?.nonce!==n)){a(Error(`Annotation changed in another tab. Your editor content is retained; reload before saving.`));return}r.put({recordingId:e,annotation:t,nonce:crypto.randomUUID(),state:`pending`}),i()}}),M()}function L(e,t=`highlight`){let n=Date.now();return{id:crypto.randomUUID(),kind:t,text:``,anchor:e,revision:0,deleted:!1,createdAt:n,updatedAt:n}}async function R(e,t,n){await P(!0,(r,i)=>{let a=r.get([e,t]);a.onsuccess=()=>{let e=a.result;e&&e.annotation.anchor.offsetMs===void 0&&r.put({...e,nonce:crypto.randomUUID(),state:`pending`,annotation:{...e.annotation,anchor:{...e.annotation.anchor,offsetMs:n}}}),i()}}),M()}async function z(e,t,n=!1){await P(!0,(r,i)=>{let a=r.get([e.recordingId,e.annotation.id]);a.onsuccess=()=>{let o=a.result;o&&(o.nonce===e.nonce?r.put({...o,annotation:t??o.annotation,state:n?`conflict`:`synced`}):t&&o.annotation.revision===e.annotation.revision&&r.put({...o,annotation:{...o.annotation,revision:t.revision}})),i()}}),M()}var B=new Map;function V(e,t){let i=`${e}:${t}`;if(B.has(i))return B.get(i);let a=(async()=>{for(let i=0;i<5;i++){let i=(await F(e)).filter(e=>e.state===`pending`);if(!i.length)return;for(let e of i){if(e.state!==`pending`)continue;let i=e.annotation;try{await z(e,await r(n(`/api/discussions/${encodeURIComponent(t)}/annotations/${encodeURIComponent(i.id)}`),{method:`PUT`,signal:AbortSignal.timeout(15e3),body:JSON.stringify({id:i.id,kind:i.kind,text:i.text,anchor:i.anchor,expectedRevision:i.revision,deleted:i.deleted})}))}catch(t){throw t.status===409&&await z(e,void 0,!0),t}}}throw Error(`Highlights are still being updated. Saved local changes will sync on retry.`)})().finally(()=>B.delete(i));return B.set(i,a),a}export{f as C,s as E,d as S,c as T,D as _,R as a,v as b,x as c,C as d,w as f,A as g,E as h,L as i,S as l,j as m,z as n,I as o,O as p,F as r,b as s,V as t,y as u,T as v,l as w,_ as x,k as y};
1
+ import{n as e,t}from"./vendor-react-BOUWij0V.js";import{i as n,o as r}from"./locale-store-TQcz_Vjt.js";import{t as i}from"./createLucideIcon-DPHK1VkS.js";import{t as a}from"./chevron-down-ccbiQQz_.js";import{t as o}from"./button-CnRSIP6m.js";var s=i(`arrow-down-to-line`,[[`path`,{d:`M12 17V3`,key:`1cwfxf`}],[`path`,{d:`m6 11 6 6 6-6`,key:`12ii2o`}],[`path`,{d:`M19 21H5`,key:`150jfl`}]]),c=i(`bookmark`,[[`path`,{d:`M17 3a2 2 0 0 1 2 2v15a1 1 0 0 1-1.496.868l-4.512-2.578a2 2 0 0 0-1.984 0l-4.512 2.578A1 1 0 0 1 5 20V5a2 2 0 0 1 2-2z`,key:`oz39mx`}]]),l=i(`lightbulb`,[[`path`,{d:`M15 14c.2-1 .7-1.7 1.5-2.5 1-.9 1.5-2.2 1.5-3.5A6 6 0 0 0 6 8c0 1 .2 2.2 1.5 3.5.7.7 1.3 1.5 1.5 2.5`,key:`1gvzjb`}],[`path`,{d:`M9 18h6`,key:`x1upvd`}],[`path`,{d:`M10 22h4`,key:`ceow96`}]]);function u(e){let t=e.audioAvailable&&!e.audioDeleted,n=`sync_pending`,r=`none`;return e.audioDeleted?n=`audio_deleted`:e.localSave===`saving`?n=`local_saving`:e.localSave===`failed`?n=`save_failed`:e.localSave===`partial`?(n=`local_partial`,r=`recover`):t?e.serverStatus===`cancelled`?n=`cancelled`:e.serverStatus===`needs_attention`?(n=e.failureStage===`organization`?`analysis_failed`:`transcription_failed`,r=`pipeline`):e.serverStatus===`completed`?e.noteAvailable?e.analysisStale?(n=`analysis_stale`,r=`analyze`):n=`ready`:(n=`analysis_missing`,r=`regenerate`):n=e.serverStatus===`organizing`?e.retryScheduled?`analysis_retrying`:`organizing`:e.retryScheduled?`transcription_retrying`:`transcribing`:e.jobState===`failed`?(n=`verify_failed`,r=`pipeline`):e.jobState===`queued`||e.jobState===`running`||e.sync===`verifying`?n=`verifying`:e.sync===`offline`||e.sync===`failed`?(n=`sync_failed`,r=e.localSave===`complete`?`sync`:`none`):e.localSave!==`complete`&&e.serverStatus===`needs_attention`&&(n=`source_missing`),{stage:n,leave:e.localSave===`saving`?`hold`:t?`cloud`:e.localSave===`complete`?`local`:`hold`,retry:r,audio:t,text:e.textAvailable,note:e.noteAvailable,stale:e.analysisStale}}var d=`open-discussion-capture`;function f(e){window.dispatchEvent(new CustomEvent(d,{detail:e?{projectId:e}:{}}))}var p=e(),m={save_failed:[`录音未能保存`,`Recording could not be saved`,`尚未确认可恢复的原音。请检查麦克风权限和可用存储空间后重新录制。`,`No recoverable audio has been confirmed. Check microphone permission and available storage before recording again.`],cancelled:[`已停止整理`,`Processing stopped`,`已有原音、文字和笔记仍可使用。`,`Existing audio, text and notes remain available.`],local_saving:[`正在保存录音`,`Saving recording`,`请稍候,确认保存完成前请留在此页面。`,`Please stay on this page until saving is confirmed.`],local_partial:[`已保留部分录音`,`Part of the recording was retained`,`本次录音未完整保存。请先恢复或导出已保存部分,确认缺失范围。`,`This recording was not saved completely. Recover or export the saved portion and review the missing parts.`],sync_pending:[`正在同步原音`,`Syncing original audio`,`已完成的文字和笔记可先使用。原音确认可用后,会继续整理。`,`Available text and notes can be used now. Processing continues once the original audio is confirmed.`],sync_failed:[`原音同步未完成`,`Audio sync incomplete`,`已保存的内容仍保留在录制设备。连接网络后可重试同步,无需重新录音。`,`Saved content remains on the recording device. Reconnect and retry sync without recording again.`],verifying:[`原音已上传,正在确认`,`Confirming uploaded audio`,`上传完成后,还需确认原音可用。已有文字可以先查看。`,`Uploaded audio is being checked. Existing text can be read now.`],verify_failed:[`原音确认未完成`,`Audio confirmation incomplete`,`上传内容已保留,可重试确认原音。已有文字和笔记仍可使用。`,`Uploaded content is retained. Retry audio confirmation; existing text and notes remain available.`],transcribing:[`正在整理文字`,`Preparing transcript`,`原音已可回听,已完成的文字可先搜索和查看。文字完成后继续生成笔记。`,`Play the original audio and search available text now. Notes will follow the transcript.`],transcription_retrying:[`正在重试整理文字`,`Retrying transcription`,`原音和处理进度已保留,系统稍后自动重试。已有文字仍可使用。`,`Audio and progress are retained. An automatic retry is scheduled; existing text remains available.`],transcription_failed:[`文字整理未完成`,`Transcription incomplete`,`原音和已有文字均保留。重试会从已保存进度继续,无需重新录音。`,`Audio and existing text are retained. Retry from saved progress without recording again.`],organizing:[`正在生成笔记`,`Preparing notes`,`可以先回听原音、查找原话。笔记完成后可查看重点、结论和行动建议。`,`Play audio and find original statements now. Highlights, conclusions and suggested actions will follow.`],analysis_retrying:[`正在重试生成笔记`,`Retrying notes`,`原音、文字和已有笔记均保留,系统稍后自动重试。`,`Audio, text and existing notes are retained. An automatic retry is scheduled.`],analysis_failed:[`笔记生成未完成`,`Notes incomplete`,`原音、文字和已有笔记均保留。重试只继续整理,不会重新录音或创建重复笔记。`,`Audio, text and existing notes are retained. Retry continues processing without recording again or creating another note.`],ready:[`录音与笔记已就绪`,`Recording and notes are ready`,`现在可以回听原音、查找原话,并回顾重要信息。`,`Play the audio, find original statements and review important information.`],analysis_missing:[`暂未生成笔记`,`Notes are not available yet`,`原音和已有文字仍可使用,可以从原音重新生成文字与笔记。`,`Audio and existing text remain available. Regenerate text and notes from the original audio.`],analysis_stale:[`原文已更新`,`Transcript updated`,`当前笔记基于修改前的原文,可保留查看,也可按新版原文重新整理。`,`Existing notes use an earlier transcript. Keep them or generate notes from the updated text.`],source_missing:[`原音尚不可用`,`Original audio is not available yet`,`请到录制设备的待恢复录音中继续同步。已有文字和笔记仍可查看。`,`Continue sync from recoverable recordings on the recording device. Existing text and notes remain readable.`],audio_deleted:[`原音已删除`,`Original audio was deleted`,`已有文字和笔记仍可查看;重新生成需要重新导入原音。`,`Existing text and notes remain readable. Import the original audio again to regenerate.`]},h={leave_local:[`录音已在本机保存,可以离开当前页面。`,`Recording saved on this device. You can leave this page.`],leave_cloud:[`原音已同步,可以离开当前页面。`,`Original audio synced. You can leave this page.`],leave_hold:[`请先确认保存结果,再离开当前页面。`,`Confirm the recording is saved before leaving this page.`],local_hint:[`关闭应用后,可在待恢复录音中继续同步。请保留本机录音数据。`,`After closing the app, continue sync from recoverable recordings. Keep the recording data on this device.`],cloud_hint:[`后续转写与笔记整理在后台继续;失败时可在这条笔记中重试。`,`Transcription and notes continue on the server. Retry here if processing fails.`],retry_sync:[`重试同步`,`Retry sync`],retry_pipeline:[`继续处理`,`Resume processing`],retry_analysis_failed:[`重试生成笔记`,`Retry notes`],retry_transcription_failed:[`继续整理文字`,`Resume transcription`],retry_verify_failed:[`重试确认原音`,`Retry audio confirmation`],retry_recover:[`恢复已录内容`,`Recover saved audio`],retry_regenerate:[`从原音重新生成`,`Regenerate from audio`],retry_analyze:[`按新版原文整理`,`Update notes from transcript`],audio:[`原音`,`Audio`],text:[`文字`,`Transcript`],note:[`笔记`,`Notes`],available:[`可用`,`Available`],pending:[`尚未完成`,`Not ready`],old_note:[`旧版可用`,`Earlier version available`],open:[`打开笔记`,`Open note`],recover:[`待恢复录音`,`Recoverable recordings`],export:[`导出已录内容`,`Export saved audio`],close:[`稍后查看`,`View later`],annotation_failed:[`重点同步未完成,原音和笔记处理不受影响。`,`Highlights are not synced yet. Audio and note processing are unaffected.`],retry_annotation:[`重试重点同步`,`Retry highlights`]},g=t();function _(e,t=`unknown`,n=`pending`){return{localSave:t,sync:n,serverStatus:e?.discussion.status??``,failureStage:e?.discussion.failureStage??``,jobState:e?.recordingJob?.state??``,retryScheduled:!!e?.processing?.nextAttemptAt,audioAvailable:!!e?.discussion.audioAttachmentId,audioDeleted:!!e?.discussion.audioDeletedAt,textAvailable:!!e?.transcript?.text?.trim()||!!e?.discussion.canonicalTranscript?.trim(),noteAvailable:!!e?.organization?.organization,analysisStale:!!e?.organization&&e.organization.transcriptRevision!==e.transcript?.revision}}function v(e){let t=(0,p.c)(58),{input:n,zh:r,compact:i,busy:s,onRetry:c,children:l,context:d}=e,f=i!==void 0&&i,_=s!==void 0&&s,v=d===void 0?`capture`:d,y,b,x,S,C,w,T,E,D,O,k,A;if(t[0]!==v||t[1]!==n||t[2]!==r){S=u(n),x=m[S.stage];let e;t[15]===r?e=t[16]:(e=e=>h[e][+!r],t[15]=r,t[16]=e),y=e,b=`retry_${[`analysis_failed`,`transcription_failed`,`verify_failed`].includes(S.stage)?S.stage:S.retry}`,k=`polite`,A=S.stage,C=v===`note`?`text-fg`:`rounded-xl bg-surface-inset p-3 text-fg`,w=v===`capture`?(0,g.jsx)(`p`,{className:`mb-1 text-sm font-medium`,children:y(`leave_${S.leave}`)}):null,D=`group`,O=v,E=`flex min-h-11 cursor-pointer list-none items-center gap-2 rounded-lg text-sm focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-accent [&::-webkit-details-marker]:hidden`,T=S.stage.endsWith(`_failed`)||S.stage===`local_partial`?`bg-danger`:`bg-accent`,t[0]=v,t[1]=n,t[2]=r,t[3]=y,t[4]=b,t[5]=x,t[6]=S,t[7]=C,t[8]=w,t[9]=T,t[10]=E,t[11]=D,t[12]=O,t[13]=k,t[14]=A}else y=t[3],b=t[4],x=t[5],S=t[6],C=t[7],w=t[8],T=t[9],E=t[10],D=t[11],O=t[12],k=t[13],A=t[14];let j=`size-1.5 shrink-0 rounded-full ${T}`,M;t[17]===j?M=t[18]:(M=(0,g.jsx)(`span`,{className:j,"aria-hidden":!0}),t[17]=j,t[18]=M);let N=x[+!r],P;t[19]===N?P=t[20]:(P=(0,g.jsx)(`span`,{className:`min-w-0 flex-1`,children:N}),t[19]=N,t[20]=P);let F;t[21]===Symbol.for(`react.memo_cache_sentinel`)?(F=(0,g.jsx)(a,{className:`size-3.5 shrink-0 text-fg-muted transition-transform group-open:rotate-180 motion-reduce:transition-none`,"aria-hidden":!0}),t[21]=F):F=t[21];let I;t[22]!==M||t[23]!==P||t[24]!==E?(I=(0,g.jsxs)(`summary`,{className:E,children:[M,P,F]}),t[22]=M,t[23]=P,t[24]=E,t[25]=I):I=t[25];let L;t[26]!==v||t[27]!==y||t[28]!==S.leave?(L=v===`note`?(0,g.jsx)(`p`,{children:y(`leave_${S.leave}`)}):null,t[26]=v,t[27]=y,t[28]=S.leave,t[29]=L):L=t[29];let R;t[30]!==f||t[31]!==y||t[32]!==x||t[33]!==S||t[34]!==r?(R=f?null:(0,g.jsxs)(g.Fragment,{children:[(0,g.jsx)(`p`,{children:x[r?2:3]}),S.leave===`local`?(0,g.jsx)(`p`,{children:y(`local_hint`)}):null,(0,g.jsx)(`ul`,{className:`flex flex-wrap gap-x-4 gap-y-1`,"aria-label":r?`已可用内容`:`Available content`,children:[`audio`,`text`,`note`].map(e=>(0,g.jsxs)(`li`,{children:[y(e),` · `,e===`note`&&S.note&&S.stale?y(`old_note`):y(S[e]?`available`:`pending`)]},e))})]}),t[30]=f,t[31]=y,t[32]=x,t[33]=S,t[34]=r,t[35]=R):R=t[35];let z;t[36]!==L||t[37]!==R?(z=(0,g.jsxs)(`div`,{className:`space-y-2 pb-3 text-xs leading-5 text-fg-muted`,children:[L,R]}),t[36]=L,t[37]=R,t[38]=z):z=t[38];let B;t[39]!==I||t[40]!==z||t[41]!==D||t[42]!==O?(B=(0,g.jsxs)(`details`,{className:D,children:[I,z]},O),t[39]=I,t[40]=z,t[41]=D,t[42]=O,t[43]=B):B=t[43];let V;t[44]!==_||t[45]!==c||t[46]!==y||t[47]!==b||t[48]!==S.retry?(V=S.retry!==`none`&&c?(0,g.jsx)(o,{className:`min-h-11`,disabled:_,onClick:()=>c(S.retry),children:y(b)}):null,t[44]=_,t[45]=c,t[46]=y,t[47]=b,t[48]=S.retry,t[49]=V):V=t[49];let H;return t[50]!==l||t[51]!==C||t[52]!==w||t[53]!==B||t[54]!==V||t[55]!==k||t[56]!==A?(H=(0,g.jsxs)(`section`,{"aria-live":k,"data-recording-outcome":A,className:C,children:[w,B,V,l]}),t[50]=l,t[51]=C,t[52]=w,t[53]=B,t[54]=V,t[55]=k,t[56]=A,t[57]=H):H=t[57],H}function y(){return r(n(`/api/discussion-capture/settings`))}function b(e){return r(n(`/api/discussion-capture/settings`),{method:`PUT`,body:JSON.stringify({consentPolicyVersion:e})})}async function x(e){return r(n(`/api/discussions`),{method:`POST`,body:JSON.stringify(e)})}function S(e){return r(n(`/api/discussions/${encodeURIComponent(e)}`))}async function C(e){try{return await r(n(`/api/discussions/by-note/${encodeURIComponent(e)}`))}catch(e){if(e.status===404)return null;throw e}}function w(e){return r(n(`/api/discussions/${encodeURIComponent(e)}/transcript`))}function T(e,t,i){let a=new FormData;return a.set(`file`,i.blob,`segment-${t}.wav`),a.set(`startedAtMs`,String(i.startedAtMs)),a.set(`endedAtMs`,String(i.endedAtMs)),a.set(`sha256`,i.sha256),r(n(`/api/discussions/${encodeURIComponent(e)}/segments/${t}`),{method:`PUT`,body:a})}function E(e,t=`resume`){return r(n(`/api/discussions/${encodeURIComponent(e)}/retry`),{method:`POST`,body:JSON.stringify({mode:t})})}function D(e){return r(n(`/api/discussions/${encodeURIComponent(e)}/project`),{method:`DELETE`})}function O(e){return r(n(`/api/discussions/${encodeURIComponent(e)}/recording/chunks`))}function k(e,t,i,a){return r(n(`/api/discussions/${encodeURIComponent(e)}/recording/chunks/${t}`),{method:`PUT`,headers:{"Content-Type":`application/octet-stream`,"x-audio-sha256":a},body:i})}function A(e,t){return r(n(`/api/discussions/${encodeURIComponent(e)}/capture/seal`),{method:`POST`,body:JSON.stringify(t)})}function j(e){return r(n(`/api/discussions/${encodeURIComponent(e)}/recording/job`))}var M=()=>window.dispatchEvent(new Event(`discussion-annotations-changed`));async function N(){return new Promise((e,t)=>{let n=indexedDB.open(`xopc-note-annotations`,1);n.onupgradeneeded=()=>{n.result.createObjectStore(`annotations`,{keyPath:[`recordingId`,`annotation.id`]}).createIndex(`recordingId`,`recordingId`)},n.onsuccess=()=>e(n.result),n.onerror=()=>t(n.error)})}async function P(e,t){let n=await N();try{return await new Promise((r,i)=>{let a=n.transaction(`annotations`,e?`readwrite`:`readonly`,{durability:`strict`}),o,s;a.oncomplete=()=>r(o),a.onabort=()=>i(s??a.error??Error(`Annotation save failed`)),a.onerror=()=>i(a.error);try{t(a.objectStore(`annotations`),e=>{o=e},e=>{s=e,a.abort()})}catch(e){a.abort(),i(e)}})}finally{n.close()}}async function F(e){return P(!1,(t,n)=>{let r=t.index(`recordingId`).getAll(e);r.onsuccess=()=>n(r.result)})}async function I(e,t,n){await P(!0,(r,i,a)=>{let o=r.get([e,t.id]);o.onsuccess=()=>{let s=o.result;if(n!==void 0&&(n===null?s&&s.state!==`synced`:s?.nonce!==n)){a(Error(`Annotation changed in another tab. Your editor content is retained; reload before saving.`));return}r.put({recordingId:e,annotation:t,nonce:crypto.randomUUID(),state:`pending`}),i()}}),M()}function L(e,t=`highlight`){let n=Date.now();return{id:crypto.randomUUID(),kind:t,text:``,anchor:e,revision:0,deleted:!1,createdAt:n,updatedAt:n}}async function R(e,t,n){await P(!0,(r,i)=>{let a=r.get([e,t]);a.onsuccess=()=>{let e=a.result;e&&e.annotation.anchor.offsetMs===void 0&&r.put({...e,nonce:crypto.randomUUID(),state:`pending`,annotation:{...e.annotation,anchor:{...e.annotation.anchor,offsetMs:n}}}),i()}}),M()}async function z(e,t,n=!1){await P(!0,(r,i)=>{let a=r.get([e.recordingId,e.annotation.id]);a.onsuccess=()=>{let o=a.result;o&&(o.nonce===e.nonce?r.put({...o,annotation:t??o.annotation,state:n?`conflict`:`synced`}):t&&o.annotation.revision===e.annotation.revision&&r.put({...o,annotation:{...o.annotation,revision:t.revision}})),i()}}),M()}var B=new Map;function V(e,t){let i=`${e}:${t}`;if(B.has(i))return B.get(i);let a=(async()=>{for(let i=0;i<5;i++){let i=(await F(e)).filter(e=>e.state===`pending`);if(!i.length)return;for(let e of i){if(e.state!==`pending`)continue;let i=e.annotation;try{await z(e,await r(n(`/api/discussions/${encodeURIComponent(t)}/annotations/${encodeURIComponent(i.id)}`),{method:`PUT`,signal:AbortSignal.timeout(15e3),body:JSON.stringify({id:i.id,kind:i.kind,text:i.text,anchor:i.anchor,expectedRevision:i.revision,deleted:i.deleted})}))}catch(t){throw t.status===409&&await z(e,void 0,!0),t}}}throw Error(`Highlights are still being updated. Saved local changes will sync on retry.`)})().finally(()=>B.delete(i));return B.set(i,a),a}export{f as C,s as E,d as S,c as T,D as _,R as a,v as b,x as c,C as d,w as f,A as g,E as h,L as i,S as l,j as m,z as n,I as o,O as p,F as r,b as s,V as t,y as u,T as v,l as w,_ as x,k as y};
@@ -1 +1 @@
1
- import"./rolldown-runtime-aKtaBQYM.js";import{a as e,n as t,t as n}from"./vendor-react-BOUWij0V.js";import{n as r}from"./locale-store-_-_QzAV0.js";import{t as i}from"./messages-D1u8VsPq.js";import{r as a}from"./extension-provider-8RM98QmD.js";import{n as o,t as s}from"./settings-page-header-CoPd_JDb.js";import"./settings-page-layout-D39EvFvm.js";var c=t();e();var l=n();function u(){let e=(0,c.c)(40),t=r(p),n;e[0]===t?n=e[1]:(n=i(t),e[0]=t,e[1]=n);let u=n.extensionDebug,m=a(),h;e[2]===m?h=e[3]:(h=m.toSorted(f),e[2]=m,e[3]=h);let g=h,_;e[4]!==u.subtitle||e[5]!==u.title?(_=(0,l.jsx)(s,{title:u.title,subtitle:u.subtitle}),e[4]=u.subtitle,e[5]=u.title,e[6]=_):_=e[6];let v;e[7]===u.listHeading?v=e[8]:(v=(0,l.jsx)(`h2`,{className:`text-sm font-semibold text-fg`,children:u.listHeading}),e[7]=u.listHeading,e[8]=v);let y;e[9]===u.colId?y=e[10]:(y=(0,l.jsx)(`th`,{className:`px-3 py-2`,children:u.colId}),e[9]=u.colId,e[10]=y);let b;e[11]===u.colName?b=e[12]:(b=(0,l.jsx)(`th`,{className:`px-3 py-2`,children:u.colName}),e[11]=u.colName,e[12]=b);let x;e[13]===u.colPermissions?x=e[14]:(x=(0,l.jsx)(`th`,{className:`px-3 py-2`,children:u.colPermissions}),e[13]=u.colPermissions,e[14]=x);let S;e[15]!==y||e[16]!==b||e[17]!==x?(S=(0,l.jsx)(`thead`,{children:(0,l.jsxs)(`tr`,{className:`text-xs uppercase text-fg-muted`,children:[y,b,x]})}),e[15]=y,e[16]=b,e[17]=x,e[18]=S):S=e[18];let C;e[19]===g?C=e[20]:(C=g.map(d),e[19]=g,e[20]=C);let w;e[21]===C?w=e[22]:(w=(0,l.jsx)(`tbody`,{children:C}),e[21]=C,e[22]=w);let T;e[23]!==S||e[24]!==w?(T=(0,l.jsx)(`div`,{className:`mt-3 overflow-x-auto`,children:(0,l.jsxs)(`table`,{className:`w-full min-w-[32rem] border-separate border-spacing-y-1 text-left text-sm`,children:[S,w]})}),e[23]=S,e[24]=w,e[25]=T):T=e[25];let E;e[26]!==T||e[27]!==v?(E=(0,l.jsxs)(`section`,{className:`rounded-xl bg-surface-hover/20 p-4`,children:[v,T]}),e[26]=T,e[27]=v,e[28]=E):E=e[28];let D;e[29]===u.futureHeading?D=e[30]:(D=(0,l.jsx)(`h2`,{className:`text-sm font-semibold text-fg`,children:u.futureHeading}),e[29]=u.futureHeading,e[30]=D);let O;e[31]===u.futureBody?O=e[32]:(O=(0,l.jsx)(`p`,{className:`mt-2`,children:u.futureBody}),e[31]=u.futureBody,e[32]=O);let k;e[33]!==D||e[34]!==O?(k=(0,l.jsxs)(`section`,{className:`rounded-xl bg-surface-hover/20 p-4 text-sm text-fg-muted`,children:[D,O]}),e[33]=D,e[34]=O,e[35]=k):k=e[35];let A;return e[36]!==E||e[37]!==k||e[38]!==_?(A=(0,l.jsxs)(o,{gap:`gap-5`,children:[_,E,k]}),e[36]=E,e[37]=k,e[38]=_,e[39]=A):A=e[39],A}function d(e){return(0,l.jsxs)(`tr`,{className:`bg-surface-base/55`,children:[(0,l.jsx)(`td`,{className:`rounded-l-lg px-3 py-2 font-mono text-xs text-fg`,children:e.id}),(0,l.jsx)(`td`,{className:`px-3 py-2 text-fg`,children:e.name}),(0,l.jsx)(`td`,{className:`rounded-r-lg px-3 py-2 font-mono text-xs text-fg-muted`,children:(e.ui?.permissions??[]).join(`, `)||`—`})]},e.id)}function f(e,t){return e.id.localeCompare(t.id)}function p(e){return e.language}export{u as ExtensionDebugPage};
1
+ import"./rolldown-runtime-aKtaBQYM.js";import{a as e,n as t,t as n}from"./vendor-react-BOUWij0V.js";import{n as r}from"./locale-store-TQcz_Vjt.js";import{t as i}from"./messages-DaLmc4W1.js";import{r as a}from"./extension-provider-BZwcaU5Y.js";import{n as o,t as s}from"./settings-page-header-DuNCn8i-.js";import"./settings-page-layout-DeNC8YHJ.js";var c=t();e();var l=n();function u(){let e=(0,c.c)(40),t=r(p),n;e[0]===t?n=e[1]:(n=i(t),e[0]=t,e[1]=n);let u=n.extensionDebug,m=a(),h;e[2]===m?h=e[3]:(h=m.toSorted(f),e[2]=m,e[3]=h);let g=h,_;e[4]!==u.subtitle||e[5]!==u.title?(_=(0,l.jsx)(s,{title:u.title,subtitle:u.subtitle}),e[4]=u.subtitle,e[5]=u.title,e[6]=_):_=e[6];let v;e[7]===u.listHeading?v=e[8]:(v=(0,l.jsx)(`h2`,{className:`text-sm font-semibold text-fg`,children:u.listHeading}),e[7]=u.listHeading,e[8]=v);let y;e[9]===u.colId?y=e[10]:(y=(0,l.jsx)(`th`,{className:`px-3 py-2`,children:u.colId}),e[9]=u.colId,e[10]=y);let b;e[11]===u.colName?b=e[12]:(b=(0,l.jsx)(`th`,{className:`px-3 py-2`,children:u.colName}),e[11]=u.colName,e[12]=b);let x;e[13]===u.colPermissions?x=e[14]:(x=(0,l.jsx)(`th`,{className:`px-3 py-2`,children:u.colPermissions}),e[13]=u.colPermissions,e[14]=x);let S;e[15]!==y||e[16]!==b||e[17]!==x?(S=(0,l.jsx)(`thead`,{children:(0,l.jsxs)(`tr`,{className:`text-xs uppercase text-fg-muted`,children:[y,b,x]})}),e[15]=y,e[16]=b,e[17]=x,e[18]=S):S=e[18];let C;e[19]===g?C=e[20]:(C=g.map(d),e[19]=g,e[20]=C);let w;e[21]===C?w=e[22]:(w=(0,l.jsx)(`tbody`,{children:C}),e[21]=C,e[22]=w);let T;e[23]!==S||e[24]!==w?(T=(0,l.jsx)(`div`,{className:`mt-3 overflow-x-auto`,children:(0,l.jsxs)(`table`,{className:`w-full min-w-[32rem] border-separate border-spacing-y-1 text-left text-sm`,children:[S,w]})}),e[23]=S,e[24]=w,e[25]=T):T=e[25];let E;e[26]!==T||e[27]!==v?(E=(0,l.jsxs)(`section`,{className:`rounded-xl bg-surface-hover/20 p-4`,children:[v,T]}),e[26]=T,e[27]=v,e[28]=E):E=e[28];let D;e[29]===u.futureHeading?D=e[30]:(D=(0,l.jsx)(`h2`,{className:`text-sm font-semibold text-fg`,children:u.futureHeading}),e[29]=u.futureHeading,e[30]=D);let O;e[31]===u.futureBody?O=e[32]:(O=(0,l.jsx)(`p`,{className:`mt-2`,children:u.futureBody}),e[31]=u.futureBody,e[32]=O);let k;e[33]!==D||e[34]!==O?(k=(0,l.jsxs)(`section`,{className:`rounded-xl bg-surface-hover/20 p-4 text-sm text-fg-muted`,children:[D,O]}),e[33]=D,e[34]=O,e[35]=k):k=e[35];let A;return e[36]!==E||e[37]!==k||e[38]!==_?(A=(0,l.jsxs)(o,{gap:`gap-5`,children:[_,E,k]}),e[36]=E,e[37]=k,e[38]=_,e[39]=A):A=e[39],A}function d(e){return(0,l.jsxs)(`tr`,{className:`bg-surface-base/55`,children:[(0,l.jsx)(`td`,{className:`rounded-l-lg px-3 py-2 font-mono text-xs text-fg`,children:e.id}),(0,l.jsx)(`td`,{className:`px-3 py-2 text-fg`,children:e.name}),(0,l.jsx)(`td`,{className:`rounded-r-lg px-3 py-2 font-mono text-xs text-fg-muted`,children:(e.ui?.permissions??[]).join(`, `)||`—`})]},e.id)}function f(e,t){return e.id.localeCompare(t.id)}function p(e){return e.language}export{u as ExtensionDebugPage};
@@ -1 +1 @@
1
- import{i as e}from"./rolldown-runtime-aKtaBQYM.js";import{a as t,n,t as r}from"./vendor-react-BOUWij0V.js";import{i,l as a,n as ee,o}from"./locale-store-_-_QzAV0.js";import{t as te}from"./messages-D1u8VsPq.js";import{a as s,n as c,o as l,r as ne,s as re,t as u}from"./dist-DfWfZ9iu.js";import{c as d,n as f}from"./extension-provider-8RM98QmD.js";import{i as p}from"./theme-store-DU_07f3M.js";import{r as m}from"./settings-form-draft-Dy10ldo8.js";var h=e(t(),1),ie=n();function g(e){return e.split(`/`).filter(Boolean).map(e=>encodeURIComponent(e)).join(`/`)}function _(e,t){let n=g(t);return i(`/api/extensions/${encodeURIComponent(e)}/assets/${n}`)}var v={"capability:xopc.notes.create":`Create notes in this workspace`,"capability:xopc.notes.update":`Change notes in this workspace at an exact revision`,"capability:xopc.notes.append":`Append content to notes in this workspace`,"capability:xopc.notes.get":`Read notes in this workspace by ID`,"capability:xopc.notes.list":`Search and list notes in this workspace`,"capability:xopc.tasks.get":`Read tasks and their context in this workspace`,"capability:xopc.tasks.list":`Search and list tasks in this workspace`,theme:`Read theme (light / dark)`,"agent.send":`Send messages to the assistant`,"agent.subscribe":`Receive live agent stream events for a chat`,"session.read":`List and open chat sessions`,"config.read":`Read plugin configuration`,"config.write":`Write plugin configuration`,storage:`Read and write plugin storage`,notification:`Show in-app notifications`},y={"capability:xopc.notes.create":`在当前工作区创建笔记`,"capability:xopc.notes.update":`按精确版本修改当前工作区的笔记`,"capability:xopc.notes.append":`向当前工作区的笔记追加内容`,"capability:xopc.notes.get":`按 ID 读取当前工作区的笔记`,"capability:xopc.notes.list":`搜索和列出当前工作区的笔记`,"capability:xopc.tasks.get":`读取当前工作区的任务及其上下文`,"capability:xopc.tasks.list":`搜索和列出当前工作区的任务`,theme:`读取主题(浅色/深色)`,"agent.send":`向助手发送消息`,"agent.subscribe":`接收会话的实时助手流式事件`,"session.read":`列出并打开聊天会话`,"config.read":`读取插件配置`,"config.write":`写入插件配置`,storage:`读写插件存储`,notification:`显示应用内通知`};function b(e,t){let n=v[e];return t===`zh`&&y[e]?y[e]:n??e}var x=r();function S(e){let t=(0,ie.c)(59),{open:n,onOpenChange:r,extensionId:i,extensionName:a,permissions:o,onConfirm:d,confirmDisabled:f}=e,p=ee(w),m,h,g,_,v,y,S,T,E,D,O,k;t[0]!==a||t[1]!==p||t[2]!==r||t[3]!==n?(v=te(p).extensionUi,_=u,O=n,k=r,g=l,t[16]===Symbol.for(`react.memo_cache_sentinel`)?(D=(0,x.jsx)(s,{className:`xopc-dialog-overlay fixed inset-0 z-[130] bg-scrim`}),t[16]=D):D=t[16],h=ne,T=`xopc-dialog-content fixed left-1/2 top-1/2 z-[131] w-[min(28rem,calc(100vw-2rem))] -translate-x-1/2 -translate-y-1/2 rounded-xl border border-edge bg-surface-overlay p-5`,E=C,m=re,y=`text-base font-semibold text-fg`,S=v.permissionTitle.replace(`{{name}}`,a),t[0]=a,t[1]=p,t[2]=r,t[3]=n,t[4]=m,t[5]=h,t[6]=g,t[7]=_,t[8]=v,t[9]=y,t[10]=S,t[11]=T,t[12]=E,t[13]=D,t[14]=O,t[15]=k):(m=t[4],h=t[5],g=t[6],_=t[7],v=t[8],y=t[9],S=t[10],T=t[11],E=t[12],D=t[13],O=t[14],k=t[15]);let A;t[17]!==m||t[18]!==y||t[19]!==S?(A=(0,x.jsx)(m,{className:y,children:S}),t[17]=m,t[18]=y,t[19]=S,t[20]=A):A=t[20];let j;t[21]===i?j=t[22]:(j=(0,x.jsxs)(`span`,{className:`font-mono text-xs text-fg-muted`,title:i,children:[`(`,i,`)`]}),t[21]=i,t[22]=j);let M;t[23]!==v.permissionSubtitle||t[24]!==j?(M=(0,x.jsxs)(`p`,{className:`mt-2 text-sm text-fg-muted`,children:[v.permissionSubtitle,` `,j]}),t[23]=v.permissionSubtitle,t[24]=j,t[25]=M):M=t[25];let N;t[26]!==p||t[27]!==o||t[28]!==v.permissionsNone?(N=o.length===0?(0,x.jsx)(`p`,{className:`mt-4 text-sm text-fg-muted`,children:v.permissionsNone}):(0,x.jsx)(`ul`,{className:`mt-4 max-h-48 list-inside list-disc space-y-1 overflow-y-auto text-sm text-fg`,children:o.map(e=>(0,x.jsx)(`li`,{children:b(e,p)},e))}),t[26]=p,t[27]=o,t[28]=v.permissionsNone,t[29]=N):N=t[29];let P;t[30]===v.deny?P=t[31]:(P=(0,x.jsx)(c,{asChild:!0,children:(0,x.jsx)(`button`,{type:`button`,className:`rounded-lg border border-edge px-3 py-2 text-sm text-fg hover:bg-surface-inset`,children:v.deny})}),t[30]=v.deny,t[31]=P);let F;t[32]!==d||t[33]!==r?(F=()=>{d(),r(!1)},t[32]=d,t[33]=r,t[34]=F):F=t[34];let I;t[35]!==f||t[36]!==v.allow||t[37]!==F?(I=(0,x.jsx)(`button`,{type:`button`,disabled:f,className:`rounded-lg bg-accent px-3 py-2 text-sm font-medium text-on-accent hover:opacity-90`,onClick:F,children:v.allow}),t[35]=f,t[36]=v.allow,t[37]=F,t[38]=I):I=t[38];let L;t[39]!==P||t[40]!==I?(L=(0,x.jsxs)(`div`,{className:`mt-6 flex justify-end gap-2`,children:[P,I]}),t[39]=P,t[40]=I,t[41]=L):L=t[41];let R;t[42]!==h||t[43]!==M||t[44]!==N||t[45]!==L||t[46]!==T||t[47]!==E||t[48]!==A?(R=(0,x.jsxs)(h,{className:T,onOpenAutoFocus:E,children:[A,M,N,L]}),t[42]=h,t[43]=M,t[44]=N,t[45]=L,t[46]=T,t[47]=E,t[48]=A,t[49]=R):R=t[49];let z;t[50]!==g||t[51]!==R||t[52]!==D?(z=(0,x.jsxs)(g,{children:[D,R]}),t[50]=g,t[51]=R,t[52]=D,t[53]=z):z=t[53];let B;return t[54]!==_||t[55]!==z||t[56]!==O||t[57]!==k?(B=(0,x.jsx)(_,{open:O,onOpenChange:k,children:z}),t[54]=_,t[55]=z,t[56]=O,t[57]=k,t[58]=B):B=t[58],B}function C(e){return e.preventDefault()}function w(e){return e.language}async function T(e){let{grant:t}=await o(i(`/api/extensions/${encodeURIComponent(e)}/ui-grant`));return t}async function E(e,t){return(await o(i(`/api/extensions/${encodeURIComponent(e)}/ui-grant`),{method:`POST`,body:JSON.stringify({manifestDigest:t})})).grant}var D=48,O=2e3,k=`allow-scripts allow-forms allow-popups`;function A(e){let t=(0,ie.c)(98),{extensionId:n,extensionName:r,entrypoint:i,permissions:o,title:s,className:c,fixedHeight:l,maxHeight:ne,minHeight:re,initialData:u}=e,g=ne===void 0?O:ne,v=re===void 0?D:re,y=ee(P),b;t[0]===y?b=t[1]:(b=te(y),t[0]=y,t[1]=b);let C=b.extensionUi,w=f(),A=a(N),F=a(M),I=(0,h.useRef)(0),L=(0,h.useRef)(!1),R=(0,h.useRef)(null),z=p(j),B;t[2]!==n||t[3]!==r?(B=r?.trim()||n,t[2]=n,t[3]=r,t[4]=B):B=t[4];let ae=B,oe;t[5]!==n||t[6]!==s?(oe=s?.trim()||`Extension ${n}`,t[5]=n,t[6]=s,t[7]=oe):oe=t[7];let se=oe,V;t[8]===o?V=t[9]:(V=JSON.stringify(Array.from(o??[]).toSorted()),t[8]=o,t[9]=V);let ce=V,H;t[10]===ce?H=t[11]:(H=JSON.parse(ce),t[10]=ce,t[11]=H);let le=H,ue=l??Math.min(g,Math.max(v,320)),U;t[12]===Symbol.for(`react.memo_cache_sentinel`)?(U=[],t[12]=U):U=t[12];let W;t[13]===ue?W=t[14]:(W={allowed:!1,dialogOpen:!1,reloadKey:0,loadError:!1,dynamicHeight:ue,grantResolved:!1,grantError:null,manifestDigest:null,grantedPermissions:U},t[13]=ue,t[14]=W);let[G,K]=(0,h.useReducer)(m,W),{allowed:q,dialogOpen:J,reloadKey:Y,loadError:de,dynamicHeight:fe,grantResolved:pe,grantError:X}=G,me;t[15]===n?me=t[16]:(me=()=>{let e=!0;return L.current=!1,K({type:`patch`,patch:{allowed:!1,dialogOpen:!1,grantResolved:!1,grantError:null,manifestDigest:null,grantedPermissions:[]}}),T(n).then(t=>{if(e){if(t.extensionId!==n||!t.manifestDigest)throw Error(`Could not verify plugin permissions`);K({type:`patch`,patch:{allowed:t.granted,dialogOpen:!t.granted,grantResolved:!0,manifestDigest:t.manifestDigest,grantedPermissions:t.permissions}})}}).catch(t=>{e&&K({type:`patch`,patch:{allowed:!1,dialogOpen:!0,grantResolved:!0,grantError:t instanceof Error?t.message:String(t)}})}),()=>{e=!1,I.current+=1}},t[15]=n,t[16]=me);let he;t[17]!==n||t[18]!==A||t[19]!==F||t[20]!==le||t[21]!==Y?(he=[n,le,A,F,Y],t[17]=n,t[18]=A,t[19]=F,t[20]=le,t[21]=Y,t[22]=he):he=t[22],(0,h.useEffect)(me,he);let ge;t[23]===Symbol.for(`react.memo_cache_sentinel`)?(ge=e=>K({type:`patch`,patch:{dialogOpen:e}}),t[23]=ge):ge=t[23];let _e=ge,ve;t[24]!==i||t[25]!==n?(ve=_(n,i),t[24]=i,t[25]=n,t[26]=ve):ve=t[26];let ye=ve,be;t[27]!==q||t[28]!==n||t[29]!==l||t[30]!==g||t[31]!==v||t[32]!==w||t[33]!==G.grantedPermissions||t[34]!==G.manifestDigest?(be=()=>{if(!q)return;let e=R.current;if(!e)return;w.registerIframe(n,e,G.grantedPermissions,G.manifestDigest??void 0);let t=w.subscribeExtensionEvents(n,e=>{if(e.event!==`ui.resize`||!e.data||typeof e.data!=`object`||e.data===null)return;let t=Number(e.data.height);Number.isFinite(t)&&l===void 0&&K({type:`patch`,patch:{dynamicHeight:Math.min(g,Math.max(v,t))}})});return()=>{t(),w.unregisterIframe(n)}},t[27]=q,t[28]=n,t[29]=l,t[30]=g,t[31]=v,t[32]=w,t[33]=G.grantedPermissions,t[34]=G.manifestDigest,t[35]=be):be=t[35];let xe;t[36]!==q||t[37]!==n||t[38]!==l||t[39]!==g||t[40]!==v||t[41]!==Y||t[42]!==w||t[43]!==G.grantedPermissions||t[44]!==G.manifestDigest?(xe=[q,n,l,g,v,G.grantedPermissions,G.manifestDigest,w,Y],t[36]=q,t[37]=n,t[38]=l,t[39]=g,t[40]=v,t[41]=Y,t[42]=w,t[43]=G.grantedPermissions,t[44]=G.manifestDigest,t[45]=xe):xe=t[45],(0,h.useLayoutEffect)(be,xe);let Se,Ce;t[46]!==q||t[47]!==n||t[48]!==z||t[49]!==w?(Se=()=>{if(!q)return;let e=d(z);w.sendEvent(n,`theme.changed`,e)},Ce=[q,n,z,w],t[46]=q,t[47]=n,t[48]=z,t[49]=w,t[50]=Se,t[51]=Ce):(Se=t[50],Ce=t[51]),(0,h.useEffect)(Se,Ce);let we;t[52]!==fe||t[53]!==l?(we=l===void 0?{width:`100%`,height:fe,border:`none`}:{width:`100%`,height:l,border:`none`},t[52]=fe,t[53]=l,t[54]=we):we=t[54];let Te=we,Ee;t[55]!==n||t[56]!==A||t[57]!==F||t[58]!==G.manifestDigest?(Ee=()=>{if(L.current||!G.manifestDigest)return;L.current=!0;let e=I.current,t=()=>I.current===e&&a.getState().baseUrl===A&&a.getState().conversationId===F;E(n,G.manifestDigest).then(e=>{if(t()){if(!e.granted||e.extensionId!==n||e.manifestDigest!==G.manifestDigest)throw Error(`Permission grant was not persisted`);K({type:`patch`,patch:{allowed:!0,grantError:null}})}}).catch(e=>{t()&&K({type:`patch`,patch:{allowed:!1,manifestDigest:null,grantError:e instanceof Error?e.message:String(e)}})}).finally(()=>{t()&&(L.current=!1)})},t[55]=n,t[56]=A,t[57]=F,t[58]=G.manifestDigest,t[59]=Ee):Ee=t[59];let De=Ee;if(!pe){let e=`${c??``} min-h-32 animate-pulse rounded-lg bg-surface-inset`,n;return t[60]===e?n=t[61]:(n=(0,x.jsx)(`div`,{className:e}),t[60]=e,t[61]=n),n}if(!q){let e=!G.manifestDigest,r;t[62]!==J||t[63]!==ae||t[64]!==n||t[65]!==De||t[66]!==e||t[67]!==G.grantedPermissions?(r=(0,x.jsx)(S,{open:J,onOpenChange:_e,extensionId:n,extensionName:ae,permissions:G.grantedPermissions,confirmDisabled:e,onConfirm:De}),t[62]=J,t[63]=ae,t[64]=n,t[65]=De,t[66]=e,t[67]=G.grantedPermissions,t[68]=r):r=t[68];let i;t[69]!==c||t[70]!==J||t[71]!==X||t[72]!==Y||t[73]!==C?(i=J?null:(0,x.jsxs)(`div`,{className:c?`${c} rounded-lg border border-edge border-dashed bg-surface-base p-4 text-sm text-fg-muted`:`rounded-lg border border-edge border-dashed bg-surface-base p-4 text-sm text-fg-muted`,children:[X?(0,x.jsx)(`p`,{className:`mb-2 text-danger`,children:X}):null,(0,x.jsx)(`p`,{children:C.deniedHint}),(0,x.jsx)(`button`,{type:`button`,className:`mt-2 text-sm font-medium text-accent underline-offset-2 hover:underline`,onClick:()=>K({type:`patch`,patch:{reloadKey:Y+1}}),children:C.reviewPermissions})]}),t[69]=c,t[70]=J,t[71]=X,t[72]=Y,t[73]=C,t[74]=i):i=t[74];let a;return t[75]!==r||t[76]!==i?(a=(0,x.jsxs)(x.Fragment,{children:[r,i]}),t[75]=r,t[76]=i,t[77]=a):a=t[77],a}let Z;t[78]!==de||t[79]!==Y||t[80]!==C?(Z=de?(0,x.jsxs)(`div`,{className:`mb-2 rounded-lg border border-amber-500/40 bg-amber-500/10 px-3 py-2 text-sm text-fg`,children:[(0,x.jsx)(`p`,{children:C.loadFailed}),(0,x.jsx)(`p`,{className:`mt-2 text-xs text-fg-muted`,children:C.loadFailedConnectionHint}),(0,x.jsx)(`button`,{type:`button`,className:`mt-2 font-medium text-accent underline-offset-2 hover:underline`,onClick:()=>{K({type:`patch`,patch:{loadError:!1,reloadKey:Y+1}})},children:C.retryLoad})]}):null,t[78]=de,t[79]=Y,t[80]=C,t[81]=Z):Z=t[81];let Oe=`${n}-${i}-${Y}`,ke;t[82]===Symbol.for(`react.memo_cache_sentinel`)?(ke=()=>K({type:`patch`,patch:{loadError:!0}}),t[82]=ke):ke=t[82];let Q;t[83]!==n||t[84]!==u||t[85]!==y||t[86]!==w?(Q=()=>{K({type:`patch`,patch:{loadError:!1}}),w.sendInit(n,d(p.getState().resolved),y),u!==void 0&&w.sendEvent(n,`widget.data`,u)},t[83]=n,t[84]=u,t[85]=y,t[86]=w,t[87]=Q):Q=t[87];let $;t[88]!==c||t[89]!==se||t[90]!==ye||t[91]!==Te||t[92]!==Oe||t[93]!==Q?($=(0,x.jsx)(`iframe`,{ref:R,className:c,title:se,src:ye,style:Te,sandbox:k,referrerPolicy:`no-referrer`,onError:ke,onLoad:Q},Oe),t[88]=c,t[89]=se,t[90]=ye,t[91]=Te,t[92]=Oe,t[93]=Q,t[94]=$):$=t[94];let Ae;return t[95]!==Z||t[96]!==$?(Ae=(0,x.jsxs)(`div`,{className:`flex flex-1 min-h-0 min-w-0 flex-col`,children:[Z,$]}),t[95]=Z,t[96]=$,t[97]=Ae):Ae=t[97],Ae}function j(e){return e.resolved}function M(e){return e.conversationId}function N(e){return e.baseUrl}function P(e){return e.language}export{A as t};
1
+ import{i as e}from"./rolldown-runtime-aKtaBQYM.js";import{a as t,n,t as r}from"./vendor-react-BOUWij0V.js";import{i,l as a,n as ee,o}from"./locale-store-TQcz_Vjt.js";import{t as te}from"./messages-DaLmc4W1.js";import{a as s,n as c,o as l,r as ne,s as re,t as u}from"./dist-DfWfZ9iu.js";import{c as d,n as f}from"./extension-provider-BZwcaU5Y.js";import{i as p}from"./theme-store-DB1ZfBUm.js";import{r as m}from"./settings-form-draft-Dy10ldo8.js";var h=e(t(),1),ie=n();function g(e){return e.split(`/`).filter(Boolean).map(e=>encodeURIComponent(e)).join(`/`)}function _(e,t){let n=g(t);return i(`/api/extensions/${encodeURIComponent(e)}/assets/${n}`)}var v={"capability:xopc.notes.create":`Create notes in this workspace`,"capability:xopc.notes.update":`Change notes in this workspace at an exact revision`,"capability:xopc.notes.append":`Append content to notes in this workspace`,"capability:xopc.notes.get":`Read notes in this workspace by ID`,"capability:xopc.notes.list":`Search and list notes in this workspace`,"capability:xopc.tasks.get":`Read tasks and their context in this workspace`,"capability:xopc.tasks.list":`Search and list tasks in this workspace`,theme:`Read theme (light / dark)`,"agent.send":`Send messages to the assistant`,"agent.subscribe":`Receive live agent stream events for a chat`,"session.read":`List and open chat sessions`,"config.read":`Read plugin configuration`,"config.write":`Write plugin configuration`,storage:`Read and write plugin storage`,notification:`Show in-app notifications`},y={"capability:xopc.notes.create":`在当前工作区创建笔记`,"capability:xopc.notes.update":`按精确版本修改当前工作区的笔记`,"capability:xopc.notes.append":`向当前工作区的笔记追加内容`,"capability:xopc.notes.get":`按 ID 读取当前工作区的笔记`,"capability:xopc.notes.list":`搜索和列出当前工作区的笔记`,"capability:xopc.tasks.get":`读取当前工作区的任务及其上下文`,"capability:xopc.tasks.list":`搜索和列出当前工作区的任务`,theme:`读取主题(浅色/深色)`,"agent.send":`向助手发送消息`,"agent.subscribe":`接收会话的实时助手流式事件`,"session.read":`列出并打开聊天会话`,"config.read":`读取插件配置`,"config.write":`写入插件配置`,storage:`读写插件存储`,notification:`显示应用内通知`};function b(e,t){let n=v[e];return t===`zh`&&y[e]?y[e]:n??e}var x=r();function S(e){let t=(0,ie.c)(59),{open:n,onOpenChange:r,extensionId:i,extensionName:a,permissions:o,onConfirm:d,confirmDisabled:f}=e,p=ee(w),m,h,g,_,v,y,S,T,E,D,O,k;t[0]!==a||t[1]!==p||t[2]!==r||t[3]!==n?(v=te(p).extensionUi,_=u,O=n,k=r,g=l,t[16]===Symbol.for(`react.memo_cache_sentinel`)?(D=(0,x.jsx)(s,{className:`xopc-dialog-overlay fixed inset-0 z-[130] bg-scrim`}),t[16]=D):D=t[16],h=ne,T=`xopc-dialog-content fixed left-1/2 top-1/2 z-[131] w-[min(28rem,calc(100vw-2rem))] -translate-x-1/2 -translate-y-1/2 rounded-xl border border-edge bg-surface-overlay p-5`,E=C,m=re,y=`text-base font-semibold text-fg`,S=v.permissionTitle.replace(`{{name}}`,a),t[0]=a,t[1]=p,t[2]=r,t[3]=n,t[4]=m,t[5]=h,t[6]=g,t[7]=_,t[8]=v,t[9]=y,t[10]=S,t[11]=T,t[12]=E,t[13]=D,t[14]=O,t[15]=k):(m=t[4],h=t[5],g=t[6],_=t[7],v=t[8],y=t[9],S=t[10],T=t[11],E=t[12],D=t[13],O=t[14],k=t[15]);let A;t[17]!==m||t[18]!==y||t[19]!==S?(A=(0,x.jsx)(m,{className:y,children:S}),t[17]=m,t[18]=y,t[19]=S,t[20]=A):A=t[20];let j;t[21]===i?j=t[22]:(j=(0,x.jsxs)(`span`,{className:`font-mono text-xs text-fg-muted`,title:i,children:[`(`,i,`)`]}),t[21]=i,t[22]=j);let M;t[23]!==v.permissionSubtitle||t[24]!==j?(M=(0,x.jsxs)(`p`,{className:`mt-2 text-sm text-fg-muted`,children:[v.permissionSubtitle,` `,j]}),t[23]=v.permissionSubtitle,t[24]=j,t[25]=M):M=t[25];let N;t[26]!==p||t[27]!==o||t[28]!==v.permissionsNone?(N=o.length===0?(0,x.jsx)(`p`,{className:`mt-4 text-sm text-fg-muted`,children:v.permissionsNone}):(0,x.jsx)(`ul`,{className:`mt-4 max-h-48 list-inside list-disc space-y-1 overflow-y-auto text-sm text-fg`,children:o.map(e=>(0,x.jsx)(`li`,{children:b(e,p)},e))}),t[26]=p,t[27]=o,t[28]=v.permissionsNone,t[29]=N):N=t[29];let P;t[30]===v.deny?P=t[31]:(P=(0,x.jsx)(c,{asChild:!0,children:(0,x.jsx)(`button`,{type:`button`,className:`rounded-lg border border-edge px-3 py-2 text-sm text-fg hover:bg-surface-inset`,children:v.deny})}),t[30]=v.deny,t[31]=P);let F;t[32]!==d||t[33]!==r?(F=()=>{d(),r(!1)},t[32]=d,t[33]=r,t[34]=F):F=t[34];let I;t[35]!==f||t[36]!==v.allow||t[37]!==F?(I=(0,x.jsx)(`button`,{type:`button`,disabled:f,className:`rounded-lg bg-accent px-3 py-2 text-sm font-medium text-on-accent hover:opacity-90`,onClick:F,children:v.allow}),t[35]=f,t[36]=v.allow,t[37]=F,t[38]=I):I=t[38];let L;t[39]!==P||t[40]!==I?(L=(0,x.jsxs)(`div`,{className:`mt-6 flex justify-end gap-2`,children:[P,I]}),t[39]=P,t[40]=I,t[41]=L):L=t[41];let R;t[42]!==h||t[43]!==M||t[44]!==N||t[45]!==L||t[46]!==T||t[47]!==E||t[48]!==A?(R=(0,x.jsxs)(h,{className:T,onOpenAutoFocus:E,children:[A,M,N,L]}),t[42]=h,t[43]=M,t[44]=N,t[45]=L,t[46]=T,t[47]=E,t[48]=A,t[49]=R):R=t[49];let z;t[50]!==g||t[51]!==R||t[52]!==D?(z=(0,x.jsxs)(g,{children:[D,R]}),t[50]=g,t[51]=R,t[52]=D,t[53]=z):z=t[53];let B;return t[54]!==_||t[55]!==z||t[56]!==O||t[57]!==k?(B=(0,x.jsx)(_,{open:O,onOpenChange:k,children:z}),t[54]=_,t[55]=z,t[56]=O,t[57]=k,t[58]=B):B=t[58],B}function C(e){return e.preventDefault()}function w(e){return e.language}async function T(e){let{grant:t}=await o(i(`/api/extensions/${encodeURIComponent(e)}/ui-grant`));return t}async function E(e,t){return(await o(i(`/api/extensions/${encodeURIComponent(e)}/ui-grant`),{method:`POST`,body:JSON.stringify({manifestDigest:t})})).grant}var D=48,O=2e3,k=`allow-scripts allow-forms allow-popups`;function A(e){let t=(0,ie.c)(98),{extensionId:n,extensionName:r,entrypoint:i,permissions:o,title:s,className:c,fixedHeight:l,maxHeight:ne,minHeight:re,initialData:u}=e,g=ne===void 0?O:ne,v=re===void 0?D:re,y=ee(P),b;t[0]===y?b=t[1]:(b=te(y),t[0]=y,t[1]=b);let C=b.extensionUi,w=f(),A=a(N),F=a(M),I=(0,h.useRef)(0),L=(0,h.useRef)(!1),R=(0,h.useRef)(null),z=p(j),B;t[2]!==n||t[3]!==r?(B=r?.trim()||n,t[2]=n,t[3]=r,t[4]=B):B=t[4];let ae=B,oe;t[5]!==n||t[6]!==s?(oe=s?.trim()||`Extension ${n}`,t[5]=n,t[6]=s,t[7]=oe):oe=t[7];let se=oe,V;t[8]===o?V=t[9]:(V=JSON.stringify(Array.from(o??[]).toSorted()),t[8]=o,t[9]=V);let ce=V,H;t[10]===ce?H=t[11]:(H=JSON.parse(ce),t[10]=ce,t[11]=H);let le=H,ue=l??Math.min(g,Math.max(v,320)),U;t[12]===Symbol.for(`react.memo_cache_sentinel`)?(U=[],t[12]=U):U=t[12];let W;t[13]===ue?W=t[14]:(W={allowed:!1,dialogOpen:!1,reloadKey:0,loadError:!1,dynamicHeight:ue,grantResolved:!1,grantError:null,manifestDigest:null,grantedPermissions:U},t[13]=ue,t[14]=W);let[G,K]=(0,h.useReducer)(m,W),{allowed:q,dialogOpen:J,reloadKey:Y,loadError:de,dynamicHeight:fe,grantResolved:pe,grantError:X}=G,me;t[15]===n?me=t[16]:(me=()=>{let e=!0;return L.current=!1,K({type:`patch`,patch:{allowed:!1,dialogOpen:!1,grantResolved:!1,grantError:null,manifestDigest:null,grantedPermissions:[]}}),T(n).then(t=>{if(e){if(t.extensionId!==n||!t.manifestDigest)throw Error(`Could not verify plugin permissions`);K({type:`patch`,patch:{allowed:t.granted,dialogOpen:!t.granted,grantResolved:!0,manifestDigest:t.manifestDigest,grantedPermissions:t.permissions}})}}).catch(t=>{e&&K({type:`patch`,patch:{allowed:!1,dialogOpen:!0,grantResolved:!0,grantError:t instanceof Error?t.message:String(t)}})}),()=>{e=!1,I.current+=1}},t[15]=n,t[16]=me);let he;t[17]!==n||t[18]!==A||t[19]!==F||t[20]!==le||t[21]!==Y?(he=[n,le,A,F,Y],t[17]=n,t[18]=A,t[19]=F,t[20]=le,t[21]=Y,t[22]=he):he=t[22],(0,h.useEffect)(me,he);let ge;t[23]===Symbol.for(`react.memo_cache_sentinel`)?(ge=e=>K({type:`patch`,patch:{dialogOpen:e}}),t[23]=ge):ge=t[23];let _e=ge,ve;t[24]!==i||t[25]!==n?(ve=_(n,i),t[24]=i,t[25]=n,t[26]=ve):ve=t[26];let ye=ve,be;t[27]!==q||t[28]!==n||t[29]!==l||t[30]!==g||t[31]!==v||t[32]!==w||t[33]!==G.grantedPermissions||t[34]!==G.manifestDigest?(be=()=>{if(!q)return;let e=R.current;if(!e)return;w.registerIframe(n,e,G.grantedPermissions,G.manifestDigest??void 0);let t=w.subscribeExtensionEvents(n,e=>{if(e.event!==`ui.resize`||!e.data||typeof e.data!=`object`||e.data===null)return;let t=Number(e.data.height);Number.isFinite(t)&&l===void 0&&K({type:`patch`,patch:{dynamicHeight:Math.min(g,Math.max(v,t))}})});return()=>{t(),w.unregisterIframe(n)}},t[27]=q,t[28]=n,t[29]=l,t[30]=g,t[31]=v,t[32]=w,t[33]=G.grantedPermissions,t[34]=G.manifestDigest,t[35]=be):be=t[35];let xe;t[36]!==q||t[37]!==n||t[38]!==l||t[39]!==g||t[40]!==v||t[41]!==Y||t[42]!==w||t[43]!==G.grantedPermissions||t[44]!==G.manifestDigest?(xe=[q,n,l,g,v,G.grantedPermissions,G.manifestDigest,w,Y],t[36]=q,t[37]=n,t[38]=l,t[39]=g,t[40]=v,t[41]=Y,t[42]=w,t[43]=G.grantedPermissions,t[44]=G.manifestDigest,t[45]=xe):xe=t[45],(0,h.useLayoutEffect)(be,xe);let Se,Ce;t[46]!==q||t[47]!==n||t[48]!==z||t[49]!==w?(Se=()=>{if(!q)return;let e=d(z);w.sendEvent(n,`theme.changed`,e)},Ce=[q,n,z,w],t[46]=q,t[47]=n,t[48]=z,t[49]=w,t[50]=Se,t[51]=Ce):(Se=t[50],Ce=t[51]),(0,h.useEffect)(Se,Ce);let we;t[52]!==fe||t[53]!==l?(we=l===void 0?{width:`100%`,height:fe,border:`none`}:{width:`100%`,height:l,border:`none`},t[52]=fe,t[53]=l,t[54]=we):we=t[54];let Te=we,Ee;t[55]!==n||t[56]!==A||t[57]!==F||t[58]!==G.manifestDigest?(Ee=()=>{if(L.current||!G.manifestDigest)return;L.current=!0;let e=I.current,t=()=>I.current===e&&a.getState().baseUrl===A&&a.getState().conversationId===F;E(n,G.manifestDigest).then(e=>{if(t()){if(!e.granted||e.extensionId!==n||e.manifestDigest!==G.manifestDigest)throw Error(`Permission grant was not persisted`);K({type:`patch`,patch:{allowed:!0,grantError:null}})}}).catch(e=>{t()&&K({type:`patch`,patch:{allowed:!1,manifestDigest:null,grantError:e instanceof Error?e.message:String(e)}})}).finally(()=>{t()&&(L.current=!1)})},t[55]=n,t[56]=A,t[57]=F,t[58]=G.manifestDigest,t[59]=Ee):Ee=t[59];let De=Ee;if(!pe){let e=`${c??``} min-h-32 animate-pulse rounded-lg bg-surface-inset`,n;return t[60]===e?n=t[61]:(n=(0,x.jsx)(`div`,{className:e}),t[60]=e,t[61]=n),n}if(!q){let e=!G.manifestDigest,r;t[62]!==J||t[63]!==ae||t[64]!==n||t[65]!==De||t[66]!==e||t[67]!==G.grantedPermissions?(r=(0,x.jsx)(S,{open:J,onOpenChange:_e,extensionId:n,extensionName:ae,permissions:G.grantedPermissions,confirmDisabled:e,onConfirm:De}),t[62]=J,t[63]=ae,t[64]=n,t[65]=De,t[66]=e,t[67]=G.grantedPermissions,t[68]=r):r=t[68];let i;t[69]!==c||t[70]!==J||t[71]!==X||t[72]!==Y||t[73]!==C?(i=J?null:(0,x.jsxs)(`div`,{className:c?`${c} rounded-lg border border-edge border-dashed bg-surface-base p-4 text-sm text-fg-muted`:`rounded-lg border border-edge border-dashed bg-surface-base p-4 text-sm text-fg-muted`,children:[X?(0,x.jsx)(`p`,{className:`mb-2 text-danger`,children:X}):null,(0,x.jsx)(`p`,{children:C.deniedHint}),(0,x.jsx)(`button`,{type:`button`,className:`mt-2 text-sm font-medium text-accent underline-offset-2 hover:underline`,onClick:()=>K({type:`patch`,patch:{reloadKey:Y+1}}),children:C.reviewPermissions})]}),t[69]=c,t[70]=J,t[71]=X,t[72]=Y,t[73]=C,t[74]=i):i=t[74];let a;return t[75]!==r||t[76]!==i?(a=(0,x.jsxs)(x.Fragment,{children:[r,i]}),t[75]=r,t[76]=i,t[77]=a):a=t[77],a}let Z;t[78]!==de||t[79]!==Y||t[80]!==C?(Z=de?(0,x.jsxs)(`div`,{className:`mb-2 rounded-lg border border-amber-500/40 bg-amber-500/10 px-3 py-2 text-sm text-fg`,children:[(0,x.jsx)(`p`,{children:C.loadFailed}),(0,x.jsx)(`p`,{className:`mt-2 text-xs text-fg-muted`,children:C.loadFailedConnectionHint}),(0,x.jsx)(`button`,{type:`button`,className:`mt-2 font-medium text-accent underline-offset-2 hover:underline`,onClick:()=>{K({type:`patch`,patch:{loadError:!1,reloadKey:Y+1}})},children:C.retryLoad})]}):null,t[78]=de,t[79]=Y,t[80]=C,t[81]=Z):Z=t[81];let Oe=`${n}-${i}-${Y}`,ke;t[82]===Symbol.for(`react.memo_cache_sentinel`)?(ke=()=>K({type:`patch`,patch:{loadError:!0}}),t[82]=ke):ke=t[82];let Q;t[83]!==n||t[84]!==u||t[85]!==y||t[86]!==w?(Q=()=>{K({type:`patch`,patch:{loadError:!1}}),w.sendInit(n,d(p.getState().resolved),y),u!==void 0&&w.sendEvent(n,`widget.data`,u)},t[83]=n,t[84]=u,t[85]=y,t[86]=w,t[87]=Q):Q=t[87];let $;t[88]!==c||t[89]!==se||t[90]!==ye||t[91]!==Te||t[92]!==Oe||t[93]!==Q?($=(0,x.jsx)(`iframe`,{ref:R,className:c,title:se,src:ye,style:Te,sandbox:k,referrerPolicy:`no-referrer`,onError:ke,onLoad:Q},Oe),t[88]=c,t[89]=se,t[90]=ye,t[91]=Te,t[92]=Oe,t[93]=Q,t[94]=$):$=t[94];let Ae;return t[95]!==Z||t[96]!==$?(Ae=(0,x.jsxs)(`div`,{className:`flex flex-1 min-h-0 min-w-0 flex-col`,children:[Z,$]}),t[95]=Z,t[96]=$,t[97]=Ae):Ae=t[97],Ae}function j(e){return e.resolved}function M(e){return e.conversationId}function N(e){return e.baseUrl}function P(e){return e.language}export{A as t};
@@ -1 +1 @@
1
- import{a as e,i as t}from"./locale-store-_-_QzAV0.js";async function n(n=``){let i=await e(t(`/api/marketplace${n.trim()?`?q=${encodeURIComponent(n.trim())}`:``}`),{cache:`no-store`});if(!i.ok)throw Error(await r(i));let a=await i.json();if(!a.ok||!Array.isArray(a.extensions))throw Error(a.error??`Invalid response`);return a.extensions}async function r(e){try{let t=await e.json();if(typeof t.error==`string`)return t.error;if(t.error&&typeof t.error==`object`&&typeof t.error.message==`string`)return t.error.message;if(typeof t.message==`string`)return t.message}catch{}return e.statusText||`HTTP ${e.status}`}async function i(n){let i=await e(t(`/api/marketplace/packages/${encodeURIComponent(n.trim())}`),{cache:`no-store`});if(!i.ok)throw Error(await r(i));let a=await i.json();if(!a.ok||!a.payload?.id)throw Error(a.error??`Invalid response`);return a.payload}async function a(n){let i=await e(t(`/api/marketplace/install`),{method:`POST`,headers:{"Content-Type":`application/json`},body:JSON.stringify(n)});if(!i.ok)throw Error(await r(i));let a=await i.json();if(!a.ok||!a.payload?.extensionId)throw Error(a.error??`Invalid response`);return a.payload}async function o(n){let i=await e(t(`/api/extensions/${encodeURIComponent(n.extensionId.trim())}/activation`),{method:`POST`,headers:{"Content-Type":`application/json`},body:JSON.stringify({enabled:n.enabled})});if(!i.ok)throw Error(await r(i));let a=await i.json();if(!a.ok||!a.payload)throw Error(a.error?.message??`Invalid response`);return a.payload}async function s(n){let i=await e(t(`/api/marketplace/uninstall`),{method:`POST`,headers:{"Content-Type":`application/json`},body:JSON.stringify({extensionId:n})});if(!i.ok)throw Error(await r(i));let a=await i.json();if(!a.ok||!a.payload)throw Error(a.error??`Invalid response`);return a.payload}export{s as a,o as i,i as n,a as r,n as t};
1
+ import{a as e,i as t}from"./locale-store-TQcz_Vjt.js";async function n(n=``){let i=await e(t(`/api/marketplace${n.trim()?`?q=${encodeURIComponent(n.trim())}`:``}`),{cache:`no-store`});if(!i.ok)throw Error(await r(i));let a=await i.json();if(!a.ok||!Array.isArray(a.extensions))throw Error(a.error??`Invalid response`);return a.extensions}async function r(e){try{let t=await e.json();if(typeof t.error==`string`)return t.error;if(t.error&&typeof t.error==`object`&&typeof t.error.message==`string`)return t.error.message;if(typeof t.message==`string`)return t.message}catch{}return e.statusText||`HTTP ${e.status}`}async function i(n){let i=await e(t(`/api/marketplace/packages/${encodeURIComponent(n.trim())}`),{cache:`no-store`});if(!i.ok)throw Error(await r(i));let a=await i.json();if(!a.ok||!a.payload?.id)throw Error(a.error??`Invalid response`);return a.payload}async function a(n){let i=await e(t(`/api/marketplace/install`),{method:`POST`,headers:{"Content-Type":`application/json`},body:JSON.stringify(n)});if(!i.ok)throw Error(await r(i));let a=await i.json();if(!a.ok||!a.payload?.extensionId)throw Error(a.error??`Invalid response`);return a.payload}async function o(n){let i=await e(t(`/api/extensions/${encodeURIComponent(n.extensionId.trim())}/activation`),{method:`POST`,headers:{"Content-Type":`application/json`},body:JSON.stringify({enabled:n.enabled})});if(!i.ok)throw Error(await r(i));let a=await i.json();if(!a.ok||!a.payload)throw Error(a.error?.message??`Invalid response`);return a.payload}async function s(n){let i=await e(t(`/api/marketplace/uninstall`),{method:`POST`,headers:{"Content-Type":`application/json`},body:JSON.stringify({extensionId:n})});if(!i.ok)throw Error(await r(i));let a=await i.json();if(!a.ok||!a.payload)throw Error(a.error??`Invalid response`);return a.payload}export{s as a,o as i,i as n,a as r,n as t};
@@ -1 +1 @@
1
- import{i as e}from"./rolldown-runtime-aKtaBQYM.js";import{a as t,n,t as r}from"./vendor-react-BOUWij0V.js";import{f as i}from"./chunk-KS7C4IRE-CiwuuyV8.js";import{t as a}from"./resource-unavailable-CqP8gARc.js";import{r as o,s}from"./extension-provider-8RM98QmD.js";import{t as c}from"./page-header-store-RgQRaRbH.js";import{t as l}from"./extension-iframe-host-D4w7-mf1.js";var u=n(),d=e(t(),1),f=r();function p(){let e=(0,u.c)(24),{extensionId:t,pageId:n}=i(),r=o(),p=c(h),g=c(m),_,v,y;e[0]!==t||e[1]!==r||e[2]!==n?(_=t?r.find(e=>e.id===t&&s(e)):void 0,v=_?.ui?.contributions?.pages,y=t&&v?.length?n?v.find(e=>e.id===n||e.id===`${t}.${n}`):v[0]:void 0,e[0]=t,e[1]=r,e[2]=n,e[3]=_,e[4]=v,e[5]=y):(_=e[3],v=e[4],y=e[5]);let b=y,x,S;if(e[6]!==g||e[7]!==_||e[8]!==t||e[9]!==b||e[10]!==p?(x=()=>{if(!t||!_||!b)return g(),()=>g();let e=b.title?.trim()||_.name||t;return p({startExtra:null,main:(0,f.jsx)(`div`,{className:`w-full min-w-0 px-3 sm:px-5 xl:px-6`,children:(0,f.jsx)(`h1`,{className:`min-w-0 truncate text-base font-semibold tracking-tight text-fg`,title:e,children:e})}),end:null}),()=>g()},S=[g,_,t,b,p],e[6]=g,e[7]=_,e[8]=t,e[9]=b,e[10]=p,e[11]=x,e[12]=S):(x=e[11],S=e[12]),(0,d.useLayoutEffect)(x,S),!t){let t;return e[13]===Symbol.for(`react.memo_cache_sentinel`)?(t=(0,f.jsx)(a,{kind:`plugin`,backTo:`/capabilities/extensions`}),e[13]=t):t=e[13],t}if(!_){let n=r.some(e=>e.id===t)?`plugin-page`:`plugin`,i;return e[14]===n?i=e[15]:(i=(0,f.jsx)(a,{kind:n,backTo:`/capabilities/extensions`}),e[14]=n,e[15]=i),i}if(!v?.length){let t;return e[16]===Symbol.for(`react.memo_cache_sentinel`)?(t=(0,f.jsx)(a,{kind:`plugin-page`,backTo:`/capabilities/extensions`}),e[16]=t):t=e[16],t}if(!b){let t;return e[17]===Symbol.for(`react.memo_cache_sentinel`)?(t=(0,f.jsx)(a,{kind:`plugin`,backTo:`/capabilities/extensions`}),e[17]=t):t=e[17],t}let C=_.ui?.permissions,w;return e[18]!==_.name||e[19]!==t||e[20]!==b.entrypoint||e[21]!==b.title||e[22]!==C?(w=(0,f.jsx)(`div`,{className:`flex min-h-0 flex-1 flex-col`,children:(0,f.jsx)(l,{extensionId:t,extensionName:_.name,entrypoint:b.entrypoint,permissions:C,title:b.title,className:`min-h-0 flex-1`,fixedHeight:void 0,maxHeight:99999})}),e[18]=_.name,e[19]=t,e[20]=b.entrypoint,e[21]=b.title,e[22]=C,e[23]=w):w=e[23],w}function m(e){return e.clearPageHeader}function h(e){return e.setPageHeader}export{p as ExtensionPage};
1
+ import{i as e}from"./rolldown-runtime-aKtaBQYM.js";import{a as t,n,t as r}from"./vendor-react-BOUWij0V.js";import{f as i}from"./chunk-KS7C4IRE-CiwuuyV8.js";import{t as a}from"./resource-unavailable-X-SIrZYI.js";import{r as o,s}from"./extension-provider-BZwcaU5Y.js";import{t as c}from"./page-header-store-D6SzJ9Ch.js";import{t as l}from"./extension-iframe-host-B4Q1CjvW.js";var u=n(),d=e(t(),1),f=r();function p(){let e=(0,u.c)(24),{extensionId:t,pageId:n}=i(),r=o(),p=c(h),g=c(m),_,v,y;e[0]!==t||e[1]!==r||e[2]!==n?(_=t?r.find(e=>e.id===t&&s(e)):void 0,v=_?.ui?.contributions?.pages,y=t&&v?.length?n?v.find(e=>e.id===n||e.id===`${t}.${n}`):v[0]:void 0,e[0]=t,e[1]=r,e[2]=n,e[3]=_,e[4]=v,e[5]=y):(_=e[3],v=e[4],y=e[5]);let b=y,x,S;if(e[6]!==g||e[7]!==_||e[8]!==t||e[9]!==b||e[10]!==p?(x=()=>{if(!t||!_||!b)return g(),()=>g();let e=b.title?.trim()||_.name||t;return p({startExtra:null,main:(0,f.jsx)(`div`,{className:`w-full min-w-0 px-3 sm:px-5 xl:px-6`,children:(0,f.jsx)(`h1`,{className:`min-w-0 truncate text-base font-semibold tracking-tight text-fg`,title:e,children:e})}),end:null}),()=>g()},S=[g,_,t,b,p],e[6]=g,e[7]=_,e[8]=t,e[9]=b,e[10]=p,e[11]=x,e[12]=S):(x=e[11],S=e[12]),(0,d.useLayoutEffect)(x,S),!t){let t;return e[13]===Symbol.for(`react.memo_cache_sentinel`)?(t=(0,f.jsx)(a,{kind:`plugin`,backTo:`/capabilities/extensions`}),e[13]=t):t=e[13],t}if(!_){let n=r.some(e=>e.id===t)?`plugin-page`:`plugin`,i;return e[14]===n?i=e[15]:(i=(0,f.jsx)(a,{kind:n,backTo:`/capabilities/extensions`}),e[14]=n,e[15]=i),i}if(!v?.length){let t;return e[16]===Symbol.for(`react.memo_cache_sentinel`)?(t=(0,f.jsx)(a,{kind:`plugin-page`,backTo:`/capabilities/extensions`}),e[16]=t):t=e[16],t}if(!b){let t;return e[17]===Symbol.for(`react.memo_cache_sentinel`)?(t=(0,f.jsx)(a,{kind:`plugin`,backTo:`/capabilities/extensions`}),e[17]=t):t=e[17],t}let C=_.ui?.permissions,w;return e[18]!==_.name||e[19]!==t||e[20]!==b.entrypoint||e[21]!==b.title||e[22]!==C?(w=(0,f.jsx)(`div`,{className:`flex min-h-0 flex-1 flex-col`,children:(0,f.jsx)(l,{extensionId:t,extensionName:_.name,entrypoint:b.entrypoint,permissions:C,title:b.title,className:`min-h-0 flex-1`,fixedHeight:void 0,maxHeight:99999})}),e[18]=_.name,e[19]=t,e[20]=b.entrypoint,e[21]=b.title,e[22]=C,e[23]=w):w=e[23],w}function m(e){return e.clearPageHeader}function h(e){return e.setPageHeader}export{p as ExtensionPage};
@@ -1 +1 @@
1
- import{i as e}from"./rolldown-runtime-aKtaBQYM.js";import{a as t,n,t as r}from"./vendor-react-BOUWij0V.js";import{a as i,i as a,l as o,o as s}from"./locale-store-_-_QzAV0.js";import{i as c}from"./vendor-swr-CdRzEUwF.js";import{d as l,i as u,t as d}from"./session-manager-DhoRfUGE.js";import{i as f,m as p,n as m,p as h,u as g}from"./schemas-CCWMleym.js";import{a as _}from"./gateway-realtime-B1CCUrsG.js";import{t as v}from"./capabilities-CTu4Y4Gc.js";import{t as y}from"./activity-store-DNkXnatd.js";import{i as b}from"./theme-store-DU_07f3M.js";var x=h({id:m([`xopc.notes.get`,`xopc.notes.list`,`xopc.tasks.get`,`xopc.tasks.list`,`xopc.notes.create`,`xopc.notes.update`,`xopc.notes.append`]),majorVersion:g().int().positive(),descriptorDigest:p().regex(/^[a-f0-9]{64}$/)});f(x).max(7).refine(e=>new Set(e.map(e=>e.id)).size===e.length,`Duplicate capability binding`);var S=e(t(),1),C=n(),w=`agent-stream-event`;function T(e){return e===`off`||e===`on`||e===`stream`}function E(e){if(!e||typeof e!=`object`||Array.isArray(e))return null;let t=e,n=typeof t.conversationId==`string`?t.conversationId.trim():``,r=typeof t.runId==`string`?t.runId.trim():``;return n&&r?{conversationId:n,runId:r}:null}function D(e,t,n){return t&&typeof t==`object`&&!Array.isArray(t)?{...t,seq:n}:{type:e,seq:n,payload:t}}async function O(e){try{let t=await i(a(`/api/sessions/${encodeURIComponent(e)}/agent-config`));if(!t.ok)return`on`;let n=await t.json(),r=n.payload?.activityDetail?.effective;if(T(r))return r;let o=n.payload?.activityDetail?.default;return T(o)?o:`on`}catch{return`on`}}function k(e){window.dispatchEvent(new CustomEvent(w,{detail:e}))}function A(e={}){let t=e.subscribe??_,n=e.loadActivityDetailLevel??O,r=e.dispatch??k,i=new Map,a=!1,o=e=>{let o=E(e.detail);if(!o||i.has(o.runId))return;let s=`on`,c=!1,l,u=!1,d=!1,f=()=>{},p=()=>{u||(u=!0,f(),i.get(o.runId)===p&&i.delete(o.runId))},m=e=>{a||u||r({conversationId:o.conversationId,event:e,activityDetailLevel:s})};n(o.conversationId).then(e=>{s=e,c=!0,e===`stream`&&l&&!d&&m(l),l=void 0}),f=t(`run:${o.runId}`,{onEvent:e=>{if(u||d)return;let t=D(e.event,e.data,e.seq);e.event===`thinking_delta`&&!c?l=t:m(t),e.event===`run_end`&&(d=!0,l=void 0,queueMicrotask(p))},onGap:e=>{e.recoverable||p()}},0),i.set(o.runId,p)},s=e=>{let t=E(e.detail);t&&i.get(t.runId)?.()};return window.addEventListener(`run-started`,o),window.addEventListener(`run-completed`,s),window.addEventListener(`agent-run-ended`,s),()=>{a=!0,window.removeEventListener(`run-started`,o),window.removeEventListener(`run-completed`,s),window.removeEventListener(`agent-run-ended`,s);for(let e of[...i.values()])e()}}var j=function(e){return e[e.PermissionDenied=4001]=`PermissionDenied`,e[e.InvalidRequest=4002]=`InvalidRequest`,e[e.MethodNotFound=4003]=`MethodNotFound`,e[e.InternalError=4004]=`InternalError`,e[e.Timeout=4005]=`Timeout`,e[e.ExtensionNotFound=4006]=`ExtensionNotFound`,e[e.RateLimited=4007]=`RateLimited`,e}({});async function M(e,t,n){let r=new d,i=await r.loadSessionAgentConfig(e);await r.loadSession(e),l(e,i),await new u().send(t,e,n,i.thinkingLevel)}var N=[`--color-surface-base`,`--color-surface-panel`,`--color-surface-hover`,`--color-fg`,`--color-fg-muted`,`--color-fg-subtle`,`--color-accent`,`--color-accent-hover`,`--color-accent-soft`,`--color-edge`,`--color-edge-subtle`,`--color-danger`,`--color-success`,`--color-warning`,`--radius-sm`,`--radius-lg`,`--radius-xl`];function P(e){let t=getComputedStyle(document.documentElement),n={};for(let e of N){let r=t.getPropertyValue(e).trim();r&&(n[e]=r)}return{mode:e,tokens:n,fontFamily:t.getPropertyValue(`font-family`).trim(),fontFamilyMono:t.getPropertyValue(`--font-mono`).trim()}}var F={"agent.sendMessage":`agent.send`,"session.list":`session.read`,"session.navigate":`session.read`,"config.get":`config.read`,"config.set":`config.write`,"storage.get":`storage`,"storage.set":`storage`,"storage.remove":`storage`,"storage.keys":`storage`,"ui.notification":`notification`,"theme.get":`theme`},I=class{iframes=new Map;byContentWindow=new WeakMap;handlers=new Map;extensionPermissions=new Map;releaseBindings=new Map;eventSubscribers=new Map;agentStreamSubscriptions=new Map;boundListener=e=>{this.onWindowMessage(e)};constructor(){window.addEventListener(`message`,this.boundListener)}dispose(){window.removeEventListener(`message`,this.boundListener),this.iframes.clear(),this.handlers.clear(),this.extensionPermissions.clear(),this.releaseBindings.clear(),this.eventSubscribers.clear(),this.agentStreamSubscriptions.clear()}registerIframe(e,t,n,r){let i=this.iframes.get(e);if(i&&i!==t&&i.contentWindow&&this.byContentWindow.delete(i.contentWindow),this.iframes.set(e,t),this.extensionPermissions.set(e,new Set(n)),this.releaseBindings.delete(e),r){let t=o.getState();this.releaseBindings.set(e,{digest:r,baseUrl:t.baseUrl,namespace:t.conversationId})}this.rememberIframeWindow(e,t)}unregisterIframe(e){let t=this.iframes.get(e);this.sendEvent(e,`panel.dispose`),t?.contentWindow&&this.byContentWindow.delete(t.contentWindow),this.iframes.delete(e),this.extensionPermissions.delete(e),this.releaseBindings.delete(e),this.agentStreamSubscriptions.delete(e)}rememberIframeWindow(e,t){let n=t.contentWindow;n&&this.byContentWindow.set(n,{extensionId:e,iframe:t})}subscribeAgentStream(e,t){let n=this.agentStreamSubscriptions.get(e);n||(n=new Set,this.agentStreamSubscriptions.set(e,n)),n.add(t)}unsubscribeAgentStream(e,t){this.agentStreamSubscriptions.get(e)?.delete(t)}forwardAgentStreamEvent(e,t){for(let[n,r]of this.agentStreamSubscriptions)r.has(e)&&this.sendEvent(n,`agent.stream.${e}`,t)}broadcastExtensionEvent(e,t,n){let r=t.startsWith(`ext.`)?t:`ext.${t}`;for(let[t]of this.iframes)t!==e&&this.sendEvent(t,r,n)}handleExtensionEvent(e,t,n){if(t.startsWith(`ext.`)){let r=t.slice(4);this.broadcastExtensionEvent(e,r,n);return}if(t===`agent.subscribe`||t===`agent.unsubscribe`){if(!(this.extensionPermissions.get(e)??new Set).has(`agent.subscribe`))return;let{conversationId:r}=n??{};if(typeof r!=`string`||!r.trim())return;let i=r.trim();t===`agent.subscribe`?this.subscribeAgentStream(e,i):this.unsubscribeAgentStream(e,i)}}registerMethod(e,t){this.handlers.set(e,t)}getReleaseDigest(e){let t=this.releaseBindings.get(e),n=o.getState();if(!t||t.baseUrl!==n.baseUrl||t.namespace!==n.conversationId)throw Error(`Extension release authorization is unavailable`);return t.digest}subscribeExtensionEvents(e,t){let n=this.eventSubscribers.get(e);return n||(n=new Set,this.eventSubscribers.set(e,n)),n.add(t),()=>{n.delete(t),n.size===0&&this.eventSubscribers.delete(e)}}sendInit(e,t,n){let r=this.iframes.get(e);if(!r?.contentWindow)return;this.rememberIframeWindow(e,r);let i=[...this.extensionPermissions.get(e)??[]];r.contentWindow.postMessage({source:`xopc-host`,type:`init`,extensionId:e,permissions:i,theme:t,locale:n},`*`)}sendEvent(e,t,n){let r=this.iframes.get(e);r?.contentWindow&&r.contentWindow.postMessage({source:`xopc-host`,type:`event`,event:t,data:n},`*`)}broadcastEvent(e,t){for(let[,n]of this.iframes)n.contentWindow?.postMessage({source:`xopc-host`,type:`event`,event:e,data:t},`*`)}postResponse(e,t,n,r,i){let a=e.contentWindow,o={source:`xopc-host`,type:`response`,requestId:n,result:r,error:i};!a||a!==t?.source||a.postMessage(o,`*`)}async onWindowMessage(e){let t=e.data;if(!t||t.source!==`xopc-extension`||!e.source)return;let n=this.byContentWindow.get(e.source);if(!n)return;let{iframe:r,extensionId:i}=n;if(this.iframes.get(i)!==r||r.contentWindow!==e.source)return;if(t.type===`event`){this.handleExtensionEvent(i,t.event,t.data);let e=this.eventSubscribers.get(i);if(e){let n={event:t.event,data:t.data};for(let t of e)try{t(n)}catch{}}return}if(t.type!==`request`)return;let{requestId:a,method:s,params:c}=t;if(typeof a!=`string`||a.length>200||typeof s!=`string`||s.length>200)return;let l=this.handlers.get(s);if(!l){this.postResponse(r,e,a,void 0,{code:j.MethodNotFound,message:`Unknown method: ${s}`});return}let u=c&&typeof c==`object`&&`id`in c?c.id:void 0,d=s===`capability.describe`||s===`capability.call`?`capability:${typeof u==`string`?u:``}`:F[s],f=this.extensionPermissions.get(i)??new Set;if(d&&!f.has(d)){this.postResponse(r,e,a,void 0,{code:j.PermissionDenied,message:`Missing permission: ${d}`});return}let p=o.getState(),m=()=>this.iframes.get(i)===r&&r.contentWindow===e.source&&this.extensionPermissions.get(i)===f&&o.getState().baseUrl===p.baseUrl&&o.getState().conversationId===p.conversationId;try{let t=await l(i,c);if(!m())return;this.postResponse(r,e,a,t)}catch(t){if(!m())return;let n=t instanceof Error?t.message:String(t);this.postResponse(r,e,a,void 0,{code:j.InternalError,message:n})}}};function L(e){let t=h({id:x.shape.id}),n=t.extend({call:v});e.registerMethod(`capability.describe`,async(n,r)=>{let{id:i}=t.parse(r),o=e.getReleaseDigest(n),c=(await s(a(`/api/local-app-capabilities/${encodeURIComponent(n)}?manifestDigest=${encodeURIComponent(o)}`))).capabilities.find(e=>e.id===i);if(!c)throw Error(`Capability is unavailable for this release`);return c}),e.registerMethod(`capability.call`,async(t,r)=>{let{id:i,call:o}=n.parse(r),c=e.getReleaseDigest(t);return s(a(`/api/local-app-capabilities/${encodeURIComponent(t)}/${encodeURIComponent(i)}/invocations`),{method:`POST`,body:JSON.stringify({manifestDigest:c,call:o})})}),e.registerMethod(`theme.get`,async()=>P(b.getState().resolved)),e.registerMethod(`ui.navigate`,async(e,t)=>{let n=t&&typeof t==`object`&&t&&`path`in t?String(t.path??``):``;if(n){let e=n.startsWith(`/`)?n:`/${n}`;window.location.hash=`#${e}`}}),e.registerMethod(`ui.notification`,async(e,t)=>{if(!t||typeof t!=`object`)return;let n=t,r=typeof n.title==`string`?n.title.trim():``;r&&y({tone:n.type===`success`||n.type===`warning`||n.type===`error`||n.type===`info`?n.type:`info`,title:r,message:typeof n.message==`string`?n.message:void 0,source:e,dedupeKey:`extension:${e}:${r}`})}),e.registerMethod(`session.navigate`,async(e,t)=>{let n=t&&typeof t==`object`&&t&&`conversationId`in t?String(t.conversationId??``):``;n&&window.dispatchEvent(new CustomEvent(`navigate-to-chat`,{detail:{conversationId:n},bubbles:!0}))}),e.registerMethod(`session.list`,async()=>{let e=await i(a(`/api/sessions`));if(!e.ok)throw Error(`Failed to list sessions: ${e.status}`);return((await e.json()).items??[]).map(e=>({conversationId:e.key,title:e.name,lastMessageAt:e.updatedAt??e.lastAccessedAt,messageCount:e.messageCount}))}),e.registerMethod(`agent.sendMessage`,async(e,t)=>{let{message:n,conversationId:r,newSession:i}=t,a=r?.trim()||``;return(i||!a)&&(a=(await new d().createSession()).key),await M(a,n),{conversationId:a}}),e.registerMethod(`config.get`,async e=>{let t=await i(a(`/api/extensions/${encodeURIComponent(e)}/config`));if(!t.ok)throw Error(`Failed to get config: ${t.status}`);return t.json()}),e.registerMethod(`config.set`,async(e,t)=>{let n=t&&typeof t==`object`&&t&&!Array.isArray(t)?t:{},r=await i(a(`/api/extensions/${encodeURIComponent(e)}/config`),{method:`PATCH`,body:JSON.stringify(n)});if(!r.ok)throw Error(`Failed to set config: ${r.status}`)}),e.registerMethod(`storage.get`,async(e,t)=>{let n=t&&typeof t==`object`&&t&&`key`in t?String(t.key??``):``,r=await i(a(`/api/extensions/${encodeURIComponent(e)}/storage/${encodeURIComponent(n)}`));if(r.status!==404){if(!r.ok)throw Error(`Failed to get storage key: ${r.status}`);return(await r.json()).value}}),e.registerMethod(`storage.set`,async(e,t)=>{let n=t,r=n&&typeof n.key==`string`?n.key:``,o=await i(a(`/api/extensions/${encodeURIComponent(e)}/storage/${encodeURIComponent(r)}`),{method:`PUT`,body:JSON.stringify({value:n?.value})});if(!o.ok)throw Error(`Failed to set storage key: ${o.status}`)}),e.registerMethod(`storage.remove`,async(e,t)=>{let n=t&&typeof t==`object`&&t&&`key`in t?String(t.key??``):``,r=await i(a(`/api/extensions/${encodeURIComponent(e)}/storage/${encodeURIComponent(n)}`),{method:`DELETE`});if(r.status!==404&&!r.ok)throw Error(`Failed to remove storage key: ${r.status}`)}),e.registerMethod(`storage.keys`,async e=>{let t=await i(a(`/api/extensions/${encodeURIComponent(e)}/storage`));if(!t.ok)throw Error(`Failed to list storage keys: ${t.status}`);return(await t.json()).keys??[]})}function R(e){return e.active||e.activationEligible===!0}function z(e){let t=e.ui?.contributions;return t?Array.isArray(t.pages)&&t.pages.length>0||Array.isArray(t.settingsPanels)&&t.settingsPanels.length>0||Array.isArray(t.chatWidgets)&&t.chatWidgets.length>0:!1}function B(e){return e.source===`bundled`&&e.hasUi===!0&&z(e)}function V(e){return e.kind===`image-generation`||e.kind===`media-provider`}function H(e){return R(e)?e.hasConfigSchema||V(e)?!0:e.hasUi?z(e):!1:!1}function U(e){return H(e)||B(e)}var W=r(),G=(0,S.createContext)(null);function K({children:e}){let t=(0,S.useRef)(null);if(!t.current){let e=new I;L(e),t.current=e}let n=t.current,{data:r,isLoading:i,mutate:l}=c(o(e=>!!e.conversationId)?`gateway-extensions-list`:null,()=>s(a(`/api/extensions`)),{revalidateOnFocus:!1}),u=r?.extensions??[],d=b(e=>e.resolved);(0,S.useEffect)(()=>{let e=()=>{l()};return window.addEventListener(`config-reload`,e),window.addEventListener(`registry-updated`,e),()=>{window.removeEventListener(`config-reload`,e),window.removeEventListener(`registry-updated`,e)}},[l]);let f=(0,S.useCallback)(e=>{let t=e.detail;t?.conversationId&&n.forwardAgentStreamEvent(t.conversationId,t.event??t)},[n]),p=(0,S.useRef)(f);p.current=f,(0,S.useEffect)(()=>{let e=e=>{p.current(e)};return window.addEventListener(w,e),()=>{window.removeEventListener(w,e)}},[]),(0,S.useEffect)(()=>{let e=P(d);n.broadcastEvent(`theme.changed`,e)},[d,n]);let m=(0,S.useRef)(n);m.current=n,(0,S.useEffect)(()=>()=>{m.current.dispose(),t.current=null},[]);let h=(0,S.useMemo)(()=>({router:n,extensions:u,loading:i}),[n,u,i]);return(0,W.jsx)(G.Provider,{value:h,children:e})}function q(){let e=(0,S.useContext)(G);if(!e)throw Error(`useExtensionRouter must be used within ExtensionProvider`);return e.router}function J(){let e=(0,S.useContext)(G);if(!e)throw Error(`useExtensions must be used within ExtensionProvider`);return e.extensions}function Y(){let e=(0,C.c)(2),t=J(),n;return e[0]===t?n=e[1]:(n=t.filter(H),e[0]=t,e[1]=n),n}function X(){let e=(0,S.useContext)(G);if(!e)throw Error(`useExtensionsLoading must be used within ExtensionProvider`);return e.loading}export{Y as a,P as c,A as d,X as i,M as l,q as n,V as o,J as r,U as s,K as t,w as u};
1
+ import{i as e}from"./rolldown-runtime-aKtaBQYM.js";import{a as t,n,t as r}from"./vendor-react-BOUWij0V.js";import{a as i,i as a,l as o,o as s}from"./locale-store-TQcz_Vjt.js";import{i as c}from"./vendor-swr-CdRzEUwF.js";import{d as l,i as u,t as d}from"./session-manager-D2rbRfX3.js";import{i as f,m as p,n as m,p as h,u as g}from"./schemas-CCWMleym.js";import{a as _}from"./gateway-realtime-CJtDXQCt.js";import{t as v}from"./capabilities-BMaJizw4.js";import{t as y}from"./activity-store-AI081rxe.js";import{i as b}from"./theme-store-DB1ZfBUm.js";var x=h({id:m([`xopc.notes.get`,`xopc.notes.list`,`xopc.tasks.get`,`xopc.tasks.list`,`xopc.notes.create`,`xopc.notes.update`,`xopc.notes.append`]),majorVersion:g().int().positive(),descriptorDigest:p().regex(/^[a-f0-9]{64}$/)});f(x).max(7).refine(e=>new Set(e.map(e=>e.id)).size===e.length,`Duplicate capability binding`);var S=e(t(),1),C=n(),w=`agent-stream-event`;function T(e){return e===`off`||e===`on`||e===`stream`}function E(e){if(!e||typeof e!=`object`||Array.isArray(e))return null;let t=e,n=typeof t.conversationId==`string`?t.conversationId.trim():``,r=typeof t.runId==`string`?t.runId.trim():``;return n&&r?{conversationId:n,runId:r}:null}function D(e,t,n){return t&&typeof t==`object`&&!Array.isArray(t)?{...t,seq:n}:{type:e,seq:n,payload:t}}async function O(e){try{let t=await i(a(`/api/sessions/${encodeURIComponent(e)}/agent-config`));if(!t.ok)return`on`;let n=await t.json(),r=n.payload?.activityDetail?.effective;if(T(r))return r;let o=n.payload?.activityDetail?.default;return T(o)?o:`on`}catch{return`on`}}function k(e){window.dispatchEvent(new CustomEvent(w,{detail:e}))}function A(e={}){let t=e.subscribe??_,n=e.loadActivityDetailLevel??O,r=e.dispatch??k,i=new Map,a=!1,o=e=>{let o=E(e.detail);if(!o||i.has(o.runId))return;let s=`on`,c=!1,l,u=!1,d=!1,f=()=>{},p=()=>{u||(u=!0,f(),i.get(o.runId)===p&&i.delete(o.runId))},m=e=>{a||u||r({conversationId:o.conversationId,event:e,activityDetailLevel:s})};n(o.conversationId).then(e=>{s=e,c=!0,e===`stream`&&l&&!d&&m(l),l=void 0}),f=t(`run:${o.runId}`,{onEvent:e=>{if(u||d)return;let t=D(e.event,e.data,e.seq);e.event===`thinking_delta`&&!c?l=t:m(t),e.event===`run_end`&&(d=!0,l=void 0,queueMicrotask(p))},onGap:e=>{e.recoverable||p()}},0),i.set(o.runId,p)},s=e=>{let t=E(e.detail);t&&i.get(t.runId)?.()};return window.addEventListener(`run-started`,o),window.addEventListener(`run-completed`,s),window.addEventListener(`agent-run-ended`,s),()=>{a=!0,window.removeEventListener(`run-started`,o),window.removeEventListener(`run-completed`,s),window.removeEventListener(`agent-run-ended`,s);for(let e of[...i.values()])e()}}var j=function(e){return e[e.PermissionDenied=4001]=`PermissionDenied`,e[e.InvalidRequest=4002]=`InvalidRequest`,e[e.MethodNotFound=4003]=`MethodNotFound`,e[e.InternalError=4004]=`InternalError`,e[e.Timeout=4005]=`Timeout`,e[e.ExtensionNotFound=4006]=`ExtensionNotFound`,e[e.RateLimited=4007]=`RateLimited`,e}({});async function M(e,t,n){let r=new d,i=await r.loadSessionAgentConfig(e);await r.loadSession(e),l(e,i),await new u().send(t,e,n,i.thinkingLevel)}var N=[`--color-surface-base`,`--color-surface-panel`,`--color-surface-hover`,`--color-fg`,`--color-fg-muted`,`--color-fg-subtle`,`--color-accent`,`--color-accent-hover`,`--color-accent-soft`,`--color-edge`,`--color-edge-subtle`,`--color-danger`,`--color-success`,`--color-warning`,`--radius-sm`,`--radius-lg`,`--radius-xl`];function P(e){let t=getComputedStyle(document.documentElement),n={};for(let e of N){let r=t.getPropertyValue(e).trim();r&&(n[e]=r)}return{mode:e,tokens:n,fontFamily:t.getPropertyValue(`font-family`).trim(),fontFamilyMono:t.getPropertyValue(`--font-mono`).trim()}}var F={"agent.sendMessage":`agent.send`,"session.list":`session.read`,"session.navigate":`session.read`,"config.get":`config.read`,"config.set":`config.write`,"storage.get":`storage`,"storage.set":`storage`,"storage.remove":`storage`,"storage.keys":`storage`,"ui.notification":`notification`,"theme.get":`theme`},I=class{iframes=new Map;byContentWindow=new WeakMap;handlers=new Map;extensionPermissions=new Map;releaseBindings=new Map;eventSubscribers=new Map;agentStreamSubscriptions=new Map;boundListener=e=>{this.onWindowMessage(e)};constructor(){window.addEventListener(`message`,this.boundListener)}dispose(){window.removeEventListener(`message`,this.boundListener),this.iframes.clear(),this.handlers.clear(),this.extensionPermissions.clear(),this.releaseBindings.clear(),this.eventSubscribers.clear(),this.agentStreamSubscriptions.clear()}registerIframe(e,t,n,r){let i=this.iframes.get(e);if(i&&i!==t&&i.contentWindow&&this.byContentWindow.delete(i.contentWindow),this.iframes.set(e,t),this.extensionPermissions.set(e,new Set(n)),this.releaseBindings.delete(e),r){let t=o.getState();this.releaseBindings.set(e,{digest:r,baseUrl:t.baseUrl,namespace:t.conversationId})}this.rememberIframeWindow(e,t)}unregisterIframe(e){let t=this.iframes.get(e);this.sendEvent(e,`panel.dispose`),t?.contentWindow&&this.byContentWindow.delete(t.contentWindow),this.iframes.delete(e),this.extensionPermissions.delete(e),this.releaseBindings.delete(e),this.agentStreamSubscriptions.delete(e)}rememberIframeWindow(e,t){let n=t.contentWindow;n&&this.byContentWindow.set(n,{extensionId:e,iframe:t})}subscribeAgentStream(e,t){let n=this.agentStreamSubscriptions.get(e);n||(n=new Set,this.agentStreamSubscriptions.set(e,n)),n.add(t)}unsubscribeAgentStream(e,t){this.agentStreamSubscriptions.get(e)?.delete(t)}forwardAgentStreamEvent(e,t){for(let[n,r]of this.agentStreamSubscriptions)r.has(e)&&this.sendEvent(n,`agent.stream.${e}`,t)}broadcastExtensionEvent(e,t,n){let r=t.startsWith(`ext.`)?t:`ext.${t}`;for(let[t]of this.iframes)t!==e&&this.sendEvent(t,r,n)}handleExtensionEvent(e,t,n){if(t.startsWith(`ext.`)){let r=t.slice(4);this.broadcastExtensionEvent(e,r,n);return}if(t===`agent.subscribe`||t===`agent.unsubscribe`){if(!(this.extensionPermissions.get(e)??new Set).has(`agent.subscribe`))return;let{conversationId:r}=n??{};if(typeof r!=`string`||!r.trim())return;let i=r.trim();t===`agent.subscribe`?this.subscribeAgentStream(e,i):this.unsubscribeAgentStream(e,i)}}registerMethod(e,t){this.handlers.set(e,t)}getReleaseDigest(e){let t=this.releaseBindings.get(e),n=o.getState();if(!t||t.baseUrl!==n.baseUrl||t.namespace!==n.conversationId)throw Error(`Extension release authorization is unavailable`);return t.digest}subscribeExtensionEvents(e,t){let n=this.eventSubscribers.get(e);return n||(n=new Set,this.eventSubscribers.set(e,n)),n.add(t),()=>{n.delete(t),n.size===0&&this.eventSubscribers.delete(e)}}sendInit(e,t,n){let r=this.iframes.get(e);if(!r?.contentWindow)return;this.rememberIframeWindow(e,r);let i=[...this.extensionPermissions.get(e)??[]];r.contentWindow.postMessage({source:`xopc-host`,type:`init`,extensionId:e,permissions:i,theme:t,locale:n},`*`)}sendEvent(e,t,n){let r=this.iframes.get(e);r?.contentWindow&&r.contentWindow.postMessage({source:`xopc-host`,type:`event`,event:t,data:n},`*`)}broadcastEvent(e,t){for(let[,n]of this.iframes)n.contentWindow?.postMessage({source:`xopc-host`,type:`event`,event:e,data:t},`*`)}postResponse(e,t,n,r,i){let a=e.contentWindow,o={source:`xopc-host`,type:`response`,requestId:n,result:r,error:i};!a||a!==t?.source||a.postMessage(o,`*`)}async onWindowMessage(e){let t=e.data;if(!t||t.source!==`xopc-extension`||!e.source)return;let n=this.byContentWindow.get(e.source);if(!n)return;let{iframe:r,extensionId:i}=n;if(this.iframes.get(i)!==r||r.contentWindow!==e.source)return;if(t.type===`event`){this.handleExtensionEvent(i,t.event,t.data);let e=this.eventSubscribers.get(i);if(e){let n={event:t.event,data:t.data};for(let t of e)try{t(n)}catch{}}return}if(t.type!==`request`)return;let{requestId:a,method:s,params:c}=t;if(typeof a!=`string`||a.length>200||typeof s!=`string`||s.length>200)return;let l=this.handlers.get(s);if(!l){this.postResponse(r,e,a,void 0,{code:j.MethodNotFound,message:`Unknown method: ${s}`});return}let u=c&&typeof c==`object`&&`id`in c?c.id:void 0,d=s===`capability.describe`||s===`capability.call`?`capability:${typeof u==`string`?u:``}`:F[s],f=this.extensionPermissions.get(i)??new Set;if(d&&!f.has(d)){this.postResponse(r,e,a,void 0,{code:j.PermissionDenied,message:`Missing permission: ${d}`});return}let p=o.getState(),m=()=>this.iframes.get(i)===r&&r.contentWindow===e.source&&this.extensionPermissions.get(i)===f&&o.getState().baseUrl===p.baseUrl&&o.getState().conversationId===p.conversationId;try{let t=await l(i,c);if(!m())return;this.postResponse(r,e,a,t)}catch(t){if(!m())return;let n=t instanceof Error?t.message:String(t);this.postResponse(r,e,a,void 0,{code:j.InternalError,message:n})}}};function L(e){let t=h({id:x.shape.id}),n=t.extend({call:v});e.registerMethod(`capability.describe`,async(n,r)=>{let{id:i}=t.parse(r),o=e.getReleaseDigest(n),c=(await s(a(`/api/local-app-capabilities/${encodeURIComponent(n)}?manifestDigest=${encodeURIComponent(o)}`))).capabilities.find(e=>e.id===i);if(!c)throw Error(`Capability is unavailable for this release`);return c}),e.registerMethod(`capability.call`,async(t,r)=>{let{id:i,call:o}=n.parse(r),c=e.getReleaseDigest(t);return s(a(`/api/local-app-capabilities/${encodeURIComponent(t)}/${encodeURIComponent(i)}/invocations`),{method:`POST`,body:JSON.stringify({manifestDigest:c,call:o})})}),e.registerMethod(`theme.get`,async()=>P(b.getState().resolved)),e.registerMethod(`ui.navigate`,async(e,t)=>{let n=t&&typeof t==`object`&&t&&`path`in t?String(t.path??``):``;if(n){let e=n.startsWith(`/`)?n:`/${n}`;window.location.hash=`#${e}`}}),e.registerMethod(`ui.notification`,async(e,t)=>{if(!t||typeof t!=`object`)return;let n=t,r=typeof n.title==`string`?n.title.trim():``;r&&y({tone:n.type===`success`||n.type===`warning`||n.type===`error`||n.type===`info`?n.type:`info`,title:r,message:typeof n.message==`string`?n.message:void 0,source:e,dedupeKey:`extension:${e}:${r}`})}),e.registerMethod(`session.navigate`,async(e,t)=>{let n=t&&typeof t==`object`&&t&&`conversationId`in t?String(t.conversationId??``):``;n&&window.dispatchEvent(new CustomEvent(`navigate-to-chat`,{detail:{conversationId:n},bubbles:!0}))}),e.registerMethod(`session.list`,async()=>{let e=await i(a(`/api/sessions`));if(!e.ok)throw Error(`Failed to list sessions: ${e.status}`);return((await e.json()).items??[]).map(e=>({conversationId:e.key,title:e.name,lastMessageAt:e.updatedAt??e.lastAccessedAt,messageCount:e.messageCount}))}),e.registerMethod(`agent.sendMessage`,async(e,t)=>{let{message:n,conversationId:r,newSession:i}=t,a=r?.trim()||``;return(i||!a)&&(a=(await new d().createSession()).key),await M(a,n),{conversationId:a}}),e.registerMethod(`config.get`,async e=>{let t=await i(a(`/api/extensions/${encodeURIComponent(e)}/config`));if(!t.ok)throw Error(`Failed to get config: ${t.status}`);return t.json()}),e.registerMethod(`config.set`,async(e,t)=>{let n=t&&typeof t==`object`&&t&&!Array.isArray(t)?t:{},r=await i(a(`/api/extensions/${encodeURIComponent(e)}/config`),{method:`PATCH`,body:JSON.stringify(n)});if(!r.ok)throw Error(`Failed to set config: ${r.status}`)}),e.registerMethod(`storage.get`,async(e,t)=>{let n=t&&typeof t==`object`&&t&&`key`in t?String(t.key??``):``,r=await i(a(`/api/extensions/${encodeURIComponent(e)}/storage/${encodeURIComponent(n)}`));if(r.status!==404){if(!r.ok)throw Error(`Failed to get storage key: ${r.status}`);return(await r.json()).value}}),e.registerMethod(`storage.set`,async(e,t)=>{let n=t,r=n&&typeof n.key==`string`?n.key:``,o=await i(a(`/api/extensions/${encodeURIComponent(e)}/storage/${encodeURIComponent(r)}`),{method:`PUT`,body:JSON.stringify({value:n?.value})});if(!o.ok)throw Error(`Failed to set storage key: ${o.status}`)}),e.registerMethod(`storage.remove`,async(e,t)=>{let n=t&&typeof t==`object`&&t&&`key`in t?String(t.key??``):``,r=await i(a(`/api/extensions/${encodeURIComponent(e)}/storage/${encodeURIComponent(n)}`),{method:`DELETE`});if(r.status!==404&&!r.ok)throw Error(`Failed to remove storage key: ${r.status}`)}),e.registerMethod(`storage.keys`,async e=>{let t=await i(a(`/api/extensions/${encodeURIComponent(e)}/storage`));if(!t.ok)throw Error(`Failed to list storage keys: ${t.status}`);return(await t.json()).keys??[]})}function R(e){return e.active||e.activationEligible===!0}function z(e){let t=e.ui?.contributions;return t?Array.isArray(t.pages)&&t.pages.length>0||Array.isArray(t.settingsPanels)&&t.settingsPanels.length>0||Array.isArray(t.chatWidgets)&&t.chatWidgets.length>0:!1}function B(e){return e.source===`bundled`&&e.hasUi===!0&&z(e)}function V(e){return e.kind===`image-generation`||e.kind===`media-provider`}function H(e){return R(e)?e.hasConfigSchema||V(e)?!0:e.hasUi?z(e):!1:!1}function U(e){return H(e)||B(e)}var W=r(),G=(0,S.createContext)(null);function K({children:e}){let t=(0,S.useRef)(null);if(!t.current){let e=new I;L(e),t.current=e}let n=t.current,{data:r,isLoading:i,mutate:l}=c(o(e=>!!e.conversationId)?`gateway-extensions-list`:null,()=>s(a(`/api/extensions`)),{revalidateOnFocus:!1}),u=r?.extensions??[],d=b(e=>e.resolved);(0,S.useEffect)(()=>{let e=()=>{l()};return window.addEventListener(`config-reload`,e),window.addEventListener(`registry-updated`,e),()=>{window.removeEventListener(`config-reload`,e),window.removeEventListener(`registry-updated`,e)}},[l]);let f=(0,S.useCallback)(e=>{let t=e.detail;t?.conversationId&&n.forwardAgentStreamEvent(t.conversationId,t.event??t)},[n]),p=(0,S.useRef)(f);p.current=f,(0,S.useEffect)(()=>{let e=e=>{p.current(e)};return window.addEventListener(w,e),()=>{window.removeEventListener(w,e)}},[]),(0,S.useEffect)(()=>{let e=P(d);n.broadcastEvent(`theme.changed`,e)},[d,n]);let m=(0,S.useRef)(n);m.current=n,(0,S.useEffect)(()=>()=>{m.current.dispose(),t.current=null},[]);let h=(0,S.useMemo)(()=>({router:n,extensions:u,loading:i}),[n,u,i]);return(0,W.jsx)(G.Provider,{value:h,children:e})}function q(){let e=(0,S.useContext)(G);if(!e)throw Error(`useExtensionRouter must be used within ExtensionProvider`);return e.router}function J(){let e=(0,S.useContext)(G);if(!e)throw Error(`useExtensions must be used within ExtensionProvider`);return e.extensions}function Y(){let e=(0,C.c)(2),t=J(),n;return e[0]===t?n=e[1]:(n=t.filter(H),e[0]=t,e[1]=n),n}function X(){let e=(0,S.useContext)(G);if(!e)throw Error(`useExtensionsLoading must be used within ExtensionProvider`);return e.loading}export{Y as a,P as c,A as d,X as i,M as l,q as n,V as o,J as r,U as s,K as t,w as u};
@@ -1 +1 @@
1
- import{i as e}from"./rolldown-runtime-aKtaBQYM.js";import{a as t,n,t as r}from"./vendor-react-BOUWij0V.js";import{f as i,t as a}from"./chunk-KS7C4IRE-CiwuuyV8.js";import{a as o,i as s,l as c,n as l,o as u}from"./locale-store-_-_QzAV0.js";import{t as d}from"./messages-D1u8VsPq.js";import{t as f}from"./resource-unavailable-CqP8gARc.js";import{n as p,r as m}from"./popover-select-DD8fmrxH.js";import{t as h}from"./cn-0WouolD0.js";import{i as g}from"./vendor-swr-CdRzEUwF.js";import{t as _}from"./button-CnRSIP6m.js";import{r as v}from"./extension-provider-8RM98QmD.js";import{a as y,o as b,s as x}from"./form-field-width-DJw_jULe.js";import{t as S}from"./extension-iframe-host-D4w7-mf1.js";import{t as C}from"./settings-loading-skeleton-BTqvr_Fw.js";import{n as w,t as T}from"./settings-page-header-CoPd_JDb.js";import"./settings-page-layout-D39EvFvm.js";import{n as E,t as D}from"./use-autosave-BqTpwsvF.js";import{a as O,c as k,o as A}from"./voice-config-api-CIRG9O8T.js";import{t as j}from"./voice-api-key-field-DGyL8PYB.js";import{t as M}from"./schema-form-BKeP5G7b.js";var N=e(t(),1),P=n(),F=r();function I(e){let t=(0,P.c)(2),{children:n}=e,r;return t[0]===n?r=t[1]:(r=(0,F.jsx)(`div`,{className:`text-sm font-medium text-fg`,children:n}),t[0]=n,t[1]=r),r}function L(e){let t=e?.manifest?.mediaUnderstandingProviders?.[0];if(typeof t==`string`&&t.trim())return t.trim();let n=e?.manifest?.contracts?.mediaUnderstandingProviders?.[0];if(typeof n==`string`&&n.trim())return n.trim()}function R(){return h(b,y)}function z(){return h(`w-full rounded-lg border border-edge bg-surface-panel px-3 py-2 text-sm text-fg`,`placeholder:text-fg-subtle`,x,`dark:border-edge`)}function B(e,t,n){if(!e||!t)return{apiKey:``,model:n};let r=e.stt.providers?.[t];return{apiKey:typeof r?.apiKey==`string`?r.apiKey:``,model:typeof r?.model==`string`?r.model:n}}function V({providerId:e,voiceSettings:t,mutateVoice:n}){let r=d(l(e=>e.language)),i=r.voiceSettings,a=r.extensionSttMedia,o={maskedHelp:i.apiKeyMaskedHelp,copy:i.apiKeyCopy,copied:i.apiKeyCopied,show:i.apiKeyShow,hide:i.apiKeyHide,notInConfigFile:i.apiKeyNotInConfigFile,loadFailed:i.apiKeyRevealFailed},{data:c}=g(s(`/api/voice/stt-providers`),A,{revalidateOnFocus:!1}),u=(0,N.useMemo)(()=>c?.providers.find(t=>t.id===e),[e,c]),f=u?.configured??!1,_=u?.models??[],v=_[0]?.id??u?.fields.find(e=>e.key===`model`)?.defaultValue??``,b=(0,N.useMemo)(()=>B(t,e,v),[v,e,t]),x=(0,N.useRef)(!1),[S,C]=(0,N.useState)(null),w=S??b,T=(0,N.useRef)(w);T.current=w;let O=b,M=D({value:w,dirty:w.apiKey!==O.apiKey||w.model!==O.model,onSave:(0,N.useCallback)(async r=>{let i=structuredClone(t);i.stt.enabled=!0,i.stt.provider=e,i.stt.providers={...i.stt.providers??{},[e]:{...i.stt.providers?.[e]??{},apiKey:r.apiKey,model:r.model}},await k(i,`transcription`),await n(i,!1),x.current=JSON.stringify(T.current)!==JSON.stringify(r),C(e=>e&&JSON.stringify(e)===JSON.stringify(r)?null:e)},[n,e,t])}),P=_.length>0?_:w.model?[{id:w.model,name:w.model}]:[];return(0,F.jsxs)(`div`,{className:`flex flex-col gap-4 rounded-xl bg-surface-base p-4`,onBlurCapture:M.onBlurCapture,children:[(0,F.jsxs)(`div`,{className:`flex flex-wrap items-center justify-between gap-2`,children:[(0,F.jsxs)(`div`,{children:[(0,F.jsx)(`h2`,{className:`text-sm font-semibold text-fg`,children:a.credentialsTitle}),(0,F.jsx)(`p`,{className:`mt-1 text-xs text-fg-muted`,children:a.credentialsHint.replace(`{providerId}`,e)})]}),(0,F.jsxs)(`div`,{className:`flex flex-wrap items-center gap-2`,children:[(0,F.jsx)(E,{status:M.status,error:M.error}),(0,F.jsx)(`span`,{className:h(`rounded-full px-2 py-0.5 text-xs font-medium`,f?`bg-emerald-500/10 text-emerald-700 dark:text-emerald-300`:`bg-amber-500/10 text-amber-800 dark:text-amber-200`),children:f?a.configured:a.notConfigured})]})]}),(0,F.jsxs)(`div`,{className:`grid gap-3 sm:grid-cols-2`,children:[(0,F.jsxs)(`div`,{className:h(`flex flex-col gap-1.5`,y),children:[(0,F.jsx)(I,{children:i.stt.apiKey}),(0,F.jsx)(j,{kind:`stt`,providerId:e,fieldId:`ext-stt-${e}-api-key`,value:w.apiKey,onChange:e=>{x.current=!0,C(t=>({...t??b,apiKey:e}))},labels:o,placeholder:e===`groq`?`gsk_...`:`sk-...`}),(0,F.jsxs)(`p`,{className:`text-xs text-fg-subtle`,children:[i.stt.apiKeyDesc,e===`groq`?` (GROQ_API_KEY)`:``]})]}),(0,F.jsxs)(`div`,{className:h(`flex flex-col gap-1.5`,y),children:[(0,F.jsx)(I,{children:i.stt.model}),P.length>0?(0,F.jsx)(p,{className:R(),value:w.model,onChange:e=>{x.current=!0,C(t=>({...t??b,model:e.target.value})),M.saveNow({...w,model:e.target.value})},children:P.map(e=>(0,F.jsx)(m,{value:e.id,children:e.name},e.id))}):(0,F.jsx)(`input`,{className:z(),value:w.model,onChange:e=>{x.current=!0,C(t=>({...t??b,model:e.target.value}))}})]})]})]})}function H(e){let t=(0,P.c)(13),{extensionId:n}=e,r=l(W),i=c(U),a;t[0]===n?a=t[1]:(a=()=>u(s(`/api/extensions/${encodeURIComponent(n)}`)),t[0]=n,t[1]=a);let{data:o,isLoading:d}=g(i&&n?`ext-stt-detail-${n}`:null,a),f;t[2]===o?f=t[3]:(f=L(o),t[2]=o,t[3]=f);let p=f,m;t[4]===Symbol.for(`react.memo_cache_sentinel`)?(m={revalidateOnFocus:!1},t[4]=m):m=t[4];let{data:h,mutate:_,isLoading:v}=g(i?`voice-settings-ext-stt`:null,O,m);if(!i)return null;if(d||v){let e;return t[5]===Symbol.for(`react.memo_cache_sentinel`)?(e=(0,F.jsx)(C,{rows:2}),t[5]=e):e=t[5],e}if(!p){let e=r===`zh`?`该插件未声明 mediaUnderstandingProviders。`:`This plugin does not declare mediaUnderstandingProviders.`,n;return t[6]===e?n=t[7]:(n=(0,F.jsx)(`p`,{className:`text-sm text-fg-muted`,children:e}),t[6]=e,t[7]=n),n}if(!h)return null;let y=`${n}:${p}`,b;return t[8]!==_||t[9]!==p||t[10]!==y||t[11]!==h?(b=(0,F.jsx)(V,{providerId:p,voiceSettings:h,mutateVoice:_},y),t[8]=_,t[9]=p,t[10]=y,t[11]=h,t[12]=b):b=t[12],b}function U(e){return!!e.conversationId}function W(e){return e.language}function G(e){return typeof e==`object`&&!!e&&!Array.isArray(e)}function K(e){let t={};if(e.type!==`object`||!G(e.properties))return t;for(let[n,r]of Object.entries(e.properties))G(r)&&Object.prototype.hasOwnProperty.call(r,`default`)&&(t[n]=r.default);return t}function q(e,t){switch(t.type){case`sync`:return{localValues:t.value,isDirty:!1};case`change`:return{localValues:t.value,isDirty:!0};case`reset-defaults`:return{localValues:t.value,isDirty:!0};case`saved`:return JSON.stringify(e.localValues)===JSON.stringify(t.value)?{localValues:e.localValues,isDirty:!1}:e}}function J({extensionId:e}){let t=c(e=>!!e.conversationId),{data:n,error:r}=g(t&&e?`ext-detail-${e}`:null,()=>u(s(`/api/extensions/${encodeURIComponent(e)}`))),{data:i,mutate:a,error:l}=g(t&&e?`ext-cfg-${e}`:null,()=>u(s(`/api/extensions/${encodeURIComponent(e)}/config`))),d=n?.manifest?.configSchema,f=(0,N.useMemo)(()=>d&&d.type===`object`?K(d):{},[d]),p=(0,N.useMemo)(()=>({...f,...i??{}}),[f,i]),[m,h]=(0,N.useReducer)(q,{localValues:{},isDirty:!1}),v=(0,N.useRef)(!1),y=(0,N.useRef)(m.localValues);y.current=m.localValues;let b=(0,N.useRef)(p);!v.current&&b.current!==p&&(b.current=p,h({type:`sync`,value:p}));let x=(0,N.useCallback)(e=>{v.current=!0,h({type:`change`,value:e})},[]),S=(0,N.useCallback)(()=>{!d||d.type!==`object`||(v.current=!0,h({type:`reset-defaults`,value:{...K(d)}}))},[d]),C=(0,N.useCallback)(async t=>{if(!e)return;let n=await o(s(`/api/extensions/${encodeURIComponent(e)}/config`),{method:`PATCH`,body:JSON.stringify(t)});if(!n.ok){let e=await n.json().catch(()=>({}));throw Error(e.error?.message??n.statusText)}await a(t,!1),h({type:`saved`,value:t}),v.current=JSON.stringify(y.current)!==JSON.stringify(t)},[e,a]),w=D({value:m.localValues,dirty:m.isDirty,onSave:C});if(!t)return null;if(r||l){let e=r??l;return(0,F.jsxs)(`p`,{className:`text-sm text-fg-muted`,children:[`Could not load extension settings: `,e instanceof Error?e.message:String(e)]})}return!d||d.type!==`object`?null:(0,F.jsxs)(`div`,{className:`flex flex-col gap-3 rounded-xl bg-surface-hover/20 p-4`,onBlurCapture:w.onBlurCapture,children:[(0,F.jsxs)(`div`,{className:`flex flex-wrap items-center justify-between gap-2`,children:[(0,F.jsx)(`h2`,{className:`text-sm font-semibold text-fg`,children:`Configuration`}),(0,F.jsxs)(`div`,{className:`flex flex-wrap items-center gap-2`,children:[(0,F.jsx)(E,{status:w.status,error:w.error}),(0,F.jsx)(_,{type:`button`,variant:`ghost`,className:`h-8 text-xs`,onClick:S,children:`Reset to defaults`})]})]}),(0,F.jsx)(M,{schema:d,values:m.localValues,onChange:x})]})}function Y(){let e=(0,P.c)(36),t=l(X),n;e[0]===t?n=e[1]:(n=d(t),e[0]=t,e[1]=n);let r=n.extensionSttMedia,{extensionId:o,panelId:s}=i(),c=v();if(!o){let t;return e[2]===Symbol.for(`react.memo_cache_sentinel`)?(t=(0,F.jsx)(f,{kind:`plugin`,backTo:`/capabilities/extensions`}),e[2]=t):t=e[2],t}let u,p,m;if(e[3]!==o||e[4]!==c||e[5]!==s){m=Symbol.for(`react.early_return_sentinel`);bb0:{let t;if(e[9]===o?t=e[10]:(t=e=>e.id===o,e[9]=o,e[10]=t),u=c.find(t),!u){let t;e[11]===Symbol.for(`react.memo_cache_sentinel`)?(t=(0,F.jsx)(f,{kind:`plugin`,backTo:`/capabilities/extensions`}),e[11]=t):t=e[11],m=t;break bb0}let n=u.ui?.contributions?.settingsPanels;p=s?n?.find(e=>e.id===s||e.id===`${o}.${s}`):n?.[0]}e[3]=o,e[4]=c,e[5]=s,e[6]=u,e[7]=p,e[8]=m}else u=e[6],p=e[7],m=e[8];if(m!==Symbol.for(`react.early_return_sentinel`))return m;let h=p,g=!!(h&&u.ui),_=!!u.hasConfigSchema,y=u.kind===`media-provider`;if(!_&&!g&&!y){let t;return e[12]===Symbol.for(`react.memo_cache_sentinel`)?(t=(0,F.jsx)(f,{kind:`plugin-settings`,backTo:`/capabilities/extensions`}),e[12]=t):t=e[12],t}let b=h?.title??(t===`zh`?`${u.name} 设置`:`${u.name} Settings`),x;e[13]===b?x=e[14]:(x=(0,F.jsx)(T,{title:b}),e[13]=b,e[14]=x);let C;e[15]!==y||e[16]!==r?(C=y?(0,F.jsxs)(`div`,{className:`flex flex-col gap-2 rounded-lg bg-surface-base px-4 py-3 text-sm`,children:[(0,F.jsx)(`p`,{className:`leading-relaxed text-fg-muted`,children:r.banner}),(0,F.jsx)(a,{to:`/settings/capabilities/models?configure=transcription`,className:`w-fit font-medium text-accent hover:underline`,children:r.openVoice})]}):null,e[15]=y,e[16]=r,e[17]=C):C=e[17];let E;e[18]!==o||e[19]!==y?(E=y?(0,F.jsx)(H,{extensionId:o}):null,e[18]=o,e[19]=y,e[20]=E):E=e[20];let D;e[21]!==o||e[22]!==_?(D=_?(0,F.jsx)(J,{extensionId:o}):null,e[21]=o,e[22]=_,e[23]=D):D=e[23];let O;e[24]!==u.name||e[25]!==u.ui||e[26]!==o||e[27]!==g||e[28]!==h?(O=g&&h&&u.ui?(0,F.jsx)(`div`,{className:`overflow-hidden rounded-xl bg-surface-base shadow-surface`,children:(0,F.jsx)(S,{extensionId:o,extensionName:u.name,entrypoint:h.entrypoint,permissions:u.ui?.permissions,title:h.title,className:`w-full`,minHeight:120,maxHeight:2e3})}):null,e[24]=u.name,e[25]=u.ui,e[26]=o,e[27]=g,e[28]=h,e[29]=O):O=e[29];let k;return e[30]!==x||e[31]!==C||e[32]!==E||e[33]!==D||e[34]!==O?(k=(0,F.jsxs)(w,{gap:`gap-5`,children:[x,C,E,D,O]}),e[30]=x,e[31]=C,e[32]=E,e[33]=D,e[34]=O,e[35]=k):k=e[35],k}function X(e){return e.language}export{Y as ExtensionSettingsPage};
1
+ import{i as e}from"./rolldown-runtime-aKtaBQYM.js";import{a as t,n,t as r}from"./vendor-react-BOUWij0V.js";import{f as i,t as a}from"./chunk-KS7C4IRE-CiwuuyV8.js";import{a as o,i as s,l as c,n as l,o as u}from"./locale-store-TQcz_Vjt.js";import{t as d}from"./messages-DaLmc4W1.js";import{t as f}from"./resource-unavailable-X-SIrZYI.js";import{n as p,r as m}from"./popover-select-DD8fmrxH.js";import{t as h}from"./cn-0WouolD0.js";import{t as g}from"./button-CnRSIP6m.js";import{i as _}from"./vendor-swr-CdRzEUwF.js";import{r as v}from"./extension-provider-BZwcaU5Y.js";import{a as y,o as b,s as x}from"./form-field-width-DJw_jULe.js";import{t as S}from"./extension-iframe-host-B4Q1CjvW.js";import{t as C}from"./settings-loading-skeleton-BTqvr_Fw.js";import{n as w,t as T}from"./settings-page-header-DuNCn8i-.js";import"./settings-page-layout-DeNC8YHJ.js";import{n as E,t as D}from"./use-autosave-itwjDYUb.js";import{a as O,c as k,o as A}from"./voice-config-api-J4o59ICE.js";import{t as j}from"./voice-api-key-field-BIfBySnN.js";import{t as M}from"./schema-form-BKeP5G7b.js";var N=e(t(),1),P=n(),F=r();function I(e){let t=(0,P.c)(2),{children:n}=e,r;return t[0]===n?r=t[1]:(r=(0,F.jsx)(`div`,{className:`text-sm font-medium text-fg`,children:n}),t[0]=n,t[1]=r),r}function L(e){let t=e?.manifest?.mediaUnderstandingProviders?.[0];if(typeof t==`string`&&t.trim())return t.trim();let n=e?.manifest?.contracts?.mediaUnderstandingProviders?.[0];if(typeof n==`string`&&n.trim())return n.trim()}function R(){return h(b,y)}function z(){return h(`w-full rounded-lg border border-edge bg-surface-panel px-3 py-2 text-sm text-fg`,`placeholder:text-fg-subtle`,x,`dark:border-edge`)}function B(e,t,n){if(!e||!t)return{apiKey:``,model:n};let r=e.stt.providers?.[t];return{apiKey:typeof r?.apiKey==`string`?r.apiKey:``,model:typeof r?.model==`string`?r.model:n}}function V({providerId:e,voiceSettings:t,mutateVoice:n}){let r=d(l(e=>e.language)),i=r.voiceSettings,a=r.extensionSttMedia,o={maskedHelp:i.apiKeyMaskedHelp,copy:i.apiKeyCopy,copied:i.apiKeyCopied,show:i.apiKeyShow,hide:i.apiKeyHide,notInConfigFile:i.apiKeyNotInConfigFile,loadFailed:i.apiKeyRevealFailed},{data:c}=_(s(`/api/voice/stt-providers`),A,{revalidateOnFocus:!1}),u=(0,N.useMemo)(()=>c?.providers.find(t=>t.id===e),[e,c]),f=u?.configured??!1,g=u?.models??[],v=g[0]?.id??u?.fields.find(e=>e.key===`model`)?.defaultValue??``,b=(0,N.useMemo)(()=>B(t,e,v),[v,e,t]),x=(0,N.useRef)(!1),[S,C]=(0,N.useState)(null),w=S??b,T=(0,N.useRef)(w);T.current=w;let O=b,M=D({value:w,dirty:w.apiKey!==O.apiKey||w.model!==O.model,onSave:(0,N.useCallback)(async r=>{let i=structuredClone(t);i.stt.enabled=!0,i.stt.provider=e,i.stt.providers={...i.stt.providers??{},[e]:{...i.stt.providers?.[e]??{},apiKey:r.apiKey,model:r.model}},await k(i,`transcription`),await n(i,!1),x.current=JSON.stringify(T.current)!==JSON.stringify(r),C(e=>e&&JSON.stringify(e)===JSON.stringify(r)?null:e)},[n,e,t])}),P=g.length>0?g:w.model?[{id:w.model,name:w.model}]:[];return(0,F.jsxs)(`div`,{className:`flex flex-col gap-4 rounded-xl bg-surface-base p-4`,onBlurCapture:M.onBlurCapture,children:[(0,F.jsxs)(`div`,{className:`flex flex-wrap items-center justify-between gap-2`,children:[(0,F.jsxs)(`div`,{children:[(0,F.jsx)(`h2`,{className:`text-sm font-semibold text-fg`,children:a.credentialsTitle}),(0,F.jsx)(`p`,{className:`mt-1 text-xs text-fg-muted`,children:a.credentialsHint.replace(`{providerId}`,e)})]}),(0,F.jsxs)(`div`,{className:`flex flex-wrap items-center gap-2`,children:[(0,F.jsx)(E,{status:M.status,error:M.error}),(0,F.jsx)(`span`,{className:h(`rounded-full px-2 py-0.5 text-xs font-medium`,f?`bg-emerald-500/10 text-emerald-700 dark:text-emerald-300`:`bg-amber-500/10 text-amber-800 dark:text-amber-200`),children:f?a.configured:a.notConfigured})]})]}),(0,F.jsxs)(`div`,{className:`grid gap-3 sm:grid-cols-2`,children:[(0,F.jsxs)(`div`,{className:h(`flex flex-col gap-1.5`,y),children:[(0,F.jsx)(I,{children:i.stt.apiKey}),(0,F.jsx)(j,{kind:`stt`,providerId:e,fieldId:`ext-stt-${e}-api-key`,value:w.apiKey,onChange:e=>{x.current=!0,C(t=>({...t??b,apiKey:e}))},labels:o,placeholder:e===`groq`?`gsk_...`:`sk-...`}),(0,F.jsxs)(`p`,{className:`text-xs text-fg-subtle`,children:[i.stt.apiKeyDesc,e===`groq`?` (GROQ_API_KEY)`:``]})]}),(0,F.jsxs)(`div`,{className:h(`flex flex-col gap-1.5`,y),children:[(0,F.jsx)(I,{children:i.stt.model}),P.length>0?(0,F.jsx)(p,{className:R(),value:w.model,onChange:e=>{x.current=!0,C(t=>({...t??b,model:e.target.value})),M.saveNow({...w,model:e.target.value})},children:P.map(e=>(0,F.jsx)(m,{value:e.id,children:e.name},e.id))}):(0,F.jsx)(`input`,{className:z(),value:w.model,onChange:e=>{x.current=!0,C(t=>({...t??b,model:e.target.value}))}})]})]})]})}function H(e){let t=(0,P.c)(13),{extensionId:n}=e,r=l(W),i=c(U),a;t[0]===n?a=t[1]:(a=()=>u(s(`/api/extensions/${encodeURIComponent(n)}`)),t[0]=n,t[1]=a);let{data:o,isLoading:d}=_(i&&n?`ext-stt-detail-${n}`:null,a),f;t[2]===o?f=t[3]:(f=L(o),t[2]=o,t[3]=f);let p=f,m;t[4]===Symbol.for(`react.memo_cache_sentinel`)?(m={revalidateOnFocus:!1},t[4]=m):m=t[4];let{data:h,mutate:g,isLoading:v}=_(i?`voice-settings-ext-stt`:null,O,m);if(!i)return null;if(d||v){let e;return t[5]===Symbol.for(`react.memo_cache_sentinel`)?(e=(0,F.jsx)(C,{rows:2}),t[5]=e):e=t[5],e}if(!p){let e=r===`zh`?`该插件未声明 mediaUnderstandingProviders。`:`This plugin does not declare mediaUnderstandingProviders.`,n;return t[6]===e?n=t[7]:(n=(0,F.jsx)(`p`,{className:`text-sm text-fg-muted`,children:e}),t[6]=e,t[7]=n),n}if(!h)return null;let y=`${n}:${p}`,b;return t[8]!==g||t[9]!==p||t[10]!==y||t[11]!==h?(b=(0,F.jsx)(V,{providerId:p,voiceSettings:h,mutateVoice:g},y),t[8]=g,t[9]=p,t[10]=y,t[11]=h,t[12]=b):b=t[12],b}function U(e){return!!e.conversationId}function W(e){return e.language}function G(e){return typeof e==`object`&&!!e&&!Array.isArray(e)}function K(e){let t={};if(e.type!==`object`||!G(e.properties))return t;for(let[n,r]of Object.entries(e.properties))G(r)&&Object.prototype.hasOwnProperty.call(r,`default`)&&(t[n]=r.default);return t}function q(e,t){switch(t.type){case`sync`:return{localValues:t.value,isDirty:!1};case`change`:return{localValues:t.value,isDirty:!0};case`reset-defaults`:return{localValues:t.value,isDirty:!0};case`saved`:return JSON.stringify(e.localValues)===JSON.stringify(t.value)?{localValues:e.localValues,isDirty:!1}:e}}function J({extensionId:e}){let t=c(e=>!!e.conversationId),{data:n,error:r}=_(t&&e?`ext-detail-${e}`:null,()=>u(s(`/api/extensions/${encodeURIComponent(e)}`))),{data:i,mutate:a,error:l}=_(t&&e?`ext-cfg-${e}`:null,()=>u(s(`/api/extensions/${encodeURIComponent(e)}/config`))),d=n?.manifest?.configSchema,f=(0,N.useMemo)(()=>d&&d.type===`object`?K(d):{},[d]),p=(0,N.useMemo)(()=>({...f,...i??{}}),[f,i]),[m,h]=(0,N.useReducer)(q,{localValues:{},isDirty:!1}),v=(0,N.useRef)(!1),y=(0,N.useRef)(m.localValues);y.current=m.localValues;let b=(0,N.useRef)(p);!v.current&&b.current!==p&&(b.current=p,h({type:`sync`,value:p}));let x=(0,N.useCallback)(e=>{v.current=!0,h({type:`change`,value:e})},[]),S=(0,N.useCallback)(()=>{!d||d.type!==`object`||(v.current=!0,h({type:`reset-defaults`,value:{...K(d)}}))},[d]),C=(0,N.useCallback)(async t=>{if(!e)return;let n=await o(s(`/api/extensions/${encodeURIComponent(e)}/config`),{method:`PATCH`,body:JSON.stringify(t)});if(!n.ok){let e=await n.json().catch(()=>({}));throw Error(e.error?.message??n.statusText)}await a(t,!1),h({type:`saved`,value:t}),v.current=JSON.stringify(y.current)!==JSON.stringify(t)},[e,a]),w=D({value:m.localValues,dirty:m.isDirty,onSave:C});if(!t)return null;if(r||l){let e=r??l;return(0,F.jsxs)(`p`,{className:`text-sm text-fg-muted`,children:[`Could not load extension settings: `,e instanceof Error?e.message:String(e)]})}return!d||d.type!==`object`?null:(0,F.jsxs)(`div`,{className:`flex flex-col gap-3 rounded-xl bg-surface-hover/20 p-4`,onBlurCapture:w.onBlurCapture,children:[(0,F.jsxs)(`div`,{className:`flex flex-wrap items-center justify-between gap-2`,children:[(0,F.jsx)(`h2`,{className:`text-sm font-semibold text-fg`,children:`Configuration`}),(0,F.jsxs)(`div`,{className:`flex flex-wrap items-center gap-2`,children:[(0,F.jsx)(E,{status:w.status,error:w.error}),(0,F.jsx)(g,{type:`button`,variant:`ghost`,className:`h-8 text-xs`,onClick:S,children:`Reset to defaults`})]})]}),(0,F.jsx)(M,{schema:d,values:m.localValues,onChange:x})]})}function Y(){let e=(0,P.c)(36),t=l(X),n;e[0]===t?n=e[1]:(n=d(t),e[0]=t,e[1]=n);let r=n.extensionSttMedia,{extensionId:o,panelId:s}=i(),c=v();if(!o){let t;return e[2]===Symbol.for(`react.memo_cache_sentinel`)?(t=(0,F.jsx)(f,{kind:`plugin`,backTo:`/capabilities/extensions`}),e[2]=t):t=e[2],t}let u,p,m;if(e[3]!==o||e[4]!==c||e[5]!==s){m=Symbol.for(`react.early_return_sentinel`);bb0:{let t;if(e[9]===o?t=e[10]:(t=e=>e.id===o,e[9]=o,e[10]=t),u=c.find(t),!u){let t;e[11]===Symbol.for(`react.memo_cache_sentinel`)?(t=(0,F.jsx)(f,{kind:`plugin`,backTo:`/capabilities/extensions`}),e[11]=t):t=e[11],m=t;break bb0}let n=u.ui?.contributions?.settingsPanels;p=s?n?.find(e=>e.id===s||e.id===`${o}.${s}`):n?.[0]}e[3]=o,e[4]=c,e[5]=s,e[6]=u,e[7]=p,e[8]=m}else u=e[6],p=e[7],m=e[8];if(m!==Symbol.for(`react.early_return_sentinel`))return m;let h=p,g=!!(h&&u.ui),_=!!u.hasConfigSchema,y=u.kind===`media-provider`;if(!_&&!g&&!y){let t;return e[12]===Symbol.for(`react.memo_cache_sentinel`)?(t=(0,F.jsx)(f,{kind:`plugin-settings`,backTo:`/capabilities/extensions`}),e[12]=t):t=e[12],t}let b=h?.title??(t===`zh`?`${u.name} 设置`:`${u.name} Settings`),x;e[13]===b?x=e[14]:(x=(0,F.jsx)(T,{title:b}),e[13]=b,e[14]=x);let C;e[15]!==y||e[16]!==r?(C=y?(0,F.jsxs)(`div`,{className:`flex flex-col gap-2 rounded-lg bg-surface-base px-4 py-3 text-sm`,children:[(0,F.jsx)(`p`,{className:`leading-relaxed text-fg-muted`,children:r.banner}),(0,F.jsx)(a,{to:`/settings/capabilities/models?configure=transcription`,className:`w-fit font-medium text-accent hover:underline`,children:r.openVoice})]}):null,e[15]=y,e[16]=r,e[17]=C):C=e[17];let E;e[18]!==o||e[19]!==y?(E=y?(0,F.jsx)(H,{extensionId:o}):null,e[18]=o,e[19]=y,e[20]=E):E=e[20];let D;e[21]!==o||e[22]!==_?(D=_?(0,F.jsx)(J,{extensionId:o}):null,e[21]=o,e[22]=_,e[23]=D):D=e[23];let O;e[24]!==u.name||e[25]!==u.ui||e[26]!==o||e[27]!==g||e[28]!==h?(O=g&&h&&u.ui?(0,F.jsx)(`div`,{className:`overflow-hidden rounded-xl bg-surface-base shadow-surface`,children:(0,F.jsx)(S,{extensionId:o,extensionName:u.name,entrypoint:h.entrypoint,permissions:u.ui?.permissions,title:h.title,className:`w-full`,minHeight:120,maxHeight:2e3})}):null,e[24]=u.name,e[25]=u.ui,e[26]=o,e[27]=g,e[28]=h,e[29]=O):O=e[29];let k;return e[30]!==x||e[31]!==C||e[32]!==E||e[33]!==D||e[34]!==O?(k=(0,F.jsxs)(w,{gap:`gap-5`,children:[x,C,E,D,O]}),e[30]=x,e[31]=C,e[32]=E,e[33]=D,e[34]=O,e[35]=k):k=e[35],k}function X(e){return e.language}export{Y as ExtensionSettingsPage};
@@ -1 +1 @@
1
- import{i as e}from"./rolldown-runtime-aKtaBQYM.js";import{a as t,i as n,t as r}from"./vendor-react-BOUWij0V.js";import{l as i,p as a}from"./locale-store-_-_QzAV0.js";import{t as o}from"./cn-0WouolD0.js";import{t as s}from"./phone-workspace-store-Ci43KRd6.js";import{n as c}from"./electron-env-DHOGevH3.js";import{a as l}from"./shares-api-DbJOyf2K.js";var u=`xopc:right-workspace:v1`,d={open:!1,tabs:[],activeId:null},f={panes:{},width:0,treeWidth:240,fileTreeOpen:!0,sideTreeOpen:!1};function p(){try{let e=JSON.parse(sessionStorage.getItem(u)||`null`);if(!e||e.version!==1||typeof e.panes!=`object`||!e.panes||e.identity!==i.getState().conversationId||e.gateway!==i.getState().baseUrl)return f;let t={};for(let[n,r]of Object.entries(e.panes)){let e=r;if(!e||!Array.isArray(e.tabs))continue;let i=e.tabs.filter(e=>e&&typeof e.id==`string`&&typeof e.title==`string`&&(e.kind===`file`&&typeof e.path==`string`||e.kind===`sidechat`&&typeof e.sideChatId==`string`||e.kind===`home`||e.kind===`files`));t[n]={open:e.open===!0&&i.length>0,tabs:i,activeId:i.some(t=>t.id===e.activeId)?e.activeId:i[0]?.id??null}}return{...f,panes:t}}catch{return f}}function m(e,t){try{let n=Number(localStorage.getItem(e));return n>0&&Number.isFinite(n)?n:t}catch{return t}}function h(e){try{let t=Object.fromEntries(Object.entries(e.panes).map(([e,t])=>[e,{...t,tabs:t.tabs.filter(e=>e.kind!==`browser`&&(e.kind!==`file`||!e.attachment)).map(e=>({...e}))}]));sessionStorage.setItem(u,JSON.stringify({version:1,identity:i.getState().conversationId,gateway:i.getState().baseUrl,panes:t}))}catch{}}var g=new WeakMap;function _(e){return e?e.id||e.uri?e.id||e.uri:(g.has(e)||g.set(e,crypto.randomUUID()),g.get(e)):``}function v(e){return e.replace(/\\/g,`/`).split(`/`).filter(e=>e!==`.`).join(`/`)}function y(e){let t=e.projectId?`project:${e.projectId}`:e.conversationId?`session:${e.conversationId}`:`agent:${e.agentId??``}`;return JSON.stringify([t,e.path?v(e.path):_(e.attachment)])}var b=a((e,t)=>{let n=(n,r)=>{e(e=>({panes:{...e.panes,[n]:r(e.panes[n]??d)}})),h(t())};return{...p(),width:m(`xopc:workspace-width`,0),treeWidth:m(`xopc:workspace-tree-width`,240),notices:{},setNotice:(t,n)=>e(e=>({notices:{...e.notices,[t]:n}})),fileStatus:{},setFileStatus:(n,r)=>{r&&t().keepFileOpen(n),e(e=>({fileStatus:{...e.fileStatus,[n]:r??``}}))},keepFileOpen:e=>{for(let[r,i]of Object.entries(t().panes))i.tabs.some(t=>t.id===e&&t.kind===`file`&&t.preview)&&n(r,t=>({...t,tabs:t.tabs.map(t=>t.id===e?{...t,preview:!1}:t)}))},scope:`new`,setScope:t=>e({scope:t}),migrateScope:(n,r)=>{let i=t().panes[n];if(!i||n===r)return;let a=t().panes[r]??d,o={...t().panes,[r]:{open:i.open||a.open,tabs:[...a.tabs,...i.tabs.filter(e=>!a.tabs.some(t=>t.id===e.id))],activeId:i.activeId??a.activeId}};delete o[n],e({panes:o,scope:t().scope===n?r:t().scope}),h(t())},openPhone:(e,t,r,i=!0,a=!0)=>{let o=`phone:${e}`;n(r,n=>({open:i||n.open,activeId:i?o:n.activeId,tabs:n.tabs.some(e=>e.id===o)?n.tabs.map(e=>e.id===o?{...e,title:t}:e):[...n.tabs,{id:o,kind:`phone`,phoneSessionId:e,title:t,visitedAt:Date.now()}]})),a&&s.getState().show(e,i,/^[\da-f]{8}-[\da-f-]{27}$/i.test(r)?r:void 0)},openTools:(e=t().scope)=>{let r=crypto.randomUUID();return n(e,e=>{let t=[...e.tabs];return t.splice(Math.max(0,t.findIndex(t=>t.id===e.activeId)+1),0,{id:r,kind:`home`,title:`New tab`,visitedAt:Date.now()}),{open:!0,tabs:t,activeId:r}}),r},openBrowser:(e,r=t().scope,i)=>{let a=t().panes[r]??d,o=a.tabs.find(e=>e.id===a.activeId&&e.kind===`home`)?.id??crypto.randomUUID(),s={id:o,kind:`browser`,title:`Browser`,initialUrl:e,visitedAt:Date.now(),returnTo:i??a.activeId??void 0};return n(r,e=>{let t=[...e.tabs],n=t.findIndex(e=>e.id===o);return n>=0?t[n]=s:t.splice(Math.max(0,t.findIndex(t=>t.id===e.activeId)+1),0,s),{open:!0,activeId:o,tabs:t}}),o},updateBrowserTitle:(e,r)=>{for(let[i,a]of Object.entries(t().panes))a.tabs.some(t=>t.id===e&&t.kind===`browser`&&t.title!==r)&&n(i,t=>({...t,tabs:t.tabs.map(t=>t.id===e?{...t,title:r.slice(0,200)}:t)}))},openFiles:(e=t().scope)=>{let r=t().panes[e]??d,i=r.tabs.find(e=>e.kind===`files`);if(i){t().activate(i.id,e);return}let a=r.tabs.find(e=>e.id===r.activeId&&e.kind===`home`),o=a?.id??crypto.randomUUID();n(e,e=>({open:!0,activeId:o,tabs:a?e.tabs.map(e=>e.id===o?{...e,kind:`files`,title:`Files`}:e):[...e.tabs,{id:o,kind:`files`,title:`Files`,visitedAt:Date.now()}]}))},setOpen:(e,r=t().scope)=>{if(e&&!t().panes[r]?.tabs.length){t().openTools(r);return}n(r,t=>({...t,open:e,activeId:t.activeId??t.tabs[0]?.id??null}))},activate:(e,r=t().scope)=>{let i=t().panes[r]?.tabs.find(t=>t.id===e);i?.kind===`phone`&&(s.getState().setDisplayMode(`docked`),s.getState().show(i.phoneSessionId,!0,/^[\da-f]{8}-[\da-f-]{27}$/i.test(r)?r:void 0)),n(r,t=>({...t,open:!!(e&&t.tabs.some(t=>t.id===e)),activeId:e&&t.tabs.some(t=>t.id===e)?e:t.activeId,tabs:t.tabs.map(t=>t.id===e?{...t,visitedAt:Date.now()}:t)}))},openFile:(e,r=t().scope)=>{let i=t().panes[r]??d,a=i.tabs.find(t=>t.kind===`file`&&(y(t)===y(e)||t.aliases?.includes(y(e)))),o=!a&&e.preview!==!1?i.tabs.find(e=>e.kind===`file`&&e.preview&&!t().fileStatus[e.id]):void 0,s=a?.id??crypto.randomUUID(),c={...a?.kind===`file`?a:{},...e,preview:a?.kind===`file`?a.preview===!0:e.preview!==!1,id:s,kind:`file`,title:e.path?.replace(/\\/g,`/`).split(`/`).pop()||e.attachment?.name||`File`,visitedAt:Date.now(),returnTo:a?.returnTo??(o?o.returnTo:i.activeId??void 0)};return n(r,e=>{let t=[...e.tabs],n=t.findIndex(e=>e.id===s);return n>=0?t[n]=c:o?t[t.findIndex(e=>e.id===o.id)]=c:t.splice(Math.max(0,t.findIndex(t=>t.id===e.activeId)+1),0,c),{open:!0,tabs:t,activeId:s}}),s},addSideChat:(e,t,r,i=!0)=>n(r,n=>{let r=`side:${e}`;if(n.tabs.some(e=>e.id===r))return i?{...n,open:!0,activeId:r}:n;let a=i?n.tabs.findIndex(e=>e.id===n.activeId&&e.kind===`home`):-1,o=[...n.tabs];return a>=0&&o.splice(a,1),o.splice(a>=0?a:Math.max(0,o.findIndex(e=>e.id===n.activeId)+1),0,{id:r,kind:`sidechat`,sideChatId:e,title:t,visitedAt:Date.now()}),{tabs:o,activeId:i?r:n.activeId,open:i||n.open}}),resolveFileIdentity:(e,r)=>{for(let[i,a]of Object.entries(t().panes)){let o=a.tabs.find(t=>t.kind===`file`&&t.id===e);if(!o||o.resourceId===r)continue;let s=a.tabs.find(t=>t.kind===`file`&&t.id!==e&&t.resourceId===r);n(i,n=>!s||t().fileStatus[e]?{...n,tabs:n.tabs.map(t=>t.id===e?{...t,resourceId:r}:t)}:{...n,activeId:n.activeId===e?s.id:n.activeId,tabs:n.tabs.filter(t=>t.id!==e).map(e=>e.id===s.id?{...s,preview:s.preview===!0&&o.preview===!0,aliases:[...new Set([...s.aliases??[],y(o)])],line:o.line??s.line}:e)})}},replaceSideChat:(e,t,r)=>n(r,n=>({...n,activeId:n.activeId===`side:${e}`?`side:${t}`:n.activeId,tabs:n.tabs.map(n=>n.id===`side:${e}`?{...n,id:`side:${t}`,kind:`sidechat`,sideChatId:t}:n)})),remove:(e,r=t().scope)=>n(r,t=>{let n=t.tabs.find(t=>t.id===e),r=t.tabs.filter(t=>t.id!==e),i=r.find(e=>e.id===n?.returnTo)??[...r].sort((e,t)=>t.visitedAt-e.visitedAt)[0];return{...t,open:t.open&&r.length>0,tabs:r,activeId:t.activeId===e?i?.id??null:t.activeId}}),setWidth:t=>{e({width:t});try{localStorage.setItem(`xopc:workspace-width`,String(t))}catch{}},setTreeWidth:n=>{e({treeWidth:Math.max(200,Math.min(320,n))});try{localStorage.setItem(`xopc:workspace-tree-width`,String(t().treeWidth))}catch{}},setTreeOpen:(t,n)=>e(t===`file`?{fileTreeOpen:n}:{sideTreeOpen:n}),reset:()=>{e({panes:{},fileStatus:{},notices:{},scope:`new`}),h(t())}}});i.subscribe((e,t)=>{e.baseUrl!==t.baseUrl||t.conversationId!==void 0&&e.conversationId!==t.conversationId?b.getState().reset():e.conversationId&&!t.conversationId&&b.setState({panes:p().panes})});var x=e(t(),1);function S(){let[e,t]=(0,x.useState)(!1),[n,r]=(0,x.useState)(!1),[i,a]=(0,x.useState)(null),[o,s]=(0,x.useState)(null),[c,u]=(0,x.useState)(null),d=(0,x.useCallback)(e=>{t(!0),u(e),a(null),s(null)},[]),f=(0,x.useCallback)(async e=>{if(!c||n)return null;r(!0),s(null);try{let t=await l({...c,...e});return a(t.payload),t.payload}catch(e){let t=e instanceof Error?e.message:String(e);return s(t),null}finally{r(!1)}},[n,c]),p=(0,x.useCallback)(()=>{a(null),s(null),r(!1),u(null)},[]);return{dialogOpen:e,loading:n,result:i,error:o,pendingParams:c,createShareLink:d,confirmShareLink:f,handleOpenChange:(0,x.useCallback)(e=>{t(e),e||p()},[p])}}var C=e(n(),1);function w(){return c()&&window.electronAPI?.platform===`darwin`}function T(){return c()&&window.electronAPI?.platform===`win32`}function E(){return T()?`windows-preview-viewport`:``}var D=r();function O({expanded:e,children:t}){let n=(0,x.useRef)(null),r=e?n.current?.closest(`.app-main-surface`)??document.querySelector(`.app-main-surface`):null,i=(0,D.jsx)(`div`,{"data-file-preview-expanded":e||void 0,"data-browser-occluder":e||void 0,className:o(`flex h-full min-h-0 min-w-0 flex-1 flex-col overflow-hidden bg-surface-inset [&_.markdown-body_h1]:border-b-0! [&_.markdown-body_h2]:border-b-0!`,e&&(r?`absolute inset-0 z-[115]`:`fixed inset-0 z-[115] h-[100dvh] w-screen`),e&&!r&&E()),children:t});return(0,D.jsxs)(D.Fragment,{children:[(0,D.jsx)(`span`,{ref:n,hidden:!0,"aria-hidden":!0}),e?(0,C.createPortal)(i,r??document.body):i]})}export{S as a,T as i,E as n,d as o,w as r,b as s,O as t};
1
+ import{i as e}from"./rolldown-runtime-aKtaBQYM.js";import{a as t,i as n,t as r}from"./vendor-react-BOUWij0V.js";import{l as i,p as a}from"./locale-store-TQcz_Vjt.js";import{t as o}from"./cn-0WouolD0.js";import{t as s}from"./phone-workspace-store-FBfrfkYq.js";import{n as c}from"./electron-env-DHOGevH3.js";import{a as l}from"./shares-api-BoUpXmxq.js";var u=`xopc:right-workspace:v1`,d={open:!1,tabs:[],activeId:null},f={panes:{},width:0,treeWidth:240,fileTreeOpen:!0,sideTreeOpen:!1};function p(){try{let e=JSON.parse(sessionStorage.getItem(u)||`null`);if(!e||e.version!==1||typeof e.panes!=`object`||!e.panes||e.identity!==i.getState().conversationId||e.gateway!==i.getState().baseUrl)return f;let t={};for(let[n,r]of Object.entries(e.panes)){let e=r;if(!e||!Array.isArray(e.tabs))continue;let i=e.tabs.filter(e=>e&&typeof e.id==`string`&&typeof e.title==`string`&&(e.kind===`file`&&typeof e.path==`string`||e.kind===`sidechat`&&typeof e.sideChatId==`string`||e.kind===`home`||e.kind===`files`));t[n]={open:e.open===!0&&i.length>0,tabs:i,activeId:i.some(t=>t.id===e.activeId)?e.activeId:i[0]?.id??null}}return{...f,panes:t}}catch{return f}}function m(e,t){try{let n=Number(localStorage.getItem(e));return n>0&&Number.isFinite(n)?n:t}catch{return t}}function h(e){try{let t=Object.fromEntries(Object.entries(e.panes).map(([e,t])=>[e,{...t,tabs:t.tabs.filter(e=>e.kind!==`browser`&&(e.kind!==`file`||!e.attachment)).map(e=>({...e}))}]));sessionStorage.setItem(u,JSON.stringify({version:1,identity:i.getState().conversationId,gateway:i.getState().baseUrl,panes:t}))}catch{}}var g=new WeakMap;function _(e){return e?e.id||e.uri?e.id||e.uri:(g.has(e)||g.set(e,crypto.randomUUID()),g.get(e)):``}function v(e){return e.replace(/\\/g,`/`).split(`/`).filter(e=>e!==`.`).join(`/`)}function y(e){let t=e.projectId?`project:${e.projectId}`:e.conversationId?`session:${e.conversationId}`:`agent:${e.agentId??``}`;return JSON.stringify([t,e.path?v(e.path):_(e.attachment)])}var b=a((e,t)=>{let n=(n,r)=>{e(e=>({panes:{...e.panes,[n]:r(e.panes[n]??d)}})),h(t())};return{...p(),width:m(`xopc:workspace-width`,0),treeWidth:m(`xopc:workspace-tree-width`,240),notices:{},setNotice:(t,n)=>e(e=>({notices:{...e.notices,[t]:n}})),fileStatus:{},setFileStatus:(n,r)=>{r&&t().keepFileOpen(n),e(e=>({fileStatus:{...e.fileStatus,[n]:r??``}}))},keepFileOpen:e=>{for(let[r,i]of Object.entries(t().panes))i.tabs.some(t=>t.id===e&&t.kind===`file`&&t.preview)&&n(r,t=>({...t,tabs:t.tabs.map(t=>t.id===e?{...t,preview:!1}:t)}))},scope:`new`,setScope:t=>e({scope:t}),migrateScope:(n,r)=>{let i=t().panes[n];if(!i||n===r)return;let a=t().panes[r]??d,o={...t().panes,[r]:{open:i.open||a.open,tabs:[...a.tabs,...i.tabs.filter(e=>!a.tabs.some(t=>t.id===e.id))],activeId:i.activeId??a.activeId}};delete o[n],e({panes:o,scope:t().scope===n?r:t().scope}),h(t())},openPhone:(e,t,r,i=!0,a=!0)=>{let o=`phone:${e}`;n(r,n=>({open:i||n.open,activeId:i?o:n.activeId,tabs:n.tabs.some(e=>e.id===o)?n.tabs.map(e=>e.id===o?{...e,title:t}:e):[...n.tabs,{id:o,kind:`phone`,phoneSessionId:e,title:t,visitedAt:Date.now()}]})),a&&s.getState().show(e,i,/^[\da-f]{8}-[\da-f-]{27}$/i.test(r)?r:void 0)},openTools:(e=t().scope)=>{let r=crypto.randomUUID();return n(e,e=>{let t=[...e.tabs];return t.splice(Math.max(0,t.findIndex(t=>t.id===e.activeId)+1),0,{id:r,kind:`home`,title:`New tab`,visitedAt:Date.now()}),{open:!0,tabs:t,activeId:r}}),r},openBrowser:(e,r=t().scope,i)=>{let a=t().panes[r]??d,o=a.tabs.find(e=>e.id===a.activeId&&e.kind===`home`)?.id??crypto.randomUUID(),s={id:o,kind:`browser`,title:`Browser`,initialUrl:e,visitedAt:Date.now(),returnTo:i??a.activeId??void 0};return n(r,e=>{let t=[...e.tabs],n=t.findIndex(e=>e.id===o);return n>=0?t[n]=s:t.splice(Math.max(0,t.findIndex(t=>t.id===e.activeId)+1),0,s),{open:!0,activeId:o,tabs:t}}),o},updateBrowserTitle:(e,r)=>{for(let[i,a]of Object.entries(t().panes))a.tabs.some(t=>t.id===e&&t.kind===`browser`&&t.title!==r)&&n(i,t=>({...t,tabs:t.tabs.map(t=>t.id===e?{...t,title:r.slice(0,200)}:t)}))},openFiles:(e=t().scope)=>{let r=t().panes[e]??d,i=r.tabs.find(e=>e.kind===`files`);if(i){t().activate(i.id,e);return}let a=r.tabs.find(e=>e.id===r.activeId&&e.kind===`home`),o=a?.id??crypto.randomUUID();n(e,e=>({open:!0,activeId:o,tabs:a?e.tabs.map(e=>e.id===o?{...e,kind:`files`,title:`Files`}:e):[...e.tabs,{id:o,kind:`files`,title:`Files`,visitedAt:Date.now()}]}))},setOpen:(e,r=t().scope)=>{if(e&&!t().panes[r]?.tabs.length){t().openTools(r);return}n(r,t=>({...t,open:e,activeId:t.activeId??t.tabs[0]?.id??null}))},activate:(e,r=t().scope)=>{let i=t().panes[r]?.tabs.find(t=>t.id===e);i?.kind===`phone`&&(s.getState().setDisplayMode(`docked`),s.getState().show(i.phoneSessionId,!0,/^[\da-f]{8}-[\da-f-]{27}$/i.test(r)?r:void 0)),n(r,t=>({...t,open:!!(e&&t.tabs.some(t=>t.id===e)),activeId:e&&t.tabs.some(t=>t.id===e)?e:t.activeId,tabs:t.tabs.map(t=>t.id===e?{...t,visitedAt:Date.now()}:t)}))},openFile:(e,r=t().scope)=>{let i=t().panes[r]??d,a=i.tabs.find(t=>t.kind===`file`&&(y(t)===y(e)||t.aliases?.includes(y(e)))),o=!a&&e.preview!==!1?i.tabs.find(e=>e.kind===`file`&&e.preview&&!t().fileStatus[e.id]):void 0,s=a?.id??crypto.randomUUID(),c={...a?.kind===`file`?a:{},...e,preview:a?.kind===`file`?a.preview===!0:e.preview!==!1,id:s,kind:`file`,title:e.path?.replace(/\\/g,`/`).split(`/`).pop()||e.attachment?.name||`File`,visitedAt:Date.now(),returnTo:a?.returnTo??(o?o.returnTo:i.activeId??void 0)};return n(r,e=>{let t=[...e.tabs],n=t.findIndex(e=>e.id===s);return n>=0?t[n]=c:o?t[t.findIndex(e=>e.id===o.id)]=c:t.splice(Math.max(0,t.findIndex(t=>t.id===e.activeId)+1),0,c),{open:!0,tabs:t,activeId:s}}),s},addSideChat:(e,t,r,i=!0)=>n(r,n=>{let r=`side:${e}`;if(n.tabs.some(e=>e.id===r))return i?{...n,open:!0,activeId:r}:n;let a=i?n.tabs.findIndex(e=>e.id===n.activeId&&e.kind===`home`):-1,o=[...n.tabs];return a>=0&&o.splice(a,1),o.splice(a>=0?a:Math.max(0,o.findIndex(e=>e.id===n.activeId)+1),0,{id:r,kind:`sidechat`,sideChatId:e,title:t,visitedAt:Date.now()}),{tabs:o,activeId:i?r:n.activeId,open:i||n.open}}),resolveFileIdentity:(e,r)=>{for(let[i,a]of Object.entries(t().panes)){let o=a.tabs.find(t=>t.kind===`file`&&t.id===e);if(!o||o.resourceId===r)continue;let s=a.tabs.find(t=>t.kind===`file`&&t.id!==e&&t.resourceId===r);n(i,n=>!s||t().fileStatus[e]?{...n,tabs:n.tabs.map(t=>t.id===e?{...t,resourceId:r}:t)}:{...n,activeId:n.activeId===e?s.id:n.activeId,tabs:n.tabs.filter(t=>t.id!==e).map(e=>e.id===s.id?{...s,preview:s.preview===!0&&o.preview===!0,aliases:[...new Set([...s.aliases??[],y(o)])],line:o.line??s.line}:e)})}},replaceSideChat:(e,t,r)=>n(r,n=>({...n,activeId:n.activeId===`side:${e}`?`side:${t}`:n.activeId,tabs:n.tabs.map(n=>n.id===`side:${e}`?{...n,id:`side:${t}`,kind:`sidechat`,sideChatId:t}:n)})),remove:(e,r=t().scope)=>n(r,t=>{let n=t.tabs.find(t=>t.id===e),r=t.tabs.filter(t=>t.id!==e),i=r.find(e=>e.id===n?.returnTo)??[...r].sort((e,t)=>t.visitedAt-e.visitedAt)[0];return{...t,open:t.open&&r.length>0,tabs:r,activeId:t.activeId===e?i?.id??null:t.activeId}}),setWidth:t=>{e({width:t});try{localStorage.setItem(`xopc:workspace-width`,String(t))}catch{}},setTreeWidth:n=>{e({treeWidth:Math.max(200,Math.min(320,n))});try{localStorage.setItem(`xopc:workspace-tree-width`,String(t().treeWidth))}catch{}},setTreeOpen:(t,n)=>e(t===`file`?{fileTreeOpen:n}:{sideTreeOpen:n}),reset:()=>{e({panes:{},fileStatus:{},notices:{},scope:`new`}),h(t())}}});i.subscribe((e,t)=>{e.baseUrl!==t.baseUrl||t.conversationId!==void 0&&e.conversationId!==t.conversationId?b.getState().reset():e.conversationId&&!t.conversationId&&b.setState({panes:p().panes})});var x=e(t(),1);function S(){let[e,t]=(0,x.useState)(!1),[n,r]=(0,x.useState)(!1),[i,a]=(0,x.useState)(null),[o,s]=(0,x.useState)(null),[c,u]=(0,x.useState)(null),d=(0,x.useCallback)(e=>{t(!0),u(e),a(null),s(null)},[]),f=(0,x.useCallback)(async e=>{if(!c||n)return null;r(!0),s(null);try{let t=await l({...c,...e});return a(t.payload),t.payload}catch(e){let t=e instanceof Error?e.message:String(e);return s(t),null}finally{r(!1)}},[n,c]),p=(0,x.useCallback)(()=>{a(null),s(null),r(!1),u(null)},[]);return{dialogOpen:e,loading:n,result:i,error:o,pendingParams:c,createShareLink:d,confirmShareLink:f,handleOpenChange:(0,x.useCallback)(e=>{t(e),e||p()},[p])}}var C=e(n(),1);function w(){return c()&&window.electronAPI?.platform===`darwin`}function T(){return c()&&window.electronAPI?.platform===`win32`}function E(){return T()?`windows-preview-viewport`:``}var D=r();function O({expanded:e,children:t}){let n=(0,x.useRef)(null),r=e?n.current?.closest(`.app-main-surface`)??document.querySelector(`.app-main-surface`):null,i=(0,D.jsx)(`div`,{"data-file-preview-expanded":e||void 0,"data-browser-occluder":e||void 0,className:o(`flex h-full min-h-0 min-w-0 flex-1 flex-col overflow-hidden bg-surface-inset [&_.markdown-body_h1]:border-b-0! [&_.markdown-body_h2]:border-b-0!`,e&&(r?`absolute inset-0 z-[115]`:`fixed inset-0 z-[115] h-[100dvh] w-screen`),e&&!r&&E()),children:t});return(0,D.jsxs)(D.Fragment,{children:[(0,D.jsx)(`span`,{ref:n,hidden:!0,"aria-hidden":!0}),e?(0,C.createPortal)(i,r??document.body):i]})}export{S as a,T as i,E as n,d as o,w as r,b as s,O as t};
@@ -1 +1 @@
1
- import{i as e}from"./rolldown-runtime-aKtaBQYM.js";import{a as t,n}from"./vendor-react-BOUWij0V.js";import{i as r,o as i}from"./locale-store-_-_QzAV0.js";import{i as a,o}from"./vendor-swr-CdRzEUwF.js";var s=e(t(),1),c=n();function l(e){if(!(!e||typeof e!=`object`||!(`section`in e)))return e.section}function u(e){return l(e)===`skills`}function d(){return r(`/api/config`)}var f=null;async function p(){return f||(f=i(d()).finally(()=>{f=null}),f)}function m(e){let t=(0,c.c)(6),n;t[0]===e?n=t[1]:(n=e?d():null,t[0]=e,t[1]=n);let r=n,i;t[2]===Symbol.for(`react.memo_cache_sentinel`)?(i={revalidateOnFocus:!1},t[2]=i):i=t[2];let l=a(r,p,i),f,m;return t[3]===e?(f=t[4],m=t[5]):(f=()=>{if(!e)return;let t=d(),n=e=>{u(e.detail)||o(t)};return window.addEventListener(`config-reload`,n),()=>window.removeEventListener(`config-reload`,n)},m=[e],t[3]=e,t[4]=f,t[5]=m),(0,s.useEffect)(f,m),l}function h(){return o(d())}export{u as a,l as i,h as n,m as r,p as t};
1
+ import{i as e}from"./rolldown-runtime-aKtaBQYM.js";import{a as t,n}from"./vendor-react-BOUWij0V.js";import{i as r,o as i}from"./locale-store-TQcz_Vjt.js";import{i as a,o}from"./vendor-swr-CdRzEUwF.js";var s=e(t(),1),c=n();function l(e){if(!(!e||typeof e!=`object`||!(`section`in e)))return e.section}function u(e){return l(e)===`skills`}function d(){return r(`/api/config`)}var f=null;async function p(){return f||(f=i(d()).finally(()=>{f=null}),f)}function m(e){let t=(0,c.c)(6),n;t[0]===e?n=t[1]:(n=e?d():null,t[0]=e,t[1]=n);let r=n,i;t[2]===Symbol.for(`react.memo_cache_sentinel`)?(i={revalidateOnFocus:!1},t[2]=i):i=t[2];let l=a(r,p,i),f,m;return t[3]===e?(f=t[4],m=t[5]):(f=()=>{if(!e)return;let t=d(),n=e=>{u(e.detail)||o(t)};return window.addEventListener(`config-reload`,n),()=>window.removeEventListener(`config-reload`,n)},m=[e],t[3]=e,t[4]=f,t[5]=m),(0,s.useEffect)(f,m),l}function h(){return o(d())}export{u as a,l as i,h as n,m as r,p as t};