@xopcai/xopc 0.0.431 → 0.0.433

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 (186) hide show
  1. package/dist/browser-ext/manifest.json +1 -1
  2. package/dist/extensions/telegram/xopc.extension.json +1 -1
  3. package/dist/gateway/static/root/assets/{activity-store-WqnVruhY.js → activity-store-BpYGrRXw.js} +1 -1
  4. package/dist/gateway/static/root/assets/{agent-avatar-dicebear-CSiO9c2F.js → agent-avatar-dicebear-DTgOSv6G.js} +1 -1
  5. package/dist/gateway/static/root/assets/{agent-avatar-display-D-yds6wG.js → agent-avatar-display-BUH7ljEo.js} +2 -2
  6. package/dist/gateway/static/root/assets/{agent-defaults-settings-panel-_UT9C7bg.js → agent-defaults-settings-panel-B_FAikHA.js} +1 -1
  7. package/dist/gateway/static/root/assets/{agent-plugin-dialog-DVzYXsAy.js → agent-plugin-dialog-DPabZaSE.js} +1 -1
  8. package/dist/gateway/static/root/assets/{agents-Ds7K3D7T.js → agents-BAPYP1Ka.js} +3 -3
  9. package/dist/gateway/static/root/assets/{agents-admin-api-Bgv4lJ9Y.js → agents-admin-api-CXCAHNPj.js} +1 -1
  10. package/dist/gateway/static/root/assets/{api-Dv6Cn-Rs.js → api-DMbimMEi.js} +1 -1
  11. package/dist/gateway/static/root/assets/{api-C-9J9ghT.js → api-oIK4hYkJ.js} +1 -1
  12. package/dist/gateway/static/root/assets/{app-management-settings-panel-BXJrrjH5.js → app-management-settings-panel-BZ3Fy8ZR.js} +1 -1
  13. package/dist/gateway/static/root/assets/{appearance-settings-oYjAVulT.js → appearance-settings-DsRTj1by.js} +1 -1
  14. package/dist/gateway/static/root/assets/{apps-page-D95yzj-f.js → apps-page-D-n71lO1.js} +1 -1
  15. package/dist/gateway/static/root/assets/{archive-plugin-DBPu3xCJ.js → archive-plugin-Bg1VTieK.js} +1 -1
  16. package/dist/gateway/static/root/assets/{automation-api-DAou8Kji.js → automation-api-CLPsgcQN.js} +1 -1
  17. package/dist/gateway/static/root/assets/{automation-result-state-CA7LV098.js → automation-result-state-CKVnR4KG.js} +1 -1
  18. package/dist/gateway/static/root/assets/{automation-task-card-DIjI_Y1X.js → automation-task-card-D27Mw66U.js} +1 -1
  19. package/dist/gateway/static/root/assets/{automations-page-BQwSCkmd.js → automations-page-DGNTJ8lN.js} +1 -1
  20. package/dist/gateway/static/root/assets/{automations-workspace-BUFTTjBq.js → automations-workspace-DWDWy-SG.js} +2 -2
  21. package/dist/gateway/static/root/assets/{binary-plugins-D25P9ZxQ.js → binary-plugins-CuwSdCG5.js} +1 -1
  22. package/dist/gateway/static/root/assets/{block-editor-BI105p1U.js → block-editor-Dtl2BG3t.js} +1 -1
  23. package/dist/gateway/static/root/assets/{browser-automation-inputs-DhDRvWQE.js → browser-automation-inputs-uGK086ag.js} +1 -1
  24. package/dist/gateway/static/root/assets/{browser-automations-page-CCPi1Bvy.js → browser-automations-page-Da_edNNS.js} +1 -1
  25. package/dist/gateway/static/root/assets/{browser-control-api-BN4F-bM1.js → browser-control-api-k3OOX3bS.js} +1 -1
  26. package/dist/gateway/static/root/assets/{browser-settings-page-BZXUZpjp.js → browser-settings-page-C1bSw-Jq.js} +1 -1
  27. package/dist/gateway/static/root/assets/{capabilities-LC-yEQYo.js → capabilities-CoeuLRt6.js} +1 -1
  28. package/dist/gateway/static/root/assets/{capabilities-u2z_KFRt.js → capabilities-DlHPLld_.js} +1 -1
  29. package/dist/gateway/static/root/assets/{capabilities-page-B8UgQ4dD.js → capabilities-page-IcwojmJK.js} +2 -2
  30. package/dist/gateway/static/root/assets/{capabilities-settings-panel-Bxn8HtEO.js → capabilities-settings-panel-CtY-bGIi.js} +1 -1
  31. package/dist/gateway/static/root/assets/{channels-9Uaa-IN0.js → channels-Cn1MWBL_.js} +1 -1
  32. package/dist/gateway/static/root/assets/{chat-agents-api-Cffxfzi1.js → chat-agents-api-BB0biwc7.js} +1 -1
  33. package/dist/gateway/static/root/assets/{chat-chart-block-Bbk0b3TV.js → chat-chart-block-QSvjx4w6.js} +1 -1
  34. package/dist/gateway/static/root/assets/{chat-page-e-xCsrdS.js → chat-page-CwP4OMdW.js} +16 -16
  35. package/dist/gateway/static/root/assets/{chat-terminal-dock-CQMuG-Bz.js → chat-terminal-dock-Cd51G9eG.js} +1 -1
  36. package/dist/gateway/static/root/assets/{command-palette-api-BRxfFgGA.js → command-palette-api-CEG10uE-.js} +1 -1
  37. package/dist/gateway/static/root/assets/{composer-payload-handoff-_9L2A5AZ.js → composer-payload-handoff-Bogdq9Hy.js} +1 -1
  38. package/dist/gateway/static/root/assets/{computer-settings-page-BIHbjBVt.js → computer-settings-page-DyAlOzqY.js} +1 -1
  39. package/dist/gateway/static/root/assets/{connected-providers-grid-B7ktDgqt.js → connected-providers-grid-D0lXg22c.js} +1 -1
  40. package/dist/gateway/static/root/assets/{connector-service-page-BVMEg8n-.js → connector-service-page-k2rjyjrp.js} +1 -1
  41. package/dist/gateway/static/root/assets/{connectors-api-B07yoCzk.js → connectors-api-DtvB9Cjm.js} +1 -1
  42. package/dist/gateway/static/root/assets/{connectors-page-hPKaJUWY.js → connectors-page-DI_Q0CKz.js} +1 -1
  43. package/dist/gateway/static/root/assets/{date-picker-BvEnSGZK.js → date-picker-CAankdQw.js} +1 -1
  44. package/dist/gateway/static/root/assets/{desktop-pet-C1z9YDEg.js → desktop-pet-DjM73fir.js} +1 -1
  45. package/dist/gateway/static/root/assets/{desktop-pet-settings-CbbVb8GY.js → desktop-pet-settings-Rmh-GxHl.js} +1 -1
  46. package/dist/gateway/static/root/assets/{dev-view-store-38EmUIEC.js → dev-view-store-BgW2Riyk.js} +1 -1
  47. package/dist/gateway/static/root/assets/{device-pairing-wizard-Wb1EKiXA.js → device-pairing-wizard-UdzSpNa5.js} +1 -1
  48. package/dist/gateway/static/root/assets/{directory-picker-path-field-BvKDrKc4.js → directory-picker-path-field-Rkw3f7lG.js} +1 -1
  49. package/dist/gateway/static/root/assets/{discussion-annotation-sync-BfVzIwe2.js → discussion-annotation-sync-Dudoj_Fz.js} +1 -1
  50. package/dist/gateway/static/root/assets/{extension-debug-page-CB9Lu3Sq.js → extension-debug-page-DxIGAO23.js} +1 -1
  51. package/dist/gateway/static/root/assets/{extension-iframe-host-BzjrVAUR.js → extension-iframe-host-63KpX6IP.js} +1 -1
  52. package/dist/gateway/static/root/assets/{extension-marketplace-api-DigziAgd.js → extension-marketplace-api-yXNUkQDA.js} +1 -1
  53. package/dist/gateway/static/root/assets/{extension-page-DUa9MeaZ.js → extension-page-C811A_Ww.js} +1 -1
  54. package/dist/gateway/static/root/assets/{extension-provider-301x0rh-.js → extension-provider-C4jLFIgh.js} +1 -1
  55. package/dist/gateway/static/root/assets/{extension-settings-page-CP9ciZUI.js → extension-settings-page-WJSw5MT0.js} +1 -1
  56. package/dist/gateway/static/root/assets/{file-preview-surface-BaMGmCbw.js → file-preview-surface-zE9AcaHM.js} +1 -1
  57. package/dist/gateway/static/root/assets/{gateway-config-swr-BD4Bf8uu.js → gateway-config-swr-D6cc6W6E.js} +1 -1
  58. package/dist/gateway/static/root/assets/{gateway-realtime-CSd9VB7Z.js → gateway-realtime-BSRNLciy.js} +1 -1
  59. package/dist/gateway/static/root/assets/gateway-realtime-store-BFeFfApQ.js +1 -0
  60. package/dist/gateway/static/root/assets/{gateway-restart-CIUCTKYR.js → gateway-restart-Unun5hRL.js} +1 -1
  61. package/dist/gateway/static/root/assets/{gateway-settings-CCqF1uZv.js → gateway-settings-DP-DV-e5.js} +1 -1
  62. package/dist/gateway/static/root/assets/{gateway-startup-retry-BsU5k8oi.js → gateway-startup-retry-C8g666Ja.js} +1 -1
  63. package/dist/gateway/static/root/assets/{global-defaults-api-asOZQeM8.js → global-defaults-api-BObi-1ww.js} +1 -1
  64. package/dist/gateway/static/root/assets/{home-page-Bb_RC1O9.js → home-page-CIcs7Mzy.js} +2 -2
  65. package/dist/gateway/static/root/assets/{image-generation-api-CdwYgzhU.js → image-generation-api-C2SqYNyD.js} +1 -1
  66. package/dist/gateway/static/root/assets/{imports-page-CVnoGUyp.js → imports-page-C8ezUkOJ.js} +1 -1
  67. package/dist/gateway/static/root/assets/{index-BmUSsdwn.js → index-D1_PUrJf.js} +5 -5
  68. package/dist/gateway/static/root/assets/{install-connector-dialog-DXVOHMhS.js → install-connector-dialog-Cn4nRSyt.js} +1 -1
  69. package/dist/gateway/static/root/assets/{keyboard-shortcuts-settings-BCl90SrD.js → keyboard-shortcuts-settings-BRaY4-wA.js} +1 -1
  70. package/dist/gateway/static/root/assets/{local-app-workbench-page-CcJc9xLJ.js → local-app-workbench-page-BZtVcjF3.js} +1 -1
  71. package/dist/gateway/static/root/assets/{local-apps-page-CdAKoWfg.js → local-apps-page-MqP4EnJm.js} +1 -1
  72. package/dist/gateway/static/root/assets/{local-session-drafts-nRGeybku.js → local-session-drafts-DTq9776a.js} +1 -1
  73. package/dist/gateway/static/root/assets/{locale-store-B7y-RVe8.js → locale-store-B6OrWgY1.js} +1 -1
  74. package/dist/gateway/static/root/assets/{logs-page-McbSQwJI.js → logs-page-hkHBjblX.js} +1 -1
  75. package/dist/gateway/static/root/assets/{management-settings-BIR0BwNV.js → management-settings-DoX4eTM3.js} +1 -1
  76. package/dist/gateway/static/root/assets/{markdown-view-DFHa8rUg.js → markdown-view-DrhYZSmg.js} +1 -1
  77. package/dist/gateway/static/root/assets/{mcp-conversation-setup-page-Dwx4TuIr.js → mcp-conversation-setup-page-BEp5E6TD.js} +1 -1
  78. package/dist/gateway/static/root/assets/{media-plugins-BzzLV7wW.js → media-plugins-D987i9Gc.js} +1 -1
  79. package/dist/gateway/static/root/assets/messages-jwdBhfL9.js +3 -0
  80. package/dist/gateway/static/root/assets/{model-selector-YsCHu1Gn.js → model-selector-DXm4NS1_.js} +1 -1
  81. package/dist/gateway/static/root/assets/{models-hub-cache-BUapaPTN.js → models-hub-cache-BLcha5rx.js} +1 -1
  82. package/dist/gateway/static/root/assets/{note-detail-panel-CJ-dPovd.js → note-detail-panel-Cl851ivY.js} +3 -3
  83. package/dist/gateway/static/root/assets/note-image-lightbox-DGYRJS03.js +1 -0
  84. package/dist/gateway/static/root/assets/{notes-api-ulup1oFS.js → notes-api-Ddsf7FVg.js} +1 -1
  85. package/dist/gateway/static/root/assets/{notes-page-BaFNplIr.js → notes-page-DSwA1MU1.js} +1 -1
  86. package/dist/gateway/static/root/assets/{oauth-api-DINa08-z.js → oauth-api-CMmu4DzH.js} +1 -1
  87. package/dist/gateway/static/root/assets/{oauth-provider-connect-C0PVEHC2.js → oauth-provider-connect-BkhnftBq.js} +1 -1
  88. package/dist/gateway/static/root/assets/{page-context-capture-button-CGfR0dsc.js → page-context-capture-button-urhQBRaN.js} +1 -1
  89. package/dist/gateway/static/root/assets/{page-context-draft-DhRNxc0v.js → page-context-draft-BuNUerth.js} +1 -1
  90. package/dist/gateway/static/root/assets/page-header-store-CEn_kPsn.js +1 -0
  91. package/dist/gateway/static/root/assets/{personal-avatar-DiVFO2Aw.js → personal-avatar-B49ueeZO.js} +1 -1
  92. package/dist/gateway/static/root/assets/{personal-page-Cvd-v9kT.js → personal-page-f05ceuFn.js} +1 -1
  93. package/dist/gateway/static/root/assets/{personal-settings-panel-Ds4ntiqu.js → personal-settings-panel-DLQxzPYr.js} +1 -1
  94. package/dist/gateway/static/root/assets/{phone-dependencies-card-B3R6L5Qu.js → phone-dependencies-card-DjmC1Z5j.js} +1 -1
  95. package/dist/gateway/static/root/assets/{phone-model-connection-BieYnAJ5.js → phone-model-connection-BRjHSgYn.js} +1 -1
  96. package/dist/gateway/static/root/assets/{phone-model-picker-Bkex4Sre.js → phone-model-picker-DgIiWLhR.js} +1 -1
  97. package/dist/gateway/static/root/assets/{phone-settings-page-D8PuvEuJ.js → phone-settings-page-DCZGCL_z.js} +1 -1
  98. package/dist/gateway/static/root/assets/{phone-workspace-store-Cmes9gQ4.js → phone-workspace-store-DbqktZbO.js} +1 -1
  99. package/dist/gateway/static/root/assets/{plugin-details-dialog-DblFhnuC.js → plugin-details-dialog-D4tGKip4.js} +1 -1
  100. package/dist/gateway/static/root/assets/{preference-select-fields-D2-QfMN5.js → preference-select-fields-BZWqG7pu.js} +1 -1
  101. package/dist/gateway/static/root/assets/{product-automation-feedback-BzY3z8zu.js → product-automation-feedback-DDQUsag7.js} +1 -1
  102. package/dist/gateway/static/root/assets/{product-open-page-BKw6H0Mn.js → product-open-page-BkRP_HmA.js} +1 -1
  103. package/dist/gateway/static/root/assets/{product-preview-content-VcvxaO2S.js → product-preview-content-o2Y3VNE7.js} +1 -1
  104. package/dist/gateway/static/root/assets/{product-preview-modal-Ym6bomTW.js → product-preview-modal-7Ohx-7OR.js} +2 -2
  105. package/dist/gateway/static/root/assets/{project-detail-page-CFbXWvcd.js → project-detail-page-B2RsSHya.js} +1 -1
  106. package/dist/gateway/static/root/assets/{project-understanding-CrSkrJnM.js → project-understanding-BIMouiYX.js} +1 -1
  107. package/dist/gateway/static/root/assets/{projects-page-Cp91_KzA.js → projects-page-C9R5u3tF.js} +1 -1
  108. package/dist/gateway/static/root/assets/{providers-api-CBSC3jdu.js → providers-api-BOCkRZ7X.js} +1 -1
  109. package/dist/gateway/static/root/assets/{recording-upload-DBHAGKZj.js → recording-upload-C6muEHEO.js} +1 -1
  110. package/dist/gateway/static/root/assets/{registry-api-QZEjziDq.js → registry-api-Bl2guMRg.js} +1 -1
  111. package/dist/gateway/static/root/assets/{remote-access-hub-BdXxFQfH.js → remote-access-hub-BceSMbCs.js} +1 -1
  112. package/dist/gateway/static/root/assets/{resource-unavailable-BTNhcOHF.js → resource-unavailable-CUNbPkdj.js} +1 -1
  113. package/dist/gateway/static/root/assets/{route-preload-C-VRKwB1.js → route-preload-C1BKDjnu.js} +2 -2
  114. package/dist/gateway/static/root/assets/{runtime-tools-api-BDTUD8Rj.js → runtime-tools-api-LopLjgvu.js} +1 -1
  115. package/dist/gateway/static/root/assets/{runtime-tools-settings-panel-CYEzIrDf.js → runtime-tools-settings-panel-9HIPerDP.js} +1 -1
  116. package/dist/gateway/static/root/assets/{service-recommendation-list-CfeYH6lK.js → service-recommendation-list-CoMI6MB1.js} +1 -1
  117. package/dist/gateway/static/root/assets/{session-api-DVXLCZX2.js → session-api-Bfmlmn9F.js} +1 -1
  118. package/dist/gateway/static/root/assets/session-manager-X4UHOjjO.js +25 -0
  119. package/dist/gateway/static/root/assets/{sessions-page-C2CH-55n.js → sessions-page-BT0GdXdS.js} +1 -1
  120. package/dist/gateway/static/root/assets/settings-advanced-gate-Dk9c-Z5e.js +1 -0
  121. package/dist/gateway/static/root/assets/{settings-advanced-section-BmrbHgQa.js → settings-advanced-section-CEorDLUp.js} +1 -1
  122. package/dist/gateway/static/root/assets/{settings-mode-store-Bk_hzwPK.js → settings-mode-store-C2LZqBES.js} +1 -1
  123. package/dist/gateway/static/root/assets/{settings-page-B6vrcc6f.js → settings-page-C_Np_6qZ.js} +1 -1
  124. package/dist/gateway/static/root/assets/{settings-page-header-BLKI3_9N.js → settings-page-header-BAN34UQi.js} +1 -1
  125. package/dist/gateway/static/root/assets/{settings-page-layout-BqBVrkC9.js → settings-page-layout-B5TVFBV2.js} +1 -1
  126. package/dist/gateway/static/root/assets/{setup-interaction-page-BDPte58u.js → setup-interaction-page-BYvTJW3_.js} +1 -1
  127. package/dist/gateway/static/root/assets/{setup-status-panel-DEefuWo3.js → setup-status-panel-UY2dH-sK.js} +1 -1
  128. package/dist/gateway/static/root/assets/{share-link-dialog-C2LyeNzj.js → share-link-dialog-BMcXyzr2.js} +1 -1
  129. package/dist/gateway/static/root/assets/{share-preview-page-BFwEr7Ws.js → share-preview-page-UQ6eUM2_.js} +1 -1
  130. package/dist/gateway/static/root/assets/{shares-api-CTFkLQxq.js → shares-api-DOeDN6Tm.js} +1 -1
  131. package/dist/gateway/static/root/assets/{shares-settings-CpK3yhtc.js → shares-settings-W8XhuAoL.js} +1 -1
  132. package/dist/gateway/static/root/assets/{skill-api-DpicfA6o.js → skill-api-Do_c0d9n.js} +1 -1
  133. package/dist/gateway/static/root/assets/{skill-list-api-B8fegRLZ.js → skill-list-api-DpHaXI2l.js} +1 -1
  134. package/dist/gateway/static/root/assets/{skill-reload-api-VmC8ySUy.js → skill-reload-api-DDRd9IJ2.js} +1 -1
  135. package/dist/gateway/static/root/assets/{skills-page-BIWXS6Ki.js → skills-page-CaeJVKhO.js} +1 -1
  136. package/dist/gateway/static/root/assets/{system-settings-panel-BmoA92oX.js → system-settings-panel-DYWlWPJL.js} +1 -1
  137. package/dist/gateway/static/root/assets/{task-detail-page-CC3Rzqq9.js → task-detail-page-De0qD7xw.js} +1 -1
  138. package/dist/gateway/static/root/assets/{task-result-evidence-BV-6hBVU.js → task-result-evidence-CICR5K1t.js} +1 -1
  139. package/dist/gateway/static/root/assets/{terminal-panel-store-BGdKE9hU.js → terminal-panel-store-BbWUcQe7.js} +1 -1
  140. package/dist/gateway/static/root/assets/{theme-store-Dvv79Wb2.js → theme-store-TkG5mo0p.js} +1 -1
  141. package/dist/gateway/static/root/assets/{tracing-settings-page-B4uA4Pnz.js → tracing-settings-page-CYXEy4EG.js} +1 -1
  142. package/dist/gateway/static/root/assets/{tunnel-api-BurZtvqx.js → tunnel-api-DquDm6U2.js} +1 -1
  143. package/dist/gateway/static/root/assets/{understanding-activity-store-C1cLL8zq.js → understanding-activity-store-Ot3wZ3oQ.js} +1 -1
  144. package/dist/gateway/static/root/assets/{understanding-refresh-store-C3Lr_pjY.js → understanding-refresh-store-C5KYFMaC.js} +1 -1
  145. package/dist/gateway/static/root/assets/{usage-page-C91ZzLm9.js → usage-page-1xFO4smo.js} +1 -1
  146. package/dist/gateway/static/root/assets/{use-autosave-zkzRuUtx.js → use-autosave-HL8XRNR8.js} +1 -1
  147. package/dist/gateway/static/root/assets/{use-composer-attachments-CoiQAgjo.js → use-composer-attachments-XRlQBdNF.js} +1 -1
  148. package/dist/gateway/static/root/assets/{use-file-preview-expanded-DFzy6iVy.js → use-file-preview-expanded-CW956CXS.js} +2 -2
  149. package/dist/gateway/static/root/assets/{use-personal-profile-BB10h9ED.js → use-personal-profile-202s6tJt.js} +1 -1
  150. package/dist/gateway/static/root/assets/{use-workspace-tree-sF5DcONt.js → use-workspace-tree-CjydkmH1.js} +1 -1
  151. package/dist/gateway/static/root/assets/{user-model-page-WFnD5utO.js → user-model-page-OGPXx3pe.js} +1 -1
  152. package/dist/gateway/static/root/assets/{voice-api-key-field-Bqa4PeZx.js → voice-api-key-field-CxFu4MEA.js} +1 -1
  153. package/dist/gateway/static/root/assets/{voice-config-api-LNO2xXHk.js → voice-config-api-MHe5Pn-A.js} +1 -1
  154. package/dist/gateway/static/root/assets/{voice-input-shortcut-events-AzfhxBX7.js → voice-input-shortcut-events-B9xc1oK8.js} +1 -1
  155. package/dist/gateway/static/root/assets/{voice-transcribe-api-Cb8i6dLb.js → voice-transcribe-api-CVEcB6Pe.js} +1 -1
  156. package/dist/gateway/static/root/assets/{work-discovery-overlay-CdQUiV-a.js → work-discovery-overlay-C-JoAg2D.js} +1 -1
  157. package/dist/gateway/static/root/assets/{work-discovery-page-HcUloXxf.js → work-discovery-page-B5Kx29Ru.js} +1 -1
  158. package/dist/gateway/static/root/assets/{working-directory-picker-modal-Dv1HUipe.js → working-directory-picker-modal-DGp9cNzH.js} +1 -1
  159. package/dist/gateway/static/root/assets/{workspace-api-Am2ee4R6.js → workspace-api-HBXn8pL9.js} +2 -2
  160. package/dist/gateway/static/root/assets/workspace-editor-agent-store-msZa42fU.js +1 -0
  161. package/dist/gateway/static/root/assets/{workspace-file-preview-dialog-z5Q00v92.js → workspace-file-preview-dialog-3cpwSG2w.js} +1 -1
  162. package/dist/gateway/static/root/assets/{workspace-open-location-menu-4ONYaGy0.js → workspace-open-location-menu-D0VOFvuP.js} +1 -1
  163. package/dist/gateway/static/root/assets/{xopc-cloud-account-card-DimGN59n.js → xopc-cloud-account-card-BkdW2p3v.js} +1 -1
  164. package/dist/gateway/static/root/index.html +78 -78
  165. package/dist/package.js +1 -1
  166. package/dist/src/gateway/global-defaults-admin.js +1 -1
  167. package/dist/src/gateway/service.js +4 -4
  168. package/dist/src/home-intelligence/host.js +2 -2
  169. package/dist/src/phone/adb-driver.js +2 -2
  170. package/dist/src/phone/model-adapter.d.ts +2 -0
  171. package/dist/src/phone/model-adapter.js +10 -3
  172. package/dist/src/phone/reliability.js +24 -2
  173. package/dist/src/phone/runtime.js +6 -1
  174. package/dist/src/phone/ui-dump-binary.d.ts +1 -1
  175. package/dist/src/phone/ui-dump-binary.js +1 -1
  176. package/dist/src/session/client-history.d.ts +2 -0
  177. package/dist/src/session/client-history.js +3 -0
  178. package/dist/src/session/compact-history.js +1 -0
  179. package/package.json +1 -1
  180. package/dist/gateway/static/root/assets/gateway-realtime-store-Bxkv62qs.js +0 -1
  181. package/dist/gateway/static/root/assets/messages-DYDkJvXj.js +0 -3
  182. package/dist/gateway/static/root/assets/note-image-lightbox-ClPkeHe5.js +0 -1
  183. package/dist/gateway/static/root/assets/page-header-store-CoKMiYoi.js +0 -1
  184. package/dist/gateway/static/root/assets/session-manager-DjRWxXJG.js +0 -23
  185. package/dist/gateway/static/root/assets/settings-advanced-gate-BMHe9uwy.js +0 -1
  186. package/dist/gateway/static/root/assets/workspace-editor-agent-store-CqHcVFhS.js +0 -1
