@lobu/runtime-server 24.11.0 → 24.12.0

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 (275) hide show
  1. package/dist/catalogs/connectors.json +1113 -107
  2. package/dist/catalogs/skills.json +2 -2
  3. package/dist/component.json +1 -1
  4. package/dist/connectors/README.md +2 -2
  5. package/dist/connectors/chat-transport-actions.ts +50 -0
  6. package/dist/connectors/discord.ts +2 -0
  7. package/dist/connectors/gchat.ts +2 -0
  8. package/dist/connectors/github.ts +4 -4
  9. package/dist/connectors/google_drive.ts +20 -0
  10. package/dist/connectors/google_gmail.ts +49 -8
  11. package/dist/connectors/herdr.ts +1 -1
  12. package/dist/connectors/imessage.ts +1 -0
  13. package/dist/connectors/linkedin-browser-script.ts +11 -0
  14. package/dist/connectors/linkedin-draft-page.js +24 -8
  15. package/dist/connectors/linkedin-inbox-adapter.js +209 -19
  16. package/dist/connectors/linkedin-inbox.ts +152 -4
  17. package/dist/connectors/linkedin-network.ts +788 -0
  18. package/dist/connectors/linkedin-search.ts +1284 -0
  19. package/dist/connectors/linkedin.ts +892 -27
  20. package/dist/connectors/microsoft_outlook.ts +57 -19
  21. package/dist/connectors/rss.ts +179 -33
  22. package/dist/connectors/slack.ts +2 -0
  23. package/dist/connectors/source-file-attachment.ts +46 -0
  24. package/dist/connectors/teams.ts +2 -0
  25. package/dist/connectors/telegram.ts +2 -0
  26. package/dist/connectors/tiktok_web.ts +1 -1
  27. package/dist/connectors/whatsapp.ts +2 -0
  28. package/dist/connectors/whatsapp_web.ts +3 -3
  29. package/dist/connectors/x-dm-adapter.js +8 -10
  30. package/dist/connectors/x.ts +8 -9
  31. package/dist/db/migrations/20261115040000_account_two_factor.sql +20 -0
  32. package/dist/db/migrations/20261115120000_events_unbound_tool_audit_without_bridge.sql +40 -0
  33. package/dist/db/migrations/20261115120001_events_unbound_tool_audit_validate.sql +19 -0
  34. package/dist/db/migrations/20261115120002_drop_events_linked_org_ids.sql +119 -0
  35. package/dist/db/migrations/20261115130000_entities_retired_type_idx.sql +34 -0
  36. package/dist/db/migrations/20261115140000_entity_identities_personal_owner_idx.sql +34 -0
  37. package/dist/db/migrations/20261117090000_write_policy_kind_note.sql +65 -0
  38. package/dist/db/migrations/20261117120000_app_policy_principal.sql +48 -0
  39. package/dist/db/migrations/20261117170000_personal_org_connector_auto_policy_backfill.sql +57 -0
  40. package/dist/db/migrations/20261117190000_org_slug_reserved_paths.sql +29 -0
  41. package/dist/db/migrations/20261118120000_workspace_view_top_level_paths.sql +69 -0
  42. package/dist/db/migrations/preconditions/20261117190000_org_slug_reserved_paths.sql +14 -0
  43. package/dist/db/migrations/preconditions/20261118120000_workspace_view_top_level_paths.sql +21 -0
  44. package/dist/dependencies.bun.lock +51 -46
  45. package/dist/guest.bundle.js +11 -2
  46. package/dist/owletto/dist/assets/_-BC9j6MkU.js +2 -0
  47. package/dist/owletto/dist/assets/_-Z1u1cIe6.js +3 -0
  48. package/dist/owletto/dist/assets/_agentId-B-TFq9TP.js +2 -0
  49. package/dist/owletto/dist/assets/{_agentId-CGScf8z_.js → _agentId-BGatZWsd.js} +2 -2
  50. package/dist/owletto/dist/assets/_automationId-CMUrWPvr.js +2 -0
  51. package/dist/owletto/dist/assets/_connectorKey._connectionId-CUoAoP0_.js +2 -0
  52. package/dist/owletto/dist/assets/_connectorKey.index-Bs49QGGH.js +2 -0
  53. package/dist/owletto/dist/assets/_conversationId-CszP1den.js +2 -0
  54. package/dist/owletto/dist/assets/_eventId-C0AZUBnD.js +2 -0
  55. package/dist/owletto/dist/assets/_owner-B4ydA75k.js +3 -0
  56. package/dist/owletto/dist/assets/_shape-C4-ikE70.js +2 -0
  57. package/dist/owletto/dist/assets/_slug-DE5J3KVu.js +2 -0
  58. package/dist/owletto/dist/assets/_viewKey-Dkcd8JQC.js +2 -0
  59. package/dist/owletto/dist/assets/{accept-invitation-BKeIzZXE.js → accept-invitation-DmrQQu_W.js} +2 -2
  60. package/dist/owletto/dist/assets/{activity-route-location-sLvKaSCa.js → activity-route-location-Bec6fW-t.js} +2 -2
  61. package/dist/owletto/dist/assets/activity-route-view-DCSNBKZU.js +2 -0
  62. package/dist/owletto/dist/assets/agent-client-connections-xvabPpi6.js +4 -0
  63. package/dist/owletto/dist/assets/agent-connect-pages-DDPtkcmq.js +6 -0
  64. package/dist/owletto/dist/assets/{agent-editor-form-DVFyyMyd.js → agent-editor-form-BrhQbHZg.js} +2 -2
  65. package/dist/owletto/dist/assets/{agent-loading-shells-BLNHIy-r.js → agent-loading-shells-D3y98xuO.js} +2 -2
  66. package/dist/owletto/dist/assets/{agent-permissions-matrix-UBKRR5vs.js → agent-permissions-matrix-jQJjSa9i.js} +2 -2
  67. package/dist/owletto/dist/assets/{agent-skill-context-fqedKd0D.js → agent-skill-context-CCcknBYE.js} +2 -2
  68. package/dist/owletto/dist/assets/{agent-subpage-shell-BUCoY2Nf.js → agent-subpage-shell-6f_53cSf.js} +2 -2
  69. package/dist/owletto/dist/assets/agent-thread-v_lSSnJi.js +6 -0
  70. package/dist/owletto/dist/assets/{app._appId-ByIypCL9.js → app._appId-CKWzZ2ic.js} +2 -2
  71. package/dist/owletto/dist/assets/assist-composer-Q9ZJjAta.js +2 -0
  72. package/dist/owletto/dist/assets/automation-run-now-Dl0MKx3N.js +2 -0
  73. package/dist/owletto/dist/assets/{callback-Pz5uS-k7.js → callback-Bentv78L.js} +2 -2
  74. package/dist/owletto/dist/assets/{card-CAPpY9P5.js → card-C4oPCVh6.js} +2 -2
  75. package/dist/owletto/dist/assets/{claim-DgWWK0KI.js → claim-B3C4qIi2.js} +2 -2
  76. package/dist/owletto/dist/assets/client-activity-scopes-DqaFEyir.js +2 -0
  77. package/dist/owletto/dist/assets/{client-rows-Dd5YV8vn.js → client-rows-rse9thnk.js} +2 -2
  78. package/dist/owletto/dist/assets/{clients-Bf7ZgGro.js → clients-BhPMbxHi.js} +2 -2
  79. package/dist/owletto/dist/assets/{code-editor-z1Sy_hiX.js → code-editor-CTdKUDPY.js} +2 -2
  80. package/dist/owletto/dist/assets/connect-D8o7HBlo.js +2 -0
  81. package/dist/owletto/dist/assets/connect-menu-D5EZvSHb.js +2 -0
  82. package/dist/owletto/dist/assets/connect._clientId-Dbagcg9L.js +2 -0
  83. package/dist/owletto/dist/assets/connected._clientId-DALW9S2K.js +2 -0
  84. package/dist/owletto/dist/assets/connection-DyxzSqVE.js +2 -0
  85. package/dist/owletto/dist/assets/connection-feed-detail-LqpxUCdy.js +2 -0
  86. package/dist/owletto/dist/assets/{connector-page-shell-an3SYLim.js → connector-page-shell-DZjKv9zQ.js} +2 -2
  87. package/dist/owletto/dist/assets/{connector-provenance-mSZCOud-.js → connector-provenance-DtTJn1Nk.js} +2 -2
  88. package/dist/owletto/dist/assets/connectors-BVl-AR33.js +2 -0
  89. package/dist/owletto/dist/assets/{consent-1ulwyJ3k.js → consent-XCqsHLxS.js} +2 -2
  90. package/dist/owletto/dist/assets/{core.esm-Ctg_pXLe.js → core.esm-B1du4Zwy.js} +3 -3
  91. package/dist/owletto/dist/assets/create-BYKCtGL4.js +2 -0
  92. package/dist/owletto/dist/assets/create-D6Mmuxcq.js +2 -0
  93. package/dist/owletto/dist/assets/{create-CGuoqPh8.js → create-GHTb6wKX.js} +2 -2
  94. package/dist/owletto/dist/assets/{create-automation-form-CD6jSlWL.js → create-automation-form-CTiy_S9G.js} +3 -3
  95. package/dist/owletto/dist/assets/create._connectorKey-DMH97KkK.js +2 -0
  96. package/dist/owletto/dist/assets/custom-guardrail-edits-DZy66ucV.js +2 -0
  97. package/dist/owletto/dist/assets/definition-comparison-C2mPfIMD.js +2 -0
  98. package/dist/owletto/dist/assets/detail-page-skeleton-DNBL7nyk.js +2 -0
  99. package/dist/owletto/dist/assets/device-CwP1PY8q.js +2 -0
  100. package/dist/owletto/dist/assets/{device-pin-tombstone-Dkj7hrBE.js → device-pin-tombstone-DYTt7kU5.js} +2 -2
  101. package/dist/owletto/dist/assets/device._deviceId-DZ2kqI4Y.js +2 -0
  102. package/dist/owletto/dist/assets/{entity-options-D4t-NAcg.js → entity-options-D9K_5Lcs.js} +2 -2
  103. package/dist/owletto/dist/assets/entity-page-DggKXrcE.js +2 -0
  104. package/dist/owletto/dist/assets/entity-pages-C6M6yKFf.js +2 -0
  105. package/dist/owletto/dist/assets/{entity-schema-graph-Cq96SJ3c.js → entity-schema-graph-B255NKjF.js} +2 -2
  106. package/dist/owletto/dist/assets/entity-type-page-CGBAP2wt.js +2 -0
  107. package/dist/owletto/dist/assets/event-attachments-D8Z8uwv9.js +2 -0
  108. package/dist/owletto/dist/assets/event-detail-CgG3pDLA.js +2 -0
  109. package/dist/owletto/dist/assets/events-feed-ClhEywwV.js +2 -0
  110. package/dist/owletto/dist/assets/{filter-editors-DGVl9U4D.js → filter-editors-D_Sfn0dv.js} +3 -3
  111. package/dist/owletto/dist/assets/{full-page-spinner-CtVlF8GQ.js → full-page-spinner-C1clibUY.js} +2 -2
  112. package/dist/owletto/dist/assets/{index-CK5GDX4B.js → index-04B26s6E.js} +2 -2
  113. package/dist/owletto/dist/assets/index-2HrEO-nl.js +2 -0
  114. package/dist/owletto/dist/assets/index-BU3k9wpw.js +2 -0
  115. package/dist/owletto/dist/assets/{index-DvuJ_S_o.js → index-BXHqp23o.js} +2 -2
  116. package/dist/owletto/dist/assets/index-BdLRUDIR.js +2 -0
  117. package/dist/owletto/dist/assets/index-C2FrGwYN.js +2 -0
  118. package/dist/owletto/dist/assets/index-CB9wGfUm.js +2 -0
  119. package/dist/owletto/dist/assets/index-Caihaftb.js +2 -0
  120. package/dist/owletto/dist/assets/index-CwH59DJV.js +2 -0
  121. package/dist/owletto/dist/assets/index-DB2lVKuV.js +7908 -0
  122. package/dist/owletto/dist/assets/{index-DbjbHlDe.js → index-DTvJRjrM.js} +2 -2
  123. package/dist/owletto/dist/assets/index-SF2ni1Rs.css +1 -0
  124. package/dist/owletto/dist/assets/{index-BifR-LE9.js → index-mSrdbx3C.js} +9 -9
  125. package/dist/owletto/dist/assets/index-uFn-Ilrx.js +2 -0
  126. package/dist/owletto/dist/assets/{json-diff-OjtREegr.js → json-diff-Ce6YAXzY.js} +2 -2
  127. package/dist/owletto/dist/assets/{list-skeleton-CH0qQBYk.js → list-skeleton-DLPBTnbR.js} +2 -2
  128. package/dist/owletto/dist/assets/login-DeWlvogD.js +2 -0
  129. package/dist/owletto/dist/assets/{logout-DfdgOLoM.js → logout-CJY0ceN9.js} +2 -2
  130. package/dist/owletto/dist/assets/{member-scope-gate-Cxg2zGQT.js → member-scope-gate-CBPMprXu.js} +2 -2
  131. package/dist/owletto/dist/assets/memory-browse-page-D5kj1RaR.js +74 -0
  132. package/dist/owletto/dist/assets/{model-selector-D2OpDkwH.js → model-selector-CjkBPpjN.js} +2 -2
  133. package/dist/owletto/dist/assets/new-BKrNkOQD.js +2 -0
  134. package/dist/owletto/dist/assets/new-BetiMuDq.js +2 -0
  135. package/dist/owletto/dist/assets/new-dk_-eXqU.js +2 -0
  136. package/dist/owletto/dist/assets/new-efN--4Wx.js +2 -0
  137. package/dist/owletto/dist/assets/organization-C3rpwx_d.js +2 -0
  138. package/dist/owletto/dist/assets/pdf-document--AN-oCKj.css +1 -0
  139. package/dist/owletto/dist/assets/pdf-document-2W1q0sRA.js +56 -0
  140. package/dist/owletto/dist/assets/pdf.worker.min-CIqJB0yW.mjs +28 -0
  141. package/dist/owletto/dist/assets/peek-pane-content-ChsBWO0P.js +3 -0
  142. package/dist/owletto/dist/assets/{pending-seed-BBACroge.js → pending-seed-CTKYdA4X.js} +2 -2
  143. package/dist/owletto/dist/assets/proposal-review-shell-EyGWEYwQ.js +2 -0
  144. package/dist/owletto/dist/assets/public-shell-ready-_KWdfzEM.js +2 -0
  145. package/dist/owletto/dist/assets/record-session-D27VNxP_.js +2 -0
  146. package/dist/owletto/dist/assets/{renderer-CTKNMcXP.js → renderer-B8yZ5lql.js} +34 -33
  147. package/dist/owletto/dist/assets/{reset-password-DKBEneyR.js → reset-password-BGVJIh2I.js} +2 -2
  148. package/dist/owletto/dist/assets/run-initiator-C0sur8lU.js +2 -0
  149. package/dist/owletto/dist/assets/runs-list-CJOFMgpk.js +2 -0
  150. package/dist/owletto/dist/assets/schema-value-DDNHANGs.js +3 -0
  151. package/dist/owletto/dist/assets/{scoped-feed-bar-DNFL0sYX.js → scoped-feed-bar-BTv9mPcR.js} +2 -2
  152. package/dist/owletto/dist/assets/settings-Ponr5XbS.js +3 -0
  153. package/dist/owletto/dist/assets/{status-variants-SzXYYedJ.js → status-variants-mLqVhg5O.js} +2 -2
  154. package/dist/owletto/dist/assets/subDays-BGA_fkig.js +2 -0
  155. package/dist/owletto/dist/assets/two-factor-pqoxGSgL.js +2 -0
  156. package/dist/owletto/dist/assets/{use-automations-DfBtVzGa.js → use-automations-DcdlmVuX.js} +2 -2
  157. package/dist/owletto/dist/assets/{use-login-redirect-BDiS3eyl.js → use-login-redirect-D7HW5Ed6.js} +2 -2
  158. package/dist/owletto/dist/assets/{use-mention-search-khySpz_V.js → use-mention-search-BniE-K2d.js} +3 -3
  159. package/dist/owletto/dist/assets/view-card-Cg6PeEiV.js +2 -0
  160. package/dist/owletto/dist/assets/view-param-filters-CvrKw0mZ.js +2 -0
  161. package/dist/owletto/dist/index.html +2 -2
  162. package/dist/server-main.bundle.mjs +5766 -2999
  163. package/npm-shrinkwrap.json +195 -172
  164. package/package.json +2 -1
  165. package/vendor/connector-sdk/dist/connector-types.d.ts +20 -0
  166. package/vendor/connector-sdk/dist/define-connector.js +2 -0
  167. package/vendor/connector-sdk/dist/extension-dom-scrape.d.ts +2 -0
  168. package/vendor/connector-sdk/dist/extension-dom-scrape.js +5 -0
  169. package/vendor/connector-sdk/dist/reaction-client-types.d.ts +20 -0
  170. package/vendor/connector-sdk/package.json +1 -1
  171. package/vendor/core/dist/contracts/entity-reference.d.ts +2 -0
  172. package/vendor/core/dist/contracts/entity-reference.js +4 -3
  173. package/vendor/core/dist/contracts/tools/entity-list-sort.d.ts +18 -0
  174. package/vendor/core/dist/contracts/tools/entity-list-sort.js +64 -0
  175. package/vendor/core/dist/contracts/tools/manage-agents.d.ts +1 -1
  176. package/vendor/core/dist/contracts/tools/manage-agents.js +3 -3
  177. package/vendor/core/dist/contracts/tools/manage-entity-schema.d.ts +4 -0
  178. package/vendor/core/dist/contracts/tools/manage-entity-schema.js +4 -0
  179. package/vendor/core/dist/contracts/tools/manage-entity.d.ts +4 -0
  180. package/vendor/core/dist/contracts/tools/manage-entity.js +11 -1
  181. package/vendor/core/dist/contracts/tools/manage-operations.d.ts +29 -3
  182. package/vendor/core/dist/contracts/tools/manage-operations.js +24 -2
  183. package/vendor/core/dist/contracts/tools/manage-views.d.ts +36 -0
  184. package/vendor/core/dist/contracts/tools/manage-views.js +15 -2
  185. package/vendor/core/dist/contracts/tools/view-definition.js +7 -2
  186. package/vendor/core/dist/contracts/tools/view-host.js +5 -0
  187. package/vendor/core/dist/contracts/tools/view-path.d.ts +8 -1
  188. package/vendor/core/dist/contracts/tools/view-path.js +11 -1
  189. package/vendor/core/dist/reserved.d.ts +7 -1
  190. package/vendor/core/dist/reserved.js +17 -0
  191. package/vendor/core/package.json +6 -1
  192. package/vendor/views/dist/api.d.ts +19 -3
  193. package/vendor/views/dist/api.js +53 -5
  194. package/vendor/views/dist/components.d.ts +7 -0
  195. package/vendor/views/dist/components.js +223 -2
  196. package/vendor/views/dist/embed.js +13 -2
  197. package/vendor/views/dist/live-gate.d.ts +34 -0
  198. package/vendor/views/dist/live-gate.js +100 -0
  199. package/vendor/views/dist/native.d.ts +43 -1
  200. package/vendor/views/dist/native.js +1 -0
  201. package/vendor/views/package.json +1 -1
  202. package/dist/owletto/dist/assets/_-BDMUN9XZ.js +0 -2
  203. package/dist/owletto/dist/assets/_-CF5X4ANe.js +0 -3
  204. package/dist/owletto/dist/assets/_agentId-EQU2aUP0.js +0 -2
  205. package/dist/owletto/dist/assets/_automationId-PXZ33jsF.js +0 -2
  206. package/dist/owletto/dist/assets/_connectorKey._connectionId-DcI29kGy.js +0 -2
  207. package/dist/owletto/dist/assets/_connectorKey.index-Cr2NDJWX.js +0 -2
  208. package/dist/owletto/dist/assets/_conversationId-CnmLYlVS.js +0 -2
  209. package/dist/owletto/dist/assets/_eventId-w5sDz5oa.js +0 -2
  210. package/dist/owletto/dist/assets/_owner-CkOZR4n0.js +0 -3
  211. package/dist/owletto/dist/assets/_shape-C_FmSf9G.js +0 -2
  212. package/dist/owletto/dist/assets/_slug-COPpRXLt.js +0 -2
  213. package/dist/owletto/dist/assets/_viewKey-BVdJiilV.js +0 -2
  214. package/dist/owletto/dist/assets/_viewKey-mxxpqjtC.js +0 -2
  215. package/dist/owletto/dist/assets/activity-route-view-msesKUwn.js +0 -2
  216. package/dist/owletto/dist/assets/agent-connect-pages-DVq9nAR7.js +0 -4
  217. package/dist/owletto/dist/assets/agent-thread-Cqf9ITrT.js +0 -6
  218. package/dist/owletto/dist/assets/assist-composer-kG_heHXo.js +0 -2
  219. package/dist/owletto/dist/assets/automation-run-now-C5XTS00o.js +0 -2
  220. package/dist/owletto/dist/assets/client-activity-scopes-Aqdo6Pdr.js +0 -2
  221. package/dist/owletto/dist/assets/connect-BFNp1y_s.js +0 -2
  222. package/dist/owletto/dist/assets/connect-menu-BWrAhMqO.js +0 -2
  223. package/dist/owletto/dist/assets/connect._clientId-CSPfwYIN.js +0 -2
  224. package/dist/owletto/dist/assets/connected._clientId-CuOeHafK.js +0 -2
  225. package/dist/owletto/dist/assets/connection-CVeHmDLs.js +0 -2
  226. package/dist/owletto/dist/assets/connection-feed-detail-BYo7zdVD.js +0 -2
  227. package/dist/owletto/dist/assets/connectors-DBEM9QQz.js +0 -2
  228. package/dist/owletto/dist/assets/copy-button-Xhh7ZnjO.js +0 -2
  229. package/dist/owletto/dist/assets/create-Ccb5R-S4.js +0 -2
  230. package/dist/owletto/dist/assets/create-DmhbacIa.js +0 -2
  231. package/dist/owletto/dist/assets/create._connectorKey-CZsAqj1p.js +0 -2
  232. package/dist/owletto/dist/assets/custom-guardrail-edits-Ce_BwiwD.js +0 -2
  233. package/dist/owletto/dist/assets/definition-comparison-D_qP25jR.js +0 -2
  234. package/dist/owletto/dist/assets/detail-page-skeleton-CPAfZLG0.js +0 -2
  235. package/dist/owletto/dist/assets/device-DDl5XKvt.js +0 -2
  236. package/dist/owletto/dist/assets/device._deviceId-bNhTcops.js +0 -2
  237. package/dist/owletto/dist/assets/dynamic-schema-form-CRyUchXo.js +0 -2
  238. package/dist/owletto/dist/assets/entity-page-BOOL_vy3.js +0 -2
  239. package/dist/owletto/dist/assets/entity-pages-_nuesgnp.js +0 -2
  240. package/dist/owletto/dist/assets/entity-type-page-CkCSbkBx.js +0 -2
  241. package/dist/owletto/dist/assets/event-detail-DUvlqn9b.js +0 -2
  242. package/dist/owletto/dist/assets/events-feed-DcKTkJVe.js +0 -2
  243. package/dist/owletto/dist/assets/index-BUlkNJzX.js +0 -2
  244. package/dist/owletto/dist/assets/index-BoqrvLHQ.js +0 -7906
  245. package/dist/owletto/dist/assets/index-CA9mW_ZM.js +0 -2
  246. package/dist/owletto/dist/assets/index-CH0GzG4i.js +0 -2
  247. package/dist/owletto/dist/assets/index-CtI5Eomq.js +0 -2
  248. package/dist/owletto/dist/assets/index-DmtQ0bds.js +0 -2
  249. package/dist/owletto/dist/assets/index-Du_J8hnx.js +0 -2
  250. package/dist/owletto/dist/assets/index-Pae_f9LM.css +0 -1
  251. package/dist/owletto/dist/assets/index-XETZnN7L.js +0 -2
  252. package/dist/owletto/dist/assets/login-DG0b9uSC.js +0 -2
  253. package/dist/owletto/dist/assets/memory-browse-page-qEDQ9Z18.js +0 -74
  254. package/dist/owletto/dist/assets/missing-view-xT0B-f5z.js +0 -2
  255. package/dist/owletto/dist/assets/needs-you-list-3uMsWcDv.js +0 -2
  256. package/dist/owletto/dist/assets/new-AdGV6a8R.js +0 -2
  257. package/dist/owletto/dist/assets/new-BdtIhBpo.js +0 -2
  258. package/dist/owletto/dist/assets/new-BjGwX6s6.js +0 -2
  259. package/dist/owletto/dist/assets/new-D-iMjV74.js +0 -2
  260. package/dist/owletto/dist/assets/organization-qaIpEiQg.js +0 -2
  261. package/dist/owletto/dist/assets/peek-pane-content-CEsDVScl.js +0 -2
  262. package/dist/owletto/dist/assets/proposal-review-shell-C8ZfIAYn.js +0 -2
  263. package/dist/owletto/dist/assets/public-shell-ready-K2R8iXSI.js +0 -2
  264. package/dist/owletto/dist/assets/record-session-BrM9cdXu.js +0 -2
  265. package/dist/owletto/dist/assets/run-initiator-BKSgI1o0.js +0 -2
  266. package/dist/owletto/dist/assets/runs-k2NpbZm8.js +0 -2
  267. package/dist/owletto/dist/assets/runs-list-DUXRMkWN.js +0 -2
  268. package/dist/owletto/dist/assets/schema-value-wjqGxXhv.js +0 -3
  269. package/dist/owletto/dist/assets/settings-V0m5Om5j.js +0 -2
  270. package/dist/owletto/dist/assets/source-record-panels-BMut9YIA.js +0 -2
  271. package/dist/owletto/dist/assets/subDays-9s9OEl5t.js +0 -2
  272. package/dist/owletto/dist/assets/table-ZuYMOjVR.js +0 -2
  273. package/dist/owletto/dist/assets/view-card-DiHWlypr.js +0 -2
  274. package/dist/owletto/dist/assets/view-param-filters-DGKxSr7r.js +0 -2
  275. package/dist/owletto/dist/assets/views-access-required-HA-PiOwA.js +0 -2
