@lobu/runtime-server 24.11.1 → 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 (272) 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/20261115130000_entities_retired_type_idx.sql +34 -0
  33. package/dist/db/migrations/20261115140000_entity_identities_personal_owner_idx.sql +34 -0
  34. package/dist/db/migrations/20261117090000_write_policy_kind_note.sql +65 -0
  35. package/dist/db/migrations/20261117120000_app_policy_principal.sql +48 -0
  36. package/dist/db/migrations/20261117170000_personal_org_connector_auto_policy_backfill.sql +57 -0
  37. package/dist/db/migrations/20261117190000_org_slug_reserved_paths.sql +29 -0
  38. package/dist/db/migrations/20261118120000_workspace_view_top_level_paths.sql +69 -0
  39. package/dist/db/migrations/preconditions/20261117190000_org_slug_reserved_paths.sql +14 -0
  40. package/dist/db/migrations/preconditions/20261118120000_workspace_view_top_level_paths.sql +21 -0
  41. package/dist/dependencies.bun.lock +51 -46
  42. package/dist/guest.bundle.js +11 -2
  43. package/dist/owletto/dist/assets/_-BC9j6MkU.js +2 -0
  44. package/dist/owletto/dist/assets/_-Z1u1cIe6.js +3 -0
  45. package/dist/owletto/dist/assets/_agentId-B-TFq9TP.js +2 -0
  46. package/dist/owletto/dist/assets/{_agentId-CGScf8z_.js → _agentId-BGatZWsd.js} +2 -2
  47. package/dist/owletto/dist/assets/_automationId-CMUrWPvr.js +2 -0
  48. package/dist/owletto/dist/assets/_connectorKey._connectionId-CUoAoP0_.js +2 -0
  49. package/dist/owletto/dist/assets/_connectorKey.index-Bs49QGGH.js +2 -0
  50. package/dist/owletto/dist/assets/_conversationId-CszP1den.js +2 -0
  51. package/dist/owletto/dist/assets/_eventId-C0AZUBnD.js +2 -0
  52. package/dist/owletto/dist/assets/_owner-B4ydA75k.js +3 -0
  53. package/dist/owletto/dist/assets/_shape-C4-ikE70.js +2 -0
  54. package/dist/owletto/dist/assets/_slug-DE5J3KVu.js +2 -0
  55. package/dist/owletto/dist/assets/_viewKey-Dkcd8JQC.js +2 -0
  56. package/dist/owletto/dist/assets/{accept-invitation-BKeIzZXE.js → accept-invitation-DmrQQu_W.js} +2 -2
  57. package/dist/owletto/dist/assets/{activity-route-location-sLvKaSCa.js → activity-route-location-Bec6fW-t.js} +2 -2
  58. package/dist/owletto/dist/assets/activity-route-view-DCSNBKZU.js +2 -0
  59. package/dist/owletto/dist/assets/agent-client-connections-xvabPpi6.js +4 -0
  60. package/dist/owletto/dist/assets/agent-connect-pages-DDPtkcmq.js +6 -0
  61. package/dist/owletto/dist/assets/{agent-editor-form-DVFyyMyd.js → agent-editor-form-BrhQbHZg.js} +2 -2
  62. package/dist/owletto/dist/assets/{agent-loading-shells-BLNHIy-r.js → agent-loading-shells-D3y98xuO.js} +2 -2
  63. package/dist/owletto/dist/assets/{agent-permissions-matrix-UBKRR5vs.js → agent-permissions-matrix-jQJjSa9i.js} +2 -2
  64. package/dist/owletto/dist/assets/{agent-skill-context-fqedKd0D.js → agent-skill-context-CCcknBYE.js} +2 -2
  65. package/dist/owletto/dist/assets/{agent-subpage-shell-BUCoY2Nf.js → agent-subpage-shell-6f_53cSf.js} +2 -2
  66. package/dist/owletto/dist/assets/agent-thread-v_lSSnJi.js +6 -0
  67. package/dist/owletto/dist/assets/{app._appId-ByIypCL9.js → app._appId-CKWzZ2ic.js} +2 -2
  68. package/dist/owletto/dist/assets/assist-composer-Q9ZJjAta.js +2 -0
  69. package/dist/owletto/dist/assets/automation-run-now-Dl0MKx3N.js +2 -0
  70. package/dist/owletto/dist/assets/{callback-Pz5uS-k7.js → callback-Bentv78L.js} +2 -2
  71. package/dist/owletto/dist/assets/{card-CAPpY9P5.js → card-C4oPCVh6.js} +2 -2
  72. package/dist/owletto/dist/assets/{claim-DgWWK0KI.js → claim-B3C4qIi2.js} +2 -2
  73. package/dist/owletto/dist/assets/client-activity-scopes-DqaFEyir.js +2 -0
  74. package/dist/owletto/dist/assets/{client-rows-Dd5YV8vn.js → client-rows-rse9thnk.js} +2 -2
  75. package/dist/owletto/dist/assets/{clients-Bf7ZgGro.js → clients-BhPMbxHi.js} +2 -2
  76. package/dist/owletto/dist/assets/{code-editor-z1Sy_hiX.js → code-editor-CTdKUDPY.js} +2 -2
  77. package/dist/owletto/dist/assets/connect-D8o7HBlo.js +2 -0
  78. package/dist/owletto/dist/assets/connect-menu-D5EZvSHb.js +2 -0
  79. package/dist/owletto/dist/assets/connect._clientId-Dbagcg9L.js +2 -0
  80. package/dist/owletto/dist/assets/connected._clientId-DALW9S2K.js +2 -0
  81. package/dist/owletto/dist/assets/connection-DyxzSqVE.js +2 -0
  82. package/dist/owletto/dist/assets/connection-feed-detail-LqpxUCdy.js +2 -0
  83. package/dist/owletto/dist/assets/{connector-page-shell-an3SYLim.js → connector-page-shell-DZjKv9zQ.js} +2 -2
  84. package/dist/owletto/dist/assets/{connector-provenance-mSZCOud-.js → connector-provenance-DtTJn1Nk.js} +2 -2
  85. package/dist/owletto/dist/assets/connectors-BVl-AR33.js +2 -0
  86. package/dist/owletto/dist/assets/{consent-1ulwyJ3k.js → consent-XCqsHLxS.js} +2 -2
  87. package/dist/owletto/dist/assets/{core.esm-Ctg_pXLe.js → core.esm-B1du4Zwy.js} +3 -3
  88. package/dist/owletto/dist/assets/create-BYKCtGL4.js +2 -0
  89. package/dist/owletto/dist/assets/create-D6Mmuxcq.js +2 -0
  90. package/dist/owletto/dist/assets/{create-CGuoqPh8.js → create-GHTb6wKX.js} +2 -2
  91. package/dist/owletto/dist/assets/{create-automation-form-CD6jSlWL.js → create-automation-form-CTiy_S9G.js} +3 -3
  92. package/dist/owletto/dist/assets/create._connectorKey-DMH97KkK.js +2 -0
  93. package/dist/owletto/dist/assets/custom-guardrail-edits-DZy66ucV.js +2 -0
  94. package/dist/owletto/dist/assets/definition-comparison-C2mPfIMD.js +2 -0
  95. package/dist/owletto/dist/assets/detail-page-skeleton-DNBL7nyk.js +2 -0
  96. package/dist/owletto/dist/assets/device-CwP1PY8q.js +2 -0
  97. package/dist/owletto/dist/assets/{device-pin-tombstone-Dkj7hrBE.js → device-pin-tombstone-DYTt7kU5.js} +2 -2
  98. package/dist/owletto/dist/assets/device._deviceId-DZ2kqI4Y.js +2 -0
  99. package/dist/owletto/dist/assets/{entity-options-D4t-NAcg.js → entity-options-D9K_5Lcs.js} +2 -2
  100. package/dist/owletto/dist/assets/entity-page-DggKXrcE.js +2 -0
  101. package/dist/owletto/dist/assets/entity-pages-C6M6yKFf.js +2 -0
  102. package/dist/owletto/dist/assets/{entity-schema-graph-Cq96SJ3c.js → entity-schema-graph-B255NKjF.js} +2 -2
  103. package/dist/owletto/dist/assets/entity-type-page-CGBAP2wt.js +2 -0
  104. package/dist/owletto/dist/assets/event-attachments-D8Z8uwv9.js +2 -0
  105. package/dist/owletto/dist/assets/event-detail-CgG3pDLA.js +2 -0
  106. package/dist/owletto/dist/assets/events-feed-ClhEywwV.js +2 -0
  107. package/dist/owletto/dist/assets/{filter-editors-DGVl9U4D.js → filter-editors-D_Sfn0dv.js} +3 -3
  108. package/dist/owletto/dist/assets/{full-page-spinner-CtVlF8GQ.js → full-page-spinner-C1clibUY.js} +2 -2
  109. package/dist/owletto/dist/assets/{index-CK5GDX4B.js → index-04B26s6E.js} +2 -2
  110. package/dist/owletto/dist/assets/index-2HrEO-nl.js +2 -0
  111. package/dist/owletto/dist/assets/index-BU3k9wpw.js +2 -0
  112. package/dist/owletto/dist/assets/{index-DvuJ_S_o.js → index-BXHqp23o.js} +2 -2
  113. package/dist/owletto/dist/assets/index-BdLRUDIR.js +2 -0
  114. package/dist/owletto/dist/assets/index-C2FrGwYN.js +2 -0
  115. package/dist/owletto/dist/assets/index-CB9wGfUm.js +2 -0
  116. package/dist/owletto/dist/assets/index-Caihaftb.js +2 -0
  117. package/dist/owletto/dist/assets/index-CwH59DJV.js +2 -0
  118. package/dist/owletto/dist/assets/index-DB2lVKuV.js +7908 -0
  119. package/dist/owletto/dist/assets/{index-DbjbHlDe.js → index-DTvJRjrM.js} +2 -2
  120. package/dist/owletto/dist/assets/index-SF2ni1Rs.css +1 -0
  121. package/dist/owletto/dist/assets/{index-BifR-LE9.js → index-mSrdbx3C.js} +9 -9
  122. package/dist/owletto/dist/assets/index-uFn-Ilrx.js +2 -0
  123. package/dist/owletto/dist/assets/{json-diff-OjtREegr.js → json-diff-Ce6YAXzY.js} +2 -2
  124. package/dist/owletto/dist/assets/{list-skeleton-CH0qQBYk.js → list-skeleton-DLPBTnbR.js} +2 -2
  125. package/dist/owletto/dist/assets/login-DeWlvogD.js +2 -0
  126. package/dist/owletto/dist/assets/{logout-DfdgOLoM.js → logout-CJY0ceN9.js} +2 -2
  127. package/dist/owletto/dist/assets/{member-scope-gate-Cxg2zGQT.js → member-scope-gate-CBPMprXu.js} +2 -2
  128. package/dist/owletto/dist/assets/memory-browse-page-D5kj1RaR.js +74 -0
  129. package/dist/owletto/dist/assets/{model-selector-D2OpDkwH.js → model-selector-CjkBPpjN.js} +2 -2
  130. package/dist/owletto/dist/assets/new-BKrNkOQD.js +2 -0
  131. package/dist/owletto/dist/assets/new-BetiMuDq.js +2 -0
  132. package/dist/owletto/dist/assets/new-dk_-eXqU.js +2 -0
  133. package/dist/owletto/dist/assets/new-efN--4Wx.js +2 -0
  134. package/dist/owletto/dist/assets/organization-C3rpwx_d.js +2 -0
  135. package/dist/owletto/dist/assets/pdf-document--AN-oCKj.css +1 -0
  136. package/dist/owletto/dist/assets/pdf-document-2W1q0sRA.js +56 -0
  137. package/dist/owletto/dist/assets/pdf.worker.min-CIqJB0yW.mjs +28 -0
  138. package/dist/owletto/dist/assets/peek-pane-content-ChsBWO0P.js +3 -0
  139. package/dist/owletto/dist/assets/{pending-seed-BBACroge.js → pending-seed-CTKYdA4X.js} +2 -2
  140. package/dist/owletto/dist/assets/proposal-review-shell-EyGWEYwQ.js +2 -0
  141. package/dist/owletto/dist/assets/public-shell-ready-_KWdfzEM.js +2 -0
  142. package/dist/owletto/dist/assets/record-session-D27VNxP_.js +2 -0
  143. package/dist/owletto/dist/assets/{renderer-CTKNMcXP.js → renderer-B8yZ5lql.js} +34 -33
  144. package/dist/owletto/dist/assets/{reset-password-DKBEneyR.js → reset-password-BGVJIh2I.js} +2 -2
  145. package/dist/owletto/dist/assets/run-initiator-C0sur8lU.js +2 -0
  146. package/dist/owletto/dist/assets/runs-list-CJOFMgpk.js +2 -0
  147. package/dist/owletto/dist/assets/schema-value-DDNHANGs.js +3 -0
  148. package/dist/owletto/dist/assets/{scoped-feed-bar-DNFL0sYX.js → scoped-feed-bar-BTv9mPcR.js} +2 -2
  149. package/dist/owletto/dist/assets/settings-Ponr5XbS.js +3 -0
  150. package/dist/owletto/dist/assets/{status-variants-SzXYYedJ.js → status-variants-mLqVhg5O.js} +2 -2
  151. package/dist/owletto/dist/assets/subDays-BGA_fkig.js +2 -0
  152. package/dist/owletto/dist/assets/two-factor-pqoxGSgL.js +2 -0
  153. package/dist/owletto/dist/assets/{use-automations-DfBtVzGa.js → use-automations-DcdlmVuX.js} +2 -2
  154. package/dist/owletto/dist/assets/{use-login-redirect-BDiS3eyl.js → use-login-redirect-D7HW5Ed6.js} +2 -2
  155. package/dist/owletto/dist/assets/{use-mention-search-khySpz_V.js → use-mention-search-BniE-K2d.js} +3 -3
  156. package/dist/owletto/dist/assets/view-card-Cg6PeEiV.js +2 -0
  157. package/dist/owletto/dist/assets/view-param-filters-CvrKw0mZ.js +2 -0
  158. package/dist/owletto/dist/index.html +2 -2
  159. package/dist/server-main.bundle.mjs +5718 -2991
  160. package/npm-shrinkwrap.json +195 -172
  161. package/package.json +2 -1
  162. package/vendor/connector-sdk/dist/connector-types.d.ts +20 -0
  163. package/vendor/connector-sdk/dist/define-connector.js +2 -0
  164. package/vendor/connector-sdk/dist/extension-dom-scrape.d.ts +2 -0
  165. package/vendor/connector-sdk/dist/extension-dom-scrape.js +5 -0
  166. package/vendor/connector-sdk/dist/reaction-client-types.d.ts +20 -0
  167. package/vendor/connector-sdk/package.json +1 -1
  168. package/vendor/core/dist/contracts/entity-reference.d.ts +2 -0
  169. package/vendor/core/dist/contracts/entity-reference.js +4 -3
  170. package/vendor/core/dist/contracts/tools/entity-list-sort.d.ts +18 -0
  171. package/vendor/core/dist/contracts/tools/entity-list-sort.js +64 -0
  172. package/vendor/core/dist/contracts/tools/manage-agents.d.ts +1 -1
  173. package/vendor/core/dist/contracts/tools/manage-agents.js +3 -3
  174. package/vendor/core/dist/contracts/tools/manage-entity-schema.d.ts +4 -0
  175. package/vendor/core/dist/contracts/tools/manage-entity-schema.js +4 -0
  176. package/vendor/core/dist/contracts/tools/manage-entity.d.ts +4 -0
  177. package/vendor/core/dist/contracts/tools/manage-entity.js +11 -1
  178. package/vendor/core/dist/contracts/tools/manage-operations.d.ts +29 -3
  179. package/vendor/core/dist/contracts/tools/manage-operations.js +24 -2
  180. package/vendor/core/dist/contracts/tools/manage-views.d.ts +36 -0
  181. package/vendor/core/dist/contracts/tools/manage-views.js +15 -2
  182. package/vendor/core/dist/contracts/tools/view-definition.js +7 -2
  183. package/vendor/core/dist/contracts/tools/view-host.js +5 -0
  184. package/vendor/core/dist/contracts/tools/view-path.d.ts +8 -1
  185. package/vendor/core/dist/contracts/tools/view-path.js +11 -1
  186. package/vendor/core/dist/reserved.d.ts +7 -1
  187. package/vendor/core/dist/reserved.js +17 -0
  188. package/vendor/core/package.json +6 -1
  189. package/vendor/views/dist/api.d.ts +19 -3
  190. package/vendor/views/dist/api.js +53 -5
  191. package/vendor/views/dist/components.d.ts +7 -0
  192. package/vendor/views/dist/components.js +223 -2
  193. package/vendor/views/dist/embed.js +13 -2
  194. package/vendor/views/dist/live-gate.d.ts +34 -0
  195. package/vendor/views/dist/live-gate.js +100 -0
  196. package/vendor/views/dist/native.d.ts +43 -1
  197. package/vendor/views/dist/native.js +1 -0
  198. package/vendor/views/package.json +1 -1
  199. package/dist/owletto/dist/assets/_-BDMUN9XZ.js +0 -2
  200. package/dist/owletto/dist/assets/_-CF5X4ANe.js +0 -3
  201. package/dist/owletto/dist/assets/_agentId-EQU2aUP0.js +0 -2
  202. package/dist/owletto/dist/assets/_automationId-PXZ33jsF.js +0 -2
  203. package/dist/owletto/dist/assets/_connectorKey._connectionId-DcI29kGy.js +0 -2
  204. package/dist/owletto/dist/assets/_connectorKey.index-Cr2NDJWX.js +0 -2
  205. package/dist/owletto/dist/assets/_conversationId-CnmLYlVS.js +0 -2
  206. package/dist/owletto/dist/assets/_eventId-w5sDz5oa.js +0 -2
  207. package/dist/owletto/dist/assets/_owner-CkOZR4n0.js +0 -3
  208. package/dist/owletto/dist/assets/_shape-C_FmSf9G.js +0 -2
  209. package/dist/owletto/dist/assets/_slug-COPpRXLt.js +0 -2
  210. package/dist/owletto/dist/assets/_viewKey-BVdJiilV.js +0 -2
  211. package/dist/owletto/dist/assets/_viewKey-mxxpqjtC.js +0 -2
  212. package/dist/owletto/dist/assets/activity-route-view-msesKUwn.js +0 -2
  213. package/dist/owletto/dist/assets/agent-connect-pages-DVq9nAR7.js +0 -4
  214. package/dist/owletto/dist/assets/agent-thread-Cqf9ITrT.js +0 -6
  215. package/dist/owletto/dist/assets/assist-composer-kG_heHXo.js +0 -2
  216. package/dist/owletto/dist/assets/automation-run-now-C5XTS00o.js +0 -2
  217. package/dist/owletto/dist/assets/client-activity-scopes-Aqdo6Pdr.js +0 -2
  218. package/dist/owletto/dist/assets/connect-BFNp1y_s.js +0 -2
  219. package/dist/owletto/dist/assets/connect-menu-BWrAhMqO.js +0 -2
  220. package/dist/owletto/dist/assets/connect._clientId-CSPfwYIN.js +0 -2
  221. package/dist/owletto/dist/assets/connected._clientId-CuOeHafK.js +0 -2
  222. package/dist/owletto/dist/assets/connection-CVeHmDLs.js +0 -2
  223. package/dist/owletto/dist/assets/connection-feed-detail-BYo7zdVD.js +0 -2
  224. package/dist/owletto/dist/assets/connectors-DBEM9QQz.js +0 -2
  225. package/dist/owletto/dist/assets/copy-button-Xhh7ZnjO.js +0 -2
  226. package/dist/owletto/dist/assets/create-Ccb5R-S4.js +0 -2
  227. package/dist/owletto/dist/assets/create-DmhbacIa.js +0 -2
  228. package/dist/owletto/dist/assets/create._connectorKey-CZsAqj1p.js +0 -2
  229. package/dist/owletto/dist/assets/custom-guardrail-edits-Ce_BwiwD.js +0 -2
  230. package/dist/owletto/dist/assets/definition-comparison-D_qP25jR.js +0 -2
  231. package/dist/owletto/dist/assets/detail-page-skeleton-CPAfZLG0.js +0 -2
  232. package/dist/owletto/dist/assets/device-DDl5XKvt.js +0 -2
  233. package/dist/owletto/dist/assets/device._deviceId-bNhTcops.js +0 -2
  234. package/dist/owletto/dist/assets/dynamic-schema-form-CRyUchXo.js +0 -2
  235. package/dist/owletto/dist/assets/entity-page-BOOL_vy3.js +0 -2
  236. package/dist/owletto/dist/assets/entity-pages-_nuesgnp.js +0 -2
  237. package/dist/owletto/dist/assets/entity-type-page-CkCSbkBx.js +0 -2
  238. package/dist/owletto/dist/assets/event-detail-DUvlqn9b.js +0 -2
  239. package/dist/owletto/dist/assets/events-feed-DcKTkJVe.js +0 -2
  240. package/dist/owletto/dist/assets/index-BUlkNJzX.js +0 -2
  241. package/dist/owletto/dist/assets/index-BoqrvLHQ.js +0 -7906
  242. package/dist/owletto/dist/assets/index-CA9mW_ZM.js +0 -2
  243. package/dist/owletto/dist/assets/index-CH0GzG4i.js +0 -2
  244. package/dist/owletto/dist/assets/index-CtI5Eomq.js +0 -2
  245. package/dist/owletto/dist/assets/index-DmtQ0bds.js +0 -2
  246. package/dist/owletto/dist/assets/index-Du_J8hnx.js +0 -2
  247. package/dist/owletto/dist/assets/index-Pae_f9LM.css +0 -1
  248. package/dist/owletto/dist/assets/index-XETZnN7L.js +0 -2
  249. package/dist/owletto/dist/assets/login-DG0b9uSC.js +0 -2
  250. package/dist/owletto/dist/assets/memory-browse-page-qEDQ9Z18.js +0 -74
  251. package/dist/owletto/dist/assets/missing-view-xT0B-f5z.js +0 -2
  252. package/dist/owletto/dist/assets/needs-you-list-3uMsWcDv.js +0 -2
  253. package/dist/owletto/dist/assets/new-AdGV6a8R.js +0 -2
  254. package/dist/owletto/dist/assets/new-BdtIhBpo.js +0 -2
  255. package/dist/owletto/dist/assets/new-BjGwX6s6.js +0 -2
  256. package/dist/owletto/dist/assets/new-D-iMjV74.js +0 -2
  257. package/dist/owletto/dist/assets/organization-qaIpEiQg.js +0 -2
  258. package/dist/owletto/dist/assets/peek-pane-content-CEsDVScl.js +0 -2
  259. package/dist/owletto/dist/assets/proposal-review-shell-C8ZfIAYn.js +0 -2
  260. package/dist/owletto/dist/assets/public-shell-ready-K2R8iXSI.js +0 -2
  261. package/dist/owletto/dist/assets/record-session-BrM9cdXu.js +0 -2
  262. package/dist/owletto/dist/assets/run-initiator-BKSgI1o0.js +0 -2
  263. package/dist/owletto/dist/assets/runs-k2NpbZm8.js +0 -2
  264. package/dist/owletto/dist/assets/runs-list-DUXRMkWN.js +0 -2
  265. package/dist/owletto/dist/assets/schema-value-wjqGxXhv.js +0 -3
  266. package/dist/owletto/dist/assets/settings-V0m5Om5j.js +0 -2
  267. package/dist/owletto/dist/assets/source-record-panels-BMut9YIA.js +0 -2
  268. package/dist/owletto/dist/assets/subDays-9s9OEl5t.js +0 -2
  269. package/dist/owletto/dist/assets/table-ZuYMOjVR.js +0 -2
  270. package/dist/owletto/dist/assets/view-card-DiHWlypr.js +0 -2
  271. package/dist/owletto/dist/assets/view-param-filters-DGKxSr7r.js +0 -2
  272. package/dist/owletto/dist/assets/views-access-required-HA-PiOwA.js +0 -2