@@ -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{m as i}from"./chunk-KS7C4IRE-CiwuuyV8.js";import{i as a,n as o,o as s}from"./locale-store-B7y-RVe8.js";import{t as c}from"./messages-DYDkJvXj.js";import{t as l}from"./bot-DjLkhyZL.js";import{t as u}from"./popover-select-CEMWIrtY.js";import{t as d}from"./circle-alert-BEjgurr2.js";import{t as f}from"./coins-DjP27vUx.js";import{t as p}from"./database-CjjeZfRG.js";import{t as m}from"./gauge-C78eD2BA.js";import{t as h}from"./refresh-cw-BRlGaq2w.js";import{t as g}from"./timer-rCwGHjuO.js";import{t as _}from"./skeleton-BI5TyibZ.js";import{i as v}from"./vendor-swr-CdRzEUwF.js";import{t as y}from"./button-Cc4hUNTt.js";import{t as b}from"./sliding-tab-list-DuQyViqe.js";import{n as x,t as S}from"./settings-page-header-BLKI3_9N.js";import"./settings-page-layout-BqBVrkC9.js";import{t as ee}from"./xopc-cloud-account-card-DimGN59n.js";var C=e(t(),1),w=n();function T(e,t=Date.now()+1){let n=t-e*24*60*60*1e3;return new URLSearchParams({from:String(n),to:String(t)}).toString()}function E(e){return s(a(`/api/usage/summary?${e}`))}function D(e,t,n=20){let r=new URLSearchParams(e);return r.set(`limit`,String(n)),t&&r.set(`cursor`,t),s(a(`/api/usage/events?${r}`))}var O=r();function k(e,t){return new Intl.NumberFormat(t===`zh`?`zh-CN`:`en-US`,{notation:`compact`,maximumFractionDigits:1}).format(e)}function A(e){return`$${Number(e).toLocaleString(void 0,{minimumFractionDigits:0,maximumFractionDigits:6})}`}function j(e){let t=BigInt(e),n=String(t%10000n).padStart(4,`0`).replace(/0+$/,``);return`${t/10000n}${n?`.${n}`:``}`}function te(e,t){return new Intl.DateTimeFormat(t===`zh`?`zh-CN`:`en-US`,{month:`short`,day:`numeric`,hour:`2-digit`,minute:`2-digit`}).format(e)}function M(){let e=(0,w.c)(1),t;return e[0]===Symbol.for(`react.memo_cache_sentinel`)?(t=(0,O.jsxs)(`div`,{className:`space-y-4`,"aria-busy":`true`,children:[(0,O.jsx)(`div`,{className:`grid gap-3 sm:grid-cols-2 lg:grid-cols-4`,children:[0,1,2,3].map(N)}),(0,O.jsx)(_,{className:`h-52 rounded-xl`}),(0,O.jsx)(_,{className:`h-72 rounded-xl`})]}),e[0]=t):t=e[0],t}function N(e){return(0,O.jsx)(_,{className:`h-24 rounded-xl`},e)}function P(){let e=o(e=>e.language),t=c(e).usage,[n,r]=i(),a=[`7`,`30`,`90`].includes(n.get(`days`)??``)?n.get(`days`):`7`,s=n.get(`size`)===`50`?50:20,w=n.getAll(`cursor`),N=w.at(-1),[P]=(0,C.useState)(()=>Date.now()+1),F=Number(n.get(`to`)),I=Number.isSafeInteger(F)&&F>Number(a)*864e5?F:P,L=(0,C.useMemo)(()=>T(Number(a),I),[a,I]),R=v([`usage-summary`,L],()=>E(L),{refreshInterval:15e3}),z=v([`usage-events`,L,N,s],()=>D(L,N,s),{refreshInterval:15e3}),B=!R.data&&!R.error,V=R.error,H=e=>{let t=new URLSearchParams(n);t.set(`to`,String(I)),e(t),r(t)},U=e=>H(t=>{t.set(`days`,e),t.set(`to`,String(Date.now()+1)),t.delete(`cursor`),t.delete(`groupPage`)}),W=n.get(`group`)===`model`?`model`:`scenario`,G=[...W===`model`?R.data?.byModel??[]:R.data?.byCategory??[]].sort((e,t)=>t.totals.calls-e.totals.calls||e.key.localeCompare(t.key)),K=Math.max(1,Math.ceil((G?.length??0)/6)),q=Number(n.get(`groupPage`)),J=Math.min(K,Number.isSafeInteger(q)&&q>0?q:1),Y=G?.slice((J-1)*6,J*6),X=w.length+1,Z=R.data?.totals,ne=(Z?.billing?.cloud.calls??0)>0,Q=e=>{let n=e.billing?.cloud;return n?.calls?n.chargedCreditMicro===null?t.cloudUnconfirmed:`${n.pendingCalls+n.unavailableCalls>0?`≥ `:``}${j(n.chargedCreditMicro)} Credits`:t.noCloudCalls},$=e=>{let n=e.billing?.external;return n?.calls?n.unknownCostCalls===n.calls?t.costUnknown:`${n.unknownCostCalls>0?`≥ `:`≈ `}${A(n.estimatedCostUsd)}`:t.noExternalCalls},re=e=>e.billing?.source===`local`||e.provider!==`xopc-cloud`&&e.costSource===`local`?t.localSource:e.billing?.source===`xopc_cloud`||e.provider===`xopc-cloud`?t.cloudSource:t.externalSource,ie=e=>{let n=e.billing;return n?.source===`local`?t.localNoCharge:n?.source===`xopc_cloud`?n.state===`settled`&&n.chargedCreditMicro!==null?`${j(n.chargedCreditMicro)} Credits`:n.state===`released`?t.cloudReleased:n.state===`pending`?n.reservedCreditMicro===null?t.cloudPending:t.cloudPendingReserved.replace(`{{credits}}`,j(n.reservedCreditMicro)):t.cloudUnconfirmed:e.provider===`xopc-cloud`?t.cloudUnconfirmed:e.costSource===`local`?t.localNoCharge:e.estimatedCostUsd===void 0?t.costUnknown:`≈ ${A(e.estimatedCostUsd)}`},ae=e=>(0,O.jsxs)(`span`,{className:`flex flex-col items-end gap-1 text-xs`,children:[e.billing?.cloud.calls?(0,O.jsxs)(`span`,{children:[t.cloudSource,`: `,Q(e)]}):null,e.billing?.external.calls?(0,O.jsxs)(`span`,{children:[t.externalSource,`: `,$(e)]}):null,e.billing?.localCalls?(0,O.jsx)(`span`,{children:t.localNoCharge}):null,(0,O.jsxs)(`span`,{children:[e.calls,` `,t.callUnit]})]}),oe={"usage.reason.imageGeneration":t.reasons.imageGeneration,"usage.reason.audioTranscription":t.reasons.audioTranscription,"usage.reason.audioSpeech":t.reasons.audioSpeech,"usage.reason.agentAnswer":t.reasons.agentAnswer,"usage.reason.continueAfterTool":t.reasons.continueAfterTool,"usage.reason.backgroundReview":t.reasons.backgroundReview,"usage.reason.sessionCompaction":t.reasons.sessionCompaction,"usage.reason.sessionTitle":t.reasons.sessionTitle,"usage.reason.imageUnderstanding":t.reasons.imageUnderstanding,"usage.reason.webExtract":t.reasons.webExtract,"usage.reason.sessionSearch":t.reasons.sessionSearch,"usage.reason.noteGeneration":t.reasons.noteGeneration,"usage.reason.automationDraft":t.reasons.automationDraft,"usage.reason.taskPlanning":t.reasons.taskPlanning,"usage.reason.taskJudging":t.reasons.taskJudging,"usage.reason.voiceSummary":t.reasons.voiceSummary,"usage.reason.voiceSelection":t.reasons.voiceSelection,"usage.reason.homeAdvice":t.reasons.homeAdvice,"usage.reason.workDiscovery":t.reasons.workDiscovery,"usage.reason.workInvestigation":t.reasons.workInvestigation,"usage.reason.discussionAnalysis":t.reasons.discussionAnalysis,"usage.reason.textAssist":t.reasons.textAssist,"usage.reason.userModelInterpretation":t.reasons.userModelInterpretation,"usage.reason.other":t.reasons.other};return(0,O.jsxs)(x,{children:[(0,O.jsx)(S,{title:t.title,subtitle:t.subtitle,actions:(0,O.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,O.jsx)(`div`,{className:`w-36`,children:(0,O.jsx)(u,{value:a,allowEmpty:!1,ariaLabel:t.periodLabel,placeholder:t.periodLabel,options:[{value:`7`,label:t.last7Days},{value:`30`,label:t.last30Days},{value:`90`,label:t.last90Days}],onChange:U})}),(0,O.jsx)(y,{variant:`ghost`,"aria-label":t.refresh,title:t.refresh,onClick:()=>U(a),children:(0,O.jsx)(h,{className:`size-4`,"aria-hidden":!0})})]})}),B?(0,O.jsx)(M,{}):V?(0,O.jsxs)(`div`,{role:`alert`,className:`flex items-start gap-3 rounded-xl border border-edge bg-surface-inset p-4 text-sm text-fg-muted`,children:[(0,O.jsx)(d,{className:`mt-0.5 size-4 shrink-0 text-danger`,"aria-hidden":!0}),(0,O.jsxs)(`div`,{className:`space-y-2`,children:[(0,O.jsxs)(`div`,{children:[(0,O.jsx)(`p`,{className:`font-medium text-fg`,children:t.loadError}),(0,O.jsx)(`p`,{className:`mt-1`,children:String(V.message??V)})]}),(0,O.jsx)(y,{variant:`secondary`,onClick:()=>void Promise.all([R.mutate(),z.mutate()]),children:t.retry})]})]}):Z?(0,O.jsxs)(`div`,{className:`space-y-5`,children:[(0,O.jsx)(`h2`,{className:`text-sm font-semibold text-fg`,children:t.summaryLabel}),(0,O.jsx)(`section`,{"aria-label":t.summaryLabel,className:`grid gap-3 sm:grid-cols-2 lg:grid-cols-4`,children:[{label:t.cloudCharged,value:Q(Z),icon:f},{label:t.knownCost,value:$(Z),icon:f},{label:t.calls,value:Z.calls.toLocaleString(),icon:m},{label:t.tokens,value:k(Z.totalTokens,e),icon:p}].map(e=>(0,O.jsxs)(`div`,{className:`rounded-xl border border-edge bg-surface-panel p-4`,children:[(0,O.jsxs)(`div`,{className:`flex items-center gap-2 text-xs text-fg-muted`,children:[(0,O.jsx)(e.icon,{className:`size-4`,"aria-hidden":!0}),e.label]}),(0,O.jsx)(`div`,{className:`mt-2 text-xl font-semibold tabular-nums text-fg`,children:e.value})]},e.label))}),(Z.billing?.external.unknownCostCalls??0)>0?(0,O.jsx)(`p`,{className:`rounded-lg border border-edge bg-surface-inset px-3 py-2 text-xs leading-5 text-fg-muted`,children:Z.billing?.external.unknownCostCalls===Z.billing?.external.calls?t.allCostsUnknown:t.someCostsUnknown}):null,Z.billing?.cloud.calls?(0,O.jsxs)(`p`,{className:`rounded-lg border border-edge bg-surface-inset px-3 py-2 text-xs leading-5 text-fg-muted`,children:[t.cloudCoverage.replace(`{{pending}}`,String(Z.billing.cloud.pendingCalls)).replace(`{{unknown}}`,String(Z.billing.cloud.unavailableCalls)),Z.billing.cloud.reservedCreditMicro===null?``:` ${t.cloudReserved.replace(`{{credits}}`,j(Z.billing.cloud.reservedCreditMicro))}`]}):null,(0,O.jsxs)(`section`,{className:`overflow-hidden rounded-xl border border-edge bg-surface-panel`,children:[(0,O.jsxs)(`div`,{className:`flex flex-wrap items-center justify-between gap-3 border-b border-edge px-4 py-3`,children:[(0,O.jsxs)(`div`,{children:[(0,O.jsx)(`h2`,{className:`text-sm font-semibold text-fg`,children:t.distribution}),(0,O.jsx)(`p`,{className:`mt-1 text-xs text-fg-subtle`,children:t.distributionHint})]}),(0,O.jsx)(b,{className:`flex gap-1`,role:`group`,"aria-label":t.distribution,children:[`scenario`,`model`].map(e=>(0,O.jsx)(y,{variant:W===e?`secondary`:`ghost`,"aria-pressed":W===e,onClick:()=>H(t=>{t.set(`group`,e),t.delete(`groupPage`)}),children:e===`scenario`?t.byScenario:t.byModel},e))})]}),(0,O.jsx)(`div`,{className:`divide-y divide-edge-subtle px-4`,children:Y?.length?Y.map(e=>{let n=W===`scenario`?t.categories[e.key]??e.key:e.key;return(0,O.jsxs)(`div`,{className:`flex flex-col gap-3 py-3 text-sm sm:flex-row sm:items-center sm:justify-between`,children:[(0,O.jsxs)(`div`,{className:`min-w-0 flex-1`,children:[(0,O.jsx)(`p`,{className:`truncate font-medium text-fg`,title:n,children:n}),(0,O.jsx)(`div`,{className:`mt-2 h-1 max-w-64 overflow-hidden rounded-full bg-surface-inset`,"aria-hidden":!0,children:(0,O.jsx)(`div`,{className:`h-full rounded-full bg-accent`,style:{width:`${Z.calls?e.totals.calls/Z.calls*100:0}%`}})})]}),(0,O.jsx)(`div`,{className:`shrink-0 self-end tabular-nums text-fg-muted sm:self-auto`,children:ae(e.totals)})]},e.key)}):(0,O.jsx)(`p`,{className:`py-5 text-sm text-fg-subtle`,children:t.empty})}),K>1?(0,O.jsxs)(`div`,{className:`flex flex-wrap items-center justify-between gap-3 border-t border-edge px-4 py-3`,children:[(0,O.jsx)(`p`,{className:`text-xs text-fg-muted`,"aria-live":`polite`,children:t.groupPage.replace(`{{page}}`,String(J)).replace(`{{pages}}`,String(K)).replace(`{{count}}`,String(G?.length??0))}),(0,O.jsxs)(`div`,{className:`flex gap-2`,children:[(0,O.jsx)(y,{disabled:J===1,"aria-label":t.previousDistribution,onClick:()=>H(e=>e.set(`groupPage`,String(J-1))),children:t.previousPage}),(0,O.jsx)(y,{disabled:J===K,"aria-label":t.nextDistribution,onClick:()=>H(e=>e.set(`groupPage`,String(J+1))),children:t.nextPage})]})]}):null]}),(0,O.jsxs)(`section`,{className:`overflow-hidden rounded-xl border border-edge bg-surface-panel`,children:[(0,O.jsxs)(`div`,{className:`flex flex-wrap items-center justify-between gap-3 border-b border-edge px-4 py-3`,children:[(0,O.jsxs)(`div`,{children:[(0,O.jsx)(`h2`,{className:`text-sm font-semibold text-fg`,children:t.recentCalls}),(0,O.jsx)(`p`,{className:`mt-1 text-xs text-fg-subtle`,children:t.recentCallsHint})]}),(0,O.jsx)(`div`,{className:`w-36`,children:(0,O.jsx)(u,{value:String(s),allowEmpty:!1,ariaLabel:t.pageSize,placeholder:t.pageSize,options:[20,50].map(e=>({value:String(e),label:t.rowsPerPage.replace(`{{count}}`,String(e))})),onChange:e=>H(t=>{t.set(`size`,e),t.delete(`cursor`)})})})]}),(0,O.jsx)(`div`,{className:`divide-y divide-edge-subtle`,children:z.error?(0,O.jsxs)(`div`,{role:`alert`,className:`space-y-3 p-4 text-sm text-fg-muted`,children:[(0,O.jsx)(`p`,{children:t.loadError}),(0,O.jsx)(y,{onClick:()=>void z.mutate(),children:t.retry})]}):z.data?z.data.items.length?z.data.items.map(n=>(0,O.jsxs)(`article`,{className:`grid gap-2 px-4 py-3 text-sm sm:grid-cols-[minmax(0,1fr)_auto] sm:items-center`,children:[(0,O.jsxs)(`div`,{className:`min-w-0`,children:[(0,O.jsxs)(`div`,{className:`flex min-w-0 items-center gap-2`,children:[(0,O.jsx)(l,{className:`size-4 shrink-0 text-fg-subtle`,"aria-hidden":!0}),(0,O.jsx)(`span`,{className:`truncate font-medium text-fg`,children:oe[n.reasonKey]??t.reasons.other})]}),(0,O.jsxs)(`div`,{className:`mt-1 flex flex-wrap items-center gap-x-3 gap-y-1 text-xs text-fg-subtle`,children:[(0,O.jsxs)(`span`,{className:`min-w-0 [overflow-wrap:anywhere]`,children:[n.provider,`/`,n.model]}),(0,O.jsxs)(`span`,{className:`inline-flex items-center gap-1`,children:[(0,O.jsx)(g,{className:`size-3`,"aria-hidden":!0}),te(n.startedAt,e)]}),(0,O.jsx)(`span`,{className:`rounded border border-edge px-1.5 py-0.5`,children:re(n)}),(0,O.jsx)(`span`,{children:n.totalTokens===void 0?t.tokensUnknown:`${k(n.totalTokens,e)} tokens`})]})]}),(0,O.jsxs)(`div`,{className:`text-left tabular-nums text-fg sm:text-right`,children:[ie(n),(0,O.jsx)(`div`,{className:`mt-0.5 text-xs text-fg-subtle`,children:t.status[n.status]??n.status})]})]},n.id)):(0,O.jsx)(`p`,{className:`px-4 py-8 text-center text-sm text-fg-subtle`,children:t.empty}):(0,O.jsx)(`div`,{"aria-busy":`true`,className:`space-y-3 p-4`,children:[0,1,2,3].map(e=>(0,O.jsx)(_,{className:`h-16`},e))})}),(0,O.jsxs)(`div`,{className:`flex flex-wrap items-center justify-between gap-3 border-t border-edge px-4 py-3`,children:[(0,O.jsx)(`p`,{className:`text-xs text-fg-muted`,"aria-live":`polite`,children:t.eventPage.replace(`{{page}}`,String(X)).replace(`{{count}}`,String(z.data?.items.length??0))}),(0,O.jsxs)(`nav`,{className:`flex gap-2`,"aria-label":t.pagination,children:[X>1?(0,O.jsx)(y,{variant:`ghost`,onClick:()=>H(e=>e.delete(`cursor`)),children:t.firstPage}):null,(0,O.jsx)(y,{disabled:X===1,onClick:()=>H(e=>{e.delete(`cursor`),w.slice(0,-1).forEach(t=>e.append(`cursor`,t))}),children:t.previousPage}),(0,O.jsx)(y,{disabled:!z.data?.nextCursor||!!z.error,onClick:()=>H(e=>{z.data?.nextCursor&&e.append(`cursor`,z.data.nextCursor)}),children:t.nextPage})]})]})]}),(0,O.jsxs)(`details`,{className:`rounded-xl border border-edge bg-surface-panel p-4`,children:[(0,O.jsx)(`summary`,{className:`cursor-pointer text-sm font-medium text-fg focus-visible:outline-accent`,children:t.billingDetails}),(0,O.jsx)(`p`,{className:`mt-3 text-xs leading-5 text-fg-muted`,children:t.cloudBillingHint}),(0,O.jsx)(`a`,{className:`mt-2 inline-block text-xs text-accent-fg hover:underline`,href:`https://console.xopc.ai/models/billing`,target:`_blank`,rel:`noreferrer`,children:t.cloudCreditsLabel}),ne?(0,O.jsx)(`div`,{className:`mt-4`,children:(0,O.jsx)(ee,{labels:c(e).capabilitiesSettings.xopcCloudAccount})}):null]})]}):null]})}export{P as UsageSettingsPage};
1
+ import{i as e}from"./rolldown-runtime-aKtaBQYM.js";import{a as t,n,t as r}from"./vendor-react-BOUWij0V.js";import{m as i}from"./chunk-KS7C4IRE-CiwuuyV8.js";import{i as a,n as o,o as s}from"./locale-store-B6OrWgY1.js";import{t as c}from"./messages-jwdBhfL9.js";import{t as l}from"./bot-DjLkhyZL.js";import{t as u}from"./popover-select-CEMWIrtY.js";import{t as d}from"./circle-alert-BEjgurr2.js";import{t as f}from"./coins-DjP27vUx.js";import{t as p}from"./database-CjjeZfRG.js";import{t as m}from"./gauge-C78eD2BA.js";import{t as h}from"./refresh-cw-BRlGaq2w.js";import{t as g}from"./timer-rCwGHjuO.js";import{t as _}from"./skeleton-BI5TyibZ.js";import{i as v}from"./vendor-swr-CdRzEUwF.js";import{t as y}from"./button-Cc4hUNTt.js";import{t as b}from"./sliding-tab-list-DuQyViqe.js";import{n as x,t as S}from"./settings-page-header-BAN34UQi.js";import"./settings-page-layout-B5TVFBV2.js";import{t as ee}from"./xopc-cloud-account-card-BkdW2p3v.js";var C=e(t(),1),w=n();function T(e,t=Date.now()+1){let n=t-e*24*60*60*1e3;return new URLSearchParams({from:String(n),to:String(t)}).toString()}function E(e){return s(a(`/api/usage/summary?${e}`))}function D(e,t,n=20){let r=new URLSearchParams(e);return r.set(`limit`,String(n)),t&&r.set(`cursor`,t),s(a(`/api/usage/events?${r}`))}var O=r();function k(e,t){return new Intl.NumberFormat(t===`zh`?`zh-CN`:`en-US`,{notation:`compact`,maximumFractionDigits:1}).format(e)}function A(e){return`$${Number(e).toLocaleString(void 0,{minimumFractionDigits:0,maximumFractionDigits:6})}`}function j(e){let t=BigInt(e),n=String(t%10000n).padStart(4,`0`).replace(/0+$/,``);return`${t/10000n}${n?`.${n}`:``}`}function te(e,t){return new Intl.DateTimeFormat(t===`zh`?`zh-CN`:`en-US`,{month:`short`,day:`numeric`,hour:`2-digit`,minute:`2-digit`}).format(e)}function M(){let e=(0,w.c)(1),t;return e[0]===Symbol.for(`react.memo_cache_sentinel`)?(t=(0,O.jsxs)(`div`,{className:`space-y-4`,"aria-busy":`true`,children:[(0,O.jsx)(`div`,{className:`grid gap-3 sm:grid-cols-2 lg:grid-cols-4`,children:[0,1,2,3].map(N)}),(0,O.jsx)(_,{className:`h-52 rounded-xl`}),(0,O.jsx)(_,{className:`h-72 rounded-xl`})]}),e[0]=t):t=e[0],t}function N(e){return(0,O.jsx)(_,{className:`h-24 rounded-xl`},e)}function P(){let e=o(e=>e.language),t=c(e).usage,[n,r]=i(),a=[`7`,`30`,`90`].includes(n.get(`days`)??``)?n.get(`days`):`7`,s=n.get(`size`)===`50`?50:20,w=n.getAll(`cursor`),N=w.at(-1),[P]=(0,C.useState)(()=>Date.now()+1),F=Number(n.get(`to`)),I=Number.isSafeInteger(F)&&F>Number(a)*864e5?F:P,L=(0,C.useMemo)(()=>T(Number(a),I),[a,I]),R=v([`usage-summary`,L],()=>E(L),{refreshInterval:15e3}),z=v([`usage-events`,L,N,s],()=>D(L,N,s),{refreshInterval:15e3}),B=!R.data&&!R.error,V=R.error,H=e=>{let t=new URLSearchParams(n);t.set(`to`,String(I)),e(t),r(t)},U=e=>H(t=>{t.set(`days`,e),t.set(`to`,String(Date.now()+1)),t.delete(`cursor`),t.delete(`groupPage`)}),W=n.get(`group`)===`model`?`model`:`scenario`,G=[...W===`model`?R.data?.byModel??[]:R.data?.byCategory??[]].sort((e,t)=>t.totals.calls-e.totals.calls||e.key.localeCompare(t.key)),K=Math.max(1,Math.ceil((G?.length??0)/6)),q=Number(n.get(`groupPage`)),J=Math.min(K,Number.isSafeInteger(q)&&q>0?q:1),Y=G?.slice((J-1)*6,J*6),X=w.length+1,Z=R.data?.totals,ne=(Z?.billing?.cloud.calls??0)>0,Q=e=>{let n=e.billing?.cloud;return n?.calls?n.chargedCreditMicro===null?t.cloudUnconfirmed:`${n.pendingCalls+n.unavailableCalls>0?`≥ `:``}${j(n.chargedCreditMicro)} Credits`:t.noCloudCalls},$=e=>{let n=e.billing?.external;return n?.calls?n.unknownCostCalls===n.calls?t.costUnknown:`${n.unknownCostCalls>0?`≥ `:`≈ `}${A(n.estimatedCostUsd)}`:t.noExternalCalls},re=e=>e.billing?.source===`local`||e.provider!==`xopc-cloud`&&e.costSource===`local`?t.localSource:e.billing?.source===`xopc_cloud`||e.provider===`xopc-cloud`?t.cloudSource:t.externalSource,ie=e=>{let n=e.billing;return n?.source===`local`?t.localNoCharge:n?.source===`xopc_cloud`?n.state===`settled`&&n.chargedCreditMicro!==null?`${j(n.chargedCreditMicro)} Credits`:n.state===`released`?t.cloudReleased:n.state===`pending`?n.reservedCreditMicro===null?t.cloudPending:t.cloudPendingReserved.replace(`{{credits}}`,j(n.reservedCreditMicro)):t.cloudUnconfirmed:e.provider===`xopc-cloud`?t.cloudUnconfirmed:e.costSource===`local`?t.localNoCharge:e.estimatedCostUsd===void 0?t.costUnknown:`≈ ${A(e.estimatedCostUsd)}`},ae=e=>(0,O.jsxs)(`span`,{className:`flex flex-col items-end gap-1 text-xs`,children:[e.billing?.cloud.calls?(0,O.jsxs)(`span`,{children:[t.cloudSource,`: `,Q(e)]}):null,e.billing?.external.calls?(0,O.jsxs)(`span`,{children:[t.externalSource,`: `,$(e)]}):null,e.billing?.localCalls?(0,O.jsx)(`span`,{children:t.localNoCharge}):null,(0,O.jsxs)(`span`,{children:[e.calls,` `,t.callUnit]})]}),oe={"usage.reason.imageGeneration":t.reasons.imageGeneration,"usage.reason.audioTranscription":t.reasons.audioTranscription,"usage.reason.audioSpeech":t.reasons.audioSpeech,"usage.reason.agentAnswer":t.reasons.agentAnswer,"usage.reason.continueAfterTool":t.reasons.continueAfterTool,"usage.reason.backgroundReview":t.reasons.backgroundReview,"usage.reason.sessionCompaction":t.reasons.sessionCompaction,"usage.reason.sessionTitle":t.reasons.sessionTitle,"usage.reason.imageUnderstanding":t.reasons.imageUnderstanding,"usage.reason.webExtract":t.reasons.webExtract,"usage.reason.sessionSearch":t.reasons.sessionSearch,"usage.reason.noteGeneration":t.reasons.noteGeneration,"usage.reason.automationDraft":t.reasons.automationDraft,"usage.reason.taskPlanning":t.reasons.taskPlanning,"usage.reason.taskJudging":t.reasons.taskJudging,"usage.reason.voiceSummary":t.reasons.voiceSummary,"usage.reason.voiceSelection":t.reasons.voiceSelection,"usage.reason.homeAdvice":t.reasons.homeAdvice,"usage.reason.workDiscovery":t.reasons.workDiscovery,"usage.reason.workInvestigation":t.reasons.workInvestigation,"usage.reason.discussionAnalysis":t.reasons.discussionAnalysis,"usage.reason.textAssist":t.reasons.textAssist,"usage.reason.userModelInterpretation":t.reasons.userModelInterpretation,"usage.reason.other":t.reasons.other};return(0,O.jsxs)(x,{children:[(0,O.jsx)(S,{title:t.title,subtitle:t.subtitle,actions:(0,O.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,O.jsx)(`div`,{className:`w-36`,children:(0,O.jsx)(u,{value:a,allowEmpty:!1,ariaLabel:t.periodLabel,placeholder:t.periodLabel,options:[{value:`7`,label:t.last7Days},{value:`30`,label:t.last30Days},{value:`90`,label:t.last90Days}],onChange:U})}),(0,O.jsx)(y,{variant:`ghost`,"aria-label":t.refresh,title:t.refresh,onClick:()=>U(a),children:(0,O.jsx)(h,{className:`size-4`,"aria-hidden":!0})})]})}),B?(0,O.jsx)(M,{}):V?(0,O.jsxs)(`div`,{role:`alert`,className:`flex items-start gap-3 rounded-xl border border-edge bg-surface-inset p-4 text-sm text-fg-muted`,children:[(0,O.jsx)(d,{className:`mt-0.5 size-4 shrink-0 text-danger`,"aria-hidden":!0}),(0,O.jsxs)(`div`,{className:`space-y-2`,children:[(0,O.jsxs)(`div`,{children:[(0,O.jsx)(`p`,{className:`font-medium text-fg`,children:t.loadError}),(0,O.jsx)(`p`,{className:`mt-1`,children:String(V.message??V)})]}),(0,O.jsx)(y,{variant:`secondary`,onClick:()=>void Promise.all([R.mutate(),z.mutate()]),children:t.retry})]})]}):Z?(0,O.jsxs)(`div`,{className:`space-y-5`,children:[(0,O.jsx)(`h2`,{className:`text-sm font-semibold text-fg`,children:t.summaryLabel}),(0,O.jsx)(`section`,{"aria-label":t.summaryLabel,className:`grid gap-3 sm:grid-cols-2 lg:grid-cols-4`,children:[{label:t.cloudCharged,value:Q(Z),icon:f},{label:t.knownCost,value:$(Z),icon:f},{label:t.calls,value:Z.calls.toLocaleString(),icon:m},{label:t.tokens,value:k(Z.totalTokens,e),icon:p}].map(e=>(0,O.jsxs)(`div`,{className:`rounded-xl border border-edge bg-surface-panel p-4`,children:[(0,O.jsxs)(`div`,{className:`flex items-center gap-2 text-xs text-fg-muted`,children:[(0,O.jsx)(e.icon,{className:`size-4`,"aria-hidden":!0}),e.label]}),(0,O.jsx)(`div`,{className:`mt-2 text-xl font-semibold tabular-nums text-fg`,children:e.value})]},e.label))}),(Z.billing?.external.unknownCostCalls??0)>0?(0,O.jsx)(`p`,{className:`rounded-lg border border-edge bg-surface-inset px-3 py-2 text-xs leading-5 text-fg-muted`,children:Z.billing?.external.unknownCostCalls===Z.billing?.external.calls?t.allCostsUnknown:t.someCostsUnknown}):null,Z.billing?.cloud.calls?(0,O.jsxs)(`p`,{className:`rounded-lg border border-edge bg-surface-inset px-3 py-2 text-xs leading-5 text-fg-muted`,children:[t.cloudCoverage.replace(`{{pending}}`,String(Z.billing.cloud.pendingCalls)).replace(`{{unknown}}`,String(Z.billing.cloud.unavailableCalls)),Z.billing.cloud.reservedCreditMicro===null?``:` ${t.cloudReserved.replace(`{{credits}}`,j(Z.billing.cloud.reservedCreditMicro))}`]}):null,(0,O.jsxs)(`section`,{className:`overflow-hidden rounded-xl border border-edge bg-surface-panel`,children:[(0,O.jsxs)(`div`,{className:`flex flex-wrap items-center justify-between gap-3 border-b border-edge px-4 py-3`,children:[(0,O.jsxs)(`div`,{children:[(0,O.jsx)(`h2`,{className:`text-sm font-semibold text-fg`,children:t.distribution}),(0,O.jsx)(`p`,{className:`mt-1 text-xs text-fg-subtle`,children:t.distributionHint})]}),(0,O.jsx)(b,{className:`flex gap-1`,role:`group`,"aria-label":t.distribution,children:[`scenario`,`model`].map(e=>(0,O.jsx)(y,{variant:W===e?`secondary`:`ghost`,"aria-pressed":W===e,onClick:()=>H(t=>{t.set(`group`,e),t.delete(`groupPage`)}),children:e===`scenario`?t.byScenario:t.byModel},e))})]}),(0,O.jsx)(`div`,{className:`divide-y divide-edge-subtle px-4`,children:Y?.length?Y.map(e=>{let n=W===`scenario`?t.categories[e.key]??e.key:e.key;return(0,O.jsxs)(`div`,{className:`flex flex-col gap-3 py-3 text-sm sm:flex-row sm:items-center sm:justify-between`,children:[(0,O.jsxs)(`div`,{className:`min-w-0 flex-1`,children:[(0,O.jsx)(`p`,{className:`truncate font-medium text-fg`,title:n,children:n}),(0,O.jsx)(`div`,{className:`mt-2 h-1 max-w-64 overflow-hidden rounded-full bg-surface-inset`,"aria-hidden":!0,children:(0,O.jsx)(`div`,{className:`h-full rounded-full bg-accent`,style:{width:`${Z.calls?e.totals.calls/Z.calls*100:0}%`}})})]}),(0,O.jsx)(`div`,{className:`shrink-0 self-end tabular-nums text-fg-muted sm:self-auto`,children:ae(e.totals)})]},e.key)}):(0,O.jsx)(`p`,{className:`py-5 text-sm text-fg-subtle`,children:t.empty})}),K>1?(0,O.jsxs)(`div`,{className:`flex flex-wrap items-center justify-between gap-3 border-t border-edge px-4 py-3`,children:[(0,O.jsx)(`p`,{className:`text-xs text-fg-muted`,"aria-live":`polite`,children:t.groupPage.replace(`{{page}}`,String(J)).replace(`{{pages}}`,String(K)).replace(`{{count}}`,String(G?.length??0))}),(0,O.jsxs)(`div`,{className:`flex gap-2`,children:[(0,O.jsx)(y,{disabled:J===1,"aria-label":t.previousDistribution,onClick:()=>H(e=>e.set(`groupPage`,String(J-1))),children:t.previousPage}),(0,O.jsx)(y,{disabled:J===K,"aria-label":t.nextDistribution,onClick:()=>H(e=>e.set(`groupPage`,String(J+1))),children:t.nextPage})]})]}):null]}),(0,O.jsxs)(`section`,{className:`overflow-hidden rounded-xl border border-edge bg-surface-panel`,children:[(0,O.jsxs)(`div`,{className:`flex flex-wrap items-center justify-between gap-3 border-b border-edge px-4 py-3`,children:[(0,O.jsxs)(`div`,{children:[(0,O.jsx)(`h2`,{className:`text-sm font-semibold text-fg`,children:t.recentCalls}),(0,O.jsx)(`p`,{className:`mt-1 text-xs text-fg-subtle`,children:t.recentCallsHint})]}),(0,O.jsx)(`div`,{className:`w-36`,children:(0,O.jsx)(u,{value:String(s),allowEmpty:!1,ariaLabel:t.pageSize,placeholder:t.pageSize,options:[20,50].map(e=>({value:String(e),label:t.rowsPerPage.replace(`{{count}}`,String(e))})),onChange:e=>H(t=>{t.set(`size`,e),t.delete(`cursor`)})})})]}),(0,O.jsx)(`div`,{className:`divide-y divide-edge-subtle`,children:z.error?(0,O.jsxs)(`div`,{role:`alert`,className:`space-y-3 p-4 text-sm text-fg-muted`,children:[(0,O.jsx)(`p`,{children:t.loadError}),(0,O.jsx)(y,{onClick:()=>void z.mutate(),children:t.retry})]}):z.data?z.data.items.length?z.data.items.map(n=>(0,O.jsxs)(`article`,{className:`grid gap-2 px-4 py-3 text-sm sm:grid-cols-[minmax(0,1fr)_auto] sm:items-center`,children:[(0,O.jsxs)(`div`,{className:`min-w-0`,children:[(0,O.jsxs)(`div`,{className:`flex min-w-0 items-center gap-2`,children:[(0,O.jsx)(l,{className:`size-4 shrink-0 text-fg-subtle`,"aria-hidden":!0}),(0,O.jsx)(`span`,{className:`truncate font-medium text-fg`,children:oe[n.reasonKey]??t.reasons.other})]}),(0,O.jsxs)(`div`,{className:`mt-1 flex flex-wrap items-center gap-x-3 gap-y-1 text-xs text-fg-subtle`,children:[(0,O.jsxs)(`span`,{className:`min-w-0 [overflow-wrap:anywhere]`,children:[n.provider,`/`,n.model]}),(0,O.jsxs)(`span`,{className:`inline-flex items-center gap-1`,children:[(0,O.jsx)(g,{className:`size-3`,"aria-hidden":!0}),te(n.startedAt,e)]}),(0,O.jsx)(`span`,{className:`rounded border border-edge px-1.5 py-0.5`,children:re(n)}),(0,O.jsx)(`span`,{children:n.totalTokens===void 0?t.tokensUnknown:`${k(n.totalTokens,e)} tokens`})]})]}),(0,O.jsxs)(`div`,{className:`text-left tabular-nums text-fg sm:text-right`,children:[ie(n),(0,O.jsx)(`div`,{className:`mt-0.5 text-xs text-fg-subtle`,children:t.status[n.status]??n.status})]})]},n.id)):(0,O.jsx)(`p`,{className:`px-4 py-8 text-center text-sm text-fg-subtle`,children:t.empty}):(0,O.jsx)(`div`,{"aria-busy":`true`,className:`space-y-3 p-4`,children:[0,1,2,3].map(e=>(0,O.jsx)(_,{className:`h-16`},e))})}),(0,O.jsxs)(`div`,{className:`flex flex-wrap items-center justify-between gap-3 border-t border-edge px-4 py-3`,children:[(0,O.jsx)(`p`,{className:`text-xs text-fg-muted`,"aria-live":`polite`,children:t.eventPage.replace(`{{page}}`,String(X)).replace(`{{count}}`,String(z.data?.items.length??0))}),(0,O.jsxs)(`nav`,{className:`flex gap-2`,"aria-label":t.pagination,children:[X>1?(0,O.jsx)(y,{variant:`ghost`,onClick:()=>H(e=>e.delete(`cursor`)),children:t.firstPage}):null,(0,O.jsx)(y,{disabled:X===1,onClick:()=>H(e=>{e.delete(`cursor`),w.slice(0,-1).forEach(t=>e.append(`cursor`,t))}),children:t.previousPage}),(0,O.jsx)(y,{disabled:!z.data?.nextCursor||!!z.error,onClick:()=>H(e=>{z.data?.nextCursor&&e.append(`cursor`,z.data.nextCursor)}),children:t.nextPage})]})]})]}),(0,O.jsxs)(`details`,{className:`rounded-xl border border-edge bg-surface-panel p-4`,children:[(0,O.jsx)(`summary`,{className:`cursor-pointer text-sm font-medium text-fg focus-visible:outline-accent`,children:t.billingDetails}),(0,O.jsx)(`p`,{className:`mt-3 text-xs leading-5 text-fg-muted`,children:t.cloudBillingHint}),(0,O.jsx)(`a`,{className:`mt-2 inline-block text-xs text-accent-fg hover:underline`,href:`https://console.xopc.ai/models/billing`,target:`_blank`,rel:`noreferrer`,children:t.cloudCreditsLabel}),ne?(0,O.jsx)(`div`,{className:`mt-4`,children:(0,O.jsx)(ee,{labels:c(e).capabilitiesSettings.xopcCloudAccount})}):null]})]}):null]})}export{P as UsageSettingsPage};
@@ -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{n as i}from"./locale-store-B7y-RVe8.js";import{t as a}from"./check-DUBLcKHA.js";import{t as o}from"./circle-alert-BEjgurr2.js";import{t as s}from"./loader-circle-CifKLtgG.js";import{t as c}from"./cn-0WouolD0.js";var l=n(),u=r();function d(e){let t=(0,l.c)(21),{status:n,error:r,className:d}=e,p=i(f)===`zh`;if(n===`idle`)return null;let m=n===`saving`?p?`正在保存…`:`Saving…`:n===`saved`?p?`已自动保存`:`Saved automatically`:n===`error`?r||(p?`自动保存失败`:`Autosave failed`):n===`dirty`?p?`编辑中,将自动保存`:`Editing — autosave pending`:``,h=n===`error`?`text-danger`:n===`saved`?`text-success`:`text-fg-subtle`,g;t[0]!==d||t[1]!==h?(g=c(`inline-flex min-w-0 items-center gap-1.5 text-xs`,h,d),t[0]=d,t[1]=h,t[2]=g):g=t[2];let _;t[3]===n?_=t[4]:(_=n===`saving`?(0,u.jsx)(s,{className:`size-3.5 shrink-0 animate-spin`,"aria-hidden":!0}):null,t[3]=n,t[4]=_);let v;t[5]===n?v=t[6]:(v=n===`saved`?(0,u.jsx)(a,{className:`size-3.5 shrink-0`,"aria-hidden":!0}):null,t[5]=n,t[6]=v);let y;t[7]===n?y=t[8]:(y=n===`error`?(0,u.jsx)(o,{className:`size-3.5 shrink-0`,"aria-hidden":!0}):null,t[7]=n,t[8]=y);let b;t[9]===n?b=t[10]:(b=n===`dirty`?(0,u.jsx)(`span`,{className:`size-1.5 shrink-0 rounded-full bg-current`,"aria-hidden":!0}):null,t[9]=n,t[10]=b);let x;t[11]===m?x=t[12]:(x=(0,u.jsx)(`span`,{className:`truncate`,children:m}),t[11]=m,t[12]=x);let S;return t[13]!==m||t[14]!==g||t[15]!==_||t[16]!==v||t[17]!==y||t[18]!==b||t[19]!==x?(S=(0,u.jsxs)(`span`,{className:g,role:`status`,"aria-live":`polite`,title:m,children:[_,v,y,b,x]}),t[13]=m,t[14]=g,t[15]=_,t[16]=v,t[17]=y,t[18]=b,t[19]=x,t[20]=S):S=t[20],S}function f(e){return e.language}var p=e(t(),1);function m({value:e,dirty:t,onSave:n,enabled:r=!0,delayMs:i=700,validate:a,serialize:o=JSON.stringify}){let[s,c]=(0,p.useState)(`idle`),[l,u]=(0,p.useState)(null),d=(0,p.useRef)(e),f=(0,p.useRef)(n),m=(0,p.useRef)(a),h=(0,p.useRef)(o),g=(0,p.useRef)(null),_=(0,p.useRef)(!1),v=(0,p.useRef)(null),y=(0,p.useRef)(null),b=(0,p.useRef)(null),x=(0,p.useRef)(!0);d.current=e,f.current=n,m.current=a,h.current=o;let S=(0,p.useCallback)(()=>{g.current!==null&&(window.clearTimeout(g.current),g.current=null)},[]),C=(0,p.useCallback)(async e=>{S();let t=h.current(e);b.current=t;let n=m.current?.(e)??null;if(n){u(n),c(`error`);return}if(_.current){v.current=e;return}_.current=!0,u(null),c(`saving`);try{await f.current(e),y.current=t,x.current&&c(`saved`)}catch(e){x.current&&(u(e instanceof Error?e.message:String(e)),c(`error`))}finally{_.current=!1;let e=v.current;v.current=null,e&&h.current(e)!==y.current&&C(e)}},[S]),w=(0,p.useCallback)(()=>{let e=d.current;!r||!t||e===null||C(e)},[t,r,C]),T=(0,p.useCallback)(e=>{let t=e??d.current;!r||t===null||C(t)},[r,C]);return(0,p.useEffect)(()=>{if(!r||!t||e===null){S(),!t&&s===`dirty`&&c(`idle`);return}let n=o(e);if(n!==y.current&&!(s===`error`&&n===b.current))return c(e=>e===`saving`?e:`dirty`),S(),g.current=window.setTimeout(()=>void C(e),i),S},[S,i,t,r,C,o,s,e]),(0,p.useEffect)(()=>(x.current=!0,()=>{x.current=!1,S()}),[S]),(0,p.useEffect)(()=>{if(s!==`saved`)return;let e=window.setTimeout(()=>c(`idle`),1600);return()=>window.clearTimeout(e)},[s]),{status:s,error:l,flush:w,saveNow:T,retry:w,onBlurCapture:w}}export{d as n,m 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{n as i}from"./locale-store-B6OrWgY1.js";import{t as a}from"./check-DUBLcKHA.js";import{t as o}from"./circle-alert-BEjgurr2.js";import{t as s}from"./loader-circle-CifKLtgG.js";import{t as c}from"./cn-0WouolD0.js";var l=n(),u=r();function d(e){let t=(0,l.c)(21),{status:n,error:r,className:d}=e,p=i(f)===`zh`;if(n===`idle`)return null;let m=n===`saving`?p?`正在保存…`:`Saving…`:n===`saved`?p?`已自动保存`:`Saved automatically`:n===`error`?r||(p?`自动保存失败`:`Autosave failed`):n===`dirty`?p?`编辑中,将自动保存`:`Editing — autosave pending`:``,h=n===`error`?`text-danger`:n===`saved`?`text-success`:`text-fg-subtle`,g;t[0]!==d||t[1]!==h?(g=c(`inline-flex min-w-0 items-center gap-1.5 text-xs`,h,d),t[0]=d,t[1]=h,t[2]=g):g=t[2];let _;t[3]===n?_=t[4]:(_=n===`saving`?(0,u.jsx)(s,{className:`size-3.5 shrink-0 animate-spin`,"aria-hidden":!0}):null,t[3]=n,t[4]=_);let v;t[5]===n?v=t[6]:(v=n===`saved`?(0,u.jsx)(a,{className:`size-3.5 shrink-0`,"aria-hidden":!0}):null,t[5]=n,t[6]=v);let y;t[7]===n?y=t[8]:(y=n===`error`?(0,u.jsx)(o,{className:`size-3.5 shrink-0`,"aria-hidden":!0}):null,t[7]=n,t[8]=y);let b;t[9]===n?b=t[10]:(b=n===`dirty`?(0,u.jsx)(`span`,{className:`size-1.5 shrink-0 rounded-full bg-current`,"aria-hidden":!0}):null,t[9]=n,t[10]=b);let x;t[11]===m?x=t[12]:(x=(0,u.jsx)(`span`,{className:`truncate`,children:m}),t[11]=m,t[12]=x);let S;return t[13]!==m||t[14]!==g||t[15]!==_||t[16]!==v||t[17]!==y||t[18]!==b||t[19]!==x?(S=(0,u.jsxs)(`span`,{className:g,role:`status`,"aria-live":`polite`,title:m,children:[_,v,y,b,x]}),t[13]=m,t[14]=g,t[15]=_,t[16]=v,t[17]=y,t[18]=b,t[19]=x,t[20]=S):S=t[20],S}function f(e){return e.language}var p=e(t(),1);function m({value:e,dirty:t,onSave:n,enabled:r=!0,delayMs:i=700,validate:a,serialize:o=JSON.stringify}){let[s,c]=(0,p.useState)(`idle`),[l,u]=(0,p.useState)(null),d=(0,p.useRef)(e),f=(0,p.useRef)(n),m=(0,p.useRef)(a),h=(0,p.useRef)(o),g=(0,p.useRef)(null),_=(0,p.useRef)(!1),v=(0,p.useRef)(null),y=(0,p.useRef)(null),b=(0,p.useRef)(null),x=(0,p.useRef)(!0);d.current=e,f.current=n,m.current=a,h.current=o;let S=(0,p.useCallback)(()=>{g.current!==null&&(window.clearTimeout(g.current),g.current=null)},[]),C=(0,p.useCallback)(async e=>{S();let t=h.current(e);b.current=t;let n=m.current?.(e)??null;if(n){u(n),c(`error`);return}if(_.current){v.current=e;return}_.current=!0,u(null),c(`saving`);try{await f.current(e),y.current=t,x.current&&c(`saved`)}catch(e){x.current&&(u(e instanceof Error?e.message:String(e)),c(`error`))}finally{_.current=!1;let e=v.current;v.current=null,e&&h.current(e)!==y.current&&C(e)}},[S]),w=(0,p.useCallback)(()=>{let e=d.current;!r||!t||e===null||C(e)},[t,r,C]),T=(0,p.useCallback)(e=>{let t=e??d.current;!r||t===null||C(t)},[r,C]);return(0,p.useEffect)(()=>{if(!r||!t||e===null){S(),!t&&s===`dirty`&&c(`idle`);return}let n=o(e);if(n!==y.current&&!(s===`error`&&n===b.current))return c(e=>e===`saving`?e:`dirty`),S(),g.current=window.setTimeout(()=>void C(e),i),S},[S,i,t,r,C,o,s,e]),(0,p.useEffect)(()=>(x.current=!0,()=>{x.current=!1,S()}),[S]),(0,p.useEffect)(()=>{if(s!==`saved`)return;let e=window.setTimeout(()=>c(`idle`),1600);return()=>window.clearTimeout(e)},[s]),{status:s,error:l,flush:w,saveNow:T,retry:w,onBlurCapture:w}}export{d as n,m as t};
@@ -1,2 +1,2 @@
1
1
  const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["assets/attachment-load-DrVGNxJm.js","assets/rolldown-runtime-aKtaBQYM.js","assets/attachment-utils-core-BIOUBrpT.js"])))=>i.map(i=>d[i]);