@@ -0,0 +1,6 @@
1
+ import{j as s,r as a,b8 as Ht,z as zt,ib as Wt,h1 as Kt,ah as et,a5 as Be,ai as tt,cm as qt,ic as nt,hp as Gt,L as gt,i as P,gJ as Jt,gU as bt,gV as Yt,id as Qt,c_ as Xt,gW as Zt,ie as en,a_ as tn,B as fe,gx as nn,ig as rn,fe as rt,X as on,an as sn,gg as ln,ej as Ne,ih as an,aM as cn,aN as un,ii as dn,aP as fn,hr as pn,ij as ot,d6 as mn,ik as hn,fz as gn,a9 as bn,h9 as xn,ha as vn}from"./index-DB2lVKuV.js";import{D as yn,E as Rn}from"./app-bridge-B-L0rGz9.js";import{A as wn,a as Sn,b as Cn,c as qe,d as xt,e as Tn}from"./agent-loading-shells-D3y98xuO.js";import{t as jn,P as Nn}from"./pending-seed-CTKYdA4X.js";import{h as En,t as An,R as In,i as kn,u as _n,f as On,b as Pn}from"./use-mention-search-BniE-K2d.js";import{E as Mn,c as Ln,d as $n}from"./events-feed-ClhEywwV.js";const vt=a.createContext(null);function Dn({extension:e,children:t}){return s.jsx(vt.Provider,{value:e??null,children:t})}function Ge(){return a.useContext(vt)}var Je=(e=>(e.PROVIDER_QUOTA_EXHAUSTED="PROVIDER_QUOTA_EXHAUSTED",e.PROVIDER_AUTH="PROVIDER_AUTH",e.PROVIDER_UNKNOWN_MODEL="PROVIDER_UNKNOWN_MODEL",e.PROVIDER_BASE_URL_UNRESOLVED="PROVIDER_BASE_URL_UNRESOLVED",e.NO_MODEL_CONFIGURED="NO_MODEL_CONFIGURED",e.WORKER_UNRESPONSIVE="WORKER_UNRESPONSIVE",e.WORKER_DIED="WORKER_DIED",e.WORKER_STARTUP_FAILED="WORKER_STARTUP_FAILED",e.PROVIDER_TOOL_CALL_FAILED="PROVIDER_TOOL_CALL_FAILED",e.SESSION_TIMEOUT="SESSION_TIMEOUT",e))(Je||{});const Un={PROVIDER_QUOTA_EXHAUSTED:{cta:"provider-management",ctaLabel:"Manage provider"},PROVIDER_AUTH:{cta:"provider-management",ctaLabel:"Reconnect provider"},PROVIDER_UNKNOWN_MODEL:{cta:"agent-settings",ctaLabel:"Choose model"},PROVIDER_BASE_URL_UNRESOLVED:{cta:"provider-management",ctaLabel:"Manage provider"},PROVIDER_TOOL_CALL_FAILED:{message:"The model provider rejected its own tool call and ended the turn. This is usually temporary — please try again.",cta:"none"},NO_MODEL_CONFIGURED:{message:"No model is configured for this agent. Choose a model in agent settings.",cta:"agent-settings",ctaLabel:"Choose a model"},WORKER_UNRESPONSIVE:{message:"The agent didn't finish responding in time. This is usually temporary — please try again.",cta:"none"},WORKER_DIED:{message:"The agent stopped unexpectedly before it could reply. This is usually temporary — please try again.",cta:"none"},WORKER_STARTUP_FAILED:{message:"The agent couldn't start, so your request wasn't processed. Please try again in a moment.",cta:"none"},SESSION_TIMEOUT:{cta:"none",silent:!0}};function Fn(e){if(typeof e=="string")return Object.values(Je).includes(e)?e:void 0}const Vn=Object.freeze(Object.defineProperty({__proto__:null,AGENT_ERRORS:Un,AgentErrorCode:Je,toAgentErrorCode:Fn},Symbol.toStringTag,{value:"Module"})),{AGENT_ERRORS:Bn,toAgentErrorCode:Hn}=Vn;function st(e,t){if(!t)return null;try{const n=new URL(t);return n.protocol!=="http:"&&n.protocol!=="https:"?null:new URL(e,`${n.origin}/`).toString()}catch{return null}}function yt(e,t){const n=Hn(e);if(!n)return null;const r=Bn[n];if(r.cta==="none"||!t.workspaceSlug)return null;const o=encodeURIComponent(t.workspaceSlug);if(r.cta==="provider-connect"||r.cta==="provider-management"){const i=t.provider?`/${o}/connectors/${encodeURIComponent(`${Ht}${t.provider}`)}`:`/${o}/connectors`,c=st(i,t.webOrigin);if(!c)return null;const u=new URL(c);return t.provider&&t.model&&u.searchParams.set("model",t.model),{label:r.ctaLabel??"Connect a provider",href:u.toString()}}if(!t.agentId)return null;const l=st(`/${o}/agents/${encodeURIComponent(t.agentId)}#models`,t.webOrigin);return l?{label:r.ctaLabel??"Open settings",href:l}:null}function Rt(e){if(!e||typeof e!="object"||Array.isArray(e))return null;const t=e.subscribable;if(!t||typeof t!="object"||Array.isArray(t))return null;const n=t;if(typeof n.connector_key!="string"||!n.connector_key||typeof n.resource_type!="string"||!n.resource_type||typeof n.resource_ref!="string"||!n.resource_ref||typeof n.label!="string"||!n.label)return null;const r=Array.isArray(n.suggested_event_keys)?n.suggested_event_keys.filter(o=>typeof o=="string"&&!!o):void 0;return{connector_key:n.connector_key,resource_type:n.resource_type,resource_ref:n.resource_ref,label:n.label,...r?.length?{suggested_event_keys:r}:{}}}const lt=new Set(["localhost","127.0.0.1","::1","[::1]"]);function zn(e){return e?.trim().toLowerCase().replace(/^\.+|\.+$/g,"")||null}function at(e,t){const n=zn(t);if(!n)return!1;const r=e.toLowerCase().replace(/\.$/,"");return r===n||r.endsWith(`.${n}`)}function it(e,t,n){try{const r=new URL(t),o=new URL(e,t),l=lt.has(o.hostname)&&lt.has(r.hostname),i=o.protocol===r.protocol&&(o.protocol==="https:"||o.protocol==="http:")&&at(o.hostname,n)&&at(r.hostname,n);return o.origin!==r.origin&&(l||i)&&(o.protocol=r.protocol,o.host=r.host),o.origin===r.origin&&o.pathname.startsWith("/api/v1/agents")&&(o.pathname=`/lobu${o.pathname}`),o.toString()}catch{return e}}const Wn=/\.(png|jpe?g|gif|webp|avif|bmp|svg)$/i,wt=new Set(["suggest_actions"]),Me="Thinking…";function Kn(e){const{textOut:t,statusLine:n,errorText:r,toolCalls:o}=e,l=[];n===Me&&l.push({type:"reasoning"}),r&&l.push({type:"error",text:r});let i=t;return n&&n!==Me&&(i=t?`${t}
2
+
3
+ ${n}`:n),i&&l.push({type:"text",text:i}),l.push(...o),l}const St=[];function qn(e,t,n){return e?.length?e:n===0?t:[]}const Ye=a.createContext(null);function Ee(){const e=a.useContext(Ye);if(!e)throw new Error("useLobuChat must be used within <LobuChatProvider>");return e}function Uo({messages:e,workspaceSlug:t=null,children:n}){const r=a.useMemo(()=>({messages:e,running:!1,append:()=>{},cancel:()=>{},pendingAttachments:[],addAttachments:()=>{},removeAttachment:()=>{},agentId:null,conversationId:"",workspaceSlug:t,currentSuggestions:null,starters:St}),[e,t]);return s.jsx(Ye.Provider,{value:r,children:n})}const Ct=/\[([^\]]*)\]\((\S*?\/api\/v1\/files\/[^)\s]+)\)/g;function ct(e){return e.replace(/<lobu_internal_context>[\s\S]*?<\/lobu_internal_context>\n*/g,"").replace(Ct,"").replace(/\n{3,}/g,`
4
+
5
+ `).trim()}function Gn(e){const t=[];for(const n of e.matchAll(Ct)){const r=n[1]?.trim()||"file",o=n[2];o&&t.push({name:r,url:o})}return t}function Jn(e,t={}){if(typeof e=="string"){const r=ct(e);return r?[{type:"text",text:r}]:[]}if(!Array.isArray(e))return[];const n=[];for(const r of e){if(!r||typeof r!="object")continue;const o=r;if(o.type==="text"&&typeof o.text=="string"){const l=ct(o.text);l&&n.push({type:"text",text:l})}else t.showToolCalls&&o.type==="toolCall"&&typeof o.name=="string"&&!wt.has(o.name)?n.push({type:"tool-call",toolCallId:o.id??`tc-${n.length}`,toolName:o.name,args:o.arguments??{},...o.result!==void 0?{result:o.result}:{}}):t.showToolCalls&&o.type==="tool_use"&&typeof o.name=="string"&&n.push({type:"tool-call",toolCallId:o.id??`tc-${n.length}`,toolName:o.name,args:o.input??{},...o.result!==void 0?{result:o.result}:{}})}return n}function Yn(e){const t=[],n=r=>{for(const{name:o,url:l}of Gn(r))t.push({id:`file-${t.length}`,name:o,url:l,isImage:Wn.test(o)})};if(typeof e=="string")return n(e),t.length>0?t:void 0;if(Array.isArray(e)){for(const r of e){if(!r||typeof r!="object")continue;const o=r;if(o.type==="image"&&typeof o.data=="string"){const l=o.mimeType||"image/png";t.push({id:`img-${t.length}`,name:`image-${t.length+1}`,imageDataUrl:`data:${l};base64,${o.data}`,isImage:!0})}else o.type==="text"&&typeof o.text=="string"&&n(o.text)}return t.length>0?t:void 0}}function Qn(e,t){if(e.type==="bashExecution"){const r=e.content??{},o=e.timestamp?new Date(e.timestamp).getTime():void 0;return{id:e.id,role:"user",parts:[{type:"bash",command:r.command??"",output:r.output??"",exitCode:r.exitCode,cancelled:r.cancelled??!1}],createdAt:o&&!Number.isNaN(o)?o:void 0}}if(e.type!=="message"||e.isVerbose||e.role!=="assistant"&&e.role!=="user"&&e.role!=="system")return null;const n=e.timestamp?new Date(e.timestamp).getTime():void 0;return{id:e.id,role:e.role,parts:Jn(e.content,t),attachments:Yn(e.content),createdAt:n&&!Number.isNaN(n)?n:void 0}}const Xn=[],Zn=[];function er(e){let t=null;for(const n of e)n.type==="suggestion"&&(t=n.prompts.length>0?n.prompts:null);return t}function tr(e,t){if(e.length===0)return null;const n=[];for(const r of e)if(r.type!=="suggestion"){if(r.type==="agent-error"){n.push({type:"error",text:String(r.error??"Agent reported an error.")});const o=yt(r.errorCode,{...t,provider:r.errorContext?.provider,model:r.errorContext?.model});o&&n.push({type:"tool-call",toolCallId:`error-run-${r.runId}`,toolName:"link-button",args:{label:o.label,url:o.href}});continue}n.push({type:"tool-call",toolCallId:`approval-event-${r.eventId}`,toolName:"tool-approval",args:{runId:r.runId,action:r.action,proposal:r.proposal,current:r.current,fields:r.fields??null,attribution:r.attribution??null,resourceKind:r.resourceKind??null,reason:r.reason??null,status:r.status??"pending",reviewedByName:r.reviewedByName??null}})}return n.length===0?null:{id:"history-interactions",role:"assistant",parts:n}}const nr=3e4,rr=3*nr,or=15e3;function ut(e){try{return JSON.parse(e.data)}catch{return{content:e.data}}}const be=e=>`${e}-${Date.now()}-${Math.random().toString(36).slice(2,6)}`;function sr(e){const t=[],n=new Set;for(const r of e){if(!r||typeof r!="object")continue;const{title:o,message:l}=r;if(typeof o!="string"||typeof l!="string")continue;const i=o.trim(),c=l.trim();if(i.length===0||c.length===0)continue;const u=`${i}\0${c}`;n.has(u)||(n.add(u),t.push({title:i,message:c}))}return t.length>0?t:null}function Fo({agentId:e,workspaceSlug:t,thread:n="agent-panel",loadHistory:r=!0,ephemeralContext:o,onFirstUserMessage:l,children:i,initialDraft:c}){const u=zt(),d=a.useRef(null),m=a.useRef(null),y=a.useRef(!1),h=a.useRef(o),g=a.useRef(!1),w=a.useRef(null);h.current=o;const{data:E,isLoading:v}=Wt(e,n,{orgSlug:t,enabled:r&&!!e&&!!n}),C=E?.messages??Xn,H=E?.interactions??Zn,{data:U}=Kt(e,{enabled:!!e}),K=U?.starters??St,z=!!(U?.showToolCalls??U?.settings?.showToolCalls),[N,L]=a.useState([]),[G,le]=a.useState(!1),[$,q]=a.useState([]),[J,R]=a.useState(null),S=a.useRef(!1);S.current=G;const T=a.useMemo(()=>C.map(I=>Qn(I,{showToolCalls:z})).filter(I=>I!==null),[C,z]),O=a.useRef(!1);a.useEffect(()=>{if(O.current||v||S.current)return;O.current=!0;const I=tr(H,{workspaceSlug:t,agentId:e,webOrigin:typeof window>"u"?null:window.location.origin});L(I?[...T,I]:T),R(er(H))},[e,v,T,H,t]);const A=a.useCallback(()=>{u.invalidateQueries({queryKey:["agent-thread-messages",t,e,n]}),u.invalidateQueries({queryKey:["agent-threads",t,e]})},[u,t,e,n]),Z=a.useCallback(async()=>{if(d.current)return d.current;if(m.current)return m.current;if(!e)throw new Error("No agent selected");const I=(async()=>{const M=await et(`${Be}/lobu/api/v1/agents`,{method:"POST",headers:{"Content-Type":"application/json",...t?{"x-lobu-org":t}:{}},credentials:"include",body:JSON.stringify({agentId:e,thread:n}),timeoutMs:2e4});if(!M.ok)throw await tt(M);const V=await M.json(),j=qt(),Q={sessionId:V.agentId,sseUrl:it(V.sseUrl,Be,j),messagesUrl:it(V.messagesUrl,Be,j)};return d.current=Q,Q})();m.current=I;try{return await I}catch(M){throw d.current=null,M}finally{m.current=null}},[e,t,n]),te=a.useCallback(async(I,M,V)=>{const j=crypto.randomUUID(),Q=new AbortController;w.current=Q;const W=f=>{L(p=>p.map(b=>b.id===V?{...b,parts:f}:b))};let B;try{B=await Z()}catch(f){W([{type:"text",text:`Error: ${f instanceof Error?f.message:"Could not start a session."}`}]);return}let X=await nt(B.sseUrl,{throwOnFailure:!0});const pe=[];let ie=null;const Re=()=>{const f=ie;ie=null,f?.()},we=f=>{pe.push(f),Re()},Se=(f,p)=>{const k=["question","link-button","tool-approval"].includes(f)?p.turnMessageId===j:p.messageId===j||Array.isArray(p.processedMessageIds)&&p.processedMessageIds.includes(j);(f==="closed"||k)&&we({kind:f,payload:p})};let me=!1,Ce=null;const Ie=new Promise(f=>{Ce=f});let ce=0,he=Date.now();const ue=f=>{he=Date.now();const p=Number(f.lastEventId);Number.isFinite(p)&&p>ce&&(ce=p)},ke=["output","status","complete","closed","agent-error","question","link-button","tool-approval","tool_use"],Te=f=>{f.addEventListener("open",()=>{me=!0,Ce?.()}),f.addEventListener("connected",b=>{ue(b),me||(me=!0,Ce?.())}),f.addEventListener("ping",ue);const p=b=>k=>{ue(k);const ee=k;typeof ee.data=="string"&&Se(b,ut(ee))};for(const b of ke)f.addEventListener(b,p(b));f.addEventListener("error",b=>{const k=b;if(typeof k.data=="string"&&k.data){ue(b),Se("error",ut(k));return}f.readyState===EventSource.CLOSED&&we({kind:"error",payload:{error:"Connection closed"}})})};Te(X);const _e=async()=>{X.close();let f=B.sseUrl;if(ce){const p=new URL(B.sseUrl,window.location.origin);p.searchParams.set("since",String(ce)),f=p.toString()}X=await nt(f,{throwOnFailure:!1}),Te(X),he=Date.now()};await Promise.race([Ie,new Promise(f=>setTimeout(f,1500))]);const Oe=()=>{X.close(),Re()};Q.signal.addEventListener("abort",Oe,{once:!0});try{const f=h.current?.trim(),p=!!f&&!g.current;p&&(g.current=!0);let b;if(M.length>0){const x=new FormData;x.set("content",I),x.set("messageId",j),p&&f&&x.set("ephemeralContext",f);for(const _ of M)x.append("files",_,_.name);b={method:"POST",credentials:"include",body:x,timeoutMs:12e4}}else{const x={content:I,messageId:j};p&&f&&(x.ephemeralContext=f),b={method:"POST",headers:{"Content-Type":"application/json"},credentials:"include",body:JSON.stringify(x),timeoutMs:2e4}}const k=await et(B.messagesUrl,b);if(!k.ok)throw d.current=null,await tt(k);let ee="",D=Me,Ze=null;const ge=[],de=()=>Kn({textOut:ee,statusLine:D,errorText:Ze,toolCalls:ge});for(W(de());!Q.signal.aborted;){if(pe.length===0){let _;const ne=await Promise.race([new Promise(Ve=>{ie=()=>Ve(!0)}),new Promise(Ve=>{_=setTimeout(()=>Ve(!1),or)})]);_&&clearTimeout(_),!ne&&Date.now()-he>=rr&&(await _e(),A());continue}const x=pe.shift();if(x){if(x.kind==="output")D=null,ee+=String(x.payload.content??"");else if(x.kind==="status")D=Me;else if(x.kind==="complete"){D=null;const _=x.payload.finalText;typeof _=="string"&&_.length>0&&(ee=_);const ne=x.payload.suggestions;ne!==void 0&&R(Array.isArray(ne)?sr(ne):null),A(),W(de());return}else if(x.kind==="closed"){d.current=null;const _=x.payload.reason;D=`Session ended${_?`: ${_}`:""}.`,A(),W(de());return}else if(x.kind==="error"||x.kind==="agent-error"){D=null,Ze=typeof x.payload.error=="string"&&x.payload.error?x.payload.error:"Agent reported an error.";const _=x.payload.errorContext&&typeof x.payload.errorContext=="object"?x.payload.errorContext:void 0,ne=yt(x.payload.errorCode,{workspaceSlug:t,agentId:e,webOrigin:typeof window>"u"?null:window.location.origin,provider:typeof _?.provider=="string"?_.provider:void 0,model:typeof _?.model=="string"?_.model:void 0});ne&&ge.push({type:"tool-call",toolCallId:be("l"),toolName:"link-button",args:{label:ne.label,url:ne.href}}),A(),W(de());return}else if(x.kind==="question")ge.push({type:"tool-call",toolCallId:be("q"),toolName:"question",args:{question:x.payload.question??"",options:x.payload.options??[]}});else if(x.kind==="tool_use"){if(D=null,wt.has(x.payload.name??"")){W(de());continue}const _=x.payload.result_summary,ne=Rt(_);if(!z&&!ne){W(de());continue}ge.push({type:"tool-call",toolCallId:x.payload.toolCallId??be("t"),toolName:z?x.payload.name??"tool":"subscription-candidate",args:z?x.payload.input??{}:null,result:_,isError:x.payload.isError})}else if(x.kind==="link-button")ge.push({type:"tool-call",toolCallId:be("l"),toolName:"link-button",args:{label:x.payload.label??"Open link",url:x.payload.url??""}});else if(x.kind==="tool-approval"){const _=x.payload.runId;if(typeof _!="number")continue;ge.push({type:"tool-call",toolCallId:`run-${_}`,toolName:"tool-approval",args:{runId:_,action:x.payload.action??null,proposal:x.payload.proposal??null,current:x.payload.current??null,fields:x.payload.fields??null,attribution:x.payload.attribution??null,resourceKind:x.payload.resourceKind??null}})}W(de())}}}catch(f){W([{type:"text",text:`Error: ${f instanceof Error?f.message:"Send failed."}`}])}finally{Q.signal.removeEventListener("abort",Oe),X.close()}},[e,Z,A,z,t]),re=a.useCallback(I=>{const M=I.trim(),V=$.map(B=>B.file);if(!M&&V.length===0||S.current||!e)return;y.current||(y.current=!0,l?.(M||V[0]?.name||""));const j={id:be("u"),role:"user",parts:M?[{type:"text",text:M}]:[],attachments:$.map(B=>({id:B.id,name:B.name,isImage:B.isImage,imageDataUrl:B.isImage?URL.createObjectURL(B.file):void 0})),createdAt:Date.now()},Q=be("asst"),W={id:Q,role:"assistant",parts:[{type:"reasoning"}],createdAt:Date.now()};L(B=>[...B,j,W]),q([]),le(!0),S.current=!0,te(M,V,Q).finally(()=>{le(!1),S.current=!1,w.current=null})},[e,l,$,te]),se=a.useCallback(()=>{w.current?.abort()},[]),ye=a.useCallback(I=>{const M=Array.from(I);q(V=>[...V,...M.map(j=>({id:crypto.randomUUID(),name:j.name,file:j,isImage:j.type.startsWith("image/")}))])},[]),Y=a.useCallback(I=>{q(M=>M.filter(V=>V.id!==I))},[]),ae=a.useRef(!1);a.useEffect(()=>{if(ae.current)return;const I=jn(n);I&&(ae.current=!0,re(I))},[n,re]);const F=a.useMemo(()=>({messages:N,running:G,append:re,cancel:se,pendingAttachments:$,addAttachments:ye,removeAttachment:Y,initialDraft:c,agentId:e,conversationId:n,workspaceSlug:t,currentSuggestions:J,starters:K}),[N,G,re,se,$,ye,Y,c,e,n,t,J,K]);return r&&v?s.jsx(wn,{}):s.jsx(Ye.Provider,{value:F,children:i})}const dt="mx-0.5 inline-flex items-center gap-1 rounded-md bg-accent px-1.5 py-0.5 align-baseline font-medium text-[0.9em] text-accent-foreground no-underline";function lr({refItem:e}){const t=In[e.kind]??Gt;return kn(e.path)?s.jsxs("span",{className:dt,children:[s.jsx(t,{className:"h-3 w-3 shrink-0 opacity-70"}),e.label]}):s.jsxs(gt,{to:e.path,className:P(dt,"hover:bg-accent/80"),children:[s.jsx(t,{className:"h-3 w-3 shrink-0 opacity-70"}),e.label]})}const Qe=({text:e,renderText:t})=>En(e)?s.jsx(s.Fragment,{children:An(e).map((n,r)=>n.type==="ref"?s.jsx(lr,{refItem:n.ref},`r${r}`):s.jsx("span",{children:t(n.text)},`t${r}`))}):s.jsx(s.Fragment,{children:t(e)}),ar=({label:e="Thinking"})=>s.jsx("span",{className:"aui-thinking-shimmer inline-block text-sm","aria-live":"polite","aria-busy":"true",children:e}),Tt=a.createContext(null),jt=()=>{const e=a.useContext(Tt);if(!e)throw new Error("ChainOfThought components must be used within ChainOfThought");return e},Nt=a.memo(({className:e,open:t,defaultOpen:n=!1,onOpenChange:r,children:o,...l})=>{const[i,c]=Jt({prop:t,defaultProp:n,onChange:r}),u=a.useMemo(()=>({isOpen:i,setIsOpen:c}),[i,c]);return s.jsx(Tt.Provider,{value:u,children:s.jsx("div",{className:P("not-prose max-w-prose space-y-4",e),...l,children:o})})}),Et=a.memo(({className:e,children:t,...n})=>{const{isOpen:r,setIsOpen:o}=jt();return s.jsx(bt,{onOpenChange:o,open:r,children:s.jsxs(Yt,{className:P("flex w-full items-center gap-2 text-muted-foreground text-sm transition-colors hover:text-foreground",e),...n,children:[s.jsx(Qt,{className:"size-4"}),s.jsx("span",{className:"flex-1 text-left",children:t??"Chain of Thought"}),s.jsx(Xt,{className:P("size-4 transition-transform",r?"rotate-180":"rotate-0")})]})})}),At=a.memo(({className:e,icon:t=en,label:n,description:r,status:o="complete",children:l,...i})=>{const c={complete:"text-muted-foreground",active:"text-foreground",pending:"text-muted-foreground/50"};return s.jsxs("div",{className:P("flex gap-2 text-sm",c[o],"fade-in-0 slide-in-from-top-2 animate-in",e),...i,children:[s.jsxs("div",{className:"relative mt-0.5",children:[s.jsx(t,{className:"size-4"}),s.jsx("div",{className:"-mx-px absolute top-7 bottom-0 left-1/2 w-px bg-border"})]}),s.jsxs("div",{className:"flex-1 space-y-2 overflow-hidden",children:[s.jsx("div",{children:n}),r&&s.jsx("div",{className:"text-muted-foreground text-xs",children:r}),l]})]})}),It=a.memo(({className:e,children:t,...n})=>{const{isOpen:r}=jt();return s.jsx(bt,{open:r,children:s.jsx(Zt,{className:P("mt-2 space-y-3","data-[state=closed]:fade-out-0 data-[state=closed]:slide-out-to-top-2 data-[state=open]:slide-in-from-top-2 text-popover-foreground outline-none data-[state=closed]:animate-out data-[state=open]:animate-in",e),...n,children:t})})});Nt.displayName="ChainOfThought";Et.displayName="ChainOfThoughtHeader";At.displayName="ChainOfThoughtStep";It.displayName="ChainOfThoughtContent";function ir(e){return{contentIds:e.filter(n=>Number.isSafeInteger(n)&&n>0),sortBy:"date",sortOrder:"asc"}}function cr({ownerSlug:e,eventIds:t}){const n=t.join(","),r=a.useMemo(()=>ir(n.split(",").map(Number)),[n]);return r.contentIds.length===0?null:s.jsx(tn,{owner:e,children:({organizationId:o,ownerSlug:l})=>o?s.jsx(Mn,{organizationId:o,ownerSlug:l,filters:r,hideOriginator:!0}):null})}function ur({defaultTagName:e,props:t,render:n,state:r={},stateAttributesMapping:o}){let l=He(dr(r,o),t);if(!n)return a.createElement(e,l);if(typeof n=="function")return n(l,r);if(!a.isValidElement(n))return null;let i=n.props,c={...He(l,i),ref:Ae(l.ref,i.ref)};return a.cloneElement(n,c)}function He(...e){let t={};for(let n of e){if(!n)continue;let r=n;for(let o of Object.keys(r)){let l=r[o];if(l===void 0)continue;let i=t[o];o==="className"?t[o]=[i,l].filter(Boolean).join(" "):o==="style"?t[o]={...i,...l}:o==="ref"?t[o]=Ae(i,l):pr(o)&&typeof i=="function"&&typeof l=="function"?t[o]=fr(l,i):t[o]=l}}return t}function dr(e,t){let n={};for(let r of Object.keys(e)){let o=e[r],l=t?.[r]?.(o);if(l){Object.assign(n,l);continue}if(r==="slot"){n["data-slot"]=o;continue}let i=`data-${String(r).replace(/[A-Z]/g,c=>`-${c.toLowerCase()}`)}`;typeof o=="boolean"?n[i]=o?"":void 0:o!=null&&(n[i]=String(o))}return n}function fr(e,t){return function(n){e(n),n.defaultPrevented||t(n)}}function pr(e){return/^on[A-Z]/.test(e)}function Ae(...e){let t=e.filter(Boolean);if(t.length!==0)return n=>{for(let r of t)typeof r=="function"?r(n):r&&(r.current=n)}}var mr=8,hr=64,gr=0,Le=.5,br=180,xr=new Set(["ArrowDown","ArrowUp","End","Home","PageDown","PageUp"," "]),kt={start:!1,end:!1},vr=[],$e={currentAnchorId:null,visibleMessageIds:vr};function yr({content:e,scrollEdgeThreshold:t,spacer:n,viewport:r}){if(!r||!e)return kt;let o=Xe({content:e,spacer:n,viewport:r});return{start:r.scrollTop>t,end:o-r.scrollTop-r.clientHeight>t}}function Rr({content:e,scrollMargin:t,scrollPreviousItemPeek:n,spacer:r,viewport:o,visibleMessageIds:l}){if(!e||!o)return $e;let i=o.getBoundingClientRect(),c=i.top+t+n,u=typeof IntersectionObserver>"u",d=[],m=null;for(let y of je(e,r)){let h=y.dataset.messageId;if(!h)continue;let g=y.dataset.scrollAnchor==="true",w=g||u?y.getBoundingClientRect():null;(u&&w?w.bottom>c&&w.top<i.bottom:l.has(h))&&d.push(h),g&&w&&w.top<=c+Le&&(m=h)}return d.length===0&&m===null?$e:{currentAnchorId:m,visibleMessageIds:d}}function je(e,t){return Array.from(e.children).filter(n=>n instanceof HTMLElement&&n!==t)}function wr(e,t){for(let n=t;n<e.length;n++){let r=e[n];if(r?.dataset.scrollAnchor==="true")return r}return null}function Sr(e,t){for(let n of e)if(n.dataset.scrollAnchor==="true"&&!t.has(n))return n;return null}function Cr(e,t){let n=0;for(let r=t;r<e.length;r++)if(e[r]?.dataset.scrollAnchor==="true"&&(n+=1,n>1))return!0;return!1}function Tr(e){for(let t=e.length-1;t>=0;t--){let n=e[t];if(n?.dataset.scrollAnchor==="true")return n}return null}function jr({content:e,spacer:t,viewport:n}){let r=n.getBoundingClientRect();for(let o of je(e,t)){if(!o.dataset.messageId)continue;let l=o.getBoundingClientRect();if(l.bottom>r.top&&l.top<r.bottom)return o}return null}function Nr({align:e,element:t,scrollMargin:n,spacer:r,viewport:o}){let l=_t(t,o),i=t.getBoundingClientRect().height,c=Ir(r);if(e==="center"){let u=Math.max(0,o.clientHeight-c.start-c.end);return l-c.start-(u-i)/2-n}if(e==="end")return l-o.clientHeight+i+c.end+n;if(e==="nearest"){let u=l+i,d=o.scrollTop+c.start,m=o.scrollTop+o.clientHeight-c.end;return l>=d&&u<=m?o.scrollTop:l<d?l-c.start-n:u-o.clientHeight+c.end+n}return l-c.start-n}function _t(e,t){let n=e.getBoundingClientRect(),r=t.getBoundingClientRect();return n.top-r.top+t.scrollTop}function Pe(e,t){return e.getBoundingClientRect().top-t.getBoundingClientRect().top}function Er({content:e,scrollTop:t,spacer:n,viewport:r}){let o=Xe({content:e,spacer:n,viewport:r});return t+r.clientHeight-o}function Xe({content:e,spacer:t,viewport:n}){let r=je(e,t),o=Ot(e),l=n.getBoundingClientRect(),i=n.scrollTop,c=o.start+o.end;for(let u of r){let d=u.getBoundingClientRect();c=Math.max(c,d.bottom-l.top+i+o.end)}return c}function Ar(e){return Math.max(0,e.scrollHeight-e.clientHeight)}function Ot(e){let t=window.getComputedStyle(e);return{end:ze(t.paddingBlockEnd||t.paddingBottom),start:ze(t.paddingBlockStart||t.paddingTop)}}function Ir(e){let t=e?.parentElement;return t?Ot(t):{end:0,start:0}}function kr(e){if(!e)return 0;let t=window.getComputedStyle(e),n=t.rowGap==="normal"?t.gap:t.rowGap;return ze(n)}function ze(e){if(!e)return 0;let t=Number.parseFloat(e);return Number.isFinite(t)?t:0}function _r({refs:e,commitScrollState:t,scheduleStateCommit:n,scheduleVisibilitySync:r}){let{streamingTurnRef:o,autoScrollRef:l,autoscrollingRef:i,autoscrollingTimeoutRef:c,contentRef:u,defaultScrollPositionAppliedRef:d,itemCountRef:m,messageElementsRef:y,modeRef:h,pendingScrollToMessageRef:g,prependRestoreRef:w,scrollMarginRef:E,scrollPreviousItemPeekRef:v,spacerGapRef:C,spacerHeightRef:H,spacerRef:U,viewportRef:K}=e,z=a.useCallback(R=>{c.current!==null&&(window.clearTimeout(c.current),c.current=null),i.current!==R&&(i.current=R,t()),R&&(c.current=window.setTimeout(()=>{c.current=null,i.current=!1,t()},br))},[t]),N=a.useCallback(R=>{let S=U.current;if(!S)return;let T=Math.max(0,Math.ceil(R));H.current!==T&&(H.current=T,S.hidden=T===0,S.style.height=`${T}px`,S.style.marginTop=T>0?`${-C.current}px`:"")},[]),L=a.useCallback((R,{behavior:S="auto",autoscrolling:T=!1}={})=>{let O=K.current;if(!O)return;let A=Math.max(0,R);if(Math.abs(O.scrollTop-A)<=Le){O.scrollTop=A,t();return}T&&z(!0),O.scrollTo({top:A,behavior:S}),n()},[t,n,z]),G=a.useCallback(({behavior:R="auto"}={})=>K.current?(N(0),o.current=null,h.current="free-scrolling",L(0,{behavior:R}),r(),!0):!1,[r,L,N]),le=a.useCallback(({behavior:R="auto"}={})=>{let S=K.current;return S?(N(0),o.current=null,h.current=l.current?"following-bottom":"free-scrolling",L(Ar(S),{autoscrolling:!0,behavior:R}),r(),!0):!1},[r,L,N]),$=a.useCallback((R,{align:S="start",behavior:T="auto",scrollMargin:O=E.current}={},{keepPreviousPeek:A=!1}={})=>{let Z=u.current,te=K.current;if(!Z||!te||!Z.contains(R))return!1;let re=Nr({align:S,element:R,scrollMargin:A?O+v.current:O,spacer:U.current,viewport:te}),se=Er({content:Z,scrollTop:re,spacer:U.current,viewport:te});return N(se),w.current={element:R,viewportTop:Pe(R,te)},h.current=A?"anchored-to-message":"settling-jump",o.current=A?R:null,L(re,{behavior:T}),r(),!0},[r,L,N]),q=a.useCallback(()=>{let R=o.current;return!R||!R.isConnected||h.current!=="anchored-to-message"?!1:$(R,{align:"start"},{keepPreviousPeek:!0})},[$]),J=a.useCallback((R,S)=>{let T=y.current.get(R);return T?(d.current=!0,$(T,S)?(g.current=null,!0):(g.current={messageId:R,options:S},!0)):m.current===0?(g.current={messageId:R,options:S},d.current=!0,!0):!1},[$]);return{flushPendingScrollToMessage:a.useCallback(()=>{let R=g.current;if(!R)return!1;let S=y.current.get(R.messageId);return!S||!$(S,R.options)?!1:(g.current=null,d.current=!0,!0)},[$]),reanchorToAnchoredMessage:q,scrollToElement:$,scrollToEnd:le,scrollToMessage:J,scrollToStart:G}}function Pt(e,t){let n=e,r=new Set;return{getSnapshot:()=>n,hasListeners:()=>r.size>0,setSnapshot:o=>{t(n,o)||(n=o,r.forEach(l=>l()))},subscribe:(o,l,i)=>{let c=r.size===0;return r.add(o),c&&l?.(),()=>{r.delete(o),r.size===0&&i?.()}}}}function Or(e,t){return Pt(e,t)}function Pr(){return Pt($e,Lr)}function Mr(e,t){return e.start===t.start&&e.end===t.end}function Lr(e,t){return e.currentAnchorId!==t.currentAnchorId||e.visibleMessageIds.length!==t.visibleMessageIds.length?!1:e.visibleMessageIds.every((n,r)=>n===t.visibleMessageIds[r])}function $r({autoScroll:e,scrollEdgeThreshold:t,scrollMargin:n,scrollPreviousItemPeek:r}){let o=a.useRef(e),l=a.useRef(!1),i=a.useRef(null),c=a.useRef(!1),u=a.useRef(t),d=a.useRef(0),m=a.useRef(null),y=a.useRef(0),h=a.useRef(e?"following-bottom":"free-scrolling"),g=a.useRef(new Map),w=a.useRef(null),E=a.useRef(null),v=a.useRef(null),C=a.useRef(r),H=a.useRef(!0),U=a.useRef(null),K=a.useRef(n),z=a.useRef(null),N=a.useRef(0),L=a.useRef(0),G=a.useRef(null),le=a.useRef(null),$=a.useRef(null),q=a.useRef(null),J=a.useRef(null),R=a.useRef(null),S=a.useRef(null),T=a.useRef(null),O=a.useRef(new Set),A=a.useRef(new WeakSet);return $.current===null&&($.current=Or(kt,Mr)),T.current===null&&(T.current=Pr()),o.current=e,u.current=t,K.current=n,C.current=r,{autoScrollRef:o,autoscrollingRef:l,autoscrollingTimeoutRef:q,streamingTurnRef:v,contentRef:i,defaultScrollPositionAppliedRef:c,firstItemRef:m,itemCountRef:d,lastScrollTopRef:y,messageElementsRef:g,modeRef:h,pendingScrollFrameRef:z,pendingScrollToMessageRef:w,prependRestoreRef:E,preserveScrollOnPrependRef:H,rootRef:U,scrollEdgeThresholdRef:u,scrollMarginRef:K,scrollPreviousItemPeekRef:C,spacerGapRef:N,spacerHeightRef:L,spacerRef:G,stateFrameRef:le,stateStore:$.current,viewportRef:J,visibilityFrameRef:R,visibilityObserverRef:S,visibilityStore:T.current,visibleMessageIdsRef:O,handledScrollAnchorsRef:A}}function ft(e,t){return a.useCallback(n=>{e.current=n,n&&t()},[e,t])}function Dr({autoScroll:e=!1,defaultScrollPosition:t="end",scrollEdgeThreshold:n=mr,scrollPreviousItemPeek:r=hr,scrollMargin:o=gr}){let l=$r({autoScroll:e,scrollEdgeThreshold:n,scrollMargin:o,scrollPreviousItemPeek:r}),{streamingTurnRef:i,autoScrollRef:c,autoscrollingRef:u,autoscrollingTimeoutRef:d,contentRef:m,defaultScrollPositionAppliedRef:y,firstItemRef:h,itemCountRef:g,lastScrollTopRef:w,messageElementsRef:E,modeRef:v,pendingScrollFrameRef:C,pendingScrollToMessageRef:H,prependRestoreRef:U,preserveScrollOnPrependRef:K,rootRef:z,scrollEdgeThresholdRef:N,scrollMarginRef:L,scrollPreviousItemPeekRef:G,spacerGapRef:le,spacerHeightRef:$,spacerRef:q,stateFrameRef:J,stateStore:R,viewportRef:S,visibilityFrameRef:T,visibilityObserverRef:O,visibilityStore:A,visibleMessageIdsRef:Z,handledScrollAnchorsRef:te}=l,re=a.useRef(t);re.current!==t&&(re.current=t,y.current=!1);let se=a.useCallback(f=>{let p=z.current,b=S.current,k=[f.start&&"start",f.end&&"end"].filter(Boolean).join(" "),ee=u.current;for(let D of[p,b])D&&(k?D.setAttribute("data-scrollable",k):D.removeAttribute("data-scrollable"),D.toggleAttribute("data-autoscrolling",ee))},[]),ye=a.useCallback(f=>{let p=S.current?.scrollTop??0,b=p<w.current-Le;w.current=p,c.current&&!f.end&&v.current!=="settling-jump"&&v.current!=="anchored-to-message"?v.current="following-bottom":v.current==="following-bottom"&&f.end&&b&&!u.current&&(v.current="free-scrolling")},[]),Y=a.useCallback(()=>{let f=yr({content:m.current,scrollEdgeThreshold:N.current,spacer:q.current,viewport:S.current});ye(f);let p=v.current==="following-bottom"?{...f,end:!1}:f;se(p),R.setSnapshot(p)},[ye,R,se]),ae=a.useCallback(()=>{J.current===null&&(J.current=window.requestAnimationFrame(()=>{J.current=null,Y()}))},[Y]),F=a.useCallback(()=>{A.hasListeners()&&T.current===null&&(T.current=window.requestAnimationFrame(()=>{T.current=null,A.hasListeners()&&A.setSnapshot(Rr({content:m.current,scrollMargin:L.current,scrollPreviousItemPeek:G.current,spacer:q.current,viewport:S.current,visibleMessageIds:Z.current}))}))},[A]),{flushPendingScrollToMessage:I,reanchorToAnchoredMessage:M,scrollToElement:V,scrollToEnd:j,scrollToMessage:Q,scrollToStart:W}=_r({refs:l,commitScrollState:Y,scheduleStateCommit:ae,scheduleVisibilitySync:F}),B=a.useCallback(()=>{let f=U.current,p=S.current;if(!f||!p||!f.element.isConnected)return!1;let b=Pe(f.element,p)-f.viewportTop;return Math.abs(b)<=Le?!1:(p.scrollTop+=b,f.viewportTop=Pe(f.element,p),ae(),F(),!0)},[ae,F]),X=a.useCallback(()=>{let f=m.current,p=S.current;if(!f||!p){U.current=null;return}let b=jr({content:f,spacer:q.current,viewport:p});U.current=b?{element:b,viewportTop:Pe(b,p)}:null},[]),pe=a.useCallback(()=>{C.current===null&&(C.current=window.requestAnimationFrame(()=>{C.current=null,I()&&X()}))},[X,I]),ie=a.useCallback(()=>{if(!t||y.current||g.current===0)return!1;let f=!1;if(t==="last-anchor"){let p=m.current,b=S.current,k=p&&b?Tr(je(p,q.current)):null;if(!p||!b||!k)f=j({behavior:"auto"});else{let ee=_t(k,b);f=Xe({content:p,spacer:q.current,viewport:b})-ee<=b.clientHeight?j({behavior:"auto"}):V(k,{align:"start"},{keepPreviousPeek:!0})}}else f=t==="end"?j({behavior:"auto"}):W({behavior:"auto"});return f?(y.current=!0,!0):!1},[t,V,j,W]),Re=a.useCallback(()=>{let f=m.current;if(!f)return;let p=je(f,q.current),b=g.current,k=h.current;g.current=p.length,h.current=p[0]??null,(()=>{if(I())return;if(b===0){if(ie()||p.length>0&&c.current&&j({behavior:"auto"}))return;Y(),F();return}let ee=k?p.indexOf(k):-1;if(K.current&&ee>0){B();return}if(p.length>b){let D=wr(p,b);if(D){if(c.current&&v.current==="following-bottom"&&Cr(p,b)){j({behavior:"auto"});return}V(D,{align:"start"},{keepPreviousPeek:!0}),te.current.add(D);return}}if(p.length===b){let D=Sr(p,te.current);if(D){V(D,{align:"start"},{keepPreviousPeek:!0}),te.current.add(D);return}}v.current==="following-bottom"&&c.current?j({behavior:"auto"}):(Y(),F())})(),X()},[ie,X,Y,I,B,F,V,j]),we=a.useCallback(()=>{if(v.current==="following-bottom"&&c.current){j({behavior:"auto"});return}let f=$.current;if(M()){c.current&&f>0&&$.current===0&&j({behavior:"auto"});return}ae(),F()},[M,ae,F,j]),Se=a.useCallback(()=>{let f=S.current;if(!(!f||!A.hasListeners())){if(typeof IntersectionObserver>"u"){F();return}O.current||(O.current=new IntersectionObserver(p=>{for(let b of p){let k=b.target.dataset.messageId;k&&(b.isIntersecting?Z.current.add(k):Z.current.delete(k))}F()},{root:f,rootMargin:`${-(L.current+G.current)}px 0px 0px 0px`,threshold:[0,.01,.5,1]})),E.current.forEach(p=>{O.current?.observe(p)}),F()}},[F,A]),me=a.useCallback(()=>{T.current!==null&&(window.cancelAnimationFrame(T.current),T.current=null),O.current?.disconnect(),O.current=null,Z.current.clear(),A.setSnapshot($e)},[A]),Ce=a.useCallback((f,p,b)=>{if(p){E.current.set(f,p),O.current?.observe(p),F(),H.current?.messageId===f&&pe();return}b&&E.current.get(f)===b&&(E.current.delete(f),Z.current.delete(f),O.current?.unobserve(b),F())},[pe,F]),Ie=a.useCallback(()=>{(v.current==="following-bottom"||v.current==="anchored-to-message"||v.current==="settling-jump")&&(i.current=null,v.current="free-scrolling")},[]),ce=a.useCallback(()=>se(R.getSnapshot()),[R,se]),he=ft(z,ce),ue=ft(S,ce),ke=a.useCallback(f=>{m.current=f},[]),Te=a.useCallback(f=>{q.current=f,le.current=kr(f?.parentElement??null)},[]),_e=a.useCallback(()=>{Y(),F(),X()},[X,Y,F]),Oe=a.useMemo(()=>({handleContentChange:Re,handleResize:we,observeVisibility:Se,preserveScrollOnPrependRef:K,scrollToEnd:j,scrollToMessage:Q,scrollToStart:W,setContentElement:ke,setRootElement:he,setSpacerElement:Te,setViewportElement:ue,stateStore:R,syncAfterScroll:_e,unobserveVisibility:me,userScrollIntent:Ie,viewportRef:S,visibilityStore:A}),[Re,we,Se,j,Q,W,ke,he,Te,ue,R,_e,me,Ie,A]);return a.useLayoutEffect(()=>{ie()},[ie]),a.useEffect(()=>()=>{J.current!==null&&(window.cancelAnimationFrame(J.current),J.current=null),T.current!==null&&(window.cancelAnimationFrame(T.current),T.current=null),d.current!==null&&(window.clearTimeout(d.current),d.current=null),C.current!==null&&(window.cancelAnimationFrame(C.current),C.current=null),O.current?.disconnect(),O.current=null},[]),a.useLayoutEffect(()=>{if(e&&v.current==="following-bottom"&&g.current>0){j({behavior:"auto"});return}Y()},[e,Y,j]),{context:Oe,registerMessage:Ce}}function Ur(e){let t=a.useRef(e);return t.current=e,t}var Mt=a.createContext(null),Lt=a.createContext(null);function xe(){let e=a.useContext(Mt);if(!e)throw new Error("useMessageScroller must be used within a MessageScroller.");return e}function Fr(){let e=a.useContext(Lt);if(!e)throw new Error("MessageScrollerItem must be used within a MessageScroller.");return e}function $t(){let{scrollToEnd:e,scrollToMessage:t,scrollToStart:n}=xe();return a.useMemo(()=>({scrollToEnd:e,scrollToMessage:t,scrollToStart:n}),[e,t,n])}function Dt(){let{observeVisibility:e,unobserveVisibility:t,visibilityStore:n}=xe(),r=a.useCallback(o=>n.subscribe(o,e,t),[e,t,n]);return a.useSyncExternalStore(r,n.getSnapshot,n.getSnapshot)}function Vr({autoScroll:e=!1,children:t,defaultScrollPosition:n="end",scrollEdgeThreshold:r,scrollPreviousItemPeek:o,scrollMargin:l}){let{context:i,registerMessage:c}=Dr({autoScroll:e,defaultScrollPosition:n,scrollEdgeThreshold:r,scrollPreviousItemPeek:o,scrollMargin:l});return s.jsx(Mt.Provider,{value:i,children:s.jsx(Lt.Provider,{value:c,children:t})})}function Br({children:e,...t}){let{setRootElement:n}=xe();return s.jsx("div",{ref:n,...t,children:e})}function Hr({"aria-label":e,children:t,onKeyDown:n,onScroll:r,onTouchMove:o,onWheel:l,preserveScrollOnPrepend:i=!0,ref:c,role:u,tabIndex:d,...m}){let{handleResize:y,preserveScrollOnPrependRef:h,setViewportElement:g,syncAfterScroll:w,userScrollIntent:E,viewportRef:v}=xe();h.current=i;let C=a.useCallback(N=>{g(N),Ae(c)?.(N)},[c,g]);function H(N){w(),r?.(N)}function U(N){E(),l?.(N)}function K(N){E(),o?.(N)}function z(N){xr.has(N.key)&&E(),n?.(N)}return a.useEffect(()=>{let N=v.current;if(!N||typeof ResizeObserver>"u")return;let L=0,G=new ResizeObserver(()=>{window.cancelAnimationFrame(L),L=window.requestAnimationFrame(y)});return G.observe(N),()=>{window.cancelAnimationFrame(L),G.disconnect()}},[y,v]),s.jsx("div",{ref:C,role:u??"region","aria-label":e??"Messages",tabIndex:d??0,onKeyDown:z,onScroll:H,onTouchMove:K,onWheel:U,...m,children:t})}function zr({"aria-relevant":e,children:t,ref:n,role:r,spacerClassName:o,...l}){let{handleContentChange:i,handleResize:c,setContentElement:u,setSpacerElement:d}=xe(),m=a.useRef(null),y=a.useCallback(h=>{m.current=h,u(h),Ae(n)?.(h)},[n,u]);return a.useLayoutEffect(()=>{let h=m.current;if(!h||(i(),typeof MutationObserver>"u"))return;let g=new MutationObserver(()=>{i()});return g.observe(h,{childList:!0}),()=>g.disconnect()},[i]),a.useEffect(()=>{let h=m.current;if(!h||typeof ResizeObserver>"u")return;let g=0,w=new ResizeObserver(()=>{window.cancelAnimationFrame(g),g=window.requestAnimationFrame(c)});return w.observe(h),()=>{window.cancelAnimationFrame(g),w.disconnect()}},[c]),s.jsxs("div",{ref:y,role:r??"log","aria-relevant":e??"additions",...l,children:[t,s.jsx("div",{ref:d,"aria-hidden":"true","data-message-scroller-spacer":"",hidden:!0,className:o})]})}function Wr({messageId:e,ref:t,scrollAnchor:n=!1,...r}){let o=Fr(),l=a.useRef(null),i=a.useCallback(c=>{let u=l.current;l.current=c,e&&o(e,c,u),Ae(t)?.(c)},[e,t,o]);return s.jsx("div",{ref:i,"data-message-id":e,"data-scroll-anchor":n?"true":"false",...r})}function Kr({behavior:e="smooth",children:t,direction:n="end",onClick:r,render:o,tabIndex:l,type:i="button",...c}){let{scrollToEnd:u,scrollToStart:d,stateStore:m}=xe(),y=Ur(r),h=a.useCallback(v=>m.subscribe(v),[m]),g=a.useCallback(()=>{let v=m.getSnapshot();return n==="start"?v.start:v.end},[n,m]),w=a.useSyncExternalStore(h,g,g),E=a.useCallback(v=>{w&&(y.current?.(v),v.defaultPrevented||(v.currentTarget.blur(),n==="start"?d({behavior:e}):u({behavior:e})))},[e,n,w,y,u,d]);return ur({defaultTagName:"button",props:He({type:i,inert:!w,tabIndex:w?l:-1,children:t??s.jsxs("span",{children:["Scroll to ",n]}),onClick:E},c),render:o,state:{active:w,direction:n},stateAttributesMapping:{active:v=>({"data-active":v?"true":"false"})}})}var ve={Provider:Vr,Root:Br,Viewport:Hr,Content:zr,Item:Wr,Button:Kr};const qr=ve.Provider;function Gr({className:e,...t}){return s.jsx(ve.Root,{className:P("relative flex size-full min-h-0 flex-col overflow-hidden",e),...t})}function Jr({className:e,...t}){return s.jsx(ve.Viewport,{className:P("size-full min-h-0 overflow-y-auto overscroll-contain [scrollbar-gutter:stable]",e),...t})}function Yr({className:e,...t}){return s.jsx(ve.Content,{className:P("flex h-max min-h-full flex-col",e),...t})}function Qr({className:e,...t}){return s.jsx(ve.Item,{className:P("min-w-0 shrink-0",e),...t})}function Xr({className:e,...t}){return s.jsx(ve.Button,{direction:"end",behavior:"smooth",render:({active:n,...r})=>n?s.jsx(fe,{...r,type:"button",variant:"outline",size:"icon",className:P("absolute right-4 bottom-4 z-20 rounded-full bg-background ",e),"aria-label":"Scroll to latest message",children:s.jsx(nn,{})}):null,...t})}function Zr(e){if(!e)return"";const t=e.startsWith("?")?e.slice(1):e,n=new URLSearchParams(t);return n.get("message_id")?.trim()||n.get("message")?.trim()||""}function eo(e){const t=e.scrollTarget.trim();return t?e.alreadyScrolledTo===t?{scroll:!1}:e.messageIds.includes(t)?{scroll:!0,id:t}:{scroll:!1}:{scroll:!1}}const to="lobu-spa";function pt(e){return typeof e=="string"&&/^https?:\/\//i.test(e.trim())}function De(e,t){return t.type==="tool-call"?`tc-${t.toolCallId}`:t.type==="reasoning"?`${e.id}-reasoning`:t.type==="bash"?`${e.id}-bash-${t.command.slice(0,24)}`:t.type==="error"?`${e.id}-error`:`${e.id}-text-${t.text.slice(0,24)}`}const Vo=({afterMessagesContent:e,readOnly:t=!1,readerPositionMode:n="messages",interactionExtension:r,onRunSelect:o})=>{const{messages:l,agentId:i,conversationId:c}=Ee(),{data:u=[]}=rn(i,{conversationId:c});return s.jsx(Dn,{extension:r,children:s.jsxs("div",{"data-agent-thread":!0,className:"flex min-h-0 flex-1 flex-col",children:[s.jsx(no,{messages:l,trips:u,mode:n,afterMessagesContent:e,onRunSelect:o}),t?null:s.jsx("div",{className:Sn,children:s.jsx(ko,{})})]})})},no=({messages:e,trips:t,mode:n,afterMessagesContent:r,onRunSelect:o})=>s.jsx(qr,{autoScroll:!0,defaultScrollPosition:n==="runs"?"last-anchor":"end",scrollPreviousItemPeek:48,children:s.jsx(oo,{messages:e,trips:t,mode:n,afterMessagesContent:r,onRunSelect:o})});function ro(e){if(!e.startsWith("sep:"))return null;const t=Number(e.slice(4));return Number.isFinite(t)&&t>0?t:null}const oo=({messages:e,trips:t,mode:n,afterMessagesContent:r,onRunSelect:o})=>{const{currentAnchorId:l}=Dt(),{scrollToMessage:i}=$t(),c=a.useRef(null);a.useEffect(()=>{if(e.length===0||typeof window>"u")return;const d=eo({messageIds:e.map(m=>m.id),scrollTarget:Zr(window.location.search),alreadyScrolledTo:c.current});d.scroll&&(c.current=d.id,i(d.id,{align:"start",behavior:"smooth"}))},[e,i]);const u=d=>n==="runs"?d.id.startsWith("sep:"):d.role==="user";return s.jsxs(Gr,{children:[s.jsx(Jr,{"aria-label":n==="runs"?"Automation run history":"Conversation",children:s.jsxs(Yr,{className:P(qe,Cn),children:[e.map(d=>{const m=n==="runs"&&o?ro(d.id):null;return s.jsx(Qr,{messageId:d.id,scrollAnchor:u(d),"aria-current":d.id===l?"location":void 0,className:P("flex flex-col",n==="runs"&&u(d)&&"border-l-2 border-transparent pl-2 transition-colors",n==="runs"&&d.id===l&&"border-primary"),children:m!=null?s.jsx(vo,{message:d,onClick:()=>o?.(m)}):s.jsx(io,{message:d})},d.id)}),t.map(d=>s.jsx(lo,{trip:d},d.id)),s.jsx(ao,{}),r?s.jsx("div",{className:"mt-auto shrink-0 py-2",children:r}):null]})}),e.length>0?s.jsx(so,{messages:e,mode:n}):null,s.jsx(Xr,{})]})},so=({messages:e,mode:t})=>{const{scrollToMessage:n}=$t(),{currentAnchorId:r,visibleMessageIds:o}=Dt(),l=t==="runs"?e.flatMap(c=>c.parts).filter(c=>c.type==="tool-call"&&c.toolName==="tool-approval"&&c.args!==null&&typeof c.args=="object"&&c.args.status==="pending").length:0,i=e.flatMap(c=>{if(!(t==="runs"?c.id.startsWith("sep:"):c.role==="user"))return[];const d=c.parts.find(m=>m.type==="text");return[{id:c.id,label:d?.type==="text"?d.text:"Automation run"}]});return i.length===0?null:s.jsxs(cn,{children:[s.jsx(un,{asChild:!0,children:s.jsxs(fe,{type:"button",variant:"outline",size:"icon",className:P("absolute top-1/2 right-4 z-20 -translate-y-1/2 rounded-full bg-background/95 ",l>0&&"w-auto px-3"),"aria-label":l>0?`Open transcript outline, ${l} ${l===1?"approval":"approvals"} waiting`:"Open transcript outline",children:[s.jsx(dn,{}),l>0?s.jsxs("span",{className:"text-xs tabular-nums",children:[l," waiting"]}):null]})}),s.jsxs(fn,{side:"left",align:"center",className:"w-80 space-y-3 p-3",children:[s.jsxs("div",{className:"px-1",children:[s.jsx("p",{className:"text-sm font-medium",children:"Transcript outline"}),s.jsx("p",{className:"text-xs text-muted-foreground",children:t==="runs"?"Track and jump between Automation runs.":"Track and jump between your messages."})]}),s.jsx("div",{className:"max-h-80 space-y-1 overflow-y-auto",children:i.map(c=>{const u=c.id===r,d=o.includes(c.id);return s.jsxs(fe,{type:"button",variant:u?"secondary":"ghost",className:"h-auto w-full justify-start gap-2 px-2 py-2 text-left text-xs font-normal","aria-current":u?"location":void 0,onClick:()=>n(c.id,{align:"start",behavior:"smooth"}),children:[s.jsx("span",{className:P("size-1.5 shrink-0 rounded-full bg-muted-foreground/30",d&&"bg-primary/60",u&&"bg-primary")}),s.jsx("span",{className:"line-clamp-2",children:c.label})]},c.id)})})]})]})},lo=({trip:e})=>s.jsxs("div",{className:P(qe,"flex items-start gap-2 rounded-md border border-destructive/40 bg-destructive/10 px-3 py-2 text-sm text-destructive"),children:[s.jsx(an,{className:"mt-0.5 size-4 shrink-0"}),s.jsxs("div",{className:"min-w-0",children:[s.jsxs("div",{className:"font-medium",children:["Guardrail blocked: ",e.guardrailName," ",s.jsxs("span",{className:"font-normal opacity-70",children:["(",e.stage,")"]})]}),e.reason?s.jsx("div",{className:"mt-0.5 break-words opacity-80",children:e.reason}):null]})]}),ao=()=>{const{currentSuggestions:e,starters:t,messages:n,running:r,append:o}=Ee(),l=qn(e,t,n.length);return r||l.length===0?null:s.jsx(Nn,{prompts:l,className:P(qe,n.length===0&&"mt-auto"),onPick:i=>o(i)})},io=({message:e})=>e.role==="user"?s.jsx(co,{message:e}):e.role==="system"?s.jsx(yo,{message:e}):s.jsx(po,{message:e}),Ut=({attachment:e})=>s.jsx(Ln,{name:e.name,url:e.url,imageSrc:e.isImage?e.imageDataUrl??e.url:void 0}),co=({message:e})=>{const t=e.parts.filter(n=>n.type==="bash");return t.length>0?s.jsx("div",{className:xt,children:s.jsx("div",{className:"space-y-2",children:t.map(n=>s.jsx(uo,{part:n},De(e,n)))})}):s.jsx("div",{className:Tn,children:s.jsxs("div",{className:P(Ne,"px-3 py-2 text-sm"),children:[e.attachments&&e.attachments.length>0?s.jsx("div",{className:"mb-1.5 flex flex-wrap gap-1.5",children:e.attachments.map(n=>s.jsx(Ut,{attachment:n},n.id))}):null,e.parts.map(n=>n.type==="text"?s.jsx("div",{className:"whitespace-pre-wrap break-words",children:s.jsx(Qe,{text:n.text,renderText:r=>r})},De(e,n)):null)]})})},uo=({part:e})=>{const t=e.cancelled||e.exitCode!==void 0&&e.exitCode!==0;return s.jsxs("div",{className:P(Ne,"overflow-hidden text-xs"),children:[s.jsxs("div",{className:"flex items-center gap-1.5 border-border/60 border-b px-3 py-1.5",children:[s.jsx(pn,{className:"size-3.5 shrink-0 text-muted-foreground"}),s.jsx("code",{className:"min-w-0 flex-1 truncate font-mono text-foreground/90",children:e.command}),e.cancelled?s.jsx("span",{className:"rounded bg-muted px-1.5 py-0.5 font-medium text-[10px] text-muted-foreground",children:"cancelled"}):t?s.jsxs("span",{className:"rounded bg-destructive/15 px-1.5 py-0.5 font-medium text-[10px] text-destructive",children:["exit ",e.exitCode]}):null]}),e.output.trim()?s.jsx("pre",{className:"overflow-x-auto whitespace-pre-wrap break-words px-3 py-2 font-mono text-foreground/80",children:e.output}):null]})},Ft=new Set(["question","link-button","tool-approval"]),fo="subscription-candidate",po=({message:e})=>{const t=Ge(),{agentId:n,workspaceSlug:r}=Ee(),o=u=>u.type==="tool-call"&&(Ft.has(u.toolName)||t?.toolNames.has(u.toolName)),l=e.parts.filter(u=>u.type==="tool-call"&&!o(u)&&u.toolName!==fo),i=e.parts.filter(u=>u.type!=="tool-call"||o(u)),c=e.parts.flatMap(u=>{if(u.type!=="tool-call")return[];const d=Rt(u.result);return d?[d]:[]});return s.jsx("div",{className:xt,children:s.jsxs("div",{className:"space-y-2 text-sm",children:[l.length>0?s.jsx(go,{tools:l,workspaceSlug:r}):null,n&&r?c.map(u=>s.jsx(mo,{candidate:u,agentId:n,workspaceSlug:r},`${u.connector_key}:${u.resource_ref}`)):null,i.map(u=>s.jsx(xo,{part:u},De(e,u))),e.attachments&&e.attachments.length>0?s.jsx("div",{className:"flex flex-wrap gap-2",children:e.attachments.map(u=>s.jsx(Ut,{attachment:u},u.id))}):null]})})},mo=({candidate:e,agentId:t,workspaceSlug:n})=>s.jsxs("div",{className:P(Ne,"flex items-center justify-between gap-3 p-3"),children:[s.jsxs("div",{className:"min-w-0",children:[s.jsx("p",{className:"truncate text-sm font-medium",children:e.label}),s.jsx("p",{className:"text-xs text-muted-foreground",children:"Run this agent when the resource changes."})]}),s.jsx(fe,{asChild:!0,size:"sm",variant:"outline",className:"shrink-0",children:s.jsxs(gt,{to:"/$owner/automations/new",params:{owner:n},search:{agent:t,platform:e.connector_key,resource_type:e.resource_type,resource:e.resource_ref,events:e.suggested_event_keys?.join(","),label:e.label},children:[s.jsx(hn,{className:"mr-1.5 h-4 w-4"}),"Add automation"]})})]});function ho(e){try{return JSON.parse(e)}catch{return null}}function Vt(e){if(Array.isArray(e)){const o=e.flatMap(l=>l?.type==="text"&&typeof l.text=="string"?Vt(l.text)??[]:[]);return o.length>0?[...new Set(o)]:null}const t=typeof e=="string"&&e.trimStart().startsWith("{")?ho(e):e;if(!t||typeof t!="object")return null;const n=t.events_persisted;if(!Array.isArray(n))return null;const r=n.flatMap(o=>{const l=o&&typeof o=="object"?o.id:null;return typeof l=="number"&&Number.isSafeInteger(l)&&l>0?[l]:[]});return r.length>0?r:null}const go=({tools:e,workspaceSlug:t})=>s.jsxs(Nt,{defaultOpen:!1,children:[s.jsx(Et,{children:e.length===1?ot(e[0].args,e[0].toolName)??e[0].toolName:`${e.length} tool calls`}),s.jsx(It,{children:e.map(n=>{const r=ot(n.args,n.toolName),o=n.args!==void 0&&n.args!==null,l=n.result!==void 0&&n.result!==null,i=Vt(n.result);return s.jsxs(At,{icon:mn,label:s.jsxs("span",{className:"flex items-center gap-1.5",children:[s.jsx("span",{className:"font-medium",children:r??n.toolName}),r?s.jsx("span",{className:"text-muted-foreground",children:n.toolName}):null,n.isError?s.jsx("span",{className:"rounded bg-destructive/15 px-1.5 py-0.5 font-medium text-[10px] text-destructive",children:"error"}):null]}),status:n.isError?"active":"complete",children:[o?s.jsx("pre",{className:"overflow-x-auto whitespace-pre-wrap break-words text-foreground/80 text-xs",children:Fe(n.args)}):null,l?s.jsx("pre",{className:"overflow-x-auto whitespace-pre-wrap break-words text-foreground/80 text-xs",children:Fe(n.result)}):null,i&&t?s.jsx(cr,{ownerSlug:t,eventIds:i}):null]},n.toolCallId)})})]}),bo=({text:e})=>{let t=e,n=null;const r=e.match(/\{[\s\S]*\}/);if(r)try{const l=JSON.parse(r[0])?.error?.message;typeof l=="string"&&l.trim()&&(t=l,n=e)}catch{}return s.jsxs("div",{className:"flex gap-2 rounded-lg border border-destructive/30 bg-destructive/5 px-3 py-2.5 text-sm",children:[s.jsx(bn,{className:"mt-0.5 size-4 shrink-0 text-destructive"}),s.jsxs("div",{className:"min-w-0 flex-1 space-y-1",children:[s.jsx("p",{className:"text-foreground/80",children:t}),n&&s.jsxs("details",{className:"text-xs text-muted-foreground",children:[s.jsx("summary",{className:"cursor-pointer select-none hover:text-foreground",children:"Technical details"}),s.jsx("pre",{className:"mt-1 overflow-x-auto whitespace-pre-wrap break-all font-mono",children:n})]})]})]})},xo=({part:e})=>{const t=Ge();return e.type==="reasoning"?s.jsx(ar,{}):e.type==="error"?s.jsx(bo,{text:e.text}):e.type==="text"?e.text.trim()?s.jsx(Qe,{text:e.text,renderText:n=>s.jsx(gn,{text:n})}):null:e.type!=="tool-call"?null:Ft.has(e.toolName)||t?.toolNames.has(e.toolName)?s.jsx(Io,{toolName:e.toolName,args:e.args}):null},vo=({message:e,onClick:t})=>{const n=e.parts.find(r=>r.type==="text");return s.jsx("button",{type:"button",onClick:t,className:P(Ne,"block w-full cursor-pointer whitespace-pre-wrap break-words px-3 py-2 text-left text-xs text-muted-foreground transition-colors hover:bg-muted/50"),children:n?.type==="text"?n.text:"Automation run"})},yo=({message:e})=>s.jsx("div",{className:"self-stretch",children:s.jsx("div",{className:P(Ne,"px-3 py-2 text-xs text-muted-foreground"),children:e.parts.map(t=>t.type==="text"?s.jsx("div",{className:"whitespace-pre-wrap break-words",children:s.jsx(Qe,{text:t.text,renderText:n=>n})},De(e,t)):null)})}),Ro="/mcp-apps/interaction/index.html";function mt(e){return new Promise(t=>{e({onSettled:(n,r)=>t(!!r)})})}const wo=({src:e,title:t,renderPayload:n,onToolCall:r,onOpenLink:o})=>{const l=a.useRef(null),[i,c]=a.useState(48),u=a.useRef({renderPayload:n,onToolCall:r,onOpenLink:o});return u.current={renderPayload:n,onToolCall:r,onOpenLink:o},a.useEffect(()=>{const d=l.current;if(!d?.contentWindow)return;const m=new yn(null,{name:"Lobu",version:"1.0.0"},{openLinks:{},serverTools:{}},{hostContext:{theme:document.documentElement.classList.contains("dark")?"dark":"light",displayMode:"inline",platform:"web"}});m.addEventListener("sizechange",({height:g})=>{typeof g=="number"&&c(Math.max(32,Math.ceil(g)))}),m.oncalltool=async({name:g,arguments:w})=>{const E=await u.current.onToolCall(g,w??{});return{isError:E,content:[{type:"text",text:E?"Action failed.":"Action completed."}]}},m.onopenlink=async({url:g})=>({isError:await u.current.onOpenLink(g)}),m.addEventListener("initialized",()=>{(async()=>(await m.sendToolInput({arguments:{}}),await m.sendToolResult({content:[],structuredContent:{...u.current.renderPayload,version:1,source:to}})))()});const y=new Rn(d.contentWindow,d.contentWindow);m.connect(y).catch(g=>{console.error("[mcp-app-host] failed to initialize",g)});const h=new MutationObserver(()=>{m.setHostContext({theme:document.documentElement.classList.contains("dark")?"dark":"light",displayMode:"inline",platform:"web"})});return h.observe(document.documentElement,{attributes:!0,attributeFilter:["class"]}),()=>{h.disconnect(),y.close()}},[]),s.jsx("iframe",{ref:l,title:t,src:e,sandbox:"allow-scripts",style:{width:"100%",height:i,border:"none",display:"block"}})},So=new Set(["action"]),Co=["name","description","identity_md"];function oe(e){return e==null||e===""?"":typeof e=="string"?e:Fe(e)}function ht(e){return e===null?"(cleared)":e===void 0?"":typeof e=="string"?e===""?"":e:Fe(e)}function Ue(e){return e.length>0?e[0].toUpperCase()+e.slice(1):e}const Bt=new Set(["delete","disconnect","remove","remove_rule","reset","revoke"]);function We(e){return e&&Bt.has(e)?"warning":"default"}function Ke(e,t){return e&&Bt.has(e)?{level:"high",reason:t}:{level:"normal"}}function To(e,t){const n=e.attribution==="automation"?"An Automation":"An agent",r=Object.keys(t),o=r.map(l=>({label:l,before:oe(e.current?.[l]),after:oe(t[l])}));return{title:`${n} proposes a change`,icon:"entity",impact:{level:"normal"},tone:"default",blocks:o.length>0?[{type:"diff",fields:o}]:[{type:"text",value:"No field changes.",muted:!0}],actions:[{id:"approve",label:"Approve",variant:"primary",icon:"check",tool:"manage_operations",args:{action:"approve"},resolvedLabel:`Approved — ${r.join(", ")} is being applied.`},{id:"reject",label:"Reject",variant:"outline",icon:"x",confirm:!0,confirmPrompt:"Reject this change?",tool:"manage_operations",args:{action:"reject"},resolvedLabel:`Rejected — ${r.join(", ")} was not applied.`}]}}function jo(e){const t=e.action??"change",n=e.proposal?.slug??e.proposal?.name??(e.proposal?.automation_id!=null?String(e.proposal.automation_id):void 0)??e.current?.slug??e.current?.name??"automation",r=[];e.action==="delete"&&r.push({type:"text",value:"This will archive the Automation.",muted:!0});const o=e.proposal??{},l=Object.keys(o).filter(i=>!So.has(i)&&o[i]!==void 0).map(i=>({label:i,...e.action==="update"&&e.current?.[i]!==void 0?{before:ht(e.current?.[i])}:{},after:ht(o[i])}));return r.push(l.length>0?{type:"diff",fields:l}:{type:"text",value:"No field changes.",muted:!0}),{title:`${Ue(t)} Automation ${n}`,icon:"automation",impact:Ke(e.action,"This archives the Automation and stops future runs."),tone:We(e.action),blocks:r,actions:[{id:"approve",label:"Approve",variant:"primary",icon:"check",tool:"manage_operations",args:{action:"approve"},resolvedLabel:`Approved — ${t} ${n} is being applied.`},{id:"reject",label:"Reject",variant:"outline",icon:"x",confirm:!0,confirmPrompt:"Reject this change?",tool:"manage_operations",args:{action:"reject"},resolvedLabel:`Rejected — ${t} ${n} was not applied.`}]}}function No(e){if(e.resourceKind==="automation")return jo(e);if(e.fields&&Object.keys(e.fields).length>0)return To(e,e.fields);const t=e.resourceKind==="entity"||e.proposal?.entity_id!==void 0||e.current?.entity_type!==void 0||e.proposal?.entity_type!==void 0;if(t&&(e.action==="link"||e.action==="unlink"))return $n({...e,action:e.action});if(t){const l=e.proposal?.name??e.current?.name??e.proposal?.entity_id??e.current?.id??"entity",i=e.action??"change",c=[];if(e.action==="delete")c.push({type:"text",value:"This will delete the entity.",muted:!0});else{const u=Object.keys(e.proposal??{}).filter(d=>!["entity_id","id"].includes(d)&&e.proposal?.[d]!==void 0&&oe(e.proposal?.[d])!==oe(e.current?.[d])).map(d=>({label:d,...e.action==="update"?{before:oe(e.current?.[d])}:{},after:oe(e.proposal?.[d])}));c.push(u.length>0?{type:"diff",fields:u}:{type:"text",value:"No field changes.",muted:!0})}return{title:`${Ue(i)} entity ${l}`,icon:"entity",impact:Ke(e.action,"This deletes the entity."),tone:We(e.action),blocks:c,actions:[{id:"approve",label:"Approve",variant:"primary",icon:"check",tool:"manage_operations",args:{action:"approve"},resolvedLabel:`Approved — ${i} ${l} is being applied.`},{id:"reject",label:"Reject",variant:"outline",icon:"x",confirm:!0,confirmPrompt:"Reject this change?",tool:"manage_operations",args:{action:"reject"},resolvedLabel:`Rejected — ${i} ${l} was not applied.`}]}}const n=e.proposal?.agent_id??e.current?.id??"agent",r=e.action??"change",o=[];if(e.action==="delete")o.push({type:"text",value:"This will permanently delete the agent.",muted:!0});else{const l=Co.filter(i=>e.proposal?.[i]!==void 0&&oe(e.proposal?.[i])!==oe(e.current?.[i])).map(i=>({label:i,...e.action==="update"?{before:oe(e.current?.[i])}:{},after:oe(e.proposal?.[i])}));o.push(l.length>0?{type:"diff",fields:l}:{type:"text",value:"No field changes.",muted:!0})}return{title:`${Ue(r)} agent ${n}`,icon:"agent",impact:Ke(e.action,"This permanently deletes the agent and its configuration."),tone:We(e.action),blocks:o,actions:[{id:"approve",label:"Approve",variant:"primary",icon:"check",tool:"manage_operations",args:{action:"approve"},resolvedLabel:`Approved — ${r} ${n} is being applied.`},{id:"reject",label:"Reject",variant:"outline",icon:"x",confirm:!0,confirmPrompt:"Reject this change?",tool:"manage_operations",args:{action:"reject"},resolvedLabel:`Rejected — ${r} ${n} was not applied.`}]}}function Eo(e){const t=Array.isArray(e.options)?e.options.filter(o=>typeof o=="string"):[],n=[{type:"text",value:e.question||"The agent has a question."}];t.length===0&&n.push({type:"text",value:"Reply below to answer.",muted:!0});const r=t.map(o=>({id:o,label:o,variant:"outline",tool:"answer_question",args:{answer:o},resolvedLabel:`Answered: ${o}`}));return{title:"Input needed",icon:"question",tone:"default",blocks:n,actions:r}}function Ao(e,t){return{tone:"bare",actions:[{id:"open",label:e.label??"Open link",variant:"outline",icon:"external",terminal:!1,href:t}]}}const Io=({toolName:e,args:t})=>{const n=xn(),r=vn(),{append:o}=Ee(),l=Ge(),i=t??{},c=l?.resolve(e,t)??null;let u=c?.view??null;const d={...c?.handlers??{}},m=new Set;if(!c){if(e==="tool-approval"&&typeof i.runId=="number"&&Number.isSafeInteger(i.runId)&&i.runId>0){const y=i.runId,h=typeof i.status=="string"?i.status:"pending",g=h==="pending",w=No(i),E=h==="confirmed"?"Approved":Ue(h);u=g?w:{...w,title:`${w.title??"Approval"} · ${E}`,tone:h==="failed"?"warning":"default",blocks:[...w.blocks??[],{type:"text",value:typeof i.reviewedByName=="string"?`${h==="rejected"?"Rejected":"Approved"} by ${i.reviewedByName}.`:`${E}.`,muted:!0}],actions:(w.actions??[]).filter(v=>v.terminal===!1)},g&&(d.manage_operations=v=>{if(v.action==="approve")return mt(C=>n.mutate({run_id:y},C));if(v.action==="reject"){const C=typeof v.reason=="string"?v.reason:void 0;return mt(H=>r.mutate({run_id:y,...C?{reason:C}:{}},H))}return Promise.resolve(!0)})}else if(e==="question"){const y=Array.isArray(i.options)?i.options.filter(h=>typeof h=="string"):[];u=Eo(i),d.answer_question=h=>{const g=typeof h.answer=="string"?h.answer:"";return y.includes(g)?(o(g),Promise.resolve(!1)):Promise.resolve(!0)}}else if(e==="link-button"){if(!pt(i.url))return null;const y=i.url;m.add(y),u=Ao(i,y)}}return u?s.jsx(wo,{src:Ro,title:u.title??"Interaction",renderPayload:u,onToolCall:(y,h)=>d[y]?d[y](h):Promise.resolve(!0),onOpenLink:y=>!m.has(y)||!pt(y)?Promise.resolve(!0):(window.open(y,"_blank","noopener,noreferrer"),Promise.resolve(!1))}):null};function Fe(e){try{return JSON.stringify(e,null,2)}catch{return String(e)}}const ko=()=>{const{running:e,append:t,cancel:n,pendingAttachments:r,addAttachments:o,removeAttachment:l,initialDraft:i,currentSuggestions:c}=Ee(),u=_o({suggestions:e?null:c}),[d,m]=a.useState(i??""),y=a.useRef(null),h=a.useRef(null),g=_n(On),w=a.useRef(i??"");a.useEffect(()=>{const C=i??"";if(C===w.current)return;const H=w.current;w.current=C,C!==""&&m(U=>U===""||U===H?C:U)},[i]);const E=a.useRef(d);E.current=d;const v=()=>{e||(t(E.current),m(""),h.current?.clear())};return s.jsxs("div",{className:"rounded-2xl border bg-background transition-colors focus-within:ring-1 focus-within:ring-ring",children:[r.length>0?s.jsx("div",{className:"flex flex-wrap gap-1.5 px-3 pt-3",children:r.map(C=>s.jsxs("div",{className:"flex items-center gap-1.5 rounded-lg border bg-muted/50 px-2 py-1 text-xs",children:[s.jsx(rt,{className:"h-3 w-3 shrink-0 text-muted-foreground"}),s.jsx("span",{className:"max-w-[12rem] truncate",children:C.name}),s.jsx("button",{type:"button",className:"text-muted-foreground transition-colors hover:text-foreground","aria-label":"Remove attachment",onClick:()=>l(C.id),children:s.jsx(on,{className:"h-3 w-3"})})]},C.id))}):null,s.jsx(Pn,{value:d,onChange:m,onSubmit:v,searchRefs:g,handleRef:h,placeholder:u,className:"max-h-48 overflow-y-auto"}),s.jsxs("div",{className:"flex items-center justify-between px-3 pb-2",children:[s.jsx("input",{ref:y,type:"file",multiple:!0,className:"hidden",onChange:C=>{C.target.files&&o(C.target.files),C.target.value=""}}),s.jsxs(fe,{type:"button",size:"icon",variant:"ghost",className:"h-8 w-8 rounded-full text-muted-foreground hover:text-foreground",onClick:()=>y.current?.click(),children:[s.jsx(rt,{className:"h-4 w-4"}),s.jsx("span",{className:"sr-only",children:"Attach files"})]}),e?s.jsxs(fe,{type:"button",size:"icon",variant:"secondary",className:"h-8 w-8 rounded-full",onClick:n,children:[s.jsx(sn,{size:"lg"}),s.jsx("span",{className:"sr-only",children:"Cancel"})]}):s.jsxs(fe,{type:"button",size:"icon",className:"h-8 w-8 rounded-full",onClick:v,children:[s.jsx(ln,{className:"h-4 w-4"}),s.jsx("span",{className:"sr-only",children:"Send message"})]})]})]})};function _o({suggestions:e}){const t=e?.find(n=>n.message.trim().length>0)?.message;return t?`Recommended: ${t.trim()}`:"Chat… (@ to mention, / for commands)"}export{Vo as A,Fo as L,Uo as R,tr as h,Qn as s};
6
+ //# sourceMappingURL=agent-thread-v_lSSnJi.js.map
@@ -1,2 +1,2 @@
1
- import{r as c,ja as b,ba as w,aZ as y,bj as C,a_ as f,j as e,au as k,L as i,i5 as j,ib as A,B as N,ia as P,jo as B,j4 as v,dt as D,du as R,dv as $,A as I,a9 as L,gd as M,jp as _,aS as E}from"./index-BoqrvLHQ.js";import{C as O}from"./connector-page-shell-an3SYLim.js";function z({ownerSlug:s,appId:n}){const a=c.useMemo(()=>b(s,n,w()),[s,n]),{data:r=[],isLoading:l,isError:d,refetch:g}=y(),[m,x]=c.useMemo(()=>{const t=a?.devicePlatforms;if(!t?.length)return[[],[]];const h=r.filter(o=>{const u=C(o);return u!=null&&t.includes(u)});return[h.filter(o=>f(o,s)),h.filter(o=>!f(o,s))]},[a,r,s]);if(!a)return e.jsxs(k,{className:"space-y-3",children:[e.jsx("p",{className:"text-sm text-muted-foreground",children:"There is no app by that name."}),e.jsx(i,{to:"/$owner/connectors",params:{owner:s},search:{},className:"text-sm text-primary hover:underline",children:"Back to connectors"})]});const p=(a.devicePlatforms?.length??0)>0;return e.jsx("div",{className:"flex flex-1 flex-col",children:e.jsxs(O,{header:e.jsx(D,{breadcrumb:e.jsx(R,{crumbs:[e.jsx(i,{to:"/$owner/connectors",params:{owner:s},search:{},className:$,children:"Connectors"},"connectors")]}),icon:e.jsx("span",{className:"flex h-7 w-7 shrink-0 items-center justify-center rounded-md border text-muted-foreground",children:a.icon}),title:a.name,caption:a.description}),children:[e.jsx("div",{id:"setup",className:"scroll-mt-40",children:e.jsx(j,{title:m.length>0?n==="owletto-chrome"?"Connect another profile":"Connect another device":"Set up",children:e.jsx("div",{className:"space-y-3",children:a.steps.map(t=>e.jsx(T,{step:t},t.label))})})}),p?e.jsx(A,{entries:m.map(t=>({id:t.id,name:v(t),description:B(t,s),tone:t.online?null:"muted",link:P({to:"/$owner/connectors/device/$deviceId",params:{owner:s,deviceId:t.id}})})),isLoading:l,isError:d,onRetry:()=>void g(),action:e.jsx(N,{asChild:!0,variant:"outline",size:"sm",children:e.jsx("a",{href:"#setup",children:"Add connection"})})}):null,p&&!l&&!d&&x.length>0?e.jsxs(j,{title:"Your devices in other workspaces",children:[e.jsx("p",{className:"mb-3 text-xs text-muted-foreground",children:"Open a device to connect its capabilities here. Moving it is confirmed first and pauses its connections where it is now."}),e.jsx("ul",{className:"divide-y border-y",children:x.map(t=>e.jsx("li",{children:e.jsxs(i,{to:"/$owner/connectors/device/$deviceId",params:{owner:s,deviceId:t.id},className:"flex items-center justify-between gap-3 py-2.5 text-sm hover:text-primary",children:[e.jsx("span",{className:"font-medium",children:v(t)}),e.jsxs("span",{className:"text-xs text-muted-foreground",children:["Attached to"," ",t.organization_name??"another workspace"]})]})},t.id))})]}):null]})})}function T({step:s}){const[n,a]=c.useState(!1);if(s.href)return e.jsxs("a",{href:s.href,target:"_blank",rel:"noreferrer",className:"inline-flex items-center gap-1.5 rounded-md border px-2.5 py-1.5 text-xs font-medium text-primary hover:bg-accent/50",children:[s.label,e.jsx(I,{className:"h-3 w-3"})]});const r=s.command??"";return e.jsxs("div",{className:"space-y-1.5",children:[e.jsx("p",{className:"text-xs text-muted-foreground",children:s.label}),e.jsxs("div",{className:"flex items-start gap-2 rounded-lg border bg-muted/40 p-2.5",children:[e.jsx("pre",{className:"min-w-0 flex-1 overflow-x-auto font-mono text-xs leading-relaxed",children:r}),e.jsxs(N,{variant:"ghost",size:"sm",className:"h-6 shrink-0 px-1.5 text-xs",onClick:()=>{typeof navigator>"u"||!navigator.clipboard||navigator.clipboard.writeText(r).then(()=>{a(!0),setTimeout(()=>a(!1),1500)})},children:[n?e.jsx(L,{className:"h-3.5 w-3.5"}):e.jsx(M,{className:"h-3.5 w-3.5"}),e.jsx("span",{className:"sr-only",children:"Copy"})]})]})]})}function G(){const{owner:s,appId:n}=_.useParams();return e.jsx(E,{owner:s,children:({ownerSlug:a})=>e.jsx(z,{ownerSlug:a,appId:n})})}export{G as component};
2
- //# sourceMappingURL=app._appId-ByIypCL9.js.map
1
+ import{r as c,jx as g,bi as y,b5 as w,br as C,b6 as u,j as e,aD as k,L as o,is as j,iy as A,B as N,ix as P,jL as D,jr as v,dH as B,dI as R,dJ as I,A as L,aa as M,h4 as $,jM as _,a_ as E}from"./index-DB2lVKuV.js";import{C as O}from"./connector-page-shell-DZjKv9zQ.js";function z({ownerSlug:s,appId:a}){const n=c.useMemo(()=>g(s,a,y()),[s,a]),{data:r=[],isLoading:l,isError:d,refetch:b}=w(),[m,x]=c.useMemo(()=>{const t=n?.devicePlatforms;if(!t?.length)return[[],[]];const h=r.filter(i=>{const f=C(i);return f!=null&&t.includes(f)});return[h.filter(i=>u(i,s)),h.filter(i=>!u(i,s))]},[n,r,s]);if(!n)return e.jsxs(k,{className:"space-y-3",children:[e.jsx("p",{className:"text-sm text-muted-foreground",children:"There is no app by that name."}),e.jsx(o,{to:"/$owner/connectors",params:{owner:s},search:{},className:"text-sm text-primary hover:underline",children:"Back to connectors"})]});const p=(n.devicePlatforms?.length??0)>0;return e.jsx("div",{className:"flex flex-1 flex-col",children:e.jsxs(O,{header:e.jsx(B,{breadcrumb:e.jsx(R,{crumbs:[e.jsx(o,{to:"/$owner/connectors",params:{owner:s},search:{},className:I,children:"Connectors"},"connectors")]}),icon:e.jsx("span",{className:"flex h-7 w-7 shrink-0 items-center justify-center rounded-md border text-muted-foreground",children:n.icon}),title:n.name,caption:n.description}),children:[e.jsx("div",{id:"setup",className:"scroll-mt-40",children:e.jsx(j,{title:m.length>0?a==="owletto-chrome"?"Connect another profile":"Connect another device":"Set up",children:e.jsx("div",{className:"space-y-3",children:n.steps.map(t=>e.jsx(T,{step:t},t.label))})})}),p?e.jsx(A,{entries:m.map(t=>({id:t.id,name:v(t),description:D(t,s),tone:t.online?null:"muted",link:P({to:"/$owner/connectors/device/$deviceId",params:{owner:s,deviceId:t.id}})})),isLoading:l,isError:d,onRetry:()=>void b(),action:e.jsx(N,{asChild:!0,variant:"outline",size:"sm",children:e.jsx("a",{href:"#setup",children:"Add connection"})})}):null,p&&!l&&!d&&x.length>0?e.jsxs(j,{title:"Your devices in other workspaces",children:[e.jsx("p",{className:"mb-3 text-xs text-muted-foreground",children:"Open a device to connect its capabilities here. Moving it is confirmed first and pauses its connections where it is now."}),e.jsx("ul",{className:"divide-y border-y",children:x.map(t=>e.jsx("li",{children:e.jsxs(o,{to:"/$owner/connectors/device/$deviceId",params:{owner:s,deviceId:t.id},className:"flex items-center justify-between gap-3 py-2.5 text-sm hover:text-primary",children:[e.jsx("span",{className:"font-medium",children:v(t)}),e.jsxs("span",{className:"text-xs text-muted-foreground",children:["Attached to"," ",t.organization_name??"another workspace"]})]})},t.id))})]}):null]})})}function T({step:s}){const[a,n]=c.useState(!1);if(s.href)return e.jsxs("a",{href:s.href,target:"_blank",rel:"noreferrer",className:"inline-flex items-center gap-1.5 rounded-md border px-2.5 py-1.5 text-xs font-medium text-primary hover:bg-accent/50",children:[s.label,e.jsx(L,{className:"h-3 w-3"})]});const r=s.command??"";return e.jsxs("div",{className:"space-y-1.5",children:[e.jsx("p",{className:"text-xs text-muted-foreground",children:s.label}),e.jsxs("div",{className:"flex items-start gap-2 rounded-lg border bg-muted/40 p-2.5",children:[e.jsx("pre",{className:"min-w-0 flex-1 overflow-x-auto font-mono text-xs leading-relaxed",children:r}),e.jsxs(N,{variant:"ghost",size:"sm",className:"h-6 shrink-0 px-1.5 text-xs",onClick:()=>{typeof navigator>"u"||!navigator.clipboard||navigator.clipboard.writeText(r).then(()=>{n(!0),setTimeout(()=>n(!1),1500)})},children:[a?e.jsx(M,{className:"h-3.5 w-3.5"}):e.jsx($,{className:"h-3.5 w-3.5"}),e.jsx("span",{className:"sr-only",children:"Copy"})]})]})]})}function W(){const{owner:s,appId:a}=_.useParams();return e.jsx(E,{owner:s,children:({ownerSlug:n})=>e.jsx(z,{ownerSlug:n,appId:a})})}export{W as component};
2
+ //# sourceMappingURL=app._appId-CKWzZ2ic.js.map
@@ -0,0 +1,2 @@
1
+ import{c as k,t as b,r as o,k7 as v,j as e,L as f,B as P,k8 as S}from"./index-DB2lVKuV.js";import{u as y,b as M,f as R}from"./use-mention-search-BniE-K2d.js";import{P as C,s as I}from"./pending-seed-CTKYdA4X.js";import{n as A,c as E}from"./agent-thread-storage-Bx2-WBHQ.js";import"./index-Vcq4gwWv.js";import"./use-automations-DcdlmVuX.js";function $({ownerSlug:i,starters:m,preferredMentionKinds:u,onSent:x}){const g=k(),{data:N=[]}=b(),l=y(R),n=o.useMemo(()=>new Set(u??[]),[u]),j=o.useCallback(async d=>{const t=await l(d);return n.size===0?t:[...t].sort((a,w)=>Number(n.has(w.kind))-Number(n.has(a.kind)))},[n,l]),r=v(N),[s,h]=o.useState(""),p=o.useRef(s);p.current=s;const c=d=>{const t=d.trim();if(!t||!r)return;const a=A();I(a,t),h(""),g(E(i,r.agentId,a)),x?.()};return e.jsxs("div",{className:"rounded-lg border bg-background p-4 transition-colors focus-within:ring-1 focus-within:ring-ring",children:[r?e.jsx(M,{value:s,onChange:h,onSubmit:()=>c(p.current),searchRefs:j,placeholder:"Ask Lobu…",className:"[&_.ProseMirror]:max-h-40 [&_.ProseMirror]:min-h-24 [&_.ProseMirror]:overflow-y-auto"}):e.jsxs("p",{className:"text-sm text-muted-foreground",children:["Bring your"," ",e.jsx(f,{to:"/$owner/agents/connect",params:{owner:i},className:"text-foreground hover:underline",children:"agent"})," ","or"," ",e.jsx(f,{to:"/$owner/agents/new",params:{owner:i},search:{},className:"text-foreground hover:underline",children:"create a new agent"})," ","to get started."]}),e.jsxs("div",{className:"flex items-end justify-between gap-3 pt-2",children:[r&&m&&!s.trim()?e.jsx(C,{prompts:m,onPick:c}):e.jsx("span",{}),e.jsxs(P,{type:"button",size:"icon",className:"h-10 w-10 shrink-0 rounded-full",disabled:!r||!s.trim(),onClick:()=>c(s),children:[e.jsx(S,{className:"h-4 w-4"}),e.jsx("span",{className:"sr-only",children:"Send message"})]})]})]})}export{$ as AssistComposer};
2
+ //# sourceMappingURL=assist-composer-Q9ZJjAta.js.map
@@ -0,0 +1,2 @@
1
+ import{r as j,j as e,eF as W,eG as Q,eH as G,eI as M,P as A,eJ as U,eK as V,eL as k,B as C,aa as X,bH as P,L as D,ey as Z,dg as R,an as S,eM as O,eN as ee,aF as te,H as L,o as I,y as se,n as ne,cw as ae,eO as ie,cy as re,eP as oe,dT as le,K as ue,eQ as ce,eR as de,eS as me,eT as xe,eU as fe,z as ge,i as pe,u as he}from"./index-DB2lVKuV.js";import{E as je}from"./event-detail-CgG3pDLA.js";import{S as ye}from"./scoped-feed-bar-BTv9mPcR.js";import{C as Ne,A as ve}from"./create-automation-form-CTiy_S9G.js";import{P as be}from"./proposal-review-shell-EyGWEYwQ.js";import{E as _e}from"./events-feed-ClhEywwV.js";import{D as ke,A as Ae}from"./definition-comparison-C2mPfIMD.js";import{R as we}from"./runs-list-CJOFMgpk.js";import{a as K,b as Re}from"./use-automations-DcdlmVuX.js";const Ce=5,Se=5;function B({entries:t,onMarkRead:s,disabled:n=!1}){const i=t.filter(a=>a.unreadIds.length>0);return i.length===0?null:e.jsxs("button",{type:"button",disabled:n,className:"ml-auto inline-flex items-center gap-1 text-xs text-muted-foreground hover:text-foreground",onClick:()=>s(i.flatMap(a=>a.unreadIds)),children:[e.jsx(Q,{"aria-hidden":"true",className:"h-3.5 w-3.5"}),"Mark ",i.length," read"]})}function tt({owner:t,entries:s,pageIds:n,onMarkRead:i,markPending:a}){const[o,u]=j.useState(!1);if(s.length===0)return null;const r=o?s:s.slice(0,Se),l=s.length-r.length,d=x=>{const f=n.has(x.item.id)?"This page":H(x);return f?`Needs you · ${f}`:"Needs you"};return e.jsxs("ul",{"aria-label":"Needs you",className:"mb-4 divide-y overflow-hidden rounded-lg border",children:[s.length>1?e.jsxs("li",{className:"flex flex-wrap items-center gap-2 px-3 py-1.5",children:[e.jsxs("span",{className:"text-xs text-muted-foreground tabular-nums",children:[s.length," need you"]}),e.jsx(B,{entries:s,onMarkRead:i,disabled:a}),e.jsx(W,{owner:t,showMarkRead:!1})]}):null,e.jsx(q,{owner:t,entries:r,tag:d}),l>0?e.jsx("li",{children:e.jsxs("button",{type:"button",className:"w-full px-3 py-2 text-left text-xs text-muted-foreground hover:bg-muted/40 hover:text-foreground",onClick:()=>u(!0),children:["Show all ",s.length]})}):null]})}function Ee({owner:t,entries:s}){return s.length===0?null:e.jsx("ul",{className:"divide-y overflow-hidden rounded-lg border",children:e.jsx(q,{owner:t,entries:s,tag:H})})}const H=t=>t.repeats>1?`${t.repeats}×`:void 0;function q({owner:t,entries:s,tag:n}){return G(s).map(i=>e.jsx("li",{children:i.entries.length>1?e.jsx(Pe,{owner:t,group:i}):e.jsx(M,{owner:t,item:i.entries[0].item,variant:"row",tag:n(i.entries[0])})},i.key))}function Pe({owner:t,group:s}){const[n,i]=j.useState(!1),{orgContext:a}=A(),o=U(),u=V(a),{entries:r}=s,l=r[0],d=r[r.length-1],x=new Set(r.map(({card:g})=>g.run_id)).size,f=n?r:r.slice(0,Ce),c=r.length-f.length,p=r.flatMap(({item:g})=>g.approvalRunId!=null?[g.approvalRunId]:[]),y=o.isPending||u.isPending,N=l.card.automation_name?.trim(),m=l.card.at===d.card.at?k(l.card.at):`${k(d.card.at)} – ${k(l.card.at)}`,h=async()=>{const g=await o.mutateAsync({decision:"approve",runIds:p}),J=new Set(g.failedRunIds),E=r.flatMap(({item:_})=>_.approvalRunId!=null&&!J.has(_.approvalRunId)&&_.notificationId!=null?[_.notificationId]:[]);E.length>0&&await u.mutateAsync(E),g.failed>0?P.error(`${g.succeeded} approved; ${g.failed} failed.`):P.success(`${g.succeeded} approved.`)};return e.jsxs("section",{"aria-label":`${r.length} approvals`,className:"min-w-0",children:[e.jsxs("div",{className:"flex flex-wrap items-baseline gap-x-2 gap-y-0.5 px-3 pt-2.5 pb-1.5",children:[e.jsxs("h3",{className:"text-sm font-medium",children:[r.length," approvals waiting"]}),e.jsxs("p",{className:"text-xs text-muted-foreground",children:["Proposed by ",N??"this Automation"," ·"," ",x===1?"1 run":`${x} runs`," · ",m]})]}),e.jsx("ul",{className:"divide-y border-t",children:f.map(g=>e.jsx("li",{children:e.jsx(M,{owner:t,item:g.item,variant:"row",showMark:!1})},g.item.id))}),e.jsxs("div",{className:"flex flex-wrap items-center gap-2 border-t px-3 py-2 text-xs",children:[c>0?e.jsxs("button",{type:"button",className:"text-muted-foreground hover:text-foreground",onClick:()=>i(!0),children:[c," more · Review all"]}):null,p.length>1?e.jsxs(C,{type:"button",size:"sm",className:"ml-auto h-7 text-xs",disabled:y,onClick:()=>void h(),children:[e.jsx(X,{className:"mr-1 h-3 w-3"}),"Approve all ",p.length]}):null]})]})}function F({automationId:t}){const{currentOwner:s}=A();return s?e.jsx(D,{to:"/$owner/events",params:{owner:s},search:Z({semanticTypes:["change"],eventCategory:"config",resourceKind:"automation",resourceId:t}),className:"text-sm text-primary underline underline-offset-4",children:"View definition history in Events"}):null}const Oe={workspace:!0},Fe=6,$e=["name","title"],$=10;function v(t){return t==null?!1:typeof t=="string"?t.trim().length>0:Array.isArray(t)?t.some(v):typeof t=="object"?Object.values(t).some(v):!0}function Te(t){const s=t.split("_").join(" ").trim();return s.charAt(0).toUpperCase()+s.slice(1)}function b({value:t,depth:s=0}){if(!v(t))return null;if(typeof t!="object"||t==null)return e.jsx("span",{className:"break-words",children:String(t)});if(s>=Fe)return e.jsx("span",{className:"break-words text-muted-foreground",children:JSON.stringify(t).slice(0,200)});if(Array.isArray(t))return e.jsx("ul",{className:"space-y-1.5",children:t.filter(v).map((o,u)=>e.jsx("li",{className:"border-l-2 border-border pl-2",children:e.jsx(b,{value:o,depth:s+1})},u))});const n=t,i=$e.find(o=>typeof n[o]=="string"&&v(n[o])),a=Object.entries(n).filter(([o,u])=>o!==i&&v(u));return e.jsxs("div",{className:"space-y-1",children:[i?e.jsx("p",{className:"font-medium text-foreground",children:String(n[i])}):null,a.length>0?e.jsx("dl",{className:"space-y-1",children:a.map(([o,u])=>e.jsxs("div",{children:[e.jsxs("dt",{className:"inline text-muted-foreground",children:[Te(o),":"," "]}),e.jsx("dd",{className:"inline",children:typeof u=="object"?e.jsx("div",{className:"mt-1",children:e.jsx(b,{value:u,depth:s+1})}):e.jsx(b,{value:u,depth:s+1})})]},o))}):null]})}function T({run:t}){const s=t.completed_at??t.created_at;return e.jsx("time",{dateTime:new Date(s).toISOString(),title:ee(s),className:"text-xs text-muted-foreground",children:k(s)})}function w({rows:t}){return t.length===0?null:e.jsx("ul",{className:"divide-y overflow-hidden rounded-lg border",children:t.map(s=>e.jsx("li",{children:s.content},s.key))})}function Me({owner:t,automationId:s,failedRows:n}){const i=j.useId(),a=R(Oe,{runTypes:["automation"],automationIds:[s],status:"completed"},t),o=a.data?.pages.flatMap(m=>m.runs)??[],u=o.filter(m=>v(m.output)),r=o.length-u.length,[l,...d]=u,x=a.data?.pages.length??0,{hasNextPage:f,isFetching:c,fetchNextPage:p}=a;j.useEffect(()=>{!l&&f&&!c&&x<$&&p()},[l,f,c,x,p]);const y=a.hasNextPage?e.jsx("div",{className:"flex justify-center",children:a.isFetchingNextPage?e.jsx(S,{role:"status","aria-label":"Loading earlier runs",className:"text-muted-foreground"}):e.jsx(C,{variant:"link",size:"sm",className:"h-auto p-0 text-xs font-normal text-muted-foreground",disabled:a.isFetching,onClick:()=>void a.fetchNextPage(),children:"Show earlier runs"})}):null,N=l?[...d.map(m=>({key:String(m.id),occurredAt:m.completed_at??m.created_at,content:e.jsxs("div",{className:"space-y-1 px-3 py-2 text-xs",children:[e.jsx(T,{run:m}),e.jsx(b,{value:m.output})]})})),...n].sort((m,h)=>(O(h.occurredAt)??0)-(O(m.occurredAt)??0)):[];return a.isError?e.jsxs("div",{className:"space-y-6 py-6",children:[e.jsx("p",{role:"alert",className:"text-sm text-muted-foreground",children:"Couldn't load this Automation's runs."}),e.jsx(w,{rows:n})]}):a.isLoading||!l&&f&&x<$?null:l?e.jsxs("div",{className:"space-y-6",children:[e.jsxs("section",{"aria-label":"Latest result",className:"space-y-2",children:[e.jsxs("div",{className:"flex items-baseline gap-2",children:[e.jsx("h2",{className:"text-xs font-medium uppercase tracking-wide text-muted-foreground",children:"Latest result"}),e.jsx(T,{run:l})]}),e.jsx("div",{className:"text-sm",children:e.jsx(b,{value:l.output})})]}),N.length>0?e.jsxs("section",{"aria-labelledby":i,className:"space-y-2",children:[e.jsx("h2",{id:i,className:"text-xs font-medium uppercase tracking-wide text-muted-foreground",children:"Earlier results"}),e.jsx(w,{rows:N})]}):null,r>0?e.jsxs("p",{className:"text-xs text-muted-foreground",children:[r," other ",r===1?"run":"runs"," found nothing new."]}):null,y]}):e.jsxs("div",{className:"space-y-6 py-6",children:[e.jsx("p",{className:"text-sm text-muted-foreground",children:o.length===0?"This Automation hasn't run yet. Its results appear here, newest first.":`It ran ${o.length}${a.hasNextPage?"+":""} times without returning a result.`}),e.jsx(w,{rows:n}),y]})}function Y(t){const{orgContext:s,hasOrgContext:n}=A(),{data:i,isLoading:a}=te(`/${t}`,s),{isAuthenticated:o}=L(),{isMember:u,isLoading:r}=I(),l=o&&u,d=i?.workspace,x=l?!n||a||r:a||r;return{organizationId:d?.id??"",isLoading:x}}function st(t){return Y(t)}const De={workspace:!0};function z(t,s,n=!0){const i=n?De:null,a=R(i,{runTypes:["automation"],automationIds:[s],status:"failed"},t),o=R(i,{runTypes:["automation"],automationIds:[s],status:"timeout"},t);return j.useMemo(()=>[...a.data?.pages[0]?.runs??[],...o.data?.pages[0]?.runs??[]].sort((u,r)=>Date.parse(r.created_at)-Date.parse(u.created_at)||r.id-u.id),[a.data,o.data])}function Le(t,s){const n=ae(t),{decisions:i,notices:a}=j.useMemo(()=>{const r=n.attentionCards.filter(l=>l.automation_id===s);return{decisions:re(r),notices:r.filter(l=>!ie(l)&&l.unread&&l.notification_id!=null)}},[n.attentionCards,s]);return{attention:n,decisions:i,notices:a,markRead:r=>{r.length>0&&n.markManyRead.mutateAsync(r)},unreadFor:r=>a.flatMap(l=>l.run_id!=null&&l.run_id===r.run_id||oe(l.href?.split(/[?#]/)[0]??"")?.eventId===Number(r.id)?[l.notification_id]:[])}}function Ie({owner:t,automationId:s,organizationId:n}){const i=Number(s),a=j.useMemo(()=>({producedByAutomationId:i}),[i]),{attention:o,decisions:u,notices:r,markRead:l,unreadFor:d}=Le(t,i),x=z(t,i);if(!Number.isFinite(i))return null;const f=x.map(c=>({key:`run:${c.id}`,occurredAt:c.completed_at??c.created_at,content:e.jsx(we,{run:c,ownerSlug:t})}));return e.jsxs(e.Fragment,{children:[o.isError?e.jsx("p",{role:"alert",className:"mb-6 text-sm text-destructive",children:"Could not load notifications. Refresh to try again."}):u.length>0?e.jsxs("section",{"aria-label":"Needs you",className:"mb-6 space-y-2",children:[e.jsx("h2",{className:"px-1 text-sm font-semibold",children:"Needs you"}),e.jsx(Ee,{owner:t,entries:u})]}):null,e.jsxs("div",{className:"mb-3 flex items-center gap-2",children:[e.jsx(ye,{owner:t,organizationId:n||null,activitySearch:{produced_by:String(i)}}),e.jsx(B,{entries:r.map(c=>({unreadIds:[c.notification_id]})),disabled:o.markManyRead.isPending,onMarkRead:l})]}),e.jsx(_e,{organizationId:n,ownerSlug:t,filters:a,foldRunSatellites:!1,unreadNotices:d,onMarkRead:l,extraRows:f,renderLead:(c,{hasEarlier:p})=>e.jsxs("div",{className:"mb-4 space-y-6",children:[e.jsxs("section",{"aria-label":"Latest result",className:"space-y-2",children:[e.jsx("h2",{className:"text-xs font-medium uppercase tracking-wide text-muted-foreground",children:"Latest result"}),e.jsx(je,{owner:t,organizationId:n,eventId:c.id})]}),p?e.jsx("h2",{className:"text-xs font-medium uppercase tracking-wide text-muted-foreground",children:"Earlier results"}):null]}),emptyState:e.jsx(Me,{owner:t,automationId:i,failedRows:f})})]})}function Ke({agentId:t,automationId:s,runId:n,organizationId:i,onDone:a}){const[o,u]=j.useState({ready:!1,triggers:[]}),r=j.useCallback(m=>{u(h=>JSON.stringify(h)===JSON.stringify(m)?h:m)},[]),l=K(s,void 0,i,{includeVersions:!0}),d=l.data?.automation,{currentOwner:x}=A(),f=se({queryKey:["automations-list",x,"editor",s,d?.status],enabled:!!x&&!!i&&!!d,queryFn:async()=>{const h=(await le("manage_automations",{action:"list",automation_id:s,status:d?.status,include_details:!0,limit:1},{slug:x})).automations.find(g=>g.automation_id===s);if(!h)throw new ue("Automation not found",404);return h},staleTime:3e4}),c=f.data,p=j.useMemo(()=>d&&c?{automation_id:d.automation_id,name:c.name,slug:c.slug,description:c.description,prompt:c.prompt,sources:c.sources,reaction_script:d.reaction_script,managed_agent_id:c.managed_agent_id,device_worker_id:c.device_worker_id,agent_kind:c.agent_kind,delivery_target:c.delivery_target??void 0,execution_config:c.execution_config??void 0,model_config:c.model_config,tags:c.tags,keying_config:d.keying_config,reactions_guidance:c.reactions_guidance,triggers:c.triggers}:void 0,[d,c]),y=e.jsx("div",{className:"flex flex-col gap-4",children:[0,1,2].map(m=>e.jsx(ne,{className:"h-16 w-full rounded-lg"},m))}),N=f.isError?e.jsxs("div",{role:"alert",className:"space-y-2 text-sm",children:[e.jsx("p",{children:"Could not load the saved Automation definition."}),e.jsx("button",{type:"button",className:"text-primary underline underline-offset-4",onClick:()=>void f.refetch(),children:"Retry"})]}):l.isLoading||d&&f.isPending?y:p?e.jsx(Ne,{organizationId:i,prefillAgentId:t??void 0,editingAutomation:p,createFields:{triggers:o.triggers},triggerFields:e.jsx(ve,{organizationId:i,initialTriggers:p.triggers??[],onChange:r},JSON.stringify(p.triggers??[])),hideHeader:!0,hideCancel:!0,submitDisabled:!o.ready,onClose:a}):e.jsx("p",{className:"text-sm text-muted-foreground",children:"Automation not found. It may have been removed."});return t?e.jsxs("div",{className:"space-y-6",children:[e.jsx(be,{resource:{kind:"automation",agentId:t,automationId:s},runId:n,onDone:a,children:({reviewMode:m,proposal:h})=>m==="active"?e.jsx(ke,{current:h?.current??null,proposed:{...h?.current??{},...h?.proposedAfter??{}},render:g=>e.jsx(Ae,{value:g})}):m==="loading"?y:m==="error"?null:N}),e.jsx(F,{automationId:s})]}):e.jsxs("div",{className:"space-y-6",children:[N,e.jsx(F,{automationId:s})]})}function nt({owner:t,agentId:s,automationId:n,view:i,runId:a,onDone:o}){const{organizationId:u}=Y(t),r=K(n,void 0,u),l=s??r.data?.automation?.managed_agent_id??null;return a||i==="definition"?e.jsx(Ke,{agentId:l,automationId:n,runId:a,organizationId:u,onDone:o},`${t}/${n}`):e.jsx(Ie,{owner:t,automationId:n,organizationId:u})}function at(t,s,n,i=!0){const{isAuthenticated:a}=L(),{isMember:o}=I(),u=Re(),r=i&&a&&o&&n?.status==="active",l=r&&n?.schedule_auto_paused_at!=null,d=Number(s),[x]=z(t,d,l&&Number.isFinite(d));return{owner:t,automationId:s,canRun:r,paused:l,pending:u.isPending,run:()=>u.mutate(s),failures:n?.consecutive_scheduled_failures??0,scheduled:n?.triggers?.some(f=>f.kind==="schedule")??!1,external:["external","manual"].includes(ce(n)),error:(x?.error_message??n?.last_scheduling_error)?.trim()||null,result:r?u.data:void 0}}function it({runNow:t}){return e.jsxs(e.Fragment,{children:[t.paused?e.jsx(He,{failures:t.failures,error:t.error,scheduled:t.scheduled,external:t.external,action:e.jsx(Be,{variant:"default",pending:t.pending,onRun:t.run})}):null,t.result?e.jsx(ze,{owner:t.owner,automationId:t.automationId,result:t.result},t.result.run_id):null]})}function Be({pending:t,onRun:s,variant:n="ghost"}){return e.jsxs(C,{type:"button",variant:n,size:"sm",className:"h-8 gap-1.5",disabled:t,onClick:s,children:[t?e.jsx(S,{}):e.jsx(de,{className:"h-3.5 w-3.5","aria-hidden":!0}),t?"Starting...":"Run now"]})}function He({failures:t,error:s,scheduled:n,external:i,action:a}){const o=i?`Run now resumes it right away${n?" and restarts its schedule":""}.`:"Run now retries it, and a successful run resumes it.";return e.jsxs("section",{"aria-label":"Automation paused",className:"flex flex-wrap items-start gap-3 rounded-lg bg-amber-500/10 px-3 py-2.5 text-sm",children:[e.jsx(me,{"aria-hidden":!0,className:"mt-0.5 h-4 w-4 shrink-0 text-amber-600 dark:text-amber-400"}),e.jsxs("div",{className:"min-w-0 flex-1 space-y-1",children:[e.jsxs("p",{className:"font-medium",children:["Automation paused after"," ",t===1?"a failed run":`${t} consecutive failed runs`]}),s?e.jsxs("p",{title:s,className:"line-clamp-3 whitespace-pre-wrap break-words text-muted-foreground",children:["Latest error: ",s]}):null,e.jsxs("p",{className:"text-muted-foreground",children:[o,n?" Changing its schedule also resumes it.":null]})]}),a]})}function qe({owner:t,automationId:s,runId:n}){const i=he();return e.jsxs(D,{to:"/$owner/events",params:{owner:t},search:{run_ids:String(n)},className:"font-medium text-foreground underline-offset-4 hover:underline",onClick:a=>{!i||a.button!==0||a.metaKey||a.ctrlKey||a.shiftKey||a.altKey||(a.preventDefault(),i.open({href:`/${t}/automations/${s}?view=activity&run_id=${n}`,title:`Run #${n}`,runId:n}))},children:["Run #",n]})}function Ye(t,s){return t==="running"||t==="claimed"?"is running":t==="pending"?s==="external_client"?"is waiting for a connected client to pick it up":s==="device_worker"?"is waiting for its device":"is queued":t==="completed"?"completed":t==="timeout"?"timed out":t==="cancelled"?"was cancelled":t}function ze({owner:t,automationId:s,result:n}){const i=xe(t,n.run_id),a=i.data?.status??n.status,o=fe(a),u=ge(),r=j.useRef(!1);j.useEffect(()=>{if(o){r.current=!0;return}if(r.current){r.current=!1;for(const x of["automation-detail","automations-list","runs-infinite"])u.invalidateQueries({queryKey:[x]})}},[o,u]);const l=o?null:i.data?.error_message?.trim(),d=a==="failed"||a==="timeout"||a==="cancelled";return e.jsxs("p",{role:"status",className:pe("flex items-center gap-1.5 text-sm",d?"text-destructive":"text-muted-foreground"),children:[o&&!i.isError?e.jsx(S,{className:"shrink-0"}):null,e.jsxs("span",{className:"min-w-0 break-words",children:[!n.created&&o?"Already in progress: ":null,e.jsx(qe,{owner:t,automationId:s,runId:n.run_id})," ",Ye(a,n.execution.lane),l?`: ${l}`:"."]})]})}export{nt as A,tt as N,Be as R,it as a,st as b,at as u};
2
+ //# sourceMappingURL=automation-run-now-Dl0MKx3N.js.map
@@ -1,2 +1,2 @@
1
- import{c as a,H as i,r as n,j as t}from"./index-BoqrvLHQ.js";function r(){const s=a(),{isReady:e}=i();return n.useEffect(()=>{e&&setTimeout(()=>{s({to:"/"})},500)},[e,s]),t.jsx("div",{className:"min-h-[calc(100vh-3.5rem)] flex items-center justify-center",children:t.jsx("div",{className:"text-center",children:t.jsx("p",{className:"text-muted-foreground",children:e?"Redirecting...":"Completing sign in..."})})})}export{r as component};
2
- //# sourceMappingURL=callback-Pz5uS-k7.js.map
1
+ import{c as a,H as i,r as n,j as t}from"./index-DB2lVKuV.js";function r(){const s=a(),{isReady:e}=i();return n.useEffect(()=>{e&&setTimeout(()=>{s({to:"/"})},500)},[e,s]),t.jsx("div",{className:"min-h-[calc(100vh-3.5rem)] flex items-center justify-center",children:t.jsx("div",{className:"text-center",children:t.jsx("p",{className:"text-muted-foreground",children:e?"Redirecting...":"Completing sign in..."})})})}export{r as component};
2
+ //# sourceMappingURL=callback-Bentv78L.js.map
@@ -1,2 +1,2 @@
1
- import{j as r,bJ as d}from"./index-BoqrvLHQ.js";function n({className:a,...t}){return r.jsx("div",{"data-slot":"card",className:`bg-card text-card-foreground flex flex-col gap-6 rounded-2xl border py-6 ${a||""}`,...t})}function i({className:a,...t}){return r.jsx("div",{"data-slot":"card-header",className:`grid auto-rows-min grid-rows-[auto_auto] items-start gap-1.5 px-6 has-data-[slot=card-action]:grid-cols-[1fr_auto] ${a||""}`,...t})}function c({className:a,asChild:t=!1,...s}){const o=t?d:"div";return r.jsx(o,{"data-slot":"card-title",className:`leading-none font-semibold ${a||""}`,...s})}function l({className:a,...t}){return r.jsx("div",{"data-slot":"card-description",className:`mt-1 first:mt-0 text-muted-foreground text-sm ${a||""}`,...t})}function u({className:a,...t}){return r.jsx("div",{"data-slot":"card-content",className:`px-6 ${a||""}`,...t})}export{n as C,i as a,c as b,u as c,l as d};
2
- //# sourceMappingURL=card-CAPpY9P5.js.map
1
+ import{j as r,bS as d}from"./index-DB2lVKuV.js";function n({className:a,...t}){return r.jsx("div",{"data-slot":"card",className:`bg-card text-card-foreground flex flex-col gap-6 rounded-2xl border py-6 ${a||""}`,...t})}function i({className:a,...t}){return r.jsx("div",{"data-slot":"card-header",className:`grid auto-rows-min grid-rows-[auto_auto] items-start gap-1.5 px-6 has-data-[slot=card-action]:grid-cols-[1fr_auto] ${a||""}`,...t})}function c({className:a,asChild:t=!1,...s}){const o=t?d:"div";return r.jsx(o,{"data-slot":"card-title",className:`leading-none font-semibold ${a||""}`,...s})}function l({className:a,...t}){return r.jsx("div",{"data-slot":"card-description",className:`mt-1 first:mt-0 text-muted-foreground text-sm ${a||""}`,...t})}function u({className:a,...t}){return r.jsx("div",{"data-slot":"card-content",className:`px-6 ${a||""}`,...t})}export{n as C,i as a,c as b,u as c,l as d};
2
+ //# sourceMappingURL=card-C4oPCVh6.js.map
@@ -1,2 +1,2 @@
1
- import{V as e,j as c,W as r}from"./index-BoqrvLHQ.js";function n(){const{team:a}=e({from:"/slack/claim"});return c.jsx(r,{to:"/connector/$name/connection",params:{name:"slack"},search:{ref:a},replace:!0})}export{n as component};
2
- //# sourceMappingURL=claim-DgWWK0KI.js.map
1
+ import{W as e,j as c,Y as r}from"./index-DB2lVKuV.js";function n(){const{team:a}=e({from:"/slack/claim"});return c.jsx(r,{to:"/connector/$name/connection",params:{name:"slack"},search:{ref:a},replace:!0})}export{n as component};
2
+ //# sourceMappingURL=claim-B3C4qIi2.js.map
@@ -0,0 +1,2 @@
1
+ import{H as m,y,ah as f,a5 as I,dV as v}from"./index-DB2lVKuV.js";function w(t){const{session:o,isReady:u}=m(),c=u?o?.user.id:void 0,l=t?.limit??20,i=(t?.clientIds??[]).join(","),a=t?.activityKind??null,d=t?.excludeCommandClients??!1,n=t?.organizationId??null,s=t?.refetchInterval;return y({queryKey:["client-activity-scopes",c,l,i,a,d,n],queryFn:async()=>{const e=new URLSearchParams({limit:String(l)});i&&e.set("client_ids",i),a&&e.set("activity_kind",a),d&&e.set("exclude_command_clients","true"),n&&e.set("organization_id",n);const r=await f(`${I}/api/me/clients/activity-scopes?${e}`,{credentials:"include"});return await v(r,"Failed to load client activity"),(await r.json()).scopes??[]},enabled:!!c&&(t?.enabled??!0),staleTime:15e3,refetchInterval:typeof s=="function"?e=>s((e.state.data?.length??0)>0):s})}export{w as u};
2
+ //# sourceMappingURL=client-activity-scopes-DqaFEyir.js.map
@@ -1,2 +1,2 @@
1
- import{eR as c}from"./index-BoqrvLHQ.js";function a(t){const n=new Map;for(const e of t){if(e.kind!=="mcp")continue;const s=e.title?.trim()||e.identifier||"Unknown app",l=e.registrationGroupKey||e.id,i=n.get(l);if(!i){n.set(l,{key:l,clientId:e.id,title:s,drivenBy:e.drivenBy?.trim()||null,clientIds:[e.id],connected:e.status==="connected",lastSeenAt:e.lastSeenAt??null,linkedUser:e.linkedUserName??e.linkedUserEmail??null,linkedUserEntitySlug:e.linkedUserEntitySlug??null});continue}i.clientIds.push(e.id),i.connected=i.connected||e.status==="connected",(e.lastSeenAt??0)>(i.lastSeenAt??0)&&(i.lastSeenAt=e.lastSeenAt??null,i.drivenBy=e.drivenBy?.trim()||null)}return[...n.values()].sort((e,s)=>(s.lastSeenAt??0)-(e.lastSeenAt??0))}function o(t){const n=[t.linkedUser];return n.push(t.connected?`active ${c(t.lastSeenAt)}`:"disconnected"),t.drivenBy&&t.drivenBy!==t.title&&n.push(`via ${t.drivenBy}`),n.filter(Boolean).join(" · ")}function d(t){return t.title?.trim()||t.clientName?.trim()||(t.activityKind==="session"?"MCP session":"App activity")}export{d as a,o as c,a as g};
2
- //# sourceMappingURL=client-rows-Dd5YV8vn.js.map
1
+ import{fc as c}from"./index-DB2lVKuV.js";function a(t){const n=new Map;for(const e of t){if(e.kind!=="mcp")continue;const s=e.title?.trim()||e.identifier||"Unknown app",l=e.registrationGroupKey||e.id,i=n.get(l);if(!i){n.set(l,{key:l,clientId:e.id,title:s,drivenBy:e.drivenBy?.trim()||null,clientIds:[e.id],connected:e.status==="connected",lastSeenAt:e.lastSeenAt??null,linkedUser:e.linkedUserName??e.linkedUserEmail??null,linkedUserEntitySlug:e.linkedUserEntitySlug??null});continue}i.clientIds.push(e.id),i.connected=i.connected||e.status==="connected",(e.lastSeenAt??0)>(i.lastSeenAt??0)&&(i.lastSeenAt=e.lastSeenAt??null,i.drivenBy=e.drivenBy?.trim()||null)}return[...n.values()].sort((e,s)=>(s.lastSeenAt??0)-(e.lastSeenAt??0))}function o(t){const n=[t.linkedUser];return n.push(t.connected?`active ${c(t.lastSeenAt)}`:"disconnected"),t.drivenBy&&t.drivenBy!==t.title&&n.push(`via ${t.drivenBy}`),n.filter(Boolean).join(" · ")}function d(t){return t.title?.trim()||t.clientName?.trim()||(t.activityKind==="session"?"MCP session":"App activity")}export{d as a,o as c,a as g};
2
+ //# sourceMappingURL=client-rows-rse9thnk.js.map
@@ -1,2 +1,2 @@
1
- import{dM as c,z as u,y as d,E as p,by as r,af as o,dN as i,a4 as w}from"./index-BoqrvLHQ.js";function l(t,s="",e){const n=`${w}/api/${t}/clients${s}`,a=e?.toString();return a?`${n}?${a}`:n}function y(t,s){const e=s?.ownerSlug??c().slug;return u({queryKey:["connected-clients",e,t??null],queryFn:async()=>{if(!e)throw new Error("Workspace required");const n=new URLSearchParams;t&&n.set("agentId",t);const a=await o(l(e,"",n),{credentials:"include"});return await i(a,"Failed to load connected clients"),(await a.json()).clients??[]},enabled:!!e&&(s?.enabled??!0),staleTime:15e3,refetchInterval:s?.refetchInterval})}function h(){const{slug:t}=c(),s=d();return p({mutationFn:async e=>{if(!t)throw new Error("Workspace required");const n=new URLSearchParams;e.scope==="all"&&n.set("scope","all");const a=await o(l(t,`/mcp/${encodeURIComponent(e.clientId)}`,n),{method:"DELETE",credentials:"include"});return await i(a,"Failed to revoke client"),await a.json()},onSuccess:()=>{s.invalidateQueries({queryKey:["connected-clients",t]}),r.success("App access revoked")},onError:e=>{r.error(e.message||"Failed to revoke app access")}})}export{h as a,y as u};
2
- //# sourceMappingURL=clients-Bf7ZgGro.js.map
1
+ import{dU as c,y as u,z as d,E as p,bH as r,ah as o,dV as i,a5 as w}from"./index-DB2lVKuV.js";function l(t,s="",e){const n=`${w}/api/${t}/clients${s}`,a=e?.toString();return a?`${n}?${a}`:n}function h(t,s){const e=s?.ownerSlug??c().slug;return u({queryKey:["connected-clients",e,t??null],queryFn:async()=>{if(!e)throw new Error("Workspace required");const n=new URLSearchParams;t&&n.set("agentId",t);const a=await o(l(e,"",n),{credentials:"include"});return await i(a,"Failed to load connected clients"),(await a.json()).clients??[]},enabled:!!e&&(s?.enabled??!0),staleTime:15e3,refetchInterval:s?.refetchInterval})}function y(){const{slug:t}=c(),s=d();return p({mutationFn:async e=>{if(!t)throw new Error("Workspace required");const n=new URLSearchParams;e.scope==="all"&&n.set("scope","all");const a=await o(l(t,`/mcp/${encodeURIComponent(e.clientId)}`,n),{method:"DELETE",credentials:"include"});return await i(a,"Failed to revoke client"),await a.json()},onSuccess:()=>{s.invalidateQueries({queryKey:["connected-clients",t]}),r.success("App access revoked")},onError:e=>{r.error(e.message||"Failed to revoke app access")}})}export{y as a,h as u};
2
+ //# sourceMappingURL=clients-BhPMbxHi.js.map
@@ -1,4 +1,4 @@
1
- import{r as $t,j as yu,i as bu}from"./index-BoqrvLHQ.js";import{k as Su,b as Qu,s as ku}from"./index-Vcq4gwWv.js";let Or=[],lh=[];(()=>{let n="lc,34,7n,7,7b,19,,,,2,,2,,,20,b,1c,l,g,,2t,7,2,6,2,2,,4,z,,u,r,2j,b,1m,9,9,,o,4,,9,,3,,5,17,3,3b,f,,w,1j,,,,4,8,4,,3,7,a,2,t,,1m,,,,2,4,8,,9,,a,2,q,,2,2,1l,,4,2,4,2,2,3,3,,u,2,3,,b,2,1l,,4,5,,2,4,,k,2,m,6,,,1m,,,2,,4,8,,7,3,a,2,u,,1n,,,,c,,9,,14,,3,,1l,3,5,3,,4,7,2,b,2,t,,1m,,2,,2,,3,,5,2,7,2,b,2,s,2,1l,2,,,2,4,8,,9,,a,2,t,,20,,4,,2,3,,,8,,29,,2,7,c,8,2q,,2,9,b,6,22,2,r,,,,,,1j,e,,5,,2,5,b,,10,9,,2u,4,,6,,2,2,2,p,2,4,3,g,4,d,,2,2,6,,f,,jj,3,qa,3,t,3,t,2,u,2,1s,2,,7,8,,2,b,9,,19,3,3b,2,y,,3a,3,4,2,9,,6,3,63,2,2,,1m,,,7,,,,,2,8,6,a,2,,1c,h,1r,4,1c,7,,,5,,14,9,c,2,w,4,2,2,,3,1k,,,2,3,,,3,1m,8,2,2,48,3,,d,,7,4,,6,,3,2,5i,1m,,5,ek,,5f,x,2da,3,3x,,2o,w,fe,6,2x,2,n9w,4,,a,w,2,28,2,7k,,3,,4,,p,2,5,,47,2,q,i,d,,12,8,p,b,1a,3,1c,,2,4,2,2,13,,1v,6,2,2,2,2,c,,8,,1b,,1f,,,3,2,2,5,2,,,16,2,8,,6m,,2,,4,,fn4,,kh,g,g,g,a6,2,gt,,6a,,45,5,1ae,3,,2,5,4,14,3,4,,4l,2,fx,4,ar,2,49,b,4w,,1i,f,1k,3,1d,4,2,2,1x,3,10,5,,8,1q,,c,2,1g,9,a,4,2,,2n,3,2,,,2,6,,4g,,3,8,l,2,1l,2,,,,,m,,e,7,3,5,5f,8,2,3,,,n,,29,,2,6,,,2,,,2,,2,6j,,2,4,6,2,,2,r,2,2d,8,2,,,2,2y,,,,2,6,,,2t,3,2,4,,5,77,9,,2,6t,,a,2,,,4,,40,4,2,2,4,,w,a,14,6,2,4,8,,9,6,2,3,1a,d,,2,ba,7,,6,,,2a,m,2,7,,2,,2,3e,6,3,,,2,,7,,,20,2,3,,,,9n,2,f0b,5,1n,7,t4,,1r,4,29,,f5k,2,43q,,,3,4,5,8,8,2,7,u,4,44,3,1iz,1j,4,1e,8,,e,,m,5,,f,11s,7,,h,2,7,,2,,5,79,7,c5,4,15s,7,31,7,240,5,gx7k,2o,3k,6o".split(",").map(e=>e?parseInt(e,36):1);for(let e=0,t=0;e<n.length;e++)(e%2?lh:Or).push(t=t+n[e])})();function wu(n){if(n<768)return!1;for(let e=0,t=Or.length;;){let i=e+t>>1;if(n<Or[i])t=i;else if(n>=lh[i])e=i+1;else return!0;if(e==t)return!1}}function sl(n){return n>=127462&&n<=127487}const rl=8205;function vu(n,e,t=!0,i=!0){return(t?ah:$u)(n,e,i)}function ah(n,e,t){if(e==n.length)return e;e&&hh(n.charCodeAt(e))&&ch(n.charCodeAt(e-1))&&e--;let i=Ls(n,e);for(e+=ol(i);e<n.length;){let s=Ls(n,e);if(i==rl||s==rl||t&&wu(s))e+=ol(s),i=s;else if(sl(s)){let r=0,o=e-2;for(;o>=0&&sl(Ls(n,o));)r++,o-=2;if(r%2==0)break;e+=2}else break}return e}function $u(n,e,t){for(;e>0;){let i=ah(n,e-2,t);if(i<e)return i;e--}return 0}function Ls(n,e){let t=n.charCodeAt(e);if(!ch(t)||e+1==n.length)return t;let i=n.charCodeAt(e+1);return hh(i)?(t-55296<<10)+(i-56320)+65536:t}function hh(n){return n>=56320&&n<57344}function ch(n){return n>=55296&&n<56320}function ol(n){return n<65536?1:2}class E{lineAt(e){if(e<0||e>this.length)throw new RangeError(`Invalid position ${e} in document of length ${this.length}`);return this.lineInner(e,!1,1,0)}line(e){if(e<1||e>this.lines)throw new RangeError(`Invalid line number ${e} in ${this.lines}-line document`);return this.lineInner(e,!0,1,0)}replace(e,t,i){[e,t]=li(this,e,t);let s=[];return this.decompose(0,e,s,2),i.length&&i.decompose(0,i.length,s,3),this.decompose(t,this.length,s,1),Ue.from(s,this.length-(t-e)+i.length)}append(e){return this.replace(this.length,this.length,e)}slice(e,t=this.length){[e,t]=li(this,e,t);let i=[];return this.decompose(e,t,i,0),Ue.from(i,t-e)}eq(e){if(e==this)return!0;if(e.length!=this.length||e.lines!=this.lines)return!1;let t=this.scanIdentical(e,1),i=this.length-this.scanIdentical(e,-1),s=new Ci(this),r=new Ci(e);for(let o=t,l=t;;){if(s.next(o),r.next(o),o=0,s.lineBreak!=r.lineBreak||s.done!=r.done||s.value!=r.value)return!1;if(l+=s.value.length,s.done||l>=i)return!0}}iter(e=1){return new Ci(this,e)}iterRange(e,t=this.length){return new fh(this,e,t)}iterLines(e,t){let i;if(e==null)i=this.iter();else{t==null&&(t=this.lines+1);let s=this.line(e).from;i=this.iterRange(s,Math.max(s,t==this.lines+1?this.length:t<=1?0:this.line(t-1).to))}return new uh(i)}toString(){return this.sliceString(0)}toJSON(){let e=[];return this.flatten(e),e}constructor(){}static of(e){if(e.length==0)throw new RangeError("A document must have at least one line");return e.length==1&&!e[0]?E.empty:e.length<=32?new H(e):Ue.from(H.split(e,[]))}}class H extends E{constructor(e,t=Pu(e)){super(),this.text=e,this.length=t}get lines(){return this.text.length}get children(){return null}lineInner(e,t,i,s){for(let r=0;;r++){let o=this.text[r],l=s+o.length;if((t?i:l)>=e)return new Tu(s,l,i,o);s=l+1,i++}}decompose(e,t,i,s){let r=e<=0&&t>=this.length?this:new H(ll(this.text,e,t),Math.min(t,this.length)-Math.max(0,e));if(s&1){let o=i.pop(),l=Mn(r.text,o.text.slice(),0,r.length);if(l.length<=32)i.push(new H(l,o.length+r.length));else{let a=l.length>>1;i.push(new H(l.slice(0,a)),new H(l.slice(a)))}}else i.push(r)}replace(e,t,i){if(!(i instanceof H))return super.replace(e,t,i);[e,t]=li(this,e,t);let s=Mn(this.text,Mn(i.text,ll(this.text,0,e)),t),r=this.length+i.length-(t-e);return s.length<=32?new H(s,r):Ue.from(H.split(s,[]),r)}sliceString(e,t=this.length,i=`
1
+ import{r as $t,j as yu,i as bu}from"./index-DB2lVKuV.js";import{k as Su,b as Qu,s as ku}from"./index-Vcq4gwWv.js";let Or=[],lh=[];(()=>{let n="lc,34,7n,7,7b,19,,,,2,,2,,,20,b,1c,l,g,,2t,7,2,6,2,2,,4,z,,u,r,2j,b,1m,9,9,,o,4,,9,,3,,5,17,3,3b,f,,w,1j,,,,4,8,4,,3,7,a,2,t,,1m,,,,2,4,8,,9,,a,2,q,,2,2,1l,,4,2,4,2,2,3,3,,u,2,3,,b,2,1l,,4,5,,2,4,,k,2,m,6,,,1m,,,2,,4,8,,7,3,a,2,u,,1n,,,,c,,9,,14,,3,,1l,3,5,3,,4,7,2,b,2,t,,1m,,2,,2,,3,,5,2,7,2,b,2,s,2,1l,2,,,2,4,8,,9,,a,2,t,,20,,4,,2,3,,,8,,29,,2,7,c,8,2q,,2,9,b,6,22,2,r,,,,,,1j,e,,5,,2,5,b,,10,9,,2u,4,,6,,2,2,2,p,2,4,3,g,4,d,,2,2,6,,f,,jj,3,qa,3,t,3,t,2,u,2,1s,2,,7,8,,2,b,9,,19,3,3b,2,y,,3a,3,4,2,9,,6,3,63,2,2,,1m,,,7,,,,,2,8,6,a,2,,1c,h,1r,4,1c,7,,,5,,14,9,c,2,w,4,2,2,,3,1k,,,2,3,,,3,1m,8,2,2,48,3,,d,,7,4,,6,,3,2,5i,1m,,5,ek,,5f,x,2da,3,3x,,2o,w,fe,6,2x,2,n9w,4,,a,w,2,28,2,7k,,3,,4,,p,2,5,,47,2,q,i,d,,12,8,p,b,1a,3,1c,,2,4,2,2,13,,1v,6,2,2,2,2,c,,8,,1b,,1f,,,3,2,2,5,2,,,16,2,8,,6m,,2,,4,,fn4,,kh,g,g,g,a6,2,gt,,6a,,45,5,1ae,3,,2,5,4,14,3,4,,4l,2,fx,4,ar,2,49,b,4w,,1i,f,1k,3,1d,4,2,2,1x,3,10,5,,8,1q,,c,2,1g,9,a,4,2,,2n,3,2,,,2,6,,4g,,3,8,l,2,1l,2,,,,,m,,e,7,3,5,5f,8,2,3,,,n,,29,,2,6,,,2,,,2,,2,6j,,2,4,6,2,,2,r,2,2d,8,2,,,2,2y,,,,2,6,,,2t,3,2,4,,5,77,9,,2,6t,,a,2,,,4,,40,4,2,2,4,,w,a,14,6,2,4,8,,9,6,2,3,1a,d,,2,ba,7,,6,,,2a,m,2,7,,2,,2,3e,6,3,,,2,,7,,,20,2,3,,,,9n,2,f0b,5,1n,7,t4,,1r,4,29,,f5k,2,43q,,,3,4,5,8,8,2,7,u,4,44,3,1iz,1j,4,1e,8,,e,,m,5,,f,11s,7,,h,2,7,,2,,5,79,7,c5,4,15s,7,31,7,240,5,gx7k,2o,3k,6o".split(",").map(e=>e?parseInt(e,36):1);for(let e=0,t=0;e<n.length;e++)(e%2?lh:Or).push(t=t+n[e])})();function wu(n){if(n<768)return!1;for(let e=0,t=Or.length;;){let i=e+t>>1;if(n<Or[i])t=i;else if(n>=lh[i])e=i+1;else return!0;if(e==t)return!1}}function sl(n){return n>=127462&&n<=127487}const rl=8205;function vu(n,e,t=!0,i=!0){return(t?ah:$u)(n,e,i)}function ah(n,e,t){if(e==n.length)return e;e&&hh(n.charCodeAt(e))&&ch(n.charCodeAt(e-1))&&e--;let i=Ls(n,e);for(e+=ol(i);e<n.length;){let s=Ls(n,e);if(i==rl||s==rl||t&&wu(s))e+=ol(s),i=s;else if(sl(s)){let r=0,o=e-2;for(;o>=0&&sl(Ls(n,o));)r++,o-=2;if(r%2==0)break;e+=2}else break}return e}function $u(n,e,t){for(;e>0;){let i=ah(n,e-2,t);if(i<e)return i;e--}return 0}function Ls(n,e){let t=n.charCodeAt(e);if(!ch(t)||e+1==n.length)return t;let i=n.charCodeAt(e+1);return hh(i)?(t-55296<<10)+(i-56320)+65536:t}function hh(n){return n>=56320&&n<57344}function ch(n){return n>=55296&&n<56320}function ol(n){return n<65536?1:2}class E{lineAt(e){if(e<0||e>this.length)throw new RangeError(`Invalid position ${e} in document of length ${this.length}`);return this.lineInner(e,!1,1,0)}line(e){if(e<1||e>this.lines)throw new RangeError(`Invalid line number ${e} in ${this.lines}-line document`);return this.lineInner(e,!0,1,0)}replace(e,t,i){[e,t]=li(this,e,t);let s=[];return this.decompose(0,e,s,2),i.length&&i.decompose(0,i.length,s,3),this.decompose(t,this.length,s,1),Ue.from(s,this.length-(t-e)+i.length)}append(e){return this.replace(this.length,this.length,e)}slice(e,t=this.length){[e,t]=li(this,e,t);let i=[];return this.decompose(e,t,i,0),Ue.from(i,t-e)}eq(e){if(e==this)return!0;if(e.length!=this.length||e.lines!=this.lines)return!1;let t=this.scanIdentical(e,1),i=this.length-this.scanIdentical(e,-1),s=new Ci(this),r=new Ci(e);for(let o=t,l=t;;){if(s.next(o),r.next(o),o=0,s.lineBreak!=r.lineBreak||s.done!=r.done||s.value!=r.value)return!1;if(l+=s.value.length,s.done||l>=i)return!0}}iter(e=1){return new Ci(this,e)}iterRange(e,t=this.length){return new fh(this,e,t)}iterLines(e,t){let i;if(e==null)i=this.iter();else{t==null&&(t=this.lines+1);let s=this.line(e).from;i=this.iterRange(s,Math.max(s,t==this.lines+1?this.length:t<=1?0:this.line(t-1).to))}return new uh(i)}toString(){return this.sliceString(0)}toJSON(){let e=[];return this.flatten(e),e}constructor(){}static of(e){if(e.length==0)throw new RangeError("A document must have at least one line");return e.length==1&&!e[0]?E.empty:e.length<=32?new H(e):Ue.from(H.split(e,[]))}}class H extends E{constructor(e,t=Pu(e)){super(),this.text=e,this.length=t}get lines(){return this.text.length}get children(){return null}lineInner(e,t,i,s){for(let r=0;;r++){let o=this.text[r],l=s+o.length;if((t?i:l)>=e)return new Tu(s,l,i,o);s=l+1,i++}}decompose(e,t,i,s){let r=e<=0&&t>=this.length?this:new H(ll(this.text,e,t),Math.min(t,this.length)-Math.max(0,e));if(s&1){let o=i.pop(),l=Mn(r.text,o.text.slice(),0,r.length);if(l.length<=32)i.push(new H(l,o.length+r.length));else{let a=l.length>>1;i.push(new H(l.slice(0,a)),new H(l.slice(a)))}}else i.push(r)}replace(e,t,i){if(!(i instanceof H))return super.replace(e,t,i);[e,t]=li(this,e,t);let s=Mn(this.text,Mn(i.text,ll(this.text,0,e)),t),r=this.length+i.length-(t-e);return s.length<=32?new H(s,r):Ue.from(H.split(s,[]),r)}sliceString(e,t=this.length,i=`
2
2
  `){[e,t]=li(this,e,t);let s="";for(let r=0,o=0;r<=t&&o<this.text.length;o++){let l=this.text[o],a=r+l.length;r>e&&o&&(s+=i),e<a&&t>r&&(s+=l.slice(Math.max(0,e-r),t-r)),r=a+1}return s}flatten(e){for(let t of this.text)e.push(t)}scanIdentical(){return 0}static split(e,t){let i=[],s=-1;for(let r of e)i.push(r),s+=r.length+1,i.length==32&&(t.push(new H(i,s)),i=[],s=-1);return s>-1&&t.push(new H(i,s)),t}}class Ue extends E{constructor(e,t){super(),this.children=e,this.length=t,this.lines=0;for(let i of e)this.lines+=i.lines}lineInner(e,t,i,s){for(let r=0;;r++){let o=this.children[r],l=s+o.length,a=i+o.lines-1;if((t?a:l)>=e)return o.lineInner(e,t,i,s);s=l+1,i=a+1}}decompose(e,t,i,s){for(let r=0,o=0;o<=t&&r<this.children.length;r++){let l=this.children[r],a=o+l.length;if(e<=a&&t>=o){let h=s&((o<=e?1:0)|(a>=t?2:0));o>=e&&a<=t&&!h?i.push(l):l.decompose(e-o,t-o,i,h)}o=a+1}}replace(e,t,i){if([e,t]=li(this,e,t),i.lines<this.lines)for(let s=0,r=0;s<this.children.length;s++){let o=this.children[s],l=r+o.length;if(e>=r&&t<=l){let a=o.replace(e-r,t-r,i),h=this.lines-o.lines+a.lines;if(a.lines<h>>4&&a.lines>h>>6){let c=this.children.slice();return c[s]=a,new Ue(c,this.length-(t-e)+i.length)}return super.replace(r,l,a)}r=l+1}return super.replace(e,t,i)}sliceString(e,t=this.length,i=`
3
3
  `){[e,t]=li(this,e,t);let s="";for(let r=0,o=0;r<this.children.length&&o<=t;r++){let l=this.children[r],a=o+l.length;o>e&&r&&(s+=i),e<a&&t>o&&(s+=l.sliceString(e-o,t-o,i)),o=a+1}return s}flatten(e){for(let t of this.children)t.flatten(e)}scanIdentical(e,t){if(!(e instanceof Ue))return 0;let i=0,[s,r,o,l]=t>0?[0,0,this.children.length,e.children.length]:[this.children.length-1,e.children.length-1,-1,-1];for(;;s+=t,r+=t){if(s==o||r==l)return i;let a=this.children[s],h=e.children[r];if(a!=h)return i+a.scanIdentical(h,t);i+=a.length+1}}static from(e,t=e.reduce((i,s)=>i+s.length+1,-1)){let i=0;for(let d of e)i+=d.lines;if(i<32){let d=[];for(let O of e)O.flatten(d);return new H(d,t)}let s=Math.max(32,i>>5),r=s<<1,o=s>>1,l=[],a=0,h=-1,c=[];function f(d){let O;if(d.lines>r&&d instanceof Ue)for(let p of d.children)f(p);else d.lines>o&&(a>o||!a)?(u(),l.push(d)):d instanceof H&&a&&(O=c[c.length-1])instanceof H&&d.lines+O.lines<=32?(a+=d.lines,h+=d.length+1,c[c.length-1]=new H(O.text.concat(d.text),O.length+1+d.length)):(a+d.lines>s&&u(),a+=d.lines,h+=d.length+1,c.push(d))}function u(){a!=0&&(l.push(c.length==1?c[0]:Ue.from(c,h)),h=-1,a=c.length=0)}for(let d of e)f(d);return u(),l.length==1?l[0]:new Ue(l,t)}}E.empty=new H([""],0);function Pu(n){let e=-1;for(let t of n)e+=t.length+1;return e}function Mn(n,e,t=0,i=1e9){for(let s=0,r=0,o=!0;r<n.length&&s<=i;r++){let l=n[r],a=s+l.length;a>=t&&(a>i&&(l=l.slice(0,i-s)),s<t&&(l=l.slice(t-s)),o?(e[e.length-1]+=l,o=!1):e.push(l)),s=a+1}return e}function ll(n,e,t){return Mn(n,[""],e,t)}class Ci{constructor(e,t=1){this.dir=t,this.done=!1,this.lineBreak=!1,this.value="",this.nodes=[e],this.offsets=[t>0?1:(e instanceof H?e.text.length:e.children.length)<<1]}nextInner(e,t){for(this.done=this.lineBreak=!1;;){let i=this.nodes.length-1,s=this.nodes[i],r=this.offsets[i],o=r>>1,l=s instanceof H?s.text.length:s.children.length;if(o==(t>0?l:0)){if(i==0)return this.done=!0,this.value="",this;t>0&&this.offsets[i-1]++,this.nodes.pop(),this.offsets.pop()}else if((r&1)==(t>0?0:1)){if(this.offsets[i]+=t,e==0)return this.lineBreak=!0,this.value=`
4
4
  `,this;e--}else if(s instanceof H){let a=s.text[o+(t<0?-1:0)];if(this.offsets[i]+=t,a.length>Math.max(0,e))return this.value=e==0?a:t>0?a.slice(e):a.slice(0,a.length-e),this;e-=a.length}else{let a=s.children[o+(t<0?-1:0)];e>a.length?(e-=a.length,this.offsets[i]+=t):(t<0&&this.offsets[i]--,this.nodes.push(a),this.offsets.push(t>0?1:(a instanceof H?a.text.length:a.children.length)<<1))}}}next(e=0){return e<0&&(this.nextInner(-e,-this.dir),e=this.value.length),this.nextInner(e,this.dir)}}class fh{constructor(e,t,i){this.value="",this.done=!1,this.cursor=new Ci(e,t>i?-1:1),this.pos=t>i?e.length:0,this.from=Math.min(t,i),this.to=Math.max(t,i)}nextInner(e,t){if(t<0?this.pos<=this.from:this.pos>=this.to)return this.value="",this.done=!0,this;e+=Math.max(0,t<0?this.pos-this.to:this.from-this.pos);let i=t<0?this.pos-this.from:this.to-this.pos;e>i&&(e=i),i-=e;let{value:s}=this.cursor.next(e);return this.pos+=(s.length+e)*t,this.value=s.length<=i?s:t<0?s.slice(s.length-i):s.slice(0,i),this.done=!this.value,this}next(e=0){return e<0?e=Math.max(e,this.from-this.pos):e>0&&(e=Math.min(e,this.to-this.pos)),this.nextInner(e,this.cursor.dir)}get lineBreak(){return this.cursor.lineBreak&&this.value!=""}}class uh{constructor(e){this.inner=e,this.afterBreak=!0,this.value="",this.done=!1}next(e=0){let{done:t,lineBreak:i,value:s}=this.inner.next(e);return t&&this.afterBreak?(this.value="",this.afterBreak=!1):t?(this.done=!0,this.value=""):i?this.afterBreak?this.value="":(this.afterBreak=!0,this.next()):(this.value=s,this.afterBreak=!1),this}get lineBreak(){return!1}}typeof Symbol<"u"&&(E.prototype[Symbol.iterator]=function(){return this.iter()},Ci.prototype[Symbol.iterator]=fh.prototype[Symbol.iterator]=uh.prototype[Symbol.iterator]=function(){return this});class Tu{constructor(e,t,i,s){this.from=e,this.to=t,this.number=i,this.text=s}get length(){return this.to-this.from}}function li(n,e,t){return e=Math.max(0,Math.min(n.length,e)),[e,Math.max(e,Math.min(n.length,t))]}function se(n,e,t=!0,i=!0){return vu(n,e,t,i)}function Cu(n){return n>=56320&&n<57344}function Zu(n){return n>=55296&&n<56320}function me(n,e){let t=n.charCodeAt(e);if(!Zu(t)||e+1==n.length)return t;let i=n.charCodeAt(e+1);return Cu(i)?(t-55296<<10)+(i-56320)+65536:t}function fo(n){return n<=65535?String.fromCharCode(n):(n-=65536,String.fromCharCode((n>>10)+55296,(n&1023)+56320))}function Fe(n){return n<65536?1:2}const pr=/\r\n?|\n/;var le=(function(n){return n[n.Simple=0]="Simple",n[n.TrackDel=1]="TrackDel",n[n.TrackBefore=2]="TrackBefore",n[n.TrackAfter=3]="TrackAfter",n})(le||(le={}));class it{constructor(e){this.sections=e}get length(){let e=0;for(let t=0;t<this.sections.length;t+=2)e+=this.sections[t];return e}get newLength(){let e=0;for(let t=0;t<this.sections.length;t+=2){let i=this.sections[t+1];e+=i<0?this.sections[t]:i}return e}get empty(){return this.sections.length==0||this.sections.length==2&&this.sections[1]<0}iterGaps(e){for(let t=0,i=0,s=0;t<this.sections.length;){let r=this.sections[t++],o=this.sections[t++];o<0?(e(i,s,r),s+=r):s+=o,i+=r}}iterChangedRanges(e,t=!1){mr(this,e,t)}get invertedDesc(){let e=[];for(let t=0;t<this.sections.length;){let i=this.sections[t++],s=this.sections[t++];s<0?e.push(i,s):e.push(s,i)}return new it(e)}composeDesc(e){return this.empty?e:e.empty?this:dh(this,e)}mapDesc(e,t=!1){return e.empty?this:gr(this,e,t)}mapPos(e,t=-1,i=le.Simple){let s=0,r=0;for(let o=0;o<this.sections.length;){let l=this.sections[o++],a=this.sections[o++],h=s+l;if(a<0){if(h>e)return r+(e-s);r+=l}else{if(i!=le.Simple&&h>=e&&(i==le.TrackDel&&s<e&&h>e||i==le.TrackBefore&&s<e||i==le.TrackAfter&&h>e))return null;if(h>e||h==e&&t<0&&!l)return e==s||t<0?r:r+a;r+=a}s=h}if(e>s)throw new RangeError(`Position ${e} is out of range for changeset of length ${s}`);return r}touchesRange(e,t=e){for(let i=0,s=0;i<this.sections.length&&s<=t;){let r=this.sections[i++],o=this.sections[i++],l=s+r;if(o>=0&&s<=t&&l>=e)return s<e&&l>t?"cover":!0;s=l}return!1}toString(){let e="";for(let t=0;t<this.sections.length;){let i=this.sections[t++],s=this.sections[t++];e+=(e?" ":"")+i+(s>=0?":"+s:"")}return e}toJSON(){return this.sections}static fromJSON(e){if(!Array.isArray(e)||e.length%2||e.some(t=>typeof t!="number"))throw new RangeError("Invalid JSON representation of ChangeDesc");return new it(e)}static create(e){return new it(e)}}class ie extends it{constructor(e,t){super(e),this.inserted=t}apply(e){if(this.length!=e.length)throw new RangeError("Applying change set to a document with the wrong length");return mr(this,(t,i,s,r,o)=>e=e.replace(s,s+(i-t),o),!1),e}mapDesc(e,t=!1){return gr(this,e,t,!0)}invert(e){let t=this.sections.slice(),i=[];for(let s=0,r=0;s<t.length;s+=2){let o=t[s],l=t[s+1];if(l>=0){t[s]=l,t[s+1]=o;let a=s>>1;for(;i.length<a;)i.push(E.empty);i.push(o?e.slice(r,r+o):E.empty)}r+=o}return new ie(t,i)}compose(e){return this.empty?e:e.empty?this:dh(this,e,!0)}map(e,t=!1){return e.empty?this:gr(this,e,t,!0)}iterChanges(e,t=!1){mr(this,e,t)}get desc(){return it.create(this.sections)}filter(e){let t=[],i=[],s=[],r=new Wi(this);e:for(let o=0,l=0;;){let a=o==e.length?1e9:e[o++];for(;l<a||l==a&&r.len==0;){if(r.done)break e;let c=Math.min(r.len,a-l);he(s,c,-1);let f=r.ins==-1?-1:r.off==0?r.ins:0;he(t,c,f),f>0&&Ot(i,t,r.text),r.forward(c),l+=c}let h=e[o++];for(;l<h;){if(r.done)break e;let c=Math.min(r.len,h-l);he(t,c,-1),he(s,c,r.ins==-1?-1:r.off==0?r.ins:0),r.forward(c),l+=c}}return{changes:new ie(t,i),filtered:it.create(s)}}toJSON(){let e=[];for(let t=0;t<this.sections.length;t+=2){let i=this.sections[t],s=this.sections[t+1];s<0?e.push(i):s==0?e.push([i]):e.push([i].concat(this.inserted[t>>1].toJSON()))}return e}static of(e,t,i){let s=[],r=[],o=0,l=null;function a(c=!1){if(!c&&!s.length)return;o<t&&he(s,t-o,-1);let f=new ie(s,r);l=l?l.compose(f.map(l)):f,s=[],r=[],o=0}function h(c){if(Array.isArray(c))for(let f of c)h(f);else if(c instanceof ie){if(c.length!=t)throw new RangeError(`Mismatched change set length (got ${c.length}, expected ${t})`);a(),l=l?l.compose(c.map(l)):c}else{let{from:f,to:u=f,insert:d}=c;if(f>u||f<0||u>t)throw new RangeError(`Invalid change range ${f} to ${u} (in doc of length ${t})`);let O=d?typeof d=="string"?E.of(d.split(i||pr)):d:E.empty,p=O.length;if(f==u&&p==0)return;f<o&&a(),f>o&&he(s,f-o,-1),he(s,u-f,p),Ot(r,s,O),o=u}}return h(e),a(!l),l}static empty(e){return new ie(e?[e,-1]:[],[])}static fromJSON(e){if(!Array.isArray(e))throw new RangeError("Invalid JSON representation of ChangeSet");let t=[],i=[];for(let s=0;s<e.length;s++){let r=e[s];if(typeof r=="number")t.push(r,-1);else{if(!Array.isArray(r)||typeof r[0]!="number"||r.some((o,l)=>l&&typeof o!="string"))throw new RangeError("Invalid JSON representation of ChangeSet");if(r.length==1)t.push(r[0],0);else{for(;i.length<s;)i.push(E.empty);i[s]=E.of(r.slice(1)),t.push(r[0],i[s].length)}}}return new ie(t,i)}static createSet(e,t){return new ie(e,t)}}function he(n,e,t,i=!1){if(e==0&&t<=0)return;let s=n.length-2;s>=0&&t<=0&&t==n[s+1]?n[s]+=e:s>=0&&e==0&&n[s]==0?n[s+1]+=t:i?(n[s]+=e,n[s+1]+=t):n.push(e,t)}function Ot(n,e,t){if(t.length==0)return;let i=e.length-2>>1;if(i<n.length)n[n.length-1]=n[n.length-1].append(t);else{for(;n.length<i;)n.push(E.empty);n.push(t)}}function mr(n,e,t){let i=n.inserted;for(let s=0,r=0,o=0;o<n.sections.length;){let l=n.sections[o++],a=n.sections[o++];if(a<0)s+=l,r+=l;else{let h=s,c=r,f=E.empty;for(;h+=l,c+=a,a&&i&&(f=f.append(i[o-2>>1])),!(t||o==n.sections.length||n.sections[o+1]<0);)l=n.sections[o++],a=n.sections[o++];e(s,h,r,c,f),s=h,r=c}}}function gr(n,e,t,i=!1){let s=[],r=i?[]:null,o=new Wi(n),l=new Wi(e);for(let a=-1;;){if(o.done&&l.len||l.done&&o.len)throw new Error("Mismatched change set lengths");if(o.ins==-1&&l.ins==-1){let h=Math.min(o.len,l.len);he(s,h,-1),o.forward(h),l.forward(h)}else if(l.ins>=0&&(o.ins<0||a==o.i||o.off==0&&(l.len<o.len||l.len==o.len&&!t))){let h=l.len;for(he(s,l.ins,-1);h;){let c=Math.min(o.len,h);o.ins>=0&&a<o.i&&o.len<=c&&(he(s,0,o.ins),r&&Ot(r,s,o.text),a=o.i),o.forward(c),h-=c}l.next()}else if(o.ins>=0){let h=0,c=o.len;for(;c;)if(l.ins==-1){let f=Math.min(c,l.len);h+=f,c-=f,l.forward(f)}else if(l.ins==0&&l.len<c)c-=l.len,l.next();else break;he(s,h,a<o.i?o.ins:0),r&&a<o.i&&Ot(r,s,o.text),a=o.i,o.forward(o.len-c)}else{if(o.done&&l.done)return r?ie.createSet(s,r):it.create(s);throw new Error("Mismatched change set lengths")}}}function dh(n,e,t=!1){let i=[],s=t?[]:null,r=new Wi(n),o=new Wi(e);for(let l=!1;;){if(r.done&&o.done)return s?ie.createSet(i,s):it.create(i);if(r.ins==0)he(i,r.len,0,l),r.next();else if(o.len==0&&!o.done)he(i,0,o.ins,l),s&&Ot(s,i,o.text),o.next();else{if(r.done||o.done)throw new Error("Mismatched change set lengths");{let a=Math.min(r.len2,o.len),h=i.length;if(r.ins==-1){let c=o.ins==-1?-1:o.off?0:o.ins;he(i,a,c,l),s&&c&&Ot(s,i,o.text)}else o.ins==-1?(he(i,r.off?0:r.len,a,l),s&&Ot(s,i,r.textBit(a))):(he(i,r.off?0:r.len,o.off?0:o.ins,l),s&&!o.off&&Ot(s,i,o.text));l=(r.ins>a||o.ins>=0&&o.len>a)&&(l||i.length>h),r.forward2(a),o.forward(a)}}}}class Wi{constructor(e){this.set=e,this.i=0,this.next()}next(){let{sections:e}=this.set;this.i<e.length?(this.len=e[this.i++],this.ins=e[this.i++]):(this.len=0,this.ins=-2),this.off=0}get done(){return this.ins==-2}get len2(){return this.ins<0?this.len:this.ins}get text(){let{inserted:e}=this.set,t=this.i-2>>1;return t>=e.length?E.empty:e[t]}textBit(e){let{inserted:t}=this.set,i=this.i-2>>1;return i>=t.length&&!e?E.empty:t[i].slice(this.off,e==null?void 0:this.off+e)}forward(e){e==this.len?this.next():(this.len-=e,this.off+=e)}forward2(e){this.ins==-1?this.forward(e):e==this.ins?this.next():(this.ins-=e,this.off+=e)}}class Rt{constructor(e,t,i){this.from=e,this.to=t,this.flags=i}get anchor(){return this.flags&32?this.to:this.from}get head(){return this.flags&32?this.from:this.to}get empty(){return this.from==this.to}get assoc(){return this.flags&8?-1:this.flags&16?1:0}get bidiLevel(){let e=this.flags&7;return e==7?null:e}get goalColumn(){let e=this.flags>>6;return e==16777215?void 0:e}map(e,t=-1){let i,s;return this.empty?i=s=e.mapPos(this.from,t):(i=e.mapPos(this.from,1),s=e.mapPos(this.to,-1)),i==this.from&&s==this.to?this:new Rt(i,s,this.flags)}extend(e,t=e,i=0){if(e<=this.anchor&&t>=this.anchor)return y.range(e,t,void 0,void 0,i);let s=Math.abs(e-this.anchor)>Math.abs(t-this.anchor)?e:t;return y.range(this.anchor,s,void 0,void 0,i)}eq(e,t=!1){return this.anchor==e.anchor&&this.head==e.head&&this.goalColumn==e.goalColumn&&(!t||!this.empty||this.assoc==e.assoc)}toJSON(){return{anchor:this.anchor,head:this.head}}static fromJSON(e){if(!e||typeof e.anchor!="number"||typeof e.head!="number")throw new RangeError("Invalid JSON representation for SelectionRange");return y.range(e.anchor,e.head)}static create(e,t,i){return new Rt(e,t,i)}}class y{constructor(e,t){this.ranges=e,this.mainIndex=t}map(e,t=-1){return e.empty?this:y.create(this.ranges.map(i=>i.map(e,t)),this.mainIndex)}eq(e,t=!1){if(this.ranges.length!=e.ranges.length||this.mainIndex!=e.mainIndex)return!1;for(let i=0;i<this.ranges.length;i++)if(!this.ranges[i].eq(e.ranges[i],t))return!1;return!0}get main(){return this.ranges[this.mainIndex]}asSingle(){return this.ranges.length==1?this:new y([this.main],0)}addRange(e,t=!0){return y.create([e].concat(this.ranges),t?0:this.mainIndex+1)}replaceRange(e,t=this.mainIndex){let i=this.ranges.slice();return i[t]=e,y.create(i,this.mainIndex)}toJSON(){return{ranges:this.ranges.map(e=>e.toJSON()),main:this.mainIndex}}static fromJSON(e){if(!e||!Array.isArray(e.ranges)||typeof e.main!="number"||e.main>=e.ranges.length)throw new RangeError("Invalid JSON representation for EditorSelection");return new y(e.ranges.map(t=>Rt.fromJSON(t)),e.main)}static single(e,t=e){return new y([y.range(e,t)],0)}static create(e,t=0){if(e.length==0)throw new RangeError("A selection needs at least one range");for(let i=0,s=0;s<e.length;s++){let r=e[s];if(r.empty?r.from<=i:r.from<i)return y.normalized(e.slice(),t);i=r.to}return new y(e,t)}static cursor(e,t=0,i,s){return Rt.create(e,e,(t==0?0:t<0?8:16)|(i==null?7:Math.min(6,i))|(s??16777215)<<6)}static range(e,t,i,s,r){let o=(i??16777215)<<6|(s==null?7:Math.min(6,s));return!r&&e!=t&&(r=t<e?1:-1),t<e?Rt.create(t,e,48|o):Rt.create(e,t,(r?r<0?8:16:0)|o)}static normalized(e,t=0){let i=e[t];e.sort((s,r)=>s.from-r.from),t=e.indexOf(i);for(let s=1;s<e.length;s++){let r=e[s],o=e[s-1];if(r.empty?r.from<=o.to:r.from<o.to){let l=o.from,a=Math.max(r.to,o.to);s<=t&&t--,e.splice(--s,2,r.anchor>r.head?y.range(a,l):y.range(l,a))}}return new y(e,t)}}function Oh(n,e){for(let t of n.ranges)if(t.to>e)throw new RangeError("Selection points outside of document")}let uo=0;class P{constructor(e,t,i,s,r){this.combine=e,this.compareInput=t,this.compare=i,this.isStatic=s,this.id=uo++,this.default=e([]),this.extensions=typeof r=="function"?r(this):r}get reader(){return this}static define(e={}){return new P(e.combine||(t=>t),e.compareInput||((t,i)=>t===i),e.compare||(e.combine?(t,i)=>t===i:Oo),!!e.static,e.enables)}of(e){return new Rn([],this,0,e)}compute(e,t){if(this.isStatic)throw new Error("Can't compute a static facet");return new Rn(e,this,1,t)}computeN(e,t){if(this.isStatic)throw new Error("Can't compute a static facet");return new Rn(e,this,2,t)}from(e,t){return t||(t=i=>i),this.compute([e],i=>t(i.field(e)))}}function Oo(n,e){return n==e||n.length==e.length&&n.every((t,i)=>t===e[i])}class Rn{constructor(e,t,i,s){this.dependencies=e,this.facet=t,this.type=i,this.value=s,this.id=uo++}dynamicSlot(e){var t;let i=this.value,s=this.facet.compareInput,r=this.id,o=e[r]>>1,l=this.type==2,a=!1,h=!1,c=[];for(let f of this.dependencies)f=="doc"?a=!0:f=="selection"?h=!0:(((t=e[f.id])!==null&&t!==void 0?t:1)&1)==0&&c.push(e[f.id]);return{create(f){return f.values[o]=i(f),1},update(f,u){if(a&&u.docChanged||h&&(u.docChanged||u.selection)||xr(f,c)){let d=i(f);if(l?!al(d,f.values[o],s):!s(d,f.values[o]))return f.values[o]=d,1}return 0},reconfigure:(f,u)=>{let d,O=u.config.address[r];if(O!=null){let p=Yn(u,O);if(this.dependencies.every(m=>m instanceof P?u.facet(m)===f.facet(m):m instanceof ce?u.field(m,!1)==f.field(m,!1):!0)||(l?al(d=i(f),p,s):s(d=i(f),p)))return f.values[o]=p,0}else d=i(f);return f.values[o]=d,1}}}}function al(n,e,t){if(n.length!=e.length)return!1;for(let i=0;i<n.length;i++)if(!t(n[i],e[i]))return!1;return!0}function xr(n,e){let t=!1;for(let i of e)Zi(n,i)&1&&(t=!0);return t}function Au(n,e,t){let i=t.map(a=>n[a.id]),s=t.map(a=>a.type),r=i.filter(a=>!(a&1)),o=n[e.id]>>1;function l(a){let h=[];for(let c=0;c<i.length;c++){let f=Yn(a,i[c]);if(s[c]==2)for(let u of f)h.push(u);else h.push(f)}return e.combine(h)}return{create(a){for(let h of i)Zi(a,h);return a.values[o]=l(a),1},update(a,h){if(!xr(a,r))return 0;let c=l(a);return e.compare(c,a.values[o])?0:(a.values[o]=c,1)},reconfigure(a,h){let c=xr(a,i),f=h.config.facets[e.id],u=h.facet(e);if(f&&!c&&Oo(t,f))return a.values[o]=u,0;let d=l(a);return e.compare(d,u)?(a.values[o]=u,0):(a.values[o]=d,1)}}}const hn=P.define({static:!0});class ce{constructor(e,t,i,s,r){this.id=e,this.createF=t,this.updateF=i,this.compareF=s,this.spec=r,this.provides=void 0}static define(e){let t=new ce(uo++,e.create,e.update,e.compare||((i,s)=>i===s),e);return e.provide&&(t.provides=e.provide(t)),t}create(e){let t=e.facet(hn).find(i=>i.field==this);return(t?.create||this.createF)(e)}slot(e){let t=e[this.id]>>1;return{create:i=>(i.values[t]=this.create(i),1),update:(i,s)=>{let r=i.values[t],o=this.updateF(r,s);return this.compareF(r,o)?0:(i.values[t]=o,1)},reconfigure:(i,s)=>{let r=i.facet(hn),o=s.facet(hn),l;return(l=r.find(a=>a.field==this))&&l!=o.find(a=>a.field==this)?(i.values[t]=l.create(i),1):s.config.address[this.id]!=null?(i.values[t]=s.field(this),0):(i.values[t]=this.create(i),1)}}}init(e){return[this,hn.of({field:this,create:e})]}get extension(){return this}}const At={lowest:4,low:3,default:2,high:1,highest:0};function bi(n){return e=>new ph(e,n)}const kt={highest:bi(At.highest),high:bi(At.high),default:bi(At.default),low:bi(At.low),lowest:bi(At.lowest)};class ph{constructor(e,t){this.inner=e,this.prec=t}}class ps{of(e){return new yr(this,e)}reconfigure(e){return ps.reconfigure.of({compartment:this,extension:e})}get(e){return e.config.compartments.get(this)}}class yr{constructor(e,t){this.compartment=e,this.inner=t}}class Bn{constructor(e,t,i,s,r,o){for(this.base=e,this.compartments=t,this.dynamicSlots=i,this.address=s,this.staticValues=r,this.facets=o,this.statusTemplate=[];this.statusTemplate.length<i.length;)this.statusTemplate.push(0)}staticFacet(e){let t=this.address[e.id];return t==null?e.default:this.staticValues[t>>1]}static resolve(e,t,i){let s=[],r=Object.create(null),o=new Map;for(let u of Mu(e,t,o))u instanceof ce?s.push(u):(r[u.facet.id]||(r[u.facet.id]=[])).push(u);let l=Object.create(null),a=[],h=[];for(let u of s)l[u.id]=h.length<<1,h.push(d=>u.slot(d));let c=i?.config.facets;for(let u in r){let d=r[u],O=d[0].facet,p=c&&c[u]||[];if(d.every(m=>m.type==0))if(l[O.id]=a.length<<1|1,Oo(p,d))a.push(i.facet(O));else{let m=O.combine(d.map(x=>x.value));a.push(i&&O.compare(m,i.facet(O))?i.facet(O):m)}else{for(let m of d)m.type==0?(l[m.id]=a.length<<1|1,a.push(m.value)):(l[m.id]=h.length<<1,h.push(x=>m.dynamicSlot(x)));l[O.id]=h.length<<1,h.push(m=>Au(m,O,d))}}let f=h.map(u=>u(l));return new Bn(e,o,f,l,a,r)}}function Mu(n,e,t){let i=[[],[],[],[],[]],s=new Map;function r(o,l){let a=s.get(o);if(a!=null){if(a<=l)return;let h=i[a].indexOf(o);h>-1&&i[a].splice(h,1),o instanceof yr&&t.delete(o.compartment)}if(s.set(o,l),Array.isArray(o))for(let h of o)r(h,l);else if(o instanceof yr){if(t.has(o.compartment))throw new RangeError("Duplicate use of compartment in extensions");let h=e.get(o.compartment)||o.inner;t.set(o.compartment,h),r(h,l)}else if(o instanceof ph)r(o.inner,o.prec);else if(o instanceof ce)i[l].push(o),o.provides&&r(o.provides,l);else if(o instanceof Rn)i[l].push(o),o.facet.extensions&&r(o.facet.extensions,At.default);else{let h=o.extension;if(!h)throw new Error(`Unrecognized extension value in extension set (${o}). This sometimes happens because multiple instances of @codemirror/state are loaded, breaking instanceof checks.`);r(h,l)}}return r(n,At.default),i.reduce((o,l)=>o.concat(l))}function Zi(n,e){if(e&1)return 2;let t=e>>1,i=n.status[t];if(i==4)throw new Error("Cyclic dependency between fields and/or facets");if(i&2)return i;n.status[t]=4;let s=n.computeSlot(n,n.config.dynamicSlots[t]);return n.status[t]=2|s}function Yn(n,e){return e&1?n.config.staticValues[e>>1]:n.values[e>>1]}const mh=P.define(),br=P.define({combine:n=>n.some(e=>e),static:!0}),gh=P.define({combine:n=>n.length?n[0]:void 0,static:!0}),xh=P.define(),yh=P.define(),bh=P.define(),Sh=P.define({combine:n=>n.length?n[0]:!1});class ct{constructor(e,t){this.type=e,this.value=t}static define(){return new Ru}}class Ru{of(e){return new ct(this,e)}}class Xu{constructor(e){this.map=e}of(e){return new M(this,e)}}class M{constructor(e,t){this.type=e,this.value=t}map(e){let t=this.type.map(this.value,e);return t===void 0?void 0:t==this.value?this:new M(this.type,t)}is(e){return this.type==e}static define(e={}){return new Xu(e.map||(t=>t))}static mapEffects(e,t){if(!e.length)return e;let i=[];for(let s of e){let r=s.map(t);r&&i.push(r)}return i}}M.reconfigure=M.define();M.appendConfig=M.define();class J{constructor(e,t,i,s,r,o){this.startState=e,this.changes=t,this.selection=i,this.effects=s,this.annotations=r,this.scrollIntoView=o,this._doc=null,this._state=null,i&&Oh(i,t.newLength),r.some(l=>l.type==J.time)||(this.annotations=r.concat(J.time.of(Date.now())))}static create(e,t,i,s,r,o){return new J(e,t,i,s,r,o)}get newDoc(){return this._doc||(this._doc=this.changes.apply(this.startState.doc))}get newSelection(){return this.selection||this.startState.selection.map(this.changes)}get state(){return this._state||this.startState.applyTransaction(this),this._state}annotation(e){for(let t of this.annotations)if(t.type==e)return t.value}get docChanged(){return!this.changes.empty}get reconfigured(){return this.startState.config!=this.state.config}isUserEvent(e){let t=this.annotation(J.userEvent);return!!(t&&(t==e||t.length>e.length&&t.slice(0,e.length)==e&&t[e.length]=="."))}}J.time=ct.define();J.userEvent=ct.define();J.addToHistory=ct.define();J.remote=ct.define();function Lu(n,e){let t=[];for(let i=0,s=0;;){let r,o;if(i<n.length&&(s==e.length||e[s]>=n[i]))r=n[i++],o=n[i++];else if(s<e.length)r=e[s++],o=e[s++];else return t;!t.length||t[t.length-1]<r?t.push(r,o):t[t.length-1]<o&&(t[t.length-1]=o)}}function Qh(n,e,t){var i;let s,r,o;return t?(s=e.changes,r=ie.empty(e.changes.length),o=n.changes.compose(e.changes)):(s=e.changes.map(n.changes),r=n.changes.mapDesc(e.changes,!0),o=n.changes.compose(s)),{changes:o,selection:e.selection?e.selection.map(r):(i=n.selection)===null||i===void 0?void 0:i.map(s),effects:M.mapEffects(n.effects,s).concat(M.mapEffects(e.effects,r)),annotations:n.annotations.length?n.annotations.concat(e.annotations):e.annotations,scrollIntoView:n.scrollIntoView||e.scrollIntoView}}function Sr(n,e,t){let i=e.selection,s=Jt(e.annotations);return e.userEvent&&(s=s.concat(J.userEvent.of(e.userEvent))),{changes:e.changes instanceof ie?e.changes:ie.of(e.changes||[],t,n.facet(gh)),selection:i&&(i instanceof y?i:y.single(i.anchor,i.head)),effects:Jt(e.effects),annotations:s,scrollIntoView:!!e.scrollIntoView}}function kh(n,e,t){let i=Sr(n,e.length?e[0]:{},n.doc.length);e.length&&e[0].filter===!1&&(t=!1);for(let r=1;r<e.length;r++){e[r].filter===!1&&(t=!1);let o=!!e[r].sequential;i=Qh(i,Sr(n,e[r],o?i.changes.newLength:n.doc.length),o)}let s=J.create(n,i.changes,i.selection,i.effects,i.annotations,i.scrollIntoView);return Wu(t?Du(s):s)}function Du(n){let e=n.startState,t=!0;for(let s of e.facet(xh)){let r=s(n);if(r===!1){t=!1;break}Array.isArray(r)&&(t=t===!0?r:Lu(t,r))}if(t!==!0){let s,r;if(t===!1)r=n.changes.invertedDesc,s=ie.empty(e.doc.length);else{let o=n.changes.filter(t);s=o.changes,r=o.filtered.mapDesc(o.changes).invertedDesc}n=J.create(e,s,n.selection&&n.selection.map(r),M.mapEffects(n.effects,r),n.annotations,n.scrollIntoView)}let i=e.facet(yh);for(let s=i.length-1;s>=0;s--){let r=i[s](n);r instanceof J?n=r:Array.isArray(r)&&r.length==1&&r[0]instanceof J?n=r[0]:n=kh(e,Jt(r),!1)}return n}function Wu(n){let e=n.startState,t=e.facet(bh),i=n;for(let s=t.length-1;s>=0;s--){let r=t[s](n);r&&Object.keys(r).length&&(i=Qh(i,Sr(e,r,n.changes.newLength),!0))}return i==n?n:J.create(e,n.changes,n.selection,i.effects,i.annotations,i.scrollIntoView)}const Eu=[];function Jt(n){return n==null?Eu:Array.isArray(n)?n:[n]}var G=(function(n){return n[n.Word=0]="Word",n[n.Space=1]="Space",n[n.Other=2]="Other",n})(G||(G={}));const zu=/[\u00df\u0587\u0590-\u05f4\u0600-\u06ff\u3040-\u309f\u30a0-\u30ff\u3400-\u4db5\u4e00-\u9fcc\uac00-\ud7af]/;let Qr;try{Qr=new RegExp("[\\p{Alphabetic}\\p{Number}_]","u")}catch{}function Bu(n){if(Qr)return Qr.test(n);for(let e=0;e<n.length;e++){let t=n[e];if(/\w/.test(t)||t>"€"&&(t.toUpperCase()!=t.toLowerCase()||zu.test(t)))return!0}return!1}function Yu(n){return e=>{if(!/\S/.test(e))return G.Space;if(Bu(e))return G.Word;for(let t=0;t<n.length;t++)if(e.indexOf(n[t])>-1)return G.Word;return G.Other}}class z{constructor(e,t,i,s,r,o){this.config=e,this.doc=t,this.selection=i,this.values=s,this.status=e.statusTemplate.slice(),this.computeSlot=r,o&&(o._state=this);for(let l=0;l<this.config.dynamicSlots.length;l++)Zi(this,l<<1);this.computeSlot=null}field(e,t=!0){let i=this.config.address[e.id];if(i==null){if(t)throw new RangeError("Field is not present in this state");return}return Zi(this,i),Yn(this,i)}update(...e){return kh(this,e,!0)}applyTransaction(e){let t=this.config,{base:i,compartments:s}=t;for(let l of e.effects)l.is(ps.reconfigure)?(t&&(s=new Map,t.compartments.forEach((a,h)=>s.set(h,a)),t=null),s.set(l.value.compartment,l.value.extension)):l.is(M.reconfigure)?(t=null,i=l.value):l.is(M.appendConfig)&&(t=null,i=Jt(i).concat(l.value));let r;t?r=e.startState.values.slice():(t=Bn.resolve(i,s,this),r=new z(t,this.doc,this.selection,t.dynamicSlots.map(()=>null),(a,h)=>h.reconfigure(a,this),null).values);let o=e.startState.facet(br)?e.newSelection:e.newSelection.asSingle();new z(t,e.newDoc,o,r,(l,a)=>a.update(l,e),e)}replaceSelection(e){return typeof e=="string"&&(e=this.toText(e)),this.changeByRange(t=>({changes:{from:t.from,to:t.to,insert:e},range:y.cursor(t.from+e.length)}))}changeByRange(e){let t=this.selection,i=e(t.ranges[0]),s=this.changes(i.changes),r=[i.range],o=Jt(i.effects);for(let l=1;l<t.ranges.length;l++){let a=e(t.ranges[l]),h=this.changes(a.changes),c=h.map(s);for(let u=0;u<l;u++)r[u]=r[u].map(c);let f=s.mapDesc(h,!0);r.push(a.range.map(f)),s=s.compose(c),o=M.mapEffects(o,c).concat(M.mapEffects(Jt(a.effects),f))}return{changes:s,selection:y.create(r,t.mainIndex),effects:o}}changes(e=[]){return e instanceof ie?e:ie.of(e,this.doc.length,this.facet(z.lineSeparator))}toText(e){return E.of(e.split(this.facet(z.lineSeparator)||pr))}sliceDoc(e=0,t=this.doc.length){return this.doc.sliceString(e,t,this.lineBreak)}facet(e){let t=this.config.address[e.id];return t==null?e.default:(Zi(this,t),Yn(this,t))}toJSON(e){let t={doc:this.sliceDoc(),selection:this.selection.toJSON()};if(e)for(let i in e){let s=e[i];s instanceof ce&&this.config.address[s.id]!=null&&(t[i]=s.spec.toJSON(this.field(e[i]),this))}return t}static fromJSON(e,t={},i){if(!e||typeof e.doc!="string")throw new RangeError("Invalid JSON representation for EditorState");let s=[];if(i){for(let r in i)if(Object.prototype.hasOwnProperty.call(e,r)){let o=i[r],l=e[r];s.push(o.init(a=>o.spec.fromJSON(l,a)))}}return z.create({doc:e.doc,selection:y.fromJSON(e.selection),extensions:t.extensions?s.concat([t.extensions]):s})}static create(e={}){let t=Bn.resolve(e.extensions||[],new Map),i=e.doc instanceof E?e.doc:E.of((e.doc||"").split(t.staticFacet(z.lineSeparator)||pr)),s=e.selection?e.selection instanceof y?e.selection:y.single(e.selection.anchor,e.selection.head):y.single(0);return Oh(s,i.length),t.staticFacet(br)||(s=s.asSingle()),new z(t,i,s,t.dynamicSlots.map(()=>null),(r,o)=>o.create(r),null)}get tabSize(){return this.facet(z.tabSize)}get lineBreak(){return this.facet(z.lineSeparator)||`
@@ -23,4 +23,4 @@ import{r as $t,j as yu,i as bu}from"./index-BoqrvLHQ.js";import{k as Su,b as Qu,
23
23
  }`,{label:"class",detail:"definition",type:"keyword"}),pe('import {${names}} from "${module}"\n${}',{label:"import",detail:"named",type:"keyword"}),pe('import ${name} from "${module}"\n${}',{label:"import",detail:"default",type:"keyword"})],b1=jf.concat([pe("interface ${name} {\n ${}\n}",{label:"interface",detail:"definition",type:"keyword"}),pe("type ${name} = ${type}",{label:"type",detail:"definition",type:"keyword"}),pe("enum ${name} {\n ${}\n}",{label:"enum",detail:"definition",type:"keyword"})]),Ya=new Pp,Nf=new Set(["Script","Block","FunctionExpression","FunctionDeclaration","ArrowFunction","MethodDeclaration","ForStatement"]);function vi(n){return(e,t)=>{let i=e.node.getChild("VariableDefinition");return i&&t(i,n),!0}}const S1=["FunctionDeclaration"],Q1={FunctionDeclaration:vi("function"),ClassDeclaration:vi("class"),ClassExpression:()=>!0,EnumDeclaration:vi("constant"),TypeAliasDeclaration:vi("type"),NamespaceDeclaration:vi("namespace"),VariableDefinition(n,e){n.matchContext(S1)||e(n,"variable")},TypeDefinition(n,e){e(n,"type")},__proto__:null};function Gf(n,e){let t=Ya.get(e);if(t)return t;let i=[],s=!0;function r(o,l){let a=n.sliceString(o.from,o.to);i.push({label:a,type:l})}return e.cursor(U.IncludeAnonymous).iterate(o=>{if(s)s=!1;else if(o.name){let l=Q1[o.name];if(l&&l(o,r)||Nf.has(o.name))return!1}else if(o.to-o.from>8192){for(let l of Gf(n,o.node))i.push(l);return!1}}),Ya.set(e,i),i}const _a=/^[\w$\xa1-\uffff][\w$\d\xa1-\uffff]*$/,Uf=["TemplateString","String","RegExp","LineComment","BlockComment","VariableDefinition","TypeDefinition","Label","PropertyDefinition","PropertyName","PrivatePropertyDefinition","PrivatePropertyName","JSXText","JSXAttributeValue","JSXOpenTag","JSXCloseTag","JSXSelfClosingTag",".","?."];function k1(n){let e=te(n.state).resolveInner(n.pos,-1);if(Uf.indexOf(e.name)>-1)return null;let t=e.name=="VariableName"||e.to-e.from<20&&_a.test(n.state.sliceDoc(e.from,e.to));if(!t&&!n.explicit)return null;let i=[];for(let s=e;s;s=s.parent)Nf.has(s.name)&&(i=i.concat(Gf(n.state.doc,s)));return{options:i,from:t?e.from:n.pos,validFor:_a}}const zt=ui.define({name:"javascript",parser:y1.configure({props:[$s.add({IfStatement:ni({except:/^\s*({|else\b)/}),TryStatement:ni({except:/^\s*({|catch\b|finally\b)/}),LabeledStatement:Np,SwitchBody:n=>{let e=n.textAfter,t=/^\s*\}/.test(e),i=/^\s*(case|default)\b/.test(e);return n.baseIndent+(t?0:i?1:2)*n.unit},Block:jp({closing:"}"}),ArrowFunction:n=>n.baseIndent+n.unit,"TemplateString BlockComment":()=>null,"Statement Property":ni({except:/^\s*{/}),JSXElement(n){let e=/^\s*<\//.test(n.textAfter);return n.lineIndent(n.node.from)+(e?0:n.unit)},JSXEscape(n){let e=/\s*\}/.test(n.textAfter);return n.lineIndent(n.node.from)+(e?0:n.unit)},"JSXOpenTag JSXSelfClosingTag"(n){return n.column(n.node.from)+n.unit}}),Ps.add({"Block ClassBody SwitchBody EnumBody ObjectExpression ArrayExpression ObjectType":qc,BlockComment(n){return{from:n.from+2,to:n.to-2}},JSXElement(n){let e=n.firstChild;if(!e||e.name=="JSXSelfClosingTag")return null;let t=n.lastChild;return{from:e.to,to:t.type.isError?n.to:t.from}},"JSXSelfClosingTag JSXOpenTag"(n){var e;let t=(e=n.firstChild)===null||e===void 0?void 0:e.nextSibling,i=n.lastChild;return!t||t.type.isError?null:{from:t.to,to:i.type.isError?n.to:i.from}}})]}),languageData:{closeBrackets:{brackets:["(","[","{","'",'"',"`"]},commentTokens:{line:"//",block:{open:"/*",close:"*/"}},indentOnInput:/^\s*(?:case |default:|\{|\}|<\/)$/,wordChars:"$"}}),Ff={test:n=>/^JSX/.test(n.name),facet:Ec({commentTokens:{block:{open:"{/*",close:"*/}"}}})},w1=zt.configure({dialect:"ts"},"typescript"),v1=zt.configure({dialect:"jsx",props:[Lo.add(n=>n.isTop?[Ff]:void 0)]}),$1=zt.configure({dialect:"jsx ts",props:[Lo.add(n=>n.isTop?[Ff]:void 0)]},"typescript");let Hf=n=>({label:n,type:"keyword"});const Kf="break case const continue default delete export extends false finally in instanceof let new return static super switch this throw true typeof var yield".split(" ").map(Hf),P1=Kf.concat(["declare","implements","private","protected","public"].map(Hf));function qa(n={}){let e=n.jsx?n.typescript?$1:v1:n.typescript?w1:zt,t=n.typescript?b1.concat(P1):jf.concat(Kf);return new Do(e,[zt.data.of({autocomplete:nf(Uf,Eo(t))}),zt.data.of({autocomplete:k1}),n.jsx?Z1:[]])}function T1(n){for(;;){if(n.name=="JSXOpenTag"||n.name=="JSXSelfClosingTag"||n.name=="JSXFragmentTag")return n;if(n.name=="JSXEscape"||!n.parent)return null;n=n.parent}}function Va(n,e,t=n.length){for(let i=e?.firstChild;i;i=i.nextSibling)if(i.name=="JSXIdentifier"||i.name=="JSXBuiltin"||i.name=="JSXNamespacedName"||i.name=="JSXMemberExpression")return n.sliceString(i.from,Math.min(i.to,t));return""}const C1=typeof navigator=="object"&&/Android\b/.test(navigator.userAgent),Z1=$.inputHandler.of((n,e,t,i,s)=>{if((C1?n.composing:n.compositionStarted)||n.state.readOnly||e!=t||i!=">"&&i!="/"||!zt.isActiveAt(n.state,e,-1))return!1;let r=s(),{state:o}=r,l=o.changeByRange(a=>{var h;let{head:c}=a,f=te(o).resolveInner(c-1,-1),u;if(f.name=="JSXStartTag"&&(f=f.parent),!(o.doc.sliceString(c-1,c)!=i||f.name=="JSXAttributeValue"&&f.to>c)){if(i==">"&&f.name=="JSXFragmentTag")return{range:a,changes:{from:c,insert:"</>"}};if(i=="/"&&f.name=="JSXStartCloseTag"){let d=f.parent,O=d.parent;if(O&&d.from==c-2&&((u=Va(o.doc,O.firstChild,c))||((h=O.firstChild)===null||h===void 0?void 0:h.name)=="JSXFragmentTag")){let p=`${u}>`;return{range:y.cursor(c+p.length,-1),changes:{from:c,insert:p}}}}else if(i==">"){let d=T1(f);if(d&&d.name=="JSXOpenTag"&&!/^\/?>|^<\//.test(o.doc.sliceString(c,c+2))&&(u=Va(o.doc,d,c)))return{range:a,changes:{from:c,insert:`</${u}>`}}}}return{range:a}});return l.changes.empty?!1:(n.dispatch([r,o.update(l,{userEvent:"input.complete",scrollIntoView:!0})]),!0)}),A1=ks({String:g.string,Number:g.number,"True False":g.bool,PropertyName:g.propertyName,Null:g.null,", :":g.separator,"[ ]":g.squareBracket,"{ }":g.brace}),M1=Oi.deserialize({version:14,states:"$bOVQPOOOOQO'#Cb'#CbOnQPO'#CeOvQPO'#ClOOQO'#Cr'#CrQOQPOOOOQO'#Cg'#CgO}QPO'#CfO!SQPO'#CtOOQO,59P,59PO![QPO,59PO!aQPO'#CuOOQO,59W,59WO!iQPO,59WOVQPO,59QOqQPO'#CmO!nQPO,59`OOQO1G.k1G.kOVQPO'#CnO!vQPO,59aOOQO1G.r1G.rOOQO1G.l1G.lOOQO,59X,59XOOQO-E6k-E6kOOQO,59Y,59YOOQO-E6l-E6l",stateData:"#O~OeOS~OQSORSOSSOTSOWQO_ROgPO~OVXOgUO~O^[O~PVO[^O~O]_OVhX~OVaO~O]bO^iX~O^dO~O]_OVha~O]bO^ia~O",goto:"!kjPPPPPPkPPkqwPPPPk{!RPPP!XP!e!hXSOR^bQWQRf_TVQ_Q`WRg`QcZRicQTOQZRQe^RhbRYQR]R",nodeNames:"⚠ JsonText True False Null Number String } { Object Property PropertyName : , ] [ Array",maxTerm:25,nodeProps:[["isolate",-2,6,11,""],["openedBy",7,"{",14,"["],["closedBy",8,"}",15,"]"]],propSources:[A1],skippedNodes:[0],repeatNodeCount:2,tokenData:"(|~RaXY!WYZ!W]^!Wpq!Wrs!]|}$u}!O$z!Q!R%T!R![&c![!]&t!}#O&y#P#Q'O#Y#Z'T#b#c'r#h#i(Z#o#p(r#q#r(w~!]Oe~~!`Wpq!]qr!]rs!xs#O!]#O#P!}#P;'S!];'S;=`$o<%lO!]~!}Og~~#QXrs!]!P!Q!]#O#P!]#U#V!]#Y#Z!]#b#c!]#f#g!]#h#i!]#i#j#m~#pR!Q![#y!c!i#y#T#Z#y~#|R!Q![$V!c!i$V#T#Z$V~$YR!Q![$c!c!i$c#T#Z$c~$fR!Q![!]!c!i!]#T#Z!]~$rP;=`<%l!]~$zO]~~$}Q!Q!R%T!R![&c~%YRT~!O!P%c!g!h%w#X#Y%w~%fP!Q![%i~%nRT~!Q![%i!g!h%w#X#Y%w~%zR{|&T}!O&T!Q![&Z~&WP!Q![&Z~&`PT~!Q![&Z~&hST~!O!P%c!Q![&c!g!h%w#X#Y%w~&yO[~~'OO_~~'TO^~~'WP#T#U'Z~'^P#`#a'a~'dP#g#h'g~'jP#X#Y'm~'rOR~~'uP#i#j'x~'{P#`#a(O~(RP#`#a(U~(ZOS~~(^P#f#g(a~(dP#i#j(g~(jP#X#Y(m~(rOQ~~(wOW~~(|OV~",tokenizers:[0],topRules:{JsonText:[0,1]},tokenPrec:0}),R1=ui.define({name:"json",parser:M1.configure({props:[$s.add({Object:ni({except:/^\s*\}/}),Array:ni({except:/^\s*\]/})}),Ps.add({"Object Array":qc})]}),languageData:{closeBrackets:{brackets:["[","{",'"']},indentOnInput:/^\s*[\}\]]$/}});function X1(){return new Do(R1)}const L1=36,Ia=1,D1=2,It=3,cr=4,W1=5,E1=6,z1=7,B1=8,Y1=9,_1=10,q1=11,V1=12,I1=13,j1=14,N1=15,G1=16,U1=17,ja=18,F1=19,Jf=20,eu=21,Na=22,H1=23,K1=24;function oo(n){return n>=65&&n<=90||n>=97&&n<=122||n>=48&&n<=57}function J1(n){return n>=48&&n<=57||n>=97&&n<=102||n>=65&&n<=70}function Zt(n,e,t){for(let i=!1;;){if(n.next<0)return;if(n.next==e&&!i){n.advance();return}i=t&&!i&&n.next==92,n.advance()}}function ex(n,e){e:for(;;){if(n.next<0)return;if(n.next==36){n.advance();for(let t=0;t<e.length;t++){if(n.next!=e.charCodeAt(t))continue e;n.advance()}if(n.next==36){n.advance();return}}else n.advance()}}function tx(n,e){let t="[{<(".indexOf(String.fromCharCode(e)),i=t<0?e:"]}>)".charCodeAt(t);for(;;){if(n.next<0)return;if(n.next==i&&n.peek(1)==39){n.advance(2);return}n.advance()}}function lo(n,e){for(;!(n.next!=95&&!oo(n.next));)e!=null&&(e+=String.fromCharCode(n.next)),n.advance();return e}function ix(n){if(n.next==39||n.next==34||n.next==96){let e=n.next;n.advance(),Zt(n,e,!1)}else lo(n)}function Ga(n,e){for(;n.next==48||n.next==49;)n.advance();e&&n.next==e&&n.advance()}function Ua(n,e){for(;;){if(n.next==46){if(e)break;e=!0}else if(n.next<48||n.next>57)break;n.advance()}if(n.next==69||n.next==101)for(n.advance(),(n.next==43||n.next==45)&&n.advance();n.next>=48&&n.next<=57;)n.advance()}function Fa(n){for(;!(n.next<0||n.next==10);)n.advance()}function Tt(n,e){for(let t=0;t<e.length;t++)if(e.charCodeAt(t)==n)return!0;return!1}const fr=` \r
24
24
  `;function tu(n,e,t){let i=Object.create(null);i.true=i.false=W1,i.null=i.unknown=E1;for(let s of n.split(" "))s&&(i[s]=Jf);for(let s of e.split(" "))s&&(i[s]=eu);for(let s of(t||"").split(" "))s&&(i[s]=K1);return i}const nx="array binary bit boolean char character clob date decimal double float int integer interval large national nchar nclob numeric object precision real smallint time timestamp varchar varying ",sx="absolute action add after all allocate alter and any are as asc assertion at authorization before begin between both breadth by call cascade cascaded case cast catalog check close collate collation column commit condition connect connection constraint constraints constructor continue corresponding count create cross cube current current_date current_default_transform_group current_transform_group_for_type current_path current_role current_time current_timestamp current_user cursor cycle data day deallocate declare default deferrable deferred delete depth deref desc describe descriptor deterministic diagnostics disconnect distinct do domain drop dynamic each else elseif end end-exec equals escape except exception exec execute exists exit external fetch first for foreign found from free full function general get global go goto grant group grouping handle having hold hour identity if immediate in indicator initially inner inout input insert intersect into is isolation join key language last lateral leading leave left level like limit local localtime localtimestamp locator loop map match method minute modifies module month names natural nesting new next no none not of old on only open option or order ordinality out outer output overlaps pad parameter partial path prepare preserve primary prior privileges procedure public read reads recursive redo ref references referencing relative release repeat resignal restrict result return returns revoke right role rollback rollup routine row rows savepoint schema scroll search second section select session session_user set sets signal similar size some space specific specifictype sql sqlexception sqlstate sqlwarning start state static system_user table temporary then timezone_hour timezone_minute to trailing transaction translation treat trigger under undo union unique unnest until update usage user using value values view when whenever where while with without work write year zone ",ao={backslashEscapes:!1,hashComments:!1,spaceAfterDashes:!1,slashComments:!1,doubleQuotedStrings:!1,doubleDollarQuotedStrings:!1,unquotedBitLiterals:!1,treatBitsAsBytes:!1,charSetCasts:!1,plsqlQuotingMechanism:!1,operatorChars:"*+-%<>!=&|~^/",specialVar:"?",identifierQuotes:'"',caseInsensitiveIdentifiers:!1,words:tu(sx,nx)};function rx(n,e,t,i){let s={};for(let r in ao)s[r]=(n.hasOwnProperty(r)?n:ao)[r];return e&&(s.words=tu(e,t||"",i)),s}function iu(n){return new xi(e=>{var t;let{next:i}=e;if(e.advance(),Tt(i,fr)){for(;Tt(e.next,fr);)e.advance();e.acceptToken(L1)}else if(i==36&&n.doubleDollarQuotedStrings){let s=lo(e,"");e.next==36&&(e.advance(),ex(e,s),e.acceptToken(It))}else if(i==39||i==34&&n.doubleQuotedStrings)Zt(e,i,n.backslashEscapes),e.acceptToken(It);else if(i==35&&n.hashComments||i==47&&e.next==47&&n.slashComments)Fa(e),e.acceptToken(Ia);else if(i==45&&e.next==45&&(!n.spaceAfterDashes||e.peek(1)==32))Fa(e),e.acceptToken(Ia);else if(i==47&&e.next==42){e.advance();for(let s=1;;){let r=e.next;if(e.next<0)break;if(e.advance(),r==42&&e.next==47){if(s--,e.advance(),!s)break}else r==47&&e.next==42&&(s++,e.advance())}e.acceptToken(D1)}else if((i==101||i==69)&&e.next==39)e.advance(),Zt(e,39,!0),e.acceptToken(It);else if((i==110||i==78)&&e.next==39&&n.charSetCasts)e.advance(),Zt(e,39,n.backslashEscapes),e.acceptToken(It);else if(i==95&&n.charSetCasts)for(let s=0;;s++){if(e.next==39&&s>1){e.advance(),Zt(e,39,n.backslashEscapes),e.acceptToken(It);break}if(!oo(e.next))break;e.advance()}else if(n.plsqlQuotingMechanism&&(i==113||i==81)&&e.next==39&&e.peek(1)>0&&!Tt(e.peek(1),fr)){let s=e.peek(1);e.advance(2),tx(e,s),e.acceptToken(It)}else if(Tt(i,n.identifierQuotes)){const s=i==91?93:i;Zt(e,s,!1),e.acceptToken(F1)}else if(i==40)e.acceptToken(z1);else if(i==41)e.acceptToken(B1);else if(i==123)e.acceptToken(Y1);else if(i==125)e.acceptToken(_1);else if(i==91)e.acceptToken(q1);else if(i==93)e.acceptToken(V1);else if(i==59)e.acceptToken(I1);else if(n.unquotedBitLiterals&&i==48&&e.next==98)e.advance(),Ga(e),e.acceptToken(Na);else if((i==98||i==66)&&(e.next==39||e.next==34)){const s=e.next;e.advance(),n.treatBitsAsBytes?(Zt(e,s,n.backslashEscapes),e.acceptToken(H1)):(Ga(e,s),e.acceptToken(Na))}else if(i==48&&(e.next==120||e.next==88)||(i==120||i==88)&&e.next==39){let s=e.next==39;for(e.advance();J1(e.next);)e.advance();s&&e.next==39&&e.advance(),e.acceptToken(cr)}else if(i==46&&e.next>=48&&e.next<=57)Ua(e,!0),e.acceptToken(cr);else if(i==46)e.acceptToken(j1);else if(i>=48&&i<=57)Ua(e,!1),e.acceptToken(cr);else if(Tt(i,n.operatorChars)){for(;Tt(e.next,n.operatorChars);)e.advance();e.acceptToken(N1)}else if(Tt(i,n.specialVar))e.next==i&&e.advance(),ix(e),e.acceptToken(U1);else if(i==58||i==44)e.acceptToken(G1);else if(oo(i)){let s=lo(e,String.fromCharCode(i));e.acceptToken(e.next==46||e.peek(-s.length-1)==46?ja:(t=n.words[s.toLowerCase()])!==null&&t!==void 0?t:ja)}})}const nu=iu(ao),ox=Oi.deserialize({version:14,states:"%vQ]QQOOO#wQRO'#DSO$OQQO'#CwO%eQQO'#CxO%lQQO'#CyO%sQQO'#CzOOQQ'#DS'#DSOOQQ'#C}'#C}O'UQRO'#C{OOQQ'#Cv'#CvOOQQ'#C|'#C|Q]QQOOQOQQOOO'`QQO'#DOO(xQRO,59cO)PQQO,59cO)UQQO'#DSOOQQ,59d,59dO)cQQO,59dOOQQ,59e,59eO)jQQO,59eOOQQ,59f,59fO)qQQO,59fOOQQ-E6{-E6{OOQQ,59b,59bOOQQ-E6z-E6zOOQQ,59j,59jOOQQ-E6|-E6|O+VQRO1G.}O+^QQO,59cOOQQ1G/O1G/OOOQQ1G/P1G/POOQQ1G/Q1G/QP+kQQO'#C}O+rQQO1G.}O)PQQO,59cO,PQQO'#Cw",stateData:",[~OtOSPOSQOS~ORUOSUOTUOUUOVROXSOZTO]XO^QO_UO`UOaPObPOcPOdUOeUOfUOgUOhUO~O^]ORvXSvXTvXUvXVvXXvXZvX]vX_vX`vXavXbvXcvXdvXevXfvXgvXhvX~OsvX~P!jOa_Ob_Oc_O~ORUOSUOTUOUUOVROXSOZTO^tO_UO`UOa`Ob`Oc`OdUOeUOfUOgUOhUO~OWaO~P$ZOYcO~P$ZO[eO~P$ZORUOSUOTUOUUOVROXSOZTO^QO_UO`UOaPObPOcPOdUOeUOfUOgUOhUO~O]hOsoX~P%zOajObjOcjO~O^]ORkaSkaTkaUkaVkaXkaZka]ka_ka`kaakabkackadkaekafkagkahka~Oska~P'kO^]O~OWvXYvX[vX~P!jOWnO~P$ZOYoO~P$ZO[pO~P$ZO^]ORkiSkiTkiUkiVkiXkiZki]ki_ki`kiakibkickidkiekifkigkihki~Oski~P)xOWkaYka[ka~P'kO]hO~P$ZOWkiYki[ki~P)xOasObsOcsO~O",goto:"#hwPPPPPPPPPPPPPPPPPPPPPPPPPPx||||!Y!^!d!xPPP#[TYOZeUORSTWZbdfqT[OZQZORiZSWOZQbRQdSQfTZgWbdfqQ^PWk^lmrQl_Qm`RrseVORSTWZbdfq",nodeNames:"⚠ LineComment BlockComment String Number Bool Null ( ) { } [ ] ; . Operator Punctuation SpecialVar Identifier QuotedIdentifier Keyword Type Bits Bytes Builtin Script Statement CompositeIdentifier Parens Braces Brackets Statement",maxTerm:38,nodeProps:[["isolate",-4,1,2,3,19,""]],skippedNodes:[0,1,2],repeatNodeCount:3,tokenData:"RORO",tokenizers:[0,nu],topRules:{Script:[0,25]},tokenPrec:0});function ho(n){let e=n.cursor().moveTo(n.from,-1);for(;/Comment/.test(e.name);)e.moveTo(e.from,-1);return e.node}function Ui(n,e){let t=n.sliceString(e.from,e.to),i=/^([`'"\[])(.*)([`'"\]])$/.exec(t);return i?i[2]:t}function as(n){return n&&(n.name=="Identifier"||n.name=="QuotedIdentifier")}function lx(n,e){if(e.name=="CompositeIdentifier"){let t=[];for(let i=e.firstChild;i;i=i.nextSibling)as(i)&&t.push(Ui(n,i));return t}return[Ui(n,e)]}function Ha(n,e){for(let t=[];;){if(!e||e.name!=".")return t;let i=ho(e);if(!as(i))return t;t.unshift(Ui(n,i)),e=ho(i)}}function ax(n,e){let t=te(n).resolveInner(e,-1),i=cx(n.doc,t);return t.name=="Identifier"||t.name=="QuotedIdentifier"||t.name=="Keyword"?{from:t.from,quoted:t.name=="QuotedIdentifier"?n.doc.sliceString(t.from,t.from+1):null,parents:Ha(n.doc,ho(t)),aliases:i}:t.name=="."?{from:e,quoted:null,parents:Ha(n.doc,t),aliases:i}:{from:e,quoted:null,parents:[],empty:!0,aliases:i}}const hx=new Set("where group having order union intersect except all distinct limit offset fetch for".split(" "));function cx(n,e){let t;for(let s=e;!t;s=s.parent){if(!s)return null;s.name=="Statement"&&(t=s)}let i=null;for(let s=t.firstChild,r=!1,o=null;s;s=s.nextSibling){let l=s.name=="Keyword"?n.sliceString(s.from,s.to).toLowerCase():null,a=null;if(!r)r=l=="from";else if(l=="as"&&o&&as(s.nextSibling))a=Ui(n,s.nextSibling);else{if(l&&hx.has(l))break;o&&as(s)&&(a=Ui(n,s))}a&&(i||(i=Object.create(null)),i[a]=lx(n,o)),o=/Identifier$/.test(s.name)?s:null}return i}function fx(n,e,t){return t.map(i=>({...i,label:i.label[0]==n?i.label:n+i.label+e,apply:void 0}))}const ux=/^\w*$/,dx=/^[`'"\[]?\w*[`'"\]]?$/;function Ka(n){return n.self&&typeof n.self.label=="string"}class Fo{constructor(e,t){this.idQuote=e,this.idCaseInsensitive=t,this.list=[],this.children=void 0}child(e){let t=this.children||(this.children=Object.create(null)),i=t[e];return i||(e&&!this.list.some(s=>s.label==e)&&this.list.push(Ja(e,"type",this.idQuote,this.idCaseInsensitive)),t[e]=new Fo(this.idQuote,this.idCaseInsensitive))}maybeChild(e){return this.children?this.children[e]:null}addCompletion(e){let t=this.list.findIndex(i=>i.label==e.label);t>-1?this.list[t]=e:this.list.push(e)}addCompletions(e){for(let t of e)this.addCompletion(typeof t=="string"?Ja(t,"property",this.idQuote,this.idCaseInsensitive):t)}addNamespace(e){Array.isArray(e)?this.addCompletions(e):Ka(e)?this.addNamespace(e.children):this.addNamespaceObject(e)}addNamespaceObject(e){for(let t of Object.keys(e)){let i=e[t],s=null,r=t.replace(/\\?\./g,l=>l=="."?"\0":l).split("\0"),o=this;Ka(i)&&(s=i.self,i=i.children);for(let l=0;l<r.length;l++)s&&l==r.length-1&&o.addCompletion(s),o=o.child(r[l].replace(/\\\./g,"."));o.addNamespace(i)}}}function Ja(n,e,t,i){return new RegExp("^[a-z_][a-z_\\d]*$",i?"i":"").test(n)?{label:n,type:e}:{label:n,type:e,apply:t+n+su(t)}}function su(n){return n==="["?"]":n}function Ox(n,e,t,i,s,r){var o;let l=((o=r?.spec.identifierQuotes)===null||o===void 0?void 0:o[0])||'"',a=new Fo(l,!!r?.spec.caseInsensitiveIdentifiers),h=s?a.child(s):null;return a.addNamespace(n),e&&(h||a).addCompletions(e),t&&a.addCompletions(t),h&&a.addCompletions(h.list),i&&a.addCompletions((h||a).child(i).list),c=>{let{parents:f,from:u,quoted:d,empty:O,aliases:p}=ax(c.state,c.pos);if(O&&!c.explicit)return null;p&&f.length==1&&(f=p[f[0]]||f);let m=a;for(let b of f){for(;!m.children||!m.children[b];)if(m==a&&h)m=h;else if(m==h&&i)m=m.child(i);else return null;let S=m.maybeChild(b);if(!S)return null;m=S}let x=m.list;if(m==a&&p&&(x=x.concat(Object.keys(p).map(b=>({label:b,type:"constant"})))),d){let b=d[0],S=su(b),C=c.state.sliceDoc(c.pos,c.pos+1)==S;return{from:u,to:C?c.pos+1:void 0,options:fx(b,S,x),validFor:dx}}else return{from:u,options:x,validFor:ux}}}function px(n){return n==eu?"type":n==Jf?"keyword":"variable"}function mx(n,e,t){let i=Object.keys(n).map(s=>t(e?s.toUpperCase():s,px(n[s])));return nf(["QuotedIdentifier","String","LineComment","BlockComment","."],Eo(i))}let gx=ox.configure({props:[$s.add({Statement:ni()}),Ps.add({Statement(n,e){return{from:Math.min(n.from+100,e.doc.lineAt(n.from).to),to:n.to}},BlockComment(n){return{from:n.from+2,to:n.to-2}}}),ks({Keyword:g.keyword,Type:g.typeName,Builtin:g.standard(g.name),Bits:g.number,Bytes:g.string,Bool:g.bool,Null:g.null,Number:g.number,String:g.string,Identifier:g.name,QuotedIdentifier:g.special(g.string),SpecialVar:g.special(g.name),LineComment:g.lineComment,BlockComment:g.blockComment,Operator:g.operator,"Semi Punctuation":g.punctuation,"( )":g.paren,"{ }":g.brace,"[ ]":g.squareBracket})]});class hs{constructor(e,t,i){this.dialect=e,this.language=t,this.spec=i}get extension(){return this.language.extension}configureLanguage(e,t){return new hs(this.dialect,this.language.configure(e,t),this.spec)}static define(e){let t=rx(e,e.keywords,e.types,e.builtin),i=ui.define({name:"sql",parser:gx.configure({tokenizers:[{from:nu,to:iu(t)}]}),languageData:{commentTokens:{line:"--",block:{open:"/*",close:"*/"}},closeBrackets:{brackets:["(","[","{","'",'"',"`"]}}});return new hs(t,i,e)}}function xx(n,e){return{label:n,type:e,boost:-1}}function yx(n,e=!1,t){return mx(n.dialect.words,e,t||xx)}function bx(n){return n.schema?Ox(n.schema,n.tables,n.schemas,n.defaultTable,n.defaultSchema,n.dialect||Ho):()=>null}function Sx(n){return n.schema?(n.dialect||Ho).language.data.of({autocomplete:bx(n)}):[]}function Qx(n={}){let e=n.dialect||Ho;return new Do(e.language,[Sx(n),e.language.data.of({autocomplete:yx(e,n.upperCaseKeywords,n.keywordCompletion)})])}const Ho=hs.define({});class eh{constructor(e,t,i){this.from=e,this.to=t,this.diagnostic=i}}class Mt{constructor(e,t,i){this.diagnostics=e,this.panel=t,this.selected=i}static init(e,t,i){let s=i.facet(Fi).markerFilter;s&&(e=s(e,i));let r=e.slice().sort((d,O)=>d.from-O.from||d.to-O.to),o=new at,l=[],a=0,h=i.doc.iter(),c=0,f=i.doc.length;for(let d=0;;){let O=d==r.length?null:r[d];if(!O&&!l.length)break;let p,m;if(l.length)p=a,m=l.reduce((S,C)=>Math.min(S,C.to),O&&O.from>p?O.from:1e8);else{if(p=O.from,p>f)break;m=O.to,l.push(O),d++}for(;d<r.length;){let S=r[d];if(S.from==p&&(S.to>S.from||S.to==p))l.push(S),d++,m=Math.min(S.to,m);else{m=Math.min(S.from,m);break}}m=Math.min(m,f);let x=!1;if(l.some(S=>S.from==p&&(S.to==m||m==f))&&(x=p==m,!x&&m-p<10)){let S=p-(c+h.value.length);S>0&&(h.next(S),c=p);for(let C=p;;){if(C>=m){x=!0;break}if(!h.lineBreak&&c+h.value.length>C)break;C=c+h.value.length,c+=h.value.length,h.next()}}let b=Lx(l);if(x)o.add(p,p,Z.widget({widget:new Ax(b),diagnostics:l.slice()}));else{let S=l.reduce((C,Q)=>Q.markClass?C+" "+Q.markClass:C,"");o.add(p,m,Z.mark({class:"cm-lintRange cm-lintRange-"+b+S,diagnostics:l.slice(),inclusiveEnd:l.some(C=>C.to>m)}))}if(a=m,a==f)break;for(let S=0;S<l.length;S++)l[S].to<=a&&l.splice(S--,1)}let u=o.finish();return new Mt(u,t,Qt(u))}}function Qt(n,e=null,t=0){let i=null;return n.between(t,1e9,(s,r,{spec:o})=>{if(!(e&&o.diagnostics.indexOf(e)<0))if(!i)i=new eh(s,r,e||o.diagnostics[0]);else{if(o.diagnostics.indexOf(i.diagnostic)<0)return!1;i=new eh(i.from,r,i.diagnostic)}}),i}function kx(n,e){let t=e.pos,i=e.end||t,s=n.state.facet(Fi).hideOn(n,t,i);if(s!=null)return s;let r=n.startState.doc.lineAt(e.pos);return!!(n.effects.some(o=>o.is(ru))||n.changes.touchesRange(r.from,Math.max(r.to,i)))}function wx(n,e){return n.field(Te,!1)?e:e.concat(M.appendConfig.of(Dx))}const ru=M.define(),Ko=M.define(),ou=M.define(),Te=ce.define({create(){return new Mt(Z.none,null,null)},update(n,e){if(e.docChanged&&n.diagnostics.size){let t=n.diagnostics.map(e.changes),i=null,s=n.panel;if(n.selected){let r=e.changes.mapPos(n.selected.from,1);i=Qt(t,n.selected.diagnostic,r)||Qt(t,null,r)}!t.size&&s&&e.state.facet(Fi).autoPanel&&(s=null),n=new Mt(t,s,i)}for(let t of e.effects)if(t.is(ru)){let i=e.state.facet(Fi).autoPanel?t.value.length?Hi.open:null:n.panel;n=Mt.init(t.value,i,e.state)}else t.is(Ko)?n=new Mt(n.diagnostics,t.value?Hi.open:null,n.selected):t.is(ou)&&(n=new Mt(n.diagnostics,n.panel,t.value));return n},provide:n=>[qi.from(n,e=>e.panel),$.decorations.from(n,e=>e.diagnostics)]}),vx=Z.mark({class:"cm-lintRange cm-lintRange-active"});function $x(n,e,t){let{diagnostics:i}=n.state.field(Te),s,r=-1,o=-1;i.between(e-(t<0?1:0),e+(t>0?1:0),(a,h,{spec:c})=>{if(e>=a&&e<=h&&(a==h||(e>a||t>0)&&(e<h||t<0)))return s=c.diagnostics,r=a,o=h,!1});let l=n.state.facet(Fi).tooltipFilter;return s&&l&&(s=l(s,n.state)),s?{pos:r,end:o,above:n.state.doc.lineAt(r).to<o,create(){return{dom:Px(n,s)}}}:null}function Px(n,e){return _("ul",{class:"cm-tooltip-lint"},e.map(t=>au(n,t,!1)))}const Tx=n=>{let e=n.state.field(Te,!1);(!e||!e.panel)&&n.dispatch({effects:wx(n.state,[Ko.of(!0)])});let t=Zo(n,Hi.open);return t&&t.dom.querySelector(".cm-panel-lint ul").focus(),!0},th=n=>{let e=n.state.field(Te,!1);return!e||!e.panel?!1:(n.dispatch({effects:Ko.of(!1)}),!0)},Cx=n=>{let e=n.state.field(Te,!1);if(!e)return!1;let t=n.state.selection.main,i=Qt(e.diagnostics,null,t.to+1);return!i&&(i=Qt(e.diagnostics,null,0),!i||i.from==t.from&&i.to==t.to)?!1:(n.dispatch({selection:{anchor:i.from,head:i.to},scrollIntoView:!0}),lp(n,i.from,1,{tooltip:hu,until:s=>s.docChanged||s.newSelection.main.head<i.from||s.newSelection.main.head>i.to}),!0)},Zx=[{key:"Mod-Shift-m",run:Tx,preventDefault:!0},{key:"F8",run:Cx}],Fi=P.define({combine(n){return{sources:n.map(e=>e.source).filter(e=>e!=null),...nt(n.map(e=>e.config),{delay:750,markerFilter:null,tooltipFilter:null,needsRefresh:null,hideOn:()=>null},{delay:Math.max,markerFilter:ih,tooltipFilter:ih,needsRefresh:(e,t)=>e?t?i=>e(i)||t(i):e:t,hideOn:(e,t)=>e?t?(i,s,r)=>e(i,s,r)||t(i,s,r):e:t,autoPanel:(e,t)=>e||t})}}});function ih(n,e){return n?e?(t,i)=>e(n(t,i),i):n:e}function lu(n){let e=[];if(n)e:for(let{name:t}of n){for(let i=0;i<t.length;i++){let s=t[i];if(/[a-zA-Z]/.test(s)&&!e.some(r=>r.toLowerCase()==s.toLowerCase())){e.push(s);continue e}}e.push("")}return e}function au(n,e,t){var i;let s=t?lu(e.actions):[];return _("li",{class:"cm-diagnostic cm-diagnostic-"+e.severity},_("span",{class:"cm-diagnosticText"},e.renderMessage?e.renderMessage(n):e.message),(i=e.actions)===null||i===void 0?void 0:i.map((r,o)=>{let l=!1,a=d=>{if(d.preventDefault(),l)return;l=!0;let O=Qt(n.state.field(Te).diagnostics,e);O&&r.apply(n,O.from,O.to)},{name:h}=r,c=s[o]?h.indexOf(s[o]):-1,f=c<0?h:[h.slice(0,c),_("u",h.slice(c,c+1)),h.slice(c+1)],u=r.markClass?" "+r.markClass:"";return _("button",{type:"button",class:"cm-diagnosticAction"+u,onclick:a,onmousedown:a,"aria-label":` Action: ${h}${c<0?"":` (access key "${s[o]})"`}.`},f)}),e.source&&_("div",{class:"cm-diagnosticSource"},e.source))}class Ax extends Be{constructor(e){super(),this.sev=e}eq(e){return e.sev==this.sev}toDOM(){return _("span",{class:"cm-lintPoint cm-lintPoint-"+this.sev})}}class nh{constructor(e,t){this.diagnostic=t,this.id="item_"+Math.floor(Math.random()*4294967295).toString(16),this.dom=au(e,t,!0),this.dom.id=this.id,this.dom.setAttribute("role","option")}}class Hi{constructor(e){this.view=e,this.items=[];let t=s=>{if(!(s.ctrlKey||s.altKey||s.metaKey)){if(s.keyCode==27)th(this.view),this.view.focus();else if(s.keyCode==38||s.keyCode==33)this.moveSelection((this.selectedIndex-1+this.items.length)%this.items.length);else if(s.keyCode==40||s.keyCode==34)this.moveSelection((this.selectedIndex+1)%this.items.length);else if(s.keyCode==36)this.moveSelection(0);else if(s.keyCode==35)this.moveSelection(this.items.length-1);else if(s.keyCode==13)this.view.focus();else if(s.keyCode>=65&&s.keyCode<=90&&this.selectedIndex>=0){let{diagnostic:r}=this.items[this.selectedIndex],o=lu(r.actions);for(let l=0;l<o.length;l++)if(o[l].toUpperCase().charCodeAt(0)==s.keyCode){let a=Qt(this.view.state.field(Te).diagnostics,r);a&&r.actions[l].apply(e,a.from,a.to)}}else return;s.preventDefault()}},i=s=>{for(let r=0;r<this.items.length;r++)this.items[r].dom.contains(s.target)&&this.moveSelection(r)};this.list=_("ul",{tabIndex:0,role:"listbox","aria-label":this.view.state.phrase("Diagnostics"),onkeydown:t,onclick:i}),this.dom=_("div",{class:"cm-panel-lint"},this.list,_("button",{type:"button",name:"close","aria-label":this.view.state.phrase("close"),onclick:()=>th(this.view)},"×")),this.update()}get selectedIndex(){let e=this.view.state.field(Te).selected;if(!e)return-1;for(let t=0;t<this.items.length;t++)if(this.items[t].diagnostic==e.diagnostic)return t;return-1}update(){let{diagnostics:e,selected:t}=this.view.state.field(Te),i=0,s=!1,r=null,o=new Set;for(e.between(0,this.view.state.doc.length,(l,a,{spec:h})=>{for(let c of h.diagnostics){if(o.has(c))continue;o.add(c);let f=-1,u;for(let d=i;d<this.items.length;d++)if(this.items[d].diagnostic==c){f=d;break}f<0?(u=new nh(this.view,c),this.items.splice(i,0,u),s=!0):(u=this.items[f],f>i&&(this.items.splice(i,f-i),s=!0)),t&&u.diagnostic==t.diagnostic?u.dom.hasAttribute("aria-selected")||(u.dom.setAttribute("aria-selected","true"),r=u):u.dom.hasAttribute("aria-selected")&&u.dom.removeAttribute("aria-selected"),i++}});i<this.items.length&&!(this.items.length==1&&this.items[0].diagnostic.from<0);)s=!0,this.items.pop();this.items.length==0&&(this.items.push(new nh(this.view,{from:-1,to:-1,severity:"info",message:this.view.state.phrase("No diagnostics")})),s=!0),r?(this.list.setAttribute("aria-activedescendant",r.id),this.view.requestMeasure({key:this,read:()=>({sel:r.dom.getBoundingClientRect(),panel:this.list.getBoundingClientRect()}),write:({sel:l,panel:a})=>{let h=a.height/this.list.offsetHeight;l.top<a.top?this.list.scrollTop-=(a.top-l.top)/h:l.bottom>a.bottom&&(this.list.scrollTop+=(l.bottom-a.bottom)/h)}})):this.selectedIndex<0&&this.list.removeAttribute("aria-activedescendant"),s&&this.sync()}sync(){let e=this.list.firstChild;function t(){let i=e;e=i.nextSibling,i.remove()}for(let i of this.items)if(i.dom.parentNode==this.list){for(;e!=i.dom;)t();e=i.dom.nextSibling}else this.list.insertBefore(i.dom,e);for(;e;)t()}moveSelection(e){if(this.selectedIndex<0)return;let t=this.view.state.field(Te),i=Qt(t.diagnostics,this.items[e].diagnostic);i&&this.view.dispatch({selection:{anchor:i.from,head:i.to},scrollIntoView:!0,effects:ou.of(i)})}static open(e){return new Hi(e)}}function Mx(n,e='viewBox="0 0 40 40"'){return`url('data:image/svg+xml,<svg xmlns="http://www.w3.org/2000/svg" ${e}>${encodeURIComponent(n)}</svg>')`}function Cn(n){return Mx(`<path d="m0 2.5 l2 -1.5 l1 0 l2 1.5 l1 0" stroke="${n}" fill="none" stroke-width=".7"/>`,'width="6" height="3"')}const Rx=$.baseTheme({".cm-diagnostic":{padding:"3px 6px 3px 8px",marginLeft:"-1px",display:"block",whiteSpace:"pre-wrap"},".cm-diagnostic-error":{borderLeft:"5px solid #d11"},".cm-diagnostic-warning":{borderLeft:"5px solid orange"},".cm-diagnostic-info":{borderLeft:"5px solid #999"},".cm-diagnostic-hint":{borderLeft:"5px solid #66d"},".cm-diagnosticAction":{font:"inherit",border:"none",padding:"2px 4px",backgroundColor:"#444",color:"white",borderRadius:"3px",marginLeft:"8px",cursor:"pointer"},".cm-diagnosticSource":{fontSize:"70%",opacity:.7},".cm-lintRange":{backgroundPosition:"left bottom",backgroundRepeat:"repeat-x",paddingBottom:"0.7px"},".cm-lintRange-error":{backgroundImage:Cn("#f11")},".cm-lintRange-warning":{backgroundImage:Cn("orange")},".cm-lintRange-info":{backgroundImage:Cn("#999")},".cm-lintRange-hint":{backgroundImage:Cn("#66d")},".cm-lintRange-active":{backgroundColor:"#ffdd9980"},".cm-tooltip-lint":{padding:0,margin:0},".cm-lintPoint":{position:"relative","&:after":{content:'""',position:"absolute",bottom:0,left:"-2px",borderLeft:"3px solid transparent",borderRight:"3px solid transparent",borderBottom:"4px solid #d11"}},".cm-lintPoint-warning":{"&:after":{borderBottomColor:"orange"}},".cm-lintPoint-info":{"&:after":{borderBottomColor:"#999"}},".cm-lintPoint-hint":{"&:after":{borderBottomColor:"#66d"}},".cm-panel.cm-panel-lint":{position:"relative","& ul":{maxHeight:"100px",overflowY:"auto","& [aria-selected]":{backgroundColor:"#ddd","& u":{textDecoration:"underline"}},"&:focus [aria-selected]":{background_fallback:"#bdf",backgroundColor:"Highlight",color_fallback:"white",color:"HighlightText"},"& u":{textDecoration:"none"},padding:0,margin:0},"& [name=close]":{position:"absolute",top:"0",right:"2px",background:"inherit",border:"none",font:"inherit",padding:0,margin:0}},"&dark .cm-lintRange-active":{backgroundColor:"#86714a80"},"&dark .cm-panel.cm-panel-lint ul":{"& [aria-selected]":{backgroundColor:"#2e343e"}}});function Xx(n){return n=="error"?4:n=="warning"?3:n=="info"?2:1}function Lx(n){let e="hint",t=1;for(let i of n){let s=Xx(i.severity);s>t&&(t=s,e=i.severity)}return e}const hu=op($x,{hideOn:kx}),Dx=[Te,$.decorations.compute([Te],n=>{let{selected:e,panel:t}=n.field(Te);return!e||!t||e.from==e.to?Z.none:Z.set([vx.range(e.from,e.to)])}),hu,Rx],sh=typeof String.prototype.normalize=="function"?n=>n.normalize("NFKD"):n=>n;class pi{constructor(e,t,i=0,s=e.length,r,o){this.test=o,this.value={from:0,to:0,precise:!1},this.done=!1,this.matches=[],this.buffer="",this.bufferPos=0,this.iter=e.iterRange(i,s),this.bufferStart=i,this.normalize=r?l=>r(sh(l)):sh,this.query=this.normalize(t)}peek(){if(this.bufferPos==this.buffer.length){if(this.bufferStart+=this.buffer.length,this.iter.next(),this.iter.done)return-1;this.bufferPos=0,this.buffer=this.iter.value}return me(this.buffer,this.bufferPos)}next(){for(;this.matches.length;)this.matches.pop();return this.nextOverlapping()}nextOverlapping(){for(;;){let e=this.peek();if(e<0)return this.done=!0,this;let t=fo(e),i=this.bufferStart+this.bufferPos;this.bufferPos+=Fe(e);let s=this.normalize(t);if(s.length)for(let r=0,o=i,l=!0;;r++){let a=s.charCodeAt(r),h=this.match(a,o,l,this.bufferPos+this.bufferStart,r==s.length-1);if(h)return this.value=h,this;if(r==s.length-1)break;l&&r<t.length&&t.charCodeAt(r)==a?o++:l=!1}}}match(e,t,i,s,r){let o=null;for(let l=0;l<this.matches.length;){let a=this.matches[l],h=!1;this.query.charCodeAt(a.index)==e&&(a.index==this.query.length-1?o={from:a.from,to:s,precise:r&&a.precise}:(a.index++,h=!0)),h?l++:this.matches.splice(l,1)}return this.query.charCodeAt(0)==e&&(this.query.length==1?o={from:t,to:s,precise:i&&r}:this.matches.push({from:t,index:1,precise:i})),o&&this.test&&!this.test(o.from,o.to,this.buffer,this.bufferStart)&&(o=null),o}}typeof Symbol<"u"&&(pi.prototype[Symbol.iterator]=function(){return this});const cu={from:-1,to:-1,match:/.*/.exec(""),precise:!0},Jo="gm"+(/x/.unicode==null?"":"u");class fu{constructor(e,t,i,s=0,r=e.length){if(this.text=e,this.to=r,this.curLine="",this.done=!1,this.value=cu,/\\[sWDnr]|\n|\r|\[\^/.test(t))return new uu(e,t,i,s,r);this.re=new RegExp(t,Jo+(i?.ignoreCase?"i":"")),this.test=i?.test,this.iter=e.iter();let o=e.lineAt(s);this.curLineStart=o.from,this.matchPos=cs(e,s),this.getLine(this.curLineStart)}getLine(e){this.iter.next(e),this.iter.lineBreak?this.curLine="":(this.curLine=this.iter.value,this.curLineStart+this.curLine.length>this.to&&(this.curLine=this.curLine.slice(0,this.to-this.curLineStart)),this.iter.next())}nextLine(){this.curLineStart=this.curLineStart+this.curLine.length+1,this.curLineStart>this.to?this.curLine="":this.getLine(0)}next(){for(let e=this.matchPos-this.curLineStart;;){this.re.lastIndex=e;let t=this.matchPos<=this.to&&this.re.exec(this.curLine);if(t){let i=this.curLineStart+t.index,s=i+t[0].length;if(this.matchPos=cs(this.text,s+(i==s?1:0)),i==this.curLineStart+this.curLine.length&&this.nextLine(),(i<s||i>this.value.to)&&(!this.test||this.test(i,s,t)))return this.value={from:i,to:s,precise:!0,match:t},this;e=this.matchPos-this.curLineStart}else if(this.curLineStart+this.curLine.length<this.to)this.nextLine(),e=0;else return this.done=!0,this}}}const ur=new WeakMap;class oi{constructor(e,t){this.from=e,this.text=t}get to(){return this.from+this.text.length}static get(e,t,i){let s=ur.get(e);if(!s||s.from>=i||s.to<=t){let l=new oi(t,e.sliceString(t,i));return ur.set(e,l),l}if(s.from==t&&s.to==i)return s;let{text:r,from:o}=s;return o>t&&(r=e.sliceString(t,o)+r,o=t),s.to<i&&(r+=e.sliceString(s.to,i)),ur.set(e,new oi(o,r)),new oi(t,r.slice(t-o,i-o))}}class uu{constructor(e,t,i,s,r){this.text=e,this.to=r,this.done=!1,this.value=cu,this.matchPos=cs(e,s),this.re=new RegExp(t,Jo+(i?.ignoreCase?"i":"")),this.test=i?.test,this.flat=oi.get(e,s,this.chunkEnd(s+5e3))}chunkEnd(e){return e>=this.to?this.to:this.text.lineAt(e).to}next(){for(;;){let e=this.re.lastIndex=this.matchPos-this.flat.from,t=this.re.exec(this.flat.text);if(t&&!t[0]&&t.index==e&&(this.re.lastIndex=e+1,t=this.re.exec(this.flat.text)),t){let i=this.flat.from+t.index,s=i+t[0].length;if((this.flat.to>=this.to||t.index+t[0].length<=this.flat.text.length-10)&&(!this.test||this.test(i,s,t)))return this.value={from:i,to:s,precise:!0,match:t},this.matchPos=cs(this.text,s+(i==s?1:0)),this}if(this.flat.to==this.to)return this.done=!0,this;this.flat=oi.get(this.text,this.flat.from,this.chunkEnd(this.flat.from+this.flat.text.length*2))}}}typeof Symbol<"u"&&(fu.prototype[Symbol.iterator]=uu.prototype[Symbol.iterator]=function(){return this});function Wx(n){try{return new RegExp(n,Jo),!0}catch{return!1}}function cs(n,e){if(e>=n.length)return e;let t=n.lineAt(e),i;for(;e<t.to&&(i=t.text.charCodeAt(e-t.from))>=56320&&i<57344;)e++;return e}const Ex=n=>{let{state:e}=n,t=String(e.doc.lineAt(n.state.selection.main.head).number),{close:i,result:s}=hp(n,{label:e.phrase("Go to line"),input:{type:"text",name:"line",value:t},focus:!0,submitLabel:e.phrase("go")});return s.then(r=>{let o=r&&/^([+-])?(\d+)?(:\d+)?(%)?$/.exec(r.elements.line.value);if(!o){n.dispatch({effects:i});return}let l=e.doc.lineAt(e.selection.main.head),[,a,h,c,f]=o,u=c?+c.slice(1):0,d=h?+h:l.number;if(h&&f){let m=d/100;a&&(m=m*(a=="-"?-1:1)+l.number/e.doc.lines),d=Math.round(e.doc.lines*m)}else h&&a&&(d=d*(a=="-"?-1:1)+l.number);let O=e.doc.line(Math.max(1,Math.min(e.doc.lines,d))),p=y.cursor(O.from+Math.max(0,Math.min(u,O.length)));n.dispatch({effects:[i,$.scrollIntoView(p.from,{y:"center"})],selection:p})}),!0},zx={highlightWordAroundCursor:!1,minSelectionLength:1,maxMatches:100,wholeWords:!1},Bx=P.define({combine(n){return nt(n,zx,{highlightWordAroundCursor:(e,t)=>e||t,minSelectionLength:Math.min,maxMatches:Math.min})}});function Yx(n){return[jx,Ix]}const _x=Z.mark({class:"cm-selectionMatch"}),qx=Z.mark({class:"cm-selectionMatch cm-selectionMatch-main"});function rh(n,e,t,i){return(t==0||n(e.sliceDoc(t-1,t))!=G.Word)&&(i==e.doc.length||n(e.sliceDoc(i,i+1))!=G.Word)}function Vx(n,e,t,i){return n(e.sliceDoc(t,t+1))==G.Word&&n(e.sliceDoc(i-1,i))==G.Word}const Ix=ee.fromClass(class{constructor(n){this.decorations=this.getDeco(n)}update(n){(n.selectionSet||n.docChanged||n.viewportChanged)&&(this.decorations=this.getDeco(n.view))}getDeco(n){let e=n.state.facet(Bx),{state:t}=n,i=t.selection;if(i.ranges.length>1)return Z.none;let s=i.main,r,o=null;if(s.empty){if(!e.highlightWordAroundCursor)return Z.none;let a=t.wordAt(s.head);if(!a)return Z.none;o=t.charCategorizer(s.head),r=t.sliceDoc(a.from,a.to)}else{let a=s.to-s.from;if(a<e.minSelectionLength||a>200)return Z.none;if(e.wholeWords){if(r=t.sliceDoc(s.from,s.to),o=t.charCategorizer(s.head),!(rh(o,t,s.from,s.to)&&Vx(o,t,s.from,s.to)))return Z.none}else if(r=t.sliceDoc(s.from,s.to),!r)return Z.none}let l=[];for(let a of n.visibleRanges){let h=new pi(t.doc,r,a.from,a.to);for(;!h.next().done;){let{from:c,to:f}=h.value;if((!o||rh(o,t,c,f))&&(s.empty&&c<=s.from&&f>=s.to?l.push(qx.range(c,f)):(c>=s.to||f<=s.from)&&l.push(_x.range(c,f)),l.length>e.maxMatches))return Z.none}}return Z.set(l)}},{decorations:n=>n.decorations}),jx=$.baseTheme({".cm-selectionMatch":{backgroundColor:"#99ff7780"},".cm-searchMatch .cm-selectionMatch":{backgroundColor:"transparent"}}),Nx=({state:n,dispatch:e})=>{let{selection:t}=n,i=y.create(t.ranges.map(s=>n.wordAt(s.head)||y.cursor(s.head)),t.mainIndex);return i.eq(t)?!1:(e(n.update({selection:i})),!0)};function Gx(n,e){let{main:t,ranges:i}=n.selection,s=n.wordAt(t.head),r=s&&s.from==t.from&&s.to==t.to;for(let o=!1,l=new pi(n.doc,e,i[i.length-1].to);;)if(l.next(),l.done){if(o)return null;l=new pi(n.doc,e,0,Math.max(0,i[i.length-1].from-1)),o=!0}else{if(o&&i.some(a=>a.from==l.value.from))continue;if(r){let a=n.wordAt(l.value.from);if(!a||a.from!=l.value.from||a.to!=l.value.to)continue}return l.value}}const Ux=({state:n,dispatch:e})=>{let{ranges:t}=n.selection;if(t.some(r=>r.from===r.to))return Nx({state:n,dispatch:e});let i=n.sliceDoc(t[0].from,t[0].to);if(n.selection.ranges.some(r=>n.sliceDoc(r.from,r.to)!=i))return!1;let s=Gx(n,i);return s?(e(n.update({selection:n.selection.addRange(y.range(s.from,s.to),!1),effects:$.scrollIntoView(s.to)})),!0):!1},yi=P.define({combine(n){return nt(n,{top:!1,caseSensitive:!1,literal:!1,regexp:!1,wholeWord:!1,createPanel:e=>new hy(e),scrollToMatch:e=>$.scrollIntoView(e)})}});class du{constructor(e){this.search=e.search,this.caseSensitive=!!e.caseSensitive,this.literal=!!e.literal,this.regexp=!!e.regexp,this.replace=e.replace||"",this.valid=!!this.search&&(!this.regexp||Wx(this.search)),this.unquoted=this.unquote(this.search),this.wholeWord=!!e.wholeWord,this.test=e.test}unquote(e){return this.literal?e:e.replace(/\\([nrt\\])/g,(t,i)=>i=="n"?`
25
25
  `:i=="r"?"\r":i=="t"?" ":"\\")}eq(e){return this.search==e.search&&this.replace==e.replace&&this.caseSensitive==e.caseSensitive&&this.regexp==e.regexp&&this.wholeWord==e.wholeWord&&this.test==e.test}create(){return this.regexp?new ty(this):new Kx(this)}getCursor(e,t=0,i){let s=e.doc?e:z.create({doc:e});return i==null&&(i=s.doc.length),this.regexp?Gt(this,s,t,i):Nt(this,s,t,i)}}class Ou{constructor(e){this.spec=e}}function Fx(n,e,t){return(i,s,r,o)=>{if(t&&!t(i,s,r,o))return!1;let l=i>=o&&s<=o+r.length?r.slice(i-o,s-o):e.doc.sliceString(i,s);return n(l,e,i,s)}}function Nt(n,e,t,i){let s;return n.wholeWord&&(s=Hx(e.doc,e.charCategorizer(e.selection.main.head))),n.test&&(s=Fx(n.test,e,s)),new pi(e.doc,n.unquoted,t,i,n.caseSensitive?void 0:r=>r.toLowerCase(),s)}function Hx(n,e){return(t,i,s,r)=>((r>t||r+s.length<i)&&(r=Math.max(0,t-2),s=n.sliceString(r,Math.min(n.length,i+2))),(e(fs(s,t-r))!=G.Word||e(us(s,t-r))!=G.Word)&&(e(us(s,i-r))!=G.Word||e(fs(s,i-r))!=G.Word))}class Kx extends Ou{constructor(e){super(e)}nextMatch(e,t,i){let s=Nt(this.spec,e,i,e.doc.length).nextOverlapping();if(s.done){let r=Math.min(e.doc.length,t+this.spec.unquoted.length);s=Nt(this.spec,e,0,r).nextOverlapping()}return s.done||s.value.from==t&&s.value.to==i?null:s.value}prevMatchInRange(e,t,i){for(let s=i;;){let r=Math.max(t,s-1e4-this.spec.unquoted.length),o=Nt(this.spec,e,r,s),l=null;for(;!o.nextOverlapping().done;)l=o.value;if(l)return l;if(r==t)return null;s-=1e4}}prevMatch(e,t,i){let s=this.prevMatchInRange(e,0,t);return s||(s=this.prevMatchInRange(e,Math.max(0,i-this.spec.unquoted.length),e.doc.length)),s&&(s.from!=t||s.to!=i)?s:null}getReplacement(e){return this.spec.unquote(this.spec.replace)}matchAll(e,t){let i=Nt(this.spec,e,0,e.doc.length),s=[];for(;!i.next().done;){if(s.length>=t)return null;s.push(i.value)}return s}highlight(e,t,i,s){let r=Nt(this.spec,e,Math.max(0,t-this.spec.unquoted.length),Math.min(i+this.spec.unquoted.length,e.doc.length));for(;!r.next().done;)s(r.value.from,r.value.to)}}function Jx(n,e,t){return(i,s,r)=>(!t||t(i,s,r))&&n(r[0],e,i,s)}function Gt(n,e,t,i){let s;return n.wholeWord&&(s=ey(e.charCategorizer(e.selection.main.head))),n.test&&(s=Jx(n.test,e,s)),new fu(e.doc,n.search,{ignoreCase:!n.caseSensitive,test:s},t,i)}function fs(n,e){return n.slice(se(n,e,!1),e)}function us(n,e){return n.slice(e,se(n,e))}function ey(n){return(e,t,i)=>!i[0].length||(n(fs(i.input,i.index))!=G.Word||n(us(i.input,i.index))!=G.Word)&&(n(us(i.input,i.index+i[0].length))!=G.Word||n(fs(i.input,i.index+i[0].length))!=G.Word)}class ty extends Ou{nextMatch(e,t,i){let s=Gt(this.spec,e,i,e.doc.length).next();return s.done&&(s=Gt(this.spec,e,0,t).next()),s.done?null:s.value}prevMatchInRange(e,t,i){for(let s=1;;s++){let r=Math.max(t,i-s*1e4),o=Gt(this.spec,e,r,i),l=null;for(;!o.next().done;)l=o.value;if(l&&(r==t||l.from>r+10))return l;if(r==t)return null}}prevMatch(e,t,i){return this.prevMatchInRange(e,0,t)||this.prevMatchInRange(e,i,e.doc.length)}getReplacement(e){return this.spec.unquote(this.spec.replace).replace(/\$([$&]|\d+)/g,(t,i)=>{if(i=="&")return e.match[0];if(i=="$")return"$";for(let s=i.length;s>0;s--){let r=+i.slice(0,s);if(r>0&&r<e.match.length)return e.match[r]+i.slice(s)}return t})}matchAll(e,t){let i=Gt(this.spec,e,0,e.doc.length),s=[];for(;!i.next().done;){if(s.length>=t)return null;s.push(i.value)}return s}highlight(e,t,i,s){let r=Gt(this.spec,e,Math.max(0,t-250),Math.min(i+250,e.doc.length));for(;!r.next().done;)s(r.value.from,r.value.to)}}const Ki=M.define(),el=M.define(),pt=ce.define({create(n){return new dr(co(n).create(),null)},update(n,e){for(let t of e.effects)t.is(Ki)?n=new dr(t.value.create(),n.panel):t.is(el)&&(n=new dr(n.query,t.value?tl:null));return n},provide:n=>qi.from(n,e=>e.panel)});class dr{constructor(e,t){this.query=e,this.panel=t}}const iy=Z.mark({class:"cm-searchMatch"}),ny=Z.mark({class:"cm-searchMatch cm-searchMatch-selected"}),sy=ee.fromClass(class{constructor(n){this.view=n,this.decorations=this.highlight(n.state.field(pt))}update(n){let e=n.state.field(pt);(e!=n.startState.field(pt)||n.docChanged||n.selectionSet||n.viewportChanged)&&(this.decorations=this.highlight(e))}highlight({query:n,panel:e}){if(!e||!n.spec.valid)return Z.none;let{view:t}=this,i=new at;for(let s=0,r=t.visibleRanges,o=r.length;s<o;s++){let{from:l,to:a}=r[s];for(;s<o-1&&a>r[s+1].from-500;)a=r[++s].to;n.highlight(t.state,l,a,(h,c)=>{let f=t.state.selection.ranges.some(u=>u.from==h&&u.to==c);i.add(h,c,f?ny:iy)})}return i.finish()}},{decorations:n=>n.decorations});function ln(n){return e=>{let t=e.state.field(pt,!1);return t&&t.query.spec.valid?n(e,t):gu(e)}}const ds=ln((n,{query:e})=>{let{to:t}=n.state.selection.main,i=e.nextMatch(n.state,t,t);if(!i)return!1;let s=y.single(i.from,i.to),r=n.state.facet(yi);return n.dispatch({selection:s,effects:[il(n,i),r.scrollToMatch(s.main,n)],userEvent:"select.search"}),mu(n),!0}),Os=ln((n,{query:e})=>{let{state:t}=n,{from:i}=t.selection.main,s=e.prevMatch(t,i,i);if(!s)return!1;let r=y.single(s.from,s.to),o=n.state.facet(yi);return n.dispatch({selection:r,effects:[il(n,s),o.scrollToMatch(r.main,n)],userEvent:"select.search"}),mu(n),!0}),ry=ln((n,{query:e})=>{let t=e.matchAll(n.state,1e3);return!t||!t.length?!1:(n.dispatch({selection:y.create(t.map(i=>y.range(i.from,i.to))),userEvent:"select.search.matches"}),!0)}),oy=({state:n,dispatch:e})=>{let t=n.selection;if(t.ranges.length>1||t.main.empty)return!1;let{from:i,to:s}=t.main,r=[],o=0;for(let l=new pi(n.doc,n.sliceDoc(i,s));!l.next().done;){if(r.length>1e3)return!1;l.value.from==i&&(o=r.length),r.push(y.range(l.value.from,l.value.to))}return e(n.update({selection:y.create(r,o),userEvent:"select.search.matches"})),!0},oh=ln((n,{query:e})=>{let{state:t}=n,{from:i,to:s}=t.selection.main;if(t.readOnly)return!1;let r=e.nextMatch(t,i,i);if(!r)return!1;let o=r,l=[],a,h,c=[];o.precise?o.from==i&&o.to==s&&(h=t.toText(e.getReplacement(o)),l.push({from:o.from,to:o.to,insert:h}),c.push($.announce.of(t.phrase("replaced match on line $",t.doc.lineAt(i).number)+"."))):o=e.nextMatch(t,o.from,o.to);let f=n.state.changes(l);return o&&(a=y.single(o.from,o.to).map(f),c.push(il(n,o)),c.push(t.facet(yi).scrollToMatch(a.main,n))),n.dispatch({changes:f,selection:a,effects:c,userEvent:"input.replace"}),!0}),ly=ln((n,{query:e})=>{if(n.state.readOnly)return!1;let t=[];for(let s of e.matchAll(n.state,1e9)){let{from:r,to:o,precise:l}=s;l&&t.push({from:r,to:o,insert:e.getReplacement(s)})}if(!t.length)return!1;let i=n.state.phrase("replaced $ matches",t.length)+".";return n.dispatch({changes:t,effects:$.announce.of(i),userEvent:"input.replace.all"}),!0});function tl(n){return n.state.facet(yi).createPanel(n)}function co(n,e){var t,i,s,r,o;let l=n.selection.main,a=l.empty||l.to>l.from+100?"":n.sliceDoc(l.from,l.to);if(e&&!a)return e;let h=n.facet(yi);return new du({search:((t=e?.literal)!==null&&t!==void 0?t:h.literal)?a:a.replace(/\n/g,"\\n"),caseSensitive:(i=e?.caseSensitive)!==null&&i!==void 0?i:h.caseSensitive,literal:(s=e?.literal)!==null&&s!==void 0?s:h.literal,regexp:(r=e?.regexp)!==null&&r!==void 0?r:h.regexp,wholeWord:(o=e?.wholeWord)!==null&&o!==void 0?o:h.wholeWord})}function pu(n){let e=Zo(n,tl);return e&&e.dom.querySelector("[main-field]")}function mu(n){let e=pu(n);e&&e==n.root.activeElement&&e.select()}const gu=n=>{let e=n.state.field(pt,!1);if(e&&e.panel){let t=pu(n);if(t&&t!=n.root.activeElement){let i=co(n.state,e.query.spec);i.valid&&n.dispatch({effects:Ki.of(i)}),t.focus(),t.select()}}else n.dispatch({effects:[el.of(!0),e?Ki.of(co(n.state,e.query.spec)):M.appendConfig.of(fy)]});return!0},xu=n=>{let e=n.state.field(pt,!1);if(!e||!e.panel)return!1;let t=Zo(n,tl);return t&&t.dom.contains(n.root.activeElement)&&n.focus(),n.dispatch({effects:el.of(!1)}),!0},ay=[{key:"Mod-f",run:gu,scope:"editor search-panel"},{key:"F3",run:ds,shift:Os,scope:"editor search-panel",preventDefault:!0},{key:"Mod-g",run:ds,shift:Os,scope:"editor search-panel",preventDefault:!0},{key:"Escape",run:xu,scope:"editor search-panel"},{key:"Mod-Shift-l",run:oy},{key:"Mod-Alt-g",run:Ex},{key:"Mod-d",run:Ux,preventDefault:!0}];class hy{constructor(e){this.view=e;let t=this.query=e.state.field(pt).query.spec;this.commit=this.commit.bind(this),this.searchField=_("input",{value:t.search,placeholder:$e(e,"Find"),"aria-label":$e(e,"Find"),class:"cm-textfield",name:"search",form:"","main-field":"true",onchange:this.commit,onkeyup:this.commit}),this.replaceField=_("input",{value:t.replace,placeholder:$e(e,"Replace"),"aria-label":$e(e,"Replace"),class:"cm-textfield",name:"replace",form:"",onchange:this.commit,onkeyup:this.commit}),this.caseField=_("input",{type:"checkbox",name:"case",form:"",checked:t.caseSensitive,onchange:this.commit}),this.reField=_("input",{type:"checkbox",name:"re",form:"",checked:t.regexp,onchange:this.commit}),this.wordField=_("input",{type:"checkbox",name:"word",form:"",checked:t.wholeWord,onchange:this.commit});function i(s,r,o){return _("button",{class:"cm-button",name:s,onclick:r,type:"button"},o)}this.dom=_("div",{onkeydown:s=>this.keydown(s),class:"cm-search"},[this.searchField,i("next",()=>ds(e),[$e(e,"next")]),i("prev",()=>Os(e),[$e(e,"previous")]),i("select",()=>ry(e),[$e(e,"all")]),_("label",null,[this.caseField,$e(e,"match case")]),_("label",null,[this.reField,$e(e,"regexp")]),_("label",null,[this.wordField,$e(e,"by word")]),...e.state.readOnly?[]:[_("br"),this.replaceField,i("replace",()=>oh(e),[$e(e,"replace")]),i("replaceAll",()=>ly(e),[$e(e,"replace all")])],_("button",{name:"close",onclick:()=>xu(e),"aria-label":$e(e,"close"),type:"button"},["×"])])}commit(){let e=new du({search:this.searchField.value,caseSensitive:this.caseField.checked,regexp:this.reField.checked,wholeWord:this.wordField.checked,replace:this.replaceField.value});e.eq(this.query)||(this.query=e,this.view.dispatch({effects:Ki.of(e)}))}keydown(e){PO(this.view,e,"search-panel")?e.preventDefault():e.keyCode==13&&e.target==this.searchField?(e.preventDefault(),(e.shiftKey?Os:ds)(this.view)):e.keyCode==13&&e.target==this.replaceField&&(e.preventDefault(),oh(this.view))}update(e){for(let t of e.transactions)for(let i of t.effects)i.is(Ki)&&!i.value.eq(this.query)&&this.setQuery(i.value)}setQuery(e){this.query=e,this.searchField.value=e.search,this.replaceField.value=e.replace,this.caseField.checked=e.caseSensitive,this.reField.checked=e.regexp,this.wordField.checked=e.wholeWord}mount(){this.searchField.select()}get pos(){return 80}get top(){return this.view.state.facet(yi).top}}function $e(n,e){return n.state.phrase(e)}const Zn=30,An=/[\s\.,:;?!]/;function il(n,{from:e,to:t}){let i=n.state.doc.lineAt(e),s=n.state.doc.lineAt(t).to,r=Math.max(i.from,e-Zn),o=Math.min(s,t+Zn),l=n.state.sliceDoc(r,o);if(r!=i.from){for(let a=0;a<Zn;a++)if(!An.test(l[a+1])&&An.test(l[a])){l=l.slice(a);break}}if(o!=s){for(let a=l.length-1;a>l.length-Zn;a--)if(!An.test(l[a-1])&&An.test(l[a])){l=l.slice(0,a);break}}return $.announce.of(`${n.state.phrase("current match")}. ${l} ${n.state.phrase("on line")} ${i.number}.`)}const cy=$.baseTheme({".cm-panel.cm-search":{padding:"2px 6px 4px",position:"relative","& [name=close]":{position:"absolute",top:"0",right:"4px",backgroundColor:"inherit",border:"none",font:"inherit",padding:0,margin:0},"& input, & button, & label":{margin:".2em .6em .2em 0"},"& input[type=checkbox]":{marginRight:".2em"},"& label":{fontSize:"80%",whiteSpace:"pre"}},"&light .cm-searchMatch":{backgroundColor:"#ffff0054"},"&dark .cm-searchMatch":{backgroundColor:"#00ffff8a"},"&light .cm-searchMatch-selected":{backgroundColor:"#ff6a0054"},"&dark .cm-searchMatch-selected":{backgroundColor:"#ff00ff8a"}}),fy=[pt,kt.low(sy),cy],uy=$.theme({"&":{backgroundColor:"var(--background)",color:"var(--foreground)",fontSize:"13px",border:"1px solid var(--border)",borderRadius:"0.5rem",overflow:"hidden",width:"100%"},"& .cm-scroller":{overflow:"auto"},"&.cm-focused":{outline:"2px solid var(--ring)",outlineOffset:"-1px"},".cm-content":{caretColor:"var(--foreground)",fontFamily:'ui-monospace, SFMono-Regular, "SF Mono", Menlo, monospace',padding:"8px 0"},".cm-cursor, .cm-dropCursor":{borderLeftColor:"var(--foreground)"},".cm-selectionBackground, ::selection":{backgroundColor:"var(--accent)"},".cm-activeLine":{backgroundColor:"var(--accent)",opacity:"0.3"},".cm-gutters":{backgroundColor:"var(--muted)",color:"var(--muted-foreground)",border:"none",borderRight:"1px solid var(--border)"},".cm-activeLineGutter":{backgroundColor:"var(--accent)"},".cm-foldPlaceholder":{backgroundColor:"var(--muted)",color:"var(--muted-foreground)",border:"1px solid var(--border)"},".cm-tooltip":{backgroundColor:"var(--popover)",color:"var(--popover-foreground)",border:"1px solid var(--border)"},".cm-placeholder":{color:"var(--muted-foreground)"}},{dark:!1});function dy(n){switch(n){case"javascript":return qa({jsx:!0});case"typescript":return qa({jsx:!0,typescript:!0});case"sql":return Qx();default:return X1()}}function yy({value:n,onChange:e,readonly:t=!1,placeholder:i,className:s,minHeight:r="120px",language:o="json"}){const l=$t.useRef(null),a=$t.useRef(null),h=$t.useRef(e),c=$t.useRef(n),f=$t.useRef(o);return h.current=e,$t.useEffect(()=>{if(!l.current)return;const u=[bp(),_O(),Cg(),om(),RO(),z.allowMultipleSelections.of(!0),am(fm,{fallback:!0}),xm(),lg(),xg(),GO(),Yx(),Ss.of([...fg,...R0,...ay,...Eg,...im,...uf,...Zx]),dy(f.current),uy,$.theme({".cm-scroller":{minHeight:r}}),$.updateListener.of(p=>{p.docChanged&&h.current?.(p.state.doc.toString())})];t&&u.push(z.readOnly.of(!0),$.editable.of(!1)),i&&u.push(KO(i));const d=z.create({doc:c.current,extensions:u}),O=new $({state:d,parent:l.current});return a.current=O,()=>{O.destroy(),a.current=null}},[t,i,r]),$t.useEffect(()=>{const u=a.current;if(!u)return;const d=u.state.doc.toString();d!==n&&u.dispatch({changes:{from:0,to:d.length,insert:n}})},[n]),yu.jsx("div",{ref:l,className:bu("w-full",s)})}export{yy as C,Z as D,$ as E,P as F,yt as G,kt as P,at as R,ce as S,E as T,ee as V,Be as W,M as a,xy as b,ie as c,D as d,z as e,fm as f,dp as g,Xp as h,X1 as j,St as l,am as s};
26
- //# sourceMappingURL=code-editor-z1Sy_hiX.js.map
26
+ //# sourceMappingURL=code-editor-CTdKUDPY.js.map
@@ -0,0 +1,2 @@
1
+ import{j as t,O as o}from"./index-DB2lVKuV.js";const n=()=>t.jsx(o,{});export{n as component};
2
+ //# sourceMappingURL=connect-D8o7HBlo.js.map