@@ -0,0 +1,2 @@
1
+ import{aH as n,j as a,Y as r}from"./index-DB2lVKuV.js";const i=["automation","agent","entity-type"];function u(){const{owner:e}=n.useParams(),{section:o}=n.useSearch(),t=i.find(s=>s===o);return a.jsx(r,{to:t?"/$owner":"/$owner/settings/organization",params:{owner:e},search:t?{section:t}:{},replace:!0})}export{u as component};
2
+ //# sourceMappingURL=index-uFn-Ilrx.js.map
@@ -1,4 +1,4 @@
1
- import{j as C,B as Ue,X as Ve,r as H,dh as qe,C as ze,i as _e,e9 as $e}from"./index-BoqrvLHQ.js";import{T as be,P as ve,E as S,S as U,g as Ke,V as Qe,F as Be,a as K,R as P,D as M,G as Q,W as Z,l as Ze,h as Xe,b as Ye,c as et,d as tt,e as le,s as nt,j as rt,f as it}from"./code-editor-z1Sy_hiX.js";function It({sources:t,onRemove:e,disabled:n,wrap:l=!1}){return C.jsx(C.Fragment,{children:t.length>0?C.jsx("ul",{className:"space-y-2",children:t.map(i=>C.jsxs("li",{className:"flex items-start gap-2 rounded-lg border bg-background p-2",children:[C.jsxs("div",{className:"min-w-0 flex-1",children:[C.jsx("div",{className:"truncate font-mono text-xs font-medium",children:i.name}),C.jsx("div",{className:l?"whitespace-pre-wrap break-words text-xs text-muted-foreground":"truncate text-xs text-muted-foreground",children:i.query})]}),e?C.jsx(Ue,{type:"button",variant:"ghost",size:"icon",className:"h-7 w-7 shrink-0","aria-label":`Remove source ${i.name}`,disabled:n,onClick:()=>e?.(i),children:C.jsx(Ve,{className:"h-3.5 w-3.5"})}):null]},i.query))}):null})}class x{constructor(e,n,l,i){this.fromA=e,this.toA=n,this.fromB=l,this.toB=i}offset(e,n=e){return new x(this.fromA+e,this.toA+e,this.fromB+n,this.toB+n)}}function j(t,e,n,l,i,r){if(t==l)return[];let o=Y(t,e,n,l,i,r),a=ee(t,e+o,n,l,i+o,r);e+=o,n-=a,i+=o,r-=a;let f=n-e,c=r-i;if(!f||!c)return[new x(e,n,i,r)];if(f>c){let d=t.slice(e,n).indexOf(l.slice(i,r));if(d>-1)return[new x(e,e+d,i,i),new x(e+d+c,n,r,r)]}else if(c>f){let d=l.slice(i,r).indexOf(t.slice(e,n));if(d>-1)return[new x(e,e,i,i+d),new x(n,n,i+d+f,r)]}if(f==1||c==1)return[new x(e,n,i,r)];let s=Me(t,e,n,l,i,r);if(s){let[d,u,h]=s;return j(t,e,d,l,i,u).concat(j(t,d+h,n,l,u+h,r))}return lt(t,e,n,l,i,r)}let G=1e9,R=0,X=!1;function lt(t,e,n,l,i,r){let o=n-e,a=r-i;if(G<1e9&&Math.min(o,a)>G*16||R>0&&Date.now()>R)return Math.min(o,a)>G*64?[new x(e,n,i,r)]:oe(t,e,n,l,i,r);let f=Math.ceil((o+a)/2);q.reset(f),z.reset(f);let c=(h,m)=>t.charCodeAt(e+h)==l.charCodeAt(i+m),s=(h,m)=>t.charCodeAt(n-h-1)==l.charCodeAt(r-m-1),d=(o-a)%2!=0?z:null,u=d?null:q;for(let h=0;h<f;h++){if(h>G||R>0&&!(h&63)&&Date.now()>R)return oe(t,e,n,l,i,r);let m=q.advance(h,o,a,f,d,!1,c)||z.advance(h,o,a,f,u,!0,s);if(m)return ot(t,e,n,e+m[0],l,i,r,i+m[1])}return[new x(e,n,i,r)]}class Le{constructor(){this.vec=[]}reset(e){this.len=e<<1;for(let n=0;n<this.len;n++)this.vec[n]=-1;this.vec[e+1]=0,this.start=this.end=0}advance(e,n,l,i,r,o,a){for(let f=-e+this.start;f<=e-this.end;f+=2){let c=i+f,s=f==-e||f!=e&&this.vec[c-1]<this.vec[c+1]?this.vec[c+1]:this.vec[c-1]+1,d=s-f;for(;s<n&&d<l&&a(s,d);)s++,d++;if(this.vec[c]=s,s>n)this.end+=2;else if(d>l)this.start+=2;else if(r){let u=i+(n-l)-f;if(u>=0&&u<this.len&&r.vec[u]!=-1)if(o){let h=r.vec[u];if(h>=n-s)return[h,i+h-u]}else{let h=n-r.vec[u];if(s>=h)return[s,d]}}}return null}}const q=new Le,z=new Le;function ot(t,e,n,l,i,r,o,a){let f=!1;return!E(t,l)&&++l==n&&(f=!0),!E(i,a)&&++a==o&&(f=!0),f?[new x(e,n,r,o)]:j(t,e,l,i,r,a).concat(j(t,l,n,i,a,o))}function De(t,e){let n=1,l=Math.min(t,e);for(;n<l;)n=n<<1;return n}function Y(t,e,n,l,i,r){if(e==n||e==r||t.charCodeAt(e)!=l.charCodeAt(i))return 0;let o=De(n-e,r-i);for(let a=e,f=i;;){let c=a+o,s=f+o;if(c>n||s>r||t.slice(a,c)!=l.slice(f,s)){if(o==1)return a-e-(E(t,a)?0:1);o=o>>1}else{if(c==n||s==r)return c-e;a=c,f=s}}}function ee(t,e,n,l,i,r){if(e==n||i==r||t.charCodeAt(n-1)!=l.charCodeAt(r-1))return 0;let o=De(n-e,r-i);for(let a=n,f=r;;){let c=a-o,s=f-o;if(c<e||s<i||t.slice(c,a)!=l.slice(s,f)){if(o==1)return n-a-(E(t,a)?0:1);o=o>>1}else{if(c==e||s==i)return n-c;a=c,f=s}}}function _(t,e,n,l,i,r,o,a){let f=l.slice(i,r),c=null;for(;;){if(c||o<a)return c;for(let s=e+o;;){E(t,s)||s++;let d=s+o;if(E(t,d)||(d+=d==s+1?1:-1),d>=n)break;let u=t.slice(s,d),h=-1;for(;(h=f.indexOf(u,h+1))!=-1;){let m=Y(t,d,n,l,i+h+u.length,r),p=ee(t,e,s,l,i,i+h),g=u.length+m+p;(!c||c[2]<g)&&(c=[s-p,i+h-p,g])}s=d}if(a<0)return c;o=o>>1}}function Me(t,e,n,l,i,r){let o=n-e,a=r-i;if(o<a){let f=Me(l,i,r,t,e,n);return f&&[f[1],f[0],f[2]]}return o<4||a*2<o?null:_(t,e,n,l,i,r,Math.floor(o/4),-1)}function oe(t,e,n,l,i,r){X=!0;let o=n-e,a=r-i,f;if(o<a){let u=_(l,i,r,t,e,n,Math.floor(o/6),50);f=u&&[u[1],u[0],u[2]]}else f=_(t,e,n,l,i,r,Math.floor(a/6),50);if(!f)return[new x(e,n,i,r)];let[c,s,d]=f;return j(t,e,c,l,i,s).concat(j(t,c+d,n,l,s+d,r))}function Se(t,e){for(let n=1;n<t.length;n++){let l=t[n-1],i=t[n];l.toA>i.fromA-e&&l.toB>i.fromB-e&&(t[n-1]=new x(l.fromA,i.toA,l.fromB,i.toB),t.splice(n--,1))}}function at(t,e,n){for(;;){Se(n,1);let l=!1;for(let i=0;i<n.length;i++){let r=n[i],o,a;(o=Y(t,r.fromA,r.toA,e,r.fromB,r.toB))&&(r=n[i]=new x(r.fromA+o,r.toA,r.fromB+o,r.toB)),(a=ee(t,r.fromA,r.toA,e,r.fromB,r.toB))&&(r=n[i]=new x(r.fromA,r.toA-a,r.fromB,r.toB-a));let f=r.toA-r.fromA,c=r.toB-r.fromB;if(f&&c)continue;let s=r.fromA-(i?n[i-1].toA:0),d=(i<n.length-1?n[i+1].fromA:t.length)-r.toA;if(!s||!d)continue;let u=f?t.slice(r.fromA,r.toA):e.slice(r.fromB,r.toB);s<=u.length&&t.slice(r.fromA-s,r.fromA)==u.slice(u.length-s)?(n[i]=new x(r.fromA-s,r.toA-s,r.fromB-s,r.toB-s),l=!0):d<=u.length&&t.slice(r.toA,r.toA+d)==u.slice(0,d)&&(n[i]=new x(r.fromA+d,r.toA+d,r.fromB+d,r.toB+d),l=!0)}if(!l)break}return n}function st(t,e,n){for(let l=0,i=0;i<t.length;i++){let r=t[i],o=r.toA-r.fromA,a=r.toB-r.fromB;if(o&&a||o>3||a>3){let f=i==t.length-1?e.length:t[i+1].fromA,c=r.fromA-l,s=f-r.toA,d=se(e,r.fromA,c),u=ae(e,r.toA,s),h=r.fromA-d,m=u-r.toA;if((!o||!a)&&h&&m){let p=Math.max(o,a),[g,k,T]=o?[e,r.fromA,r.toA]:[n,r.fromB,r.toB];p>h&&e.slice(d,r.fromA)==g.slice(T-h,T)?(r=t[i]=new x(d,d+o,r.fromB-h,r.toB-h),d=r.fromA,u=ae(e,r.toA,f-r.toA)):p>m&&e.slice(r.toA,u)==g.slice(k,k+m)&&(r=t[i]=new x(u-o,u,r.fromB+m,r.toB+m),u=r.toA,d=se(e,r.fromA,r.fromA-l)),h=r.fromA-d,m=u-r.toA}if(h||m)r=t[i]=new x(r.fromA-h,r.toA+m,r.fromB-h,r.toB+m);else if(o){if(!a){let p=fe(e,r.fromA,r.toA),g,k=p<0?-1:de(e,r.toA,r.fromA);p>-1&&(g=p-r.fromA)<=s&&e.slice(r.fromA,p)==e.slice(r.toA,r.toA+g)?r=t[i]=r.offset(g):k>-1&&(g=r.toA-k)<=c&&e.slice(r.fromA-g,r.fromA)==e.slice(k,r.toA)&&(r=t[i]=r.offset(-g))}}else{let p=fe(n,r.fromB,r.toB),g,k=p<0?-1:de(n,r.toB,r.fromB);p>-1&&(g=p-r.fromB)<=s&&n.slice(r.fromB,p)==n.slice(r.toB,r.toB+g)?r=t[i]=r.offset(g):k>-1&&(g=r.toB-k)<=c&&n.slice(r.fromB-g,r.fromB)==n.slice(k,r.toB)&&(r=t[i]=r.offset(-g))}}l=r.toA}return Se(t,3),t}let y;try{y=new RegExp("[\\p{Alphabetic}\\p{Number}]","u")}catch{}function ye(t){return t>48&&t<58||t>64&&t<91||t>96&&t<123}function je(t,e){if(e==t.length)return 0;let n=t.charCodeAt(e);return n<192?ye(n)?1:0:y?!Oe(n)||e==t.length-1?y.test(String.fromCharCode(n))?1:0:y.test(t.slice(e,e+2))?2:0:0}function Ne(t,e){if(!e)return 0;let n=t.charCodeAt(e-1);return n<192?ye(n)?1:0:y?!Te(n)||e==1?y.test(String.fromCharCode(n))?1:0:y.test(t.slice(e-2,e))?2:0:0}const Ee=8;function ae(t,e,n){if(e==t.length||!Ne(t,e))return e;for(let l=e,i=e+n,r=0;r<Ee;r++){let o=je(t,l);if(!o||l+o>i)return l;l+=o}return e}function se(t,e,n){if(!e||!je(t,e))return e;for(let l=e,i=e-n,r=0;r<Ee;r++){let o=Ne(t,l);if(!o||l-o<i)return l;l-=o}return e}function de(t,e,n){for(;e!=n;e--)if(t.charCodeAt(e-1)==10)return e;return-1}function fe(t,e,n){for(;e!=n;e++)if(t.charCodeAt(e)==10)return e;return-1}const Oe=t=>t>=55296&&t<=56319,Te=t=>t>=56320&&t<=57343;function E(t,e){return!e||e==t.length||!Oe(t.charCodeAt(e-1))||!Te(t.charCodeAt(e))}function dt(t,e,n){var l;let i=n?.override;return i?i(t,e):(G=((l=n?.scanLimit)!==null&&l!==void 0?l:1e9)>>1,R=n?.timeout?Date.now()+n.timeout:0,X=!1,at(t,e,j(t,0,t.length,e,0,e.length)))}function Fe(){return!X}function Ge(t,e,n){return st(dt(t,e,n),t,e)}const D=Be.define({combine:t=>t[0]}),ft=K.define(),Re=Be.define(),w=U.define({create(t){return null},update(t,e){for(let n of e.effects)n.is(ft)&&(t=n.value);for(let n of e.state.facet(Re))t=n(t,e);return t}});class N{constructor(e,n,l,i,r,o=!0){this.changes=e,this.fromA=n,this.toA=l,this.fromB=i,this.toB=r,this.precise=o}offset(e,n){return e||n?new N(this.changes,this.fromA+e,this.toA+e,this.fromB+n,this.toB+n,this.precise):this}get endA(){return Math.max(this.fromA,this.toA-1)}get endB(){return Math.max(this.fromB,this.toB-1)}static build(e,n,l){let i=Ge(e.toString(),n.toString(),l);return Ie(i,e,n,0,0,Fe())}static updateA(e,n,l,i,r){return ge(me(e,i,!0,l.length),e,n,l,r)}static updateB(e,n,l,i,r){return ge(me(e,i,!1,n.length),e,n,l,r)}}function ce(t,e,n,l){let i=n.lineAt(t),r=l.lineAt(e);return i.to==t&&r.to==e&&t<n.length&&e<l.length?[t+1,e+1]:[i.from,r.from]}function ue(t,e,n,l){let i=n.lineAt(t),r=l.lineAt(e);return i.from==t&&r.from==e?[t,e]:[i.to+1,r.to+1]}function Ie(t,e,n,l,i,r){let o=[];for(let a=0;a<t.length;a++){let f=t[a],[c,s]=ce(f.fromA+l,f.fromB+i,e,n),[d,u]=ue(f.toA+l,f.toB+i,e,n),h=[f.offset(-c+l,-s+i)];for(;a<t.length-1;){let m=t[a+1],[p,g]=ce(m.fromA+l,m.fromB+i,e,n);if(p>d+1&&g>u+1)break;h.push(m.offset(-c+l,-s+i)),[d,u]=ue(m.toA+l,m.toB+i,e,n),a++}o.push(new N(h,c,Math.max(c,d),s,Math.max(s,u),r))}return o}const W=1e3;function he(t,e,n,l){let i=0,r=t.length;for(;;){if(i==r){let s=0,d=0;i&&({toA:s,toB:d}=t[i-1]);let u=e-(n?s:d);return[s+u,d+u]}let o=i+r>>1,a=t[o],[f,c]=n?[a.fromA,a.toA]:[a.fromB,a.toB];if(f>e)r=o;else if(c<=e)i=o+1;else return l?[a.fromA,a.fromB]:[a.toA,a.toB]}}function me(t,e,n,l){let i=[];return e.iterChangedRanges((r,o,a,f)=>{let c=0,s=n?e.length:l,d=0,u=n?l:e.length;r>W&&([c,d]=he(t,r-W,n,!0)),o<e.length-W&&([s,u]=he(t,o+W,n,!1));let h=f-a-(o-r),m,[p,g]=n?[h,0]:[0,h];i.length&&(m=i[i.length-1]).toA>=c?i[i.length-1]={fromA:m.fromA,fromB:m.fromB,toA:s,toB:u,diffA:m.diffA+p,diffB:m.diffB+g}:i.push({fromA:c,toA:s,fromB:d,toB:u,diffA:p,diffB:g})}),i}function ge(t,e,n,l,i){if(!t.length)return e;let r=[];for(let o=0,a=0,f=0,c=0;;o++){let s=o==t.length?null:t[o],d=s?s.fromA+a:n.length,u=s?s.fromB+f:l.length;for(;c<e.length;){let g=e[c];if(s&&(g.toA+a>d||g.toB+f>u))break;r.push(g.offset(a,f)),c++}if(!s)break;let h=s.toA+a+s.diffA,m=s.toB+f+s.diffB,p=Ge(n.sliceString(d,h),l.sliceString(u,m),i);for(let g of Ie(p,n,l,d,u,Fe()))r.push(g);for(a+=s.diffA,f+=s.diffB;c<e.length;){let g=e[c];if(g.fromA+a>h&&g.fromB+f>m)break;c++}}return r}const ct={scanLimit:500},We=Qe.fromClass(class{constructor(t){({deco:this.deco,gutter:this.gutter}=Ce(t))}update(t){(t.docChanged||t.viewportChanged||ut(t.startState,t.state)||ht(t.startState,t.state))&&({deco:this.deco,gutter:this.gutter}=Ce(t.view))}},{decorations:t=>t.deco});function ut(t,e){return t.field(w,!1)!=e.field(w,!1)}function ht(t,e){return t.facet(D)!=e.facet(D)}const pe=M.line({class:"cm-changedLine"}),He=M.mark({class:"cm-changedText"}),mt=M.mark({tagName:"ins",class:"cm-insertedLine"}),gt=M.mark({tagName:"del",class:"cm-deletedLine"}),xe=new class extends Q{constructor(){super(...arguments),this.elementClass="cm-changedLineGutter"}};function pt(t,e,n,l,i,r){let o=n?t.fromA:t.fromB,a=n?t.toA:t.toB,f=0;if(o!=a){i.add(o,o,pe),i.add(o,a,n?gt:mt),r&&r.add(o,o,xe);for(let c=e.iterRange(o,a-1),s=o;!c.next().done;){if(c.lineBreak){s++,i.add(s,s,pe),r&&r.add(s,s,xe);continue}let d=s+c.value.length;if(l)for(;f<t.changes.length;){let u=t.changes[f],h=o+(n?u.fromA:u.fromB),m=o+(n?u.toA:u.toB),p=Math.max(s,h),g=Math.min(d,m);if(p<g&&i.add(p,g,He),m<d)f++;else break}s=d}}}function Ce(t){let e=t.state.field(w),{side:n,highlightChanges:l,markGutter:i,overrideChunk:r}=t.state.facet(D),o=n=="a",a=new P,f=i?new P:null,{from:c,to:s}=t.viewport;for(let d of e){if((o?d.fromA:d.fromB)>=s)break;(o?d.toA:d.toB)>c&&(!r||!r(t.state,d,a,f))&&pt(d,t.state.doc,o,l,a,f)}return{deco:a.finish(),gutter:f&&f.finish()}}const $=K.define({map:(t,e)=>e.mapPos(t)});class xt extends Z{constructor(e){super(),this.lines=e}eq(e){return this.lines==e.lines}toDOM(e){let n=document.createElement("div");return n.className="cm-collapsedLines",n.textContent=e.state.phrase("$ unchanged lines",this.lines),n.addEventListener("click",l=>{let i=e.posAtDOM(l.target);e.dispatch({effects:$.of(i)});let{side:r,sibling:o}=e.state.facet(D);o&&o().dispatch({effects:$.of(Ct(i,e.state.field(w),r=="a"))})}),n}ignoreEvent(e){return e instanceof MouseEvent}get estimatedHeight(){return 27}get type(){return"collapsed-unchanged-code"}}function Ct(t,e,n){let l=0,i=0;for(let r=0;;r++){let o=r<e.length?e[r]:null;if(!o||(n?o.fromA:o.fromB)>=t)return i+(t-l);[l,i]=n?[o.toA,o.toB]:[o.toB,o.toA]}}const At=U.define({create(t){return M.none},update(t,e){t=t.map(e.changes);for(let n of e.effects)n.is($)&&(t=t.update({filter:l=>l!=n.value}));if(t.size&&e.state.field(w)!=e.startState.field(w,!1)){let n=e.state.facet(D).side=="a",l=[];for(let i of e.state.field(w))t.between(n?i.fromA:i.fromB,n?i.toA:i.toB,r=>{l.push(r)});l.length&&(t=t.update({filter:i=>l.indexOf(i)<0}))}return t},provide:t=>S.decorations.from(t)});function kt({margin:t=3,minSize:e=4}){return At.init(n=>wt(n,t,e))}function wt(t,e,n){let l=new P,i=t.facet(D).side=="a",r=t.field(w),o=1;for(let a=0;;a++){let f=a<r.length?r[a]:null,c=a?o+e:1,s=f?t.doc.lineAt(i?f.fromA:f.fromB).number-1-e:t.doc.lines,d=s-c+1;if(d>=n&&l.add(t.doc.line(c).from,t.doc.line(s).to,M.replace({widget:new xt(d),block:!0})),!f)break;o=t.doc.lineAt(Math.min(t.doc.length,i?f.toA:f.toB)).number}return l.finish()}const bt=S.baseTheme({".cm-mergeView & .cm-scroller, .cm-mergeView &":{height:"auto !important",overflowY:"visible !important"},"&.cm-merge-a .cm-changedLine, .cm-deletedChunk":{backgroundColor:"rgba(160, 128, 100, .08)"},"&.cm-merge-b .cm-changedLine, .cm-inlineChangedLine":{backgroundColor:"rgba(100, 160, 128, .08)"},"&light.cm-merge-a .cm-changedText, &light .cm-deletedChunk .cm-deletedText":{background:"linear-gradient(#ee443366, #ee443366) bottom/100% 2px no-repeat"},"&dark.cm-merge-a .cm-changedText, &dark .cm-deletedChunk .cm-deletedText":{background:"linear-gradient(#ffaa9966, #ffaa9966) bottom/100% 2px no-repeat"},"&light.cm-merge-b .cm-changedText":{background:"linear-gradient(#22bb22aa, #22bb22aa) bottom/100% 2px no-repeat"},"&dark.cm-merge-b .cm-changedText":{background:"linear-gradient(#88ff88aa, #88ff88aa) bottom/100% 2px no-repeat"},"&.cm-merge-b .cm-deletedText":{background:"#ff000033"},".cm-insertedLine, .cm-deletedLine, .cm-deletedLine del":{textDecoration:"none"},".cm-deletedChunk":{paddingLeft:"6px","& .cm-chunkButtons":{position:"absolute",insetInlineEnd:"5px"},"& button":{border:"none",cursor:"pointer",color:"white",margin:"0 2px",borderRadius:"3px","&[name=accept]":{background:"#2a2"},"&[name=reject]":{background:"#d43"}}},".cm-collapsedLines":{padding:"5px 5px 5px 10px",cursor:"pointer","&:before":{content:'"⦚"',marginInlineEnd:"7px"},"&:after":{content:'"⦚"',marginInlineStart:"7px"}},"&light .cm-collapsedLines":{color:"#444",background:"linear-gradient(to bottom, transparent 0, #f3f3f3 30%, #f3f3f3 70%, transparent 100%)"},"&dark .cm-collapsedLines":{color:"#ddd",background:"linear-gradient(to bottom, transparent 0, #222 30%, #222 70%, transparent 100%)"},".cm-changeGutter":{width:"3px",paddingLeft:"1px"},"&light.cm-merge-a .cm-changedLineGutter, &light .cm-deletedLineGutter":{background:"#e43"},"&dark.cm-merge-a .cm-changedLineGutter, &dark .cm-deletedLineGutter":{background:"#fa9"},"&light.cm-merge-b .cm-changedLineGutter":{background:"#2b2"},"&dark.cm-merge-b .cm-changedLineGutter":{background:"#8f8"},".cm-inlineChangedLineGutter":{background:"#75d"}}),vt=new class extends Q{constructor(){super(...arguments),this.elementClass="cm-deletedLineGutter"}},Bt=ve.low(Ke({class:"cm-changeGutter",markers:t=>{var e;return((e=t.plugin(We))===null||e===void 0?void 0:e.gutter)||tt.empty},widgetMarker:(t,e)=>e instanceof Pe?vt:null}));function Lt(t){var e;let n=typeof t.original=="string"?be.of(t.original.split(/\r?\n/)):t.original,l=t.diffConfig||ct;return[ve.low(We),yt,bt,S.editorAttributes.of({class:"cm-merge-b"}),Re.of((i,r)=>{let o=r.effects.find(a=>a.is(te));return o&&(i=N.updateA(i,o.value.doc,r.startState.doc,o.value.changes,l)),r.docChanged&&(i=N.updateB(i,r.state.field(O),r.newDoc,r.changes,l)),i}),D.of({highlightChanges:t.highlightChanges!==!1,markGutter:t.gutter!==!1,syntaxHighlightDeletions:t.syntaxHighlightDeletions!==!1,syntaxHighlightDeletionsMaxLength:3e3,mergeControls:(e=t.mergeControls)!==null&&e!==void 0?e:!0,overrideChunk:t.allowInlineDiffs?Ot:void 0,side:"b"}),O.init(()=>n),Bt,t.collapseUnchanged?kt(t.collapseUnchanged):[],w.init(i=>N.build(n,i.doc,l))]}const te=K.define(),O=U.define({create:()=>be.empty,update(t,e){for(let n of e.effects)n.is(te)&&(t=n.value.doc);return t}}),Ae=new WeakMap;class Pe extends Z{constructor(e){super(),this.buildDOM=e,this.dom=null}eq(e){return this.dom==e.dom}toDOM(e){return this.dom||(this.dom=this.buildDOM(e))}}function Dt(t,e,n){let l=Ae.get(e.changes);if(l)return l;let i=o=>{let{highlightChanges:a,syntaxHighlightDeletions:f,syntaxHighlightDeletionsMaxLength:c,mergeControls:s}=t.facet(D),d=document.createElement("div");if(d.className="cm-deletedChunk",s){let b=d.appendChild(document.createElement("div"));b.className="cm-chunkButtons";let B=A=>{A.preventDefault(),Mt(o,o.posAtDOM(d))},L=A=>{A.preventDefault(),St(o,o.posAtDOM(d))};if(typeof s=="function")b.appendChild(s("accept",B)),b.appendChild(s("reject",L));else{let A=b.appendChild(document.createElement("button"));A.name="accept",A.textContent=t.phrase("Accept"),A.onmousedown=B;let v=b.appendChild(document.createElement("button"));v.name="reject",v.textContent=t.phrase("Reject"),v.onmousedown=L}}if(n||e.fromA>=e.toA)return d;let u=o.state.field(O).sliceString(e.fromA,e.endA),h=f&&t.facet(Ze),m=T(),p=e.changes,g=0,k=!1;function T(){let b=d.appendChild(document.createElement("div"));return b.className="cm-deletedLine",b.appendChild(document.createElement("del"))}function I(b,B,L){for(let A=b;A<B;){if(u.charAt(A)==`
1
+ import{j as C,B as Ue,X as Ve,r as H,c_ as qe,C as ze,i as _e,ej as $e}from"./index-DB2lVKuV.js";import{T as be,P as ve,E as S,S as U,g as Ke,V as Qe,F as Be,a as K,R as P,D as M,G as Q,W as Z,l as Ze,h as Xe,b as Ye,c as et,d as tt,e as le,s as nt,j as rt,f as it}from"./code-editor-CTdKUDPY.js";function It({sources:t,onRemove:e,disabled:n,wrap:l=!1}){return C.jsx(C.Fragment,{children:t.length>0?C.jsx("ul",{className:"space-y-2",children:t.map(i=>C.jsxs("li",{className:"flex items-start gap-2 rounded-lg border bg-background p-2",children:[C.jsxs("div",{className:"min-w-0 flex-1",children:[C.jsx("div",{className:"truncate font-mono text-xs font-medium",children:i.name}),C.jsx("div",{className:l?"whitespace-pre-wrap break-words text-xs text-muted-foreground":"truncate text-xs text-muted-foreground",children:i.query})]}),e?C.jsx(Ue,{type:"button",variant:"ghost",size:"icon",className:"h-7 w-7 shrink-0","aria-label":`Remove source ${i.name}`,disabled:n,onClick:()=>e?.(i),children:C.jsx(Ve,{className:"h-3.5 w-3.5"})}):null]},i.query))}):null})}class x{constructor(e,n,l,i){this.fromA=e,this.toA=n,this.fromB=l,this.toB=i}offset(e,n=e){return new x(this.fromA+e,this.toA+e,this.fromB+n,this.toB+n)}}function j(t,e,n,l,i,r){if(t==l)return[];let o=Y(t,e,n,l,i,r),a=ee(t,e+o,n,l,i+o,r);e+=o,n-=a,i+=o,r-=a;let f=n-e,c=r-i;if(!f||!c)return[new x(e,n,i,r)];if(f>c){let d=t.slice(e,n).indexOf(l.slice(i,r));if(d>-1)return[new x(e,e+d,i,i),new x(e+d+c,n,r,r)]}else if(c>f){let d=l.slice(i,r).indexOf(t.slice(e,n));if(d>-1)return[new x(e,e,i,i+d),new x(n,n,i+d+f,r)]}if(f==1||c==1)return[new x(e,n,i,r)];let s=Me(t,e,n,l,i,r);if(s){let[d,u,h]=s;return j(t,e,d,l,i,u).concat(j(t,d+h,n,l,u+h,r))}return lt(t,e,n,l,i,r)}let G=1e9,R=0,X=!1;function lt(t,e,n,l,i,r){let o=n-e,a=r-i;if(G<1e9&&Math.min(o,a)>G*16||R>0&&Date.now()>R)return Math.min(o,a)>G*64?[new x(e,n,i,r)]:oe(t,e,n,l,i,r);let f=Math.ceil((o+a)/2);q.reset(f),z.reset(f);let c=(h,m)=>t.charCodeAt(e+h)==l.charCodeAt(i+m),s=(h,m)=>t.charCodeAt(n-h-1)==l.charCodeAt(r-m-1),d=(o-a)%2!=0?z:null,u=d?null:q;for(let h=0;h<f;h++){if(h>G||R>0&&!(h&63)&&Date.now()>R)return oe(t,e,n,l,i,r);let m=q.advance(h,o,a,f,d,!1,c)||z.advance(h,o,a,f,u,!0,s);if(m)return ot(t,e,n,e+m[0],l,i,r,i+m[1])}return[new x(e,n,i,r)]}class Le{constructor(){this.vec=[]}reset(e){this.len=e<<1;for(let n=0;n<this.len;n++)this.vec[n]=-1;this.vec[e+1]=0,this.start=this.end=0}advance(e,n,l,i,r,o,a){for(let f=-e+this.start;f<=e-this.end;f+=2){let c=i+f,s=f==-e||f!=e&&this.vec[c-1]<this.vec[c+1]?this.vec[c+1]:this.vec[c-1]+1,d=s-f;for(;s<n&&d<l&&a(s,d);)s++,d++;if(this.vec[c]=s,s>n)this.end+=2;else if(d>l)this.start+=2;else if(r){let u=i+(n-l)-f;if(u>=0&&u<this.len&&r.vec[u]!=-1)if(o){let h=r.vec[u];if(h>=n-s)return[h,i+h-u]}else{let h=n-r.vec[u];if(s>=h)return[s,d]}}}return null}}const q=new Le,z=new Le;function ot(t,e,n,l,i,r,o,a){let f=!1;return!E(t,l)&&++l==n&&(f=!0),!E(i,a)&&++a==o&&(f=!0),f?[new x(e,n,r,o)]:j(t,e,l,i,r,a).concat(j(t,l,n,i,a,o))}function De(t,e){let n=1,l=Math.min(t,e);for(;n<l;)n=n<<1;return n}function Y(t,e,n,l,i,r){if(e==n||e==r||t.charCodeAt(e)!=l.charCodeAt(i))return 0;let o=De(n-e,r-i);for(let a=e,f=i;;){let c=a+o,s=f+o;if(c>n||s>r||t.slice(a,c)!=l.slice(f,s)){if(o==1)return a-e-(E(t,a)?0:1);o=o>>1}else{if(c==n||s==r)return c-e;a=c,f=s}}}function ee(t,e,n,l,i,r){if(e==n||i==r||t.charCodeAt(n-1)!=l.charCodeAt(r-1))return 0;let o=De(n-e,r-i);for(let a=n,f=r;;){let c=a-o,s=f-o;if(c<e||s<i||t.slice(c,a)!=l.slice(s,f)){if(o==1)return n-a-(E(t,a)?0:1);o=o>>1}else{if(c==e||s==i)return n-c;a=c,f=s}}}function _(t,e,n,l,i,r,o,a){let f=l.slice(i,r),c=null;for(;;){if(c||o<a)return c;for(let s=e+o;;){E(t,s)||s++;let d=s+o;if(E(t,d)||(d+=d==s+1?1:-1),d>=n)break;let u=t.slice(s,d),h=-1;for(;(h=f.indexOf(u,h+1))!=-1;){let m=Y(t,d,n,l,i+h+u.length,r),p=ee(t,e,s,l,i,i+h),g=u.length+m+p;(!c||c[2]<g)&&(c=[s-p,i+h-p,g])}s=d}if(a<0)return c;o=o>>1}}function Me(t,e,n,l,i,r){let o=n-e,a=r-i;if(o<a){let f=Me(l,i,r,t,e,n);return f&&[f[1],f[0],f[2]]}return o<4||a*2<o?null:_(t,e,n,l,i,r,Math.floor(o/4),-1)}function oe(t,e,n,l,i,r){X=!0;let o=n-e,a=r-i,f;if(o<a){let u=_(l,i,r,t,e,n,Math.floor(o/6),50);f=u&&[u[1],u[0],u[2]]}else f=_(t,e,n,l,i,r,Math.floor(a/6),50);if(!f)return[new x(e,n,i,r)];let[c,s,d]=f;return j(t,e,c,l,i,s).concat(j(t,c+d,n,l,s+d,r))}function Se(t,e){for(let n=1;n<t.length;n++){let l=t[n-1],i=t[n];l.toA>i.fromA-e&&l.toB>i.fromB-e&&(t[n-1]=new x(l.fromA,i.toA,l.fromB,i.toB),t.splice(n--,1))}}function at(t,e,n){for(;;){Se(n,1);let l=!1;for(let i=0;i<n.length;i++){let r=n[i],o,a;(o=Y(t,r.fromA,r.toA,e,r.fromB,r.toB))&&(r=n[i]=new x(r.fromA+o,r.toA,r.fromB+o,r.toB)),(a=ee(t,r.fromA,r.toA,e,r.fromB,r.toB))&&(r=n[i]=new x(r.fromA,r.toA-a,r.fromB,r.toB-a));let f=r.toA-r.fromA,c=r.toB-r.fromB;if(f&&c)continue;let s=r.fromA-(i?n[i-1].toA:0),d=(i<n.length-1?n[i+1].fromA:t.length)-r.toA;if(!s||!d)continue;let u=f?t.slice(r.fromA,r.toA):e.slice(r.fromB,r.toB);s<=u.length&&t.slice(r.fromA-s,r.fromA)==u.slice(u.length-s)?(n[i]=new x(r.fromA-s,r.toA-s,r.fromB-s,r.toB-s),l=!0):d<=u.length&&t.slice(r.toA,r.toA+d)==u.slice(0,d)&&(n[i]=new x(r.fromA+d,r.toA+d,r.fromB+d,r.toB+d),l=!0)}if(!l)break}return n}function st(t,e,n){for(let l=0,i=0;i<t.length;i++){let r=t[i],o=r.toA-r.fromA,a=r.toB-r.fromB;if(o&&a||o>3||a>3){let f=i==t.length-1?e.length:t[i+1].fromA,c=r.fromA-l,s=f-r.toA,d=se(e,r.fromA,c),u=ae(e,r.toA,s),h=r.fromA-d,m=u-r.toA;if((!o||!a)&&h&&m){let p=Math.max(o,a),[g,k,T]=o?[e,r.fromA,r.toA]:[n,r.fromB,r.toB];p>h&&e.slice(d,r.fromA)==g.slice(T-h,T)?(r=t[i]=new x(d,d+o,r.fromB-h,r.toB-h),d=r.fromA,u=ae(e,r.toA,f-r.toA)):p>m&&e.slice(r.toA,u)==g.slice(k,k+m)&&(r=t[i]=new x(u-o,u,r.fromB+m,r.toB+m),u=r.toA,d=se(e,r.fromA,r.fromA-l)),h=r.fromA-d,m=u-r.toA}if(h||m)r=t[i]=new x(r.fromA-h,r.toA+m,r.fromB-h,r.toB+m);else if(o){if(!a){let p=fe(e,r.fromA,r.toA),g,k=p<0?-1:de(e,r.toA,r.fromA);p>-1&&(g=p-r.fromA)<=s&&e.slice(r.fromA,p)==e.slice(r.toA,r.toA+g)?r=t[i]=r.offset(g):k>-1&&(g=r.toA-k)<=c&&e.slice(r.fromA-g,r.fromA)==e.slice(k,r.toA)&&(r=t[i]=r.offset(-g))}}else{let p=fe(n,r.fromB,r.toB),g,k=p<0?-1:de(n,r.toB,r.fromB);p>-1&&(g=p-r.fromB)<=s&&n.slice(r.fromB,p)==n.slice(r.toB,r.toB+g)?r=t[i]=r.offset(g):k>-1&&(g=r.toB-k)<=c&&n.slice(r.fromB-g,r.fromB)==n.slice(k,r.toB)&&(r=t[i]=r.offset(-g))}}l=r.toA}return Se(t,3),t}let y;try{y=new RegExp("[\\p{Alphabetic}\\p{Number}]","u")}catch{}function ye(t){return t>48&&t<58||t>64&&t<91||t>96&&t<123}function je(t,e){if(e==t.length)return 0;let n=t.charCodeAt(e);return n<192?ye(n)?1:0:y?!Oe(n)||e==t.length-1?y.test(String.fromCharCode(n))?1:0:y.test(t.slice(e,e+2))?2:0:0}function Ne(t,e){if(!e)return 0;let n=t.charCodeAt(e-1);return n<192?ye(n)?1:0:y?!Te(n)||e==1?y.test(String.fromCharCode(n))?1:0:y.test(t.slice(e-2,e))?2:0:0}const Ee=8;function ae(t,e,n){if(e==t.length||!Ne(t,e))return e;for(let l=e,i=e+n,r=0;r<Ee;r++){let o=je(t,l);if(!o||l+o>i)return l;l+=o}return e}function se(t,e,n){if(!e||!je(t,e))return e;for(let l=e,i=e-n,r=0;r<Ee;r++){let o=Ne(t,l);if(!o||l-o<i)return l;l-=o}return e}function de(t,e,n){for(;e!=n;e--)if(t.charCodeAt(e-1)==10)return e;return-1}function fe(t,e,n){for(;e!=n;e++)if(t.charCodeAt(e)==10)return e;return-1}const Oe=t=>t>=55296&&t<=56319,Te=t=>t>=56320&&t<=57343;function E(t,e){return!e||e==t.length||!Oe(t.charCodeAt(e-1))||!Te(t.charCodeAt(e))}function dt(t,e,n){var l;let i=n?.override;return i?i(t,e):(G=((l=n?.scanLimit)!==null&&l!==void 0?l:1e9)>>1,R=n?.timeout?Date.now()+n.timeout:0,X=!1,at(t,e,j(t,0,t.length,e,0,e.length)))}function Fe(){return!X}function Ge(t,e,n){return st(dt(t,e,n),t,e)}const D=Be.define({combine:t=>t[0]}),ft=K.define(),Re=Be.define(),w=U.define({create(t){return null},update(t,e){for(let n of e.effects)n.is(ft)&&(t=n.value);for(let n of e.state.facet(Re))t=n(t,e);return t}});class N{constructor(e,n,l,i,r,o=!0){this.changes=e,this.fromA=n,this.toA=l,this.fromB=i,this.toB=r,this.precise=o}offset(e,n){return e||n?new N(this.changes,this.fromA+e,this.toA+e,this.fromB+n,this.toB+n,this.precise):this}get endA(){return Math.max(this.fromA,this.toA-1)}get endB(){return Math.max(this.fromB,this.toB-1)}static build(e,n,l){let i=Ge(e.toString(),n.toString(),l);return Ie(i,e,n,0,0,Fe())}static updateA(e,n,l,i,r){return ge(me(e,i,!0,l.length),e,n,l,r)}static updateB(e,n,l,i,r){return ge(me(e,i,!1,n.length),e,n,l,r)}}function ce(t,e,n,l){let i=n.lineAt(t),r=l.lineAt(e);return i.to==t&&r.to==e&&t<n.length&&e<l.length?[t+1,e+1]:[i.from,r.from]}function ue(t,e,n,l){let i=n.lineAt(t),r=l.lineAt(e);return i.from==t&&r.from==e?[t,e]:[i.to+1,r.to+1]}function Ie(t,e,n,l,i,r){let o=[];for(let a=0;a<t.length;a++){let f=t[a],[c,s]=ce(f.fromA+l,f.fromB+i,e,n),[d,u]=ue(f.toA+l,f.toB+i,e,n),h=[f.offset(-c+l,-s+i)];for(;a<t.length-1;){let m=t[a+1],[p,g]=ce(m.fromA+l,m.fromB+i,e,n);if(p>d+1&&g>u+1)break;h.push(m.offset(-c+l,-s+i)),[d,u]=ue(m.toA+l,m.toB+i,e,n),a++}o.push(new N(h,c,Math.max(c,d),s,Math.max(s,u),r))}return o}const W=1e3;function he(t,e,n,l){let i=0,r=t.length;for(;;){if(i==r){let s=0,d=0;i&&({toA:s,toB:d}=t[i-1]);let u=e-(n?s:d);return[s+u,d+u]}let o=i+r>>1,a=t[o],[f,c]=n?[a.fromA,a.toA]:[a.fromB,a.toB];if(f>e)r=o;else if(c<=e)i=o+1;else return l?[a.fromA,a.fromB]:[a.toA,a.toB]}}function me(t,e,n,l){let i=[];return e.iterChangedRanges((r,o,a,f)=>{let c=0,s=n?e.length:l,d=0,u=n?l:e.length;r>W&&([c,d]=he(t,r-W,n,!0)),o<e.length-W&&([s,u]=he(t,o+W,n,!1));let h=f-a-(o-r),m,[p,g]=n?[h,0]:[0,h];i.length&&(m=i[i.length-1]).toA>=c?i[i.length-1]={fromA:m.fromA,fromB:m.fromB,toA:s,toB:u,diffA:m.diffA+p,diffB:m.diffB+g}:i.push({fromA:c,toA:s,fromB:d,toB:u,diffA:p,diffB:g})}),i}function ge(t,e,n,l,i){if(!t.length)return e;let r=[];for(let o=0,a=0,f=0,c=0;;o++){let s=o==t.length?null:t[o],d=s?s.fromA+a:n.length,u=s?s.fromB+f:l.length;for(;c<e.length;){let g=e[c];if(s&&(g.toA+a>d||g.toB+f>u))break;r.push(g.offset(a,f)),c++}if(!s)break;let h=s.toA+a+s.diffA,m=s.toB+f+s.diffB,p=Ge(n.sliceString(d,h),l.sliceString(u,m),i);for(let g of Ie(p,n,l,d,u,Fe()))r.push(g);for(a+=s.diffA,f+=s.diffB;c<e.length;){let g=e[c];if(g.fromA+a>h&&g.fromB+f>m)break;c++}}return r}const ct={scanLimit:500},We=Qe.fromClass(class{constructor(t){({deco:this.deco,gutter:this.gutter}=Ce(t))}update(t){(t.docChanged||t.viewportChanged||ut(t.startState,t.state)||ht(t.startState,t.state))&&({deco:this.deco,gutter:this.gutter}=Ce(t.view))}},{decorations:t=>t.deco});function ut(t,e){return t.field(w,!1)!=e.field(w,!1)}function ht(t,e){return t.facet(D)!=e.facet(D)}const pe=M.line({class:"cm-changedLine"}),He=M.mark({class:"cm-changedText"}),mt=M.mark({tagName:"ins",class:"cm-insertedLine"}),gt=M.mark({tagName:"del",class:"cm-deletedLine"}),xe=new class extends Q{constructor(){super(...arguments),this.elementClass="cm-changedLineGutter"}};function pt(t,e,n,l,i,r){let o=n?t.fromA:t.fromB,a=n?t.toA:t.toB,f=0;if(o!=a){i.add(o,o,pe),i.add(o,a,n?gt:mt),r&&r.add(o,o,xe);for(let c=e.iterRange(o,a-1),s=o;!c.next().done;){if(c.lineBreak){s++,i.add(s,s,pe),r&&r.add(s,s,xe);continue}let d=s+c.value.length;if(l)for(;f<t.changes.length;){let u=t.changes[f],h=o+(n?u.fromA:u.fromB),m=o+(n?u.toA:u.toB),p=Math.max(s,h),g=Math.min(d,m);if(p<g&&i.add(p,g,He),m<d)f++;else break}s=d}}}function Ce(t){let e=t.state.field(w),{side:n,highlightChanges:l,markGutter:i,overrideChunk:r}=t.state.facet(D),o=n=="a",a=new P,f=i?new P:null,{from:c,to:s}=t.viewport;for(let d of e){if((o?d.fromA:d.fromB)>=s)break;(o?d.toA:d.toB)>c&&(!r||!r(t.state,d,a,f))&&pt(d,t.state.doc,o,l,a,f)}return{deco:a.finish(),gutter:f&&f.finish()}}const $=K.define({map:(t,e)=>e.mapPos(t)});class xt extends Z{constructor(e){super(),this.lines=e}eq(e){return this.lines==e.lines}toDOM(e){let n=document.createElement("div");return n.className="cm-collapsedLines",n.textContent=e.state.phrase("$ unchanged lines",this.lines),n.addEventListener("click",l=>{let i=e.posAtDOM(l.target);e.dispatch({effects:$.of(i)});let{side:r,sibling:o}=e.state.facet(D);o&&o().dispatch({effects:$.of(Ct(i,e.state.field(w),r=="a"))})}),n}ignoreEvent(e){return e instanceof MouseEvent}get estimatedHeight(){return 27}get type(){return"collapsed-unchanged-code"}}function Ct(t,e,n){let l=0,i=0;for(let r=0;;r++){let o=r<e.length?e[r]:null;if(!o||(n?o.fromA:o.fromB)>=t)return i+(t-l);[l,i]=n?[o.toA,o.toB]:[o.toB,o.toA]}}const At=U.define({create(t){return M.none},update(t,e){t=t.map(e.changes);for(let n of e.effects)n.is($)&&(t=t.update({filter:l=>l!=n.value}));if(t.size&&e.state.field(w)!=e.startState.field(w,!1)){let n=e.state.facet(D).side=="a",l=[];for(let i of e.state.field(w))t.between(n?i.fromA:i.fromB,n?i.toA:i.toB,r=>{l.push(r)});l.length&&(t=t.update({filter:i=>l.indexOf(i)<0}))}return t},provide:t=>S.decorations.from(t)});function kt({margin:t=3,minSize:e=4}){return At.init(n=>wt(n,t,e))}function wt(t,e,n){let l=new P,i=t.facet(D).side=="a",r=t.field(w),o=1;for(let a=0;;a++){let f=a<r.length?r[a]:null,c=a?o+e:1,s=f?t.doc.lineAt(i?f.fromA:f.fromB).number-1-e:t.doc.lines,d=s-c+1;if(d>=n&&l.add(t.doc.line(c).from,t.doc.line(s).to,M.replace({widget:new xt(d),block:!0})),!f)break;o=t.doc.lineAt(Math.min(t.doc.length,i?f.toA:f.toB)).number}return l.finish()}const bt=S.baseTheme({".cm-mergeView & .cm-scroller, .cm-mergeView &":{height:"auto !important",overflowY:"visible !important"},"&.cm-merge-a .cm-changedLine, .cm-deletedChunk":{backgroundColor:"rgba(160, 128, 100, .08)"},"&.cm-merge-b .cm-changedLine, .cm-inlineChangedLine":{backgroundColor:"rgba(100, 160, 128, .08)"},"&light.cm-merge-a .cm-changedText, &light .cm-deletedChunk .cm-deletedText":{background:"linear-gradient(#ee443366, #ee443366) bottom/100% 2px no-repeat"},"&dark.cm-merge-a .cm-changedText, &dark .cm-deletedChunk .cm-deletedText":{background:"linear-gradient(#ffaa9966, #ffaa9966) bottom/100% 2px no-repeat"},"&light.cm-merge-b .cm-changedText":{background:"linear-gradient(#22bb22aa, #22bb22aa) bottom/100% 2px no-repeat"},"&dark.cm-merge-b .cm-changedText":{background:"linear-gradient(#88ff88aa, #88ff88aa) bottom/100% 2px no-repeat"},"&.cm-merge-b .cm-deletedText":{background:"#ff000033"},".cm-insertedLine, .cm-deletedLine, .cm-deletedLine del":{textDecoration:"none"},".cm-deletedChunk":{paddingLeft:"6px","& .cm-chunkButtons":{position:"absolute",insetInlineEnd:"5px"},"& button":{border:"none",cursor:"pointer",color:"white",margin:"0 2px",borderRadius:"3px","&[name=accept]":{background:"#2a2"},"&[name=reject]":{background:"#d43"}}},".cm-collapsedLines":{padding:"5px 5px 5px 10px",cursor:"pointer","&:before":{content:'"⦚"',marginInlineEnd:"7px"},"&:after":{content:'"⦚"',marginInlineStart:"7px"}},"&light .cm-collapsedLines":{color:"#444",background:"linear-gradient(to bottom, transparent 0, #f3f3f3 30%, #f3f3f3 70%, transparent 100%)"},"&dark .cm-collapsedLines":{color:"#ddd",background:"linear-gradient(to bottom, transparent 0, #222 30%, #222 70%, transparent 100%)"},".cm-changeGutter":{width:"3px",paddingLeft:"1px"},"&light.cm-merge-a .cm-changedLineGutter, &light .cm-deletedLineGutter":{background:"#e43"},"&dark.cm-merge-a .cm-changedLineGutter, &dark .cm-deletedLineGutter":{background:"#fa9"},"&light.cm-merge-b .cm-changedLineGutter":{background:"#2b2"},"&dark.cm-merge-b .cm-changedLineGutter":{background:"#8f8"},".cm-inlineChangedLineGutter":{background:"#75d"}}),vt=new class extends Q{constructor(){super(...arguments),this.elementClass="cm-deletedLineGutter"}},Bt=ve.low(Ke({class:"cm-changeGutter",markers:t=>{var e;return((e=t.plugin(We))===null||e===void 0?void 0:e.gutter)||tt.empty},widgetMarker:(t,e)=>e instanceof Pe?vt:null}));function Lt(t){var e;let n=typeof t.original=="string"?be.of(t.original.split(/\r?\n/)):t.original,l=t.diffConfig||ct;return[ve.low(We),yt,bt,S.editorAttributes.of({class:"cm-merge-b"}),Re.of((i,r)=>{let o=r.effects.find(a=>a.is(te));return o&&(i=N.updateA(i,o.value.doc,r.startState.doc,o.value.changes,l)),r.docChanged&&(i=N.updateB(i,r.state.field(O),r.newDoc,r.changes,l)),i}),D.of({highlightChanges:t.highlightChanges!==!1,markGutter:t.gutter!==!1,syntaxHighlightDeletions:t.syntaxHighlightDeletions!==!1,syntaxHighlightDeletionsMaxLength:3e3,mergeControls:(e=t.mergeControls)!==null&&e!==void 0?e:!0,overrideChunk:t.allowInlineDiffs?Ot:void 0,side:"b"}),O.init(()=>n),Bt,t.collapseUnchanged?kt(t.collapseUnchanged):[],w.init(i=>N.build(n,i.doc,l))]}const te=K.define(),O=U.define({create:()=>be.empty,update(t,e){for(let n of e.effects)n.is(te)&&(t=n.value.doc);return t}}),Ae=new WeakMap;class Pe extends Z{constructor(e){super(),this.buildDOM=e,this.dom=null}eq(e){return this.dom==e.dom}toDOM(e){return this.dom||(this.dom=this.buildDOM(e))}}function Dt(t,e,n){let l=Ae.get(e.changes);if(l)return l;let i=o=>{let{highlightChanges:a,syntaxHighlightDeletions:f,syntaxHighlightDeletionsMaxLength:c,mergeControls:s}=t.facet(D),d=document.createElement("div");if(d.className="cm-deletedChunk",s){let b=d.appendChild(document.createElement("div"));b.className="cm-chunkButtons";let B=A=>{A.preventDefault(),Mt(o,o.posAtDOM(d))},L=A=>{A.preventDefault(),St(o,o.posAtDOM(d))};if(typeof s=="function")b.appendChild(s("accept",B)),b.appendChild(s("reject",L));else{let A=b.appendChild(document.createElement("button"));A.name="accept",A.textContent=t.phrase("Accept"),A.onmousedown=B;let v=b.appendChild(document.createElement("button"));v.name="reject",v.textContent=t.phrase("Reject"),v.onmousedown=L}}if(n||e.fromA>=e.toA)return d;let u=o.state.field(O).sliceString(e.fromA,e.endA),h=f&&t.facet(Ze),m=T(),p=e.changes,g=0,k=!1;function T(){let b=d.appendChild(document.createElement("div"));return b.className="cm-deletedLine",b.appendChild(document.createElement("del"))}function I(b,B,L){for(let A=b;A<B;){if(u.charAt(A)==`
2
2
  `){m.firstChild||m.appendChild(document.createElement("br")),m=T(),A++;continue}let v=B,ne=L+(k?" cm-deletedText":""),re=!1,V=u.indexOf(`
3
3
  `,A);if(V>-1&&V<B&&(v=V),a&&g<p.length){let F=Math.max(0,k?p[g].toA:p[g].fromA);F<=v&&(v=F,k&&g++,re=!0)}if(v>A){let F=document.createTextNode(u.slice(A,v));if(ne){let ie=m.appendChild(document.createElement("span"));ie.className=ne,ie.appendChild(F)}else m.appendChild(F);A=v}re&&(k=!k)}}if(h&&e.toA-e.fromA<=c){let b=h.parser.parse(u),B=0;Xe(b,{style:L=>Ye(t,L)},(L,A,v)=>{L>B&&I(B,L,""),I(L,A,v),B=A}),I(B,u.length,"")}else I(0,u.length,"");return m.firstChild||m.appendChild(document.createElement("br")),d},r=M.widget({block:!0,side:-1,widget:new Pe(i)});return Ae.set(e.changes,r),r}function Mt(t,e){let{state:n}=t,l=e??n.selection.main.head,i=t.state.field(w).find(f=>f.fromB<=l&&f.endB>=l);if(!i)return!1;let r=t.state.sliceDoc(i.fromB,Math.max(i.fromB,i.toB-1)),o=t.state.field(O);i.fromB!=i.toB&&i.toA<=o.length&&(r+=t.state.lineBreak);let a=et.of({from:i.fromA,to:Math.min(o.length,i.toA),insert:r},o.length);return t.dispatch({effects:te.of({doc:a.apply(o),changes:a}),userEvent:"accept"}),!0}function St(t,e){let{state:n}=t,l=e??n.selection.main.head,i=n.field(w).find(a=>a.fromB<=l&&a.endB>=l);if(!i)return!1;let o=n.field(O).sliceString(i.fromA,Math.max(i.fromA,i.toA-1));return i.fromA!=i.toA&&i.toB<=n.doc.length&&(o+=n.lineBreak),t.dispatch({changes:{from:i.fromB,to:Math.min(n.doc.length,i.toB),insert:o},userEvent:"revert"}),!0}function ke(t){let e=new P;for(let n of t.field(w)){let l=t.facet(D).overrideChunk&&Je(t,n);e.add(n.fromB,n.fromB,Dt(t,n,!!l))}return e.finish()}const yt=U.define({create:t=>ke(t),update(t,e){return e.state.field(w,!1)!=e.startState.field(w,!1)?ke(e.state):t},provide:t=>S.decorations.from(t)}),we=new WeakMap;function Je(t,e){let n=we.get(e);if(n!==void 0)return n;n=null;let l=t.field(O),i=t.doc,r=l.lineAt(e.endA).number-l.lineAt(e.fromA).number+1,o=i.lineAt(e.endB).number-i.lineAt(e.fromB).number+1;e:if(r==o&&r<10){let a=[],f=0,c=e.fromA,s=e.fromB;for(let d of e.changes){if(d.fromA<d.toA){f+=d.toA-d.fromA;let u=l.sliceString(c+d.fromA,c+d.toA);if(/\n/.test(u))break e;a.push(M.widget({widget:new jt(u),side:-1}).range(s+d.fromB))}d.fromB<d.toB&&a.push(He.range(s+d.fromB,s+d.toB))}f<e.endA-e.fromA-r*2&&(n=a)}return we.set(e,n),n}class jt extends Z{constructor(e){super(),this.text=e}eq(e){return this.text==e.text}toDOM(e){let n=document.createElement("del");return n.className="cm-deletedText",n.textContent=this.text,n}}const Nt=new class extends Q{constructor(){super(...arguments),this.elementClass="cm-inlineChangedLineGutter"}},Et=M.line({class:"cm-inlineChangedLine"});function Ot(t,e,n,l){let i=Je(t,e),r=0;if(!i)return!1;for(let o=t.doc.lineAt(e.fromB);;){for(l&&l.add(o.from,o.from,Nt),n.add(o.from,o.from,Et);r<i.length&&i[r].to<=o.to;){let a=i[r++];n.add(a.from,a.to,a.value)}if(o.to>=e.endB)break;o=t.doc.lineAt(o.to+1)}return!0}const Tt=S.theme({"&":{backgroundColor:"var(--background)",color:"var(--foreground)",fontSize:"12px",border:"1px solid var(--border)",borderRadius:"0.5rem",overflow:"hidden",width:"100%"},"& .cm-scroller":{overflow:"auto",maxHeight:"20rem",fontFamily:'ui-monospace, SFMono-Regular, "SF Mono", Menlo, monospace'},".cm-content":{padding:"6px 0"},".cm-content span":{color:"inherit"},".cm-gutters":{backgroundColor:"var(--muted)",color:"var(--muted-foreground)",border:"none",borderRight:"1px solid var(--border)"},".cm-changedLine":{backgroundColor:"color-mix(in oklch, var(--chart-2) 14%, transparent)"},".cm-changedText":{background:"color-mix(in oklch, var(--chart-2) 32%, transparent)"},".cm-deletedChunk":{backgroundColor:"color-mix(in oklch, var(--destructive) 10%, transparent)"},".cm-deletedText":{background:"color-mix(in oklch, var(--destructive) 28%, transparent)"},".cm-collapsedLines":{background:"var(--muted)",color:"var(--muted-foreground)",padding:"2px 8px"}});function J(t){if(Array.isArray(t))return t.map(J);if(t&&typeof t=="object"){const e=Object.create(null);for(const n of Object.keys(t).sort())e[n]=J(t[n]);return e}return t}function Ft({before:t,after:e}){const n=H.useRef(null);return H.useEffect(()=>{if(!n.current)return;const l=new S({state:le.create({doc:e,extensions:[le.readOnly.of(!0),S.editable.of(!1),S.lineWrapping,nt(it,{fallback:!0}),rt(),Lt({original:t,mergeControls:!1,gutter:!0,collapseUnchanged:{margin:3,minSize:4}}),Tt]}),parent:n.current});return()=>l.destroy()},[t,e]),C.jsx("div",{ref:n,className:"w-full"})}function Wt({before:t,after:e}){const[n,l]=H.useState(!1),i=H.useId();if(!t&&!e)return null;const r=!!(t&&e);return C.jsxs("div",{className:"mt-2",children:[C.jsxs("button",{type:"button",onClick:()=>l(o=>!o),"aria-expanded":n,"aria-controls":n?i:void 0,className:"flex items-center gap-1 text-xs text-muted-foreground transition-colors hover:text-foreground",children:[n?C.jsx(qe,{className:"h-3 w-3"}):C.jsx(ze,{className:"h-3 w-3"}),r?n?"Hide diff":"Show diff":n?"Hide details":"Show details"]}),n&&(r?C.jsx("div",{id:i,className:"mt-2",children:C.jsx(Ft,{before:JSON.stringify(J(t),null,2),after:JSON.stringify(J(e),null,2)})}):C.jsxs("div",{id:i,className:"mt-2",children:[C.jsx("p",{className:"mb-1 text-[10px] font-medium uppercase text-muted-foreground",children:e?"After":"Before"}),C.jsx("pre",{className:_e($e,"max-h-48 overflow-auto p-2 text-xs"),children:JSON.stringify(e??t,null,2)})]}))]})}export{It as A,Wt as J};
4
- //# sourceMappingURL=json-diff-OjtREegr.js.map
4
+ //# sourceMappingURL=json-diff-Ce6YAXzY.js.map
@@ -1,2 +1,2 @@
1
- import{j as s,bk as t,m as e,i as o}from"./index-BoqrvLHQ.js";function d({mark:a=!0}){return s.jsxs("div",{className:t,children:[a?s.jsx(e,{className:"h-7 w-7 shrink-0 rounded-md"}):null,s.jsxs("div",{className:"min-w-0 flex-1 space-y-1.5",children:[s.jsx(e,{className:"h-3.5 w-40 max-w-[60%]"}),s.jsx(e,{className:"h-3 w-64 max-w-[80%]"})]}),s.jsx(e,{className:"h-3 w-10 shrink-0"})]})}function x({label:a,rows:r=4,bordered:l=!0,className:n}){return s.jsx("div",{role:"status","aria-label":a,className:o(l&&"divide-y overflow-hidden rounded-lg border",n),children:Array.from({length:r},(m,i)=>s.jsx(d,{},i))})}export{x as L,d as a};
2
- //# sourceMappingURL=list-skeleton-CH0qQBYk.js.map
1
+ import{j as s,bs as t,n as e,i as o}from"./index-DB2lVKuV.js";function d({mark:a=!0}){return s.jsxs("div",{className:t,children:[a?s.jsx(e,{className:"h-7 w-7 shrink-0 rounded-md"}):null,s.jsxs("div",{className:"min-w-0 flex-1 space-y-1.5",children:[s.jsx(e,{className:"h-3.5 w-40 max-w-[60%]"}),s.jsx(e,{className:"h-3 w-64 max-w-[80%]"})]}),s.jsx(e,{className:"h-3 w-10 shrink-0"})]})}function x({label:a,rows:r=4,bordered:n=!0,className:l}){return s.jsx("div",{role:"status","aria-label":a,className:o(n&&"divide-y overflow-hidden rounded-lg border",l),children:Array.from({length:r},(m,i)=>s.jsx(d,{},i))})}export{x as L,d as a};
2
+ //# sourceMappingURL=list-skeleton-DLPBTnbR.js.map
@@ -0,0 +1,2 @@
1
+ import{r as s,j as e,B as Re,c as Ie,z as Pe,H as Me,ak as ze,W as Ae,al as Te,am as qe,an as j,ao as he,ap as _,aq as Oe,ar as Be,F as $e,ah as We,a5 as De,ai as He,as as fe}from"./index-DB2lVKuV.js";import{s as _e}from"./index-mSrdbx3C.js";import{C as Je,c as Ke}from"./card-C4oPCVh6.js";const M=()=>window.turnstile;let z=null;function Qe(){return M()?Promise.resolve(M()):z||(z=new Promise((a,l)=>{const o=document.createElement("script");o.src="https://challenges.cloudflare.com/turnstile/v0/api.js?render=explicit",o.async=!0;const p=()=>{clearTimeout(r),o.remove(),z=null,l(new Error("Verification could not load. Check your connection and try again."))},r=setTimeout(p,15e3);o.addEventListener("error",p,{once:!0}),o.addEventListener("load",()=>{clearTimeout(r),M()?a(M()):p()},{once:!0}),document.head.append(o)}),z)}function Ve({siteKey:a,onVerify:l,ref:o}){const p=s.useRef(null),r=s.useRef(null),[v,k]=s.useState(null),[c,J]=s.useState(0);return s.useImperativeHandle(o,()=>({reset:()=>{l(null),r.current&&M()?.reset(r.current)}}),[l]),s.useEffect(()=>{let d=!0;return k(null),l(null),Qe().then(x=>{!d||!p.current||(r.current=x.render(p.current,{sitekey:a,action:"auth",size:"flexible",theme:"auto",callback:m=>{d&&(k(null),l(m))},"expired-callback":()=>{d&&l(null)},"error-callback":()=>{d&&(l(null),k("Verification failed. Try again."))}}))}).catch(x=>{d&&k(x.message)}),()=>{d=!1,r.current&&M()?.remove(r.current),r.current=null}},[a,l,c]),e.jsxs("div",{className:"space-y-2",children:[e.jsx("div",{ref:p}),v&&e.jsxs("div",{role:"alert",className:"space-y-2 text-sm text-destructive",children:[e.jsx("p",{children:v}),e.jsx(Re,{type:"button",variant:"outline",size:"sm",onClick:()=>J(d=>d+1),children:"Retry verification"})]})]})}function P(a){if(!a||typeof a!="object")return null;const l=a.error;if(typeof l=="string")return l;if(l&&typeof l=="object"){const p=l.message;if(typeof p=="string"&&p.length>0)return p}const o=a.message;return typeof o=="string"&&o.length>0?o:null}async function pe(a,l){if(typeof window>"u")return;const o=window.PasswordCredential;if(!(!o||!navigator.credentials?.store))try{const p=new o({id:a,password:l});await navigator.credentials.store(p)}catch{}}function Ge({domain:a}){const[l,o]=s.useState(!1);return!(a.length>0&&a.length<=253&&/^[A-Za-z0-9.-]+$/.test(a))||l?e.jsx(he,{className:"w-4 h-4"}):e.jsx("img",{src:`https://www.google.com/s2/favicons?domain=${encodeURIComponent(a)}&sz=32`,alt:"",width:16,height:16,className:"h-4 w-4",onError:()=>o(!0)})}function R(a){return a?a.toLowerCase().replaceAll("_"," ").trim().includes("account not linked")?"This social account matches an existing Lobu user. Sign in with a magic link to verify ownership, then continue.":a:null}function Ye(a){return a==="two_factor_required"?"Your account uses two-factor authentication, so sign in below.":"Automatic sign-in only works on the computer running Lobu. Sign in below."}function tt(){const a=Ie(),l=Pe(),{session:o,isReady:p}=Me(),{data:r,isLoading:v,error:k}=ze(),c=Ae({from:"/auth/login"}),J=c.invitationOrg,[d,x]=s.useState("social"),[m,A]=s.useState(c.intent??"sign-in"),[K,ge]=s.useState(""),[u,Q]=s.useState(()=>c.loginHint??""),[E,xe]=s.useState(""),[L,be]=s.useState(""),[T,Z]=s.useState(""),[ye,X]=s.useState(!1),[h,g]=s.useState(null),[q,i]=s.useState(null),[b,we]=s.useState(null),O=s.useRef(null),[ee,te]=s.useState(!1),[je,ne]=s.useState(!1),[re,ve]=s.useState(!1),[V,ke]=s.useState(null),se=s.useRef(!1),N=c.callbackUrl?Te(c.callbackUrl):void 0,B=qe(J,c.loginHint),ae=c.mode==="extension",G=c.error==="account_not_linked",ie=R(c.errorDescription||c.error),$=Object.values(r?.social??{}).some(Boolean),C=!!r?.magicLink,W=!!r?.phone,y=!!r?.emailPassword,oe=!!r?.passkey,w=!!r?.singleUserMode,le=!!r?.hasUser,D=w&&V===null,I=d==="magic-link"&&C&&ee,S=s.useMemo(()=>{const t=[];return y&&t.push("email-password"),$&&t.push("social"),C&&t.push("magic-link"),W&&t.push("whatsapp"),t},[y,C,$,W]),Ne=s.useMemo(()=>y?S.filter(t=>t!=="magic-link"&&t!=="social"):S,[S,y]),Y=k instanceof Error?k.message:k?"Unable to load sign-in options.":null;s.useEffect(()=>{o&&(N?window.location.href=N:a({to:"/"}))},[o,a,N]),s.useEffect(()=>{!r||S.length===0||S.includes(d)||x(S[0])},[r,d,S]),s.useEffect(()=>{!C||!G||(x("magic-link"),c.loginHint&&!u&&Q(c.loginHint))},[C,G,c.loginHint,u]),s.useEffect(()=>{c.intent&&A(c.intent)},[c.intent]),s.useEffect(()=>{if(!w||!r)return;const t=le?"sign-in":"sign-up";m!==t&&A(t)},[w,le,r,m]);const ce=t=>new URL(t,window.location.origin).href,F=()=>ce(N??"/"),de=async(t,{quiet:n=!1}={})=>{g(t),i(null);try{const f=await _.social({provider:t,callbackURL:F(),newUserCallbackURL:N?F():ce(`/?onboard_provider=${encodeURIComponent(t)}`)}),U=P(f);if(U&&!n){const H=R(U);H?.toLowerCase().includes("magic link")&&x("magic-link"),i(H)}}catch(f){if(n)return;i(R(f instanceof Error?f.message:`Failed to sign in with ${t}`))}finally{g(null)}};s.useEffect(()=>{if(se.current||!p||o||v||!r||c.error)return;const t=c.provider;if(!t)return;se.current=!0;const n=Object.hasOwn(r.social??{},t)&&!!r.social?.[t];de(t,{quiet:!n})},[r,v,o,p,c.provider,c.error]);const ue=async()=>{if(u){if(r?.captcha&&!b)return i("Complete the verification first."),!1;g("magic-link"),i(null);try{const t=await _.magicLink({email:u,callbackURL:F(),fetchOptions:{headers:b?{"x-captcha-response":b}:{}}}),n=P(t);if(n)throw new Error(n);return te(!0),!0}catch(t){return i(t instanceof Error?t.message:"Failed to send magic link"),!1}finally{O.current?.reset(),g(null)}}},Ce=async t=>{t.preventDefault(),await ue()},Se=async t=>{if(t.preventDefault(),!(!u||!E)){if(r?.captcha&&!b){i("Complete the verification first.");return}g("email-password"),i(null);try{if(m==="sign-up"){const n=await Be.email({email:u,password:E,name:K||u.split("@")[0]||"User",callbackURL:F(),fetchOptions:{headers:b?{"x-captcha-response":b}:{}}}),f=P(n);if(f){i(R(f));return}if(await pe(u,E),await l.invalidateQueries({queryKey:["organizations"]}),w&&oe)try{await $e.passkey.addPasskey({name:K||`${navigator.platform||"This device"}`})}catch{}}else{const n=await _.email({email:u,password:E,callbackURL:F(),fetchOptions:{headers:b?{"x-captcha-response":b}:{}}}),f=P(n);if(f){i(R(f));return}if(!n?.data){i("Invalid email or password");return}if("twoFactorRedirect"in n.data&&n.data.twoFactorRedirect){await a({to:"/auth/two-factor",search:{callbackUrl:N??"/"}});return}await pe(u,E)}}catch(n){const f=n instanceof Error?n.message:typeof n=="string"?n:P(n);i(f||"Authentication failed")}finally{O.current?.reset(),g(null)}}},me=async()=>{i(null),ve(!0),g("local");try{const t=await Oe();if(!t.ok){if(t.status===403){const n=await t.json().catch(()=>null);ke(Ye(n?.error));return}i("Could not sign in to your local install.");return}window.location.href=F()}catch{i("Could not sign in to your local install.")}finally{g(null)}};s.useEffect(()=>{D&&r&&!o&&!re&&me()},[D,r,o,re]);const Ee=async()=>{if(r?.captcha&&!b){i("Complete the verification first.");return}if(!u){i("Enter your email address first to reset your password.");return}g("reset-password-request"),i(null);try{const t=`${window.location.origin}/auth/reset-password`,n=await We(`${De}/api/auth/request-password-reset`,{method:"POST",headers:{"Content-Type":"application/json",...b?{"x-captcha-response":b}:{}},credentials:"include",body:JSON.stringify({email:u,redirectTo:t})});if(!n.ok)throw await He(n);ne(!0)}catch(t){i(t instanceof Error?t.message:"Failed to send password reset email")}finally{O.current?.reset(),g(null)}},Le=async t=>{if(t.preventDefault(),!!L){g("phone"),i(null);try{await fe.sendOtp({phoneNumber:L}),X(!0)}catch(n){i(n instanceof Error?n.message:"Failed to send verification code")}finally{g(null)}}},Fe=async t=>{if(t.preventDefault(),!(!L||!T)){g("verify"),i(null);try{const n=await fe.verify({phoneNumber:L,code:T}),f=P(n);if(f)throw new Error(f);n.data&&"twoFactorRedirect"in n.data&&n.data.twoFactorRedirect&&await a({to:"/auth/two-factor",search:{callbackUrl:N??"/"}})}catch(n){i(n instanceof Error?n.message:"Invalid verification code")}finally{g(null)}}};return e.jsx("div",{className:"min-h-[calc(100vh-3.5rem)] flex items-center justify-center",children:e.jsxs("div",{className:"w-full max-w-md p-8",children:[e.jsxs("div",{className:"text-center mb-8",children:[e.jsx("img",{src:"/lobu-logo.svg",alt:"Lobu",className:"mx-auto mb-6 h-8 w-auto"}),e.jsx("h1",{className:"text-2xl font-bold",children:B?B.title:w&&m==="sign-up"?"Set up your local install":w?"Welcome back":m==="sign-up"?"Create your account":"Sign in"}),e.jsx("p",{className:"text-muted-foreground mt-2",children:B?B.detail:w&&m==="sign-up"?"This account stays on this machine. Email is just an identifier — pick anything you’ll remember.":w?"Sign in to your local install.":ae?"Sign in to connect the browser extension":m==="sign-up"?"Choose a sign-up method":"Choose your preferred sign-in method"}),w&&e.jsxs("div",{className:"mt-3 inline-flex items-center gap-2 px-3 py-1.5 bg-muted text-muted-foreground rounded-full text-xs",children:[e.jsx("svg",{className:"w-3.5 h-3.5",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24","aria-hidden":"true",children:e.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M12 15v2m-6 4h12a2 2 0 002-2v-6a2 2 0 00-2-2H6a2 2 0 00-2 2v6a2 2 0 002 2zm10-10V7a4 4 0 00-8 0v4h8z"})}),"Local install · nothing sent to lobu.ai"]}),ae&&e.jsxs("div",{className:"mt-3 inline-flex items-center gap-2 px-3 py-1.5 bg-primary/10 text-primary rounded-full text-sm",children:[e.jsx("svg",{className:"w-4 h-4",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24","aria-hidden":"true",children:e.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M9 12l2 2 4-4m5.618-4.016A11.955 11.955 0 0112 2.944a11.955 11.955 0 01-8.618 3.04A12.02 12.02 0 003 9c0 5.591 3.824 10.29 9 11.622 5.176-1.332 9-6.03 9-11.622 0-1.042-.133-2.052-.382-3.016z"})}),"Browser Extension"]})]}),e.jsx(Je,{children:e.jsx(Ke,{children:D?e.jsx("div",{className:"space-y-4",children:q?e.jsxs(e.Fragment,{children:[e.jsx("div",{className:"rounded-md bg-destructive/10 px-3 py-2 text-sm text-destructive",children:q}),e.jsx("button",{type:"button",disabled:h!==null,onClick:me,className:"flex h-10 w-full items-center justify-center rounded-md bg-primary px-4 py-2 text-sm font-medium text-primary-foreground transition-colors hover:bg-primary/90 disabled:opacity-50",children:"Try again"})]}):e.jsxs("div",{className:"flex items-center justify-center gap-2 py-6 text-sm text-muted-foreground",children:[e.jsx(j,{size:"lg"}),e.jsx("span",{children:"Signing you into your local install…"})]})}):e.jsxs(e.Fragment,{children:[v&&e.jsxs("div",{className:"flex items-center justify-center gap-2 py-6 text-sm text-muted-foreground",children:[e.jsx(j,{size:"lg"}),e.jsx("span",{children:"Loading sign-in options…"})]}),!v&&Y&&e.jsxs("div",{className:"text-sm text-destructive",children:["Failed to load sign-in options. ",Y]}),!v&&!Y&&S.length===0&&e.jsx("div",{className:"text-sm text-muted-foreground",children:"No sign-in methods are configured. Contact support for access."}),y&&!I&&e.jsxs("div",{className:"mb-4 flex rounded-lg border p-1",children:[e.jsx("button",{type:"button",className:`flex-1 rounded-md px-3 py-2 text-sm font-medium transition-colors ${m==="sign-in"?"bg-primary text-primary-foreground":"text-muted-foreground hover:text-foreground"}`,onClick:()=>A("sign-in"),children:"Sign In"}),e.jsx("button",{type:"button",className:`flex-1 rounded-md px-3 py-2 text-sm font-medium transition-colors ${m==="sign-up"?"bg-primary text-primary-foreground":"text-muted-foreground hover:text-foreground"}`,onClick:()=>A("sign-up"),children:"Sign Up"})]}),!I&&Ne.length>1&&e.jsxs("div",{className:"mb-6 flex rounded-lg border p-1",children:[y&&e.jsx("button",{type:"button",className:`flex-1 rounded-md px-3 py-2 text-sm font-medium transition-colors ${d==="email-password"?"bg-primary text-primary-foreground":"text-muted-foreground hover:text-foreground"}`,onClick:()=>x("email-password"),children:"Email + Password"}),$&&e.jsx("button",{type:"button",className:`flex-1 rounded-md px-3 py-2 text-sm font-medium transition-colors ${d==="social"?"bg-primary text-primary-foreground":"text-muted-foreground hover:text-foreground"}`,onClick:()=>x("social"),children:"Social"}),!y&&C&&e.jsx("button",{type:"button",className:`flex-1 rounded-md px-3 py-2 text-sm font-medium transition-colors ${d==="magic-link"?"bg-primary text-primary-foreground":"text-muted-foreground hover:text-foreground"}`,onClick:()=>x("magic-link"),children:"Magic Link"}),W&&e.jsx("button",{type:"button",className:`flex-1 rounded-md px-3 py-2 text-sm font-medium transition-colors ${d==="whatsapp"?"bg-primary text-primary-foreground":"text-muted-foreground hover:text-foreground"}`,onClick:()=>x("whatsapp"),children:"WhatsApp"})]}),G&&e.jsx("div",{className:"mb-4 rounded-lg border border-amber-300 bg-amber-50 p-3 text-sm text-amber-900",children:"We found an existing account for this identity. To protect the account, verify with a magic link before linking social sign-in."}),ie&&e.jsx("div",{className:"mb-4 p-3 text-sm text-destructive bg-destructive/10 rounded-lg",children:ie}),V&&e.jsx("p",{className:"mb-4 text-sm text-muted-foreground",children:V}),q&&e.jsx("div",{className:"mb-4 p-3 text-sm text-destructive bg-destructive/10 rounded-lg",children:q}),!I&&(y||d==="social")&&$&&e.jsxs("div",{className:"space-y-3",children:[Object.entries(r?.social??{}).filter(([,t])=>t).map(([t])=>{const n=_e.find(Ue=>Ue.provider===t),f=n?.icon,U=r?.socialMeta?.[t],H=n?.name??U?.name??t.charAt(0).toUpperCase()+t.slice(1);return e.jsxs("button",{type:"button",onClick:()=>de(t),disabled:h!==null,className:"w-full flex items-center justify-center gap-3 h-10 px-4 border border-input rounded-lg bg-background hover:bg-accent hover:text-accent-foreground transition-colors disabled:opacity-50",children:[h===t?e.jsx(j,{size:"lg"}):f?e.jsx(f,{className:"w-4 h-4"}):U?.faviconDomain?e.jsx(Ge,{domain:U.faviconDomain},U.faviconDomain):e.jsx(he,{className:"w-4 h-4"}),"Continue with ",H]},t)}),y&&e.jsxs("div",{className:"relative my-2",children:[e.jsx("div",{className:"absolute inset-0 flex items-center",children:e.jsx("span",{className:"w-full border-t"})}),e.jsx("div",{className:"relative flex justify-center text-xs uppercase",children:e.jsx("span",{className:"bg-card px-2 text-muted-foreground",children:"or"})})]})]}),!I&&!D&&(y||d==="magic-link")&&r?.captcha&&e.jsx(Ve,{ref:O,siteKey:r.captcha.siteKey,onVerify:we}),!I&&y&&e.jsxs("form",{onSubmit:Se,className:"space-y-4",children:[m==="sign-up"&&e.jsxs("div",{children:[e.jsx("label",{htmlFor:"full-name",className:"block text-sm font-medium",children:"Full name"}),e.jsx("input",{id:"full-name",type:"text",value:K,onChange:t=>ge(t.target.value),placeholder:"Jane Doe",className:"mt-1 block h-10 w-full rounded-md border border-input bg-background px-3 py-2 text-sm placeholder:text-muted-foreground focus:outline-none focus:ring-2 focus:ring-ring"})]}),e.jsxs("div",{children:[e.jsx("label",{htmlFor:"email-password-email",className:"block text-sm font-medium",children:"Email address"}),e.jsx("input",{id:"email-password-email",type:"email",value:u,onChange:t=>{Q(t.target.value),ne(!1)},placeholder:"you@example.com",required:!0,className:"mt-1 block h-10 w-full rounded-md border border-input bg-background px-3 py-2 text-sm placeholder:text-muted-foreground focus:outline-none focus:ring-2 focus:ring-ring"})]}),e.jsxs("div",{children:[e.jsx("label",{htmlFor:"email-password-password",className:"block text-sm font-medium",children:"Password"}),e.jsx("input",{id:"email-password-password",type:"password",value:E,onChange:t=>xe(t.target.value),placeholder:"Enter a password",required:!0,minLength:8,className:"mt-1 block h-10 w-full rounded-md border border-input bg-background px-3 py-2 text-sm placeholder:text-muted-foreground focus:outline-none focus:ring-2 focus:ring-ring"})]}),e.jsx("button",{type:"submit",disabled:h!==null||!u||!E,className:"flex h-10 w-full items-center justify-center rounded-md bg-primary px-4 py-2 text-sm font-medium text-primary-foreground transition-colors hover:bg-primary/90 disabled:opacity-50",children:h==="email-password"?e.jsxs(e.Fragment,{children:[e.jsx(j,{size:"lg"}),e.jsx("span",{className:"ml-2",children:m==="sign-up"?"Creating account...":"Signing in..."})]}):m==="sign-up"?w?"Create local account":"Create Account":"Sign In"}),m==="sign-in"&&oe&&e.jsx("button",{type:"button",disabled:h!==null,onClick:async()=>{i(null),g("passkey");try{const t=await _.passkey();if(t.data&&"twoFactorRedirect"in t.data&&t.data.twoFactorRedirect){await a({to:"/auth/two-factor",search:{callbackUrl:N??"/"}});return}if(t?.error){const n=t.error.message??"Passkey sign-in failed.";i(R(n)??n);return}window.location.href=F()}catch(t){const n=t instanceof Error?t.message:String(t);i(R(n)??n)}finally{g(null)}},className:"flex h-10 w-full items-center justify-center rounded-md border border-input bg-background px-4 py-2 text-sm font-medium transition-colors hover:bg-accent hover:text-accent-foreground disabled:opacity-50",children:h==="passkey"?e.jsxs(e.Fragment,{children:[e.jsx(j,{size:"lg"}),e.jsx("span",{className:"ml-2",children:"Waiting for passkey…"})]}):"Sign in with passkey"}),m==="sign-in"&&C&&e.jsx("button",{type:"button",disabled:h!==null||!u,onClick:async()=>{await ue()&&x("magic-link")},className:"flex h-10 w-full items-center justify-center rounded-md border border-input bg-background px-4 py-2 text-sm font-medium transition-colors hover:bg-accent hover:text-accent-foreground disabled:opacity-50",children:h==="magic-link"?e.jsxs(e.Fragment,{children:[e.jsx(j,{size:"lg"}),e.jsx("span",{className:"ml-2",children:"Sending magic link..."})]}):"Send me a magic link instead"}),m==="sign-in"&&e.jsx("button",{type:"button",disabled:h!==null||!u,onClick:Ee,className:"flex h-10 w-full items-center justify-center rounded-md border border-input bg-background px-4 py-2 text-sm font-medium transition-colors hover:bg-accent hover:text-accent-foreground disabled:opacity-50",children:h==="reset-password-request"?e.jsxs(e.Fragment,{children:[e.jsx(j,{size:"lg"}),e.jsx("span",{className:"ml-2",children:"Sending reset email..."})]}):"Forgot password?"}),m==="sign-in"&&je&&e.jsx("p",{className:"text-sm text-muted-foreground",children:"If this email exists, we sent a password reset link."})]}),d==="magic-link"&&C&&(ee?e.jsxs("div",{className:"text-center",children:[e.jsx("div",{className:"mb-4 flex justify-center",children:e.jsx("svg",{className:"h-12 w-12 text-primary",fill:"none",viewBox:"0 0 24 24",stroke:"currentColor","aria-hidden":"true",children:e.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M3 8l7.89 5.26a2 2 0 002.22 0L21 8M5 19h14a2 2 0 002-2V7a2 2 0 00-2-2H5a2 2 0 00-2 2v10a2 2 0 002 2z"})})}),e.jsx("h2",{className:"text-lg font-medium",children:"Check your email"}),e.jsxs("p",{className:"mt-2 text-sm text-muted-foreground",children:["We sent a magic link to ",e.jsx("strong",{children:u}),".",e.jsx("br",{}),"Click the link in the email to sign in."]}),e.jsx("button",{type:"button",className:"mt-4 text-sm text-primary hover:underline",onClick:()=>te(!1),children:"Use a different email"})]}):e.jsxs("form",{onSubmit:Ce,className:"space-y-4",children:[e.jsxs("div",{children:[e.jsx("label",{htmlFor:"email",className:"block text-sm font-medium",children:"Email address"}),e.jsx("input",{id:"email",type:"email",value:u,onChange:t=>Q(t.target.value),placeholder:"you@example.com",required:!0,className:"mt-1 block h-10 w-full rounded-md border border-input bg-background px-3 py-2 text-sm placeholder:text-muted-foreground focus:outline-none focus:ring-2 focus:ring-ring"})]}),e.jsx("button",{type:"submit",disabled:h!==null||!u,className:"flex h-10 w-full items-center justify-center rounded-md bg-primary px-4 py-2 text-sm font-medium text-primary-foreground transition-colors hover:bg-primary/90 disabled:opacity-50",children:h==="magic-link"?e.jsxs(e.Fragment,{children:[e.jsx(j,{size:"lg"}),e.jsx("span",{className:"ml-2",children:"Sending..."})]}):"Send Magic Link"})]})),!I&&d==="whatsapp"&&W&&(ye?e.jsxs("form",{onSubmit:Fe,className:"space-y-4",children:[e.jsxs("div",{className:"text-center text-sm text-muted-foreground",children:["Enter the 6-digit code sent to ",e.jsx("strong",{children:L})]}),e.jsx("div",{children:e.jsx("input",{type:"text",value:T,onChange:t=>Z(t.target.value),placeholder:"000000",maxLength:6,pattern:"[0-9]{6}",required:!0,className:"block h-12 w-full rounded-md border border-input bg-background px-3 py-2 text-center text-xl tracking-widest placeholder:text-muted-foreground focus:outline-none focus:ring-2 focus:ring-ring"})}),e.jsx("button",{type:"submit",disabled:h!==null||T.length!==6,className:"flex h-10 w-full items-center justify-center rounded-md bg-primary px-4 py-2 text-sm font-medium text-primary-foreground transition-colors hover:bg-primary/90 disabled:opacity-50",children:h==="verify"?e.jsxs(e.Fragment,{children:[e.jsx(j,{size:"lg"}),e.jsx("span",{className:"ml-2",children:"Verifying..."})]}):"Verify & Sign In"}),e.jsx("button",{type:"button",className:"w-full text-sm text-primary hover:underline",onClick:()=>{X(!1),Z("")},children:"Use a different number"})]}):e.jsxs("form",{onSubmit:Le,className:"space-y-4",children:[e.jsxs("div",{children:[e.jsx("label",{htmlFor:"phone",className:"block text-sm font-medium",children:"WhatsApp Number"}),e.jsx("input",{id:"phone",type:"tel",value:L,onChange:t=>be(t.target.value),placeholder:"+1234567890",required:!0,className:"mt-1 block h-10 w-full rounded-md border border-input bg-background px-3 py-2 text-sm placeholder:text-muted-foreground focus:outline-none focus:ring-2 focus:ring-ring"}),e.jsx("p",{className:"mt-1 text-xs text-muted-foreground",children:"Include country code (e.g., +1 for US)"})]}),e.jsx("button",{type:"submit",disabled:h!==null||!L,className:"flex h-10 w-full items-center justify-center rounded-md bg-primary px-4 py-2 text-sm font-medium text-primary-foreground transition-colors hover:bg-primary/90 disabled:opacity-50",children:h==="phone"?e.jsxs(e.Fragment,{children:[e.jsx(j,{size:"lg"}),e.jsx("span",{className:"ml-2",children:"Sending..."})]}):"Send Code via WhatsApp"})]}))]})})})]})})}export{tt as component};
2
+ //# sourceMappingURL=login-DeWlvogD.js.map
@@ -1,2 +1,2 @@
1
- import{r as n,ah as o,j as e}from"./index-BoqrvLHQ.js";function s(){return n.useEffect(()=>{o().catch(t=>console.error("Sign out failed:",t)).finally(()=>{window.location.href="/"})},[]),e.jsx("div",{className:"min-h-[calc(100vh-3.5rem)] flex items-center justify-center",children:e.jsx("p",{className:"text-muted-foreground",children:"Signing out..."})})}export{s as component};
2
- //# sourceMappingURL=logout-DfdgOLoM.js.map
1
+ import{r as n,aj as o,j as e}from"./index-DB2lVKuV.js";function s(){return n.useEffect(()=>{o().catch(t=>console.error("Sign out failed:",t)).finally(()=>{window.location.href="/"})},[]),e.jsx("div",{className:"min-h-[calc(100vh-3.5rem)] flex items-center justify-center",children:e.jsx("p",{className:"text-muted-foreground",children:"Signing out..."})})}export{s as component};
2
+ //# sourceMappingURL=logout-CJY0ceN9.js.map
@@ -1,2 +1,2 @@
1
- import{j as e,m as o,H as c,n as u,P as d,bc as h,cU as b,B as p,L as x,T as g}from"./index-BoqrvLHQ.js";function j({rows:t=5}){return e.jsx("div",{className:"space-y-2",role:"status","aria-label":"Loading members",children:Array.from({length:t}).map((n,s)=>e.jsxs("div",{className:"flex items-center gap-3 rounded-lg px-3 py-2",children:[e.jsx(o,{className:"h-8 w-8 shrink-0 rounded-full"}),e.jsx(o,{className:"h-4 w-40"})]},s))})}function l({title:t,body:n,ctaLabel:s,showCta:r,callbackUrl:a}){return e.jsx(h,{icon:b,title:t,description:n,children:s&&r?e.jsx(p,{asChild:!0,className:"mt-4",children:e.jsx(x,{to:"/auth/login",search:g({callbackUrl:a,intent:"sign-in"}),children:s})}):null})}function y({children:t}){const{isAuthenticated:n,isReady:s}=c(),{isMember:r,isLoading:a}=u(),i=d({select:m=>m.href});return!s||a?e.jsx(j,{}):n?r?e.jsx(e.Fragment,{children:t}):e.jsx(l,{title:"Join to see members",body:"Emails and member details are only visible to members of this workspace. Use the banner above to join.",callbackUrl:i}):e.jsx(l,{title:"Sign in to see members",body:"The members of this workspace are only visible to people who have signed in.",ctaLabel:"Sign in",showCta:!0,callbackUrl:i})}export{y as M};
2
- //# sourceMappingURL=member-scope-gate-Cxg2zGQT.js.map
1
+ import{j as e,n as o,H as c,o as d,Q as u,bk as h,d7 as b,B as p,L as x,U as g}from"./index-DB2lVKuV.js";function j({rows:t=5}){return e.jsx("div",{className:"space-y-2",role:"status","aria-label":"Loading members",children:Array.from({length:t}).map((n,s)=>e.jsxs("div",{className:"flex items-center gap-3 rounded-lg px-3 py-2",children:[e.jsx(o,{className:"h-8 w-8 shrink-0 rounded-full"}),e.jsx(o,{className:"h-4 w-40"})]},s))})}function l({title:t,body:n,ctaLabel:s,showCta:r,callbackUrl:a}){return e.jsx(h,{icon:b,title:t,description:n,children:s&&r?e.jsx(p,{asChild:!0,className:"mt-4",children:e.jsx(x,{to:"/auth/login",search:g({callbackUrl:a,intent:"sign-in"}),children:s})}):null})}function y({children:t}){const{isAuthenticated:n,isReady:s}=c(),{isMember:r,isLoading:a}=d(),i=u({select:m=>m.href});return!s||a?e.jsx(j,{}):n?r?e.jsx(e.Fragment,{children:t}):e.jsx(l,{title:"Join to see members",body:"Emails and member details are only visible to members of this workspace. Use the banner above to join.",callbackUrl:i}):e.jsx(l,{title:"Sign in to see members",body:"The members of this workspace are only visible to people who have signed in.",ctaLabel:"Sign in",showCta:!0,callbackUrl:i})}export{y as M};
2
+ //# sourceMappingURL=member-scope-gate-CBPMprXu.js.map
@@ -0,0 +1,74 @@
1
+ import{fl as Xe,cd as Ft,ce as Pt,hu as Dt,h0 as Bt,j as t,dL as Vt,ci as Ht,$ as ke,a0 as ce,fU as Ut,b_ as qt,B as O,gY as zt,bH as Ze,y as Ke,dT as fe,r as b,dA as Gt,f7 as Wt,gm as Jt,gN as Yt,fF as Qt,a8 as Re,i as ge,dY as et,hv as Xt,hw as tt,L as ve,ej as Zt,d1 as Kt,hx as Ae,e5 as Ue,bk as st,hy as es,cZ as nt,dz as at,hz as ts,dy as ss,aM as rt,aN as ot,c_ as it,aP as lt,K as ns,fi as as,P as je,x as ct,cJ as rs,hA as os,c as de,u as dt,eD as is,c9 as ls,df as cs,aQ as ds,aR as us,aS as ms,aT as ps,aU as qe,aY as hs,hB as fs,aW as gs,aa as ys,hC as ut,hD as mt,aF as xs,hE as bs,W as pt,H as vs,dN as le,cs as ne,w as ht,e$ as _e,cT as js,hF as Ss,hG as Ns,ds as Cs,cP as Es,cQ as ws,cq as Le,hH as ks,hI as _s,hJ as ze,eZ as Rs,fV as Ls,hK as $s,bx as Ms,hL as Ts,cY as As,aC as Os,a_ as Is}from"./index-DB2lVKuV.js";import{P as Fs}from"./public-shell-ready-_KWdfzEM.js";import{S as Ps,c as Ds,r as Bs,f as Vs,a as Hs,u as Us,b as qs,s as zs,d as Gs,e as Ws,E as ft,R as Js,g as Ys,h as Qs,i as Xs,j as Zs,k as Ks,l as en}from"./entity-pages-C6M6yKFf.js";import{b as tn,F as sn}from"./filter-editors-D_Sfn0dv.js";import{u as nn,a as an,D as rn,P as on,b as gt,c as ln,C as cn}from"./core.esm-B1du4Zwy.js";import{p as Se,e as yt,r as dn,a as un,S as mn,J as pn}from"./renderer-B8yZ5lql.js";import{G as xt,l as hn,H as fn,n as gn,c as yn}from"./entity-schema-graph-B255NKjF.js";import{v as xn,V as $e,M as bt,a as vt,w as bn,b as vn}from"./view-param-filters-CvrKw0mZ.js";import{M as jn}from"./member-scope-gate-CBPMprXu.js";function Sn({onClose:e,entityTypeSlug:s,orgContext:a,onSuccess:i}){const{data:o,isLoading:d}=Xe(s,a),l=`${a.organizationId??a.slug}:${s}`,n=Ft(l,{name:"",customSlug:"",useCustomSlug:!1,metadata:{}},o?.metadata_schema),[p,r]=n.field("name"),[c,m]=n.field("customSlug"),[u,h]=n.field("useCustomSlug"),[x,C]=n.field("metadata"),[S,j]=Pt(l,null),y=Dt(),N=u?c:Bt(p),g=async R=>{if(R.preventDefault(),!n.canSubmit)return;if(j(null),!p.trim()){j("Name is required");return}const k=zt(x,"metadata"),T={entityType:s,name:p.trim(),slug:u?c:void 0,metadata:Object.keys(k).length>0?k:void 0};try{const $=await y.mutateAsync(T);if(e(),$.approval_queued||!$.entity){Ze.info("Create queued for approval");return}typeof $.entity.id=="number"&&i?.($.entity.id)}catch($){j($ instanceof Error?$.message:"Failed to create entity")}},v=o?.name||s,f=n.revision,E=`Create ${v}`,L=`Add a new ${v.toLowerCase()} to your workspace.`;return d?t.jsx(Vt,{rows:6}):t.jsxs("form",{onSubmit:g,children:[t.jsx(Ht,{visible:n.hasConflict,onReload:n.reset}),t.jsxs("div",{className:"space-y-1.5",children:[t.jsx("h1",{className:"text-2xl font-semibold leading-tight",children:E}),t.jsx("p",{className:"text-sm text-muted-foreground",children:L})]}),t.jsxs("div",{className:"grid gap-4 py-4",children:[t.jsxs("div",{className:"grid gap-2",children:[t.jsxs(ke,{htmlFor:"name",children:["Name ",t.jsx("span",{className:"text-destructive",children:"*"})]}),t.jsx(ce,{id:"name",value:p,onChange:R=>r(R.target.value),placeholder:`Enter ${v.toLowerCase()} name`,autoFocus:!0})]}),t.jsxs("div",{className:"grid gap-2",children:[t.jsxs("div",{className:"flex items-center justify-between",children:[t.jsx(ke,{htmlFor:"slug",children:"URL Slug"}),t.jsx("button",{type:"button",onClick:()=>h(!u),className:"text-xs text-muted-foreground hover:text-foreground",children:u?"Auto-generate":"Customize"})]}),u?t.jsx(ce,{id:"slug",value:c,onChange:R=>m(R.target.value.toLowerCase().replace(/[^a-z0-9-]/g,"")),placeholder:"custom-slug"}):t.jsx("div",{className:"flex h-9 items-center rounded-md border border-input bg-muted px-3 text-sm text-muted-foreground",children:N||"slug-preview"})]}),f&&Object.keys(f).length>0?t.jsxs(t.Fragment,{children:[t.jsx(Ps,{className:"my-2"}),t.jsxs("div",{className:"grid gap-2",children:[t.jsx(ke,{className:"text-sm font-medium",children:"Additional Fields"}),t.jsx(Ut,{valueModel:"metadata",schema:n.revision,values:x,onValuesChange:C,orgContext:a})]})]}):null,S&&t.jsx("div",{className:"rounded-md bg-destructive/10 px-3 py-2 text-sm text-destructive",children:S})]}),t.jsx(qt,{onCancel:e,cancelDisabled:y.isPending,className:"mt-2",children:t.jsx(O,{type:"submit",disabled:!n.canSubmit||y.isPending||!p.trim(),children:y.isPending?"Creating...":`Create ${v}`})})]})}function Nn(e,s,a,i,o){const d={...i,filters:i.filters?.filter(l=>l.field!==a)};return Ke({queryKey:["collection-facets",e,s,a,d],enabled:!!s&&!!a,staleTime:3e4,retry:!1,queryFn:async({signal:l})=>{const n=await fe("query_sdk",{title:`Value counts query for ${a}`,script:`const input = ${JSON.stringify({field:a,collection:d})};
2
+ ${s}`},e,{signal:l}),p=n.return_value;if(!n.success||typeof p?.connection!="string"||typeof p.sql!="string")throw new Error(n.error?.message??"Value distribution is unavailable");if(l.aborted)throw new DOMException("Aborted","AbortError");const r=await fe("query_sql",{title:`Value counts for ${a}`,connection:p.connection,sql:p.sql,limit:51},e,{signal:l});if(r.error)throw new Error(r.error);if(!Array.isArray(r.rows))throw new Error("Source did not return value counts");const c=r.rows.map(m=>{const u=m,h=typeof u.count=="string"&&/^\d+$/.test(u.count)?Number(u.count):u.count;if(!(u.value===null||["string","number","boolean"].includes(typeof u.value))||typeof h!="number"||!Number.isSafeInteger(h)||h<0)throw new Error("Source returned an invalid value distribution");return{value:u.value,count:h}});return{values:c.slice(0,50),truncated:c.length>50||r.truncated===!0}}})}const Cn=300;function En({label:e,search:s,onSearch:a,className:i}){const o=s??"",[d,l]=b.useState(o),n=b.useRef({search:s,onSearch:a});n.current={search:s,onSearch:a};const p=b.useRef(void 0);b.useEffect(()=>{const c=()=>{clearTimeout(p.current),l(n.current.search??"")};return window.addEventListener("popstate",c),()=>window.removeEventListener("popstate",c)},[]);const r=b.useRef(o);return b.useEffect(()=>{o!==r.current&&(r.current=o,l(o))},[o]),b.useEffect(()=>{if(d===(n.current.search??""))return;const c=setTimeout(()=>{const m=n.current.onSearch;r.current=d,m(d||void 0,!0)},Cn);return p.current=c,()=>clearTimeout(c)},[d]),t.jsxs("div",{className:`relative${i?` ${i}`:""}`,children:[t.jsx(Gt,{"aria-hidden":"true",className:"absolute left-3 top-1/2 h-4 w-4 -translate-y-1/2 text-muted-foreground"}),t.jsx(ce,{type:"search","aria-label":`Search ${e.toLowerCase()}`,placeholder:`Search ${e.toLowerCase()}...`,maxLength:512,value:d,onChange:c=>l(c.target.value),className:"pl-9"})]})}function wn({field:e,initial:s,org:a,facetQuery:i,collection:o,onApply:d,close:l}){const[n,p]=b.useState(s?.op??"eq"),[r,c]=b.useState(s?.value==null?"":String(s.value)),[m,u]=b.useState(""),[h,x]=b.useState(!1),[C,S]=b.useState(),j=e.type==="date"||e.type==="datetime-local"||e.type==="number"?e.type:"text",y=Nn(a,i,e.field,o),N=f=>{try{const E=h?[{field:e.field,op:"gte",value:e.type==="number"?Number(r):r},{field:e.field,op:"lte",value:e.type==="number"?Number(m):m}]:[{field:e.field,op:n,value:f}];if(e.type==="datetime-local")for(const k of E)typeof k.value=="string"&&(k.value=new Date(k.value).toISOString());if(E.some(k=>typeof k.value=="number"&&!Number.isFinite(k.value)))throw new Error("Enter a valid number.");const L=E[0].value,R=E[1]?.value;if(h&&L!=null&&R!=null&&L>R)throw new Error("The lower bound must be before the upper bound.");d(E),l()}catch(E){S(E instanceof Error?E.message:"Could not apply filter")}},g=[...e.options];for(const f of y.data?.values??[])g.some(E=>E.value===f.value)||g.push({value:f.value,label:f.value===null?"Not supplied":String(f.value)});const v=Math.max(1,...y.data?.values.map(f=>f.count)??[]);return t.jsxs("div",{className:"min-w-0 space-y-3 p-3",children:[t.jsxs("select",{"aria-label":"Filter operator",className:"h-8 w-full rounded-md border bg-background px-2 text-sm",value:h?"range":n,onChange:f=>{x(f.target.value==="range"),f.target.value!=="range"&&p(f.target.value)},children:[t.jsx("option",{value:"eq",children:"is"}),t.jsx("option",{value:"neq",children:"is not"}),(e.type==="number"||e.type==="date"||e.type==="datetime-local")&&t.jsxs(t.Fragment,{children:[t.jsx("option",{value:"lt",children:"less than / before"}),t.jsx("option",{value:"lte",children:"at most / on or before"}),t.jsx("option",{value:"gt",children:"greater than / after"}),t.jsx("option",{value:"gte",children:"at least / on or after"}),s?null:t.jsx("option",{value:"range",children:"between"})]})]}),e.type!=="boolean"&&t.jsxs("form",{className:"space-y-2",onSubmit:f=>{f.preventDefault(),N(e.type==="number"?Number(r):r)},children:[t.jsx(ce,{required:!0,"aria-label":h?"From value":"Filter value",type:j,step:e.type==="number"?"any":void 0,value:r,onChange:f=>c(f.target.value),placeholder:"Enter a value…"}),h&&t.jsx(ce,{required:!0,"aria-label":"To value",type:j,step:e.type==="number"?"any":void 0,value:m,onChange:f=>u(f.target.value)}),t.jsx(O,{size:"sm",type:"submit",className:"w-full",children:"Apply filter"})]}),!h&&(n==="eq"||n==="neq")&&t.jsx("div",{className:"max-h-48 space-y-1 overflow-y-auto",children:g.filter(f=>!r||f.label.toLowerCase().includes(r.toLowerCase())).map(f=>{const E=y.data?.values.find(L=>L.value===f.value)?.count;return t.jsxs("button",{type:"button","aria-label":f.label,onClick:()=>N(f.value),className:"relative flex w-full items-center justify-between gap-3 overflow-hidden rounded px-2 py-1.5 text-left text-sm hover:bg-accent focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring",children:[E!==void 0&&t.jsx("span",{"aria-hidden":"true",className:"absolute inset-y-0 left-0 bg-primary/10",style:{width:`${E/v*100}%`}}),t.jsx("span",{className:"relative truncate",children:f.label}),t.jsx("span",{className:"relative text-xs tabular-nums text-muted-foreground",children:E?.toLocaleString()})]},JSON.stringify(f.value))})}),i&&y.isFetching&&t.jsx("p",{role:"status",className:"text-xs text-muted-foreground",children:"Loading distribution…"}),y.isError&&t.jsx("p",{role:"status",className:"text-xs text-muted-foreground",children:"Counts unavailable. You can still enter a value."}),y.data?.truncated&&t.jsx("p",{className:"text-xs text-muted-foreground",children:"Top 50 values. Enter any other value above."}),C&&t.jsx("p",{role:"alert",className:"text-xs text-destructive",children:C})]})}function jt({collection:e,schema:s,label:a,onChange:i,org:o,facetQuery:d,segmentChip:l,viewFilters:n,onClearAll:p}){const r=Ds(s),c=(x,C)=>({kind:"custom",className:"w-80",render:S=>t.jsx(wn,{field:x,initial:C==null?void 0:e.filters?.[C],org:o,facetQuery:d,collection:e,onApply:j=>i(Hs(e,j,C)),close:S})}),m=r.map(x=>({key:x.field,label:x.label,icon:t.jsx(Wt,{className:"h-4 w-4"}),editor:c(x)})),u=new Map,h=(e.filters??[]).map((x,C)=>{const S=`${x.field}:${x.op}:${JSON.stringify(x.value)}`,j=u.get(S)??0;u.set(S,j+1);const y=r.find(N=>N.field===x.field);return{id:`${S}:${j}`,label:y?.label??x.field,...Vs(x,y),editor:y?c(y,C):void 0,onRemove:()=>i(Bs(e,C))}});if(l&&h.unshift(l),n?.fields.length){for(const x of m)x.group=a;m.push(...n.fields),h.push(...n.chips)}return!m.length&&!h.length?{fields:m,chips:h,clearAll:()=>{}}:{fields:m,chips:h,clearAll:p??(()=>i({...e,filters:[],segment:void 0}))}}function kn(e){const{fields:s}=jt(e);return s.length?t.jsx(tn,{fields:s}):null}function _n(e){const{chips:s,clearAll:a}=jt(e);return s.length?t.jsx(sn,{label:`${e.label} filters`,fields:[],chips:s,onClearAll:a,className:"mb-4"}):null}function Rn(e){return String(e??"").replace(/[_-]+/g," ").replace(/\b\w/g,s=>s.toUpperCase())}function St(e){return e["x-lobu"]?.role||e["x-lobu-role"]}function Oe(e){const s=e?.properties;if(!s)return null;const o=Jt(s).find(([,r])=>St(r)==="workflowState");if(!o)return null;const[d,l]=o,n=l["x-lobu"]?.states,p=Array.isArray(n)&&n.length>0?n:(l.enum??[]).map(r=>({value:r}));return p.length===0||p.some(r=>typeof r.value!="string")?null:{field:d,states:p.map(r=>({...r,label:r.label||Yt(l,r.value)||Rn(r.value),terminal:r.terminal??["done","complete","completed","closed","archived"].includes(r.value.toLowerCase())}))}}function Ln(e){const s=e?.properties;if(!s)return null;const a=Object.entries(s),i=a.find(([,l])=>St(l)==="sortRank"),o=a.find(([l])=>["rank","sort_rank","order"].includes(l)),d=i??o;return d?{field:d[0]}:null}function Me(e){return e.replace(/[_-]+/g," ").replace(/\b\w/g,s=>s.toUpperCase())}function ye(e,s){if(!s)return e.created_at??String(e.id);const a=Se(e.metadata);return String(a[s.field]??e.created_at??e.id)}function $n(e,s){const a=e?Number(e):Number.NaN,i=s?Number(s):Number.NaN;return Number.isFinite(a)&&Number.isFinite(i)&&a<i?String((a+i)/2):Number.isFinite(a)?String(a+1):Number.isFinite(i)?String(i-1):String(Date.now())}function Te(e,s){const a=Se(e.metadata);return String(a[s]??"")}function Nt(e,s){return[...e].sort((a,i)=>ye(a,s).localeCompare(ye(i,s)))}function Mn(e,s,a,i,o){if(!s.startsWith("card:")||!a)return null;const d=Number(s.slice(5)),l=e.find(y=>y.id===d);if(!l)return null;const n=a.startsWith("column:")?a.slice(7):Te(e.find(y=>`card:${y.id}`===a)??l,i.field);if(!n)return null;const p=Nt(e.filter(y=>y.id!==d&&Te(y,i.field)===n),o),r=a.startsWith("card:")?p.findIndex(y=>`card:${y.id}`===a):p.length,c=r>=0?r:p.length,m=c>0?p[c-1]:void 0,u=p[c],h=o?$n(m?ye(m,o):void 0,u?ye(u,o):void 0):void 0,x=Se(l.metadata),C={[i.field]:n,...o&&h?{[o.field]:h}:{}};i.states.find(y=>y.value===n)?.terminal&&!x.completed_at&&(C.completed_at=new Date().toISOString());const j={...x,...C};return{entityId:d,changedMetadata:C,nextMetadata:j}}function Ge(e,s,a){return e.map(i=>i.id===s?{...i,metadata:a}:i)}function Tn({id:e,children:s,className:a}){const{setNodeRef:i,isOver:o}=gt({id:`column:${e}`});return t.jsx("div",{ref:i,className:ge("min-h-[220px] rounded-lg bg-card p-2 transition-colors",o?"bg-accent/50":"",a),children:s})}function An({entity:e,owner:s,statusField:a,entityTypeIcon:i,schema:o,didDragRef:d,readOnly:l}){const n=Se(e.metadata),{attributes:p,listeners:r,setNodeRef:c,transform:m,isDragging:u}=ln({id:`card:${e.id}`,disabled:l}),h=Us(e),{setNodeRef:x,isOver:C}=gt({id:`card:${e.id}`}),S=et(s,yt(e)),j=y=>{if(d.current){y.preventDefault(),y.stopPropagation();return}h?.(y)};return t.jsx("div",{ref:y=>{c(y),x(y)},style:{transform:cn.Translate.toString(m)},className:ge(Zt,"p-3 text-sm text-muted-foreground transition-colors hover:bg-accent/50 hover:text-foreground",u?"opacity-60":"",C?"ring-1 ring-ring":""),children:t.jsxs("div",{className:"flex items-start gap-2",children:[l?null:t.jsx("button",{type:"button",className:"mt-0.5 shrink-0 cursor-grab touch-none text-muted-foreground/60 hover:text-foreground active:cursor-grabbing","aria-label":`Drag ${e.name}`,...p,...r,children:t.jsx(Xt,{className:"h-4 w-4"})}),t.jsx(tt,{metadata:n,metadataSchema:o,name:e.name,typeIcon:i,className:"mt-0.5 h-6 w-6 shrink-0",initialsFallback:!0}),t.jsxs("div",{className:"min-w-0 flex-1",children:[t.jsx(ve,{to:S,className:"font-medium text-foreground hover:underline",onClick:j,children:e.name}),t.jsxs("div",{className:"mt-1 flex flex-wrap gap-1.5",children:[typeof n.priority=="string"&&n.priority?t.jsx(Re,{variant:"outline",className:"text-xs",children:Me(n.priority)}):null,typeof n[a]=="string"&&n[a]?t.jsx(Re,{variant:"secondary",className:"text-xs",children:Me(String(n[a]))}):null]})]})]})})}function On({owner:e,entities:s,totalCount:a,schema:i,entityTypeIcon:o,onUpdate:d}){const l=b.useMemo(()=>Oe(i),[i]),n=b.useMemo(()=>Ln(i),[i]),[p,r]=b.useState(s),[c,m]=b.useState(()=>new Set),u=b.useRef(!1),h=nn(an(on,{activationConstraint:{distance:6}})),x=b.useCallback(()=>{window.setTimeout(()=>{u.current=!1},0)},[]);b.useEffect(()=>{r(s)},[s]);const C=b.useMemo(()=>{if(!l)return new Map;const N=new Map(l.states.map(g=>[g.value,[]]));for(const g of p){const v=Te(g,l.field),f=N.has(v)?v:l.states[0]?.value;f&&N.get(f)?.push(g)}for(const[g,v]of N)N.set(g,Nt(v,n));return N},[p,n,l]);if(!l)return null;const S=N=>{m(g=>{const v=new Set(g);return v.has(N)?v.delete(N):v.add(N),v})},j=()=>{u.current=!0},y=N=>{const g=String(N.active.id),v=N.over?String(N.over.id):null;if(!d){x();return}const f=Mn(p,g,v,l,n);if(!f){x();return}const{entityId:E,changedMetadata:L,nextMetadata:R}=f,T=p.find($=>$.id===E)?.metadata;r($=>Ge($,E,R)),d(E,L).catch(()=>{r($=>Ge($,E,T))}),x()};return t.jsxs("div",{className:"space-y-4",children:[t.jsxs("div",{children:[t.jsx("h2",{className:"text-base font-semibold",children:"Board"}),t.jsxs("p",{className:"text-sm text-muted-foreground",children:["Grouped by ",Me(l.field),typeof a=="number"&&a>p.length?t.jsxs(t.Fragment,{children:[" · ",t.jsxs("span",{className:"text-amber-600 dark:text-amber-500",children:["showing first ",p.length," of ",a," — narrow with search"]})]}):null]})]}),t.jsx(rn,{sensors:h,onDragStart:j,onDragEnd:y,children:t.jsx("div",{className:"grid gap-3 md:grid-cols-2 xl:grid-cols-4",children:l.states.map(N=>{const g=C.get(N.value)??[],v=N.collapsed??N.terminal,f=v&&!c.has(N.value);return t.jsxs(Tn,{id:N.value,children:[t.jsxs("div",{className:"mb-2 flex items-center justify-between gap-2 px-1",children:[t.jsxs("div",{className:"flex items-center gap-1.5",children:[N.terminal?t.jsx(Qt,{className:"h-4 w-4 text-muted-foreground"}):null,t.jsx("h3",{className:"text-sm font-medium",children:N.label})]}),t.jsxs("div",{className:"flex items-center gap-1.5",children:[t.jsx(Re,{variant:"secondary",className:"text-xs",children:g.length}),v?t.jsx(O,{type:"button",variant:"ghost",size:"sm",className:"h-6 px-1.5 text-xs",onClick:()=>S(N.value),children:f?"Show":"Hide"}):null]})]}),f?t.jsxs("p",{className:"py-4 text-center text-xs text-muted-foreground/60",children:[g.length," hidden ",N.label?.toLowerCase()," item",g.length===1?"":"s"]}):t.jsx("div",{className:"space-y-2",children:g.length>0?g.map(E=>t.jsx(An,{entity:E,owner:e,statusField:l.field,entityTypeIcon:o,schema:i,didDragRef:u,readOnly:!d},E.id)):t.jsxs("p",{className:"py-4 text-center text-xs text-muted-foreground/60",children:["No ",N.label?.toLowerCase()," items"]})})]},N.value)})})})]})}const Ct=b.memo(On);function In(e,{isDerived:s}){const a=e?.["x-lobu"]?.defaultView;return(a==="table"||a==="board")&&!(s&&a!=="table")?a:s?"table":Oe(e)?"board":"table"}function Fn(e){return Object.entries(e?.metrics_config?.segments??{}).filter(([,s])=>s.on==="entity").map(([s,a])=>({name:s,description:a.description}))}const xe={table:{label:"Table",icon:ss},board:{label:"Board",icon:ts},graph:{label:"Graph",icon:at}};function Pn({entityTypeSlug:e,orgContext:s,search:a,viewPath:i,viewer:o,authReady:d}){const l=Xe(e,s),{data:n,isLoading:p}=l,r=d&&!p&&n?.slug===e,c=b.useMemo(()=>qs(a,n?.metadata_schema,i,o),[a,n?.metadata_schema,i,o]),m=Kt(n),u=n?.metadata_schema;return{entityTypeQuery:l,entityType:n??void 0,isTypeReady:r,...c,collectionError:r?c.error:void 0,isDerived:m,schema:u,canShowBoard:!!Oe(u)&&!m,defaultLayout:In(u,{isDerived:m}),pageTitle:n?.name?.trim()||Ae(e)}}function Dn(e,{owner:s,entityTypeSlug:a,orgContext:i,layout:o,enabled:d,pageSize:l=50,onTableChange:n}){const{collection:p,table:r,isDerived:c,schema:m,entityType:u,pageTitle:h}=e,[x,C]=b.useState({key:"",page:0}),S=c?r.sort:zs(r,u?.metadata_schema),j=S?.field,y=S?.order,N=j&&!c?Xs(j):j,g=b.useMemo(()=>N?[{id:N,desc:y==="desc"}]:[],[N,y]),v=b.useCallback(A=>{const z=typeof A=="function"?A(g):A;z[0]&&n({...r,sort:{field:c?z[0].id:Gs(z[0].id),order:z[0].desc?"desc":"asc"}})},[g,n,r,c]),f=g[0]?.id,E=g[0]?g[0].desc?"desc":"asc":void 0,L=p.search??"",R=p.segment,k=o==="table"?l:200,T=`${a}?${JSON.stringify(p)}&sort=${JSON.stringify(r.sort)}&size=${k}`,$=x.key===T?x.page:0,W=b.useCallback(A=>C(z=>({key:T,page:A(z.key===T?z.page:0)})),[T]),V=e.isTypeReady&&d&&!e.collectionError,I=Ue(a,i,{limit:k,offset:$*k,search:L.trim()||void 0,sortBy:f,sortOrder:E,segment:R,filters:p.filters,enabled:V}),ae=Ue(a,i,{limit:1,offset:0,parentId:null,search:L.trim()||void 0,segment:R,filters:p.filters,enabled:V&&!c}),{data:G}=I,K=I.isLoading||I.isPending&&I.fetchStatus==="paused",M=G?.entities??[],ee=G?.metadata?.has_more??!1,F=G?.metadata?.total_count??0,H=M.length>0||L.trim().length>0||$>0||!!R||!!p.filters?.length,re=G?.linked_entities??{},J=ae.data?.metadata?.total_count,Q=F>0&&typeof J=="number"?J<F:!1,q=b.useMemo(()=>u?.measure_columns??[],[u?.measure_columns]),te=b.useCallback(A=>n({...r,columns:A}),[n,r]),X=u?.icon||void 0,B=b.useMemo(()=>({entities:M,owner:s,schema:m,entityTypeIcon:X,isDerived:c,measureColumns:q,linkedEntityLookups:re,hasAnyParents:Q,sorting:g,onSortingChange:v,visibleColumns:r.columns,columnChoices:Ws(m,c,M),onVisibleColumnsChange:te,page:$,pageSize:k,totalCount:F,hasMore:ee,pageTitle:h,onPrevPage:()=>W(A=>Math.max(0,A-1)),onNextPage:()=>W(A=>A+1)}),[M,s,m,X,c,q,re,Q,g,r.columns,te,v,W,$,k,F,ee,h]),P=b.useMemo(()=>({owner:s,entityType:u,entities:M,totalCount:F,schema:m,entityTypeIcon:X}),[s,u,M,F,m,X]);return{entityListQuery:I,entities:M,hasMore:ee,totalCount:F,hasRecords:H,tableState:B,boardState:P,isLoading:K||!c&&ae.isLoading,error:I.error??null}}function Bn({entityTypeSlug:e,orgContext:s,hasOrgContext:a,type:i,records:o,layout:d,layouts:l,onLayoutChange:n,onCollectionChange:p,onPresetChange:r,revision:c,controls:m,facets:u,title:h,actions:x,form:C,leading:S,afterPresets:j,trailing:y,filterExtras:N,loading:g=!1,recordsErrorShown:v=!0,content:f,onUpdateEntity:E,onOpenRecord:L,empty:R,onCreate:k}){const{entityType:T,entityTypeQuery:$,isTypeReady:W,collection:V,collectionError:I,presentation:ae,presets:G,preset:K,edited:M,schema:ee,isDerived:F,pageTitle:H}=i,[re,J]=b.useState(!1),Q=V.segment,q=Q?Fn(T).find(_=>_.name===Q)??{name:Q,description:""}:null,te=I||$.error||(v?o.error:null),X=!I&&(!a||!W||g||v&&o.isLoading),B=d==="graph",P={collection:V,schema:ee,label:H,org:s??"",facetQuery:u?ae.facetQuery:void 0,onChange:p,...N,segmentChip:q&&m.segments?{id:"segment",label:"Segment",op:"is",value:Ae(q.name),title:q.description||void 0,editor:q.description?{kind:"custom",render:()=>t.jsx("p",{className:"p-3 text-sm text-muted-foreground",children:q.description})}:void 0,onRemove:()=>p({...V,segment:void 0})}:void 0},A=_=>{J(!1),r(_)},z=d==="board"?t.jsx(Ct,{...o.boardState,onUpdate:E}):t.jsx(ft,{...o.tableState});return t.jsx(Js,{value:L,children:t.jsx(Ys,{title:h,actions:x,controls:t.jsxs(t.Fragment,{children:[C,!C&&W&&t.jsxs("nav",{className:"mb-4 flex flex-wrap items-center gap-x-3 gap-y-2","aria-label":`${H} views`,children:[S,d&&l.length>1&&t.jsx("fieldset",{className:"flex items-center rounded-md border p-0.5","aria-label":"Record layout",children:l.map(_=>{const oe=xe[_].icon,ie=d===_;return t.jsx(O,{type:"button",variant:"ghost",size:"sm","aria-pressed":ie,title:xe[_].label,"data-testid":`shape-${_}`,className:ge("h-7 px-2",ie&&"bg-accent text-accent-foreground"),onClick:()=>n(_),children:t.jsx(oe,{className:"h-4 w-4"})},_)})}),m.presets&&!!G.length&&t.jsxs(rt,{open:re,onOpenChange:J,children:[t.jsx(ot,{asChild:!0,children:t.jsxs(O,{variant:"outline",className:ge("gap-2",M&&"border-dashed border-primary"),"data-edited":M||void 0,title:"Choose saved filter",children:[K?.label??(V.filters?.length||V.search?"Custom filter":"All records"),M?t.jsx("span",{className:"text-xs font-normal text-primary",children:"Edited"}):null,t.jsx(it,{className:"h-4 w-4 text-muted-foreground"})]})}),t.jsxs(lt,{align:"start",className:"w-60 p-1",children:[t.jsx(O,{variant:K?"ghost":"secondary",className:"w-full justify-start",onClick:()=>A(),children:"All records"}),G.map(_=>t.jsx(O,{variant:K?.key===_.key?"secondary":"ghost",className:"w-full justify-start",onClick:()=>A(_),children:_.label},_.key))]})]}),j,!I&&m.filters&&t.jsx(kn,{...P},`filters:${e}:${c}`),t.jsxs("div",{className:"ml-auto flex flex-wrap items-center justify-end gap-x-3 gap-y-2",children:[m.search&&t.jsx(En,{label:H,search:V.search,onSearch:(_,oe)=>p({...V,search:_},oe),className:"w-64 max-w-full"},`search:${e}:${c}`),y]})]}),!C&&W&&!I&&(m.filters||m.segments)?t.jsx(_n,{...P},`applied:${e}:${c}`):null]}),children:C?null:X?B?t.jsx(xt,{label:`Loading ${H} graph`}):t.jsx(Qs,{}):te?t.jsxs("div",{role:"alert",className:"rounded-lg border border-destructive/30 bg-destructive/5 px-4 py-6 text-sm text-destructive",children:[te.message||`Failed to load ${H.toLowerCase()}.`,I&&t.jsx(O,{variant:"outline",size:"sm",className:"ml-3",onClick:()=>p({}),children:"Clear filters"})]}):f!==void 0?f:o.hasRecords?z:R??t.jsx(st,{icon:es,iconElement:t.jsx(nt,{icon:T?.icon,className:"mb-4 h-12 w-12 opacity-50"}),title:`No ${H.toLowerCase()} yet`,description:F?"This view has no rows yet. They appear as the underlying data arrives.":k?`Get started by creating your first ${T?.name?.toLowerCase()||"entity"}.`:"Records appear here as they are added.",actionLabel:F||!k?void 0:`Add ${T?.name||"Entity"}`,onAction:F?void 0:k})})})}const be=120,Y=12;function We(e,s){return typeof e.linkId=="number"&&typeof s.linkId=="number"?e.linkId-s.linkId:String(e.linkId).localeCompare(String(s.linkId))}function Vn(e){const s=e.records.slice(0,be),a=r=>e.types.get(r)??{label:r},i=new Map;for(const r of s)i.set(String(r.id),{source:r.source,entityType:e.typeSlug,slug:r.slug,name:r.name,isFocus:!0,hasMoreLinks:!1});const o=new Map;for(const r of e.links){if(!i.has(String(r.recordId)))continue;const c=o.get(r.recordId)??new Map;c.set(r.linkId,r),o.set(r.recordId,c)}const d=new Map;for(const[r,c]of o){const m=[...c.values()].sort(We),u=i.get(String(r));u&&m.length>Y&&(u.hasMoreLinks=!0);for(const h of m.slice(0,Y)){d.set(h.linkId,h);const x=String(h.peer.id);i.has(x)||i.set(x,{source:h.peer.source,...h.peer.remote?{remote:h.peer.remote}:{},entityType:h.peer.type,slug:h.peer.slug,name:h.peer.name,isFocus:!1,hasMoreLinks:!1})}}const l=[];for(const[r,c]of i){const m=c.remote?{label:c.entityType}:a(c.entityType),u=c.name||c.slug,h=c.hasMoreLinks?`${m.label} · ${Y}+ links`:m.label;l.push({id:r,data:{slug:c.slug,label:u,icon:m.icon,isSystem:!1,metaLabel:h},width:gn(u,h),height:fn})}const n=new Map;for(const r of[...d.values()].sort(We)){const c=String(r.fromId),m=String(r.toId),u=JSON.stringify([c,m]),h=n.get(u)??{source:c,target:m,rels:new Map,symmetric:!0};h.symmetric&&=r.isSymmetric,h.rels.has(r.relSlug)||h.rels.set(r.relSlug,{slug:r.relSlug,label:r.relName,ruleCount:1}),n.set(u,h)}const p=[...n.entries()].map(([r,c])=>({id:`link:${r}`,source:c.source,target:c.target,data:{relationships:[...c.rels.values()],isSymmetric:c.symmetric}}));return{nodes:l,edges:p,records:i,hasMoreRecords:e.hasMore===!0||e.records.length>be,listedCount:s.length,focusCount:s.length}}async function Hn(e,s){const a=Vn(e);return{...await hn({nodes:a.nodes,edges:a.edges},s),records:a.records,hasMoreRecords:a.hasMoreRecords,listedCount:a.listedCount,focusCount:a.focusCount}}const Un=8,qn=3,zn=4;function he(e){return`source:${JSON.stringify([e.type,e.key])}`}function Gn(e,s){return s.map(a=>{const i={type:e,key:a.slug};return{...a,id:he(i),source:i}})}function Je(e){return JSON.stringify([e.relationship_type,e.direction,e.entity_type,e.key])}async function Wn(e,s,a){const i=e.slice(0,Un),o=[];let d=0;return await Promise.all(Array.from({length:Math.min(qn,i.length)},async()=>{for(;d<i.length;){const l=d++,n=i[l];try{if(a?.aborted)throw a.reason;const p=await s(n),r=new Map(n.links.map(S=>[Je(S),S]));for(const S of p.record_links){const j=Je(S),y=r.get(j);(!y||y.occurred_at<S.occurred_at)&&r.set(j,S)}const c=new Map((n.relationships??[]).map(S=>[S.id,S]));for(const S of p.relationships??[])c.set(S.id,S);const m=[...c.values()].slice(0,Y+1),u=[...r.values()].slice(0,Y+1),h=(n.pagesRead??0)+1,x=!!p.next_cursor&&h>=zn,C=p.record_failures.some(S=>S.code!=="withheld")||!!p.relationship_failures?.length||x;o[l]={read:{record:n.record,links:u,failed:C,entityId:n.entityId,relationships:m},...!x&&(C||p.next_cursor&&u.length+m.length<=Y)?{next:{record:n.record,entityId:n.entityId,relationships:m,pagesRead:h,cursor:p.next_cursor??n.cursor,links:u}}:{}}}catch(p){if(a?.aborted)throw p;o[l]={read:{record:n.record,links:n.links,failed:!0,entityId:n.entityId,relationships:n.relationships},next:{...n,cursor:p instanceof ns&&p.status===400?null:n.cursor}}}}})),{reads:o.map(l=>l.read),pending:[...o.flatMap(l=>l.next?[l.next]:[]),...e.slice(i.length)]}}function Jn(e,s){const a=new Map;for(const d of e)for(const l of d.reads)a.set(String(l.entityId??he(l.record)),l);const i=new Map(s.map(d=>[d.slug,d])),o=[];for(const[d,l]of a){for(const n of l.relationships??[]){const p=(S,j,y)=>y?`remote:${y}`:typeof S=="number"?S:he({type:j,key:S}),r=p(n.from_entity_id,n.from_entity_type,n.from_entity_url),c=p(n.to_entity_id,n.to_entity_type,n.to_entity_url),m=String(r)===d,u=m?c:r,h=m?n.to_entity_id:n.from_entity_id,x=m?n.to_entity_url:n.from_entity_url,C=(m?n.to_entity_type:n.from_entity_type)??"";o.push({recordId:d,linkId:n.id,fromId:r,toId:c,relSlug:n.relationship_type_slug,relName:n.relationship_type_name,isSymmetric:n.is_symmetric,peer:{id:u,name:(m?n.to_entity_name:n.from_entity_name)??String(h),slug:(m?n.to_entity_slug:n.from_entity_slug)??String(h),type:C,...x?{remote:{url:as(x)}}:typeof h=="string"?{source:{type:C,key:h}}:{}}})}for(const n of l.links){const p={type:n.entity_type,key:n.key},r=he(p),c=i.get(n.relationship_type);let m=n.direction==="incoming"?r:d,u=n.direction==="incoming"?d:r;c?.is_symmetric&&m>u&&([m,u]=[u,m]),o.push({recordId:d,linkId:JSON.stringify([m,u,n.relationship_type]),fromId:m,toId:u,relSlug:n.relationship_type,relName:c?.name||n.relationship_type.replaceAll("_"," "),isSymmetric:c?.is_symmetric??!1,peer:{id:r,name:n.name||n.key,slug:n.key,type:n.entity_type,source:p}})}}return{links:o,checked:a.size,failed:[...a.values()].filter(d=>d.failed).length}}function Yn(e,s,a,i,o,d=!1){const{orgContext:l}=je(),n=ct(l),p=rs(l),r=b.useMemo(()=>d?Gn(s,a):a,[d,s,a]),c=b.useMemo(()=>r.slice(0,be).flatMap(g=>g.source?[{record:g.source,cursor:null,links:[]}]:typeof g.id=="number"?[{entityId:g.id,record:{type:s,key:g.slug},cursor:null,links:[]}]:[]),[r,s]),m=os({queryKey:["source-records-graph",l.organizationId,e,s,c.map(g=>[g.record,g.entityId])],enabled:!0,initialPageParam:c,queryFn:({pageParam:g,signal:v})=>Wn(g,async f=>{const E=await fe("manage_entity",{action:"list_links",...f.entityId===void 0?{record:f.record,cursor:f.cursor}:{entity_id:f.entityId,offset:Number(f.cursor??0)},limit:Y+1},e,{signal:v});return{...E,record_links:E.record_links??[],record_failures:E.record_failures??[],next_cursor:f.entityId===void 0?E.next_cursor:E.metadata?.has_more?String(Number(f.cursor??0)+Y+1):null}},v),getNextPageParam:g=>g.pending.length?g.pending:void 0,staleTime:3e4,retry:!1}),u=b.useMemo(()=>m.data?Jn(m.data.pages,p.data??[]):void 0,[m.data,p.data]),h=u?.links,x=m.isError,C=JSON.stringify([l.organizationId,e,s,d,r.map(g=>[g.id,g.name,g.slug]),i]),S=b.useMemo(()=>new Map((n.data??[]).map(g=>[g.slug,{label:g.name||g.slug,icon:g.icon}])),[n.data]),[j,y]=b.useState(null);b.useEffect(()=>{if(!h)return;let g=!1;return Hn({typeSlug:s,records:r,hasMore:i,links:h,types:S},{targetAspect:o}).then(v=>{g||y({graph:v,key:C,isError:!1})}).catch(()=>{g||y({graph:null,key:C,isError:!0})}),()=>{g=!0}},[h,s,r,i,S,o,C]);const N=j?.key===C?j:null;return{graph:N?.graph??null,isLoading:!x&&!N,isError:x||N?.isError===!0,sourceProgress:{checked:u?.checked??0,total:Math.min(a.length,be),failed:u?.failed??0,hasMore:!!m.hasNextPage,isFetching:m.isFetching,loadMore:()=>{m.isFetching||m.fetchNextPage()}}}}function Qn(e){const s=new Map(e.nodes.map(o=>[o.id,o.data.label])),a=e.nodes.map(o=>({id:o.id,x:o.position.x+o.width/2,y:o.position.y+o.height/2,w:o.width,h:o.height,title:o.data.label,meta:o.data.metaLabel,icon:o.data.icon,muted:e.records.get(o.id)?.isFocus===!1})),i=e.edges.map(o=>{const{relationships:d,isSymmetric:l}=o.data,n=d.map(p=>p.label);return{id:o.id,source:o.source,target:o.target,route:o.route??null,summary:n.length===1?n[0]:`${n.length} relationships`,details:n,directed:!l,ariaLabel:`${s.get(o.source)??o.source} ${l?"and":"to"} ${s.get(o.target)??o.target}: ${n.join(", ")}`}});return{boxes:a,edges:i}}function Xn({ownerSlug:e,typeSlug:s,records:a,hasMore:i,sourceBacked:o=!1}){const d=de(),l=dt(),{orgContext:n}=je(),{data:p=[]}=ct(n),r=p.find(v=>v.slug===s)?.name??s,[c,m]=b.useState(),u=b.useRef(null),h=b.useCallback(v=>{if(u.current?.disconnect(),u.current=null,!v||typeof ResizeObserver>"u")return;const f=()=>{if(!v.clientWidth||!v.clientHeight)return;const L=Math.round(v.clientHeight/v.clientWidth*10)/10;m(R=>R===L?R:L)};f();const E=new ResizeObserver(f);E.observe(v),u.current=E},[]),{graph:x,isLoading:C,isError:S,sourceProgress:j}=Yn(e,s,a,i,c,o),y=b.useMemo(()=>x?Qn(x):null,[x]),N=b.useCallback(v=>{const f=x?.records.get(v);if(f){if(f.remote){f.remote.url&&window.open(f.remote.url,"_blank","noopener,noreferrer");return}if(l){l.open(dn(f.source?{owner:e,segments:[{entity_type:f.source.type,slug:f.source.key}]}:{owner:e,entityId:Number(v)},f.name||f.slug));return}d({to:is(e,[{entity_type:f.entityType,slug:f.slug}])})}},[x,e,l,d]);if(S)return t.jsx(ls,{label:`${r} graph`});if(C||!x||!y)return t.jsx(xt,{label:`Loading ${r} graph`});const g=j?t.jsxs("div",{className:"flex flex-wrap items-center justify-between gap-3",children:[t.jsxs("div",{className:"text-sm text-muted-foreground",role:"status",children:[t.jsxs("p",{children:["Checked ",j.checked," of ",j.total," records. Up to ",Y," relationships per record."]}),j.failed>0?t.jsx("p",{role:"alert",children:"Some sources could not be read. These relationships are incomplete."}):null]}),j.hasMore?t.jsx(O,{variant:"outline",size:"sm",disabled:j.isFetching,onClick:j.loadMore,children:j.isFetching?"Loading…":j.failed>0?"Retry sources":"Load more relationships"}):null]}):null;return x.focusCount===0?t.jsxs("div",{className:"space-y-3",children:[g,t.jsx(st,{icon:at,title:`No ${r} records match`,description:"Change the search or filters to see records here."})]}):t.jsxs("div",{className:"flex flex-col gap-2",children:[g,t.jsxs("p",{className:"text-sm text-muted-foreground",children:["Showing ",x.hasMoreRecords?"the first ":"",x.focusCount," ",r," record",x.focusCount===1?"":"s",". Click a record to see it."]}),t.jsx("div",{ref:h,className:"h-[70vh] min-h-[420px] min-w-0 overflow-hidden",children:t.jsx(yn,{boxes:y.boxes,edges:y.edges,label:`${r} records`,onOpenBox:N,openLabel:v=>`Show ${v.title}`})})]})}const Et={version:1,root:{type:"entity-table",props:{state:"{{tableState}}"}}},Zn={version:1,root:{type:"entity-board",props:{state:"{{boardState}}",onUpdate:"@updateEntity"}}};function Kn(e){const{canShowBoard:s,builtinData:a,builtInLabels:i}=e,o=["table",...s?["board"]:[]],d={table:Et,board:Zn};return o.map(l=>({id:l,label:i[l],builtInMode:l,template:d[l],data:a}))}function ea(e){let s=0;for(let a=0;a<e.length;a++)s=(s<<5)-s+e.charCodeAt(a),s|=0;return s.toString(36)}function wt(e,s){return{queryKey:["metric_series",e,ea(s)],queryFn:()=>fe("metric_series",{sql:s},{slug:e}),staleTime:6e4}}function kt(e,s){const a=!!e&&!!s,i=wt(e??"",s??"");return Ke({...i,enabled:a})}kt.queryOptions=(e,s)=>wt(e,s);function ta(e,s){if(!e?.columns?.length||!e.rows)return[];const a=e.columns.indexOf(s);return a<0?[]:e.rows.map(i=>Number(i[a])||0)}const Ye=/^[a-z][a-z0-9_]*$/;function sa(e){const s=Object.entries(e);for(const[o,d]of s){if(!Ye.test(o))throw new Error(`lifecycleCumulativeStatsSql: unsafe column name '${o}'`);if(!Ye.test(d))throw new Error(`lifecycleCumulativeStatsSql: unsafe entity_type '${d}'`)}const a=s.flatMap(([o,d])=>[`COUNT(*) FILTER (
3
+ WHERE semantic_type = 'change'
4
+ AND metadata->>'category' = 'lifecycle'
5
+ AND metadata->>'entity_type' = '${d}'
6
+ AND metadata->>'op' = 'created'
7
+ ) AS ${o}_added`,`COUNT(*) FILTER (
8
+ WHERE semantic_type = 'change'
9
+ AND metadata->>'category' = 'lifecycle'
10
+ AND metadata->>'entity_type' = '${d}'
11
+ AND metadata->>'op' = 'deleted'
12
+ ) AS ${o}_removed`]).join(`,
13
+ `),i=s.map(([o])=>` SUM(COALESCE(b.${o}_added, 0) - COALESCE(b.${o}_removed, 0))
14
+ OVER (ORDER BY d.bucket) AS ${o}`).join(`,
15
+ `);return`
16
+ WITH days AS (
17
+ SELECT generate_series(
18
+ date_trunc('day', now() - interval '13 days'),
19
+ date_trunc('day', now()),
20
+ interval '1 day'
21
+ ) AS bucket
22
+ ),
23
+ buckets AS (
24
+ SELECT
25
+ date_trunc('day', created_at) AS bucket,
26
+ ${a}
27
+ FROM events
28
+ WHERE created_at > now() - interval '14 days'
29
+ GROUP BY 1
30
+ )
31
+ SELECT d.bucket,
32
+ ${i}
33
+ FROM days d
34
+ LEFT JOIN buckets b ON b.bucket = d.bucket
35
+ ORDER BY d.bucket
36
+ `}const na={"memory-activity":`
37
+ WITH days AS (
38
+ SELECT generate_series(
39
+ date_trunc('day', now() - interval '13 days'),
40
+ date_trunc('day', now()),
41
+ interval '1 day'
42
+ ) AS bucket
43
+ ),
44
+ buckets AS (
45
+ SELECT
46
+ date_trunc('day', created_at) AS bucket,
47
+ COUNT(*) FILTER (
48
+ WHERE semantic_type NOT IN ('change', 'audit', 'operation')
49
+ ) AS events_count,
50
+ COUNT(*) FILTER (
51
+ WHERE semantic_type = 'change'
52
+ AND metadata->>'category' = 'lifecycle'
53
+ AND metadata->>'entity_type' = 'connection'
54
+ AND metadata->>'op' = 'created'
55
+ ) AS connections_added,
56
+ COUNT(*) FILTER (
57
+ WHERE semantic_type = 'change'
58
+ AND metadata->>'category' = 'lifecycle'
59
+ AND metadata->>'entity_type' = 'connection'
60
+ AND metadata->>'op' = 'deleted'
61
+ ) AS connections_removed
62
+ FROM events
63
+ WHERE created_at > now() - interval '14 days'
64
+ GROUP BY 1
65
+ )
66
+ SELECT d.bucket,
67
+ COALESCE(b.events_count, 0)::int AS events,
68
+ SUM(COALESCE(b.connections_added, 0) - COALESCE(b.connections_removed, 0))
69
+ OVER (ORDER BY d.bucket) AS connections
70
+ FROM days d
71
+ LEFT JOIN buckets b ON b.bucket = d.bucket
72
+ ORDER BY d.bucket
73
+ `};function aa(e){if(typeof e.sql=="string"&&e.sql.trim())return e.sql;if(e.lifecycle&&typeof e.lifecycle=="object"){const s=Object.fromEntries(Object.entries(e.lifecycle).map(([a,i])=>[a,String(i)]));if(Object.keys(s).length>0)try{return sa(s)}catch{return null}}return typeof e.preset=="string"?na[e.preset]??null:null}function ra({owner:e,sql:s,lifecycle:a,preset:i,column:o,chart:d,height:l,width:n,color:p,label:r,className:c}){const m=b.useMemo(()=>aa({sql:s,lifecycle:a,preset:i}),[s,a,i]),u=typeof e=="string"&&e?e:null,{data:h}=kt(u,m),x=String(o??""),C=b.useMemo(()=>ta(h,x),[h,x]),S=b.useMemo(()=>!h?.columns?.length||!h.rows?[]:h.rows.map((y,N)=>({label:String(y[0]??"").slice(0,10),value:C[N]??0})),[h,C]);if(!u||!m||!x)return null;const j=d==="line"?t.jsx(un,{data:S,height:typeof l=="number"?l:void 0}):t.jsx(mn,{data:C,height:typeof l=="number"?l:void 0,width:typeof n=="number"?n:void 0,color:typeof p=="string"?p:void 0});return r==null?t.jsx("div",{className:c,children:j}):t.jsxs("div",{className:c,children:[t.jsx("p",{className:"text-sm text-muted-foreground",children:String(r)}),j]})}function oa({metadata:e,metadataSchema:s,name:a,typeIcon:i,initialsFallback:o,className:d}){return t.jsx(tt,{metadata:e,metadataSchema:s,name:String(a??""),typeIcon:i,initialsFallback:!!o,className:d})}function ia({entity:e,owner:s,className:a,onClick:i,children:o}){const d=e;if(!d)return t.jsx(t.Fragment,{children:o});const l=et(String(s??""),yt(d));return t.jsx(ve,{to:l,className:a,onClick:i,children:o})}function la({state:e}){return e?t.jsx(ft,{...e}):null}function ca({state:e,onUpdate:s}){return e?t.jsx(Ct,{...e,onUpdate:s}):null}const da={"entity-avatar":oa,"entity-link":ia,"entity-table":la,"entity-board":ca,"metric-series":ra};function ua({ownerSlug:e,typeSlug:s,title:a,shape:i}){const[o,d]=b.useState(!1),l=de(),{visible:n,system:p,isTypesLoading:r}=cs(e),c=u=>{d(!1);const h=`/${e}/${ut(u)}`;l({to:i?`${h}/${mt}/${i}`:h})},m=u=>t.jsxs(gs,{value:`${u.name} ${u.slug}`,onSelect:()=>c(u.slug),children:[t.jsx(nt,{icon:u.icon,className:"mr-2 h-4 w-4 shrink-0"}),t.jsx("span",{className:"flex-1 truncate",children:u.name||u.slug}),u.slug===s?t.jsx(ys,{className:"ml-2 h-3.5 w-3.5 shrink-0","aria-label":"Current"}):null,u.entity_count!=null?t.jsx("span",{className:"ml-2 shrink-0 text-xs tabular-nums text-muted-foreground",children:u.entity_count.toLocaleString()}):null]},u.slug);return t.jsxs(rt,{open:o,onOpenChange:d,children:[t.jsx("h1",{className:"flex min-w-0 items-center text-lg font-semibold tracking-tight @sm:text-2xl",children:t.jsx(ot,{asChild:!0,children:t.jsxs(O,{type:"button",variant:"ghost",title:a,className:"-ml-2 h-auto min-w-0 gap-1 px-2 py-1 text-lg font-semibold tracking-tight @sm:gap-1.5 @sm:text-2xl",children:[t.jsx("span",{className:"truncate",children:a}),t.jsx(it,{className:"h-5 w-5 shrink-0 text-muted-foreground"})]})})}),t.jsx(lt,{align:"start",className:"w-72 p-0",children:t.jsxs(ds,{children:[t.jsx(us,{autoFocus:!0,placeholder:"Find a type…"}),t.jsxs(ms,{children:[t.jsx(ps,{children:r?"Loading types…":"No type matches."}),n.length>0?t.jsx(qe,{heading:"Types",children:n.map(m)}):null,p.length>0?t.jsx(qe,{heading:"System",children:p.map(m)}):null]}),t.jsx(hs,{}),t.jsxs(ve,{to:"/$owner",params:{owner:e},search:{layout:"graph"},onClick:()=>d(!1),className:"flex items-center gap-2 px-3 py-2 text-sm text-muted-foreground hover:text-foreground",children:[t.jsx(fs,{className:"h-4 w-4"}),"Data map"]})]})})]})}const _t=(e,s)=>`lobu.record-shape:v1:${e}/${s}`,ma=new Set(["table","board","graph"]);function pa(e,s){const a=Es(_t(e,s));return a&&ma.has(a)?a:void 0}function ha(e,s,a){ws(_t(e,s),a)}const Qe=":records",fa={search:!0,filters:!0,segments:!0,presets:!0};function ga({ownerSlug:e,entityTypeSlug:s,create:a,onCreateChange:i,viewKey:o,shape:d}){const{orgContext:l,hasOrgContext:n}=je();xs(`/${e}`,l);const p=bs(),r=pt({strict:!1}),c=de(),m=dt(),u=`/${e}/${ut(s)}`,{session:h,isReady:x}=vs(),C=h?.user?.email,S=b.useMemo(()=>C?{email:C}:void 0,[C]),j=Pn({entityTypeSlug:s,orgContext:l,search:r,viewPath:!!o,viewer:S,authReady:x}),{entityType:y,entityTypeQuery:N,isTypeReady:g,collection:v,preset:f,table:E,pageTitle:L,isDerived:R,canShowBoard:k}=j,T=b.useMemo(()=>Zs(r,v),[r,v]),[$,W]=b.useState(0),V=w=>void c({...le,search:D=>({...Le(D,ne(w)),...T}),replace:!0}),I=b.useCallback(w=>void c({...le,search:{...o?ne(r):{},...T,$table:JSON.stringify(w)},replace:!0}),[c,o,r,T]),ae=a===!0,G=()=>i(!0),K=()=>i(!1),M=ht(l),ee=_e(M.data??[],s,v),F=(w,D=!1,Z=ne(r))=>{const U=!o||!M.data||_e(M.data,s,w).some(me=>me.key===o);c({to:U?".":u,search:{...U&&o?Z:{},...Ks(w,f?.key),$table:JSON.stringify(E)},replace:D})},H=w=>{const D=w?ks(w,void 0,S):{},Z=!o||_e(M.data??[],s,D).some(U=>U.key===o);W(U=>U+1),c({to:Z?".":u,search:w?{$preset:w.key}:{}})},{isAdmin:re}=js(l.organizationId),J=Ss(l),Q=re&&!!y&&!N.isPlaceholderData,q=b.useRef(r);q.current=r;const te=async()=>{if(!f)return;const w=JSON.stringify(r),{data:D}=await N.refetch(),Z=D?.metadata_schema,U=Z?_s(Z[ze]??{}):void 0,me=U?.presets?.find(pe=>pe.key===f.key);if(!D||!Z||!U||!me){Ze.error("This saved filter changed. Reload and try again.");return}const we=en(me,v,E,U,void 0,S);await J.mutateAsync({slug:D.slug,metadata_schema:{...Z,[ze]:{...U,presets:U.presets?.map(pe=>pe.key===we.key?we:pe)}}}).then(()=>!0,()=>!1)&&(await N.refetch(),JSON.stringify(q.current)===w&&H(we))},X=b.useMemo(()=>pa(e,s),[e,s]),B=Ns(M.data??[],s,{viewKey:o,shape:d??(o?void 0:X)},j.defaultLayout,v),P=B.kind==="builtin"?B.mode==="board"&&!k?"table":B.mode:null,A=P==="graph";b.useEffect(()=>{d&&g&&P&&ha(e,s,P)},[d,g,P,e,s]);const z=["table",...k?["board"]:[],"graph"],_=B.kind==="view"?B.view:null,oe=B.kind==="missing"?B.key:null,ie=B.kind==="inapplicable"?B:null,se=Dn(j,{owner:e,entityTypeSlug:s,orgContext:l,layout:P,enabled:!o,onTableChange:I}),{entities:Ne,hasMore:Rt,totalCount:ue}=se,Ie=ue>Ne.length,Fe=`showing first ${Ne.length} of ${ue} — narrow with search`,Ce=b.useMemo(()=>({tableState:se.tableState,boardState:se.boardState,owner:e,schema:j.schema,entityType:y,entityTypeIcon:y?.icon||void 0,totalCount:ue,isTruncated:Ie,truncationNotice:Fe,canCreate:!R,addLabel:`Add ${y?.name||Ae(s)}`}),[se.tableState,se.boardState,e,j.schema,y,ue,Ie,Fe,R,s]),Lt=b.useMemo(()=>Kn({canShowBoard:k,builtinData:Ce,builtInLabels:{table:xe.table.label,board:xe.board.label}}),[k,Ce]),Pe=P?Lt.find(w=>w.id===P)??null:null,$t=Pe?.template??Et,Mt=Pe?.data??Ce,De=w=>void c({to:w===Qe?u:`${u}${Rs(w)}`,search:T}),Ee=ne(r),Tt=xn(_?.params,Ee,w=>void c({...le,search:{...ne(w),...T}})),At=()=>F({...v,filters:[],segment:void 0},!1,bn(_?.params,Ee)),Be=`Moved on ${y?.name||y?.slug||s} board`,Ve=b.useMemo(()=>(w,D)=>p.mutateAsync({entityId:w,metadata:D,field_note:Be}),[p,Be]),Ot=b.useMemo(()=>({updateEntity:Ve,openCreate:()=>i(!0)}),[Ve,i]),He=w=>m?t.jsx("span",{className:w,children:t.jsx(O,{type:"button",variant:"ghost",size:"icon",className:"size-8 shrink-0 text-muted-foreground hover:text-foreground","aria-label":"Edit type",title:"Edit type",onClick:()=>m.open({href:$s(e,s),title:L}),children:t.jsx(Ls,{className:"h-4 w-4"})})}):null,It=!!o&&M.data===void 0&&M.isError?t.jsx($e,{onRetry:()=>void M.refetch()}):ie?t.jsxs("div",{className:"flex flex-col items-center justify-center py-16 text-center","data-testid":"inapplicable-view",children:[t.jsxs("h2",{className:"text-lg font-semibold",children:["“",ie.view.name,"” doesn’t apply to the current filters"]}),t.jsxs("p",{className:"text-muted-foreground mt-2 text-sm",children:["It appears when the selection includes"," ",Object.entries(ie.when).map(([w,D])=>`${w} is ${D===null?"not supplied":String(D)}`).join(" and "),"."]}),t.jsx(ve,{to:u,search:T,className:"mt-4 text-sm font-medium underline underline-offset-4",children:`Back to ${L}`})]}):oe?t.jsx(bt,{viewKey:oe,backTo:u,backLabel:`Back to ${L}`}):_?t.jsx(vt,{orgSlug:e,viewKey:_.key,scope:{type:s,collection:v},params:Ee,onParamsChange:V,paramDecls:_.params,contentHash:_.content_hash,title:_.name,minHeight:320}):se.hasRecords?A?t.jsx(Xn,{ownerSlug:e,typeSlug:s,sourceBacked:R,records:Ne.map(w=>({...w,id:w.id??JSON.stringify([w.entity_type,w.slug])})),hasMore:Rt}):t.jsx(pn,{template:$t,data:Mt,actions:Ot,components:da}):void 0;return t.jsx(Bn,{entityTypeSlug:s,orgContext:l,hasOrgContext:n,type:j,records:se,layout:o?null:P,layouts:z,onLayoutChange:w=>void c({to:`${u}/${mt}/${w}`,search:T,replace:!0}),onCollectionChange:F,onPresetChange:H,revision:$,controls:fa,facets:!0,title:t.jsx(ua,{ownerSlug:e,typeSlug:s,title:L,shape:o?null:P}),actions:He("hidden @sm:contents"),form:ae?t.jsx("div",{className:"max-w-3xl",children:t.jsx(Sn,{onClose:K,entityTypeSlug:s,orgContext:l})}):void 0,leading:t.jsxs(t.Fragment,{children:[He("-mr-1 @sm:hidden"),o&&t.jsx(O,{variant:"ghost",onClick:()=>De(Qe),children:"Records"})]}),afterPresets:t.jsxs(t.Fragment,{children:[f&&j.edited?t.jsxs("div",{className:"-ml-2 mr-2 inline-flex items-center gap-1",children:[t.jsx(O,{variant:"ghost",size:"sm",onClick:()=>H(f),children:"Reset"}),Q?t.jsx(O,{size:"sm",disabled:J.isPending,onClick:()=>void te(),children:J.isPending?"Saving…":"Save"}):null]}):null,ee.map(w=>t.jsx(O,{"data-testid":`tab-${w.key}`,variant:o===w.key?"secondary":"ghost","aria-pressed":o===w.key,onClick:()=>De(w.key),children:w.name},w.key))]}),trailing:!R&&!o?t.jsxs(O,{size:"sm","aria-label":`Add ${L||"entity"}`,onClick:()=>G(),children:[t.jsx(Cs,{className:"mr-2 h-4 w-4"}),"Add"]}):null,filterExtras:{viewFilters:Tt,onClearAll:At},loading:!!o&&M.data===void 0&&!M.isError,recordsErrorShown:!o,content:It,onCreate:G})}function ya({ownerSlug:e,typeScope:s,create:a,viewKey:i,shape:o}){const d=de(),l=pt({strict:!1}),n=s?Ms(s):void 0,p=n==="$member",r=m=>{if(!n)return;const u=As(e,n);d({to:u.to,params:u.params,search:m?{create:!0}:{},replace:!0})},c=n?t.jsx(ga,{ownerSlug:e,entityTypeSlug:n,create:a,onCreateChange:r,viewKey:i,shape:o}):i?t.jsx(xa,{ownerSlug:e,viewKey:i,search:l}):null;return t.jsx("div",{className:"flex min-h-0 min-w-0 flex-1 flex-col gap-4",children:p?t.jsx(jn,{children:c}):c})}function xa({ownerSlug:e,viewKey:s,search:a}){const i=de(),{orgContext:o}=je(),{data:d,isError:l,error:n,refetch:p}=ht(o),r=Ts(d??[],s);return d===void 0?l?t.jsx($e,{error:n,onRetry:()=>void p()}):null:r.kind==="missing"?t.jsx(bt,{viewKey:r.key,backTo:`/${e}`,backLabel:"Back to Home"}):t.jsxs("div",{className:"flex min-h-0 min-w-0 flex-1 flex-col gap-4",children:[l?t.jsx($e,{error:n,onRetry:()=>void p()}):null,t.jsx(vn,{decls:r.view.params,params:ne(a),onParamsChange:c=>void i({...le,search:m=>Le(m,c)})}),t.jsx(vt,{className:"min-h-0 flex-1",fixedHeight:"100%",orgSlug:e,viewKey:r.view.key,scope:{},params:ne(a),onParamsChange:c=>void i({...le,search:m=>Le(m,c),replace:!0}),paramDecls:r.view.params,contentHash:r.view.content_hash,title:r.view.name,minHeight:400})]})}function La({ownerSlug:e,typeScope:s,create:a,viewKey:i,shape:o}){return t.jsxs(Os,{inset:i?"flush":"page",className:i?"gap-0 pt-0 pb-0":"gap-6 pt-2.5 pb-8",children:[t.jsx(Fs,{}),t.jsx(Is,{owner:e,children:d=>t.jsx("div",{className:"flex min-h-0 min-w-0 flex-1 flex-col",children:t.jsx(ya,{ownerSlug:d.ownerSlug,typeScope:s,create:a,viewKey:i,shape:o})})})]})}export{La as M};
74
+ //# sourceMappingURL=memory-browse-page-D5kj1RaR.js.map
@@ -1,2 +1,2 @@
1
- import{aW as v,aX as N,j as s,gL as y,aO as m,a9 as p,i as f,B as w,gN as b}from"./index-BoqrvLHQ.js";function M(o,r){const l=new Map(r.map(e=>[e.slug,e])),i=new Map,d=e=>{const a=e.model?.trim();if(!a)return;const t=`${e.slug}/${a}`;i.has(t)||i.set(t,{value:t,provider:e.provider,model:a,isDefault:e.isDefault})};for(const e of o){const a=l.get(e.kind)??l.get(e.slug),t={slug:e.slug,provider:e.displayName||e.slug,isDefault:e.isDefault};d({...t,model:e.capabilities.text?.model}),d({...t,model:a?.defaultModel});for(const x of a?.models??[])d({...t,model:x})}for(const e of r){if(!e.systemAvailable)continue;const a={slug:e.slug,provider:e.displayName||e.slug,isDefault:!1};d({...a,model:e.defaultModel});for(const t of e.models)d({...a,model:t})}return[...i.values()]}function _(o,r){const l=o.trim();return l.length>0&&l!=="auto"&&!r.some(i=>i.value===l)}function S({value:o,onChange:r,placeholder:l,disabled:i,className:d}){const{data:e=[]}=v(),{data:a=[]}=N(),t=M(e,a),x=t.find(c=>c.value===o),h=o==="auto"?"auto":x?.value??o;return s.jsx(y,{contentClassName:"w-[--radix-popover-trigger-width] min-w-[280px]",searchPlaceholder:"Search or type a model ref…",emptyText:"Type a full provider/model ref to use it.",trigger:c=>s.jsxs(w,{type:"button",variant:"outline",role:"combobox","aria-expanded":c,disabled:i,className:f("w-full justify-between font-normal",o?"":"text-muted-foreground",d),children:[s.jsx("span",{className:"truncate",children:o?h:l}),s.jsx(b,{className:"ml-2 h-4 w-4 shrink-0 opacity-50"})]}),children:(c,j)=>{const u=j.trim(),g=_(u,t);return s.jsxs(s.Fragment,{children:[s.jsxs(m,{value:"__inherit__ use default inherit",onSelect:()=>{r(""),c()},className:"cursor-pointer",children:[s.jsx(p,{className:f("mr-2 h-4 w-4",o===""?"opacity-100":"opacity-0")}),s.jsx("span",{className:"text-muted-foreground",children:l})]}),s.jsxs(m,{value:"auto newest latest",onSelect:()=>{r("auto"),c()},className:"cursor-pointer",children:[s.jsx(p,{className:f("mr-2 h-4 w-4",o==="auto"?"opacity-100":"opacity-0")}),s.jsxs("span",{children:["auto"," ",s.jsx("span",{className:"text-muted-foreground text-xs",children:"(newest for the provider)"})]})]}),t.map(n=>s.jsxs(m,{value:`${n.provider} ${n.model} ${n.value}`,onSelect:()=>{r(n.value),c()},className:"cursor-pointer",children:[s.jsx(p,{className:f("mr-2 h-4 w-4",o===n.value?"opacity-100":"opacity-0")}),s.jsxs("span",{className:"truncate",children:[n.provider," ",s.jsx("span",{className:"text-muted-foreground text-xs",children:n.model}),n.isDefault?s.jsx("span",{className:"ml-1.5 text-muted-foreground text-xs",children:"· org default"}):null]})]},n.value)),g?s.jsxs(m,{value:`__custom__ ${u}`,onSelect:()=>{r(u),c()},className:"cursor-pointer",children:[s.jsx(p,{className:"mr-2 h-4 w-4 opacity-0"}),s.jsxs("span",{children:["Use ",s.jsx("span",{className:"font-mono text-xs",children:u})]})]}):null]})}})}export{S as M,M as b,_ as s};
2
- //# sourceMappingURL=model-selector-D2OpDkwH.js.map
1
+ import{b2 as v,b3 as N,j as s,gZ as y,aW as m,aa as p,i as f,B as w,g_ as b}from"./index-DB2lVKuV.js";function _(o,r){const l=new Map(r.map(e=>[e.slug,e])),i=new Map,d=e=>{const a=e.model?.trim();if(!a)return;const t=`${e.slug}/${a}`;i.has(t)||i.set(t,{value:t,provider:e.provider,model:a,isDefault:e.isDefault})};for(const e of o){const a=l.get(e.kind)??l.get(e.slug),t={slug:e.slug,provider:e.displayName||e.slug,isDefault:e.isDefault};d({...t,model:e.capabilities.text?.model}),d({...t,model:a?.defaultModel});for(const x of a?.models??[])d({...t,model:x})}for(const e of r){if(!e.systemAvailable)continue;const a={slug:e.slug,provider:e.displayName||e.slug,isDefault:!1};d({...a,model:e.defaultModel});for(const t of e.models)d({...a,model:t})}return[...i.values()]}function M(o,r){const l=o.trim();return l.length>0&&l!=="auto"&&!r.some(i=>i.value===l)}function S({value:o,onChange:r,placeholder:l,disabled:i,className:d}){const{data:e=[]}=v(),{data:a=[]}=N(),t=_(e,a),x=t.find(c=>c.value===o),h=o==="auto"?"auto":x?.value??o;return s.jsx(y,{contentClassName:"w-[--radix-popover-trigger-width] min-w-[280px]",searchPlaceholder:"Search or type a model ref…",emptyText:"Type a full provider/model ref to use it.",trigger:c=>s.jsxs(w,{type:"button",variant:"outline",role:"combobox","aria-expanded":c,disabled:i,className:f("w-full justify-between font-normal",o?"":"text-muted-foreground",d),children:[s.jsx("span",{className:"truncate",children:o?h:l}),s.jsx(b,{className:"ml-2 h-4 w-4 shrink-0 opacity-50"})]}),children:(c,j)=>{const u=j.trim(),g=M(u,t);return s.jsxs(s.Fragment,{children:[s.jsxs(m,{value:"__inherit__ use default inherit",onSelect:()=>{r(""),c()},className:"cursor-pointer",children:[s.jsx(p,{className:f("mr-2 h-4 w-4",o===""?"opacity-100":"opacity-0")}),s.jsx("span",{className:"text-muted-foreground",children:l})]}),s.jsxs(m,{value:"auto newest latest",onSelect:()=>{r("auto"),c()},className:"cursor-pointer",children:[s.jsx(p,{className:f("mr-2 h-4 w-4",o==="auto"?"opacity-100":"opacity-0")}),s.jsxs("span",{children:["auto"," ",s.jsx("span",{className:"text-muted-foreground text-xs",children:"(newest for the provider)"})]})]}),t.map(n=>s.jsxs(m,{value:`${n.provider} ${n.model} ${n.value}`,onSelect:()=>{r(n.value),c()},className:"cursor-pointer",children:[s.jsx(p,{className:f("mr-2 h-4 w-4",o===n.value?"opacity-100":"opacity-0")}),s.jsxs("span",{className:"truncate",children:[n.provider," ",s.jsx("span",{className:"text-muted-foreground text-xs",children:n.model}),n.isDefault?s.jsx("span",{className:"ml-1.5 text-muted-foreground text-xs",children:"· org default"}):null]})]},n.value)),g?s.jsxs(m,{value:`__custom__ ${u}`,onSelect:()=>{r(u),c()},className:"cursor-pointer",children:[s.jsx(p,{className:"mr-2 h-4 w-4 opacity-0"}),s.jsxs("span",{children:["Use ",s.jsx("span",{className:"font-mono text-xs",children:u})]})]}):null]})}})}export{S as M,_ as b,M as s};
2
+ //# sourceMappingURL=model-selector-CjkBPpjN.js.map
@@ -0,0 +1,2 @@
1
+ import{c as S,o as p,cU as k,b0 as A,t as T,r as g,j as e,aC as L,aD as P,dI as B,L as w,dJ as I,dw as R,n as C,dQ as f,a_ as $}from"./index-DB2lVKuV.js";import{C as D,A as O}from"./create-automation-form-CTiy_S9G.js";import"./entity-options-D9K_5Lcs.js";import"./use-automations-DcdlmVuX.js";import"./device-automation-Dp3faMvp.js";import"./model-selector-CjkBPpjN.js";import"./skill-editor-D_W3QlRz.js";import"./code-editor-CTdKUDPY.js";import"./index-Vcq4gwWv.js";import"./json-diff-Ce6YAXzY.js";import"./use-mention-search-BniE-K2d.js";function E(n){return n.includes(":")?n.slice(n.indexOf(":")+1):n}function F({prefillAgentId:n,onCancel:t,initialTriggers:l,conversationSetup:h}){const{org:o}=p(),[i,d]=g.useState({ready:!1,triggers:[]}),[u,N]=g.useState(),a=g.useCallback(s=>{d(m=>JSON.stringify(m)===JSON.stringify(s)?m:s)},[]),r=u??l;return e.jsx(D,{startFromScratch:!!l,organizationId:o?.id??"",prefillAgentId:n,conversationSetup:h,onClose:t,onPrefillTriggers:s=>N(s.length>0?s:void 0),onSuccess:t,hideHeader:!0,hideCancel:!0,submitLabel:"Create Automation",submitDisabled:!i.ready,createFields:{triggers:i.triggers},triggerFields:e.jsx(O,{organizationId:o?.id??null,initialTriggers:r,onChange:a},JSON.stringify(r??"new"))})}function J({owner:n,prefilled:t}){const l=S(),{org:h}=p(),o=k(h?.id??null,{status:"active",limit:500}),i=A(h?.id??null),{data:d=[]}=T(),u=!!(t?.platform&&(t.listen||t.resource)),N=u&&(o.isLoading||i.isLoading),a=g.useMemo(()=>{if(!t?.platform||!t.listen&&!t.resource)return;const x=o.data??[],j=t.connection?x.find(c=>c.slug===t.connection):(()=>{const c=x.filter(v=>v.connector_key!==t.platform?!1:t.resource?!0:v.facets.chat&&(v.external_tenant_id??"")===(t.team??""));return c.length===1?c[0]:void 0})();if(t.connection&&!j)return;const b=t.events?.split(",").map(c=>c.trim()).filter(Boolean)??[];return[{kind:"event",source:"connector",connector_key:t.platform,...j?{connection_id:j.id}:{},event_types:b.length>0?b:t.listen?["message.created"]:[],match:t.resource?{resource_ref:t.resource,...t.resource_type?{resource_type:t.resource_type}:{}}:{channel_id:E(t.listen??"")},execution:"turn",active_run:t.listen?"steer":"queue",output:t.listen?"reply_to_source":"silent",skip_if_unchanged:!t.listen}]},[o.data,t]),r=i.data?.find(x=>x.key===t?.platform)?.name,s=t?.label??t?.listen,m=g.useMemo(()=>t?.listen&&a&&s?{name:r?`${r}: ${s}`:s}:void 0,[s,r,a,t?.listen]),_=()=>void l({to:"/$owner",params:{owner:n},search:{section:"automation"}}),y=a?t?.resource?`React to changes on ${t.label??t.resource}.`:`React to messages in ${t?.label??t?.listen}.`:u&&!o.isLoading?"Choose the matching connection and event, then define the reaction.":"Start from a template, from scratch, or clone an existing Automation.";return e.jsx(L,{className:"gap-6 pt-2.5 pb-8",children:e.jsxs(P,{className:"flex min-w-0 flex-col gap-4",children:[e.jsx(B,{crumbs:[e.jsx(w,{to:"/$owner",params:{owner:n},search:{section:"automation"},className:I,children:"Automations"},"automations")],current:"New automation"}),e.jsx("div",{className:"flex flex-wrap items-center justify-between gap-3",children:e.jsx("div",{className:"flex min-w-0 items-center gap-2",children:e.jsxs("h1",{className:"flex min-w-0 items-center gap-2 truncate font-display text-xl font-semibold",children:[e.jsx(R,{className:"h-4 w-4 shrink-0 text-muted-foreground","aria-hidden":!0}),"New automation"]})})}),e.jsx("p",{className:"text-sm text-muted-foreground",children:y}),m&&!t?.agent?e.jsxs("p",{className:"text-sm text-muted-foreground",children:[d.length===0?"This workspace has no agents yet. ":"Choose the agent that answers here, or ",e.jsx(w,{to:"/$owner/agents/new",params:{owner:n},search:t,className:"underline underline-offset-4",children:d.length===0?"Create an agent":"create an agent"})," ","and come back to finish this setup."]}):null,N?e.jsxs("div",{className:"space-y-3",children:[e.jsx(C,{className:"h-10 w-full"}),e.jsx(C,{className:"h-32 w-full"})]}):u&&t?.connection&&!a?e.jsx("p",{role:"alert",className:"text-sm text-destructive",children:"This connection is no longer available. Reopen setup from your conversation."}):e.jsx(F,{prefillAgentId:t?.agent,onCancel:_,initialTriggers:a,conversationSetup:m})]})})}function Z(){const{owner:n}=f.useParams(),t=f.useSearch();return e.jsx($,{owner:n,children:()=>e.jsx(J,{owner:n,prefilled:t})})}export{Z as component};
2
+ //# sourceMappingURL=new-BKrNkOQD.js.map
@@ -0,0 +1,2 @@
1
+ import{c as z,H as F,Z as L,r,j as e,$ as v,a0 as S,B as U,a1 as N,a2 as E}from"./index-DB2lVKuV.js";import{C as A,a as I,b as T,c as $}from"./card-C4oPCVh6.js";import{F as k}from"./full-page-spinner-C1clibUY.js";function c(l){return l.toLowerCase().replace(/[^a-z0-9]+/g,"-").replace(/^-+|-+$/g,"")}function q(){const l=z(),{session:u,isReady:d}=F(),{slug:n,name:i}=L.useSearch(),[m,y]=r.useState(i||n||""),[g,h]=r.useState(n||(i?c(i):"")),[b,C]=r.useState(!!n),[x,o]=r.useState(null),[f,p]=r.useState(!1),j=r.useRef(!1);if(r.useEffect(()=>{if(!d||u||j.current)return;j.current=!0;const a=new URL("/orgs/new",window.location.origin);n&&a.searchParams.set("slug",n),i&&a.searchParams.set("name",i);const s=new URL("/auth/login",window.location.origin);s.searchParams.set("callbackUrl",`${a.pathname}${a.search}`),window.location.assign(s.toString())},[d,u,n,i]),!d||!u)return e.jsx(k,{});const P=a=>{const s=E(a);if(s.kind==="cross-host"){window.location.assign(s.href);return}l({to:s.to})},R=async a=>{a.preventDefault(),o(null);const s=m.trim(),w=(g.trim()||c(s)).trim();if(!s){o("Name is required");return}if(!w){o("Slug is required");return}p(!0);try{const t=await N.create({name:s,slug:w});if(t.error){o(t.error.message||"Failed to create organization");return}t.data&&(await N.setActive({organizationId:t.data.id}),P(t.data.slug))}catch(t){o(t instanceof Error?t.message:"An error occurred")}finally{p(!1)}};return e.jsx("div",{className:"container mx-auto max-w-md px-4 py-10",children:e.jsxs(A,{children:[e.jsx(I,{children:e.jsx(T,{children:"Create organization"})}),e.jsx($,{children:e.jsxs("form",{onSubmit:R,className:"space-y-4",children:[x&&e.jsx("div",{className:"rounded-md bg-destructive/10 px-3 py-2 text-sm text-destructive",children:x}),e.jsxs("div",{className:"space-y-2",children:[e.jsxs(v,{htmlFor:"org-name",children:["Name",e.jsx("span",{className:"ml-1 text-destructive",children:"*"})]}),e.jsx(S,{id:"org-name",value:m,onChange:a=>{y(a.target.value),b||h(c(a.target.value))},placeholder:"Acme Inc.",autoFocus:!0})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsxs(v,{htmlFor:"org-slug",children:["Slug",e.jsx("span",{className:"ml-1 text-destructive",children:"*"})]}),e.jsx(S,{id:"org-slug",value:g,onChange:a=>{C(!0),h(c(a.target.value))},placeholder:"acme"}),e.jsxs("p",{className:"text-xs text-muted-foreground",children:["Used in URLs and as the org id in ",e.jsx("code",{children:"lobu.toml"}),". Lowercase letters, numbers, and hyphens."]})]}),e.jsx("div",{className:"flex justify-end",children:e.jsx(U,{type:"submit",disabled:f,children:f?"Creating…":"Create organization"})})]})})]})})}export{q as component};
2
+ //# sourceMappingURL=new-BetiMuDq.js.map
@@ -0,0 +1,2 @@
1
+ import{dE as s,P as n,c as r,j as t,aC as p,aD as i}from"./index-DB2lVKuV.js";import{E as m}from"./entity-type-page-CGBAP2wt.js";import"./event-kind-options-fHAIXu24.js";import"./code-editor-CTdKUDPY.js";import"./index-Vcq4gwWv.js";function y(){const{owner:e}=s.useParams(),{orgContext:a}=n(),o=r();return t.jsx(p,{className:"gap-4 pt-2.5 pb-8",children:t.jsx(i,{children:t.jsx(m,{entityType:null,orgContext:a,onClose:()=>{o({to:"/$owner",params:{owner:e},search:{layout:"graph"}})}})})})}export{y as component};
2
+ //# sourceMappingURL=new-dk_-eXqU.js.map
@@ -0,0 +1,2 @@
1
+ import{im as o,c as p,z as x,H as h,o as b,t as w,j as a,aC as L,aD as j,dH as A,bl as f,dI as C,L as N,dJ as S,dL as k,bk as y,cg as E}from"./index-DB2lVKuV.js";import{A as I}from"./agent-editor-form-BrhQbHZg.js";import"./definition-comparison-C2mPfIMD.js";import"./json-diff-Ce6YAXzY.js";import"./code-editor-CTdKUDPY.js";import"./index-Vcq4gwWv.js";import"./schema-value-DDNHANGs.js";import"./model-selector-CjkBPpjN.js";function M(){const{owner:e}=o.useParams(),t=o.useSearch(),r=p(),i=x(),{isAuthenticated:c}=h(),{isMember:m,isLoading:g}=b(),n=c&&m,{data:d=[],isLoading:u}=w({enabled:n});return a.jsx(L,{className:"gap-3 pt-2.5 pb-8",children:a.jsxs(j,{className:"flex flex-1 flex-col gap-6",children:[a.jsx(A,{breadcrumb:a.jsx(C,{crumbs:[a.jsx(N,{to:"/$owner",params:{owner:e},search:{section:"agent"},className:S,children:"Agents"},"agents")]}),icon:a.jsx(f.agents.icon,{className:"h-6 w-6"}),title:"Build a managed agent",caption:"Create an agent that Lobu runs and manages for this workspace."}),g||n&&u?a.jsx(k,{rows:1}):n?a.jsx(I,{mode:{kind:"create"},existingAgentIds:d.map(s=>s.agentId),onCreated:async s=>{const l=["agents",e];if(await i.refetchQueries({queryKey:l,exact:!0}),t.platform&&t.listen){await r({to:"/$owner/automations/new",params:{owner:e},search:{...t,agent:s}});return}await r({to:"/$owner/agents/$agentId",params:{owner:e,agentId:s}})}}):a.jsx(y,{icon:E,title:"Workspace membership required",description:"Only workspace members can build managed agents."})]})})}export{M as component};
2
+ //# sourceMappingURL=new-efN--4Wx.js.map
@@ -0,0 +1,2 @@
1
+ import{z as xe,r as y,bV as qe,bW as Ze,bX as es,bY as ss,K as Ne,j as e,bZ as Y,B as N,b_ as ts,bk as ns,b$ as as,c0 as is,c1 as os,c2 as rs,c3 as cs,c4 as ls,c5 as ds,c6 as us,E as ke,bH as oe,c7 as ms,c8 as hs,c9 as ps,ca as he,cb as gs,cc as xs,c as fs,ae as Ge,P as ys,cd as js,ce as ie,cf as vs,$ as Ce,a0 as _e,cg as bs,ch as Ns,ci as ks,an as Se,cj as Cs,n as z,a1 as ue,ck as _s,cl as Ae,cm as we,cn as Ss,a2 as As,co as Oe,aC as ws,aD as Os,S as zs,i as Ps,cp as $s}from"./index-DB2lVKuV.js";import{P as pe,a as Ke,A as Es}from"./agent-permissions-matrix-jQJjSa9i.js";import{C as ze,a as Pe,b as $e,c as Ee}from"./card-C4oPCVh6.js";const Re=["auto","approval","deny"],Te=["approval","deny"],Rs=280,Ts={matched_rule:"Matching policy rules apply.",guardrail:"A guardrail makes the result stricter.",default_auto:"No rule matches; the action runs automatically.",unresolved_principal:"The requesting agent or Automation could not be identified.",parent_approval:"Approval is inherited from the parent action.",unavailable_operation:"This action is unavailable on the connection."},Me={read:"Reads",write:"Writes",destructive:"Destructive writes",non_destructive:"Non-destructive writes",unknown:"Unclassified writes"};function ge(s){return{operation_key:s.operation_key??null,connector_key:s.connector_key??null,connection_id:s.connection_id??null,operation_category:s.operation_category??null}}const me=s=>JSON.stringify([ge(s),s.kind??"grant"]),F=s=>s.kind==="guardrail";function Fe(s){return{...F(s)?{kind:"guardrail"}:{},...s.note?{note:s.note}:{}}}const Ie=s=>({...s,effect:s.effects.execute??"approval",note:s.note??void 0});function R({label:s,value:n,onChange:i,children:l,disabled:p}){return e.jsxs("label",{className:"flex min-w-0 flex-col gap-1 text-sm",children:[e.jsx("span",{className:"text-muted-foreground",children:s}),e.jsx("select",{"aria-label":s,value:n,onChange:r=>i(r.target.value),disabled:p,className:"h-9 w-full rounded-lg border bg-background px-2 text-foreground",children:l})]})}function Fs(s,n){const i=n.connections?.find(l=>l.id===s.connection_id);return s.connection_id?`Connection: ${i?.display_name||i?.connector_key||"Unavailable"} (#${s.connection_id})`:s.connector_key?`Connector: ${n.connectors?.find(l=>l.key===s.connector_key)?.name||s.connector_key}`:"All connectors"}function Is(s,n){return s.operation_key?n.connector_operations.find(i=>i.operation_key===s.operation_key)?.name||s.operation_key:s.operation_category?Me[s.operation_category]:"All actions"}function Ue(s,n){return`${Fs(s,n)} · ${Is(s,n)}`}function De(s,n){return`${Ue(s,n)}${F(s)?" · Guardrail":""}`}function Le(s){return s.connection_id?`connection:${s.connection_id}`:s.connector_key?`connector:${s.connector_key}`:"all"}function We({catalog:s}){return e.jsxs(e.Fragment,{children:[e.jsx("option",{value:"all",children:"All connectors"}),e.jsx("optgroup",{label:"Connectors",children:s.connectors?.map(n=>e.jsx("option",{value:`connector:${n.key}`,children:n.name},n.key))}),e.jsx("optgroup",{label:"Connections",children:s.connections?.map(n=>e.jsxs("option",{value:`connection:${n.id}`,children:[n.display_name||n.connector_key," (#",n.id,")"]},n.id))})]})}function Ds({label:s,ariaLabel:n,disabled:i,onRemove:l}){const[p,r]=y.useState(!1);return p?e.jsxs("div",{className:"flex gap-1",children:[e.jsx(N,{type:"button",variant:"destructive",size:"sm",disabled:i,"aria-label":"Confirm removal",onClick:async()=>{await l()&&r(!1)},children:"Confirm"}),e.jsx(N,{type:"button",variant:"ghost",size:"sm",disabled:i,onClick:()=>r(!1),children:"Cancel"})]}):e.jsx(N,{type:"button",variant:"ghost",size:"sm",disabled:i,"aria-label":n,onClick:()=>r(!0),children:s})}function Ls({owner:s,connector:n,connection:i,agent:l}){const p=xe(),[r,j]=y.useState(l??""),k=qe(s),d=k.data,u=d?.agents.some(t=>t.id===r)?r:"",h=Ze(s,u),a=es(s,!u),[P,C]=y.useState(i?`connection:${i}`:n?`connector:${n}`:"all"),[Q,J]=y.useState(P),[I,D]=y.useState(!1),[S,L]=y.useState(""),[w,q]=y.useState("all"),[X,T]=y.useState("approval"),[G,A]=y.useState("grant"),[W,K]=y.useState(""),[g,M]=y.useState(!1),[Z,$]=y.useState(null),[ee,se]=y.useState(i?String(i):""),[U,te]=y.useState(""),x=d?.connections?.some(t=>String(t.id)===ee)?ee:"",o=ss(s,x?Number(x):void 0,U,u||void 0);async function b(t,f){M(!0),$(null);try{if(u){const c={resource_class:"connector_action",...ge(t)};f?await os(s,u,{...c,effects:{execute:f}}):await rs(s,u,c)||$("This rule was already removed. The list has been refreshed.")}else{const c=a.data;if(!c)return;const B=c.rules.filter(Xe=>me(Xe)!==me(t));f&&B.push({...ge(t),effect:f,...Fe(t)});const de=await cs(s,{revision:c.revision,rules:B});p.setQueryData(ls(s),de)}return await ds(p),t}catch(c){c instanceof Ne&&c.status===409?($("Policies changed in another session. Review the refreshed rules before saving again."),await a.refetch()):$(c instanceof Error?c.message:"Could not save policy.")}finally{M(!1)}}const v=k.error||(u?h.error:a.error);if(v instanceof Ne&&v.status===403)return e.jsx("p",{role:"status",className:"text-sm text-muted-foreground",children:"Only organization owners and admins can manage policies."});if(v)return e.jsxs("p",{role:"alert",className:"text-sm text-destructive",children:["Could not load policies. ",String(v)]});if(!d||(u?!h.data:!a.data))return e.jsx(Y,{label:"policies",rows:2});const E=t=>t==="all"||d.connectors?.some(f=>`connector:${f.key}`===t)||d.connections?.some(f=>`connection:${f.id}`===t)?t:"all",m=E(P),_=E(Q),V=d.connections?.find(t=>`connection:${t.id}`===_),O=V?.connector_key??(_.startsWith("connector:")?_.slice(10):void 0),H=t=>_==="all"||Le(t)==="all"?!0:t.connection_id?V?t.connection_id===V.id:d.connections?.some(f=>f.id===t.connection_id&&f.connector_key===O):t.connector_key===O;function re(t){return u?t.principal_kind==="agent"&&t.principal_id===u:!t.principal_kind}const ne=m.startsWith("connector:")?m.slice(10):m.startsWith("connection:")?d.connections?.find(t=>t.id===Number(m.slice(11)))?.connector_key:void 0,ae=d.connector_operations.filter(t=>!ne||t.connector_key===ne),Ve=d.connections?.find(t=>t.id===Number(x))?.connector_key,He=d.connector_operations.filter(t=>t.connector_key===Ve),Ye=u?(h.data?.agent??[]).filter(t=>t.resource_class==="connector_action").map(Ie):a.data?.rules??[],ye=(h.data?.floor??[]).filter(t=>t.resource_class==="connector_action"&&H(t)).map(Ie),ce={connector_key:m.startsWith("connector:")?m.slice(10):m==="all"&&w==="specific"?ae.find(t=>t.operation_key===S)?.connector_key??null:null,connection_id:m.startsWith("connection:")?Number(m.slice(11)):null,operation_key:w==="specific"?S:null,operation_category:w.startsWith("category:")?w.slice(9):null,...u?{}:Fe({kind:G,note:W.trim()})},Je=F(ce)?Te:Re,je=F(ce)&&X==="auto"?"approval":X,le=Ye.filter(H);function ve(){C(_),q("all"),L(""),T("approval"),A("grant"),K(""),D(!0)}const be=(t,f=!1)=>e.jsx("div",{className:"divide-y rounded-lg border",children:t.map(c=>{const B=!f&&re(c);return e.jsxs(Ke,{controls:e.jsxs(e.Fragment,{children:[e.jsx(pe,{options:F(c)?Te:Re,value:c.effect,floor:"auto",compact:!0,disabled:g||!B,ariaLabel:`Policy for ${De(c,d)}`,onChange:de=>void b(c,de)}),B&&e.jsx(Ds,{label:"Remove",disabled:g,ariaLabel:`Remove rule: ${De(c,d)}`,onRemove:()=>b(c)})]}),children:[e.jsx("p",{className:"text-sm break-words",children:Ue(c,d)}),(F(c)||c.note)&&e.jsx("p",{className:"text-xs text-muted-foreground break-words",children:[F(c)?"Guardrail":null,c.note].filter(Boolean).join(" · ")}),!B&&e.jsx("p",{className:"text-xs text-muted-foreground",children:c.principal_kind==="agent"&&!c.principal_id?"All agents":"Inherited restriction"})]},JSON.stringify([c.principal_kind,c.principal_id,me(c)]))})});return e.jsxs("div",{className:"space-y-4",children:[(_!==Q||u!==r)&&e.jsx("p",{role:"status",className:"text-sm text-muted-foreground",children:"The requested scope is unavailable. Showing organization rules; install the connector or choose an available scope."}),e.jsxs("div",{className:"space-y-1 text-sm text-muted-foreground",children:[e.jsx("p",{children:"Auto runs immediately. Ask waits for human approval. Block prevents execution and hides the action from agents. Authentication and guardrails still apply."}),e.jsxs("details",{className:"space-y-2",children:[e.jsx("summary",{className:"cursor-pointer text-sm font-medium text-foreground",children:"How rules combine"}),e.jsx("p",{children:"A rule overrides another when it is narrower in target or actions and at least as narrow in the other. When rules are narrower in different ways, or use different categories, the stricter choice wins: Block, then Ask, then Auto. With no matching rule, the result is Auto. Impact categories apply only to writes."}),e.jsx("p",{children:"A connection-wide Auto does not override an organization-wide destructive Block. Add a destructive rule for that connection to make an exception."}),e.jsx("p",{children:"A guardrail applies after the narrowest rule and can only make the result stricter: Ask or Block. Use one when a narrower Auto rule must never override a broad rule. Its note explains held and blocked runs."}),e.jsx("p",{children:"Agents and their Automations can only tighten organization policy. Internal browser steps inherit the parent approval; an explicit browser Block still wins."})]})]}),e.jsxs(R,{label:"Policy owner",value:u,onChange:j,disabled:g,children:[e.jsx("option",{value:"",children:"Organization"}),d.agents.map(t=>e.jsxs("option",{value:t.id,children:["Agent: ",t.name]},t.id))]}),u&&e.jsx("p",{className:"text-sm text-muted-foreground",children:"Auto adds no restriction for this agent. It inherits organization policy and cannot bypass Ask or Block."}),e.jsx("p",{className:"text-sm text-muted-foreground",children:u?"Without a matching restriction, this agent inherits organization policy.":"Without a matching rule, actions run automatically (Auto). Add an Ask or Block rule, or a guardrail, to hold them."}),e.jsx(R,{label:"Show rules for",value:_,onChange:J,disabled:g,children:e.jsx(We,{catalog:d})}),u&&ye.length>0&&e.jsxs("div",{className:"space-y-2",children:[e.jsx("h3",{className:"text-sm font-medium",children:"Inherited organization rules"}),be(ye,!0)]}),e.jsxs("div",{className:"space-y-2",children:[e.jsxs("div",{className:"flex items-center justify-between gap-3",children:[e.jsx("h3",{className:"text-sm font-medium",children:u?"Saved restrictions":"Saved rules"}),!I&&le.length>0&&e.jsx(N,{variant:"outline",size:"sm",disabled:g,onClick:ve,children:"Add rule"})]}),I&&e.jsxs("form",{className:"space-y-3 border-t pt-4",onSubmit:t=>{t.preventDefault(),!g&&(w!=="specific"||S)&&b(ce,je).then(f=>{f&&(D(!1),J(Le(f)))})},children:[e.jsx("h3",{className:"text-sm font-medium",children:"Add rule"}),e.jsxs("div",{className:"grid gap-3 sm:grid-cols-2",children:[e.jsx(R,{label:"Applies to",value:m,onChange:t=>{C(t),q("all"),L("")},disabled:g,children:e.jsx(We,{catalog:d})}),e.jsxs(R,{label:"Actions",value:w,onChange:q,disabled:g,children:[e.jsx("option",{value:"all",children:"All actions"}),e.jsx("optgroup",{label:"Categories",children:d.operation_categories?.map(t=>e.jsx("option",{value:`category:${t}`,children:Me[t]},t))}),e.jsx("option",{value:"specific",children:"Specific action"})]})]}),w==="specific"&&e.jsxs(R,{label:"Specific action",value:S,onChange:L,disabled:g,children:[e.jsx("option",{value:"",children:"Choose action"}),ae.map(t=>e.jsxs("option",{value:t.operation_key,children:[t.connector_name,": ",t.name]},t.operation_key))]}),!u&&e.jsxs("div",{className:"grid gap-3 sm:grid-cols-2",children:[e.jsxs(R,{label:"Rule type",value:G,onChange:t=>A(t),disabled:g,children:[e.jsx("option",{value:"grant",children:"Rule"}),e.jsx("option",{value:"guardrail",children:"Guardrail (only tightens)"})]}),e.jsxs("label",{className:"flex min-w-0 flex-col gap-1 text-sm",children:[e.jsx("span",{className:"text-muted-foreground",children:"Note"}),e.jsx("input",{value:W,maxLength:Rs,onChange:t=>K(t.target.value),disabled:g,placeholder:"Shown when this rule holds or blocks a run",className:"h-9 w-full rounded-lg border bg-background px-2 text-foreground"})]})]}),e.jsxs("div",{className:"flex flex-wrap items-center justify-between gap-3",children:[e.jsx(pe,{options:Je,value:je,floor:"auto",compact:!0,disabled:g,ariaLabel:"New rule decision",onChange:T}),e.jsx(ts,{onCancel:()=>D(!1),cancelDisabled:g,children:e.jsx(N,{type:"submit",disabled:g||w==="specific"&&!S,children:g?"Saving…":"Save rule"})})]}),e.jsx("p",{className:"text-xs text-muted-foreground",children:"Saving an existing scope replaces its decision. Removing a rule reveals the next matching rule."})]}),le.length?be(le):!I&&e.jsx(ns,{icon:as,title:"No saved rules in this scope",description:"Add a rule for all actions, a category, or a specific action.",actionLabel:"Add rule",onAction:ve})]}),Z&&e.jsx("p",{role:"alert",className:"rounded-md bg-destructive/10 px-3 py-2 text-sm text-destructive",children:Z}),e.jsxs("details",{className:"space-y-3 border-t pt-4",children:[e.jsx("summary",{className:"cursor-pointer text-sm font-medium",children:"Check an action"}),e.jsxs("div",{className:"grid gap-3 sm:grid-cols-2",children:[e.jsxs(R,{label:"Check connection",value:x,onChange:t=>{se(t),te("")},children:[e.jsx("option",{value:"",children:"Choose connection"}),d.connections?.map(t=>e.jsxs("option",{value:String(t.id),children:[t.display_name||t.connector_key," (#",t.id,")"]},t.id))]}),e.jsxs(R,{label:"Check action",value:U,onChange:te,disabled:!x,children:[e.jsx("option",{value:"",children:"Choose action"}),He.map(t=>e.jsx("option",{value:t.operation_key.slice(t.connector_key.length+2),children:t.name},t.operation_key))]})]}),o.error?e.jsxs("p",{role:"alert",className:"text-sm text-destructive",children:["Could not check policy. ",String(o.error)]}):e.jsx("p",{"aria-live":"polite",className:"text-sm",children:U?o.isPending?"Checking…":o.data?e.jsxs(e.Fragment,{children:[e.jsx("strong",{children:is[o.data.effect]})," ·"," ",Ts[o.data.reason]??"The server evaluated this action.",o.data.rule_ids.length>0?` · Rules ${o.data.rule_ids.map(t=>`#${t}`).join(", ")}`:""]}):"":""})]})]})}const Ws=[{action:"create_type",label:"Create entity types",description:"Add a new type and its initial fields."},{action:"update_type",label:"Edit entity types",description:"Change fields, write rules, event kinds, or type metadata."},{action:"delete_type",label:"Delete entity types",description:"Remove an entity-type definition."}],Bs=[{action:"create_relationship_type",label:"Create relationship types",description:"Add a new kind of link between entity types."},{action:"update_relationship_type",label:"Edit relationship types",description:"Change a definition, or which types it may connect."},{action:"delete_relationship_type",label:"Delete relationship types",description:"Remove a relationship-type definition."}];function fe(s){return s.resource_class==="entity_schema"&&s.principal_kind===null&&s.entity_type_slug===null&&s.operation_key===null&&s.target_agent_id===null}function Qs(s){return s.agent.find(fe)}function qs(s,n){return{...s,agent:[...s.agent.filter(i=>!fe(i)),n]}}function Gs(s){return{...s,agent:s.agent.filter(n=>!fe(n))}}function Ks({label:s,description:n,action:i,value:l,pending:p,onChange:r}){return e.jsxs(Ke,{controls:e.jsx(pe,{options:xs("entity_schema",i),value:l,floor:"auto",disabled:p,compact:!0,ariaLabel:s,onChange:r}),children:[e.jsx("p",{children:s}),e.jsx("p",{className:"text-xs leading-5 text-muted-foreground",children:n})]})}function Be({title:s,actions:n,effects:i,pending:l,onChange:p}){return e.jsxs("section",{className:"space-y-2",children:[e.jsx("h3",{className:"text-sm font-medium",children:s}),e.jsx("div",{className:"divide-y overflow-hidden rounded-lg border",children:n.map(({action:r,label:j,description:k})=>e.jsx(Ks,{action:r,label:j,description:k,value:i[r]??he.entity_schema[r]??"deny",pending:l,onChange:d=>p(r,d)},r))})]})}function Ms({owner:s}){const n=xe(),i=us(s),l=qe(s),p=ke({mutationFn:h=>ms(s,{resource_class:"entity_schema",effects:h}),onSuccess:h=>{n.setQueryData(i,a=>a&&qs(a,h)),n.invalidateQueries({queryKey:i})},onError:h=>{oe.error(h instanceof Error?h.message:"Failed to save schema policy")}}),r=ke({mutationFn:()=>hs(s,{resource_class:"entity_schema"}),onSuccess:()=>{n.setQueryData(i,h=>h&&Gs(h)),n.invalidateQueries({queryKey:i})},onError:h=>{oe.error(h instanceof Error?h.message:"Failed to reset schema policy")}});if(l.isLoading)return e.jsx(Y,{label:"schema policy",variant:"cards",cards:1});if(l.isError||!l.data)return e.jsx(ps,{label:"schema policy"});const j=Qs(l.data),k=j?.effects??he.entity_schema,d=p.isPending||r.isPending,u=(h,a)=>{p.mutate({...j?.effects??he.entity_schema,[h]:a})};return e.jsxs("div",{className:"space-y-4",children:[e.jsxs("div",{className:"flex flex-wrap items-center justify-between gap-3",children:[e.jsx("p",{className:"text-xs text-muted-foreground",children:j?"Custom policy":"Workspace defaults"}),j?e.jsxs(N,{type:"button",variant:"outline",size:"sm",disabled:d,onClick:()=>r.mutate(),children:[e.jsx(gs,{className:"mr-1.5 h-3.5 w-3.5"}),"Remove custom policy"]}):null]}),e.jsxs("div",{className:"space-y-4",children:[e.jsx(Be,{title:"Entity types",actions:Ws,effects:k,pending:d,onChange:u}),e.jsx(Be,{title:"Relationship types",actions:Bs,effects:k,pending:d,onChange:u})]})]})}function Qe(s){return s.toLowerCase().replace(/[^a-z0-9]+/g,"-").replace(/^-+|-+$/g,"")}function Us(s,n,i){const l=s.split("/");return l[1]===n?(l[1]=i,l.join("/")||"/"):`/${i}`}function Vs({section:s}){return s==="policies"?e.jsx(Y,{label:"policies",rows:2}):s==="governance"?e.jsxs("div",{className:"space-y-6",children:[e.jsxs("section",{className:"space-y-4",children:[e.jsx("h2",{className:"text-sm font-medium",children:"Agent write defaults"}),e.jsx(Y,{label:"agent write defaults",variant:"table",rows:3})]}),e.jsxs("section",{className:"space-y-4",children:[e.jsx("h2",{className:"text-sm font-medium",children:"Schema governance"}),e.jsx(Y,{label:"schema governance",rows:3})]})]}):e.jsxs("div",{role:"status","aria-label":"Loading general settings","aria-busy":"true",className:"space-y-6",children:[e.jsxs("section",{className:"space-y-4",children:[e.jsx("h2",{className:"text-base font-semibold leading-none",children:"Identity"}),e.jsxs("div",{"aria-hidden":"true",className:"space-y-4",children:[["name","slug"].map(n=>e.jsxs("div",{className:"space-y-1.5",children:[e.jsx(z,{className:"h-3.5 w-12 rounded-none"}),e.jsx("div",{className:"flex h-9 items-center border border-input bg-background px-3",children:e.jsx(z,{className:"h-4 w-32 rounded-none"})})]},n)),e.jsx(z,{className:"h-3 w-4/5 rounded-none"})]})]}),e.jsxs("section",{className:"space-y-4",children:[e.jsxs("div",{children:[e.jsx("h2",{className:"text-base font-semibold leading-none",children:"Workspace visibility"}),e.jsx("p",{className:"mt-1 text-sm text-muted-foreground",children:"Choose who can browse this workspace and its public pages."})]}),e.jsx("div",{"aria-hidden":"true",className:"grid gap-2 sm:grid-cols-2",children:["private","public"].map(n=>e.jsxs("div",{className:"flex items-start gap-3 rounded-lg border p-3",children:[e.jsx(z,{className:"mt-0.5 h-4 w-4 shrink-0 rounded-none"}),e.jsxs("div",{className:"flex-1 space-y-2",children:[e.jsx(z,{className:"h-4 w-16 rounded-none"}),e.jsx(z,{className:"h-3 w-full rounded-none"}),e.jsx(z,{className:"h-3 w-2/3 rounded-none"})]})]},n))})]}),e.jsxs("div",{"aria-hidden":"true",className:"flex justify-end gap-2",children:[e.jsx(z,{className:"h-9 w-20 rounded-none"}),e.jsx(z,{className:"h-9 w-28 rounded-none"})]})]})}function Hs({owner:s,section:n="general",connector:i,connection:l,agent:p}){const r=fs(),j=xe(),{data:k,error:d}=Ge(),{activeOrg:u,urlOrgSlug:h}=ys(),a=(k??[]).find(o=>o.slug===s&&o.is_member)??null,P=a?.id??s,C=js(P,{name:a?.name??"",slug:a?.slug??"",visibility:a?.visibility??"private"}),[Q,J]=C.field("name"),[I,D]=C.field("slug"),[S,L]=C.field("visibility"),[w,q]=ie(P,!!a),[X,T]=ie(P,!1),[G,A]=ie(P,null),[W,K]=y.useState(!1),[g,M]=y.useState(!1),[Z,$]=ie(P,!1);if(vs(d)&&k===void 0)return e.jsxs(ze,{role:"alert",children:[e.jsx(Pe,{children:e.jsx($e,{children:"Couldn't load organizations"})}),e.jsx(Ee,{children:e.jsx("p",{className:"text-sm text-muted-foreground",children:"Please try again in a moment."})})]});if(k===void 0)return e.jsx(Vs,{section:n});if(!a)return e.jsxs(ze,{children:[e.jsx(Pe,{children:e.jsx($e,{children:"Organization not found"})}),e.jsx(Ee,{children:e.jsxs("p",{className:"text-sm text-muted-foreground",children:["You aren't a member of an organization at"," ",e.jsx("span",{className:"font-mono",children:s}),", or it has been deleted."]})})]});if(n==="policies")return e.jsx("div",{className:"space-y-6",children:e.jsxs("section",{id:"policies",className:"scroll-mt-6 space-y-4",children:[e.jsx("div",{className:"space-y-1",children:e.jsx("p",{className:"text-sm text-muted-foreground",children:"Control connector actions across the organization. Changes to existing rules save automatically."})}),e.jsx(Ls,{owner:s,connector:i,connection:l,agent:p},`${s}:${p??""}:${i??""}:${l??""}`)]})});if(n==="governance")return e.jsxs("div",{className:"space-y-6",children:[e.jsxs("section",{className:"space-y-4",children:[e.jsxs("div",{className:"space-y-1",children:[e.jsx("h2",{className:"text-sm font-medium",children:"Agent write defaults"}),e.jsx("p",{className:"text-sm text-muted-foreground",children:"Set the defaults agents inherit for entities and agents. Changes save automatically; agents can only tighten them."})]}),e.jsx(Es,{owner:s,variant:"org-floor"})]}),e.jsxs("section",{className:"space-y-4",children:[e.jsxs("div",{className:"space-y-1",children:[e.jsx("h2",{className:"text-sm font-medium",children:"Schema governance"}),e.jsx("p",{className:"text-sm text-muted-foreground",children:"Control structural changes by agents and connected AI clients. Changes save automatically."})]}),e.jsx(Ms,{owner:s})]})]});const ee=o=>{const b=As(o);if(b.kind==="cross-host"){window.location.assign(b.href);return}r({to:b.to})},se=o=>{if(o==="public"&&a.visibility!=="public"){T(!0);return}L(o),T(!1)},U=async()=>{if(!C.canSubmit)return;const o=Q.trim();if(!o){A("Name is required");return}const b=I.trim()||Qe(o);if(!b){A("Slug is required");return}K(!0),A(null);try{const v=o!==a.name||b!==a.slug,E=S!==a.visibility;let m=a.slug;if(v){const O=await ue.update({organizationId:a.id,data:{name:o,slug:b}});if(O.error){A(O.error.message||"Failed to update organization");return}m=O.data?.slug??b}E&&(m=(await _s(m,S)).slug),(v||E)&&(C.accept(C.values,{name:o,slug:m,visibility:S}),await j.invalidateQueries({queryKey:["organizations"]}),oe.success("Organization updated"));const _=u?.id===a.id||h===a.slug,V=m!==a.slug;if(_&&V){const O=Ae(),H=we();if(O===a.slug&&H){const ne=Ss(window.location.pathname,a.slug)||"/",ae=`${window.location.protocol}//${m}.${H}${ne}${window.location.search}${window.location.hash}`;window.location.assign(ae);return}const re=Us(window.location.pathname,a.slug,m);r({to:`${re}${window.location.search}${window.location.hash}`});return}}catch(v){A(v instanceof Error?v.message:"Failed to update organization")}finally{K(!1)}},te=async()=>{M(!0),A(null);try{const o=await ue.delete({organizationId:a.id});if(o.error){A(o.error.message||"Failed to delete organization");return}await j.invalidateQueries({queryKey:["organizations"]}),oe.success("Organization deleted");const v=(k??[]).filter(m=>m.is_member).find(m=>m.id!==a.id)??null,E=u?.id===a.id||h===a.slug;if(E&&v){await ue.setActive({organizationId:v.id}),ee(v.slug);return}if(E){const m=Ae(),_=we();if(m===a.slug&&_){window.location.assign(`${window.location.protocol}//app.${_}/`);return}r({to:"/"});return}r({to:"/"})}catch(o){A(o instanceof Error?o.message:"Failed to delete organization")}finally{M(!1),$(!1)}},x=W||g;return e.jsxs("div",{className:"space-y-6",children:[e.jsxs("section",{className:"space-y-4",children:[e.jsx("h2",{className:"text-base font-semibold leading-none",children:"Identity"}),e.jsxs("div",{className:"space-y-1.5",children:[e.jsx(Ce,{htmlFor:"org-name",children:"Name"}),e.jsx(_e,{id:"org-name",value:Q,onChange:o=>{J(o.target.value),w||D(Qe(o.target.value))},placeholder:"e.g. My Team",disabled:x})]}),e.jsxs("div",{className:"space-y-1.5",children:[e.jsx(Ce,{htmlFor:"org-slug",children:"Slug"}),e.jsx(_e,{id:"org-slug",value:I,onChange:o=>{q(!0),D(o.target.value)},placeholder:"e.g. my-team",disabled:x}),e.jsxs("p",{className:"text-xs text-muted-foreground",children:["Changing the slug rewrites this workspace's URL. Existing links to"," ",e.jsxs("span",{className:"font-mono",children:["/",a.slug]})," redirect for a grace period."]})]})]}),e.jsxs("section",{className:"space-y-4",children:[e.jsxs("div",{children:[e.jsx("h2",{className:"text-base font-semibold leading-none",children:"Workspace visibility"}),e.jsx("p",{className:"mt-1 text-sm text-muted-foreground",children:"Choose who can browse this workspace and its public pages."})]}),e.jsxs("div",{className:"grid gap-2 sm:grid-cols-2",children:[e.jsxs("button",{type:"button",onClick:()=>se("private"),disabled:x,className:`flex items-start gap-3 rounded-lg border p-3 text-left transition-colors ${S==="private"?"border-primary bg-primary/5":"border-border hover:bg-muted/40"}`,children:[e.jsx(bs,{className:"mt-0.5 h-4 w-4 shrink-0"}),e.jsxs("div",{children:[e.jsx("div",{className:"text-sm font-medium",children:"Private"}),e.jsx("p",{className:"text-xs text-muted-foreground",children:"Only members can access this workspace."})]})]}),e.jsxs("button",{type:"button",onClick:()=>se("public"),disabled:x,className:`flex items-start gap-3 rounded-lg border p-3 text-left transition-colors ${S==="public"?"border-primary bg-primary/5":"border-border hover:bg-muted/40"}`,children:[e.jsx(Ns,{className:"mt-0.5 h-4 w-4 shrink-0"}),e.jsxs("div",{children:[e.jsx("div",{className:"text-sm font-medium",children:"Public"}),e.jsx("p",{className:"text-xs text-muted-foreground",children:"Anyone can browse public pages for this workspace."})]})]})]}),X&&e.jsxs("div",{className:"rounded-md border border-amber-500/30 bg-amber-500/10 px-3 py-2 text-sm",children:[e.jsx("p",{className:"text-foreground",children:"Make this workspace public? Catalog-style content may become visible outside the membership."}),e.jsxs("div",{className:"mt-2 flex gap-2",children:[e.jsx(N,{type:"button",size:"sm",onClick:()=>{L("public"),T(!1)},disabled:x,children:"Confirm public"}),e.jsx(N,{type:"button",size:"sm",variant:"ghost",onClick:()=>T(!1),disabled:x,children:"Cancel"})]})]})]}),G&&e.jsx("div",{className:"rounded-md bg-destructive/10 px-3 py-2 text-sm text-destructive",children:G}),e.jsx(ks,{visible:C.hasConflict,onReload:C.reset}),e.jsxs("div",{className:"flex justify-end gap-2",children:[e.jsx(N,{variant:"outline",onClick:()=>void r({to:`/${s}`}),disabled:x,children:"Cancel"}),e.jsxs(N,{onClick:U,disabled:x||!C.canSubmit,children:[W?e.jsx(Se,{size:"lg",className:"mr-1.5"}):null,W?"Saving...":"Save changes"]})]}),e.jsxs("div",{className:"rounded-lg border border-destructive/30 bg-destructive/5 p-4",children:[e.jsx("p",{className:"text-sm font-medium",children:a.is_personal?"Personal workspace":"Delete this organization"}),e.jsx("p",{className:"mt-1 text-xs text-muted-foreground",children:a.is_personal?"Your personal workspace can't be deleted — your devices and personal connections are bound to it.":"Permanently removes the organization and all members' workspace access. This cannot be undone."}),!a.is_personal&&e.jsx("div",{className:"mt-3",children:Z?e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsxs(N,{variant:"destructive",size:"sm",onClick:te,disabled:x,children:[g?e.jsx(Se,{className:"mr-1.5"}):null,"Confirm delete"]}),e.jsx(N,{variant:"ghost",size:"sm",onClick:()=>$(!1),disabled:x,children:"Cancel"})]}):e.jsxs(N,{variant:"outline",size:"sm",className:"text-destructive hover:text-destructive",onClick:()=>$(!0),disabled:x,children:[e.jsx(Cs,{className:"mr-1.5 h-3.5 w-3.5"}),"Delete organization"]})})]})]})}function Zs(){const{owner:s}=Oe.useParams(),n=Oe.useSearch(),i=n.section??"general",l={general:"General",policies:"Policies",governance:"Governance"}[i],{data:p}=Ge(),r=(p??[]).find(j=>j.slug===s&&j.is_member)?.name;return e.jsx(ws,{className:"pt-2.5 pb-8",children:e.jsxs(Os,{className:Ps("flex flex-1 flex-col gap-6",$s(i)),children:[e.jsxs("div",{className:"space-y-1",children:[e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(zs,{className:"h-7 w-7"}),e.jsx("h1",{className:"text-3xl font-semibold leading-tight",children:l})]}),r?e.jsx("p",{className:"text-base font-medium text-foreground",children:r}):null]}),e.jsx(Hs,{owner:s,...n,section:i})]})})}export{Zs as component};
2
+ //# sourceMappingURL=organization-C3rpwx_d.js.map
@@ -0,0 +1 @@
1
+ .pdf-page{--scale-round-x: 1px;--scale-round-y: 1px}.pdf-page .textLayer{color-scheme:only light;position:absolute;text-align:initial;inset:0;overflow:clip;opacity:1;line-height:1;letter-spacing:normal;word-spacing:normal;-webkit-text-size-adjust:none;text-size-adjust:none;forced-color-adjust:none;transform-origin:0 0;caret-color:CanvasText;z-index:0;--min-font-size: 1;--text-scale-factor: calc(var(--total-scale-factor) * var(--min-font-size));--min-font-size-inv: calc(1 / var(--min-font-size))}.pdf-page .textLayer :is(span,br){color:transparent;position:absolute;white-space:pre;cursor:text;transform-origin:0% 0%;-webkit-user-select:text;-moz-user-select:text;user-select:text}.pdf-page .textLayer>:not(.markedContent),.pdf-page .textLayer .markedContent span:not(.markedContent){z-index:1;--font-height: 0;font-size:calc(var(--text-scale-factor) * var(--font-height));--scale-x: 1;--rotate: 0deg;transform:rotate(var(--rotate)) scaleX(var(--scale-x)) scale(var(--min-font-size-inv))}.pdf-page .textLayer .markedContent{display:contents}.pdf-page .textLayer ::-moz-selection{background:#0000ff40;background:color-mix(in srgb,AccentColor,transparent 50%);color:transparent}.pdf-page .textLayer ::selection{background:#0000ff40;background:color-mix(in srgb,AccentColor,transparent 50%);color:transparent}.pdf-page .textLayer br::-moz-selection{background:transparent}.pdf-page .textLayer br::selection{background:transparent}.pdf-page .textLayer .endOfContent{display:block;position:absolute;inset:100% 0 0;z-index:0;cursor:default;-webkit-user-select:none;-moz-user-select:none;user-select:none}.pdf-page .textLayer.selecting .endOfContent{top:0}