2
- import{i as e}from"./rolldown-runtime-aKtaBQYM.js";import{a as t,n,t as r}from"./vendor-react-BOUWij0V.js";import{t as i}from"./preload-helper-Czpn1I53.js";import{i as a,n as o,o as s}from"./locale-store-B7y-RVe8.js";import{t as c}from"./messages-DYDkJvXj.js";import{o as l,r as u,s as d,t as f}from"./dist-BGTk37IG.js";import{t as p}from"./chevron-left-DqFhpbvK.js";import{t as m}from"./chevron-right-BweFrslA.js";import{n as h,t as g}from"./file-BqMS_3DT.js";import{a as _,b as v,l as y,n as b,t as x,x as S}from"./use-file-preview-expanded-DFzy6iVy.js";import{t as C}from"./mic-CuUb7zc-.js";import{n as w}from"./share-link-dialog-C2LyeNzj.js";import{t as T}from"./cn-0WouolD0.js";import{r as ee,t as E}from"./constants-DBtMsXdW.js";import{r as D}from"./tasks-DRmd6sWt.js";import{a as O,i as k,o as A}from"./capabilities-u2z_KFRt.js";import{t as j}from"./capabilities-LC-yEQYo.js";import{r as M}from"./attachment-utils-core-BIOUBrpT.js";import{a as te,n as ne,s as N,t as re}from"./file-preview-surface-BaMGmCbw.js";import{n as P}from"./interaction-BdhHBbYa.js";import{n as ie}from"./electron-env-DHOGevH3.js";import{i as F}from"./skill-wire-pattern-BPpeIcCi.js";async function I(e){return D.parse(await s(a(`/api/tasks`),{method:`POST`,body:JSON.stringify(e)}))}async function L(e){return j(`xopc.tasks.get`,{id:e})}async function R(e){return s(a(`/api/tasks/${encodeURIComponent(e)}/conversation`),{method:`POST`})}async function z(e,t,n){return await s(a(`/api/tasks/${encodeURIComponent(e)}`),{method:`PATCH`,body:JSON.stringify({...t,expectedVersion:n})}),L(e)}async function ae(e){await s(a(`/api/tasks/${encodeURIComponent(e)}`),{method:`DELETE`})}async function B(e,t,n,r=crypto.randomUUID(),i=`api`){return await s(a(`/api/tasks/${encodeURIComponent(e)}/commands`),{method:`POST`,body:JSON.stringify({idempotencyKey:r,expectedVersion:n,command:t,source:i})}),L(e)}async function V(e,t,n,r,i){return await s(a(`/api/tasks/${encodeURIComponent(e)}/criteria/${t}/review`),{method:`PUT`,body:JSON.stringify({status:n,expectedVersion:r,contractVersion:i})}),L(e)}async function H(e,t,n){return await s(a(`/api/task-runs/${encodeURIComponent(t)}/cancel`),{method:`POST`,body:JSON.stringify({expectedVersion:n,reason:`Cancelled by user`})}),L(e)}async function U(e,t,n){return await s(a(`/api/tasks/${encodeURIComponent(e)}/handoff`),{method:`POST`,body:JSON.stringify({toAgentId:t,expectedVersion:n,idempotencyKey:crypto.randomUUID()})}),L(e)}async function W(e,t,n){return await s(a(`/api/tasks/${encodeURIComponent(e)}/dependencies`),{method:`PUT`,body:JSON.stringify({dependsOnTaskIds:t,expectedVersion:n})}),L(e)}async function G(e,t,n){return await s(a(`/api/tasks/${encodeURIComponent(e)}/board-position`),{method:`PUT`,body:JSON.stringify({beforeTaskId:t,expectedVersion:n})}),L(e)}async function K(e,t,n){await s(a(`/api/task-runs/${encodeURIComponent(e)}/feedback`),{method:`POST`,headers:{"idempotency-key":crypto.randomUUID()},body:JSON.stringify({rating:t,reason:n?.trim()||void 0})})}function q(e,t=!1){let n=new URLSearchParams;return e&&n.set(`locale`,e),t&&n.set(`attention`,`all`),s(a(`/api/home${n.size?`?${n.toString()}`:``}`)).then(A)}function J(e){return s(a(`/api/home/advisor/refresh`),{method:`POST`,body:JSON.stringify({idempotencyKey:crypto.randomUUID(),locale:e})})}function Y(){return s(a(`/api/home/advisor/history`)).then(e=>O.parse(e))}async function X(e,t){return k.parse(await s(a(`/api/home/opportunities/${encodeURIComponent(e.id)}/action`),{method:`POST`,body:JSON.stringify({idempotencyKey:crypto.randomUUID(),expectedRevision:e.revision,mode:t})}))}function Z(e,t){let n=crypto.randomUUID();return s(a(`/api/home/opportunities/${encodeURIComponent(e.id)}/feedback`),{method:`POST`,body:JSON.stringify({...t,idempotencyKey:n,expectedRevision:e.revision})}).then(()=>({ok:!0,idempotencyKey:n}))}function oe(e,t){return s(a(`/api/home/opportunities/${encodeURIComponent(e)}/feedback/undo`),{method:`POST`,body:JSON.stringify({idempotencyKey:t})})}function se(e,t){return s(a(`/api/home/decisions/respond`),{method:`POST`,body:JSON.stringify({...e,decision:t})})}function ce(e){return s(a(`/api/home/attention/acknowledge`),{method:`POST`,body:JSON.stringify(e)})}function le(e){return s(a(`/api/home/attention/retry`),{method:`POST`,body:JSON.stringify(e)})}function ue(e,t){let n=e.trim(),r=t.trim();return n&&F(n)?`/skill:${n}${r?` ${r}`:` `}`:r||null}function de(e,t,n){let r=e.trim(),i=t?.trim()??``;if(!r&&!i)return null;let a=new URLSearchParams;return r&&a.set(`draft`,r),a.set(`autoSend`,`1`),i&&a.set(`attachmentsHandoff`,i),n?.projectScope===`none`&&a.set(`projectScope`,`none`),`/chat/new?${a.toString()}`}function fe(e){let t=e.startsWith(`?`)?e.slice(1):e;if(!t)return``;let n=new URLSearchParams(t),r=new URLSearchParams,i=n.get(`skill`),a=n.get(`slash`),o=n.get(`draft`),s=n.get(`autoSend`),c=n.get(`attachmentHandoff`),l=n.get(`attachmentsHandoff`),u=n.get(`agentSetup`);i&&r.set(`skill`,i),a&&r.set(`slash`,a),o&&r.set(`draft`,o),s===`1`&&r.set(`autoSend`,`1`),c&&r.set(`attachmentHandoff`,c),l&&r.set(`attachmentsHandoff`,l),n.get(`setup`)===`automation`&&r.set(`setup`,`automation`),u===`1`&&r.set(`agentSetup`,`1`),n.get(`scene`)===`find-skills`&&r.set(`scene`,`find-skills`);let d=r.toString();return d?`?${d}`:``}function pe(e){let t=e.startsWith(`?`)?e.slice(1):e,n=new URLSearchParams(t),r=n.get(`projectId`)?.trim();return r?{kind:`project`,projectId:r}:n.get(`projectScope`)===`none`?{kind:`none`}:{kind:`remember-last`}}function me(e){let t=e?.trim();return t?`/chat/new?projectId=${encodeURIComponent(t)}`:`/chat/new?projectScope=none`}var he=n(),Q=e(t(),1),$=r();function ge(e){let t=(0,he.c)(6),n=v(),r,i;if(t[0]!==n||t[1]!==e?(r=()=>{!n||e.embedded||!e.open||!e.attachment||(N.getState().openFile({attachment:e.attachment,images:e.images,conversationId:e.conversationId||void 0,resultRevision:e.resultRevision},n),e.onClose())},i=[n,e],t[0]=n,t[1]=e,t[2]=r,t[3]=i):(r=t[2],i=t[3]),(0,Q.useEffect)(r,i),n&&!e.embedded)return null;let a;return t[4]===e?a=t[5]:(a=(0,$.jsx)(_e,{...e}),t[4]=e,t[5]=a),a}function _e({open:e,embedded:t=!1,tabId:n,attachment:r,images:i=[],resultRevision:a,onAttachmentChange:s,authToken:h,conversationId:g,layerClassName:_=`z-[81]`,onClose:v}){let C=o(e=>e.language),E=c(C).chat,D=y({open:e,attachment:r,authToken:h,conversationId:g,language:C}),O=te(),{expanded:k,setExpanded:A}=x(e,O.dialogOpen),[j,M]=(0,Q.useState)(!1),{preview:N,fileType:F,hasExtractedText:I}=D,L=r?i.findIndex(e=>e===r||e.id&&e.id===r.id||e.uri&&e.uri===r.uri||!e.id&&!e.uri&&e.name===r.name&&!!e.data&&e.data===r.data):-1,R=F===`image`&&i.length>1&&L>=0&&!!s,z=e=>{if(!R||O.dialogOpen)return;let t=L+(e===`previous`?-1:1);t>=0&&t<i.length&&s?.(i[t])},ae=F!==`image`&&F!==`text`&&F!==`pptx`&&I,B=N?.uri?ee(N.uri):null,V=!!(B||N?.uri?.startsWith(`media://`)&&(g||N.taskId)),H=()=>{!N?.uri||!V||O.createShareLink(B?{fileId:B,fileName:N.name}:{uri:N.uri,conversationId:g??void 0,taskId:N.taskId,fileName:N.name})},U=!!(N&&!D.loading&&!D.loadError),W=()=>{A(!1),v()},G=()=>{if(!N||!D.downloadBuffer)return;let e=new Blob([D.downloadBuffer],{type:D.descriptor.mimeType}),t=URL.createObjectURL(e),n=document.createElement(`a`);n.href=t,n.download=N.name??`download`,document.body.appendChild(n),n.click(),document.body.removeChild(n),URL.revokeObjectURL(t)},K=!!D.downloadBuffer,q=ie()&&F===`spreadsheet`&&/\.xlsx?$/i.test(D.fileName)&&!!D.downloadBuffer&&!!window.electronAPI?.shell?.openTemporaryFile,J=async()=>{let e=D.downloadBuffer,t=window.electronAPI?.shell?.openTemporaryFile;if(!(!e||!t||j)){M(!0);try{(await t({fileName:D.fileName,data:new Uint8Array(e)})).ok||S(`warning`,E.attachmentPreviewOpenLocalFailed)}catch{S(`warning`,E.attachmentPreviewOpenLocalFailed)}finally{M(!1)}}},Y={onDownload:G,canDownload:K},X=T(`min-h-0 min-w-0 flex-1 cursor-pointer border-0 p-0`,`bg-surface-base transition-colors`,`hover:bg-surface-hover/90 dark:bg-black/60 dark:hover:bg-black/70`,P.focusRingBase),Z=(0,$.jsxs)($.Fragment,{children:[(0,$.jsx)(b,{header:{expanded:k,onToggleExpanded:U?()=>A(e=>!e):void 0,hideClose:t,onClose:W,share:V?{onClick:H,loading:O.loading}:void 0,openWithSystemApp:q?{onClick:()=>void J(),loading:j}:void 0,textView:ae?{active:D.showExtractedText,onChange:e=>{D.setShowExtractedText(e),D.clearLoadError()}}:void 0},chat:D.downloadBuffer?{conversationId:g,createFile:async()=>new File([D.downloadBuffer],D.fileName,{type:D.descriptor.mimeType})}:void 0,onImageSwipe:R?z:void 0,language:C,descriptor:n?{...D.descriptor,id:n}:D.descriptor,loading:D.loading,loadError:D.loadError,textContent:D.textContent,binaryBuffer:D.binaryBuffer,showExtractedText:D.showExtractedText,extractedText:D.extractedText,extractedTextTruncated:D.extractedTextTruncated,actions:Y}),a?(0,$.jsxs)(`p`,{className:`shrink-0 border-t border-edge px-4 py-2 text-xs text-fg-muted`,"data-result-revision":!0,children:[C===`zh`?`成果版本`:`Result version`,` `,a]}):null,R?(0,$.jsxs)(`div`,{className:`flex shrink-0 items-center justify-center gap-4 border-t border-edge bg-surface-panel px-3 py-2`,children:[(0,$.jsx)(`button`,{type:`button`,"aria-label":E.attachmentPreviewPreviousImage,disabled:L===0,onClick:()=>z(`previous`),className:T(`flex size-11 touch-manipulation items-center justify-center rounded-lg hover:bg-surface-hover disabled:opacity-30`,P.focusRingBase),children:(0,$.jsx)(p,{size:20,"aria-hidden":`true`})}),(0,$.jsxs)(`span`,{role:`status`,className:`min-w-16 text-center text-sm tabular-nums text-fg-muted`,children:[L+1,` / `,i.length]}),(0,$.jsx)(`button`,{type:`button`,"aria-label":E.attachmentPreviewNextImage,disabled:L===i.length-1,onClick:()=>z(`next`),className:T(`flex size-11 touch-manipulation items-center justify-center rounded-lg hover:bg-surface-hover disabled:opacity-30`,P.focusRingBase),children:(0,$.jsx)(m,{size:20,"aria-hidden":`true`})})]}):null]});return t?(0,$.jsxs)($.Fragment,{children:[(0,$.jsx)(re,{expanded:k,children:Z}),(0,$.jsx)(w,{open:O.dialogOpen,onOpenChange:O.handleOpenChange,loading:O.loading,error:O.error,result:O.result,pendingParams:O.pendingParams,onConfirm:e=>void O.confirmShareLink(e)})]}):(0,$.jsxs)($.Fragment,{children:[(0,$.jsx)(f,{open:e,onOpenChange:e=>!e&&W(),children:(0,$.jsx)(l,{children:(0,$.jsxs)(u,{"aria-describedby":void 0,onKeyDown:e=>{!R||O.dialogOpen||e.altKey||e.ctrlKey||e.metaKey||e.target.closest(`input, textarea, select, [contenteditable="true"]`)||(e.key===`ArrowLeft`||e.key===`ArrowRight`)&&(e.preventDefault(),z(e.key===`ArrowLeft`?`previous`:`next`))},className:T(`xopc-dialog-content-fullscreen fixed inset-0 flex h-[100dvh] w-full flex-row overflow-hidden`,ne(),_,`border-0 bg-transparent p-0 shadow-none outline-none`),children:[(0,$.jsx)(d,{className:`sr-only`,children:N?.name??``}),(0,$.jsx)(`button`,{type:`button`,className:X,onClick:W,"aria-label":E.attachmentPreviewClose}),(0,$.jsx)(`div`,{className:T(`flex h-full min-h-0 shrink-0 flex-col overflow-hidden`,k?`w-full`:`w-[min(100%,var(--max-width-app-main))]`,`bg-surface-panel sm:border-x sm:border-edge dark:sm:border-edge`,`shadow-float dark:shadow-elevated`),children:Z}),(0,$.jsx)(`button`,{type:`button`,className:X,onClick:W,"aria-label":E.attachmentPreviewClose})]})})}),(0,$.jsx)(w,{open:O.dialogOpen,onOpenChange:O.handleOpenChange,loading:O.loading,error:O.error,result:O.result,pendingParams:O.pendingParams,onConfirm:e=>void O.confirmShareLink(e)})]})}function ve(e){let t=(0,he.c)(23),{attachments:n,conversationId:r,topPadded:i,onRemove:a,className:s}=e,l=o(ye),u;t[0]===l?u=t[1]:(u=c(l),t[0]=l,t[1]=u);let d=u.chat,[f,p]=(0,Q.useState)(null);if(n.length===0)return null;let m=i?`pt-2`:`pt-3`,_;t[2]!==s||t[3]!==m?(_=T(`flex flex-wrap gap-2 border-b border-edge-subtle/90 bg-surface-hover/20 px-4 pb-2 dark:border-edge-subtle`,m,s),t[2]=s,t[3]=m,t[4]=_):_=t[4];let v;if(t[5]!==n||t[6]!==d||t[7]!==a){let e;t[9]!==d||t[10]!==a?(e=(e,t)=>{let n=e.type===`pasted_text`?d.pastedText:e.name;return(0,$.jsxs)(`div`,{className:`flex max-w-[200px] items-center rounded-lg bg-surface-hover text-xs dark:bg-surface-hover/80`,children:[(0,$.jsxs)(`button`,{type:`button`,className:T(`flex min-w-0 flex-1 items-center gap-1.5 rounded-l-lg py-1 pl-2 pr-1 text-left hover:bg-surface-active`,P.transition,P.press,P.focusRingPanel),onClick:()=>p(e),"aria-label":`${d.attachmentPreviewOpen}: ${n}`,title:`${d.attachmentPreviewOpen}: ${n}`,children:[e.mimeType?.startsWith(`image/`)&&e.content?(0,$.jsx)(`img`,{src:`data:${e.mimeType};base64,${e.content}`,alt:``,className:`size-6 shrink-0 rounded object-cover`}):e.type===`voice`||e.mimeType?.startsWith(`audio/`)?(0,$.jsx)(C,{className:`size-3.5 shrink-0 text-accent-fg`,"aria-hidden":!0}):e.type===`pasted_text`?(0,$.jsx)(h,{className:`size-3.5 shrink-0 text-accent-fg`,"aria-hidden":!0}):(0,$.jsx)(g,{className:`size-3.5 shrink-0 text-fg-muted`,"aria-hidden":!0}),(0,$.jsx)(`span`,{className:`min-w-0 flex-1 truncate`,children:n}),(0,$.jsx)(`span`,{className:`shrink-0 text-fg-disabled`,children:M(e.size)})]}),(0,$.jsx)(`button`,{type:`button`,className:T(`flex min-h-8 min-w-8 items-center justify-center rounded-r-lg text-fg-muted hover:bg-surface-active hover:text-fg`,P.transition,P.press,P.focusRingPanel),onClick:()=>a(t),"aria-label":`${d.attachmentPreviewRemove}: ${n}`,title:`${d.attachmentPreviewRemove}: ${n}`,children:(0,$.jsx)(`span`,{"aria-hidden":!0,children:`×`})})]},e.id??`${e.name}-${e.size}-${e.mimeType}-${e.content?.slice(0,16)??``}`)},t[9]=d,t[10]=a,t[11]=e):e=t[11],v=n.map(e),t[5]=n,t[6]=d,t[7]=a,t[8]=v}else v=t[8];let y;t[12]!==_||t[13]!==v?(y=(0,$.jsx)(`div`,{className:_,children:v}),t[12]=_,t[13]=v,t[14]=y):y=t[14];let b=f!==null,x;t[15]===Symbol.for(`react.memo_cache_sentinel`)?(x=()=>p(null),t[15]=x):x=t[15];let S;t[16]!==r||t[17]!==f||t[18]!==b?(S=(0,$.jsx)(ge,{open:b,attachment:f,conversationId:r,onClose:x}),t[16]=r,t[17]=f,t[18]=b,t[19]=S):S=t[19];let w;return t[20]!==y||t[21]!==S?(w=(0,$.jsxs)($.Fragment,{children:[y,S]}),t[20]=y,t[21]=S,t[22]=w):w=t[22],w}function ye(e){return e.language}function be(e){let{chat:t,initialAttachments:n=[],onAttachmentsChange:r}=e,[a,o]=(0,Q.useState)(n),[s,c]=(0,Q.useState)(!1),l=(0,Q.useRef)(null),u=(0,Q.useRef)(a),d=(0,Q.useRef)(r);u.current=a,d.current=r;let f=(0,Q.useCallback)(e=>{let t=typeof e==`function`?e(u.current):e;u.current=t,o(t),d.current?.(t)},[]),p=(0,Q.useCallback)(()=>{f([])},[]),m=(0,Q.useCallback)(e=>{f(t=>t.filter((t,n)=>n!==e))},[]),h=(0,Q.useCallback)(()=>u.current.map(e=>({type:e.type===`voice`?`voice`:e.type||`file`,mimeType:e.mimeType,data:e.content,name:e.name,size:e.size,...e.uri?{uri:e.uri}:{},...typeof e.durationSeconds==`number`&&Number.isFinite(e.durationSeconds)&&e.durationSeconds>0?{durationSeconds:e.durationSeconds}:{}})),[]),g=(0,Q.useCallback)(async(e,n)=>{if(e.length===0)return;let r=10-u.current.length;if(r<=0){S(`warning`,t.maxAttachmentsReached,{max:10});return}let a=e.slice(0,r);e.length>a.length&&S(`warning`,t.maxAttachmentsTruncated,{max:10,dropped:e.length-a.length});let{loadAttachment:o}=await i(async()=>{let{loadAttachment:e}=await import(`./attachment-load-DrVGNxJm.js`).then(e=>e.t);return{loadAttachment:e}},__vite__mapDeps([0,1,2])),s=(await Promise.all(a.map(async e=>{if(e.size>33554432)return S(`warning`,t.attachmentFileTooLarge,{name:e.name,maxSize:M(E)}),null;try{return await o(e,e.name)}catch{return S(`error`,t.attachmentLoadFailed,{name:e.name}),null}}))).filter(e=>e!==null).map(e=>n?{...e,type:n}:e);f(e=>[...e,...s])},[t.attachmentFileTooLarge,t.attachmentLoadFailed,t.maxAttachmentsReached,t.maxAttachmentsTruncated]),v=(0,Q.useCallback)(e=>g(e),[g]);return(0,Q.useEffect)(()=>{if(e.conversationId)return _(e.conversationId,async e=>{let t=u.current.length;return await g([e]),u.current.length>t})},[g,e.conversationId]),{attachments:a,setAttachments:f,attachmentsRef:u,isDragging:s,setIsDragging:c,fileInputRef:l,processFiles:v,processPastedText:(0,Q.useCallback)(e=>g([new File([e.text],e.name,{type:e.mimeType})],`pasted_text`),[g]),removeAttachment:m,clearAttachments:p,wireAttachmentsPayload:h}}export{V as C,z as D,oe as E,G as O,le as S,K as T,Y as _,de as a,J as b,fe as c,H as d,B as f,q as g,R as h,ue as i,W as k,ce as l,ae as m,ve as n,me as o,I as p,ge as r,pe as s,be as t,X as u,L as v,Z as w,se as x,U as y};
2
+ import{i as e}from"./rolldown-runtime-aKtaBQYM.js";import{a as t,n,t as r}from"./vendor-react-BOUWij0V.js";import{t as i}from"./preload-helper-Czpn1I53.js";import{i as a,n as o,o as s}from"./locale-store-B6OrWgY1.js";import{t as c}from"./messages-jwdBhfL9.js";import{o as l,r as u,s as d,t as f}from"./dist-BGTk37IG.js";import{t as p}from"./chevron-left-DqFhpbvK.js";import{t as m}from"./chevron-right-BweFrslA.js";import{n as h,t as g}from"./file-BqMS_3DT.js";import{a as _,b as v,l as y,n as b,t as x,x as S}from"./use-file-preview-expanded-CW956CXS.js";import{t as C}from"./mic-CuUb7zc-.js";import{n as w}from"./share-link-dialog-BMcXyzr2.js";import{t as T}from"./cn-0WouolD0.js";import{r as ee,t as E}from"./constants-DBtMsXdW.js";import{r as D}from"./tasks-DRmd6sWt.js";import{a as O,i as k,o as A}from"./capabilities-DlHPLld_.js";import{t as j}from"./capabilities-CoeuLRt6.js";import{r as M}from"./attachment-utils-core-BIOUBrpT.js";import{a as te,n as ne,s as N,t as re}from"./file-preview-surface-zE9AcaHM.js";import{n as P}from"./interaction-BdhHBbYa.js";import{n as ie}from"./electron-env-DHOGevH3.js";import{i as F}from"./skill-wire-pattern-BPpeIcCi.js";async function I(e){return D.parse(await s(a(`/api/tasks`),{method:`POST`,body:JSON.stringify(e)}))}async function L(e){return j(`xopc.tasks.get`,{id:e})}async function R(e){return s(a(`/api/tasks/${encodeURIComponent(e)}/conversation`),{method:`POST`})}async function z(e,t,n){return await s(a(`/api/tasks/${encodeURIComponent(e)}`),{method:`PATCH`,body:JSON.stringify({...t,expectedVersion:n})}),L(e)}async function ae(e){await s(a(`/api/tasks/${encodeURIComponent(e)}`),{method:`DELETE`})}async function B(e,t,n,r=crypto.randomUUID(),i=`api`){return await s(a(`/api/tasks/${encodeURIComponent(e)}/commands`),{method:`POST`,body:JSON.stringify({idempotencyKey:r,expectedVersion:n,command:t,source:i})}),L(e)}async function V(e,t,n,r,i){return await s(a(`/api/tasks/${encodeURIComponent(e)}/criteria/${t}/review`),{method:`PUT`,body:JSON.stringify({status:n,expectedVersion:r,contractVersion:i})}),L(e)}async function H(e,t,n){return await s(a(`/api/task-runs/${encodeURIComponent(t)}/cancel`),{method:`POST`,body:JSON.stringify({expectedVersion:n,reason:`Cancelled by user`})}),L(e)}async function U(e,t,n){return await s(a(`/api/tasks/${encodeURIComponent(e)}/handoff`),{method:`POST`,body:JSON.stringify({toAgentId:t,expectedVersion:n,idempotencyKey:crypto.randomUUID()})}),L(e)}async function W(e,t,n){return await s(a(`/api/tasks/${encodeURIComponent(e)}/dependencies`),{method:`PUT`,body:JSON.stringify({dependsOnTaskIds:t,expectedVersion:n})}),L(e)}async function G(e,t,n){return await s(a(`/api/tasks/${encodeURIComponent(e)}/board-position`),{method:`PUT`,body:JSON.stringify({beforeTaskId:t,expectedVersion:n})}),L(e)}async function K(e,t,n){await s(a(`/api/task-runs/${encodeURIComponent(e)}/feedback`),{method:`POST`,headers:{"idempotency-key":crypto.randomUUID()},body:JSON.stringify({rating:t,reason:n?.trim()||void 0})})}function q(e,t=!1){let n=new URLSearchParams;return e&&n.set(`locale`,e),t&&n.set(`attention`,`all`),s(a(`/api/home${n.size?`?${n.toString()}`:``}`)).then(A)}function J(e){return s(a(`/api/home/advisor/refresh`),{method:`POST`,body:JSON.stringify({idempotencyKey:crypto.randomUUID(),locale:e})})}function Y(){return s(a(`/api/home/advisor/history`)).then(e=>O.parse(e))}async function X(e,t){return k.parse(await s(a(`/api/home/opportunities/${encodeURIComponent(e.id)}/action`),{method:`POST`,body:JSON.stringify({idempotencyKey:crypto.randomUUID(),expectedRevision:e.revision,mode:t})}))}function Z(e,t){let n=crypto.randomUUID();return s(a(`/api/home/opportunities/${encodeURIComponent(e.id)}/feedback`),{method:`POST`,body:JSON.stringify({...t,idempotencyKey:n,expectedRevision:e.revision})}).then(()=>({ok:!0,idempotencyKey:n}))}function oe(e,t){return s(a(`/api/home/opportunities/${encodeURIComponent(e)}/feedback/undo`),{method:`POST`,body:JSON.stringify({idempotencyKey:t})})}function se(e,t){return s(a(`/api/home/decisions/respond`),{method:`POST`,body:JSON.stringify({...e,decision:t})})}function ce(e){return s(a(`/api/home/attention/acknowledge`),{method:`POST`,body:JSON.stringify(e)})}function le(e){return s(a(`/api/home/attention/retry`),{method:`POST`,body:JSON.stringify(e)})}function ue(e,t){let n=e.trim(),r=t.trim();return n&&F(n)?`/skill:${n}${r?` ${r}`:` `}`:r||null}function de(e,t,n){let r=e.trim(),i=t?.trim()??``;if(!r&&!i)return null;let a=new URLSearchParams;return r&&a.set(`draft`,r),a.set(`autoSend`,`1`),i&&a.set(`attachmentsHandoff`,i),n?.projectScope===`none`&&a.set(`projectScope`,`none`),`/chat/new?${a.toString()}`}function fe(e){let t=e.startsWith(`?`)?e.slice(1):e;if(!t)return``;let n=new URLSearchParams(t),r=new URLSearchParams,i=n.get(`skill`),a=n.get(`slash`),o=n.get(`draft`),s=n.get(`autoSend`),c=n.get(`attachmentHandoff`),l=n.get(`attachmentsHandoff`),u=n.get(`agentSetup`);i&&r.set(`skill`,i),a&&r.set(`slash`,a),o&&r.set(`draft`,o),s===`1`&&r.set(`autoSend`,`1`),c&&r.set(`attachmentHandoff`,c),l&&r.set(`attachmentsHandoff`,l),n.get(`setup`)===`automation`&&r.set(`setup`,`automation`),u===`1`&&r.set(`agentSetup`,`1`),n.get(`scene`)===`find-skills`&&r.set(`scene`,`find-skills`);let d=r.toString();return d?`?${d}`:``}function pe(e){let t=e.startsWith(`?`)?e.slice(1):e,n=new URLSearchParams(t),r=n.get(`projectId`)?.trim();return r?{kind:`project`,projectId:r}:n.get(`projectScope`)===`none`?{kind:`none`}:{kind:`remember-last`}}function me(e){let t=e?.trim();return t?`/chat/new?projectId=${encodeURIComponent(t)}`:`/chat/new?projectScope=none`}var he=n(),Q=e(t(),1),$=r();function ge(e){let t=(0,he.c)(6),n=v(),r,i;if(t[0]!==n||t[1]!==e?(r=()=>{!n||e.embedded||!e.open||!e.attachment||(N.getState().openFile({attachment:e.attachment,images:e.images,conversationId:e.conversationId||void 0,resultRevision:e.resultRevision},n),e.onClose())},i=[n,e],t[0]=n,t[1]=e,t[2]=r,t[3]=i):(r=t[2],i=t[3]),(0,Q.useEffect)(r,i),n&&!e.embedded)return null;let a;return t[4]===e?a=t[5]:(a=(0,$.jsx)(_e,{...e}),t[4]=e,t[5]=a),a}function _e({open:e,embedded:t=!1,tabId:n,attachment:r,images:i=[],resultRevision:a,onAttachmentChange:s,authToken:h,conversationId:g,layerClassName:_=`z-[81]`,onClose:v}){let C=o(e=>e.language),E=c(C).chat,D=y({open:e,attachment:r,authToken:h,conversationId:g,language:C}),O=te(),{expanded:k,setExpanded:A}=x(e,O.dialogOpen),[j,M]=(0,Q.useState)(!1),{preview:N,fileType:F,hasExtractedText:I}=D,L=r?i.findIndex(e=>e===r||e.id&&e.id===r.id||e.uri&&e.uri===r.uri||!e.id&&!e.uri&&e.name===r.name&&!!e.data&&e.data===r.data):-1,R=F===`image`&&i.length>1&&L>=0&&!!s,z=e=>{if(!R||O.dialogOpen)return;let t=L+(e===`previous`?-1:1);t>=0&&t<i.length&&s?.(i[t])},ae=F!==`image`&&F!==`text`&&F!==`pptx`&&I,B=N?.uri?ee(N.uri):null,V=!!(B||N?.uri?.startsWith(`media://`)&&(g||N.taskId)),H=()=>{!N?.uri||!V||O.createShareLink(B?{fileId:B,fileName:N.name}:{uri:N.uri,conversationId:g??void 0,taskId:N.taskId,fileName:N.name})},U=!!(N&&!D.loading&&!D.loadError),W=()=>{A(!1),v()},G=()=>{if(!N||!D.downloadBuffer)return;let e=new Blob([D.downloadBuffer],{type:D.descriptor.mimeType}),t=URL.createObjectURL(e),n=document.createElement(`a`);n.href=t,n.download=N.name??`download`,document.body.appendChild(n),n.click(),document.body.removeChild(n),URL.revokeObjectURL(t)},K=!!D.downloadBuffer,q=ie()&&F===`spreadsheet`&&/\.xlsx?$/i.test(D.fileName)&&!!D.downloadBuffer&&!!window.electronAPI?.shell?.openTemporaryFile,J=async()=>{let e=D.downloadBuffer,t=window.electronAPI?.shell?.openTemporaryFile;if(!(!e||!t||j)){M(!0);try{(await t({fileName:D.fileName,data:new Uint8Array(e)})).ok||S(`warning`,E.attachmentPreviewOpenLocalFailed)}catch{S(`warning`,E.attachmentPreviewOpenLocalFailed)}finally{M(!1)}}},Y={onDownload:G,canDownload:K},X=T(`min-h-0 min-w-0 flex-1 cursor-pointer border-0 p-0`,`bg-surface-base transition-colors`,`hover:bg-surface-hover/90 dark:bg-black/60 dark:hover:bg-black/70`,P.focusRingBase),Z=(0,$.jsxs)($.Fragment,{children:[(0,$.jsx)(b,{header:{expanded:k,onToggleExpanded:U?()=>A(e=>!e):void 0,hideClose:t,onClose:W,share:V?{onClick:H,loading:O.loading}:void 0,openWithSystemApp:q?{onClick:()=>void J(),loading:j}:void 0,textView:ae?{active:D.showExtractedText,onChange:e=>{D.setShowExtractedText(e),D.clearLoadError()}}:void 0},chat:D.downloadBuffer?{conversationId:g,createFile:async()=>new File([D.downloadBuffer],D.fileName,{type:D.descriptor.mimeType})}:void 0,onImageSwipe:R?z:void 0,language:C,descriptor:n?{...D.descriptor,id:n}:D.descriptor,loading:D.loading,loadError:D.loadError,textContent:D.textContent,binaryBuffer:D.binaryBuffer,showExtractedText:D.showExtractedText,extractedText:D.extractedText,extractedTextTruncated:D.extractedTextTruncated,actions:Y}),a?(0,$.jsxs)(`p`,{className:`shrink-0 border-t border-edge px-4 py-2 text-xs text-fg-muted`,"data-result-revision":!0,children:[C===`zh`?`成果版本`:`Result version`,` `,a]}):null,R?(0,$.jsxs)(`div`,{className:`flex shrink-0 items-center justify-center gap-4 border-t border-edge bg-surface-panel px-3 py-2`,children:[(0,$.jsx)(`button`,{type:`button`,"aria-label":E.attachmentPreviewPreviousImage,disabled:L===0,onClick:()=>z(`previous`),className:T(`flex size-11 touch-manipulation items-center justify-center rounded-lg hover:bg-surface-hover disabled:opacity-30`,P.focusRingBase),children:(0,$.jsx)(p,{size:20,"aria-hidden":`true`})}),(0,$.jsxs)(`span`,{role:`status`,className:`min-w-16 text-center text-sm tabular-nums text-fg-muted`,children:[L+1,` / `,i.length]}),(0,$.jsx)(`button`,{type:`button`,"aria-label":E.attachmentPreviewNextImage,disabled:L===i.length-1,onClick:()=>z(`next`),className:T(`flex size-11 touch-manipulation items-center justify-center rounded-lg hover:bg-surface-hover disabled:opacity-30`,P.focusRingBase),children:(0,$.jsx)(m,{size:20,"aria-hidden":`true`})})]}):null]});return t?(0,$.jsxs)($.Fragment,{children:[(0,$.jsx)(re,{expanded:k,children:Z}),(0,$.jsx)(w,{open:O.dialogOpen,onOpenChange:O.handleOpenChange,loading:O.loading,error:O.error,result:O.result,pendingParams:O.pendingParams,onConfirm:e=>void O.confirmShareLink(e)})]}):(0,$.jsxs)($.Fragment,{children:[(0,$.jsx)(f,{open:e,onOpenChange:e=>!e&&W(),children:(0,$.jsx)(l,{children:(0,$.jsxs)(u,{"aria-describedby":void 0,onKeyDown:e=>{!R||O.dialogOpen||e.altKey||e.ctrlKey||e.metaKey||e.target.closest(`input, textarea, select, [contenteditable="true"]`)||(e.key===`ArrowLeft`||e.key===`ArrowRight`)&&(e.preventDefault(),z(e.key===`ArrowLeft`?`previous`:`next`))},className:T(`xopc-dialog-content-fullscreen fixed inset-0 flex h-[100dvh] w-full flex-row overflow-hidden`,ne(),_,`border-0 bg-transparent p-0 shadow-none outline-none`),children:[(0,$.jsx)(d,{className:`sr-only`,children:N?.name??``}),(0,$.jsx)(`button`,{type:`button`,className:X,onClick:W,"aria-label":E.attachmentPreviewClose}),(0,$.jsx)(`div`,{className:T(`flex h-full min-h-0 shrink-0 flex-col overflow-hidden`,k?`w-full`:`w-[min(100%,var(--max-width-app-main))]`,`bg-surface-panel sm:border-x sm:border-edge dark:sm:border-edge`,`shadow-float dark:shadow-elevated`),children:Z}),(0,$.jsx)(`button`,{type:`button`,className:X,onClick:W,"aria-label":E.attachmentPreviewClose})]})})}),(0,$.jsx)(w,{open:O.dialogOpen,onOpenChange:O.handleOpenChange,loading:O.loading,error:O.error,result:O.result,pendingParams:O.pendingParams,onConfirm:e=>void O.confirmShareLink(e)})]})}function ve(e){let t=(0,he.c)(23),{attachments:n,conversationId:r,topPadded:i,onRemove:a,className:s}=e,l=o(ye),u;t[0]===l?u=t[1]:(u=c(l),t[0]=l,t[1]=u);let d=u.chat,[f,p]=(0,Q.useState)(null);if(n.length===0)return null;let m=i?`pt-2`:`pt-3`,_;t[2]!==s||t[3]!==m?(_=T(`flex flex-wrap gap-2 border-b border-edge-subtle/90 bg-surface-hover/20 px-4 pb-2 dark:border-edge-subtle`,m,s),t[2]=s,t[3]=m,t[4]=_):_=t[4];let v;if(t[5]!==n||t[6]!==d||t[7]!==a){let e;t[9]!==d||t[10]!==a?(e=(e,t)=>{let n=e.type===`pasted_text`?d.pastedText:e.name;return(0,$.jsxs)(`div`,{className:`flex max-w-[200px] items-center rounded-lg bg-surface-hover text-xs dark:bg-surface-hover/80`,children:[(0,$.jsxs)(`button`,{type:`button`,className:T(`flex min-w-0 flex-1 items-center gap-1.5 rounded-l-lg py-1 pl-2 pr-1 text-left hover:bg-surface-active`,P.transition,P.press,P.focusRingPanel),onClick:()=>p(e),"aria-label":`${d.attachmentPreviewOpen}: ${n}`,title:`${d.attachmentPreviewOpen}: ${n}`,children:[e.mimeType?.startsWith(`image/`)&&e.content?(0,$.jsx)(`img`,{src:`data:${e.mimeType};base64,${e.content}`,alt:``,className:`size-6 shrink-0 rounded object-cover`}):e.type===`voice`||e.mimeType?.startsWith(`audio/`)?(0,$.jsx)(C,{className:`size-3.5 shrink-0 text-accent-fg`,"aria-hidden":!0}):e.type===`pasted_text`?(0,$.jsx)(h,{className:`size-3.5 shrink-0 text-accent-fg`,"aria-hidden":!0}):(0,$.jsx)(g,{className:`size-3.5 shrink-0 text-fg-muted`,"aria-hidden":!0}),(0,$.jsx)(`span`,{className:`min-w-0 flex-1 truncate`,children:n}),(0,$.jsx)(`span`,{className:`shrink-0 text-fg-disabled`,children:M(e.size)})]}),(0,$.jsx)(`button`,{type:`button`,className:T(`flex min-h-8 min-w-8 items-center justify-center rounded-r-lg text-fg-muted hover:bg-surface-active hover:text-fg`,P.transition,P.press,P.focusRingPanel),onClick:()=>a(t),"aria-label":`${d.attachmentPreviewRemove}: ${n}`,title:`${d.attachmentPreviewRemove}: ${n}`,children:(0,$.jsx)(`span`,{"aria-hidden":!0,children:`×`})})]},e.id??`${e.name}-${e.size}-${e.mimeType}-${e.content?.slice(0,16)??``}`)},t[9]=d,t[10]=a,t[11]=e):e=t[11],v=n.map(e),t[5]=n,t[6]=d,t[7]=a,t[8]=v}else v=t[8];let y;t[12]!==_||t[13]!==v?(y=(0,$.jsx)(`div`,{className:_,children:v}),t[12]=_,t[13]=v,t[14]=y):y=t[14];let b=f!==null,x;t[15]===Symbol.for(`react.memo_cache_sentinel`)?(x=()=>p(null),t[15]=x):x=t[15];let S;t[16]!==r||t[17]!==f||t[18]!==b?(S=(0,$.jsx)(ge,{open:b,attachment:f,conversationId:r,onClose:x}),t[16]=r,t[17]=f,t[18]=b,t[19]=S):S=t[19];let w;return t[20]!==y||t[21]!==S?(w=(0,$.jsxs)($.Fragment,{children:[y,S]}),t[20]=y,t[21]=S,t[22]=w):w=t[22],w}function ye(e){return e.language}function be(e){let{chat:t,initialAttachments:n=[],onAttachmentsChange:r}=e,[a,o]=(0,Q.useState)(n),[s,c]=(0,Q.useState)(!1),l=(0,Q.useRef)(null),u=(0,Q.useRef)(a),d=(0,Q.useRef)(r);u.current=a,d.current=r;let f=(0,Q.useCallback)(e=>{let t=typeof e==`function`?e(u.current):e;u.current=t,o(t),d.current?.(t)},[]),p=(0,Q.useCallback)(()=>{f([])},[]),m=(0,Q.useCallback)(e=>{f(t=>t.filter((t,n)=>n!==e))},[]),h=(0,Q.useCallback)(()=>u.current.map(e=>({type:e.type===`voice`?`voice`:e.type||`file`,mimeType:e.mimeType,data:e.content,name:e.name,size:e.size,...e.uri?{uri:e.uri}:{},...typeof e.durationSeconds==`number`&&Number.isFinite(e.durationSeconds)&&e.durationSeconds>0?{durationSeconds:e.durationSeconds}:{}})),[]),g=(0,Q.useCallback)(async(e,n)=>{if(e.length===0)return;let r=10-u.current.length;if(r<=0){S(`warning`,t.maxAttachmentsReached,{max:10});return}let a=e.slice(0,r);e.length>a.length&&S(`warning`,t.maxAttachmentsTruncated,{max:10,dropped:e.length-a.length});let{loadAttachment:o}=await i(async()=>{let{loadAttachment:e}=await import(`./attachment-load-DrVGNxJm.js`).then(e=>e.t);return{loadAttachment:e}},__vite__mapDeps([0,1,2])),s=(await Promise.all(a.map(async e=>{if(e.size>33554432)return S(`warning`,t.attachmentFileTooLarge,{name:e.name,maxSize:M(E)}),null;try{return await o(e,e.name)}catch{return S(`error`,t.attachmentLoadFailed,{name:e.name}),null}}))).filter(e=>e!==null).map(e=>n?{...e,type:n}:e);f(e=>[...e,...s])},[t.attachmentFileTooLarge,t.attachmentLoadFailed,t.maxAttachmentsReached,t.maxAttachmentsTruncated]),v=(0,Q.useCallback)(e=>g(e),[g]);return(0,Q.useEffect)(()=>{if(e.conversationId)return _(e.conversationId,async e=>{let t=u.current.length;return await g([e]),u.current.length>t})},[g,e.conversationId]),{attachments:a,setAttachments:f,attachmentsRef:u,isDragging:s,setIsDragging:c,fileInputRef:l,processFiles:v,processPastedText:(0,Q.useCallback)(e=>g([new File([e.text],e.name,{type:e.mimeType})],`pasted_text`),[g]),removeAttachment:m,clearAttachments:p,wireAttachmentsPayload:h}}export{V as C,z as D,oe as E,G as O,le as S,K as T,Y as _,de as a,J as b,fe as c,H as d,B as f,q as g,R as h,ue as i,W as k,ce as l,ae as m,ve as n,me as o,I as p,ge as r,pe as s,be as t,X as u,L as v,Z as w,se as x,U as y};
@@ -1,2 +1,2 @@
1
- const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["assets/attachment-process-heavy-DGZZ-M85.js","assets/rolldown-runtime-aKtaBQYM.js","assets/preload-helper-Czpn1I53.js","assets/pdf-runtime-JnUAvfIa.js","assets/source-workspace-editor-kxosllTu.js","assets/vendor-react-BOUWij0V.js","assets/vendor-codemirror-aCQ0FcJT.js","assets/languages-zXtNocoy.js","assets/binary-plugins-D25P9ZxQ.js","assets/messages-DYDkJvXj.js","assets/attachment-utils-core-BIOUBrpT.js","assets/preview-open-alternatives-CY_hjK4b.js","assets/download-Dk-ZjtO6.js","assets/createLucideIcon-DPHK1VkS.js","assets/external-link-DjqjBmc3.js","assets/cn-0WouolD0.js","assets/bundle-mjs-rHxsej31.js","assets/interaction-BdhHBbYa.js","assets/electron-env-DHOGevH3.js","assets/use-blob-object-url-D4BFuzZB.js","assets/media-plugins-BzzLV7wW.js","assets/archive-plugin-DBPu3xCJ.js","assets/jszip.min-Dj17eJqX.js"])))=>i.map(i=>d[i]);
2
- import{i as e}from"./rolldown-runtime-aKtaBQYM.js";import{a as t,n,t as r}from"./vendor-react-BOUWij0V.js";import{t as i}from"./preload-helper-Czpn1I53.js";import{u as a}from"./chunk-KS7C4IRE-CiwuuyV8.js";import{a as o,i as s,l as c,n as l}from"./locale-store-B7y-RVe8.js";import{t as u}from"./messages-DYDkJvXj.js";import{t as d}from"./createLucideIcon-DPHK1VkS.js";import{t as f}from"./app-window-DXFNqt_0.js";import{t as p}from"./check-DUBLcKHA.js";import{t as m}from"./chevron-down-ccbiQQz_.js";import{t as h}from"./copy-Dv6d4Dvw.js";import{t as g}from"./download-Dk-ZjtO6.js";import{t as _}from"./ellipsis-0k4rZLoy.js";import{t as v}from"./external-link-DjqjBmc3.js";import{t as y}from"./eye-CABVeTq0.js";import{t as b}from"./folder-open-CyzJ19I9.js";import{t as x}from"./link-2-D_ZKYUW7.js";import{t as S}from"./loader-circle-CifKLtgG.js";import{G as C,K as w,t as T}from"./markdown-view-DFHa8rUg.js";import{t as ee}from"./message-square-plus-XP0tGdlV.js";import{t as te}from"./minimize-2-DtOGrlpo.js";import{t as E}from"./paperclip-f1HujQY1.js";import{t as ne}from"./pencil-DmIY3Oa-.js";import{t as D}from"./plus-Q2yW6OE7.js";import{t as O}from"./refresh-cw-BRlGaq2w.js";import{t as k}from"./rotate-cw-LIg3Am9S.js";import{t as re}from"./save-DRDABU--.js";import{t as A}from"./search-DA7gz22f.js";import{t as ie}from"./x-B_N4OPjy.js";import{t as j}from"./cn-0WouolD0.js";import{t as M}from"./skeleton-BI5TyibZ.js";import{r as N,t as P}from"./constants-DBtMsXdW.js";import{a as ae}from"./session-api-DVXLCZX2.js";import{a as oe,i as F,n as I,r as L,s as se,t as R}from"./attachment-utils-core-BIOUBrpT.js";import{n as ce}from"./interaction-BdhHBbYa.js";import{t as z}from"./activity-store-WqnVruhY.js";import{r as le}from"./app-chrome-BeB4KgOf.js";import{n as ue}from"./electron-env-DHOGevH3.js";import{t as de}from"./use-async-resource-BHFGZCY2.js";import{t as fe}from"./sliding-tab-list-DuQyViqe.js";import{t as pe}from"./index.module-Cd9ENXfk.js";import{a as me,c as B,d as he,m as V,n as H,r as ge,u as _e}from"./workspace-api-Am2ee4R6.js";import{a as ve,l as ye,m as be,n as xe,o as U,r as Se,t as Ce,u as we}from"./dist-ZrL34Ps4.js";var Te=d(`folders`,[[`path`,{d:`M20 5a2 2 0 0 1 2 2v7a2 2 0 0 1-2 2H9a2 2 0 0 1-2-2V5a2 2 0 0 1 2-2h2.5a1.5 1.5 0 0 1 1.2.6l.6.8a1.5 1.5 0 0 0 1.2.6z`,key:`a4852j`}],[`path`,{d:`M3 8.268a2 2 0 0 0-1 1.738V19a2 2 0 0 0 2 2h11a2 2 0 0 0 1.732-1`,key:`yxbcw3`}]]),Ee=d(`step-forward`,[[`path`,{d:`M10.029 4.285A2 2 0 0 0 7 6v12a2 2 0 0 0 3.029 1.715l9.997-5.998a2 2 0 0 0 .003-3.432z`,key:`1ystz2`}],[`path`,{d:`M3 4v16`,key:`1ph11n`}]]),De=d(`step-back`,[[`path`,{d:`M13.971 4.285A2 2 0 0 1 17 6v12a2 2 0 0 1-3.029 1.715l-9.997-5.998a2 2 0 0 1-.003-3.432z`,key:`19qhus`}],[`path`,{d:`M21 20V4`,key:`cb8qj8`}]]),Oe=d(`text-wrap`,[[`path`,{d:`m16 16-3 3 3 3`,key:`117b85`}],[`path`,{d:`M3 12h14.5a1 1 0 0 1 0 7H13`,key:`18xa6z`}],[`path`,{d:`M3 19h6`,key:`1ygdsz`}],[`path`,{d:`M3 5h18`,key:`1u36vt`}]]),W=e(t(),1),G=n();function K(e,t,n,r){let i=n?t.replace(/\{\{(\w+)\}\}/g,(e,t)=>String(n[t]??``)):t;z({tone:e,title:i,href:r?.href,dedupeKey:`action-feedback:${e}:${i}`})}var q=(0,W.createContext)(null);function ke(){return(0,W.useContext)(q)}var Ae=(0,W.createContext)([]),je=(0,W.createContext)(null),Me=5*1024*1024,Ne=32*1024*1024,Pe=new Set(`.astro,.bat,.c,.cc,.clj,.cljs,.cljc,.cmd,.cpp,.cs,.cts,.cxx,.dart,.edn,.erl,.ex,.exs,.fish,.fs,.fsx,.go,.gql,.graphql,.groovy,.h,.hh,.hpp,.hrl,.hxx,.java,.ts,.tsx,.mts,.js,.jsx,.mjs,.cjs,.css,.scss,.sass,.less,.json,.jsonc,.json5,.yml,.yaml,.xml,.xsd,.xsl,.py,.pyw,.rb,.php,.rs,.kt,.kts,.scala,.swift,.m,.mm,.sh,.bash,.zsh,.ps1,.sql,.lua,.r,.pl,.pm,.sol,.tf,.tfvars,.nix,.proto,.vue,.svelte,.toml,.ini,.cfg,.conf,.properties`.split(`,`)),Fe=new Set([`.txt`,`.log`,`.lock`,`.csv`,`.tsv`,`.env`,`.gitignore`,`.gitattributes`,`.editorconfig`,`.npmrc`,`.dockerignore`,`.eslintignore`,`.prettierignore`,`.stylelintignore`]),Ie=new Set([`dockerfile`,`gemfile`,`jenkinsfile`,`makefile`,`procfile`,`rakefile`]),Le=new Set([`brewfile`,`changelog`,`codeowners`,`license`,`readme`]),Re=new Set([`.png`,`.jpg`,`.jpeg`,`.gif`,`.webp`,`.bmp`,`.ico`,`.svg`,`.svgz`,`.tif`,`.tiff`,`.avif`,`.heic`,`.heif`,`.jxl`]),ze=new Set([`.mp3`,`.wav`,`.ogg`,`.oga`,`.aac`,`.m4a`,`.flac`,`.opus`,`.weba`]),Be=new Set([`.mp4`,`.webm`,`.mov`,`.m4v`,`.ogv`]),Ve=new Set([`.zip`]),He=new Map([[`.pdf`,`application/pdf`],[`.docx`,`application/vnd.openxmlformats-officedocument.wordprocessingml.document`],[`.pptx`,`application/vnd.openxmlformats-officedocument.presentationml.presentation`],[`.xlsx`,`application/vnd.openxmlformats-officedocument.spreadsheetml.sheet`],[`.xls`,`application/vnd.ms-excel`],[`.md`,`text/markdown`],[`.markdown`,`text/markdown`],[`.html`,`text/html`],[`.htm`,`text/html`],[`.json`,`application/json`],[`.txt`,`text/plain`],[`.csv`,`text/csv`],[`.tsv`,`text/tab-separated-values`],[`.png`,`image/png`],[`.jpg`,`image/jpeg`],[`.jpeg`,`image/jpeg`],[`.gif`,`image/gif`],[`.webp`,`image/webp`],[`.svg`,`image/svg+xml`],[`.svgz`,`image/svg+xml`],[`.mp3`,`audio/mpeg`],[`.wav`,`audio/wav`],[`.ogg`,`audio/ogg`],[`.mp4`,`video/mp4`],[`.webm`,`video/webm`],[`.mov`,`video/quicktime`],[`.zip`,`application/zip`]]);function Ue(e){let t=J(e),n=t.lastIndexOf(`.`);return n<0||n===t.length-1?``:t.slice(n).toLowerCase()}function J(e){let t=e.replace(/\\/g,`/`).split(`/`);return t[t.length-1]||e}function Y(e,t){let n=t?.split(`;`)[0]?.trim().toLowerCase();return n&&n!==`application/octet-stream`?n:He.get(Ue(e))??n??`application/octet-stream`}function X(e,t){let n=Ue(e),r=J(e).toLowerCase(),i=Y(e,t);return i===`text/markdown`||n===`.md`||n===`.markdown`?`markdown`:i===`text/html`||n===`.html`||n===`.htm`?`html`:i===`application/pdf`||n===`.pdf`?`pdf`:i===`application/vnd.openxmlformats-officedocument.wordprocessingml.document`||n===`.docx`?`docx`:i===`application/vnd.openxmlformats-officedocument.spreadsheetml.sheet`||i===`application/vnd.ms-excel`||n===`.xlsx`||n===`.xls`?`spreadsheet`:i===`application/vnd.openxmlformats-officedocument.presentationml.presentation`||n===`.pptx`?`pptx`:i.startsWith(`image/`)||Re.has(n)?`image`:i.startsWith(`audio/`)||ze.has(n)?`audio`:i.startsWith(`video/`)||Be.has(n)?`video`:i===`application/zip`||Ve.has(n)?`archive`:Pe.has(n)||Ie.has(r)||r.startsWith(`dockerfile.`)?`code`:i.startsWith(`text/`)||Fe.has(n)||Le.has(r)||r.startsWith(`.env.`)||i===`application/json`?`text`:`unsupported`}function We(e){switch(e){case`text`:case`markdown`:case`code`:case`html`:return`text`;case`unsupported`:return`metadata`;default:return`binary`}}async function Ge(e){let{uri:t,conversationId:n,taskId:r}=e;try{let e=N(t),i=await o(s(e?`/api/files/${encodeURIComponent(e)}/content`:se(t,n,r)));return i.ok?{ok:!0,blob:await i.blob()}:{ok:!1,reason:`http`,status:i.status}}catch(e){return{ok:!1,reason:`network`,message:e instanceof Error?e.message:String(e)}}}async function Ke(e){let t=await Ge(e);return t.ok?{ok:!0,buffer:await t.blob.arrayBuffer()}:t}function qe(e){return e.id?String(e.id):`${e.name}:${e.uri??``}`}function Je(){return{id:`__empty__`,context:`attachment`,fileName:``,mimeType:`application/octet-stream`,type:`unsupported`,source:{kind:`inline`}}}function Ye(e){let t=(0,G.c)(65),{open:n,attachment:r,authToken:i,conversationId:a,language:o}=e,[s,c]=(0,W.useState)(n?r:null),[l,d]=(0,W.useState)(!1),[f,p]=(0,W.useState)(!1),m;t[0]!==r||t[1]!==n?(m=n&&r?qe(r):null,t[0]=r,t[1]=n,t[2]=m):m=t[2];let h=m,g=(0,W.useRef)(h);h!==g.current&&(g.current=h,c(n&&r?r:null),d(!1),p(!1));let _=s,v;bb0:{if(!_){let e;t[3]===Symbol.for(`react.memo_cache_sentinel`)?(e=Je(),t[3]=e):e=t[3],v=e;break bb0}let e=_.name??`attachment`,n,r;t[4]!==e||t[5]!==_.mimeType?(n=Y(e,_.mimeType),r=X(e,n),t[4]=e,t[5]=_.mimeType,t[6]=n,t[7]=r):(n=t[6],r=t[7]);let i=r,o=_.id?String(_.id):`${e}:${_.uri??``}`,s;t[8]!==a||t[9]!==_.uri?(s=_.uri?{kind:`media-uri`,uri:_.uri,conversationId:a}:{kind:`inline`},t[8]=a,t[9]=_.uri,t[10]=s):s=t[10];let c;t[11]!==e||t[12]!==n||t[13]!==_.size||t[14]!==o||t[15]!==s||t[16]!==i?(c={id:o,context:`attachment`,fileName:e,mimeType:n,size:_.size,type:i,source:s},t[11]=e,t[12]=n,t[13]=_.size,t[14]=o,t[15]=s,t[16]=i,t[17]=c):c=t[17],v=c}let y=v,b;t[18]===_?b=t[19]:(b=_?F(_):void 0,t[18]=_,t[19]=b);let x=b,S=_?.uri,C;t[20]===y.type?C=t[21]:(C=We(y.type),t[20]=y.type,t[21]=C);let w=C,T=!!(n&&S&&!x&&i&&(w===`binary`||w===`text`)),ee;t[22]!==a||t[23]!==o||t[24]!==S||t[25]!==_?.taskId?(ee=async()=>{let e=u(o).chat,t=await Ke({uri:S,conversationId:a,taskId:_?.taskId});if(!t.ok)throw t.reason===`http`?Error(`${e.attachmentPreviewLoadError} (HTTP ${t.status})`):Error(t.message);return t.buffer},t[22]=a,t[23]=o,t[24]=S,t[25]=_?.taskId,t[26]=ee):ee=t[26];let te=_?.taskId,E;t[27]!==i||t[28]!==a||t[29]!==x||t[30]!==o||t[31]!==S||t[32]!==n||t[33]!==w||t[34]!==te?(E=[n,S,i,o,x,te,a,w],t[27]=i,t[28]=a,t[29]=x,t[30]=o,t[31]=S,t[32]=n,t[33]=w,t[34]=te,t[35]=E):E=t[35];let ne;t[36]===T?ne=t[37]:(ne={enabled:T,initial:null,errorData:null},t[36]=T,t[37]=ne);let D=de(ee,E,ne),O;bb1:{if(x)try{let e;t[38]===x?e=t[39]:(e=I(x),t[38]=x,t[39]=e),O=e;break bb1}catch{O=null;break bb1}if(T&&D.loading){O=null;break bb1}O=D.data??null}let k=O,re=w===`binary`?k:null,A=_?.extractedText??``,ie;t[40]!==k||t[41]!==A||t[42]!==o||t[43]!==w?(ie=w===`text`?A||(k?new TextDecoder(`utf-8`,{fatal:!1}).decode(new Uint8Array(k)):u(o).chat.attachmentPreviewNoText):null,t[40]=k,t[41]=A,t[42]=o,t[43]=w,t[44]=ie):ie=t[44];let j=ie,M=!!_?.extractedText,N=y.type===`pptx`&&A.length>3e5,P;t[45]!==i||t[46]!==x||t[47]!==o||t[48]!==S||t[49]!==n||t[50]!==w?(P=n&&S&&!x&&!i&&w===`binary`?u(o).chat.attachmentPreviewMissingAuth:null,t[45]=i,t[46]=x,t[47]=o,t[48]=S,t[49]=n,t[50]=w,t[51]=P):P=t[51];let ae=P,oe=D.error?D.error instanceof Error?D.error.message:String(D.error):null,L=f?null:ae??oe,se=T?D.loading:!1,R;t[52]===Symbol.for(`react.memo_cache_sentinel`)?(R=()=>p(!0),t[52]=R):R=t[52];let ce=A||null,z;return t[53]!==re||t[54]!==y||t[55]!==k||t[56]!==N||t[57]!==M||t[58]!==L||t[59]!==_||t[60]!==l||t[61]!==se||t[62]!==ce||t[63]!==j?(z={preview:_,descriptor:y,fileType:y.type,fileName:y.fileName,loading:se,loadError:L,clearLoadError:R,textContent:j,binaryBuffer:re,downloadBuffer:k,hasExtractedText:M,extractedText:ce,extractedTextTruncated:N,showExtractedText:l,setShowExtractedText:d},t[53]=re,t[54]=y,t[55]=k,t[56]=N,t[57]=M,t[58]=L,t[59]=_,t[60]=l,t[61]=se,t[62]=ce,t[63]=j,t[64]=z):z=t[64],z}function Xe(e){let t=(0,G.c)(12),{projectId:n,conversationId:r,agentId:i}=e,a;bb0:{let e;t[0]===n?e=t[1]:(e=n?.trim(),t[0]=n,t[1]=e);let o=e;if(o){let e;t[2]===o?e=t[3]:(e={projectId:o},t[2]=o,t[3]=e),a=e;break bb0}let s;t[4]===r?s=t[5]:(s=r?.trim(),t[4]=r,t[5]=s);let c=s;if(c){let e;t[6]===c?e=t[7]:(e={conversationId:c},t[6]=c,t[7]=e),a=e;break bb0}let l;t[8]===i?l=t[9]:(l=i?.trim(),t[8]=i,t[9]=l);let u=l,d;t[10]===u?d=t[11]:(d=u?{agentId:u}:void 0,t[10]=u,t[11]=d),a=d}return a}function Ze(e){return{descriptor:e,textContent:null,binaryBuffer:null,fileResourceId:null,mtimeMs:null,loadError:null,loading:!1,pptxText:null,pptxTruncated:!1,pptxError:null}}function Qe(e,t){switch(t.type){case`clear`:return Ze(t.descriptor);case`loadStart`:return{...Ze(t.descriptor),loading:!0};case`loadSuccess`:return{...e,descriptor:t.payload.descriptor,textContent:t.payload.textContent??null,binaryBuffer:t.payload.binaryBuffer??null,fileResourceId:t.payload.fileResourceId??null,mtimeMs:t.payload.mtimeMs??null,loadError:null,loading:!1};case`loadError`:return{...Ze(t.descriptor),loadError:t.error};case`patchMtime`:return{...e,mtimeMs:t.mtimeMs};case`patchText`:return{...e,textContent:t.text};case`pptxClear`:return{...e,pptxText:null,pptxTruncated:!1,pptxError:null};case`pptxSuccess`:return{...e,pptxText:t.text,pptxTruncated:t.truncated,pptxError:null};case`pptxError`:return{...e,pptxText:null,pptxTruncated:!1,pptxError:t.error}}}function $e(e,t){switch(t.type){case`reset`:return{sourceEditMode:!1,saveStatus:`idle`};case`source`:return{...e,sourceEditMode:typeof t.value==`function`?t.value(e.sourceEditMode):t.value};case`saveStatus`:return{...e,saveStatus:t.value}}}function et({filePath:e,projectId:t,conversationId:n,agentId:r,initialEditMode:a=!1}){let o=Xe({projectId:t,conversationId:n,agentId:r}),s=(0,W.useMemo)(()=>{let t=e?J(e):``,i=Y(t,oe(t)),a=e?X(t,i):`unsupported`;return{id:e||`__empty__`,context:`workspace`,fileName:t,mimeType:i,type:a,source:{kind:`workspace`,path:e||``,conversationId:n,agentId:r}}},[r,e,n]),[c,l]=(0,W.useReducer)(Qe,s,Ze),[u,d]=(0,W.useReducer)($e,{sourceEditMode:a,saveStatus:`idle`}),[f,p]=(0,W.useState)([]),[m,h]=(0,W.useState)([]),g=(0,W.useRef)(e),_=(0,W.useRef)(void 0),v=(0,W.useRef)(null),y=(0,W.useRef)(null),b=(0,W.useRef)(null),[x,S]=(0,W.useState)(!1),[C,w]=(0,W.useState)(!1),[T,ee]=(0,W.useState)(0);g.current!==e&&(g.current=e,d({type:`reset`})),(0,W.useEffect)(()=>{if(!e){l({type:`clear`,descriptor:s});return}let t=!1;l({type:`loadStart`,descriptor:s});let n=We(s.type),r=e=>{t||l({type:`loadError`,descriptor:s,error:e instanceof Error?e.message:String(e)})};return n===`metadata`?(Promise.all([he(e,o).catch(()=>null),_e(e,o).catch(()=>null)]).then(async([n,r])=>{if(!n){t||l({type:`loadSuccess`,payload:{descriptor:s,fileResourceId:r?.fileId??null,mtimeMs:typeof r?.mtimeMs==`number`?r.mtimeMs:null}});return}let i={...s,mimeType:n.mimeType,type:X(n.name,n.mimeType)};if(We(i.type)===`text`){let{content:r,mtimeMs:a,revision:s}=await B(e,o);t||(_.current=s,v.current=r,y.current=r,S(!1),w(!1)),t||l({type:`loadSuccess`,payload:{descriptor:i,textContent:r,fileResourceId:n.id,mtimeMs:typeof a==`number`?a:n.modifiedAt}});return}t||l({type:`loadSuccess`,payload:{descriptor:i,fileResourceId:n.id,mtimeMs:n.modifiedAt}})}).catch(r),()=>{t=!0}):(n===`text`?Promise.all([B(e,o),_e(e,o).catch(()=>null)]).then(([{content:e,mtimeMs:n,revision:r},i])=>{t||(_.current=r,v.current=e,y.current=e,S(!1),w(!1)),t||l({type:`loadSuccess`,payload:{descriptor:s,textContent:e,fileResourceId:i?.fileId??null,mtimeMs:typeof n==`number`?n:null}})}).catch(r):Promise.all([me(e,o),_e(e,o).catch(()=>null)]).then(async([e,n])=>{let r=await e.arrayBuffer();t||l({type:`loadSuccess`,payload:{descriptor:s,binaryBuffer:r,fileResourceId:n?.fileId??null,mtimeMs:typeof n?.mtimeMs==`number`?n.mtimeMs:null}})}).catch(r),()=>{t=!0})},[s,e,o,T]),(0,W.useEffect)(()=>{if(!c.binaryBuffer||c.descriptor.type!==`pptx`){l({type:`pptxClear`});return}let e=!1;return l({type:`pptxClear`}),i(()=>import(`./attachment-process-heavy-DGZZ-M85.js`).then(e=>e.processPptx(c.binaryBuffer,c.descriptor.fileName)),__vite__mapDeps([0,1,2,3])).then(({extractedText:t})=>{if(e)return;let n=t.length>R;l({type:`pptxSuccess`,text:n?t.slice(0,R):t,truncated:n})}).catch(t=>{e||l({type:`pptxError`,error:t instanceof Error?t.message:String(t)})}),()=>{e=!0}},[c.binaryBuffer,c.descriptor.fileName,c.descriptor.type]);let te=(0,W.useCallback)(async()=>{if(b.current&&!await b.current)return!1;if(!e||v.current===null||v.current===y.current)return!0;let t=(async()=>{d({type:`saveStatus`,value:`saving`});try{for(;v.current!==y.current;){let t=v.current,n=await V(e,t,o,_.current);_.current=n.revision,y.current=t,typeof n.mtimeMs==`number`&&l({type:`patchMtime`,mtimeMs:n.mtimeMs})}return S(!1),d({type:`saveStatus`,value:`saved`}),!0}catch{return d({type:`saveStatus`,value:`error`}),!1}})();b.current=t;try{return await t}finally{b.current===t&&(b.current=null)}},[e,o]),E=pe(()=>void te(),500),ne=(0,W.useCallback)(e=>{v.current=e,S(e!==y.current),l({type:`patchText`,text:e}),E()},[E]);(0,W.useEffect)(()=>{let e=e=>{v.current!==y.current&&(e.preventDefault(),e.returnValue=``)};return window.addEventListener(`beforeunload`,e),()=>{window.removeEventListener(`beforeunload`,e),E.cancel()}},[E]);let D=(0,W.useCallback)(()=>{!x&&!b.current&&ee(e=>e+1)},[x]),O=(0,W.useRef)(!1),k=(0,W.useCallback)(async()=>{if(!(!e||c.loading||b.current||O.current)){O.current=!0;try{let t=await he(e,o);if(!t||!(_.current?t.revision!==_.current:c.mtimeMs!=null&&t.modifiedAt!==c.mtimeMs))return;x||u.sourceEditMode?w(!0):D()}catch{w(!0)}finally{O.current=!1}}},[x,u.sourceEditMode,e,c.loading,c.mtimeMs,o,D]),re=(0,W.useCallback)(async()=>{if(!e)return;let t=J(e);if(c.binaryBuffer){H(t,c.binaryBuffer,c.descriptor.mimeType||`application/octet-stream`);return}if(c.textContent!=null){ge(t,c.textContent);return}let n=await me(e,o);H(t,await n.arrayBuffer(),c.descriptor.mimeType||n.type||`application/octet-stream`)},[e,c.binaryBuffer,c.descriptor.mimeType,c.textContent,o]),A=(0,W.useCallback)(async()=>{if(!e)throw Error(`No workspace file selected`);let t=J(e),n=c.descriptor.mimeType||`application/octet-stream`,r;return r=c.binaryBuffer?new Blob([c.binaryBuffer],{type:n}):c.textContent==null?await me(e,o):new Blob([c.textContent],{type:n}),new File([r],t,{type:c.descriptor.mimeType||r.type||`application/octet-stream`,lastModified:c.mtimeMs??Date.now()})},[e,c.binaryBuffer,c.descriptor.mimeType,c.mtimeMs,c.textContent,o]),ie=!c.loading&&!!e,j=ue()&&(!!c.fileResourceId&&!!window.electronAPI?.shell?.openFileResource||c.descriptor.type===`spreadsheet`&&!!c.binaryBuffer&&!!window.electronAPI?.shell?.openTemporaryFile),M=ue()&&!!c.fileResourceId&&!!window.electronAPI?.shell?.chooseAppAndOpenFileResource,N=(0,W.useCallback)(async()=>{let e=c.fileResourceId;if(!ue()||!e||!window.electronAPI?.shell?.getOpenWithAppsForFileResource){h([]),p([]);return}try{let t=await window.electronAPI.shell.getOpenWithAppsForFileResource(e);h(t.recommended.map(e=>({name:e.name,path:e.path,iconDataUrl:e.iconDataUrl}))),p(t.recent.map(e=>({name:e.name,path:e.path,iconDataUrl:e.iconDataUrl,lastUsedAt:e.lastUsedAt})))}catch{h([]),p([])}},[c.fileResourceId]);(0,W.useEffect)(()=>{N()},[N]);let P=(0,W.useCallback)(async()=>{let e=c.fileResourceId;if(e&&window.electronAPI?.shell?.openFileResource)return window.electronAPI.shell.openFileResource(e);if(c.descriptor.type===`spreadsheet`&&c.binaryBuffer&&window.electronAPI?.shell?.openTemporaryFile)return window.electronAPI.shell.openTemporaryFile({fileName:c.descriptor.fileName,data:new Uint8Array(c.binaryBuffer)})},[c.binaryBuffer,c.descriptor.fileName,c.descriptor.type,c.fileResourceId]),ae=(0,W.useCallback)(async()=>{let e=c.fileResourceId;if(!e||!window.electronAPI?.shell?.chooseAppAndOpenFileResource)return;let t=await window.electronAPI.shell.chooseAppAndOpenFileResource(e);return t.ok&&N(),t},[c.fileResourceId,N]),F=(0,W.useCallback)(async e=>{let t=c.fileResourceId;if(!t||!e||!window.electronAPI?.shell?.openFileResourceWithApp)return;let n=await window.electronAPI.shell.openFileResourceWithApp(t,e);return n.ok&&N(),n},[c.fileResourceId,N]),I=ue()&&!!c.fileResourceId&&!!window.electronAPI?.shell?.showFileResourceInFolder,L=(0,W.useCallback)(async()=>{let e=c.fileResourceId;if(e&&window.electronAPI?.shell?.showFileResourceInFolder)return window.electronAPI.shell.showFileResourceInFolder(e)},[c.fileResourceId]);return{...c,dirty:x,externalChange:C,flushSource:te,refresh:D,checkForUpdates:k,extractedText:c.descriptor.type===`pptx`?c.pptxText:null,extractedTextTruncated:c.pptxTruncated,sourceEditMode:u.sourceEditMode,setSourceEditMode:e=>d({type:`source`,value:e}),saveStatus:u.saveStatus,onSourceChange:ne,onDownload:re,createAttachmentFile:A,canDownload:ie,canOpenWithSystemApp:j,onOpenWithSystemApp:P,canChooseOpenWithApp:M,onChooseOpenWithApp:ae,recommendedOpenWithApps:m,recentOpenWithApps:f,onOpenWithRecentApp:F,canRevealInFolder:I,onRevealInFolder:L}}var tt=new Map;function nt(e){return tt.get(e)??{zoom:1,rotation:0,page:1,pageCount:null,searchQuery:``,scroll:[]}}function rt(e,t){let n={...nt(e),...t};for(tt.delete(e),tt.set(e,n);tt.size>100;)tt.delete(tt.keys().next().value)}c.subscribe((e,t)=>{(e.baseUrl!==t.baseUrl||e.conversationId!==t.conversationId)&&tt.clear()});var it=new Map;function at(e,t){return it.set(e,t),()=>{it.get(e)===t&&it.delete(e)}}async function ot(e,t){return await it.get(e)?.(t)??!1}var st=120*1e3,ct=new Map;function lt(){return typeof globalThis.crypto?.randomUUID==`function`?globalThis.crypto.randomUUID():`${Date.now().toString(36)}-${Math.random().toString(36).slice(2)}`}function ut(e){for(let[t,n]of ct)n.expiresAt<=e&&ct.delete(t)}function dt(e,t=Date.now()){ut(t);let n=lt();return ct.set(n,{file:e,name:e.name,type:e.type,expiresAt:t+st}),n}function ft(e,t=Date.now()){let n=ct.get(e);return n?n.expiresAt<=t?(ct.delete(e),null):{name:n.name,type:n.type}:null}function pt(e,t=Date.now()){let n=ct.get(e);if(!n)return null;if(n.expiresAt<=t)return ct.delete(e),null;if(!n.file)return null;let r=n.file;return n.file=null,r}var Z=r();function mt(e){let t=(0,G.c)(3),{app:n}=e,[r,i]=(0,W.useState)(),a;return t[0]!==n||t[1]!==r?(a=n?.iconDataUrl&&n.iconDataUrl!==r?(0,Z.jsx)(`img`,{src:n.iconDataUrl,alt:``,width:20,height:20,className:`size-5 shrink-0 object-contain`,onError:()=>i(n.iconDataUrl)}):(0,Z.jsx)(f,{className:`size-5 shrink-0 text-fg-muted`,strokeWidth:1.75,"aria-hidden":!0}),t[0]=n,t[1]=r,t[2]=a):a=t[2],a}function ht({variant:e=`split`,onAction:t,systemApp:n,chooseApp:r,recommendedApps:i,recentApps:a,onOpenWithApp:o}){let s=l(e=>e.language),c=u(s).workspace,[d,h]=(0,W.useState)(),[g,_]=(0,W.useState)(!1),y=[...i,...a],b=o&&d!==null?y.find(e=>e.path===d?.path)??d??y[0]:void 0,x=!!(g||n?.loading||r?.loading),C=x||!!n?.disabled,w=b?s===`zh`?`用 ${b.name} 打开`:`Open with ${b.name}`:c.openSystemApp,T=`flex min-h-9 cursor-default items-center gap-2.5 rounded-md px-2.5 py-2 text-sm text-fg outline-none data-[highlighted]:bg-surface-hover data-[disabled]:pointer-events-none data-[disabled]:opacity-40`,ee=`my-1 h-px bg-edge-subtle`;if(!n&&!r&&(!o||!y.length))return null;if(e===`menu`){let e=e=>t?t(e):e(),s=`flex min-h-9 w-full items-center gap-2.5 rounded-md px-2.5 py-2 text-left text-sm text-fg hover:bg-surface-hover focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-accent disabled:cursor-not-allowed disabled:opacity-40`;return(0,Z.jsxs)(Z.Fragment,{children:[n?(0,Z.jsxs)(`button`,{type:`button`,role:`menuitem`,className:s,disabled:C,onClick:()=>e(n.onClick),children:[(0,Z.jsx)(v,{className:`size-5 shrink-0 text-fg-muted`,"aria-hidden":!0}),(0,Z.jsx)(`span`,{className:`min-w-0 flex-1 truncate`,children:c.openSystemApp})]}):null,o?[{label:c.recommendedApps,apps:i},{label:c.recentApps,apps:a.filter(e=>!i.some(t=>t.path===e.path))}].map(t=>t.apps.length?(0,Z.jsxs)(`div`,{role:`group`,"aria-label":t.label,children:[(0,Z.jsx)(`div`,{className:`px-2.5 pb-1 pt-1.5 text-xs font-medium text-fg-muted`,children:t.label}),t.apps.map(t=>(0,Z.jsxs)(`button`,{type:`button`,role:`menuitem`,className:s,disabled:C,onClick:()=>e(()=>o(t.path)),children:[(0,Z.jsx)(mt,{app:t}),(0,Z.jsx)(`span`,{className:`min-w-0 flex-1 truncate`,children:t.name})]},t.path))]},t.label):null):null,r?(0,Z.jsxs)(`button`,{type:`button`,role:`menuitem`,className:s,disabled:C||r.disabled,onClick:()=>e(()=>{r.onClick()}),children:[(0,Z.jsx)(f,{className:`size-5 shrink-0 text-fg-muted`,"aria-hidden":!0}),(0,Z.jsx)(`span`,{className:`min-w-0 truncate`,children:c.chooseApp})]}):null,(0,Z.jsx)(`div`,{className:`my-1 border-t border-edge-subtle dark:border-edge`})]})}return(0,Z.jsxs)(`div`,{className:`inline-flex h-9 shrink-0 items-stretch rounded-full border border-edge-subtle bg-surface-panel`,children:[(0,Z.jsxs)(`button`,{type:`button`,"aria-label":w,title:w,disabled:C||!b&&!n,onClick:()=>b?o?.(b.path):n?.onClick(),className:j(`inline-flex min-w-0 items-center gap-2 rounded-l-full pl-3 pr-2 text-sm font-medium text-fg transition-colors hover:bg-surface-hover disabled:cursor-not-allowed disabled:opacity-40`,ce.focusRingPanel),children:[x?(0,Z.jsx)(S,{className:`size-5 animate-spin`,"aria-hidden":!0}):(0,Z.jsx)(mt,{app:b}),(0,Z.jsx)(`span`,{children:s===`zh`?`打开`:`Open`})]}),(0,Z.jsxs)(ye,{modal:!1,children:[(0,Z.jsx)(be,{asChild:!0,children:(0,Z.jsx)(`button`,{type:`button`,"aria-label":c.chooseApp,title:c.chooseApp,disabled:C,className:j(`inline-flex w-8 shrink-0 items-center justify-center rounded-r-full text-fg-muted transition-colors hover:bg-surface-hover hover:text-fg disabled:cursor-not-allowed disabled:opacity-40`,ce.focusRingPanel),children:(0,Z.jsx)(m,{className:`size-4`,strokeWidth:1.75,"aria-hidden":!0})})}),(0,Z.jsx)(U,{children:(0,Z.jsxs)(Ce,{align:`end`,sideOffset:6,collisionPadding:8,"aria-label":c.chooseApp,onEscapeKeyDown:e=>e.stopPropagation(),className:`z-[150] max-h-[var(--radix-dropdown-menu-content-available-height)] w-64 max-w-[calc(100vw-1rem)] overflow-y-auto overscroll-contain rounded-xl border border-edge bg-surface-overlay p-1 shadow-popover outline-none`,children:[n?(0,Z.jsxs)(Se,{className:T,disabled:n.disabled||x,onSelect:()=>{h(null),n.onClick()},children:[(0,Z.jsx)(v,{className:`size-5 shrink-0 text-fg-muted`,strokeWidth:1.75,"aria-hidden":!0}),(0,Z.jsx)(`span`,{className:`min-w-0 flex-1 truncate`,children:c.openSystemApp}),b?null:(0,Z.jsx)(p,{className:`size-4 shrink-0`,"aria-hidden":!0})]}):null,o?[{label:c.recommendedApps,apps:i},{label:c.recentApps,apps:a.filter(e=>!i.some(t=>t.path===e.path))}].map(e=>e.apps.length?(0,Z.jsxs)(xe,{children:[(0,Z.jsx)(we,{className:ee}),(0,Z.jsx)(ve,{className:`px-2.5 pb-1 pt-1.5 text-xs font-medium text-fg-muted`,children:e.label}),e.apps.map(e=>(0,Z.jsxs)(Se,{className:T,disabled:x,title:e.name,onSelect:()=>{h(e),o(e.path)},children:[(0,Z.jsx)(mt,{app:e}),(0,Z.jsx)(`span`,{className:`min-w-0 flex-1 truncate`,children:e.name}),e.path===b?.path?(0,Z.jsx)(p,{className:`size-4 shrink-0`,"aria-hidden":!0}):null]},e.path))]},e.label):null):null,r?(0,Z.jsxs)(Z.Fragment,{children:[(0,Z.jsx)(we,{className:ee}),(0,Z.jsxs)(Se,{className:T,disabled:r.disabled||x,onSelect:async()=>{_(!0);try{let e=await r.onClick();e&&h(e)}finally{_(!1)}},children:[(0,Z.jsx)(f,{className:`size-5 shrink-0 text-fg-muted`,strokeWidth:1.75,"aria-hidden":!0}),(0,Z.jsx)(`span`,{className:`min-w-0 truncate`,children:c.chooseApp})]})]}):null]})})]})]})}var gt=`<base href="about:srcdoc">`;function _t(e){if(/<base(?:\s|>)/i.test(e))return e;let t=/<head(?:\s[^>]*)?>/i.exec(e);if(t?.index!==void 0){let n=t.index+t[0].length;return`${e.slice(0,n)}${gt}${e.slice(n)}`}let n=/<html(?:\s[^>]*)?>/i.exec(e);if(n?.index!==void 0){let t=n.index+n[0].length;return`${e.slice(0,t)}<head>${gt}</head>${e.slice(t)}`}let r=/^\s*<!doctype[^>]*>/i.exec(e);return r?`${r[0]}<head>${gt}</head>${e.slice(r[0].length)}`:`<head>${gt}</head>${e}`}function vt(e){let t=(0,G.c)(8),{html:n,title:r}=e,i=(0,W.useRef)(null),a;t[0]===n?a=t[1]:(a=()=>{i.current?.contentWindow?.postMessage({type:`xopc-html-preview`,html:_t(n)},`*`)},t[0]=n,t[1]=a);let o=a,c;t[2]===o?c=t[3]:(c=[o],t[2]=o,t[3]=c),(0,W.useEffect)(o,c);let l;t[4]===Symbol.for(`react.memo_cache_sentinel`)?(l=s(`/api/preview/html`),t[4]=l):l=t[4];let u;return t[5]!==o||t[6]!==r?(u=(0,Z.jsx)(`iframe`,{ref:i,title:r,className:`min-h-0 w-full flex-1 rounded-lg border border-edge-subtle bg-white dark:border-edge dark:bg-[#1e1e1e]`,src:l,sandbox:`allow-scripts allow-popups allow-popups-to-escape-sandbox allow-downloads allow-forms allow-modals`,referrerPolicy:`no-referrer`,onLoad:o}),t[5]=o,t[6]=r,t[7]=u):u=t[7],u}var yt=(0,W.lazy)(()=>i(()=>import(`./source-workspace-editor-kxosllTu.js`).then(e=>({default:e.SourceWorkspaceEditor})),__vite__mapDeps([4,1,5,6,7,2])));function bt(){let e=(0,G.c)(1),t;return e[0]===Symbol.for(`react.memo_cache_sentinel`)?(t=(0,Z.jsxs)(`div`,{className:`flex h-full min-h-0 flex-col px-4 py-3`,"aria-busy":!0,children:[(0,Z.jsx)(`div`,{className:`h-4 w-11/12 animate-pulse rounded bg-surface-hover`}),(0,Z.jsx)(`div`,{className:`mt-3 h-4 w-9/12 animate-pulse rounded bg-surface-hover`}),(0,Z.jsx)(`div`,{className:`mt-3 h-4 w-10/12 animate-pulse rounded bg-surface-hover`})]}),e[0]=t):t=e[0],t}function xt(e){let t=e.lastIndexOf(`.`);return t>0?e.slice(t).toLowerCase():``}function St(e){return{".ts":`typescript`,".tsx":`tsx`,".js":`javascript`,".jsx":`jsx`,".json":`json`,".css":`css`,".yml":`yaml`,".yaml":`yaml`,".py":`python`,".go":`go`,".rs":`rust`,".sh":`bash`}[xt(e)]??`plaintext`}function Ct(e){let t=(0,G.c)(12),{text:n,targetLine:r}=e,i=(0,W.useRef)(null),a;if(t[0]!==n){let e;t[2]===Symbol.for(`react.memo_cache_sentinel`)?(e=/\r\n|\n|\r/,t[2]=e):e=t[2],a=n.split(e),t[0]=n,t[1]=a}else a=t[1];let o=a,s;t[3]===Symbol.for(`react.memo_cache_sentinel`)?(s=()=>{i.current?.scrollIntoView({block:`center`})},t[3]=s):s=t[3];let c;t[4]!==r||t[5]!==n?(c=[r,n],t[4]=r,t[5]=n,t[6]=c):c=t[6],(0,W.useEffect)(s,c);let l;t[7]!==o||t[8]!==r?(l=o.map((e,t)=>{let n=t+1,a=n===r;return(0,Z.jsxs)(`div`,{ref:a?i:void 0,className:a?`flex bg-accent-soft/60 text-fg`:`flex`,"data-line":n,children:[(0,Z.jsx)(`span`,{className:`w-12 shrink-0 select-none pr-3 text-right text-fg-subtle`,children:n}),(0,Z.jsx)(`span`,{className:`min-w-0 flex-1 whitespace-pre-wrap break-words`,children:e||` `})]},n)}),t[7]=o,t[8]=r,t[9]=l):l=t[9];let u;return t[10]===l?u=t[11]:(u=(0,Z.jsx)(`div`,{className:`min-h-0 flex-1 overflow-auto px-4 py-3`,children:(0,Z.jsx)(`div`,{className:`min-w-max font-mono text-xs leading-relaxed text-fg`,children:l})}),t[10]=l,t[11]=u),u}function wt(e,t){let n=e.textContent??``,r=e.descriptor.context===`workspace`,i=e.workspaceEditing;return r&&i?.sourceEditMode?(0,Z.jsx)(`div`,{className:`min-h-0 flex-1 overflow-hidden`,children:(0,Z.jsx)(W.Suspense,{fallback:(0,Z.jsx)(bt,{}),children:(0,Z.jsx)(yt,{fileName:e.descriptor.fileName,initialContent:n,onChange:e=>i.onSourceChange?.(e),isDark:(i.isDark??e.resolvedTheme===`dark`)===!0,lineWrap:i.sourceWordWrap===!0},e.descriptor.id)})}):t===`markdown`?(0,Z.jsx)(`div`,{className:`min-h-0 flex-1 overflow-y-auto px-4 py-3`,children:(0,Z.jsx)(T,{content:n})}):t===`html`?(0,Z.jsx)(`div`,{className:`flex min-h-0 flex-1 flex-col overflow-hidden px-2 pb-2 pt-1 sm:px-4`,children:(0,Z.jsx)(vt,{html:n,title:e.descriptor.fileName})}):e.targetLine&&e.targetLine>0?(0,Z.jsx)(Ct,{text:n,targetLine:e.targetLine}):t===`code`?(0,Z.jsx)(`div`,{className:`min-h-0 flex-1 overflow-y-auto px-4 py-3`,children:(0,Z.jsx)(T,{content:`\`\`\`${St(e.descriptor.fileName)}\n${n}\n\`\`\``})}):(0,Z.jsx)(`div`,{className:`min-h-0 flex-1 overflow-y-auto px-4 py-3`,children:(0,Z.jsx)(`pre`,{className:`whitespace-pre-wrap break-words font-mono text-xs text-fg`,children:n})})}function Tt(e){return wt(e,`text`)}function Et(e){return wt(e,`markdown`)}function Dt(e){return wt(e,`code`)}function Ot(e){return wt(e,`html`)}function kt(){return(0,W.createElement)(`div`,{className:`px-4 py-6 text-sm text-fg-muted`},`Loading preview...`)}function Q(e,t,n,r=`binary`){let i=(0,W.lazy)(n);return{id:e,readMode:r,capabilities:t,render:e=>(0,W.createElement)(W.Suspense,{fallback:kt()},(0,W.createElement)(i,e))}}var At={text:{id:`text`,readMode:`text`,capabilities:[`download`,`edit`],render:e=>(0,W.createElement)(Tt,e)},markdown:{id:`markdown`,readMode:`text`,capabilities:[`download`,`edit`],render:e=>(0,W.createElement)(Et,e)},code:{id:`code`,readMode:`text`,capabilities:[`download`,`edit`],render:e=>(0,W.createElement)(Dt,e)},html:{id:`html`,readMode:`text`,capabilities:[`download`,`edit`],render:e=>(0,W.createElement)(Ot,e)},image:Q(`image`,[`download`,`zoom`,`rotate`],()=>i(()=>import(`./binary-plugins-D25P9ZxQ.js`).then(e=>({default:e.InteractiveImagePreview})),__vite__mapDeps([8,1,5,2,9,10,11,12,13,14,15,16,17,18,19]))),pdf:Q(`pdf`,[`download`,`zoom`,`rotate`,`pageNavigation`,`print`],()=>i(()=>import(`./binary-plugins-D25P9ZxQ.js`).then(e=>({default:e.PdfPreviewPluginView})),__vite__mapDeps([8,1,5,2,9,10,11,12,13,14,15,16,17,18,19]))),docx:Q(`docx`,[`download`],()=>i(()=>import(`./binary-plugins-D25P9ZxQ.js`).then(e=>({default:e.DocxPreviewPluginView})),__vite__mapDeps([8,1,5,2,9,10,11,12,13,14,15,16,17,18,19]))),spreadsheet:Q(`spreadsheet`,[`download`],()=>i(()=>import(`./binary-plugins-D25P9ZxQ.js`).then(e=>({default:e.SpreadsheetPreviewPluginView})),__vite__mapDeps([8,1,5,2,9,10,11,12,13,14,15,16,17,18,19]))),pptx:Q(`pptx`,[`download`],()=>i(()=>import(`./binary-plugins-D25P9ZxQ.js`).then(e=>({default:e.PptxPreviewPluginView})),__vite__mapDeps([8,1,5,2,9,10,11,12,13,14,15,16,17,18,19]))),audio:Q(`audio`,[`download`],()=>i(()=>import(`./media-plugins-BzzLV7wW.js`).then(e=>({default:e.AudioPreviewPluginView})),__vite__mapDeps([20,1,5,9,10,11,12,13,14,15,16,17,18,19]))),video:Q(`video`,[`download`],()=>i(()=>import(`./media-plugins-BzzLV7wW.js`).then(e=>({default:e.VideoPreviewPluginView})),__vite__mapDeps([20,1,5,9,10,11,12,13,14,15,16,17,18,19]))),archive:Q(`archive`,[`download`],()=>i(()=>import(`./archive-plugin-DBPu3xCJ.js`).then(e=>({default:e.ArchivePreviewPluginView})),__vite__mapDeps([21,1,5,9,22,11,12,13,14,15,16,17,18]))),unsupported:Q(`unsupported`,[`download`],()=>i(()=>import(`./media-plugins-BzzLV7wW.js`).then(e=>({default:e.UnsupportedPreviewPluginView})),__vite__mapDeps([20,1,5,9,10,11,12,13,14,15,16,17,18,19])),`metadata`)};function jt(e){return At[e]??At.unsupported}function Mt(e){let t=(0,G.c)(63),{plugin:n,controls:r,onZoomIn:i,onZoomOut:a,onZoomReset:o,onRotate:s,onSearchChange:c}=e,l;t[0]===n.capabilities?l=t[1]:(l=n.capabilities.includes(`zoom`),t[0]=n.capabilities,t[1]=l);let u=l,d;t[2]===n.capabilities?d=t[3]:(d=n.capabilities.includes(`search`),t[2]=n.capabilities,t[3]=d);let f=d,p;t[4]===n.capabilities?p=t[5]:(p=n.capabilities.includes(`rotate`),t[4]=n.capabilities,t[5]=p);let m=p,h;t[6]!==r||t[7]!==n.capabilities?(h=n.capabilities.includes(`pageNavigation`)&&r.pageCount!=null&&r.pageCount>1,t[6]=r,t[7]=n.capabilities,t[8]=h):h=t[8];let g=h;if(!(u||f||m||g))return null;let _;if(t[9]!==g||t[10]!==m||t[11]!==f||t[12]!==u||t[13]!==r||t[14]!==s||t[15]!==c||t[16]!==i||t[17]!==a||t[18]!==o){let e=[];if(g){let n=r.page<=1,i;t[20]===r?i=t[21]:(i=()=>r.setPage(Math.max(1,r.page-1)),t[20]=r,t[21]=i);let a;t[22]===Symbol.for(`react.memo_cache_sentinel`)?(a=(0,Z.jsx)(De,{className:`size-3.5`}),t[22]=a):a=t[22];let o;t[23]!==n||t[24]!==i?(o=(0,Z.jsx)(Nt,{label:`Previous page`,disabled:n,onClick:i,children:a}),t[23]=n,t[24]=i,t[25]=o):o=t[25];let s;t[26]!==r.page||t[27]!==r.pageCount?(s=(0,Z.jsxs)(`span`,{className:`min-w-16 px-1 text-center text-xs text-fg-muted`,children:[r.page,` / `,r.pageCount]}),t[26]=r.page,t[27]=r.pageCount,t[28]=s):s=t[28];let c=r.page>=(r.pageCount??1),l;t[29]===r?l=t[30]:(l=()=>r.setPage(Math.min(r.pageCount??r.page,r.page+1)),t[29]=r,t[30]=l);let u;t[31]===Symbol.for(`react.memo_cache_sentinel`)?(u=(0,Z.jsx)(Ee,{className:`size-3.5`}),t[31]=u):u=t[31];let d;t[32]!==c||t[33]!==l?(d=(0,Z.jsx)(Nt,{label:`Next page`,disabled:c,onClick:l,children:u}),t[32]=c,t[33]=l,t[34]=d):d=t[34];let f;t[35]!==s||t[36]!==d||t[37]!==o?(f=(0,Z.jsxs)(`div`,{className:`flex items-center gap-1 rounded-md border border-edge-subtle bg-surface-base p-0.5 dark:border-edge`,children:[o,s,d]},`page`),t[35]=s,t[36]=d,t[37]=o,t[38]=f):f=t[38],e.push(f)}if(u){let n;t[39]===Symbol.for(`react.memo_cache_sentinel`)?(n=(0,Z.jsx)(C,{className:`size-3.5`}),t[39]=n):n=t[39];let s;t[40]===a?s=t[41]:(s=(0,Z.jsx)(Nt,{label:`Zoom out`,onClick:a,children:n}),t[40]=a,t[41]=s);let c;t[42]===r.zoom?c=t[43]:(c=Math.round(r.zoom*100),t[42]=r.zoom,t[43]=c);let l;t[44]!==o||t[45]!==c?(l=(0,Z.jsxs)(`button`,{type:`button`,className:`min-w-14 rounded px-1.5 py-1 text-xs text-fg-muted hover:bg-surface-hover hover:text-fg`,onClick:o,title:`Reset zoom`,children:[c,`%`]}),t[44]=o,t[45]=c,t[46]=l):l=t[46];let u;t[47]===Symbol.for(`react.memo_cache_sentinel`)?(u=(0,Z.jsx)(D,{className:`size-3.5`}),t[47]=u):u=t[47];let d;t[48]===i?d=t[49]:(d=(0,Z.jsx)(Nt,{label:`Zoom in`,onClick:i,children:u}),t[48]=i,t[49]=d);let f;t[50]!==d||t[51]!==s||t[52]!==l?(f=(0,Z.jsxs)(`div`,{className:`flex items-center gap-1 rounded-md border border-edge-subtle bg-surface-base p-0.5 dark:border-edge`,children:[s,l,d]},`zoom`),t[50]=d,t[51]=s,t[52]=l,t[53]=f):f=t[53],e.push(f)}if(m){let n;t[54]===Symbol.for(`react.memo_cache_sentinel`)?(n=(0,Z.jsx)(k,{className:`size-3.5`}),t[54]=n):n=t[54];let r;t[55]===s?r=t[56]:(r=(0,Z.jsx)(Nt,{label:`Rotate`,onClick:s,children:n},`rotate`),t[55]=s,t[56]=r),e.push(r)}if(f){let n;t[57]===Symbol.for(`react.memo_cache_sentinel`)?(n=(0,Z.jsx)(A,{className:`size-3.5`,"aria-hidden":!0}),t[57]=n):n=t[57];let i;t[58]===c?i=t[59]:(i=e=>c(e.target.value),t[58]=c,t[59]=i);let a;t[60]!==r.searchQuery||t[61]!==i?(a=(0,Z.jsxs)(`label`,{className:`flex min-w-40 items-center gap-1 rounded-md border border-edge-subtle bg-surface-base px-2 py-1 text-xs text-fg-muted dark:border-edge`,children:[n,(0,Z.jsx)(`input`,{className:`min-w-0 flex-1 bg-transparent text-fg outline-none placeholder:text-fg-subtle`,value:r.searchQuery,onChange:i,placeholder:`Search`})]},`search`),t[60]=r.searchQuery,t[61]=i,t[62]=a):a=t[62],e.push(a)}_=(0,Z.jsx)(`div`,{className:`flex shrink-0 items-center gap-1`,children:e}),t[9]=g,t[10]=m,t[11]=f,t[12]=u,t[13]=r,t[14]=s,t[15]=c,t[16]=i,t[17]=a,t[18]=o,t[19]=_}else _=t[19];return _}function Nt(e){let t=(0,G.c)(6),{label:n,disabled:r,onClick:i,children:a}=e,o;t[0]===Symbol.for(`react.memo_cache_sentinel`)?(o=j(`inline-flex size-9 shrink-0 items-center justify-center rounded-md text-fg-muted transition-colors hover:bg-surface-hover hover:text-fg disabled:opacity-40`),t[0]=o):o=t[0];let s;return t[1]!==a||t[2]!==r||t[3]!==n||t[4]!==i?(s=(0,Z.jsx)(`button`,{type:`button`,className:o,title:n,"aria-label":n,disabled:r,onClick:i,children:a}),t[1]=a,t[2]=r,t[3]=n,t[4]=i,t[5]=s):s=t[5],s}function Pt(e){let t=jt(e.type),n=nt(e.id),[r,i]=(0,W.useState)(n.zoom),[a,o]=(0,W.useState)(n.rotation),[s,c]=(0,W.useState)(n.page),[l,u]=(0,W.useState)(n.pageCount),[d,f]=(0,W.useState)(n.searchQuery),p=(0,W.useCallback)(e=>{c(Math.max(1,Math.min(l??e,Math.floor(e))))},[l]);(0,W.useEffect)(()=>{let t=nt(e.id);i(t.zoom),o(t.rotation),c(t.page),u(t.pageCount),f(t.searchQuery)},[e.id,e.type]);let m=(0,W.useRef)({zoom:r,rotation:a,page:s,pageCount:l,searchQuery:d});return m.current={zoom:r,rotation:a,page:s,pageCount:l,searchQuery:d},(0,W.useEffect)(()=>()=>rt(e.id,m.current),[e.id]),{plugin:t,controls:(0,W.useMemo)(()=>({zoom:r,rotation:a,page:s,pageCount:l,searchQuery:d,setPageCount:u,setPage:p}),[s,l,a,d,p,r]),onZoomIn:()=>i(e=>Math.min(4,Number((e+.15).toFixed(2)))),onZoomOut:()=>i(e=>Math.max(.25,Number((e-.15).toFixed(2)))),onZoomReset:()=>{i(1),o(0)},onRotate:()=>o(e=>(e+90)%360),onSearchChange:f}}function Ft(e){let t=(0,G.c)(8),{controller:n}=e,r;return t[0]!==n.controls||t[1]!==n.onRotate||t[2]!==n.onSearchChange||t[3]!==n.onZoomIn||t[4]!==n.onZoomOut||t[5]!==n.onZoomReset||t[6]!==n.plugin?(r=(0,Z.jsx)(Mt,{plugin:n.plugin,controls:n.controls,onZoomIn:n.onZoomIn,onZoomOut:n.onZoomOut,onZoomReset:n.onZoomReset,onRotate:n.onRotate,onSearchChange:n.onSearchChange}),t[0]=n.controls,t[1]=n.onRotate,t[2]=n.onSearchChange,t[3]=n.onZoomIn,t[4]=n.onZoomOut,t[5]=n.onZoomReset,t[6]=n.plugin,t[7]=r):r=t[7],r}function It(e){let t=(0,G.c)(14),n;t[0]===e.language?n=t[1]:(n=u(e.language),t[0]=e.language,t[1]=n);let r=n,{controller:i}=e;if(e.loading){let e;return t[2]===Symbol.for(`react.memo_cache_sentinel`)?(e=(0,Z.jsxs)(`div`,{className:`flex min-h-0 flex-1 flex-col gap-3 px-4 py-6`,"aria-busy":`true`,children:[(0,Z.jsx)(M,{className:`h-5 w-48 max-w-full`}),(0,Z.jsx)(M,{className:`h-4 w-full`}),(0,Z.jsx)(M,{className:`h-4 w-11/12`}),(0,Z.jsx)(M,{className:`h-4 w-3/4`}),(0,Z.jsx)(M,{className:`mt-3 min-h-48 flex-1 rounded-lg`})]}),t[2]=e):e=t[2],e}if(e.loadError){let n=(e.descriptor.context===`workspace`?r.workspace.loadError:r.chat.attachmentPreviewLoadError)+`: `+e.loadError,i;return t[3]===n?i=t[4]:(i=(0,Z.jsx)(`div`,{className:`flex min-h-0 flex-1 flex-col gap-3 overflow-auto p-4`,children:(0,Z.jsx)(`p`,{className:`text-sm text-red-600 dark:text-red-400`,children:n})}),t[3]=n,t[4]=i),i}if(e.descriptor.context===`attachment`&&e.showExtractedText&&e.descriptor.type!==`image`){let n=e.extractedText||r.chat.attachmentPreviewNoText,i;return t[5]===n?i=t[6]:(i=(0,Z.jsx)(`div`,{className:`flex min-h-0 flex-1 flex-col gap-2 overflow-hidden`,children:(0,Z.jsx)(`div`,{className:`min-h-0 flex-1 overflow-auto rounded-lg border border-edge-subtle bg-surface-hover/40 p-4 dark:border-edge`,children:(0,Z.jsx)(`pre`,{className:`whitespace-pre-wrap break-words font-mono text-xs leading-relaxed text-fg-muted`,children:n})})}),t[5]=n,t[6]=i),i}let a=`${e.descriptor.id}:${i.plugin.id}`,o;t[7]!==i.controls||t[8]!==e?(o={...e,controls:i.controls},t[7]=i.controls,t[8]=e,t[9]=o):o=t[9];let s;return t[10]!==i.plugin.render||t[11]!==a||t[12]!==o?(s=(0,Z.jsx)(`div`,{className:`flex min-h-0 flex-1 flex-col overflow-hidden`,children:(0,Z.jsx)(Lt,{pluginRender:i.plugin.render,props:o},a)}),t[10]=i.plugin.render,t[11]=a,t[12]=o,t[13]=s):s=t[13],s}function Lt(e){let t=(0,G.c)(5),{pluginRender:n,props:r}=e,i;t[0]!==n||t[1]!==r?(i=n(r),t[0]=n,t[1]=r,t[2]=i):i=t[2];let a;return t[3]===i?a=t[4]:(a=(0,Z.jsx)(`div`,{className:`flex min-h-0 flex-1 flex-col`,children:i}),t[3]=i,t[4]=a),a}function Rt(e){let t=(0,G.c)(9),{label:n,active:r,disabled:i,onClick:a,children:o}=e,s=r&&`border-accent/20 bg-accent-soft text-accent-fg`,c;t[0]===s?c=t[1]:(c=j(`inline-flex size-9 shrink-0 items-center justify-center rounded-full border border-edge-subtle bg-surface-panel text-fg-muted transition-colors hover:bg-surface-hover hover:text-fg disabled:cursor-not-allowed disabled:opacity-40`,s,ce.focusRingPanel),t[0]=s,t[1]=c);let l;return t[2]!==r||t[3]!==o||t[4]!==i||t[5]!==n||t[6]!==a||t[7]!==c?(l=(0,Z.jsx)(`button`,{type:`button`,className:c,title:n,"aria-label":n,"aria-pressed":r,disabled:i,onClick:a,children:o}),t[2]=r,t[3]=o,t[4]=i,t[5]=n,t[6]=a,t[7]=c,t[8]=l):l=t[8],l}function $(e){let t=(0,G.c)(14),{icon:n,label:r,active:i,disabled:a,onClick:o}=e,s=i===void 0?`menuitem`:`menuitemcheckbox`,c;t[0]===n?c=t[1]:(c=(0,Z.jsx)(`span`,{className:`flex size-4 shrink-0 items-center justify-center text-fg-muted`,"aria-hidden":!0,children:n}),t[0]=n,t[1]=c);let l;t[2]===r?l=t[3]:(l=(0,Z.jsx)(`span`,{className:`min-w-0 flex-1 truncate`,children:r}),t[2]=r,t[3]=l);let u;t[4]===i?u=t[5]:(u=i?(0,Z.jsx)(p,{className:`size-4 shrink-0`,"aria-hidden":!0}):null,t[4]=i,t[5]=u);let d;return t[6]!==i||t[7]!==a||t[8]!==o||t[9]!==s||t[10]!==c||t[11]!==l||t[12]!==u?(d=(0,Z.jsxs)(`button`,{type:`button`,role:s,"aria-checked":i,className:`flex h-9 w-full min-w-0 items-center gap-2.5 rounded-md px-2.5 text-left text-sm text-fg hover:bg-surface-hover focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-accent disabled:cursor-not-allowed disabled:opacity-40`,disabled:a,onClick:o,children:[c,l,u]}),t[6]=i,t[7]=a,t[8]=o,t[9]=s,t[10]=c,t[11]=l,t[12]=u,t[13]=d):d=t[13],d}function zt(e){let t=(0,G.c)(92),{referenceActions:n,onRefresh:r,onRetrySave:i,subtitle:a,controller:o,actions:s,expanded:c,onToggleExpanded:d,onClose:f,hideClose:m,edit:C,wordWrap:T,editInNewChat:D,share:k,openWithSystemApp:A,chooseApp:M,recommendedApps:N,recentApps:P,onOpenWithApp:ae,onRevealInFolder:oe,copyPath:F,textView:I,openInBrowser:L}=e,se;t[0]===n?se=t[1]:(se=n===void 0?[]:n,t[0]=n,t[1]=se);let R=se,z;t[2]===N?z=t[3]:(z=N===void 0?[]:N,t[2]=N,t[3]=z);let de=z,pe;t[4]===P?pe=t[5]:(pe=P===void 0?[]:P,t[4]=P,t[5]=pe);let me=pe,B=l(Ht),he;t[6]===B?he=t[7]:(he=u(B),t[6]=B,t[7]=he);let V=he,H=V.workspace,ge=o.plugin.id===`pdf`?V.chat.attachmentPreviewPdf:o.plugin.id===`docx`?V.chat.attachmentPreviewDocument:o.plugin.id===`spreadsheet`?V.chat.attachmentPreviewSpreadsheet:H.preview,_e;t[8]===Symbol.for(`react.memo_cache_sentinel`)?(_e=ue(),t[8]=_e):_e=t[8];let ve=_e,ye=(0,W.useContext)(je),be=(0,W.useRef)(null),xe=(0,W.useRef)(null),[U,Se]=(0,W.useState)(!1),Ce;t[9]===o.plugin.capabilities?Ce=t[10]:(Ce=o.plugin.capabilities.some(Vt),t[9]=o.plugin.capabilities,t[10]=Ce);let we=Ce,Ee,De;t[11]===U?(Ee=t[12],De=t[13]):(Ee=()=>{if(!U)return;be.current?.querySelector(`button:not(:disabled), a`)?.focus();let e=e=>{if([`ArrowDown`,`ArrowUp`,`Home`,`End`].includes(e.key)&&be.current?.contains(document.activeElement)){e.preventDefault(),e.stopImmediatePropagation();let t=[...be.current.querySelectorAll(`button:not(:disabled), a`)],n=t.indexOf(document.activeElement);t[e.key===`Home`?0:e.key===`End`?t.length-1:(n+(e.key===`ArrowDown`?1:-1)+t.length)%t.length]?.focus();return}e.key===`Escape`&&(e.preventDefault(),e.stopImmediatePropagation(),Se(!1),xe.current?.focus())};return window.addEventListener(`keydown`,e,!0),()=>window.removeEventListener(`keydown`,e,!0)},De=[U],t[11]=U,t[12]=Ee,t[13]=De),(0,W.useEffect)(Ee,De);let K;t[14]===Symbol.for(`react.memo_cache_sentinel`)?(K=e=>{Se(!1),xe.current?.focus(),e()},t[14]=K):K=t[14];let q=K,ke;t[15]===Symbol.for(`react.memo_cache_sentinel`)?(ke=j(`shrink-0 bg-surface-base px-3 py-2 sm:px-4`,le),t[15]=ke):ke=t[15];let Ae;t[16]===ye?Ae=t[17]:(Ae=ye?(0,Z.jsx)(Rt,{label:ye.label,active:ye.active,onClick:ye.onToggle,children:(0,Z.jsx)(Te,{className:`size-4`,strokeWidth:1.75,"aria-hidden":!0})}):null,t[16]=ye,t[17]=Ae);let Me=c?H.collapsePreview:H.expandPreview,Ne=!d,Pe;t[18]===c?Pe=t[19]:(Pe=c?(0,Z.jsx)(te,{className:`size-4`,"aria-hidden":!0}):(0,Z.jsx)(w,{className:`size-4`,"aria-hidden":!0}),t[18]=c,t[19]=Pe);let Fe;t[20]!==c||t[21]!==d||t[22]!==Me||t[23]!==Ne||t[24]!==Pe?(Fe=(0,Z.jsx)(Rt,{label:Me,active:c,disabled:Ne,onClick:d,children:Pe}),t[20]=c,t[21]=d,t[22]=Me,t[23]=Ne,t[24]=Pe,t[25]=Fe):Fe=t[25];let Ie;t[26]===U?Ie=t[27]:(Ie=U?(0,Z.jsx)(`button`,{type:`button`,className:`fixed inset-0 z-40 cursor-default bg-transparent`,"aria-hidden":!0,tabIndex:-1,onPointerDown:e=>{e.preventDefault(),Se(!1)}}):null,t[26]=U,t[27]=Ie);let Le;t[28]===Symbol.for(`react.memo_cache_sentinel`)?(Le=j(`inline-flex size-9 shrink-0 items-center justify-center rounded-full border border-edge-subtle bg-surface-panel text-fg-muted transition-colors hover:bg-surface-hover hover:text-fg`,ce.focusRingPanel),t[28]=Le):Le=t[28];let Re,ze;t[29]===Symbol.for(`react.memo_cache_sentinel`)?(Re=()=>Se(Bt),ze=(0,Z.jsx)(_,{className:`size-4`}),t[29]=Re,t[30]=ze):(Re=t[29],ze=t[30]);let Be;t[31]!==H.moreActions||t[32]!==U?(Be=(0,Z.jsx)(`button`,{ref:xe,type:`button`,className:Le,title:H.moreActions,"aria-label":H.moreActions,"aria-haspopup":`menu`,"aria-expanded":U,onClick:Re,children:ze}),t[31]=H.moreActions,t[32]=U,t[33]=Be):Be=t[33];let Ve;t[34]!==s||t[35]!==M||t[36]!==o.plugin.capabilities||t[37]!==F||t[38]!==C||t[39]!==D||t[40]!==B||t[41]!==H.copyFilePath||t[42]!==H.copyWorkspacePath||t[43]!==H.download||t[44]!==H.edit||t[45]!==H.editInNewChat||t[46]!==H.moreActions||t[47]!==H.openInBrowser||t[48]!==H.pathCopied||t[49]!==H.preview||t[50]!==H.revealInFolder||t[51]!==H.saveCopy||t[52]!==H.shareLink||t[53]!==H.wordWrap||t[54]!==U||t[55]!==ae||t[56]!==r||t[57]!==i||t[58]!==oe||t[59]!==L||t[60]!==A||t[61]!==me||t[62]!==de||t[63]!==R||t[64]!==k||t[65]!==T?(Ve=U?(0,Z.jsxs)(`div`,{ref:be,role:`menu`,"aria-label":H.moreActions,"data-file-preview-menu":!0,className:`absolute right-0 top-full z-50 mt-1 max-h-[min(32rem,calc(100dvh-8rem))] w-60 max-w-[calc(100vw-2rem)] overflow-y-auto overscroll-contain rounded-lg border border-edge bg-surface-overlay p-1 shadow-popover`,children:[(0,Z.jsx)(ht,{variant:`menu`,onAction:q,systemApp:A,chooseApp:M,recommendedApps:de,recentApps:me,onOpenWithApp:ae}),R.map(e=>(0,Z.jsx)($,{icon:(0,Z.jsx)(E,{className:`size-4`}),label:e.label,disabled:e.disabled,onClick:()=>q(e.onClick)},e.label)),i?(0,Z.jsx)($,{icon:(0,Z.jsx)(re,{className:`size-4`}),label:B===`zh`?`重试保存`:`Retry save`,onClick:()=>q(i)}):null,r?(0,Z.jsx)($,{icon:(0,Z.jsx)(O,{className:`size-4`}),label:B===`zh`?`刷新文件`:`Refresh file`,onClick:()=>q(r)}):null,o.plugin.capabilities.includes(`edit`)?(0,Z.jsx)($,{icon:C?.active?(0,Z.jsx)(y,{className:`size-4`}):(0,Z.jsx)(ne,{className:`size-4`}),label:C?.active?H.preview:H.edit,disabled:!C,onClick:()=>q(()=>C?.onToggle())}):null,T?(0,Z.jsx)($,{icon:(0,Z.jsx)(Oe,{className:`size-4`}),label:H.wordWrap,active:T.active,onClick:()=>q(T.onToggle)}):null,(0,Z.jsx)(`div`,{className:`my-1 border-t border-edge-subtle dark:border-edge`}),(0,Z.jsx)($,{icon:D?.loading?(0,Z.jsx)(S,{className:`size-4 animate-spin`}):(0,Z.jsx)(ee,{className:`size-4`}),label:H.editInNewChat,disabled:!D||D.disabled||D.loading,onClick:()=>q(()=>D?.onClick())}),(0,Z.jsx)($,{icon:k?.loading?(0,Z.jsx)(S,{className:`size-4 animate-spin`}):(0,Z.jsx)(x,{className:`size-4`}),label:H.shareLink,disabled:!k||k.disabled||k.loading,onClick:()=>q(()=>k?.onClick())}),(0,Z.jsx)(`div`,{className:`my-1 border-t border-edge-subtle dark:border-edge`}),L?(0,Z.jsxs)(`a`,{href:L.href,target:`_blank`,rel:`noopener noreferrer`,role:`menuitem`,className:`flex h-9 w-full items-center gap-2.5 rounded-md px-2.5 text-sm text-fg hover:bg-surface-hover`,onClick:()=>Se(!1),children:[(0,Z.jsx)(v,{className:`size-4 text-fg-muted`,"aria-hidden":!0}),H.openInBrowser]}):null,oe?(0,Z.jsx)($,{icon:(0,Z.jsx)(b,{className:`size-4`}),label:H.revealInFolder,onClick:()=>q(oe)}):null,oe?(0,Z.jsx)(`div`,{className:`my-1 border-t border-edge-subtle dark:border-edge`}):null,(0,Z.jsx)($,{icon:(0,Z.jsx)(g,{className:`size-4`}),label:ve?H.saveCopy:H.download,disabled:!s.canDownload,onClick:()=>q(()=>void s.onDownload())}),F?(0,Z.jsx)($,{icon:F.copied?(0,Z.jsx)(p,{className:`size-4 text-emerald-500`}):(0,Z.jsx)(h,{className:`size-4`}),label:F.copied?H.pathCopied:ve?H.copyFilePath:H.copyWorkspacePath,onClick:()=>q(F.onClick)}):null]}):null,t[34]=s,t[35]=M,t[36]=o.plugin.capabilities,t[37]=F,t[38]=C,t[39]=D,t[40]=B,t[41]=H.copyFilePath,t[42]=H.copyWorkspacePath,t[43]=H.download,t[44]=H.edit,t[45]=H.editInNewChat,t[46]=H.moreActions,t[47]=H.openInBrowser,t[48]=H.pathCopied,t[49]=H.preview,t[50]=H.revealInFolder,t[51]=H.saveCopy,t[52]=H.shareLink,t[53]=H.wordWrap,t[54]=U,t[55]=ae,t[56]=r,t[57]=i,t[58]=oe,t[59]=L,t[60]=A,t[61]=me,t[62]=de,t[63]=R,t[64]=k,t[65]=T,t[66]=Ve):Ve=t[66];let He;t[67]!==Ie||t[68]!==Be||t[69]!==Ve?(He=(0,Z.jsxs)(`div`,{className:`relative shrink-0`,children:[Ie,Be,Ve]}),t[67]=Ie,t[68]=Be,t[69]=Ve,t[70]=He):He=t[70];let Ue;t[71]!==m||t[72]!==H.close||t[73]!==f?(Ue=m?null:(0,Z.jsxs)(Z.Fragment,{children:[(0,Z.jsx)(`div`,{className:`mx-0.5 h-5 w-px bg-edge-subtle`,"aria-hidden":!0}),(0,Z.jsx)(Rt,{label:H.close,onClick:f,children:(0,Z.jsx)(ie,{className:`size-4`,strokeWidth:1.75})})]}),t[71]=m,t[72]=H.close,t[73]=f,t[74]=Ue):Ue=t[74];let J;t[75]!==Ae||t[76]!==Fe||t[77]!==He||t[78]!==Ue?(J=(0,Z.jsx)(`div`,{className:`flex min-w-0 flex-wrap items-center gap-2`,children:(0,Z.jsxs)(`div`,{className:`ml-auto flex shrink-0 items-center gap-1.5`,children:[Ae,Fe,He,Ue]})}),t[75]=Ae,t[76]=Fe,t[77]=He,t[78]=Ue,t[79]=J):J=t[79];let Y;t[80]===a?Y=t[81]:(Y=a?(0,Z.jsx)(`div`,{className:`mt-1.5 flex min-h-4 min-w-0 items-center gap-2 px-3 text-xs leading-4 text-fg-muted`,children:a}):null,t[80]=a,t[81]=Y);let X;t[82]!==o||t[83]!==we||t[84]!==V.chat||t[85]!==ge||t[86]!==I?(X=we||I?(0,Z.jsxs)(`div`,{className:`mt-2 flex items-center gap-2 overflow-x-auto pb-0.5`,children:[I?(0,Z.jsx)(fe,{className:`mr-2 flex shrink-0 rounded-lg bg-surface-hover p-0.5`,role:`group`,"aria-label":V.chat.attachmentPreviewText,children:[{active:!1,label:ge},{active:!0,label:V.chat.attachmentPreviewText}].map(e=>(0,Z.jsx)(`button`,{type:`button`,"aria-pressed":I.active===e.active,className:j(`rounded-md px-2.5 py-1 text-xs font-medium`,I.active===e.active?`bg-surface-hover text-fg`:`text-fg-muted hover:text-fg`),onClick:()=>I.onChange(e.active),children:e.label},e.label))}):null,we?(0,Z.jsx)(Ft,{controller:o}):null]}):null,t[82]=o,t[83]=we,t[84]=V.chat,t[85]=ge,t[86]=I,t[87]=X):X=t[87];let We;return t[88]!==J||t[89]!==Y||t[90]!==X?(We=(0,Z.jsxs)(`div`,{"data-workspace-toolbar":!0,className:ke,children:[J,Y,X]}),t[88]=J,t[89]=Y,t[90]=X,t[91]=We):We=t[91],We}function Bt(e){return!e}function Vt(e){return[`zoom`,`search`,`rotate`,`pageNavigation`].includes(e)}function Ht(e){return e.language}function Ut({header:e,chat:t,...n}){let r=(0,W.useRef)(null);(0,W.useEffect)(()=>{let e=r.current;if(!e)return;let t=()=>{let t=nt(n.descriptor.id).scroll;e.querySelectorAll(`[class*="overflow-auto"], [class*="overflow-y-auto"], .cm-scroller`).forEach((e,n)=>{t[n]!=null&&(e.scrollTop=t[n])})},i=requestAnimationFrame(t),a=typeof MutationObserver<`u`?new MutationObserver(t):null;a?.observe(e,{childList:!0,subtree:!0});let o=()=>rt(n.descriptor.id,{scroll:[...e.querySelectorAll(`[class*="overflow-auto"], [class*="overflow-y-auto"], .cm-scroller`)].map(e=>e.scrollTop)});return e.addEventListener(`scroll`,o,!0),()=>{cancelAnimationFrame(i),a?.disconnect(),e.removeEventListener(`scroll`,o,!0)}},[n.descriptor.id]);let i=(0,W.useContext)(Ae),[o,s]=(0,W.useState)(!1),c=Pt(n.descriptor),l=a(),d=u(n.language),[f,p]=(0,W.useState)(!1),m=async()=>{if(!(!t||f)){p(!0);try{let[n,r]=await Promise.all([t.createFile(),t.conversationId?ae(t.conversationId).catch(()=>null):Promise.resolve(null)]);if(n.size>33554432){K(`warning`,d.chat.attachmentFileTooLarge,{name:n.name,maxSize:L(P)});return}let i=new URLSearchParams({attachmentHandoff:dt(n)}),a=t.projectId?.trim()||r?.projectId?.trim(),o=t.agentId?.trim()||r?.routing?.agentId?.trim();a&&i.set(`projectId`,a),l({pathname:`/chat/new`,search:`?${i}`},{state:{forceNewChat:!0,agentId:o||void 0}}),e.onClose()}catch{K(`error`,d.workspace.editInNewChatFailed)}finally{p(!1)}}};return(0,Z.jsxs)(`div`,{ref:r,className:`flex h-full min-h-0 min-w-0 flex-1 flex-col overflow-hidden bg-transparent`,children:[(0,Z.jsx)(zt,{...e,name:n.descriptor.fileName,filePath:n.descriptor.source.kind===`workspace`?n.descriptor.source.path:void 0,controller:c,actions:n.actions,referenceActions:t?i.map(e=>({label:e.label,disabled:o||n.loading||!!n.loadError||t.disabled,onClick:async()=>{if(!o){s(!0);try{let r=await t.createFile(),i=await ot(e.id,r);K(i?`success`:`warning`,n.language===`zh`?i?`已添加到目标聊天草稿`:`未能添加附件,请确认目标聊天可用及附件限制`:i?`Added to the target chat draft`:`Could not add attachment. Check the target chat and attachment limits.`)}catch{K(`error`,n.language===`zh`?`文件引用失败,原草稿已保留`:`Could not reference file. Your draft is retained.`)}finally{s(!1)}}}})):void 0,editInNewChat:t?{onClick:()=>void m(),loading:f,disabled:n.loading||!!n.loadError||t.disabled}:void 0},n.descriptor.id),(0,Z.jsx)(It,{...n,controller:c})]})}function Wt(e,t){let n=(0,G.c)(7),r=e===void 0||e,i=t!==void 0&&t,[a,o]=(0,W.useState)(!1);!r&&a&&o(!1);let s,c;n[0]!==r||n[1]!==i||n[2]!==a?(s=()=>{if(!r||!a)return;let e=document.body.style.overflow;document.body.style.overflow=`hidden`;let t=e=>{i||e.key!==`Escape`||e.defaultPrevented||document.querySelector(`[data-file-preview-menu]`)||(e.preventDefault(),e.stopImmediatePropagation(),o(!1))};return window.addEventListener(`keydown`,t,!0),()=>{document.body.style.overflow=e,window.removeEventListener(`keydown`,t,!0)}},c=[r,a,i],n[0]=r,n[1]=i,n[2]=a,n[3]=s,n[4]=c):(s=n[3],c=n[4]),(0,W.useEffect)(s,c);let l;return n[5]===a?l=n[6]:(l={expanded:a,setExpanded:o},n[5]=a,n[6]=l),l}export{De as C,Oe as S,Te as T,Ae as _,at as a,ke as b,et as c,Ne as d,Me as f,We as g,Y as h,pt as i,Ye as l,J as m,Ut as n,nt as o,X as p,ft as r,rt as s,Wt as t,Ge as u,q as v,Ee as w,K as x,je as y};
1
+ const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["assets/attachment-process-heavy-DGZZ-M85.js","assets/rolldown-runtime-aKtaBQYM.js","assets/preload-helper-Czpn1I53.js","assets/pdf-runtime-JnUAvfIa.js","assets/source-workspace-editor-kxosllTu.js","assets/vendor-react-BOUWij0V.js","assets/vendor-codemirror-aCQ0FcJT.js","assets/languages-zXtNocoy.js","assets/binary-plugins-CuwSdCG5.js","assets/messages-jwdBhfL9.js","assets/attachment-utils-core-BIOUBrpT.js","assets/preview-open-alternatives-CY_hjK4b.js","assets/download-Dk-ZjtO6.js","assets/createLucideIcon-DPHK1VkS.js","assets/external-link-DjqjBmc3.js","assets/cn-0WouolD0.js","assets/bundle-mjs-rHxsej31.js","assets/interaction-BdhHBbYa.js","assets/electron-env-DHOGevH3.js","assets/use-blob-object-url-D4BFuzZB.js","assets/media-plugins-D987i9Gc.js","assets/archive-plugin-Bg1VTieK.js","assets/jszip.min-Dj17eJqX.js"])))=>i.map(i=>d[i]);
2
+ import{i as e}from"./rolldown-runtime-aKtaBQYM.js";import{a as t,n,t as r}from"./vendor-react-BOUWij0V.js";import{t as i}from"./preload-helper-Czpn1I53.js";import{u as a}from"./chunk-KS7C4IRE-CiwuuyV8.js";import{a as o,i as s,l as c,n as l}from"./locale-store-B6OrWgY1.js";import{t as u}from"./messages-jwdBhfL9.js";import{t as d}from"./createLucideIcon-DPHK1VkS.js";import{t as f}from"./app-window-DXFNqt_0.js";import{t as p}from"./check-DUBLcKHA.js";import{t as m}from"./chevron-down-ccbiQQz_.js";import{t as h}from"./copy-Dv6d4Dvw.js";import{t as g}from"./download-Dk-ZjtO6.js";import{t as _}from"./ellipsis-0k4rZLoy.js";import{t as v}from"./external-link-DjqjBmc3.js";import{t as y}from"./eye-CABVeTq0.js";import{t as b}from"./folder-open-CyzJ19I9.js";import{t as x}from"./link-2-D_ZKYUW7.js";import{t as S}from"./loader-circle-CifKLtgG.js";import{G as C,K as w,t as T}from"./markdown-view-DrhYZSmg.js";import{t as ee}from"./message-square-plus-XP0tGdlV.js";import{t as te}from"./minimize-2-DtOGrlpo.js";import{t as E}from"./paperclip-f1HujQY1.js";import{t as ne}from"./pencil-DmIY3Oa-.js";import{t as D}from"./plus-Q2yW6OE7.js";import{t as O}from"./refresh-cw-BRlGaq2w.js";import{t as k}from"./rotate-cw-LIg3Am9S.js";import{t as re}from"./save-DRDABU--.js";import{t as A}from"./search-DA7gz22f.js";import{t as ie}from"./x-B_N4OPjy.js";import{t as j}from"./cn-0WouolD0.js";import{t as M}from"./skeleton-BI5TyibZ.js";import{r as N,t as P}from"./constants-DBtMsXdW.js";import{a as ae}from"./session-api-Bfmlmn9F.js";import{a as oe,i as F,n as I,r as L,s as se,t as R}from"./attachment-utils-core-BIOUBrpT.js";import{n as ce}from"./interaction-BdhHBbYa.js";import{t as z}from"./activity-store-BpYGrRXw.js";import{r as le}from"./app-chrome-BeB4KgOf.js";import{n as ue}from"./electron-env-DHOGevH3.js";import{t as de}from"./use-async-resource-BHFGZCY2.js";import{t as fe}from"./sliding-tab-list-DuQyViqe.js";import{t as pe}from"./index.module-Cd9ENXfk.js";import{a as me,c as B,d as he,m as V,n as H,r as ge,u as _e}from"./workspace-api-HBXn8pL9.js";import{a as ve,l as ye,m as be,n as xe,o as U,r as Se,t as Ce,u as we}from"./dist-ZrL34Ps4.js";var Te=d(`folders`,[[`path`,{d:`M20 5a2 2 0 0 1 2 2v7a2 2 0 0 1-2 2H9a2 2 0 0 1-2-2V5a2 2 0 0 1 2-2h2.5a1.5 1.5 0 0 1 1.2.6l.6.8a1.5 1.5 0 0 0 1.2.6z`,key:`a4852j`}],[`path`,{d:`M3 8.268a2 2 0 0 0-1 1.738V19a2 2 0 0 0 2 2h11a2 2 0 0 0 1.732-1`,key:`yxbcw3`}]]),Ee=d(`step-forward`,[[`path`,{d:`M10.029 4.285A2 2 0 0 0 7 6v12a2 2 0 0 0 3.029 1.715l9.997-5.998a2 2 0 0 0 .003-3.432z`,key:`1ystz2`}],[`path`,{d:`M3 4v16`,key:`1ph11n`}]]),De=d(`step-back`,[[`path`,{d:`M13.971 4.285A2 2 0 0 1 17 6v12a2 2 0 0 1-3.029 1.715l-9.997-5.998a2 2 0 0 1-.003-3.432z`,key:`19qhus`}],[`path`,{d:`M21 20V4`,key:`cb8qj8`}]]),Oe=d(`text-wrap`,[[`path`,{d:`m16 16-3 3 3 3`,key:`117b85`}],[`path`,{d:`M3 12h14.5a1 1 0 0 1 0 7H13`,key:`18xa6z`}],[`path`,{d:`M3 19h6`,key:`1ygdsz`}],[`path`,{d:`M3 5h18`,key:`1u36vt`}]]),W=e(t(),1),G=n();function K(e,t,n,r){let i=n?t.replace(/\{\{(\w+)\}\}/g,(e,t)=>String(n[t]??``)):t;z({tone:e,title:i,href:r?.href,dedupeKey:`action-feedback:${e}:${i}`})}var q=(0,W.createContext)(null);function ke(){return(0,W.useContext)(q)}var Ae=(0,W.createContext)([]),je=(0,W.createContext)(null),Me=5*1024*1024,Ne=32*1024*1024,Pe=new Set(`.astro,.bat,.c,.cc,.clj,.cljs,.cljc,.cmd,.cpp,.cs,.cts,.cxx,.dart,.edn,.erl,.ex,.exs,.fish,.fs,.fsx,.go,.gql,.graphql,.groovy,.h,.hh,.hpp,.hrl,.hxx,.java,.ts,.tsx,.mts,.js,.jsx,.mjs,.cjs,.css,.scss,.sass,.less,.json,.jsonc,.json5,.yml,.yaml,.xml,.xsd,.xsl,.py,.pyw,.rb,.php,.rs,.kt,.kts,.scala,.swift,.m,.mm,.sh,.bash,.zsh,.ps1,.sql,.lua,.r,.pl,.pm,.sol,.tf,.tfvars,.nix,.proto,.vue,.svelte,.toml,.ini,.cfg,.conf,.properties`.split(`,`)),Fe=new Set([`.txt`,`.log`,`.lock`,`.csv`,`.tsv`,`.env`,`.gitignore`,`.gitattributes`,`.editorconfig`,`.npmrc`,`.dockerignore`,`.eslintignore`,`.prettierignore`,`.stylelintignore`]),Ie=new Set([`dockerfile`,`gemfile`,`jenkinsfile`,`makefile`,`procfile`,`rakefile`]),Le=new Set([`brewfile`,`changelog`,`codeowners`,`license`,`readme`]),Re=new Set([`.png`,`.jpg`,`.jpeg`,`.gif`,`.webp`,`.bmp`,`.ico`,`.svg`,`.svgz`,`.tif`,`.tiff`,`.avif`,`.heic`,`.heif`,`.jxl`]),ze=new Set([`.mp3`,`.wav`,`.ogg`,`.oga`,`.aac`,`.m4a`,`.flac`,`.opus`,`.weba`]),Be=new Set([`.mp4`,`.webm`,`.mov`,`.m4v`,`.ogv`]),Ve=new Set([`.zip`]),He=new Map([[`.pdf`,`application/pdf`],[`.docx`,`application/vnd.openxmlformats-officedocument.wordprocessingml.document`],[`.pptx`,`application/vnd.openxmlformats-officedocument.presentationml.presentation`],[`.xlsx`,`application/vnd.openxmlformats-officedocument.spreadsheetml.sheet`],[`.xls`,`application/vnd.ms-excel`],[`.md`,`text/markdown`],[`.markdown`,`text/markdown`],[`.html`,`text/html`],[`.htm`,`text/html`],[`.json`,`application/json`],[`.txt`,`text/plain`],[`.csv`,`text/csv`],[`.tsv`,`text/tab-separated-values`],[`.png`,`image/png`],[`.jpg`,`image/jpeg`],[`.jpeg`,`image/jpeg`],[`.gif`,`image/gif`],[`.webp`,`image/webp`],[`.svg`,`image/svg+xml`],[`.svgz`,`image/svg+xml`],[`.mp3`,`audio/mpeg`],[`.wav`,`audio/wav`],[`.ogg`,`audio/ogg`],[`.mp4`,`video/mp4`],[`.webm`,`video/webm`],[`.mov`,`video/quicktime`],[`.zip`,`application/zip`]]);function Ue(e){let t=J(e),n=t.lastIndexOf(`.`);return n<0||n===t.length-1?``:t.slice(n).toLowerCase()}function J(e){let t=e.replace(/\\/g,`/`).split(`/`);return t[t.length-1]||e}function Y(e,t){let n=t?.split(`;`)[0]?.trim().toLowerCase();return n&&n!==`application/octet-stream`?n:He.get(Ue(e))??n??`application/octet-stream`}function X(e,t){let n=Ue(e),r=J(e).toLowerCase(),i=Y(e,t);return i===`text/markdown`||n===`.md`||n===`.markdown`?`markdown`:i===`text/html`||n===`.html`||n===`.htm`?`html`:i===`application/pdf`||n===`.pdf`?`pdf`:i===`application/vnd.openxmlformats-officedocument.wordprocessingml.document`||n===`.docx`?`docx`:i===`application/vnd.openxmlformats-officedocument.spreadsheetml.sheet`||i===`application/vnd.ms-excel`||n===`.xlsx`||n===`.xls`?`spreadsheet`:i===`application/vnd.openxmlformats-officedocument.presentationml.presentation`||n===`.pptx`?`pptx`:i.startsWith(`image/`)||Re.has(n)?`image`:i.startsWith(`audio/`)||ze.has(n)?`audio`:i.startsWith(`video/`)||Be.has(n)?`video`:i===`application/zip`||Ve.has(n)?`archive`:Pe.has(n)||Ie.has(r)||r.startsWith(`dockerfile.`)?`code`:i.startsWith(`text/`)||Fe.has(n)||Le.has(r)||r.startsWith(`.env.`)||i===`application/json`?`text`:`unsupported`}function We(e){switch(e){case`text`:case`markdown`:case`code`:case`html`:return`text`;case`unsupported`:return`metadata`;default:return`binary`}}async function Ge(e){let{uri:t,conversationId:n,taskId:r}=e;try{let e=N(t),i=await o(s(e?`/api/files/${encodeURIComponent(e)}/content`:se(t,n,r)));return i.ok?{ok:!0,blob:await i.blob()}:{ok:!1,reason:`http`,status:i.status}}catch(e){return{ok:!1,reason:`network`,message:e instanceof Error?e.message:String(e)}}}async function Ke(e){let t=await Ge(e);return t.ok?{ok:!0,buffer:await t.blob.arrayBuffer()}:t}function qe(e){return e.id?String(e.id):`${e.name}:${e.uri??``}`}function Je(){return{id:`__empty__`,context:`attachment`,fileName:``,mimeType:`application/octet-stream`,type:`unsupported`,source:{kind:`inline`}}}function Ye(e){let t=(0,G.c)(65),{open:n,attachment:r,authToken:i,conversationId:a,language:o}=e,[s,c]=(0,W.useState)(n?r:null),[l,d]=(0,W.useState)(!1),[f,p]=(0,W.useState)(!1),m;t[0]!==r||t[1]!==n?(m=n&&r?qe(r):null,t[0]=r,t[1]=n,t[2]=m):m=t[2];let h=m,g=(0,W.useRef)(h);h!==g.current&&(g.current=h,c(n&&r?r:null),d(!1),p(!1));let _=s,v;bb0:{if(!_){let e;t[3]===Symbol.for(`react.memo_cache_sentinel`)?(e=Je(),t[3]=e):e=t[3],v=e;break bb0}let e=_.name??`attachment`,n,r;t[4]!==e||t[5]!==_.mimeType?(n=Y(e,_.mimeType),r=X(e,n),t[4]=e,t[5]=_.mimeType,t[6]=n,t[7]=r):(n=t[6],r=t[7]);let i=r,o=_.id?String(_.id):`${e}:${_.uri??``}`,s;t[8]!==a||t[9]!==_.uri?(s=_.uri?{kind:`media-uri`,uri:_.uri,conversationId:a}:{kind:`inline`},t[8]=a,t[9]=_.uri,t[10]=s):s=t[10];let c;t[11]!==e||t[12]!==n||t[13]!==_.size||t[14]!==o||t[15]!==s||t[16]!==i?(c={id:o,context:`attachment`,fileName:e,mimeType:n,size:_.size,type:i,source:s},t[11]=e,t[12]=n,t[13]=_.size,t[14]=o,t[15]=s,t[16]=i,t[17]=c):c=t[17],v=c}let y=v,b;t[18]===_?b=t[19]:(b=_?F(_):void 0,t[18]=_,t[19]=b);let x=b,S=_?.uri,C;t[20]===y.type?C=t[21]:(C=We(y.type),t[20]=y.type,t[21]=C);let w=C,T=!!(n&&S&&!x&&i&&(w===`binary`||w===`text`)),ee;t[22]!==a||t[23]!==o||t[24]!==S||t[25]!==_?.taskId?(ee=async()=>{let e=u(o).chat,t=await Ke({uri:S,conversationId:a,taskId:_?.taskId});if(!t.ok)throw t.reason===`http`?Error(`${e.attachmentPreviewLoadError} (HTTP ${t.status})`):Error(t.message);return t.buffer},t[22]=a,t[23]=o,t[24]=S,t[25]=_?.taskId,t[26]=ee):ee=t[26];let te=_?.taskId,E;t[27]!==i||t[28]!==a||t[29]!==x||t[30]!==o||t[31]!==S||t[32]!==n||t[33]!==w||t[34]!==te?(E=[n,S,i,o,x,te,a,w],t[27]=i,t[28]=a,t[29]=x,t[30]=o,t[31]=S,t[32]=n,t[33]=w,t[34]=te,t[35]=E):E=t[35];let ne;t[36]===T?ne=t[37]:(ne={enabled:T,initial:null,errorData:null},t[36]=T,t[37]=ne);let D=de(ee,E,ne),O;bb1:{if(x)try{let e;t[38]===x?e=t[39]:(e=I(x),t[38]=x,t[39]=e),O=e;break bb1}catch{O=null;break bb1}if(T&&D.loading){O=null;break bb1}O=D.data??null}let k=O,re=w===`binary`?k:null,A=_?.extractedText??``,ie;t[40]!==k||t[41]!==A||t[42]!==o||t[43]!==w?(ie=w===`text`?A||(k?new TextDecoder(`utf-8`,{fatal:!1}).decode(new Uint8Array(k)):u(o).chat.attachmentPreviewNoText):null,t[40]=k,t[41]=A,t[42]=o,t[43]=w,t[44]=ie):ie=t[44];let j=ie,M=!!_?.extractedText,N=y.type===`pptx`&&A.length>3e5,P;t[45]!==i||t[46]!==x||t[47]!==o||t[48]!==S||t[49]!==n||t[50]!==w?(P=n&&S&&!x&&!i&&w===`binary`?u(o).chat.attachmentPreviewMissingAuth:null,t[45]=i,t[46]=x,t[47]=o,t[48]=S,t[49]=n,t[50]=w,t[51]=P):P=t[51];let ae=P,oe=D.error?D.error instanceof Error?D.error.message:String(D.error):null,L=f?null:ae??oe,se=T?D.loading:!1,R;t[52]===Symbol.for(`react.memo_cache_sentinel`)?(R=()=>p(!0),t[52]=R):R=t[52];let ce=A||null,z;return t[53]!==re||t[54]!==y||t[55]!==k||t[56]!==N||t[57]!==M||t[58]!==L||t[59]!==_||t[60]!==l||t[61]!==se||t[62]!==ce||t[63]!==j?(z={preview:_,descriptor:y,fileType:y.type,fileName:y.fileName,loading:se,loadError:L,clearLoadError:R,textContent:j,binaryBuffer:re,downloadBuffer:k,hasExtractedText:M,extractedText:ce,extractedTextTruncated:N,showExtractedText:l,setShowExtractedText:d},t[53]=re,t[54]=y,t[55]=k,t[56]=N,t[57]=M,t[58]=L,t[59]=_,t[60]=l,t[61]=se,t[62]=ce,t[63]=j,t[64]=z):z=t[64],z}function Xe(e){let t=(0,G.c)(12),{projectId:n,conversationId:r,agentId:i}=e,a;bb0:{let e;t[0]===n?e=t[1]:(e=n?.trim(),t[0]=n,t[1]=e);let o=e;if(o){let e;t[2]===o?e=t[3]:(e={projectId:o},t[2]=o,t[3]=e),a=e;break bb0}let s;t[4]===r?s=t[5]:(s=r?.trim(),t[4]=r,t[5]=s);let c=s;if(c){let e;t[6]===c?e=t[7]:(e={conversationId:c},t[6]=c,t[7]=e),a=e;break bb0}let l;t[8]===i?l=t[9]:(l=i?.trim(),t[8]=i,t[9]=l);let u=l,d;t[10]===u?d=t[11]:(d=u?{agentId:u}:void 0,t[10]=u,t[11]=d),a=d}return a}function Ze(e){return{descriptor:e,textContent:null,binaryBuffer:null,fileResourceId:null,mtimeMs:null,loadError:null,loading:!1,pptxText:null,pptxTruncated:!1,pptxError:null}}function Qe(e,t){switch(t.type){case`clear`:return Ze(t.descriptor);case`loadStart`:return{...Ze(t.descriptor),loading:!0};case`loadSuccess`:return{...e,descriptor:t.payload.descriptor,textContent:t.payload.textContent??null,binaryBuffer:t.payload.binaryBuffer??null,fileResourceId:t.payload.fileResourceId??null,mtimeMs:t.payload.mtimeMs??null,loadError:null,loading:!1};case`loadError`:return{...Ze(t.descriptor),loadError:t.error};case`patchMtime`:return{...e,mtimeMs:t.mtimeMs};case`patchText`:return{...e,textContent:t.text};case`pptxClear`:return{...e,pptxText:null,pptxTruncated:!1,pptxError:null};case`pptxSuccess`:return{...e,pptxText:t.text,pptxTruncated:t.truncated,pptxError:null};case`pptxError`:return{...e,pptxText:null,pptxTruncated:!1,pptxError:t.error}}}function $e(e,t){switch(t.type){case`reset`:return{sourceEditMode:!1,saveStatus:`idle`};case`source`:return{...e,sourceEditMode:typeof t.value==`function`?t.value(e.sourceEditMode):t.value};case`saveStatus`:return{...e,saveStatus:t.value}}}function et({filePath:e,projectId:t,conversationId:n,agentId:r,initialEditMode:a=!1}){let o=Xe({projectId:t,conversationId:n,agentId:r}),s=(0,W.useMemo)(()=>{let t=e?J(e):``,i=Y(t,oe(t)),a=e?X(t,i):`unsupported`;return{id:e||`__empty__`,context:`workspace`,fileName:t,mimeType:i,type:a,source:{kind:`workspace`,path:e||``,conversationId:n,agentId:r}}},[r,e,n]),[c,l]=(0,W.useReducer)(Qe,s,Ze),[u,d]=(0,W.useReducer)($e,{sourceEditMode:a,saveStatus:`idle`}),[f,p]=(0,W.useState)([]),[m,h]=(0,W.useState)([]),g=(0,W.useRef)(e),_=(0,W.useRef)(void 0),v=(0,W.useRef)(null),y=(0,W.useRef)(null),b=(0,W.useRef)(null),[x,S]=(0,W.useState)(!1),[C,w]=(0,W.useState)(!1),[T,ee]=(0,W.useState)(0);g.current!==e&&(g.current=e,d({type:`reset`})),(0,W.useEffect)(()=>{if(!e){l({type:`clear`,descriptor:s});return}let t=!1;l({type:`loadStart`,descriptor:s});let n=We(s.type),r=e=>{t||l({type:`loadError`,descriptor:s,error:e instanceof Error?e.message:String(e)})};return n===`metadata`?(Promise.all([he(e,o).catch(()=>null),_e(e,o).catch(()=>null)]).then(async([n,r])=>{if(!n){t||l({type:`loadSuccess`,payload:{descriptor:s,fileResourceId:r?.fileId??null,mtimeMs:typeof r?.mtimeMs==`number`?r.mtimeMs:null}});return}let i={...s,mimeType:n.mimeType,type:X(n.name,n.mimeType)};if(We(i.type)===`text`){let{content:r,mtimeMs:a,revision:s}=await B(e,o);t||(_.current=s,v.current=r,y.current=r,S(!1),w(!1)),t||l({type:`loadSuccess`,payload:{descriptor:i,textContent:r,fileResourceId:n.id,mtimeMs:typeof a==`number`?a:n.modifiedAt}});return}t||l({type:`loadSuccess`,payload:{descriptor:i,fileResourceId:n.id,mtimeMs:n.modifiedAt}})}).catch(r),()=>{t=!0}):(n===`text`?Promise.all([B(e,o),_e(e,o).catch(()=>null)]).then(([{content:e,mtimeMs:n,revision:r},i])=>{t||(_.current=r,v.current=e,y.current=e,S(!1),w(!1)),t||l({type:`loadSuccess`,payload:{descriptor:s,textContent:e,fileResourceId:i?.fileId??null,mtimeMs:typeof n==`number`?n:null}})}).catch(r):Promise.all([me(e,o),_e(e,o).catch(()=>null)]).then(async([e,n])=>{let r=await e.arrayBuffer();t||l({type:`loadSuccess`,payload:{descriptor:s,binaryBuffer:r,fileResourceId:n?.fileId??null,mtimeMs:typeof n?.mtimeMs==`number`?n.mtimeMs:null}})}).catch(r),()=>{t=!0})},[s,e,o,T]),(0,W.useEffect)(()=>{if(!c.binaryBuffer||c.descriptor.type!==`pptx`){l({type:`pptxClear`});return}let e=!1;return l({type:`pptxClear`}),i(()=>import(`./attachment-process-heavy-DGZZ-M85.js`).then(e=>e.processPptx(c.binaryBuffer,c.descriptor.fileName)),__vite__mapDeps([0,1,2,3])).then(({extractedText:t})=>{if(e)return;let n=t.length>R;l({type:`pptxSuccess`,text:n?t.slice(0,R):t,truncated:n})}).catch(t=>{e||l({type:`pptxError`,error:t instanceof Error?t.message:String(t)})}),()=>{e=!0}},[c.binaryBuffer,c.descriptor.fileName,c.descriptor.type]);let te=(0,W.useCallback)(async()=>{if(b.current&&!await b.current)return!1;if(!e||v.current===null||v.current===y.current)return!0;let t=(async()=>{d({type:`saveStatus`,value:`saving`});try{for(;v.current!==y.current;){let t=v.current,n=await V(e,t,o,_.current);_.current=n.revision,y.current=t,typeof n.mtimeMs==`number`&&l({type:`patchMtime`,mtimeMs:n.mtimeMs})}return S(!1),d({type:`saveStatus`,value:`saved`}),!0}catch{return d({type:`saveStatus`,value:`error`}),!1}})();b.current=t;try{return await t}finally{b.current===t&&(b.current=null)}},[e,o]),E=pe(()=>void te(),500),ne=(0,W.useCallback)(e=>{v.current=e,S(e!==y.current),l({type:`patchText`,text:e}),E()},[E]);(0,W.useEffect)(()=>{let e=e=>{v.current!==y.current&&(e.preventDefault(),e.returnValue=``)};return window.addEventListener(`beforeunload`,e),()=>{window.removeEventListener(`beforeunload`,e),E.cancel()}},[E]);let D=(0,W.useCallback)(()=>{!x&&!b.current&&ee(e=>e+1)},[x]),O=(0,W.useRef)(!1),k=(0,W.useCallback)(async()=>{if(!(!e||c.loading||b.current||O.current)){O.current=!0;try{let t=await he(e,o);if(!t||!(_.current?t.revision!==_.current:c.mtimeMs!=null&&t.modifiedAt!==c.mtimeMs))return;x||u.sourceEditMode?w(!0):D()}catch{w(!0)}finally{O.current=!1}}},[x,u.sourceEditMode,e,c.loading,c.mtimeMs,o,D]),re=(0,W.useCallback)(async()=>{if(!e)return;let t=J(e);if(c.binaryBuffer){H(t,c.binaryBuffer,c.descriptor.mimeType||`application/octet-stream`);return}if(c.textContent!=null){ge(t,c.textContent);return}let n=await me(e,o);H(t,await n.arrayBuffer(),c.descriptor.mimeType||n.type||`application/octet-stream`)},[e,c.binaryBuffer,c.descriptor.mimeType,c.textContent,o]),A=(0,W.useCallback)(async()=>{if(!e)throw Error(`No workspace file selected`);let t=J(e),n=c.descriptor.mimeType||`application/octet-stream`,r;return r=c.binaryBuffer?new Blob([c.binaryBuffer],{type:n}):c.textContent==null?await me(e,o):new Blob([c.textContent],{type:n}),new File([r],t,{type:c.descriptor.mimeType||r.type||`application/octet-stream`,lastModified:c.mtimeMs??Date.now()})},[e,c.binaryBuffer,c.descriptor.mimeType,c.mtimeMs,c.textContent,o]),ie=!c.loading&&!!e,j=ue()&&(!!c.fileResourceId&&!!window.electronAPI?.shell?.openFileResource||c.descriptor.type===`spreadsheet`&&!!c.binaryBuffer&&!!window.electronAPI?.shell?.openTemporaryFile),M=ue()&&!!c.fileResourceId&&!!window.electronAPI?.shell?.chooseAppAndOpenFileResource,N=(0,W.useCallback)(async()=>{let e=c.fileResourceId;if(!ue()||!e||!window.electronAPI?.shell?.getOpenWithAppsForFileResource){h([]),p([]);return}try{let t=await window.electronAPI.shell.getOpenWithAppsForFileResource(e);h(t.recommended.map(e=>({name:e.name,path:e.path,iconDataUrl:e.iconDataUrl}))),p(t.recent.map(e=>({name:e.name,path:e.path,iconDataUrl:e.iconDataUrl,lastUsedAt:e.lastUsedAt})))}catch{h([]),p([])}},[c.fileResourceId]);(0,W.useEffect)(()=>{N()},[N]);let P=(0,W.useCallback)(async()=>{let e=c.fileResourceId;if(e&&window.electronAPI?.shell?.openFileResource)return window.electronAPI.shell.openFileResource(e);if(c.descriptor.type===`spreadsheet`&&c.binaryBuffer&&window.electronAPI?.shell?.openTemporaryFile)return window.electronAPI.shell.openTemporaryFile({fileName:c.descriptor.fileName,data:new Uint8Array(c.binaryBuffer)})},[c.binaryBuffer,c.descriptor.fileName,c.descriptor.type,c.fileResourceId]),ae=(0,W.useCallback)(async()=>{let e=c.fileResourceId;if(!e||!window.electronAPI?.shell?.chooseAppAndOpenFileResource)return;let t=await window.electronAPI.shell.chooseAppAndOpenFileResource(e);return t.ok&&N(),t},[c.fileResourceId,N]),F=(0,W.useCallback)(async e=>{let t=c.fileResourceId;if(!t||!e||!window.electronAPI?.shell?.openFileResourceWithApp)return;let n=await window.electronAPI.shell.openFileResourceWithApp(t,e);return n.ok&&N(),n},[c.fileResourceId,N]),I=ue()&&!!c.fileResourceId&&!!window.electronAPI?.shell?.showFileResourceInFolder,L=(0,W.useCallback)(async()=>{let e=c.fileResourceId;if(e&&window.electronAPI?.shell?.showFileResourceInFolder)return window.electronAPI.shell.showFileResourceInFolder(e)},[c.fileResourceId]);return{...c,dirty:x,externalChange:C,flushSource:te,refresh:D,checkForUpdates:k,extractedText:c.descriptor.type===`pptx`?c.pptxText:null,extractedTextTruncated:c.pptxTruncated,sourceEditMode:u.sourceEditMode,setSourceEditMode:e=>d({type:`source`,value:e}),saveStatus:u.saveStatus,onSourceChange:ne,onDownload:re,createAttachmentFile:A,canDownload:ie,canOpenWithSystemApp:j,onOpenWithSystemApp:P,canChooseOpenWithApp:M,onChooseOpenWithApp:ae,recommendedOpenWithApps:m,recentOpenWithApps:f,onOpenWithRecentApp:F,canRevealInFolder:I,onRevealInFolder:L}}var tt=new Map;function nt(e){return tt.get(e)??{zoom:1,rotation:0,page:1,pageCount:null,searchQuery:``,scroll:[]}}function rt(e,t){let n={...nt(e),...t};for(tt.delete(e),tt.set(e,n);tt.size>100;)tt.delete(tt.keys().next().value)}c.subscribe((e,t)=>{(e.baseUrl!==t.baseUrl||e.conversationId!==t.conversationId)&&tt.clear()});var it=new Map;function at(e,t){return it.set(e,t),()=>{it.get(e)===t&&it.delete(e)}}async function ot(e,t){return await it.get(e)?.(t)??!1}var st=120*1e3,ct=new Map;function lt(){return typeof globalThis.crypto?.randomUUID==`function`?globalThis.crypto.randomUUID():`${Date.now().toString(36)}-${Math.random().toString(36).slice(2)}`}function ut(e){for(let[t,n]of ct)n.expiresAt<=e&&ct.delete(t)}function dt(e,t=Date.now()){ut(t);let n=lt();return ct.set(n,{file:e,name:e.name,type:e.type,expiresAt:t+st}),n}function ft(e,t=Date.now()){let n=ct.get(e);return n?n.expiresAt<=t?(ct.delete(e),null):{name:n.name,type:n.type}:null}function pt(e,t=Date.now()){let n=ct.get(e);if(!n)return null;if(n.expiresAt<=t)return ct.delete(e),null;if(!n.file)return null;let r=n.file;return n.file=null,r}var Z=r();function mt(e){let t=(0,G.c)(3),{app:n}=e,[r,i]=(0,W.useState)(),a;return t[0]!==n||t[1]!==r?(a=n?.iconDataUrl&&n.iconDataUrl!==r?(0,Z.jsx)(`img`,{src:n.iconDataUrl,alt:``,width:20,height:20,className:`size-5 shrink-0 object-contain`,onError:()=>i(n.iconDataUrl)}):(0,Z.jsx)(f,{className:`size-5 shrink-0 text-fg-muted`,strokeWidth:1.75,"aria-hidden":!0}),t[0]=n,t[1]=r,t[2]=a):a=t[2],a}function ht({variant:e=`split`,onAction:t,systemApp:n,chooseApp:r,recommendedApps:i,recentApps:a,onOpenWithApp:o}){let s=l(e=>e.language),c=u(s).workspace,[d,h]=(0,W.useState)(),[g,_]=(0,W.useState)(!1),y=[...i,...a],b=o&&d!==null?y.find(e=>e.path===d?.path)??d??y[0]:void 0,x=!!(g||n?.loading||r?.loading),C=x||!!n?.disabled,w=b?s===`zh`?`用 ${b.name} 打开`:`Open with ${b.name}`:c.openSystemApp,T=`flex min-h-9 cursor-default items-center gap-2.5 rounded-md px-2.5 py-2 text-sm text-fg outline-none data-[highlighted]:bg-surface-hover data-[disabled]:pointer-events-none data-[disabled]:opacity-40`,ee=`my-1 h-px bg-edge-subtle`;if(!n&&!r&&(!o||!y.length))return null;if(e===`menu`){let e=e=>t?t(e):e(),s=`flex min-h-9 w-full items-center gap-2.5 rounded-md px-2.5 py-2 text-left text-sm text-fg hover:bg-surface-hover focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-accent disabled:cursor-not-allowed disabled:opacity-40`;return(0,Z.jsxs)(Z.Fragment,{children:[n?(0,Z.jsxs)(`button`,{type:`button`,role:`menuitem`,className:s,disabled:C,onClick:()=>e(n.onClick),children:[(0,Z.jsx)(v,{className:`size-5 shrink-0 text-fg-muted`,"aria-hidden":!0}),(0,Z.jsx)(`span`,{className:`min-w-0 flex-1 truncate`,children:c.openSystemApp})]}):null,o?[{label:c.recommendedApps,apps:i},{label:c.recentApps,apps:a.filter(e=>!i.some(t=>t.path===e.path))}].map(t=>t.apps.length?(0,Z.jsxs)(`div`,{role:`group`,"aria-label":t.label,children:[(0,Z.jsx)(`div`,{className:`px-2.5 pb-1 pt-1.5 text-xs font-medium text-fg-muted`,children:t.label}),t.apps.map(t=>(0,Z.jsxs)(`button`,{type:`button`,role:`menuitem`,className:s,disabled:C,onClick:()=>e(()=>o(t.path)),children:[(0,Z.jsx)(mt,{app:t}),(0,Z.jsx)(`span`,{className:`min-w-0 flex-1 truncate`,children:t.name})]},t.path))]},t.label):null):null,r?(0,Z.jsxs)(`button`,{type:`button`,role:`menuitem`,className:s,disabled:C||r.disabled,onClick:()=>e(()=>{r.onClick()}),children:[(0,Z.jsx)(f,{className:`size-5 shrink-0 text-fg-muted`,"aria-hidden":!0}),(0,Z.jsx)(`span`,{className:`min-w-0 truncate`,children:c.chooseApp})]}):null,(0,Z.jsx)(`div`,{className:`my-1 border-t border-edge-subtle dark:border-edge`})]})}return(0,Z.jsxs)(`div`,{className:`inline-flex h-9 shrink-0 items-stretch rounded-full border border-edge-subtle bg-surface-panel`,children:[(0,Z.jsxs)(`button`,{type:`button`,"aria-label":w,title:w,disabled:C||!b&&!n,onClick:()=>b?o?.(b.path):n?.onClick(),className:j(`inline-flex min-w-0 items-center gap-2 rounded-l-full pl-3 pr-2 text-sm font-medium text-fg transition-colors hover:bg-surface-hover disabled:cursor-not-allowed disabled:opacity-40`,ce.focusRingPanel),children:[x?(0,Z.jsx)(S,{className:`size-5 animate-spin`,"aria-hidden":!0}):(0,Z.jsx)(mt,{app:b}),(0,Z.jsx)(`span`,{children:s===`zh`?`打开`:`Open`})]}),(0,Z.jsxs)(ye,{modal:!1,children:[(0,Z.jsx)(be,{asChild:!0,children:(0,Z.jsx)(`button`,{type:`button`,"aria-label":c.chooseApp,title:c.chooseApp,disabled:C,className:j(`inline-flex w-8 shrink-0 items-center justify-center rounded-r-full text-fg-muted transition-colors hover:bg-surface-hover hover:text-fg disabled:cursor-not-allowed disabled:opacity-40`,ce.focusRingPanel),children:(0,Z.jsx)(m,{className:`size-4`,strokeWidth:1.75,"aria-hidden":!0})})}),(0,Z.jsx)(U,{children:(0,Z.jsxs)(Ce,{align:`end`,sideOffset:6,collisionPadding:8,"aria-label":c.chooseApp,onEscapeKeyDown:e=>e.stopPropagation(),className:`z-[150] max-h-[var(--radix-dropdown-menu-content-available-height)] w-64 max-w-[calc(100vw-1rem)] overflow-y-auto overscroll-contain rounded-xl border border-edge bg-surface-overlay p-1 shadow-popover outline-none`,children:[n?(0,Z.jsxs)(Se,{className:T,disabled:n.disabled||x,onSelect:()=>{h(null),n.onClick()},children:[(0,Z.jsx)(v,{className:`size-5 shrink-0 text-fg-muted`,strokeWidth:1.75,"aria-hidden":!0}),(0,Z.jsx)(`span`,{className:`min-w-0 flex-1 truncate`,children:c.openSystemApp}),b?null:(0,Z.jsx)(p,{className:`size-4 shrink-0`,"aria-hidden":!0})]}):null,o?[{label:c.recommendedApps,apps:i},{label:c.recentApps,apps:a.filter(e=>!i.some(t=>t.path===e.path))}].map(e=>e.apps.length?(0,Z.jsxs)(xe,{children:[(0,Z.jsx)(we,{className:ee}),(0,Z.jsx)(ve,{className:`px-2.5 pb-1 pt-1.5 text-xs font-medium text-fg-muted`,children:e.label}),e.apps.map(e=>(0,Z.jsxs)(Se,{className:T,disabled:x,title:e.name,onSelect:()=>{h(e),o(e.path)},children:[(0,Z.jsx)(mt,{app:e}),(0,Z.jsx)(`span`,{className:`min-w-0 flex-1 truncate`,children:e.name}),e.path===b?.path?(0,Z.jsx)(p,{className:`size-4 shrink-0`,"aria-hidden":!0}):null]},e.path))]},e.label):null):null,r?(0,Z.jsxs)(Z.Fragment,{children:[(0,Z.jsx)(we,{className:ee}),(0,Z.jsxs)(Se,{className:T,disabled:r.disabled||x,onSelect:async()=>{_(!0);try{let e=await r.onClick();e&&h(e)}finally{_(!1)}},children:[(0,Z.jsx)(f,{className:`size-5 shrink-0 text-fg-muted`,strokeWidth:1.75,"aria-hidden":!0}),(0,Z.jsx)(`span`,{className:`min-w-0 truncate`,children:c.chooseApp})]})]}):null]})})]})]})}var gt=`<base href="about:srcdoc">`;function _t(e){if(/<base(?:\s|>)/i.test(e))return e;let t=/<head(?:\s[^>]*)?>/i.exec(e);if(t?.index!==void 0){let n=t.index+t[0].length;return`${e.slice(0,n)}${gt}${e.slice(n)}`}let n=/<html(?:\s[^>]*)?>/i.exec(e);if(n?.index!==void 0){let t=n.index+n[0].length;return`${e.slice(0,t)}<head>${gt}</head>${e.slice(t)}`}let r=/^\s*<!doctype[^>]*>/i.exec(e);return r?`${r[0]}<head>${gt}</head>${e.slice(r[0].length)}`:`<head>${gt}</head>${e}`}function vt(e){let t=(0,G.c)(8),{html:n,title:r}=e,i=(0,W.useRef)(null),a;t[0]===n?a=t[1]:(a=()=>{i.current?.contentWindow?.postMessage({type:`xopc-html-preview`,html:_t(n)},`*`)},t[0]=n,t[1]=a);let o=a,c;t[2]===o?c=t[3]:(c=[o],t[2]=o,t[3]=c),(0,W.useEffect)(o,c);let l;t[4]===Symbol.for(`react.memo_cache_sentinel`)?(l=s(`/api/preview/html`),t[4]=l):l=t[4];let u;return t[5]!==o||t[6]!==r?(u=(0,Z.jsx)(`iframe`,{ref:i,title:r,className:`min-h-0 w-full flex-1 rounded-lg border border-edge-subtle bg-white dark:border-edge dark:bg-[#1e1e1e]`,src:l,sandbox:`allow-scripts allow-popups allow-popups-to-escape-sandbox allow-downloads allow-forms allow-modals`,referrerPolicy:`no-referrer`,onLoad:o}),t[5]=o,t[6]=r,t[7]=u):u=t[7],u}var yt=(0,W.lazy)(()=>i(()=>import(`./source-workspace-editor-kxosllTu.js`).then(e=>({default:e.SourceWorkspaceEditor})),__vite__mapDeps([4,1,5,6,7,2])));function bt(){let e=(0,G.c)(1),t;return e[0]===Symbol.for(`react.memo_cache_sentinel`)?(t=(0,Z.jsxs)(`div`,{className:`flex h-full min-h-0 flex-col px-4 py-3`,"aria-busy":!0,children:[(0,Z.jsx)(`div`,{className:`h-4 w-11/12 animate-pulse rounded bg-surface-hover`}),(0,Z.jsx)(`div`,{className:`mt-3 h-4 w-9/12 animate-pulse rounded bg-surface-hover`}),(0,Z.jsx)(`div`,{className:`mt-3 h-4 w-10/12 animate-pulse rounded bg-surface-hover`})]}),e[0]=t):t=e[0],t}function xt(e){let t=e.lastIndexOf(`.`);return t>0?e.slice(t).toLowerCase():``}function St(e){return{".ts":`typescript`,".tsx":`tsx`,".js":`javascript`,".jsx":`jsx`,".json":`json`,".css":`css`,".yml":`yaml`,".yaml":`yaml`,".py":`python`,".go":`go`,".rs":`rust`,".sh":`bash`}[xt(e)]??`plaintext`}function Ct(e){let t=(0,G.c)(12),{text:n,targetLine:r}=e,i=(0,W.useRef)(null),a;if(t[0]!==n){let e;t[2]===Symbol.for(`react.memo_cache_sentinel`)?(e=/\r\n|\n|\r/,t[2]=e):e=t[2],a=n.split(e),t[0]=n,t[1]=a}else a=t[1];let o=a,s;t[3]===Symbol.for(`react.memo_cache_sentinel`)?(s=()=>{i.current?.scrollIntoView({block:`center`})},t[3]=s):s=t[3];let c;t[4]!==r||t[5]!==n?(c=[r,n],t[4]=r,t[5]=n,t[6]=c):c=t[6],(0,W.useEffect)(s,c);let l;t[7]!==o||t[8]!==r?(l=o.map((e,t)=>{let n=t+1,a=n===r;return(0,Z.jsxs)(`div`,{ref:a?i:void 0,className:a?`flex bg-accent-soft/60 text-fg`:`flex`,"data-line":n,children:[(0,Z.jsx)(`span`,{className:`w-12 shrink-0 select-none pr-3 text-right text-fg-subtle`,children:n}),(0,Z.jsx)(`span`,{className:`min-w-0 flex-1 whitespace-pre-wrap break-words`,children:e||` `})]},n)}),t[7]=o,t[8]=r,t[9]=l):l=t[9];let u;return t[10]===l?u=t[11]:(u=(0,Z.jsx)(`div`,{className:`min-h-0 flex-1 overflow-auto px-4 py-3`,children:(0,Z.jsx)(`div`,{className:`min-w-max font-mono text-xs leading-relaxed text-fg`,children:l})}),t[10]=l,t[11]=u),u}function wt(e,t){let n=e.textContent??``,r=e.descriptor.context===`workspace`,i=e.workspaceEditing;return r&&i?.sourceEditMode?(0,Z.jsx)(`div`,{className:`min-h-0 flex-1 overflow-hidden`,children:(0,Z.jsx)(W.Suspense,{fallback:(0,Z.jsx)(bt,{}),children:(0,Z.jsx)(yt,{fileName:e.descriptor.fileName,initialContent:n,onChange:e=>i.onSourceChange?.(e),isDark:(i.isDark??e.resolvedTheme===`dark`)===!0,lineWrap:i.sourceWordWrap===!0},e.descriptor.id)})}):t===`markdown`?(0,Z.jsx)(`div`,{className:`min-h-0 flex-1 overflow-y-auto px-4 py-3`,children:(0,Z.jsx)(T,{content:n})}):t===`html`?(0,Z.jsx)(`div`,{className:`flex min-h-0 flex-1 flex-col overflow-hidden px-2 pb-2 pt-1 sm:px-4`,children:(0,Z.jsx)(vt,{html:n,title:e.descriptor.fileName})}):e.targetLine&&e.targetLine>0?(0,Z.jsx)(Ct,{text:n,targetLine:e.targetLine}):t===`code`?(0,Z.jsx)(`div`,{className:`min-h-0 flex-1 overflow-y-auto px-4 py-3`,children:(0,Z.jsx)(T,{content:`\`\`\`${St(e.descriptor.fileName)}\n${n}\n\`\`\``})}):(0,Z.jsx)(`div`,{className:`min-h-0 flex-1 overflow-y-auto px-4 py-3`,children:(0,Z.jsx)(`pre`,{className:`whitespace-pre-wrap break-words font-mono text-xs text-fg`,children:n})})}function Tt(e){return wt(e,`text`)}function Et(e){return wt(e,`markdown`)}function Dt(e){return wt(e,`code`)}function Ot(e){return wt(e,`html`)}function kt(){return(0,W.createElement)(`div`,{className:`px-4 py-6 text-sm text-fg-muted`},`Loading preview...`)}function Q(e,t,n,r=`binary`){let i=(0,W.lazy)(n);return{id:e,readMode:r,capabilities:t,render:e=>(0,W.createElement)(W.Suspense,{fallback:kt()},(0,W.createElement)(i,e))}}var At={text:{id:`text`,readMode:`text`,capabilities:[`download`,`edit`],render:e=>(0,W.createElement)(Tt,e)},markdown:{id:`markdown`,readMode:`text`,capabilities:[`download`,`edit`],render:e=>(0,W.createElement)(Et,e)},code:{id:`code`,readMode:`text`,capabilities:[`download`,`edit`],render:e=>(0,W.createElement)(Dt,e)},html:{id:`html`,readMode:`text`,capabilities:[`download`,`edit`],render:e=>(0,W.createElement)(Ot,e)},image:Q(`image`,[`download`,`zoom`,`rotate`],()=>i(()=>import(`./binary-plugins-CuwSdCG5.js`).then(e=>({default:e.InteractiveImagePreview})),__vite__mapDeps([8,1,5,2,9,10,11,12,13,14,15,16,17,18,19]))),pdf:Q(`pdf`,[`download`,`zoom`,`rotate`,`pageNavigation`,`print`],()=>i(()=>import(`./binary-plugins-CuwSdCG5.js`).then(e=>({default:e.PdfPreviewPluginView})),__vite__mapDeps([8,1,5,2,9,10,11,12,13,14,15,16,17,18,19]))),docx:Q(`docx`,[`download`],()=>i(()=>import(`./binary-plugins-CuwSdCG5.js`).then(e=>({default:e.DocxPreviewPluginView})),__vite__mapDeps([8,1,5,2,9,10,11,12,13,14,15,16,17,18,19]))),spreadsheet:Q(`spreadsheet`,[`download`],()=>i(()=>import(`./binary-plugins-CuwSdCG5.js`).then(e=>({default:e.SpreadsheetPreviewPluginView})),__vite__mapDeps([8,1,5,2,9,10,11,12,13,14,15,16,17,18,19]))),pptx:Q(`pptx`,[`download`],()=>i(()=>import(`./binary-plugins-CuwSdCG5.js`).then(e=>({default:e.PptxPreviewPluginView})),__vite__mapDeps([8,1,5,2,9,10,11,12,13,14,15,16,17,18,19]))),audio:Q(`audio`,[`download`],()=>i(()=>import(`./media-plugins-D987i9Gc.js`).then(e=>({default:e.AudioPreviewPluginView})),__vite__mapDeps([20,1,5,9,10,11,12,13,14,15,16,17,18,19]))),video:Q(`video`,[`download`],()=>i(()=>import(`./media-plugins-D987i9Gc.js`).then(e=>({default:e.VideoPreviewPluginView})),__vite__mapDeps([20,1,5,9,10,11,12,13,14,15,16,17,18,19]))),archive:Q(`archive`,[`download`],()=>i(()=>import(`./archive-plugin-Bg1VTieK.js`).then(e=>({default:e.ArchivePreviewPluginView})),__vite__mapDeps([21,1,5,9,22,11,12,13,14,15,16,17,18]))),unsupported:Q(`unsupported`,[`download`],()=>i(()=>import(`./media-plugins-D987i9Gc.js`).then(e=>({default:e.UnsupportedPreviewPluginView})),__vite__mapDeps([20,1,5,9,10,11,12,13,14,15,16,17,18,19])),`metadata`)};function jt(e){return At[e]??At.unsupported}function Mt(e){let t=(0,G.c)(63),{plugin:n,controls:r,onZoomIn:i,onZoomOut:a,onZoomReset:o,onRotate:s,onSearchChange:c}=e,l;t[0]===n.capabilities?l=t[1]:(l=n.capabilities.includes(`zoom`),t[0]=n.capabilities,t[1]=l);let u=l,d;t[2]===n.capabilities?d=t[3]:(d=n.capabilities.includes(`search`),t[2]=n.capabilities,t[3]=d);let f=d,p;t[4]===n.capabilities?p=t[5]:(p=n.capabilities.includes(`rotate`),t[4]=n.capabilities,t[5]=p);let m=p,h;t[6]!==r||t[7]!==n.capabilities?(h=n.capabilities.includes(`pageNavigation`)&&r.pageCount!=null&&r.pageCount>1,t[6]=r,t[7]=n.capabilities,t[8]=h):h=t[8];let g=h;if(!(u||f||m||g))return null;let _;if(t[9]!==g||t[10]!==m||t[11]!==f||t[12]!==u||t[13]!==r||t[14]!==s||t[15]!==c||t[16]!==i||t[17]!==a||t[18]!==o){let e=[];if(g){let n=r.page<=1,i;t[20]===r?i=t[21]:(i=()=>r.setPage(Math.max(1,r.page-1)),t[20]=r,t[21]=i);let a;t[22]===Symbol.for(`react.memo_cache_sentinel`)?(a=(0,Z.jsx)(De,{className:`size-3.5`}),t[22]=a):a=t[22];let o;t[23]!==n||t[24]!==i?(o=(0,Z.jsx)(Nt,{label:`Previous page`,disabled:n,onClick:i,children:a}),t[23]=n,t[24]=i,t[25]=o):o=t[25];let s;t[26]!==r.page||t[27]!==r.pageCount?(s=(0,Z.jsxs)(`span`,{className:`min-w-16 px-1 text-center text-xs text-fg-muted`,children:[r.page,` / `,r.pageCount]}),t[26]=r.page,t[27]=r.pageCount,t[28]=s):s=t[28];let c=r.page>=(r.pageCount??1),l;t[29]===r?l=t[30]:(l=()=>r.setPage(Math.min(r.pageCount??r.page,r.page+1)),t[29]=r,t[30]=l);let u;t[31]===Symbol.for(`react.memo_cache_sentinel`)?(u=(0,Z.jsx)(Ee,{className:`size-3.5`}),t[31]=u):u=t[31];let d;t[32]!==c||t[33]!==l?(d=(0,Z.jsx)(Nt,{label:`Next page`,disabled:c,onClick:l,children:u}),t[32]=c,t[33]=l,t[34]=d):d=t[34];let f;t[35]!==s||t[36]!==d||t[37]!==o?(f=(0,Z.jsxs)(`div`,{className:`flex items-center gap-1 rounded-md border border-edge-subtle bg-surface-base p-0.5 dark:border-edge`,children:[o,s,d]},`page`),t[35]=s,t[36]=d,t[37]=o,t[38]=f):f=t[38],e.push(f)}if(u){let n;t[39]===Symbol.for(`react.memo_cache_sentinel`)?(n=(0,Z.jsx)(C,{className:`size-3.5`}),t[39]=n):n=t[39];let s;t[40]===a?s=t[41]:(s=(0,Z.jsx)(Nt,{label:`Zoom out`,onClick:a,children:n}),t[40]=a,t[41]=s);let c;t[42]===r.zoom?c=t[43]:(c=Math.round(r.zoom*100),t[42]=r.zoom,t[43]=c);let l;t[44]!==o||t[45]!==c?(l=(0,Z.jsxs)(`button`,{type:`button`,className:`min-w-14 rounded px-1.5 py-1 text-xs text-fg-muted hover:bg-surface-hover hover:text-fg`,onClick:o,title:`Reset zoom`,children:[c,`%`]}),t[44]=o,t[45]=c,t[46]=l):l=t[46];let u;t[47]===Symbol.for(`react.memo_cache_sentinel`)?(u=(0,Z.jsx)(D,{className:`size-3.5`}),t[47]=u):u=t[47];let d;t[48]===i?d=t[49]:(d=(0,Z.jsx)(Nt,{label:`Zoom in`,onClick:i,children:u}),t[48]=i,t[49]=d);let f;t[50]!==d||t[51]!==s||t[52]!==l?(f=(0,Z.jsxs)(`div`,{className:`flex items-center gap-1 rounded-md border border-edge-subtle bg-surface-base p-0.5 dark:border-edge`,children:[s,l,d]},`zoom`),t[50]=d,t[51]=s,t[52]=l,t[53]=f):f=t[53],e.push(f)}if(m){let n;t[54]===Symbol.for(`react.memo_cache_sentinel`)?(n=(0,Z.jsx)(k,{className:`size-3.5`}),t[54]=n):n=t[54];let r;t[55]===s?r=t[56]:(r=(0,Z.jsx)(Nt,{label:`Rotate`,onClick:s,children:n},`rotate`),t[55]=s,t[56]=r),e.push(r)}if(f){let n;t[57]===Symbol.for(`react.memo_cache_sentinel`)?(n=(0,Z.jsx)(A,{className:`size-3.5`,"aria-hidden":!0}),t[57]=n):n=t[57];let i;t[58]===c?i=t[59]:(i=e=>c(e.target.value),t[58]=c,t[59]=i);let a;t[60]!==r.searchQuery||t[61]!==i?(a=(0,Z.jsxs)(`label`,{className:`flex min-w-40 items-center gap-1 rounded-md border border-edge-subtle bg-surface-base px-2 py-1 text-xs text-fg-muted dark:border-edge`,children:[n,(0,Z.jsx)(`input`,{className:`min-w-0 flex-1 bg-transparent text-fg outline-none placeholder:text-fg-subtle`,value:r.searchQuery,onChange:i,placeholder:`Search`})]},`search`),t[60]=r.searchQuery,t[61]=i,t[62]=a):a=t[62],e.push(a)}_=(0,Z.jsx)(`div`,{className:`flex shrink-0 items-center gap-1`,children:e}),t[9]=g,t[10]=m,t[11]=f,t[12]=u,t[13]=r,t[14]=s,t[15]=c,t[16]=i,t[17]=a,t[18]=o,t[19]=_}else _=t[19];return _}function Nt(e){let t=(0,G.c)(6),{label:n,disabled:r,onClick:i,children:a}=e,o;t[0]===Symbol.for(`react.memo_cache_sentinel`)?(o=j(`inline-flex size-9 shrink-0 items-center justify-center rounded-md text-fg-muted transition-colors hover:bg-surface-hover hover:text-fg disabled:opacity-40`),t[0]=o):o=t[0];let s;return t[1]!==a||t[2]!==r||t[3]!==n||t[4]!==i?(s=(0,Z.jsx)(`button`,{type:`button`,className:o,title:n,"aria-label":n,disabled:r,onClick:i,children:a}),t[1]=a,t[2]=r,t[3]=n,t[4]=i,t[5]=s):s=t[5],s}function Pt(e){let t=jt(e.type),n=nt(e.id),[r,i]=(0,W.useState)(n.zoom),[a,o]=(0,W.useState)(n.rotation),[s,c]=(0,W.useState)(n.page),[l,u]=(0,W.useState)(n.pageCount),[d,f]=(0,W.useState)(n.searchQuery),p=(0,W.useCallback)(e=>{c(Math.max(1,Math.min(l??e,Math.floor(e))))},[l]);(0,W.useEffect)(()=>{let t=nt(e.id);i(t.zoom),o(t.rotation),c(t.page),u(t.pageCount),f(t.searchQuery)},[e.id,e.type]);let m=(0,W.useRef)({zoom:r,rotation:a,page:s,pageCount:l,searchQuery:d});return m.current={zoom:r,rotation:a,page:s,pageCount:l,searchQuery:d},(0,W.useEffect)(()=>()=>rt(e.id,m.current),[e.id]),{plugin:t,controls:(0,W.useMemo)(()=>({zoom:r,rotation:a,page:s,pageCount:l,searchQuery:d,setPageCount:u,setPage:p}),[s,l,a,d,p,r]),onZoomIn:()=>i(e=>Math.min(4,Number((e+.15).toFixed(2)))),onZoomOut:()=>i(e=>Math.max(.25,Number((e-.15).toFixed(2)))),onZoomReset:()=>{i(1),o(0)},onRotate:()=>o(e=>(e+90)%360),onSearchChange:f}}function Ft(e){let t=(0,G.c)(8),{controller:n}=e,r;return t[0]!==n.controls||t[1]!==n.onRotate||t[2]!==n.onSearchChange||t[3]!==n.onZoomIn||t[4]!==n.onZoomOut||t[5]!==n.onZoomReset||t[6]!==n.plugin?(r=(0,Z.jsx)(Mt,{plugin:n.plugin,controls:n.controls,onZoomIn:n.onZoomIn,onZoomOut:n.onZoomOut,onZoomReset:n.onZoomReset,onRotate:n.onRotate,onSearchChange:n.onSearchChange}),t[0]=n.controls,t[1]=n.onRotate,t[2]=n.onSearchChange,t[3]=n.onZoomIn,t[4]=n.onZoomOut,t[5]=n.onZoomReset,t[6]=n.plugin,t[7]=r):r=t[7],r}function It(e){let t=(0,G.c)(14),n;t[0]===e.language?n=t[1]:(n=u(e.language),t[0]=e.language,t[1]=n);let r=n,{controller:i}=e;if(e.loading){let e;return t[2]===Symbol.for(`react.memo_cache_sentinel`)?(e=(0,Z.jsxs)(`div`,{className:`flex min-h-0 flex-1 flex-col gap-3 px-4 py-6`,"aria-busy":`true`,children:[(0,Z.jsx)(M,{className:`h-5 w-48 max-w-full`}),(0,Z.jsx)(M,{className:`h-4 w-full`}),(0,Z.jsx)(M,{className:`h-4 w-11/12`}),(0,Z.jsx)(M,{className:`h-4 w-3/4`}),(0,Z.jsx)(M,{className:`mt-3 min-h-48 flex-1 rounded-lg`})]}),t[2]=e):e=t[2],e}if(e.loadError){let n=(e.descriptor.context===`workspace`?r.workspace.loadError:r.chat.attachmentPreviewLoadError)+`: `+e.loadError,i;return t[3]===n?i=t[4]:(i=(0,Z.jsx)(`div`,{className:`flex min-h-0 flex-1 flex-col gap-3 overflow-auto p-4`,children:(0,Z.jsx)(`p`,{className:`text-sm text-red-600 dark:text-red-400`,children:n})}),t[3]=n,t[4]=i),i}if(e.descriptor.context===`attachment`&&e.showExtractedText&&e.descriptor.type!==`image`){let n=e.extractedText||r.chat.attachmentPreviewNoText,i;return t[5]===n?i=t[6]:(i=(0,Z.jsx)(`div`,{className:`flex min-h-0 flex-1 flex-col gap-2 overflow-hidden`,children:(0,Z.jsx)(`div`,{className:`min-h-0 flex-1 overflow-auto rounded-lg border border-edge-subtle bg-surface-hover/40 p-4 dark:border-edge`,children:(0,Z.jsx)(`pre`,{className:`whitespace-pre-wrap break-words font-mono text-xs leading-relaxed text-fg-muted`,children:n})})}),t[5]=n,t[6]=i),i}let a=`${e.descriptor.id}:${i.plugin.id}`,o;t[7]!==i.controls||t[8]!==e?(o={...e,controls:i.controls},t[7]=i.controls,t[8]=e,t[9]=o):o=t[9];let s;return t[10]!==i.plugin.render||t[11]!==a||t[12]!==o?(s=(0,Z.jsx)(`div`,{className:`flex min-h-0 flex-1 flex-col overflow-hidden`,children:(0,Z.jsx)(Lt,{pluginRender:i.plugin.render,props:o},a)}),t[10]=i.plugin.render,t[11]=a,t[12]=o,t[13]=s):s=t[13],s}function Lt(e){let t=(0,G.c)(5),{pluginRender:n,props:r}=e,i;t[0]!==n||t[1]!==r?(i=n(r),t[0]=n,t[1]=r,t[2]=i):i=t[2];let a;return t[3]===i?a=t[4]:(a=(0,Z.jsx)(`div`,{className:`flex min-h-0 flex-1 flex-col`,children:i}),t[3]=i,t[4]=a),a}function Rt(e){let t=(0,G.c)(9),{label:n,active:r,disabled:i,onClick:a,children:o}=e,s=r&&`border-accent/20 bg-accent-soft text-accent-fg`,c;t[0]===s?c=t[1]:(c=j(`inline-flex size-9 shrink-0 items-center justify-center rounded-full border border-edge-subtle bg-surface-panel text-fg-muted transition-colors hover:bg-surface-hover hover:text-fg disabled:cursor-not-allowed disabled:opacity-40`,s,ce.focusRingPanel),t[0]=s,t[1]=c);let l;return t[2]!==r||t[3]!==o||t[4]!==i||t[5]!==n||t[6]!==a||t[7]!==c?(l=(0,Z.jsx)(`button`,{type:`button`,className:c,title:n,"aria-label":n,"aria-pressed":r,disabled:i,onClick:a,children:o}),t[2]=r,t[3]=o,t[4]=i,t[5]=n,t[6]=a,t[7]=c,t[8]=l):l=t[8],l}function $(e){let t=(0,G.c)(14),{icon:n,label:r,active:i,disabled:a,onClick:o}=e,s=i===void 0?`menuitem`:`menuitemcheckbox`,c;t[0]===n?c=t[1]:(c=(0,Z.jsx)(`span`,{className:`flex size-4 shrink-0 items-center justify-center text-fg-muted`,"aria-hidden":!0,children:n}),t[0]=n,t[1]=c);let l;t[2]===r?l=t[3]:(l=(0,Z.jsx)(`span`,{className:`min-w-0 flex-1 truncate`,children:r}),t[2]=r,t[3]=l);let u;t[4]===i?u=t[5]:(u=i?(0,Z.jsx)(p,{className:`size-4 shrink-0`,"aria-hidden":!0}):null,t[4]=i,t[5]=u);let d;return t[6]!==i||t[7]!==a||t[8]!==o||t[9]!==s||t[10]!==c||t[11]!==l||t[12]!==u?(d=(0,Z.jsxs)(`button`,{type:`button`,role:s,"aria-checked":i,className:`flex h-9 w-full min-w-0 items-center gap-2.5 rounded-md px-2.5 text-left text-sm text-fg hover:bg-surface-hover focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-accent disabled:cursor-not-allowed disabled:opacity-40`,disabled:a,onClick:o,children:[c,l,u]}),t[6]=i,t[7]=a,t[8]=o,t[9]=s,t[10]=c,t[11]=l,t[12]=u,t[13]=d):d=t[13],d}function zt(e){let t=(0,G.c)(92),{referenceActions:n,onRefresh:r,onRetrySave:i,subtitle:a,controller:o,actions:s,expanded:c,onToggleExpanded:d,onClose:f,hideClose:m,edit:C,wordWrap:T,editInNewChat:D,share:k,openWithSystemApp:A,chooseApp:M,recommendedApps:N,recentApps:P,onOpenWithApp:ae,onRevealInFolder:oe,copyPath:F,textView:I,openInBrowser:L}=e,se;t[0]===n?se=t[1]:(se=n===void 0?[]:n,t[0]=n,t[1]=se);let R=se,z;t[2]===N?z=t[3]:(z=N===void 0?[]:N,t[2]=N,t[3]=z);let de=z,pe;t[4]===P?pe=t[5]:(pe=P===void 0?[]:P,t[4]=P,t[5]=pe);let me=pe,B=l(Ht),he;t[6]===B?he=t[7]:(he=u(B),t[6]=B,t[7]=he);let V=he,H=V.workspace,ge=o.plugin.id===`pdf`?V.chat.attachmentPreviewPdf:o.plugin.id===`docx`?V.chat.attachmentPreviewDocument:o.plugin.id===`spreadsheet`?V.chat.attachmentPreviewSpreadsheet:H.preview,_e;t[8]===Symbol.for(`react.memo_cache_sentinel`)?(_e=ue(),t[8]=_e):_e=t[8];let ve=_e,ye=(0,W.useContext)(je),be=(0,W.useRef)(null),xe=(0,W.useRef)(null),[U,Se]=(0,W.useState)(!1),Ce;t[9]===o.plugin.capabilities?Ce=t[10]:(Ce=o.plugin.capabilities.some(Vt),t[9]=o.plugin.capabilities,t[10]=Ce);let we=Ce,Ee,De;t[11]===U?(Ee=t[12],De=t[13]):(Ee=()=>{if(!U)return;be.current?.querySelector(`button:not(:disabled), a`)?.focus();let e=e=>{if([`ArrowDown`,`ArrowUp`,`Home`,`End`].includes(e.key)&&be.current?.contains(document.activeElement)){e.preventDefault(),e.stopImmediatePropagation();let t=[...be.current.querySelectorAll(`button:not(:disabled), a`)],n=t.indexOf(document.activeElement);t[e.key===`Home`?0:e.key===`End`?t.length-1:(n+(e.key===`ArrowDown`?1:-1)+t.length)%t.length]?.focus();return}e.key===`Escape`&&(e.preventDefault(),e.stopImmediatePropagation(),Se(!1),xe.current?.focus())};return window.addEventListener(`keydown`,e,!0),()=>window.removeEventListener(`keydown`,e,!0)},De=[U],t[11]=U,t[12]=Ee,t[13]=De),(0,W.useEffect)(Ee,De);let K;t[14]===Symbol.for(`react.memo_cache_sentinel`)?(K=e=>{Se(!1),xe.current?.focus(),e()},t[14]=K):K=t[14];let q=K,ke;t[15]===Symbol.for(`react.memo_cache_sentinel`)?(ke=j(`shrink-0 bg-surface-base px-3 py-2 sm:px-4`,le),t[15]=ke):ke=t[15];let Ae;t[16]===ye?Ae=t[17]:(Ae=ye?(0,Z.jsx)(Rt,{label:ye.label,active:ye.active,onClick:ye.onToggle,children:(0,Z.jsx)(Te,{className:`size-4`,strokeWidth:1.75,"aria-hidden":!0})}):null,t[16]=ye,t[17]=Ae);let Me=c?H.collapsePreview:H.expandPreview,Ne=!d,Pe;t[18]===c?Pe=t[19]:(Pe=c?(0,Z.jsx)(te,{className:`size-4`,"aria-hidden":!0}):(0,Z.jsx)(w,{className:`size-4`,"aria-hidden":!0}),t[18]=c,t[19]=Pe);let Fe;t[20]!==c||t[21]!==d||t[22]!==Me||t[23]!==Ne||t[24]!==Pe?(Fe=(0,Z.jsx)(Rt,{label:Me,active:c,disabled:Ne,onClick:d,children:Pe}),t[20]=c,t[21]=d,t[22]=Me,t[23]=Ne,t[24]=Pe,t[25]=Fe):Fe=t[25];let Ie;t[26]===U?Ie=t[27]:(Ie=U?(0,Z.jsx)(`button`,{type:`button`,className:`fixed inset-0 z-40 cursor-default bg-transparent`,"aria-hidden":!0,tabIndex:-1,onPointerDown:e=>{e.preventDefault(),Se(!1)}}):null,t[26]=U,t[27]=Ie);let Le;t[28]===Symbol.for(`react.memo_cache_sentinel`)?(Le=j(`inline-flex size-9 shrink-0 items-center justify-center rounded-full border border-edge-subtle bg-surface-panel text-fg-muted transition-colors hover:bg-surface-hover hover:text-fg`,ce.focusRingPanel),t[28]=Le):Le=t[28];let Re,ze;t[29]===Symbol.for(`react.memo_cache_sentinel`)?(Re=()=>Se(Bt),ze=(0,Z.jsx)(_,{className:`size-4`}),t[29]=Re,t[30]=ze):(Re=t[29],ze=t[30]);let Be;t[31]!==H.moreActions||t[32]!==U?(Be=(0,Z.jsx)(`button`,{ref:xe,type:`button`,className:Le,title:H.moreActions,"aria-label":H.moreActions,"aria-haspopup":`menu`,"aria-expanded":U,onClick:Re,children:ze}),t[31]=H.moreActions,t[32]=U,t[33]=Be):Be=t[33];let Ve;t[34]!==s||t[35]!==M||t[36]!==o.plugin.capabilities||t[37]!==F||t[38]!==C||t[39]!==D||t[40]!==B||t[41]!==H.copyFilePath||t[42]!==H.copyWorkspacePath||t[43]!==H.download||t[44]!==H.edit||t[45]!==H.editInNewChat||t[46]!==H.moreActions||t[47]!==H.openInBrowser||t[48]!==H.pathCopied||t[49]!==H.preview||t[50]!==H.revealInFolder||t[51]!==H.saveCopy||t[52]!==H.shareLink||t[53]!==H.wordWrap||t[54]!==U||t[55]!==ae||t[56]!==r||t[57]!==i||t[58]!==oe||t[59]!==L||t[60]!==A||t[61]!==me||t[62]!==de||t[63]!==R||t[64]!==k||t[65]!==T?(Ve=U?(0,Z.jsxs)(`div`,{ref:be,role:`menu`,"aria-label":H.moreActions,"data-file-preview-menu":!0,className:`absolute right-0 top-full z-50 mt-1 max-h-[min(32rem,calc(100dvh-8rem))] w-60 max-w-[calc(100vw-2rem)] overflow-y-auto overscroll-contain rounded-lg border border-edge bg-surface-overlay p-1 shadow-popover`,children:[(0,Z.jsx)(ht,{variant:`menu`,onAction:q,systemApp:A,chooseApp:M,recommendedApps:de,recentApps:me,onOpenWithApp:ae}),R.map(e=>(0,Z.jsx)($,{icon:(0,Z.jsx)(E,{className:`size-4`}),label:e.label,disabled:e.disabled,onClick:()=>q(e.onClick)},e.label)),i?(0,Z.jsx)($,{icon:(0,Z.jsx)(re,{className:`size-4`}),label:B===`zh`?`重试保存`:`Retry save`,onClick:()=>q(i)}):null,r?(0,Z.jsx)($,{icon:(0,Z.jsx)(O,{className:`size-4`}),label:B===`zh`?`刷新文件`:`Refresh file`,onClick:()=>q(r)}):null,o.plugin.capabilities.includes(`edit`)?(0,Z.jsx)($,{icon:C?.active?(0,Z.jsx)(y,{className:`size-4`}):(0,Z.jsx)(ne,{className:`size-4`}),label:C?.active?H.preview:H.edit,disabled:!C,onClick:()=>q(()=>C?.onToggle())}):null,T?(0,Z.jsx)($,{icon:(0,Z.jsx)(Oe,{className:`size-4`}),label:H.wordWrap,active:T.active,onClick:()=>q(T.onToggle)}):null,(0,Z.jsx)(`div`,{className:`my-1 border-t border-edge-subtle dark:border-edge`}),(0,Z.jsx)($,{icon:D?.loading?(0,Z.jsx)(S,{className:`size-4 animate-spin`}):(0,Z.jsx)(ee,{className:`size-4`}),label:H.editInNewChat,disabled:!D||D.disabled||D.loading,onClick:()=>q(()=>D?.onClick())}),(0,Z.jsx)($,{icon:k?.loading?(0,Z.jsx)(S,{className:`size-4 animate-spin`}):(0,Z.jsx)(x,{className:`size-4`}),label:H.shareLink,disabled:!k||k.disabled||k.loading,onClick:()=>q(()=>k?.onClick())}),(0,Z.jsx)(`div`,{className:`my-1 border-t border-edge-subtle dark:border-edge`}),L?(0,Z.jsxs)(`a`,{href:L.href,target:`_blank`,rel:`noopener noreferrer`,role:`menuitem`,className:`flex h-9 w-full items-center gap-2.5 rounded-md px-2.5 text-sm text-fg hover:bg-surface-hover`,onClick:()=>Se(!1),children:[(0,Z.jsx)(v,{className:`size-4 text-fg-muted`,"aria-hidden":!0}),H.openInBrowser]}):null,oe?(0,Z.jsx)($,{icon:(0,Z.jsx)(b,{className:`size-4`}),label:H.revealInFolder,onClick:()=>q(oe)}):null,oe?(0,Z.jsx)(`div`,{className:`my-1 border-t border-edge-subtle dark:border-edge`}):null,(0,Z.jsx)($,{icon:(0,Z.jsx)(g,{className:`size-4`}),label:ve?H.saveCopy:H.download,disabled:!s.canDownload,onClick:()=>q(()=>void s.onDownload())}),F?(0,Z.jsx)($,{icon:F.copied?(0,Z.jsx)(p,{className:`size-4 text-emerald-500`}):(0,Z.jsx)(h,{className:`size-4`}),label:F.copied?H.pathCopied:ve?H.copyFilePath:H.copyWorkspacePath,onClick:()=>q(F.onClick)}):null]}):null,t[34]=s,t[35]=M,t[36]=o.plugin.capabilities,t[37]=F,t[38]=C,t[39]=D,t[40]=B,t[41]=H.copyFilePath,t[42]=H.copyWorkspacePath,t[43]=H.download,t[44]=H.edit,t[45]=H.editInNewChat,t[46]=H.moreActions,t[47]=H.openInBrowser,t[48]=H.pathCopied,t[49]=H.preview,t[50]=H.revealInFolder,t[51]=H.saveCopy,t[52]=H.shareLink,t[53]=H.wordWrap,t[54]=U,t[55]=ae,t[56]=r,t[57]=i,t[58]=oe,t[59]=L,t[60]=A,t[61]=me,t[62]=de,t[63]=R,t[64]=k,t[65]=T,t[66]=Ve):Ve=t[66];let He;t[67]!==Ie||t[68]!==Be||t[69]!==Ve?(He=(0,Z.jsxs)(`div`,{className:`relative shrink-0`,children:[Ie,Be,Ve]}),t[67]=Ie,t[68]=Be,t[69]=Ve,t[70]=He):He=t[70];let Ue;t[71]!==m||t[72]!==H.close||t[73]!==f?(Ue=m?null:(0,Z.jsxs)(Z.Fragment,{children:[(0,Z.jsx)(`div`,{className:`mx-0.5 h-5 w-px bg-edge-subtle`,"aria-hidden":!0}),(0,Z.jsx)(Rt,{label:H.close,onClick:f,children:(0,Z.jsx)(ie,{className:`size-4`,strokeWidth:1.75})})]}),t[71]=m,t[72]=H.close,t[73]=f,t[74]=Ue):Ue=t[74];let J;t[75]!==Ae||t[76]!==Fe||t[77]!==He||t[78]!==Ue?(J=(0,Z.jsx)(`div`,{className:`flex min-w-0 flex-wrap items-center gap-2`,children:(0,Z.jsxs)(`div`,{className:`ml-auto flex shrink-0 items-center gap-1.5`,children:[Ae,Fe,He,Ue]})}),t[75]=Ae,t[76]=Fe,t[77]=He,t[78]=Ue,t[79]=J):J=t[79];let Y;t[80]===a?Y=t[81]:(Y=a?(0,Z.jsx)(`div`,{className:`mt-1.5 flex min-h-4 min-w-0 items-center gap-2 px-3 text-xs leading-4 text-fg-muted`,children:a}):null,t[80]=a,t[81]=Y);let X;t[82]!==o||t[83]!==we||t[84]!==V.chat||t[85]!==ge||t[86]!==I?(X=we||I?(0,Z.jsxs)(`div`,{className:`mt-2 flex items-center gap-2 overflow-x-auto pb-0.5`,children:[I?(0,Z.jsx)(fe,{className:`mr-2 flex shrink-0 rounded-lg bg-surface-hover p-0.5`,role:`group`,"aria-label":V.chat.attachmentPreviewText,children:[{active:!1,label:ge},{active:!0,label:V.chat.attachmentPreviewText}].map(e=>(0,Z.jsx)(`button`,{type:`button`,"aria-pressed":I.active===e.active,className:j(`rounded-md px-2.5 py-1 text-xs font-medium`,I.active===e.active?`bg-surface-hover text-fg`:`text-fg-muted hover:text-fg`),onClick:()=>I.onChange(e.active),children:e.label},e.label))}):null,we?(0,Z.jsx)(Ft,{controller:o}):null]}):null,t[82]=o,t[83]=we,t[84]=V.chat,t[85]=ge,t[86]=I,t[87]=X):X=t[87];let We;return t[88]!==J||t[89]!==Y||t[90]!==X?(We=(0,Z.jsxs)(`div`,{"data-workspace-toolbar":!0,className:ke,children:[J,Y,X]}),t[88]=J,t[89]=Y,t[90]=X,t[91]=We):We=t[91],We}function Bt(e){return!e}function Vt(e){return[`zoom`,`search`,`rotate`,`pageNavigation`].includes(e)}function Ht(e){return e.language}function Ut({header:e,chat:t,...n}){let r=(0,W.useRef)(null);(0,W.useEffect)(()=>{let e=r.current;if(!e)return;let t=()=>{let t=nt(n.descriptor.id).scroll;e.querySelectorAll(`[class*="overflow-auto"], [class*="overflow-y-auto"], .cm-scroller`).forEach((e,n)=>{t[n]!=null&&(e.scrollTop=t[n])})},i=requestAnimationFrame(t),a=typeof MutationObserver<`u`?new MutationObserver(t):null;a?.observe(e,{childList:!0,subtree:!0});let o=()=>rt(n.descriptor.id,{scroll:[...e.querySelectorAll(`[class*="overflow-auto"], [class*="overflow-y-auto"], .cm-scroller`)].map(e=>e.scrollTop)});return e.addEventListener(`scroll`,o,!0),()=>{cancelAnimationFrame(i),a?.disconnect(),e.removeEventListener(`scroll`,o,!0)}},[n.descriptor.id]);let i=(0,W.useContext)(Ae),[o,s]=(0,W.useState)(!1),c=Pt(n.descriptor),l=a(),d=u(n.language),[f,p]=(0,W.useState)(!1),m=async()=>{if(!(!t||f)){p(!0);try{let[n,r]=await Promise.all([t.createFile(),t.conversationId?ae(t.conversationId).catch(()=>null):Promise.resolve(null)]);if(n.size>33554432){K(`warning`,d.chat.attachmentFileTooLarge,{name:n.name,maxSize:L(P)});return}let i=new URLSearchParams({attachmentHandoff:dt(n)}),a=t.projectId?.trim()||r?.projectId?.trim(),o=t.agentId?.trim()||r?.routing?.agentId?.trim();a&&i.set(`projectId`,a),l({pathname:`/chat/new`,search:`?${i}`},{state:{forceNewChat:!0,agentId:o||void 0}}),e.onClose()}catch{K(`error`,d.workspace.editInNewChatFailed)}finally{p(!1)}}};return(0,Z.jsxs)(`div`,{ref:r,className:`flex h-full min-h-0 min-w-0 flex-1 flex-col overflow-hidden bg-transparent`,children:[(0,Z.jsx)(zt,{...e,name:n.descriptor.fileName,filePath:n.descriptor.source.kind===`workspace`?n.descriptor.source.path:void 0,controller:c,actions:n.actions,referenceActions:t?i.map(e=>({label:e.label,disabled:o||n.loading||!!n.loadError||t.disabled,onClick:async()=>{if(!o){s(!0);try{let r=await t.createFile(),i=await ot(e.id,r);K(i?`success`:`warning`,n.language===`zh`?i?`已添加到目标聊天草稿`:`未能添加附件,请确认目标聊天可用及附件限制`:i?`Added to the target chat draft`:`Could not add attachment. Check the target chat and attachment limits.`)}catch{K(`error`,n.language===`zh`?`文件引用失败,原草稿已保留`:`Could not reference file. Your draft is retained.`)}finally{s(!1)}}}})):void 0,editInNewChat:t?{onClick:()=>void m(),loading:f,disabled:n.loading||!!n.loadError||t.disabled}:void 0},n.descriptor.id),(0,Z.jsx)(It,{...n,controller:c})]})}function Wt(e,t){let n=(0,G.c)(7),r=e===void 0||e,i=t!==void 0&&t,[a,o]=(0,W.useState)(!1);!r&&a&&o(!1);let s,c;n[0]!==r||n[1]!==i||n[2]!==a?(s=()=>{if(!r||!a)return;let e=document.body.style.overflow;document.body.style.overflow=`hidden`;let t=e=>{i||e.key!==`Escape`||e.defaultPrevented||document.querySelector(`[data-file-preview-menu]`)||(e.preventDefault(),e.stopImmediatePropagation(),o(!1))};return window.addEventListener(`keydown`,t,!0),()=>{document.body.style.overflow=e,window.removeEventListener(`keydown`,t,!0)}},c=[r,a,i],n[0]=r,n[1]=i,n[2]=a,n[3]=s,n[4]=c):(s=n[3],c=n[4]),(0,W.useEffect)(s,c);let l;return n[5]===a?l=n[6]:(l={expanded:a,setExpanded:o},n[5]=a,n[6]=l),l}export{De as C,Oe as S,Te as T,Ae as _,at as a,ke as b,et as c,Ne as d,Me as f,We as g,Y as h,pt as i,Ye as l,J as m,Ut as n,nt as o,X as p,ft as r,rt as s,Wt as t,Ge as u,q as v,Ee as w,K as x,je as y};
@@ -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,l as i,o as a}from"./locale-store-B7y-RVe8.js";import{i as o}from"./vendor-swr-CdRzEUwF.js";var s=n(),c=e(t(),1);function l(){let e=(0,s.c)(11),t=i(d),n;e[0]===t?n=e[1]:(n=t?[`personal-agent-nav`,t]:null,e[0]=t,e[1]=n);let r;e[2]===Symbol.for(`react.memo_cache_sentinel`)?(r={revalidateOnFocus:!1},e[2]=r):r=e[2];let{data:a,mutate:l}=o(n,u,r),f,p;e[3]===l?(f=e[4],p=e[5]):(f=()=>{let e=e=>{let t=e.detail;t===void 0?l():l({ok:!0,payload:t},{revalidate:!1})};return window.addEventListener(`personal-agent-updated`,e),()=>window.removeEventListener(`personal-agent-updated`,e)},p=[l],e[3]=l,e[4]=f,e[5]=p),(0,c.useEffect)(f,p);let m=a?.payload,h;e[6]===a?.payload?.displayName?h=e[7]:(h=a?.payload?.displayName?.trim()||`Ada`,e[6]=a?.payload?.displayName,e[7]=h);let g;return e[8]!==m||e[9]!==h?(g={profile:m,displayName:h},e[8]=m,e[9]=h,e[10]=g):g=e[10],g}function u(){return a(r(`/api/personal-agent`))}function d(e){return e.conversationId}export{l 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,l as i,o as a}from"./locale-store-B6OrWgY1.js";import{i as o}from"./vendor-swr-CdRzEUwF.js";var s=n(),c=e(t(),1);function l(){let e=(0,s.c)(11),t=i(d),n;e[0]===t?n=e[1]:(n=t?[`personal-agent-nav`,t]:null,e[0]=t,e[1]=n);let r;e[2]===Symbol.for(`react.memo_cache_sentinel`)?(r={revalidateOnFocus:!1},e[2]=r):r=e[2];let{data:a,mutate:l}=o(n,u,r),f,p;e[3]===l?(f=e[4],p=e[5]):(f=()=>{let e=e=>{let t=e.detail;t===void 0?l():l({ok:!0,payload:t},{revalidate:!1})};return window.addEventListener(`personal-agent-updated`,e),()=>window.removeEventListener(`personal-agent-updated`,e)},p=[l],e[3]=l,e[4]=f,e[5]=p),(0,c.useEffect)(f,p);let m=a?.payload,h;e[6]===a?.payload?.displayName?h=e[7]:(h=a?.payload?.displayName?.trim()||`Ada`,e[6]=a?.payload?.displayName,e[7]=h);let g;return e[8]!==m||e[9]!==h?(g={profile:m,displayName:h},e[8]=m,e[9]=h,e[10]=g):g=e[10],g}function u(){return a(r(`/api/personal-agent`))}function d(e){return e.conversationId}export{l as t};
@@ -1 +1 @@
1
- import{i as e}from"./rolldown-runtime-aKtaBQYM.js";import{a as t}from"./vendor-react-BOUWij0V.js";import{i as n,o as r,s as i}from"./workspace-api-Am2ee4R6.js";var a=e(t(),1);function o(e){return e.map(e=>({fileId:e.id,name:e.name,path:e.path,isDirectory:e.isDirectory,children:e.isDirectory?[]:void 0}))}function s(e,t,n){return e.map(e=>e.path===t?{...e,children:n}:e.isDirectory&&e.children?.length?{...e,children:s(e.children,t,n)}:e)}function c(e,t,c){let[l,u]=(0,a.useState)([]),[d,f]=(0,a.useState)(null),[p,m]=(0,a.useState)(!1),[h,g]=(0,a.useState)(null),_=(0,a.useRef)(new Set),v=e.trim(),y=t?.trim()??``,b=c?.trim()??``,x=b?``:y,S=!b&&!y?v:``,C=(0,a.useMemo)(()=>{if(b)return{projectId:b};if(x)return{conversationId:x};if(S)return{agentId:S}},[b,x,S]);return{tree:l,rootResource:d,loading:p,error:h,loadRoot:(0,a.useCallback)(async()=>{m(!0),g(null),_.current.clear();try{let[e,t]=await Promise.all([n(``,C),r(C)]);u(o(e.entries)),f(o([t])[0]??null),_.current.add(``)}catch(e){f(null),g(e instanceof Error?e.message:String(e))}finally{m(!1)}},[C]),loadChildren:(0,a.useCallback)(async e=>{if(!_.current.has(e)){_.current.add(e);try{let t=o(await i(e,C));u(n=>s(n,e,t))}catch{_.current.delete(e)}}},[C]),refreshDirectory:(0,a.useCallback)(async e=>{let t=o(await i(e,C));u(e?n=>s(n,e,t):t),_.current.add(e)},[C]),reset:(0,a.useCallback)(()=>{u([]),f(null),g(null),_.current.clear()},[])}}export{c as t};
1
+ import{i as e}from"./rolldown-runtime-aKtaBQYM.js";import{a as t}from"./vendor-react-BOUWij0V.js";import{i as n,o as r,s as i}from"./workspace-api-HBXn8pL9.js";var a=e(t(),1);function o(e){return e.map(e=>({fileId:e.id,name:e.name,path:e.path,isDirectory:e.isDirectory,children:e.isDirectory?[]:void 0}))}function s(e,t,n){return e.map(e=>e.path===t?{...e,children:n}:e.isDirectory&&e.children?.length?{...e,children:s(e.children,t,n)}:e)}function c(e,t,c){let[l,u]=(0,a.useState)([]),[d,f]=(0,a.useState)(null),[p,m]=(0,a.useState)(!1),[h,g]=(0,a.useState)(null),_=(0,a.useRef)(new Set),v=e.trim(),y=t?.trim()??``,b=c?.trim()??``,x=b?``:y,S=!b&&!y?v:``,C=(0,a.useMemo)(()=>{if(b)return{projectId:b};if(x)return{conversationId:x};if(S)return{agentId:S}},[b,x,S]);return{tree:l,rootResource:d,loading:p,error:h,loadRoot:(0,a.useCallback)(async()=>{m(!0),g(null),_.current.clear();try{let[e,t]=await Promise.all([n(``,C),r(C)]);u(o(e.entries)),f(o([t])[0]??null),_.current.add(``)}catch(e){f(null),g(e instanceof Error?e.message:String(e))}finally{m(!1)}},[C]),loadChildren:(0,a.useCallback)(async e=>{if(!_.current.has(e)){_.current.add(e);try{let t=o(await i(e,C));u(n=>s(n,e,t))}catch{_.current.delete(e)}}},[C]),refreshDirectory:(0,a.useCallback)(async e=>{let t=o(await i(e,C));u(e?n=>s(n,e,t):t),_.current.add(e)},[C]),reset:(0,a.useCallback)(()=>{u([]),f(null),g(null),_.current.clear()},[])}}export{c as t};