@lobu/runtime-server 24.8.0 → 24.10.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/automations.json +2 -2
  2. package/dist/catalogs/connectors.json +99 -10
  3. package/dist/catalogs/skills.json +1 -1
  4. package/dist/component.json +1 -1
  5. package/dist/connectors/README.md +6 -2
  6. package/dist/connectors/github.ts +16 -3
  7. package/dist/connectors/market_quotes.ts +388 -91
  8. package/dist/connectors/postgres.ts +60 -38
  9. package/dist/connectors/whatsapp-web-adapter.js +41 -10
  10. package/dist/connectors/whatsapp-web-helpers.ts +12 -2
  11. package/dist/connectors/whatsapp_web.ts +18 -2
  12. package/dist/connectors/x-dm-adapter.js +55 -21
  13. package/dist/connectors/x.ts +1 -1
  14. package/dist/db/migrations/20261109010000_workspace_navigation.sql +14 -0
  15. package/dist/db/migrations/20261110010000_view_resources.sql +11 -0
  16. package/dist/db/migrations/20261112210000_instance_identity.sql +18 -0
  17. package/dist/dependencies.bun.lock +88 -86
  18. package/dist/embeddings-server.mjs +38 -5
  19. package/dist/owletto/dist/assets/_-CYvj1y65.js +3 -0
  20. package/dist/owletto/dist/assets/_-CeLTSYYY.js +2 -0
  21. package/dist/owletto/dist/assets/_agentId-BB5E-L6T.js +2 -0
  22. package/dist/owletto/dist/assets/_agentId-DN0EwMAC.js +2 -0
  23. package/dist/owletto/dist/assets/_automationId-DvUl9CSd.js +2 -0
  24. package/dist/owletto/dist/assets/_connectorKey._connectionId-CVKfL9AG.js +2 -0
  25. package/dist/owletto/dist/assets/_connectorKey.index-Cv6FzK1v.js +2 -0
  26. package/dist/owletto/dist/assets/{_conversationId-OJrZjd0o.js → _conversationId-CPpNySjO.js} +2 -2
  27. package/dist/owletto/dist/assets/_eventId-DZKicuq6.js +2 -0
  28. package/dist/owletto/dist/assets/_owner-Dauk3YuD.js +3 -0
  29. package/dist/owletto/dist/assets/_shape-cKrEID3T.js +2 -0
  30. package/dist/owletto/dist/assets/_slug-DJx_8fsV.js +2 -0
  31. package/dist/owletto/dist/assets/_viewKey-CPVzVKEf.js +2 -0
  32. package/dist/owletto/dist/assets/_viewKey-CW8gexOQ.js +2 -0
  33. package/dist/owletto/dist/assets/accept-invitation-Dwq1GAnG.js +2 -0
  34. package/dist/owletto/dist/assets/activity-route-location-C1jcXC7v.js +2 -0
  35. package/dist/owletto/dist/assets/activity-route-view-D78Wj0RH.js +2 -0
  36. package/dist/owletto/dist/assets/agent-connect-pages-DoI9UR0a.js +4 -0
  37. package/dist/owletto/dist/assets/{agent-editor-form-CDAHRNWl.js → agent-editor-form-DlavYg2q.js} +2 -2
  38. package/dist/owletto/dist/assets/{agent-loading-shells-BupiSjR-.js → agent-loading-shells-DYqQphN7.js} +2 -2
  39. package/dist/owletto/dist/assets/agent-permissions-matrix-C1L8IcYR.js +2 -0
  40. package/dist/owletto/dist/assets/{agent-skill-context-B0ZYVE3n.js → agent-skill-context-D1nMrVod.js} +2 -2
  41. package/dist/owletto/dist/assets/{agent-subpage-shell-ByU0xhXn.js → agent-subpage-shell-2w7vTeXw.js} +2 -2
  42. package/dist/owletto/dist/assets/{agent-thread-DiVKn1WX.js → agent-thread-BopD-2k1.js} +2 -2
  43. package/dist/owletto/dist/assets/{app._appId-BQWElSoP.js → app._appId-BXeFXW1w.js} +2 -2
  44. package/dist/owletto/dist/assets/{assist-composer-igTXq3DL.js → assist-composer-CL5x8pNt.js} +2 -2
  45. package/dist/owletto/dist/assets/automation-run-now-MtxUTfzd.js +2 -0
  46. package/dist/owletto/dist/assets/{callback-Dmaio9CX.js → callback-BgfwP1Eo.js} +2 -2
  47. package/dist/owletto/dist/assets/{card-rE4Ctuy6.js → card-DtLIFq7D.js} +2 -2
  48. package/dist/owletto/dist/assets/{claim-BN17CPYh.js → claim-CT3hYVMF.js} +2 -2
  49. package/dist/owletto/dist/assets/{client-activity-scopes-B7xVaUA-.js → client-activity-scopes-BPbRX-Pe.js} +2 -2
  50. package/dist/owletto/dist/assets/{client-rows-B3LULJxW.js → client-rows-vrNA6FLs.js} +2 -2
  51. package/dist/owletto/dist/assets/clients-xnzZeEdZ.js +2 -0
  52. package/dist/owletto/dist/assets/{code-editor-UppEMWpt.js → code-editor-mrKkAfcE.js} +2 -2
  53. package/dist/owletto/dist/assets/connect-NUCSay8X.js +2 -0
  54. package/dist/owletto/dist/assets/{connect-menu-B9u86bb2.js → connect-menu-C6iVtuSo.js} +2 -2
  55. package/dist/owletto/dist/assets/connect._clientId-Cp-d9Q5b.js +2 -0
  56. package/dist/owletto/dist/assets/{connected._clientId-CaF-ZWlZ.js → connected._clientId-ROfVgp9h.js} +2 -2
  57. package/dist/owletto/dist/assets/connection-BMz740Wi.js +2 -0
  58. package/dist/owletto/dist/assets/{connection-feed-detail-CJYqryAV.js → connection-feed-detail-0VAJiZTP.js} +2 -2
  59. package/dist/owletto/dist/assets/connector-page-shell-BFv21yuv.js +2 -0
  60. package/dist/owletto/dist/assets/{connector-provenance-CW4CXtCz.js → connector-provenance-b59RfBtk.js} +2 -2
  61. package/dist/owletto/dist/assets/connectors-nYS31lO2.js +2 -0
  62. package/dist/owletto/dist/assets/consent-cPRF9JQv.js +2 -0
  63. package/dist/owletto/dist/assets/{copy-button-1ALlvZU1.js → copy-button-C3wMMv63.js} +2 -2
  64. package/dist/owletto/dist/assets/{core.esm-6koO33th.js → core.esm-C9QlSrgK.js} +3 -3
  65. package/dist/owletto/dist/assets/{create-kUevP9Xx.js → create-ASRN3Obq.js} +2 -2
  66. package/dist/owletto/dist/assets/create-CBcodaSO.js +2 -0
  67. package/dist/owletto/dist/assets/create-CGOWfMk4.js +2 -0
  68. package/dist/owletto/dist/assets/{create-automation-form-BhujNbRr.js → create-automation-form-CLicoPH5.js} +3 -3
  69. package/dist/owletto/dist/assets/create._connectorKey-s4xkktTC.js +2 -0
  70. package/dist/owletto/dist/assets/{custom-guardrail-edits-B_aCgvoZ.js → custom-guardrail-edits-BUL7nmuO.js} +2 -2
  71. package/dist/owletto/dist/assets/{definition-comparison-3zKUSTt8.js → definition-comparison-4UYMI6BK.js} +2 -2
  72. package/dist/owletto/dist/assets/{detail-page-skeleton-BmxqqIsH.js → detail-page-skeleton-C8v3rJXK.js} +2 -2
  73. package/dist/owletto/dist/assets/device-BBwsOi7q.js +2 -0
  74. package/dist/owletto/dist/assets/device-pin-tombstone-Bcpe7nAA.js +2 -0
  75. package/dist/owletto/dist/assets/{device._deviceId-Dqtmb1Xp.js → device._deviceId-DLT4jh0Z.js} +2 -2
  76. package/dist/owletto/dist/assets/{dynamic-schema-form-D3KnzCsW.js → dynamic-schema-form-BDT8x0Vg.js} +2 -2
  77. package/dist/owletto/dist/assets/entity-options-B9hm9V87.js +2 -0
  78. package/dist/owletto/dist/assets/entity-page-DZjzQ2V4.js +2 -0
  79. package/dist/owletto/dist/assets/entity-pages-BWBpttz3.js +2 -0
  80. package/dist/owletto/dist/assets/entity-schema-graph-lMMx3HhR.js +2 -0
  81. package/dist/owletto/dist/assets/{entity-type-page-CouHZbc9.js → entity-type-page-CkQm0yEu.js} +2 -2
  82. package/dist/owletto/dist/assets/event-detail-CkzfakTK.js +2 -0
  83. package/dist/owletto/dist/assets/events-feed-DmRzikZW.js +2 -0
  84. package/dist/owletto/dist/assets/filter-editors-CQoSj-20.js +3 -0
  85. package/dist/owletto/dist/assets/{full-page-spinner-B7A6Ycyi.js → full-page-spinner-CYyCnKve.js} +2 -2
  86. package/dist/owletto/dist/assets/index-BE7eb2kE.js +2 -0
  87. package/dist/owletto/dist/assets/index-BFR0uiKY.js +2 -0
  88. package/dist/owletto/dist/assets/{index-DXfYVs5m.js → index-BS5Ty3tf.js} +2 -2
  89. package/dist/owletto/dist/assets/index-C38OzBpB.js +2 -0
  90. package/dist/owletto/dist/assets/{index-BztXeLBN.js → index-C3hz9tzx.js} +2 -2
  91. package/dist/owletto/dist/assets/index-CDyFQ32o.js +2 -0
  92. package/dist/owletto/dist/assets/{index-B-dZruj6.js → index-CUndAH6o.js} +2 -2
  93. package/dist/owletto/dist/assets/index-CiKysEhV.js +2 -0
  94. package/dist/owletto/dist/assets/index-DByaMzsG.js +7906 -0
  95. package/dist/owletto/dist/assets/index-DfdinB7B.js +2 -0
  96. package/dist/owletto/dist/assets/index-DgMM4Zt5.css +1 -0
  97. package/dist/owletto/dist/assets/index-Xk711gVC.js +2 -0
  98. package/dist/owletto/dist/assets/index-ittfA0k8.js +2 -0
  99. package/dist/owletto/dist/assets/{json-diff-CJK-gzCt.js → json-diff-mcDgyct_.js} +2 -2
  100. package/dist/owletto/dist/assets/{list-skeleton-bQAZ0hQp.js → list-skeleton-DsYGUHxi.js} +2 -2
  101. package/dist/owletto/dist/assets/login-EoLq136v.js +2 -0
  102. package/dist/owletto/dist/assets/{logout-H0F3IfiO.js → logout-gLgEQOiX.js} +2 -2
  103. package/dist/owletto/dist/assets/{member-scope-gate-Doic_6qX.js → member-scope-gate-vvkgSAb2.js} +2 -2
  104. package/dist/owletto/dist/assets/memory-browse-page-DvDtwrEI.js +74 -0
  105. package/dist/owletto/dist/assets/{model-selector-BrfaDwIg.js → model-selector-D3vSMLO2.js} +2 -2
  106. package/dist/owletto/dist/assets/needs-you-list-B5Bgd05M.js +2 -0
  107. package/dist/owletto/dist/assets/new-BPW3V0Y1.js +2 -0
  108. package/dist/owletto/dist/assets/new-Bk_flKQO.js +2 -0
  109. package/dist/owletto/dist/assets/new-C5HtQdM_.js +2 -0
  110. package/dist/owletto/dist/assets/new-dLXsCHBd.js +2 -0
  111. package/dist/owletto/dist/assets/organization-DBfgBkzq.js +2 -0
  112. package/dist/owletto/dist/assets/peek-pane-content-c2PG3TEX.js +2 -0
  113. package/dist/owletto/dist/assets/{pending-seed-DYYOoCvj.js → pending-seed-CBhx2Ql-.js} +2 -2
  114. package/dist/owletto/dist/assets/{proposal-review-shell-BVwOMoq9.js → proposal-review-shell-B-jYcKfB.js} +2 -2
  115. package/dist/owletto/dist/assets/public-shell-ready-D8TijlRY.js +2 -0
  116. package/dist/owletto/dist/assets/record-activity-DnRVOrG2.js +2 -0
  117. package/dist/owletto/dist/assets/{record-session-KuEDuF3S.js → record-session-CAmGHMyM.js} +2 -2
  118. package/dist/owletto/dist/assets/{renderer-ucwCQmBk.js → renderer-olRv_HMI.js} +3 -3
  119. package/dist/owletto/dist/assets/reset-password-B9_xi8Pq.js +2 -0
  120. package/dist/owletto/dist/assets/{run-initiator-8vdkq-3o.js → run-initiator-DhE5v4z0.js} +2 -2
  121. package/dist/owletto/dist/assets/runs-C8sZQr4o.js +2 -0
  122. package/dist/owletto/dist/assets/runs-list-CwtH-wmk.js +2 -0
  123. package/dist/owletto/dist/assets/{schema-value-CefbtPIY.js → schema-value-zTJGE4eh.js} +3 -3
  124. package/dist/owletto/dist/assets/scoped-feed-bar-BKyJSa3_.js +2 -0
  125. package/dist/owletto/dist/assets/{settings-DvzkRYQy.js → settings-z02cvVS3.js} +2 -2
  126. package/dist/owletto/dist/assets/source-record-panels-CGmKIJdN.js +2 -0
  127. package/dist/owletto/dist/assets/{status-variants-BxHtpMOj.js → status-variants-DyRCXBzM.js} +2 -2
  128. package/dist/owletto/dist/assets/subDays-D8nHthaS.js +2 -0
  129. package/dist/owletto/dist/assets/{table-1O-ik4_O.js → table-C637cQxG.js} +2 -2
  130. package/dist/owletto/dist/assets/use-automations-CgWNoYio.js +2 -0
  131. package/dist/owletto/dist/assets/use-login-redirect-tDdhXTpt.js +2 -0
  132. package/dist/owletto/dist/assets/{use-mention-search-CA-evCDf.js → use-mention-search-D-kIKchD.js} +2 -2
  133. package/dist/owletto/dist/assets/view-param-filters-CUCj9Df-.js +2 -0
  134. package/dist/owletto/dist/assets/views-access-required-C35Dyt91.js +2 -0
  135. package/dist/owletto/dist/index.html +19 -12
  136. package/dist/server-main.bundle.mjs +6964 -4213
  137. package/npm-shrinkwrap.json +423 -406
  138. package/package.json +1 -1
  139. package/vendor/connector-sdk/dist/connector-types.d.ts +29 -2
  140. package/vendor/connector-sdk/dist/index.d.ts +1 -0
  141. package/vendor/connector-sdk/dist/index.js +1 -0
  142. package/vendor/connector-sdk/dist/ip-reachability.d.ts +1 -1
  143. package/vendor/connector-sdk/dist/ip-reachability.js +1 -1
  144. package/vendor/connector-sdk/dist/logger.d.ts +1 -1
  145. package/vendor/connector-sdk/dist/logger.js +1 -1
  146. package/vendor/connector-sdk/dist/reaction-client-types.d.ts +3 -1
  147. package/vendor/connector-sdk/dist/retry.d.ts +1 -1
  148. package/vendor/connector-sdk/dist/retry.js +1 -1
  149. package/vendor/connector-sdk/dist/source-withheld-error.d.ts +16 -0
  150. package/vendor/connector-sdk/dist/source-withheld-error.js +19 -0
  151. package/vendor/connector-sdk/package.json +1 -1
  152. package/vendor/core/dist/classify-error.d.ts +4 -5
  153. package/vendor/core/dist/classify-error.js +10 -10
  154. package/vendor/core/dist/contracts/tools/collection-presentation.d.ts +17 -1
  155. package/vendor/core/dist/contracts/tools/collection-presentation.js +27 -3
  156. package/vendor/core/dist/contracts/tools/manage-automations.d.ts +67 -3
  157. package/vendor/core/dist/contracts/tools/manage-automations.js +38 -9
  158. package/vendor/core/dist/contracts/tools/manage-entity-schema.js +1 -1
  159. package/vendor/core/dist/contracts/tools/manage-entity.d.ts +8 -0
  160. package/vendor/core/dist/contracts/tools/manage-entity.js +11 -3
  161. package/vendor/core/dist/contracts/tools/manage-views.d.ts +249 -7
  162. package/vendor/core/dist/contracts/tools/manage-views.js +83 -21
  163. package/vendor/core/dist/contracts/tools/navigation.d.ts +248 -0
  164. package/vendor/core/dist/contracts/tools/navigation.js +284 -0
  165. package/vendor/core/dist/contracts/tools/save-memory.d.ts +11 -1
  166. package/vendor/core/dist/contracts/tools/save-memory.js +25 -3
  167. package/vendor/core/dist/contracts/tools/search-memory.js +1 -1
  168. package/vendor/core/dist/contracts/tools/view-attach.d.ts +7 -0
  169. package/vendor/core/dist/contracts/tools/view-attach.js +15 -0
  170. package/vendor/core/dist/contracts/tools/view-content-hash.d.ts +4 -1
  171. package/vendor/core/dist/contracts/tools/view-content-hash.js +4 -2
  172. package/vendor/core/dist/contracts/tools/view-definition.d.ts +2 -0
  173. package/vendor/core/dist/contracts/tools/view-definition.js +52 -0
  174. package/vendor/core/dist/contracts/tools/view-host.d.ts +68 -0
  175. package/vendor/core/dist/contracts/tools/view-host.js +28 -1
  176. package/vendor/core/dist/contracts/tools/view-scope.d.ts +31 -0
  177. package/vendor/core/dist/contracts/tools/view-scope.js +45 -0
  178. package/vendor/core/dist/credentials.d.ts +12 -0
  179. package/vendor/core/dist/credentials.js +1 -0
  180. package/vendor/core/dist/errors.d.ts +17 -24
  181. package/vendor/core/dist/errors.js +19 -26
  182. package/vendor/core/dist/types.d.ts +0 -6
  183. package/vendor/core/dist/worker/auth.d.ts +5 -0
  184. package/vendor/core/dist/worker/auth.js +15 -4
  185. package/vendor/core/package.json +11 -1
  186. package/vendor/postgres/cf/src/connection.js +7 -2
  187. package/vendor/postgres/cjs/src/connection.js +7 -2
  188. package/vendor/postgres/src/connection.js +7 -2
  189. package/vendor/views/dist/api.d.ts +30 -5
  190. package/vendor/views/dist/api.js +22 -8
  191. package/vendor/views/dist/bridge.d.ts +17 -0
  192. package/vendor/views/dist/bridge.js +49 -1
  193. package/vendor/views/dist/components.d.ts +27 -5
  194. package/vendor/views/dist/components.js +57 -7
  195. package/vendor/views/dist/embed.d.ts +98 -0
  196. package/vendor/views/dist/embed.js +418 -0
  197. package/vendor/views/dist/index.d.ts +3 -1
  198. package/vendor/views/dist/index.js +1 -0
  199. package/vendor/views/dist/native.d.ts +33 -1
  200. package/vendor/views/dist/native.js +3 -0
  201. package/vendor/views/package.json +1 -1
  202. package/dist/owletto/dist/assets/_-B0tmXZ86.js +0 -2
  203. package/dist/owletto/dist/assets/_-DwXULq4r.js +0 -3
  204. package/dist/owletto/dist/assets/_agentId-B1dNkhnr.js +0 -2
  205. package/dist/owletto/dist/assets/_agentId-sYjvnBaB.js +0 -2
  206. package/dist/owletto/dist/assets/_automationId-Bnw_CnT_.js +0 -2
  207. package/dist/owletto/dist/assets/_connectorKey._connectionId-D7Z8DQ-B.js +0 -2
  208. package/dist/owletto/dist/assets/_connectorKey.index-DM5MTO8c.js +0 -2
  209. package/dist/owletto/dist/assets/_eventId-CfB0_2zK.js +0 -2
  210. package/dist/owletto/dist/assets/_owner-BDvTUY0a.js +0 -3
  211. package/dist/owletto/dist/assets/_shape-BZidoJMB.js +0 -2
  212. package/dist/owletto/dist/assets/_slug-R989vOiM.js +0 -2
  213. package/dist/owletto/dist/assets/_viewKey-BDUSrpe5.js +0 -2
  214. package/dist/owletto/dist/assets/_viewKey-BnFqh5-t.js +0 -2
  215. package/dist/owletto/dist/assets/accept-invitation-BC-ZIsrf.js +0 -2
  216. package/dist/owletto/dist/assets/activity-route-view-CN2dOiCD.js +0 -2
  217. package/dist/owletto/dist/assets/agent-connect-pages-CdDjrHjn.js +0 -4
  218. package/dist/owletto/dist/assets/agent-permissions-matrix-ju7L2M0l.js +0 -2
  219. package/dist/owletto/dist/assets/automation-detail-content-BJwRU6qT.js +0 -2
  220. package/dist/owletto/dist/assets/clients-CydgUHrc.js +0 -2
  221. package/dist/owletto/dist/assets/connect-OdHpIVV9.js +0 -2
  222. package/dist/owletto/dist/assets/connect._clientId-EI1tcdSE.js +0 -2
  223. package/dist/owletto/dist/assets/connection-D8ZAMHBT.js +0 -2
  224. package/dist/owletto/dist/assets/connector-boxes-BWPXijAk.js +0 -2
  225. package/dist/owletto/dist/assets/connector-page-shell-C23dWdKz.js +0 -2
  226. package/dist/owletto/dist/assets/connectors-Bp08_KPq.js +0 -2
  227. package/dist/owletto/dist/assets/consent-_PpYI1cT.js +0 -2
  228. package/dist/owletto/dist/assets/create-DULVO0HS.js +0 -2
  229. package/dist/owletto/dist/assets/create-Drx9tcnG.js +0 -2
  230. package/dist/owletto/dist/assets/create._connectorKey-N6fhcIPy.js +0 -2
  231. package/dist/owletto/dist/assets/device-D2eUt_nr.js +0 -2
  232. package/dist/owletto/dist/assets/device-pin-tombstone-BFPbTM_o.js +0 -2
  233. package/dist/owletto/dist/assets/entity-options-IUdQ-64R.js +0 -2
  234. package/dist/owletto/dist/assets/entity-page-B3Im65EI.js +0 -2
  235. package/dist/owletto/dist/assets/entity-pages-DJNSQrfB.js +0 -2
  236. package/dist/owletto/dist/assets/event-detail-CvaRN1qB.js +0 -2
  237. package/dist/owletto/dist/assets/events-feed-DwOkLk6A.js +0 -2
  238. package/dist/owletto/dist/assets/filter-editors-DQ5V4Cvh.js +0 -2
  239. package/dist/owletto/dist/assets/home-stream-Bg97PUBJ.js +0 -2
  240. package/dist/owletto/dist/assets/home-toolbar-CpCcHA6z.js +0 -2
  241. package/dist/owletto/dist/assets/index-9PGnv4-5.js +0 -2
  242. package/dist/owletto/dist/assets/index-C2TCKJDP.js +0 -7901
  243. package/dist/owletto/dist/assets/index-C7QM3aqU.js +0 -2
  244. package/dist/owletto/dist/assets/index-CWn46a4y.js +0 -2
  245. package/dist/owletto/dist/assets/index-CxJONizf.js +0 -2
  246. package/dist/owletto/dist/assets/index-DJhb3li3.js +0 -2
  247. package/dist/owletto/dist/assets/index-DY-YGnCe.js +0 -2
  248. package/dist/owletto/dist/assets/index-j3v7ITPb.js +0 -2
  249. package/dist/owletto/dist/assets/index-oiy6ygaI.js +0 -2
  250. package/dist/owletto/dist/assets/index-pEgtAY1t.js +0 -2
  251. package/dist/owletto/dist/assets/index-xAvK3IyQ.css +0 -1
  252. package/dist/owletto/dist/assets/login-DLqL54Rk.js +0 -2
  253. package/dist/owletto/dist/assets/memory-browse-page-CUea2Llz.js +0 -74
  254. package/dist/owletto/dist/assets/new-5GkxlOuQ.js +0 -2
  255. package/dist/owletto/dist/assets/new-BiA4DGoN.js +0 -2
  256. package/dist/owletto/dist/assets/new-M-MX_T5C.js +0 -2
  257. package/dist/owletto/dist/assets/organization-CLrcmgNK.js +0 -2
  258. package/dist/owletto/dist/assets/peek-pane-content-B29OcHwm.js +0 -2
  259. package/dist/owletto/dist/assets/public-shell-ready-BbjPgh3k.js +0 -2
  260. package/dist/owletto/dist/assets/record-activity-BCpNKaUo.js +0 -2
  261. package/dist/owletto/dist/assets/reset-password-BkiAmXZW.js +0 -2
  262. package/dist/owletto/dist/assets/runs-B_iywKWb.js +0 -2
  263. package/dist/owletto/dist/assets/runs-list-CJJFRhTl.js +0 -2
  264. package/dist/owletto/dist/assets/schema-type-editor-panel-C4e8pq1A.js +0 -2
  265. package/dist/owletto/dist/assets/scoped-feed-bar-CapleZvS.js +0 -2
  266. package/dist/owletto/dist/assets/source-record-panels-LJIWGtHb.js +0 -2
  267. package/dist/owletto/dist/assets/subDays-DwIOMzYC.js +0 -2
  268. package/dist/owletto/dist/assets/use-automations-lV8PuE8L.js +0 -2
  269. package/dist/owletto/dist/assets/use-login-redirect-CfCbEeJR.js +0 -2
  270. package/dist/owletto/dist/assets/view-param-filters-Bp84PUMd.js +0 -2
  271. package/dist/owletto/dist/assets/views-access-required-BerT4Z1d.js +0 -2
  272. /package/vendor/postgres/{.bun-tag-c81dacd34e959a7a → .bun-tag-652f2580b8090d71} +0 -0
@@ -0,0 +1,74 @@
1
+ import{eG as Tt,c3 as Is,c4 as As,g0 as Ps,g1 as Fs,j as s,dv as Ds,c8 as Vs,Z as Ve,$ as se,bR as Bs,B as R,by as It,g2 as At,g3 as te,g4 as je,g5 as qs,g6 as Hs,g7 as Qe,g8 as Us,g9 as He,ga as Ue,gb as zs,gc as Gs,gd as Js,z as Pt,dI as Ne,r as x,d9 as Ws,ex as Ys,K as Qs,eD as Zs,M as Ee,x as Ft,cz as Ks,f_ as Xs,c as ne,u as Dt,fe as en,b$ as tn,bc as Vt,d8 as Bt,fG as sn,fY as nn,e_ as an,a7 as ze,i as ie,dL as qt,ge as rn,L as ke,e6 as on,c_ as ln,aE as Ht,aF as Ut,dh as zt,aH as Gt,aI as cn,aJ as dn,aK as un,aL as mn,aM as Ct,aQ as pn,cT as fn,aO as hn,cP as Jt,a9 as gn,gf as Wt,gg as Yt,aw as yn,gh as xn,V as Qt,H as bn,gi as vn,ci as Z,w as Zt,gj as Be,cJ as jn,gk as Nn,gl as Sn,dU as Et,gm as qe,gn as wn,go as Cn,d7 as En,dg as kn,cF as _n,cG as $n,cg as Ge,dE as Rn,gp as Ln,gq as Je,gr as On,gs as Mn,d4 as Tn,bo as In,cZ as An,gt as Pn,gu as Fn,a as Dn,gv as Vn,gw as Bn,gx as qn,gy as Hn,cO as Un,at as zn,aS as Gn}from"./index-DByaMzsG.js";import{P as Jn}from"./public-shell-ready-D8TijlRY.js";import{D as Wn,c as Yn}from"./dynamic-schema-form-BDT8x0Vg.js";import{S as Qn,E as Kt,a as Zn,e as Kn,b as Xn,c as ea}from"./entity-pages-BWBpttz3.js";import{b as ta,F as sa}from"./filter-editors-CQoSj-20.js";import{l as na,H as aa,n as ra,G as Xt,c as oa}from"./entity-schema-graph-lMMx3HhR.js";import{l as ia,p as _e,e as es,a as la,S as ca,J as da}from"./renderer-olRv_HMI.js";import{u as ua,a as ma,D as pa,P as fa,b as ts,c as ha,C as ga}from"./core.esm-C9QlSrgK.js";import{v as ya,V as ss,M as ns,a as as,w as xa,b as ba}from"./view-param-filters-CUCj9Df-.js";import{M as va}from"./member-scope-gate-vvkgSAb2.js";function ja({onClose:e,entityTypeSlug:t,orgContext:r,onSuccess:l}){const{data:n,isLoading:d}=Tt(t,r),i=`${r.organizationId??r.slug}:${t}`,a=Is(i,{name:"",customSlug:"",useCustomSlug:!1,metadata:{}},n?.metadata_schema),[u,o]=a.field("name"),[c,m]=a.field("customSlug"),[p,f]=a.field("useCustomSlug"),[y,N]=a.field("metadata"),[v,C]=As(i,null),b=Ps(),w=p?c:Fs(u),j=async L=>{if(L.preventDefault(),!a.canSubmit)return;if(C(null),!u.trim()){C("Name is required");return}const M=Yn(y),K={entityType:t,name:u.trim(),slug:p?c:void 0,metadata:Object.keys(M).length>0?M:void 0};try{const $=await b.mutateAsync(K);if(e(),$.approval_queued||!$.entity){It.info("Create queued for approval");return}typeof $.entity.id=="number"&&l?.($.entity.id)}catch($){C($ instanceof Error?$.message:"Failed to create entity")}},S=n?.name||t,g=a.revision,E=`Create ${S}`,k=`Add a new ${S.toLowerCase()} to your workspace.`;return d?s.jsx(Ds,{rows:6}):s.jsxs("form",{onSubmit:j,children:[s.jsx(Vs,{visible:a.hasConflict,onReload:a.reset}),s.jsxs("div",{className:"space-y-1.5",children:[s.jsx("h1",{className:"text-2xl font-semibold leading-tight",children:E}),s.jsx("p",{className:"text-sm text-muted-foreground",children:k})]}),s.jsxs("div",{className:"grid gap-4 py-4",children:[s.jsxs("div",{className:"grid gap-2",children:[s.jsxs(Ve,{htmlFor:"name",children:["Name ",s.jsx("span",{className:"text-destructive",children:"*"})]}),s.jsx(se,{id:"name",value:u,onChange:L=>o(L.target.value),placeholder:`Enter ${S.toLowerCase()} name`,autoFocus:!0})]}),s.jsxs("div",{className:"grid gap-2",children:[s.jsxs("div",{className:"flex items-center justify-between",children:[s.jsx(Ve,{htmlFor:"slug",children:"URL Slug"}),s.jsx("button",{type:"button",onClick:()=>f(!p),className:"text-xs text-muted-foreground hover:text-foreground",children:p?"Auto-generate":"Customize"})]}),p?s.jsx(se,{id:"slug",value:c,onChange:L=>m(L.target.value.toLowerCase().replace(/[^a-z0-9-]/g,"")),placeholder:"custom-slug"}):s.jsx("div",{className:"flex h-9 items-center rounded-md border border-input bg-muted px-3 text-sm text-muted-foreground",children:w||"slug-preview"})]}),g&&Object.keys(g).length>0?s.jsxs(s.Fragment,{children:[s.jsx(Qn,{className:"my-2"}),s.jsxs("div",{className:"grid gap-2",children:[s.jsx(Ve,{className:"text-sm font-medium",children:"Additional Fields"}),s.jsx(Wn,{schema:a.revision,values:y,onValuesChange:N,orgContext:r})]})]}):null,v&&s.jsx("div",{className:"rounded-md bg-destructive/10 px-3 py-2 text-sm text-destructive",children:v})]}),s.jsx(Bs,{onCancel:e,cancelDisabled:b.isPending,className:"mt-2",children:s.jsx(R,{type:"submit",disabled:!a.canSubmit||b.isPending||!u.trim(),children:b.isPending?"Creating...":`Create ${S}`})})]})}function Na(e){const t=e?.properties??{},r=zs(e);return Object.entries(t).flatMap(([l,n])=>{const d=r.find(m=>m.field===l);if(!/^[A-Za-z_][A-Za-z0-9_]*$/.test(l)||!n||n.const!==void 0||n["x-table-column"]!==!0&&n["x-facet"]!==!0&&!d)return[];const i=[n,...Array.isArray(n.anyOf)?n.anyOf:[]],a=d?.options??Gs(n),u=a.find(m=>m.value!==null)?.value,o=i.find(m=>["string","number","integer","boolean"].includes(String(m.type)))??(u===void 0?void 0:{type:typeof u});if(!o)return[];const c=n.format==="date-time"||o.format==="date-time"?"datetime-local":n.format==="date"||o.format==="date"?"date":o.type==="number"||o.type==="integer"?"number":o.type==="boolean"?"boolean":"string";return[{field:l,label:String(n["x-table-label"]??n.title??l.replaceAll("_"," ")),type:c,options:c==="boolean"&&!a.some(m=>typeof m.value=="boolean")?[{value:!0,label:"Yes"},{value:!1,label:"No"},...a]:a}]})}const kt={eq:"is",neq:"is not",lt:"<",lte:"≤",gt:">",gte:"≥"};function Sa(e,t){return e.value===null&&e.op==="neq"?{op:kt.eq,value:"set"}:{op:kt[e.op],value:t?.options.find(r=>r.value===e.value)?.label??String(e.value)}}function wa(e){const t=e?.[Ue];return t===void 0?{}:Qe(t)}function Ca(e,t){return(e.presets??[]).filter(r=>!r.viewer||!!t?.email)}function Ea(e,t,r,l){try{const n=wa(t),d=Ca(n,l),i=e[At],a=i===void 0?void 0:d.find(p=>p.key===i);if(i!==void 0&&!a)throw new Error("This saved filter is unavailable. Choose another filter.");if(a&&!r&&typeof e.segment=="string"&&e.segment)throw new Error("A saved filter and an explicit selection cannot be combined.");const u=a&&e[te]===void 0?{collection:je(a,void 0,l)}:qs(e,r);if(u.error)throw u.error;const o=e[Hs],c=o===void 0?a?.table??n.table??{}:Qe({table:typeof o=="string"?JSON.parse(o):o}).table??{},m=!!a&&(_t(u.collection)!==_t(je(a,void 0,l))||Se(c)!==Se(a.table??n.table??{}));return{...u,presentation:n,presets:d,preset:a,table:c,edited:m}}catch(n){return{collection:{},presentation:{},presets:[],table:{},edited:!1,error:n instanceof Error?n:new Error("Invalid collection configuration")}}}function _t(e){return JSON.stringify([e.search??"",e.segment??"",(e.filters??[]).map(Q)])}function Q(e){return JSON.stringify([e.field,e.op,e.value])}function Se(e){return JSON.stringify([e.columns??null,e.sort?.field??null,e.sort?.order??null])}function ka(e,t){return t?{[At]:t,[te]:He(e)[te]??"{}"}:He(e)}function _a(e,t,r,l,n=new Date,d){let i=t.filters??[],a=e.viewer;if(a){const o=d?.email?Q({field:a.field,op:"eq",value:d.email.toLowerCase()}):void 0;o&&i.some(c=>Q(c)===o)?i=i.filter(c=>Q(c)!==o):a=void 0}let u=e.relativeDate;if(u){const o=(je({...e,viewer:void 0,selection:{}},n).filters??[]).map(Q),c=i.map(Q);o.every(m=>c.includes(m))?i=i.filter(m=>!o.includes(Q(m))):u=void 0}return{key:e.key,label:e.label,selection:{...t.search?{search:t.search}:{},...i.length?{filters:i}:{},...t.segment?{segment:t.segment}:{}},...Se(r)!==Se(l.table??{})?{table:r}:{},...u?{relativeDate:u}:{},...a?{viewer:a}:{}}}function $a(e,t,r){const l=[...e.filters??[]],n=r??(t.length===1&&t[0].op==="eq"?l.findIndex(i=>i.field===t[0].field&&i.op==="eq"):-1),d=n>=0?[...l.slice(0,n),...t,...l.slice(n+1)]:[...l,...t];return{...e,filters:Js({filters:d}).filters}}function Ra(e,t){return{...e,filters:e.filters?.filter((r,l)=>l!==t)}}function La(e,t){return{...typeof e.$preset=="string"?e[te]===void 0?{$preset:e.$preset}:{$preset:e.$preset,[te]:String(Us(e[te]))}:He(t),...e.$table===void 0?{}:{$table:typeof e.$table=="string"?e.$table:JSON.stringify(e.$table)}}}const Oa=[{field:"name",label:"Name"},{field:"created_at",label:"Created"},{field:"total_content",label:"Activity count"},{field:"active_connections",label:"Connections"},{field:"automations_count",label:"Automations"},{field:"children_count",label:"Children"}];function Ma(e){return e.sort&&Oa.some(t=>t.field===e.sort?.field)?e.sort:{field:"created_at",order:"desc"}}function Ta(e,t,r,l,n){const d={...l,filters:l.filters?.filter(i=>i.field!==r)};return Pt({queryKey:["collection-facets",e,t,r,d],enabled:!!t&&!!r,staleTime:3e4,retry:!1,queryFn:async({signal:i})=>{const a=await Ne("query_sdk",{title:`Value counts query for ${r}`,script:`const input = ${JSON.stringify({field:r,collection:d})};
2
+ ${t}`},e,{signal:i}),u=a.return_value;if(!a.success||typeof u?.connection!="string"||typeof u.sql!="string")throw new Error(a.error?.message??"Value distribution is unavailable");if(i.aborted)throw new DOMException("Aborted","AbortError");const o=await Ne("query_sql",{title:`Value counts for ${r}`,connection:u.connection,sql:u.sql,limit:51},e,{signal:i});if(o.error)throw new Error(o.error);if(!Array.isArray(o.rows))throw new Error("Source did not return value counts");const c=o.rows.map(m=>{const p=m,f=typeof p.count=="string"&&/^\d+$/.test(p.count)?Number(p.count):p.count;if(!(p.value===null||["string","number","boolean"].includes(typeof p.value))||typeof f!="number"||!Number.isSafeInteger(f)||f<0)throw new Error("Source returned an invalid value distribution");return{value:p.value,count:f}});return{values:c.slice(0,50),truncated:c.length>50||o.truncated===!0}}})}const Ia=300;function Aa({label:e,search:t,onSearch:r,className:l}){const n=t??"",[d,i]=x.useState(n),a=x.useRef({search:t,onSearch:r});a.current={search:t,onSearch:r};const u=x.useRef(void 0);x.useEffect(()=>{const c=()=>{clearTimeout(u.current),i(a.current.search??"")};return window.addEventListener("popstate",c),()=>window.removeEventListener("popstate",c)},[]);const o=x.useRef(n);return x.useEffect(()=>{n!==o.current&&(o.current=n,i(n))},[n]),x.useEffect(()=>{if(d===(a.current.search??""))return;const c=setTimeout(()=>{const m=a.current.onSearch;o.current=d,m(d||void 0,!0)},Ia);return u.current=c,()=>clearTimeout(c)},[d]),s.jsxs("div",{className:`relative${l?` ${l}`:""}`,children:[s.jsx(Ws,{"aria-hidden":"true",className:"absolute left-3 top-1/2 h-4 w-4 -translate-y-1/2 text-muted-foreground"}),s.jsx(se,{type:"search","aria-label":`Search ${e.toLowerCase()}`,placeholder:`Search ${e.toLowerCase()}...`,maxLength:512,value:d,onChange:c=>i(c.target.value),className:"pl-9"})]})}function Pa({field:e,initial:t,org:r,facetQuery:l,collection:n,onApply:d,close:i}){const[a,u]=x.useState(t?.op??"eq"),[o,c]=x.useState(t?.value==null?"":String(t.value)),[m,p]=x.useState(""),[f,y]=x.useState(!1),[N,v]=x.useState(),C=e.type==="date"||e.type==="datetime-local"||e.type==="number"?e.type:"text",b=Ta(r,l,e.field,n),w=g=>{try{const E=f?[{field:e.field,op:"gte",value:e.type==="number"?Number(o):o},{field:e.field,op:"lte",value:e.type==="number"?Number(m):m}]:[{field:e.field,op:a,value:g}];if(e.type==="datetime-local")for(const M of E)typeof M.value=="string"&&(M.value=new Date(M.value).toISOString());if(E.some(M=>typeof M.value=="number"&&!Number.isFinite(M.value)))throw new Error("Enter a valid number.");const k=E[0].value,L=E[1]?.value;if(f&&k!=null&&L!=null&&k>L)throw new Error("The lower bound must be before the upper bound.");d(E),i()}catch(E){v(E instanceof Error?E.message:"Could not apply filter")}},j=[...e.options];for(const g of b.data?.values??[])j.some(E=>E.value===g.value)||j.push({value:g.value,label:g.value===null?"Not supplied":String(g.value)});const S=Math.max(1,...b.data?.values.map(g=>g.count)??[]);return s.jsxs("div",{className:"min-w-0 space-y-3 p-3",children:[s.jsxs("select",{"aria-label":"Filter operator",className:"h-8 w-full rounded-md border bg-background px-2 text-sm",value:f?"range":a,onChange:g=>{y(g.target.value==="range"),g.target.value!=="range"&&u(g.target.value)},children:[s.jsx("option",{value:"eq",children:"is"}),s.jsx("option",{value:"neq",children:"is not"}),(e.type==="number"||e.type==="date"||e.type==="datetime-local")&&s.jsxs(s.Fragment,{children:[s.jsx("option",{value:"lt",children:"less than / before"}),s.jsx("option",{value:"lte",children:"at most / on or before"}),s.jsx("option",{value:"gt",children:"greater than / after"}),s.jsx("option",{value:"gte",children:"at least / on or after"}),t?null:s.jsx("option",{value:"range",children:"between"})]})]}),e.type!=="boolean"&&s.jsxs("form",{className:"space-y-2",onSubmit:g=>{g.preventDefault(),w(e.type==="number"?Number(o):o)},children:[s.jsx(se,{required:!0,"aria-label":f?"From value":"Filter value",type:C,step:e.type==="number"?"any":void 0,value:o,onChange:g=>c(g.target.value),placeholder:"Enter a value…"}),f&&s.jsx(se,{required:!0,"aria-label":"To value",type:C,step:e.type==="number"?"any":void 0,value:m,onChange:g=>p(g.target.value)}),s.jsx(R,{size:"sm",type:"submit",className:"w-full",children:"Apply filter"})]}),!f&&(a==="eq"||a==="neq")&&s.jsx("div",{className:"max-h-48 space-y-1 overflow-y-auto",children:j.filter(g=>!o||g.label.toLowerCase().includes(o.toLowerCase())).map(g=>{const E=b.data?.values.find(k=>k.value===g.value)?.count;return s.jsxs("button",{type:"button","aria-label":g.label,onClick:()=>w(g.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&&s.jsx("span",{"aria-hidden":"true",className:"absolute inset-y-0 left-0 bg-primary/10",style:{width:`${E/S*100}%`}}),s.jsx("span",{className:"relative truncate",children:g.label}),s.jsx("span",{className:"relative text-xs tabular-nums text-muted-foreground",children:E?.toLocaleString()})]},JSON.stringify(g.value))})}),l&&b.isFetching&&s.jsx("p",{role:"status",className:"text-xs text-muted-foreground",children:"Loading distribution…"}),b.isError&&s.jsx("p",{role:"status",className:"text-xs text-muted-foreground",children:"Counts unavailable. You can still enter a value."}),b.data?.truncated&&s.jsx("p",{className:"text-xs text-muted-foreground",children:"Top 50 values. Enter any other value above."}),N&&s.jsx("p",{role:"alert",className:"text-xs text-destructive",children:N})]})}function rs({collection:e,schema:t,label:r,onChange:l,org:n,facetQuery:d,segmentChip:i,viewFilters:a,onClearAll:u}){const o=Na(t),c=(y,N)=>({kind:"custom",className:"w-80",render:v=>s.jsx(Pa,{field:y,initial:N==null?void 0:e.filters?.[N],org:n,facetQuery:d,collection:e,onApply:C=>l($a(e,C,N)),close:v})}),m=o.map(y=>({key:y.field,label:y.label,icon:s.jsx(Ys,{className:"h-4 w-4"}),editor:c(y)})),p=new Map,f=(e.filters??[]).map((y,N)=>{const v=`${y.field}:${y.op}:${JSON.stringify(y.value)}`,C=p.get(v)??0;p.set(v,C+1);const b=o.find(w=>w.field===y.field);return{id:`${v}:${C}`,label:b?.label??y.field,...Sa(y,b),editor:b?c(b,N):void 0,onRemove:()=>l(Ra(e,N))}});if(i&&f.unshift(i),a?.fields.length){for(const y of m)y.group=r;m.push(...a.fields),f.push(...a.chips)}return!m.length&&!f.length?{fields:m,chips:f,clearAll:()=>{}}:{fields:m,chips:f,clearAll:u??(()=>l({...e,filters:[],segment:void 0}))}}function Fa(e){const{fields:t}=rs(e);return t.length?s.jsx(ta,{fields:t}):null}function Da(e){const{chips:t,clearAll:r}=rs(e);return t.length?s.jsx(sa,{label:`${e.label} filters`,fields:[],chips:t,onClearAll:r,className:"mb-4"}):null}const we=120,H=12;function $t(e,t){return typeof e.linkId=="number"&&typeof t.linkId=="number"?e.linkId-t.linkId:String(e.linkId).localeCompare(String(t.linkId))}function Va(e){const t=e.records.slice(0,we),r=o=>e.types.get(o)??{label:o},l=new Map;for(const o of t)l.set(String(o.id),{source:o.source,entityType:e.typeSlug,slug:o.slug,name:o.name,isFocus:!0,hasMoreLinks:!1});const n=new Map;for(const o of e.links){if(!l.has(String(o.recordId)))continue;const c=n.get(o.recordId)??new Map;c.set(o.linkId,o),n.set(o.recordId,c)}const d=new Map;for(const[o,c]of n){const m=[...c.values()].sort($t),p=l.get(String(o));p&&m.length>H&&(p.hasMoreLinks=!0);for(const f of m.slice(0,H)){d.set(f.linkId,f);const y=String(f.peer.id);l.has(y)||l.set(y,{source:f.peer.source,...f.peer.remote?{remote:f.peer.remote}:{},entityType:f.peer.type,slug:f.peer.slug,name:f.peer.name,isFocus:!1,hasMoreLinks:!1})}}const i=[];for(const[o,c]of l){const m=c.remote?{label:c.entityType}:r(c.entityType),p=c.name||c.slug,f=c.hasMoreLinks?`${m.label} · ${H}+ links`:m.label;i.push({id:o,data:{slug:c.slug,label:p,icon:m.icon,isSystem:!1,metaLabel:f},width:ra(p,f),height:aa})}const a=new Map;for(const o of[...d.values()].sort($t)){const c=String(o.fromId),m=String(o.toId),p=JSON.stringify([c,m]),f=a.get(p)??{source:c,target:m,rels:new Map,symmetric:!0};f.symmetric&&=o.isSymmetric,f.rels.has(o.relSlug)||f.rels.set(o.relSlug,{slug:o.relSlug,label:o.relName,ruleCount:1}),a.set(p,f)}const u=[...a.entries()].map(([o,c])=>({id:`link:${o}`,source:c.source,target:c.target,data:{relationships:[...c.rels.values()],isSymmetric:c.symmetric}}));return{nodes:i,edges:u,records:l,hasMoreRecords:e.hasMore===!0||e.records.length>we,listedCount:t.length,focusCount:t.length}}async function Ba(e,t){const r=Va(e);return{...await na({nodes:r.nodes,edges:r.edges},t),records:r.records,hasMoreRecords:r.hasMoreRecords,listedCount:r.listedCount,focusCount:r.focusCount}}const qa=8,Ha=3,Ua=4;function ve(e){return`source:${JSON.stringify([e.type,e.key])}`}function za(e,t){return t.map(r=>{const l={type:e,key:r.slug};return{...r,id:ve(l),source:l}})}function Rt(e){return JSON.stringify([e.relationship_type,e.direction,e.entity_type,e.key])}async function Ga(e,t,r){const l=e.slice(0,qa),n=[];let d=0;return await Promise.all(Array.from({length:Math.min(Ha,l.length)},async()=>{for(;d<l.length;){const i=d++,a=l[i];try{if(r?.aborted)throw r.reason;const u=await t(a),o=new Map(a.links.map(v=>[Rt(v),v]));for(const v of u.record_links){const C=Rt(v),b=o.get(C);(!b||b.occurred_at<v.occurred_at)&&o.set(C,v)}const c=new Map((a.relationships??[]).map(v=>[v.id,v]));for(const v of u.relationships??[])c.set(v.id,v);const m=[...c.values()].slice(0,H+1),p=[...o.values()].slice(0,H+1),f=(a.pagesRead??0)+1,y=!!u.next_cursor&&f>=Ua,N=u.record_failures.some(v=>v.code!=="withheld")||!!u.relationship_failures?.length||y;n[i]={read:{record:a.record,links:p,failed:N,entityId:a.entityId,relationships:m},...!y&&(N||u.next_cursor&&p.length+m.length<=H)?{next:{record:a.record,entityId:a.entityId,relationships:m,pagesRead:f,cursor:u.next_cursor??a.cursor,links:p}}:{}}}catch(u){if(r?.aborted)throw u;n[i]={read:{record:a.record,links:a.links,failed:!0,entityId:a.entityId,relationships:a.relationships},next:{...a,cursor:u instanceof Qs&&u.status===400?null:a.cursor}}}}})),{reads:n.map(i=>i.read),pending:[...n.flatMap(i=>i.next?[i.next]:[]),...e.slice(l.length)]}}function Ja(e,t){const r=new Map;for(const d of e)for(const i of d.reads)r.set(String(i.entityId??ve(i.record)),i);const l=new Map(t.map(d=>[d.slug,d])),n=[];for(const[d,i]of r){for(const a of i.relationships??[]){const u=(v,C,b)=>b?`remote:${b}`:typeof v=="number"?v:ve({type:C,key:v}),o=u(a.from_entity_id,a.from_entity_type,a.from_entity_url),c=u(a.to_entity_id,a.to_entity_type,a.to_entity_url),m=String(o)===d,p=m?c:o,f=m?a.to_entity_id:a.from_entity_id,y=m?a.to_entity_url:a.from_entity_url,N=(m?a.to_entity_type:a.from_entity_type)??"";n.push({recordId:d,linkId:a.id,fromId:o,toId:c,relSlug:a.relationship_type_slug,relName:a.relationship_type_name,isSymmetric:a.is_symmetric,peer:{id:p,name:(m?a.to_entity_name:a.from_entity_name)??String(f),slug:(m?a.to_entity_slug:a.from_entity_slug)??String(f),type:N,...y?{remote:{url:Zs(y)}}:typeof f=="string"?{source:{type:N,key:f}}:{}}})}for(const a of i.links){const u={type:a.entity_type,key:a.key},o=ve(u),c=l.get(a.relationship_type);let m=a.direction==="incoming"?o:d,p=a.direction==="incoming"?d:o;c?.is_symmetric&&m>p&&([m,p]=[p,m]),n.push({recordId:d,linkId:JSON.stringify([m,p,a.relationship_type]),fromId:m,toId:p,relSlug:a.relationship_type,relName:c?.name||a.relationship_type.replaceAll("_"," "),isSymmetric:c?.is_symmetric??!1,peer:{id:o,name:a.name||a.key,slug:a.key,type:a.entity_type,source:u}})}}return{links:n,checked:r.size,failed:[...r.values()].filter(d=>d.failed).length}}function Wa(e,t,r,l,n,d=!1){const{orgContext:i}=Ee(),a=Ft(i),u=Ks(i),o=x.useMemo(()=>d?za(t,r):r,[d,t,r]),c=x.useMemo(()=>o.slice(0,we).flatMap(j=>j.source?[{record:j.source,cursor:null,links:[]}]:typeof j.id=="number"?[{entityId:j.id,record:{type:t,key:j.slug},cursor:null,links:[]}]:[]),[o,t]),m=Xs({queryKey:["source-records-graph",i.organizationId,e,t,c.map(j=>[j.record,j.entityId])],enabled:!0,initialPageParam:c,queryFn:({pageParam:j,signal:S})=>Ga(j,async g=>{const E=await Ne("manage_entity",{action:"list_links",...g.entityId===void 0?{record:g.record,cursor:g.cursor}:{entity_id:g.entityId,offset:Number(g.cursor??0)},limit:H+1},e,{signal:S});return{...E,record_links:E.record_links??[],record_failures:E.record_failures??[],next_cursor:g.entityId===void 0?E.next_cursor:E.metadata?.has_more?String(Number(g.cursor??0)+H+1):null}},S),getNextPageParam:j=>j.pending.length?j.pending:void 0,staleTime:3e4,retry:!1}),p=x.useMemo(()=>m.data?Ja(m.data.pages,u.data??[]):void 0,[m.data,u.data]),f=p?.links,y=m.isError,N=JSON.stringify([i.organizationId,e,t,d,o.map(j=>[j.id,j.name,j.slug]),l]),v=x.useMemo(()=>new Map((a.data??[]).map(j=>[j.slug,{label:j.name||j.slug,icon:j.icon}])),[a.data]),[C,b]=x.useState(null);x.useEffect(()=>{if(!f)return;let j=!1;return Ba({typeSlug:t,records:o,hasMore:l,links:f,types:v},{targetAspect:n}).then(S=>{j||b({graph:S,key:N,isError:!1})}).catch(()=>{j||b({graph:null,key:N,isError:!0})}),()=>{j=!0}},[f,t,o,l,v,n,N]);const w=C?.key===N?C:null;return{graph:w?.graph??null,isLoading:!y&&!w,isError:y||w?.isError===!0,sourceProgress:{checked:p?.checked??0,total:Math.min(r.length,we),failed:p?.failed??0,hasMore:!!m.hasNextPage,isFetching:m.isFetching,loadMore:()=>{m.isFetching||m.fetchNextPage()}}}}function Ya(e){const t=new Map(e.nodes.map(n=>[n.id,n.data.label])),r=e.nodes.map(n=>({id:n.id,x:n.position.x+n.width/2,y:n.position.y+n.height/2,w:n.width,h:n.height,title:n.data.label,meta:n.data.metaLabel,icon:n.data.icon,muted:e.records.get(n.id)?.isFocus===!1})),l=e.edges.map(n=>{const{relationships:d,isSymmetric:i}=n.data,a=d.map(u=>u.label);return{id:n.id,source:n.source,target:n.target,route:n.route??null,summary:a.length===1?a[0]:`${a.length} relationships`,details:a,directed:!i,ariaLabel:`${t.get(n.source)??n.source} ${i?"and":"to"} ${t.get(n.target)??n.target}: ${a.join(", ")}`}});return{boxes:r,edges:l}}function Qa({ownerSlug:e,typeSlug:t,records:r,hasMore:l,sourceBacked:n=!1}){const d=ne(),i=Dt(),{orgContext:a}=Ee(),{data:u=[]}=Ft(a),o=u.find(S=>S.slug===t)?.name??t,[c,m]=x.useState(),p=x.useRef(null),f=x.useCallback(S=>{if(p.current?.disconnect(),p.current=null,!S||typeof ResizeObserver>"u")return;const g=()=>{if(!S.clientWidth||!S.clientHeight)return;const k=Math.round(S.clientHeight/S.clientWidth*10)/10;m(L=>L===k?L:k)};g();const E=new ResizeObserver(g);E.observe(S),p.current=E},[]),{graph:y,isLoading:N,isError:v,sourceProgress:C}=Wa(e,t,r,l,c,n),b=x.useMemo(()=>y?Ya(y):null,[y]),w=x.useCallback(S=>{const g=y?.records.get(S);if(g){if(g.remote){g.remote.url&&window.open(g.remote.url,"_blank","noopener,noreferrer");return}if(i){i.open(ia({...g.source?{record:g.source}:{entityId:Number(S)},ownerSlug:e,orgContext:a,name:g.name||g.slug}));return}d({to:en(e,[{entity_type:g.entityType,slug:g.slug}])})}},[y,e,a,i,d]);if(v)return s.jsx(tn,{label:`${o} graph`});if(N||!y||!b)return s.jsx(Xt,{label:`Loading ${o} graph`});const j=C?s.jsxs("div",{className:"flex flex-wrap items-center justify-between gap-3",children:[s.jsxs("div",{className:"text-sm text-muted-foreground",role:"status",children:[s.jsxs("p",{children:["Checked ",C.checked," of ",C.total," records. Up to ",H," relationships per record."]}),C.failed>0?s.jsx("p",{role:"alert",children:"Some sources could not be read. These relationships are incomplete."}):null]}),C.hasMore?s.jsx(R,{variant:"outline",size:"sm",disabled:C.isFetching,onClick:C.loadMore,children:C.isFetching?"Loading…":C.failed>0?"Retry sources":"Load more relationships"}):null]}):null;return y.focusCount===0?s.jsxs("div",{className:"space-y-3",children:[j,s.jsx(Vt,{icon:Bt,title:`No ${o} records match`,description:"Change the search or filters to see records here."})]}):s.jsxs("div",{className:"flex flex-col gap-2",children:[j,s.jsxs("p",{className:"text-sm text-muted-foreground",children:["Showing ",y.hasMoreRecords?"the first ":"",y.focusCount," ",o," record",y.focusCount===1?"":"s",". Click a record to see it."]}),s.jsx("div",{ref:f,className:"h-[70vh] min-h-[420px] min-w-0 overflow-hidden",children:s.jsx(oa,{boxes:b.boxes,edges:b.edges,label:`${o} records`,onOpenBox:w,openLabel:S=>`Show ${S.title}`})})]})}function Za(e){return String(e??"").replace(/[_-]+/g," ").replace(/\b\w/g,t=>t.toUpperCase())}function os(e){return e["x-lobu"]?.role||e["x-lobu-role"]}function Ze(e){const t=e?.properties;if(!t)return null;const n=sn(t).find(([,o])=>os(o)==="workflowState");if(!n)return null;const[d,i]=n,a=i["x-lobu"]?.states,u=Array.isArray(a)&&a.length>0?a:(i.enum??[]).map(o=>({value:o}));return u.length===0||u.some(o=>typeof o.value!="string")?null:{field:d,states:u.map(o=>({...o,label:o.label||nn(i,o.value)||Za(o.value),terminal:o.terminal??["done","complete","completed","closed","archived"].includes(o.value.toLowerCase())}))}}function Ka(e){const t=e?.properties;if(!t)return null;const r=Object.entries(t),l=r.find(([,i])=>os(i)==="sortRank"),n=r.find(([i])=>["rank","sort_rank","order"].includes(i)),d=l??n;return d?{field:d[0]}:null}function Xa(e,{isDerived:t}){const r=e?.["x-lobu"]?.defaultView;return(r==="table"||r==="board")&&!(t&&r!=="table")?r:t?"table":Ze(e)?"board":"table"}const is={version:1,root:{type:"entity-table",props:{state:"{{tableState}}"}}},er={version:1,root:{type:"entity-board",props:{state:"{{boardState}}",onUpdate:"@updateEntity"}}};function tr(e){const{canShowBoard:t,builtinData:r,builtInLabels:l}=e,n=["table",...t?["board"]:[]],d={table:is,board:er};return n.map(i=>({id:i,label:l[i],builtInMode:i,template:d[i],data:r}))}function We(e){return e.replace(/[_-]+/g," ").replace(/\b\w/g,t=>t.toUpperCase())}function Ce(e,t){if(!t)return e.created_at??String(e.id);const r=_e(e.metadata);return String(r[t.field]??e.created_at??e.id)}function sr(e,t){const r=e?Number(e):Number.NaN,l=t?Number(t):Number.NaN;return Number.isFinite(r)&&Number.isFinite(l)&&r<l?String((r+l)/2):Number.isFinite(r)?String(r+1):Number.isFinite(l)?String(l-1):String(Date.now())}function Ye(e,t){const r=_e(e.metadata);return String(r[t]??"")}function ls(e,t){return[...e].sort((r,l)=>Ce(r,t).localeCompare(Ce(l,t)))}function nr(e,t,r,l,n){if(!t.startsWith("card:")||!r)return null;const d=Number(t.slice(5)),i=e.find(b=>b.id===d);if(!i)return null;const a=r.startsWith("column:")?r.slice(7):Ye(e.find(b=>`card:${b.id}`===r)??i,l.field);if(!a)return null;const u=ls(e.filter(b=>b.id!==d&&Ye(b,l.field)===a),n),o=r.startsWith("card:")?u.findIndex(b=>`card:${b.id}`===r):u.length,c=o>=0?o:u.length,m=c>0?u[c-1]:void 0,p=u[c],f=n?sr(m?Ce(m,n):void 0,p?Ce(p,n):void 0):void 0,y=_e(i.metadata),N={[l.field]:a,...n&&f?{[n.field]:f}:{}};l.states.find(b=>b.value===a)?.terminal&&!y.completed_at&&(N.completed_at=new Date().toISOString());const C={...y,...N};return{entityId:d,changedMetadata:N,nextMetadata:C}}function Lt(e,t,r){return e.map(l=>l.id===t?{...l,metadata:r}:l)}function ar({id:e,children:t,className:r}){const{setNodeRef:l,isOver:n}=ts({id:`column:${e}`});return s.jsx("div",{ref:l,className:ie("min-h-[220px] rounded-lg bg-card p-2 transition-colors",n?"bg-accent/50":"",r),children:t})}function rr({entity:e,owner:t,statusField:r,entityTypeIcon:l,schema:n,didDragRef:d}){const i=_e(e.metadata),{attributes:a,listeners:u,setNodeRef:o,transform:c,isDragging:m}=ha({id:`card:${e.id}`}),{setNodeRef:p,isOver:f}=ts({id:`card:${e.id}`}),y=qt(t,es(e)),N=v=>{d.current&&(v.preventDefault(),v.stopPropagation())};return s.jsx("div",{ref:v=>{o(v),p(v)},style:{transform:ga.Translate.toString(c)},className:ie(on,"p-3 text-sm text-muted-foreground transition-colors hover:bg-accent/50 hover:text-foreground",m?"opacity-60":"",f?"ring-1 ring-ring":""),children:s.jsxs("div",{className:"flex items-start gap-2",children:[s.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}`,...a,...u,children:s.jsx(rn,{className:"h-4 w-4"})}),s.jsx(Kt,{metadata:i,metadataSchema:n,name:e.name,typeIcon:l,className:"mt-0.5 h-6 w-6 shrink-0",initialsFallback:!0}),s.jsxs("div",{className:"min-w-0 flex-1",children:[s.jsx(ke,{to:y,className:"font-medium text-foreground hover:underline",onClick:N,children:e.name}),s.jsxs("div",{className:"mt-1 flex flex-wrap gap-1.5",children:[typeof i.priority=="string"&&i.priority?s.jsx(ze,{variant:"outline",className:"text-xs",children:We(i.priority)}):null,typeof i[r]=="string"&&i[r]?s.jsx(ze,{variant:"secondary",className:"text-xs",children:We(String(i[r]))}):null]})]})]})})}function or({owner:e,entities:t,totalCount:r,schema:l,entityTypeIcon:n,onUpdate:d}){const i=x.useMemo(()=>Ze(l),[l]),a=x.useMemo(()=>Ka(l),[l]),[u,o]=x.useState(t),[c,m]=x.useState(()=>new Set),p=x.useRef(!1),f=ua(ma(fa,{activationConstraint:{distance:6}})),y=x.useCallback(()=>{window.setTimeout(()=>{p.current=!1},0)},[]);x.useEffect(()=>{o(t)},[t]);const N=x.useMemo(()=>{if(!i)return new Map;const w=new Map(i.states.map(j=>[j.value,[]]));for(const j of u){const S=Ye(j,i.field),g=w.has(S)?S:i.states[0]?.value;g&&w.get(g)?.push(j)}for(const[j,S]of w)w.set(j,ls(S,a));return w},[u,a,i]);if(!i)return null;const v=w=>{m(j=>{const S=new Set(j);return S.has(w)?S.delete(w):S.add(w),S})},C=()=>{p.current=!0},b=w=>{const j=String(w.active.id),S=w.over?String(w.over.id):null,g=nr(u,j,S,i,a);if(!g){y();return}const{entityId:E,changedMetadata:k,nextMetadata:L}=g,K=u.find($=>$.id===E)?.metadata;o($=>Lt($,E,L)),d(E,k).catch(()=>{o($=>Lt($,E,K))}),y()};return s.jsxs("div",{className:"space-y-4",children:[s.jsxs("div",{children:[s.jsx("h2",{className:"text-base font-semibold",children:"Board"}),s.jsxs("p",{className:"text-sm text-muted-foreground",children:["Grouped by ",We(i.field),typeof r=="number"&&r>u.length?s.jsxs(s.Fragment,{children:[" · ",s.jsxs("span",{className:"text-amber-600 dark:text-amber-500",children:["showing first ",u.length," of ",r," — narrow with search"]})]}):null]})]}),s.jsx(pa,{sensors:f,onDragStart:C,onDragEnd:b,children:s.jsx("div",{className:"grid gap-3 md:grid-cols-2 xl:grid-cols-4",children:i.states.map(w=>{const j=N.get(w.value)??[],S=w.collapsed??w.terminal,g=S&&!c.has(w.value);return s.jsxs(ar,{id:w.value,children:[s.jsxs("div",{className:"mb-2 flex items-center justify-between gap-2 px-1",children:[s.jsxs("div",{className:"flex items-center gap-1.5",children:[w.terminal?s.jsx(an,{className:"h-4 w-4 text-muted-foreground"}):null,s.jsx("h3",{className:"text-sm font-medium",children:w.label})]}),s.jsxs("div",{className:"flex items-center gap-1.5",children:[s.jsx(ze,{variant:"secondary",className:"text-xs",children:j.length}),S?s.jsx(R,{type:"button",variant:"ghost",size:"sm",className:"h-6 px-1.5 text-xs",onClick:()=>v(w.value),children:g?"Show":"Hide"}):null]})]}),g?s.jsxs("p",{className:"py-4 text-center text-xs text-muted-foreground/60",children:[j.length," hidden ",w.label?.toLowerCase()," item",j.length===1?"":"s"]}):s.jsx("div",{className:"space-y-2",children:j.length>0?j.map(E=>s.jsx(rr,{entity:E,owner:e,statusField:i.field,entityTypeIcon:n,schema:l,didDragRef:p},E.id)):s.jsxs("p",{className:"py-4 text-center text-xs text-muted-foreground/60",children:["No ",w.label?.toLowerCase()," items"]})})]},w.value)})})})]})}const ir=x.memo(or);function lr(e){let t=0;for(let r=0;r<e.length;r++)t=(t<<5)-t+e.charCodeAt(r),t|=0;return t.toString(36)}function cs(e,t){return{queryKey:["metric_series",e,lr(t)],queryFn:()=>Ne("metric_series",{sql:t},{slug:e}),staleTime:6e4}}function ds(e,t){const r=!!e&&!!t,l=cs(e??"",t??"");return Pt({...l,enabled:r})}ds.queryOptions=(e,t)=>cs(e,t);function cr(e,t){if(!e?.columns?.length||!e.rows)return[];const r=e.columns.indexOf(t);return r<0?[]:e.rows.map(l=>Number(l[r])||0)}const Ot=/^[a-z][a-z0-9_]*$/;function dr(e){const t=Object.entries(e);for(const[n,d]of t){if(!Ot.test(n))throw new Error(`lifecycleCumulativeStatsSql: unsafe column name '${n}'`);if(!Ot.test(d))throw new Error(`lifecycleCumulativeStatsSql: unsafe entity_type '${d}'`)}const r=t.flatMap(([n,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 ${n}_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 ${n}_removed`]).join(`,
13
+ `),l=t.map(([n])=>` SUM(COALESCE(b.${n}_added, 0) - COALESCE(b.${n}_removed, 0))
14
+ OVER (ORDER BY d.bucket) AS ${n}`).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
+ ${r}
27
+ FROM events
28
+ WHERE created_at > now() - interval '14 days'
29
+ GROUP BY 1
30
+ )
31
+ SELECT d.bucket,
32
+ ${l}
33
+ FROM days d
34
+ LEFT JOIN buckets b ON b.bucket = d.bucket
35
+ ORDER BY d.bucket
36
+ `}const ur={"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 mr(e){if(typeof e.sql=="string"&&e.sql.trim())return e.sql;if(e.lifecycle&&typeof e.lifecycle=="object"){const t=Object.fromEntries(Object.entries(e.lifecycle).map(([r,l])=>[r,String(l)]));if(Object.keys(t).length>0)try{return dr(t)}catch{return null}}return typeof e.preset=="string"?ur[e.preset]??null:null}function pr({owner:e,sql:t,lifecycle:r,preset:l,column:n,chart:d,height:i,width:a,color:u,label:o,className:c}){const m=x.useMemo(()=>mr({sql:t,lifecycle:r,preset:l}),[t,r,l]),p=typeof e=="string"&&e?e:null,{data:f}=ds(p,m),y=String(n??""),N=x.useMemo(()=>cr(f,y),[f,y]),v=x.useMemo(()=>!f?.columns?.length||!f.rows?[]:f.rows.map((b,w)=>({label:String(b[0]??"").slice(0,10),value:N[w]??0})),[f,N]);if(!p||!m||!y)return null;const C=d==="line"?s.jsx(la,{data:v,height:typeof i=="number"?i:void 0}):s.jsx(ca,{data:N,height:typeof i=="number"?i:void 0,width:typeof a=="number"?a:void 0,color:typeof u=="string"?u:void 0});return o==null?s.jsx("div",{className:c,children:C}):s.jsxs("div",{className:c,children:[s.jsx("p",{className:"text-sm text-muted-foreground",children:String(o)}),C]})}function fr({metadata:e,metadataSchema:t,name:r,typeIcon:l,initialsFallback:n,className:d}){return s.jsx(Kt,{metadata:e,metadataSchema:t,name:String(r??""),typeIcon:l,initialsFallback:!!n,className:d})}function hr({entity:e,owner:t,className:r,onClick:l,children:n}){const d=e;if(!d)return s.jsx(s.Fragment,{children:n});const i=qt(String(t??""),es(d));return s.jsx(ke,{to:i,className:r,onClick:l,children:n})}function gr({state:e}){return e?s.jsx(Zn,{...e}):null}function yr({state:e,onUpdate:t}){return e?s.jsx(ir,{...e,onUpdate:t}):null}const xr={"entity-avatar":fr,"entity-link":hr,"entity-table":gr,"entity-board":yr,"metric-series":pr};function br({ownerSlug:e,typeSlug:t,title:r,shape:l}){const[n,d]=x.useState(!1),i=ne(),{visible:a,system:u,isTypesLoading:o}=ln(e),c=p=>{d(!1);const f=`/${e}/${Wt(p)}`;i({to:l?`${f}/${Yt}/${l}`:f})},m=p=>s.jsxs(hn,{value:`${p.name} ${p.slug}`,onSelect:()=>c(p.slug),children:[s.jsx(Jt,{icon:p.icon,className:"mr-2 h-4 w-4 shrink-0"}),s.jsx("span",{className:"flex-1 truncate",children:p.name||p.slug}),p.slug===t?s.jsx(gn,{className:"ml-2 h-3.5 w-3.5 shrink-0","aria-label":"Current"}):null,p.entity_count!=null?s.jsx("span",{className:"ml-2 shrink-0 text-xs tabular-nums text-muted-foreground",children:p.entity_count.toLocaleString()}):null]},p.slug);return s.jsxs(Ht,{open:n,onOpenChange:d,children:[s.jsx("h1",{className:"flex min-w-0 items-center text-lg font-semibold tracking-tight @sm:text-2xl",children:s.jsx(Ut,{asChild:!0,children:s.jsxs(R,{type:"button",variant:"ghost",title:r,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:[s.jsx("span",{className:"truncate",children:r}),s.jsx(zt,{className:"h-5 w-5 shrink-0 text-muted-foreground"})]})})}),s.jsx(Gt,{align:"start",className:"w-72 p-0",children:s.jsxs(cn,{children:[s.jsx(dn,{autoFocus:!0,placeholder:"Find a type…"}),s.jsxs(un,{children:[s.jsx(mn,{children:o?"Loading types…":"No type matches."}),a.length>0?s.jsx(Ct,{heading:"Types",children:a.map(m)}):null,u.length>0?s.jsx(Ct,{heading:"System",children:u.map(m)}):null]}),s.jsx(pn,{}),s.jsxs(ke,{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:[s.jsx(fn,{className:"h-4 w-4"}),"Data map"]})]})})]})}function vr(e){return Object.entries(e?.metrics_config?.segments??{}).filter(([,t])=>t.on==="entity").map(([t,r])=>({name:t,description:r.description}))}const be={table:{label:"Table",icon:En},board:{label:"Board",icon:Cn},graph:{label:"Graph",icon:Bt}},us=(e,t)=>`lobu.record-shape:v1:${e}/${t}`,jr=new Set(["table","board","graph"]);function Nr(e,t){const r=_n(us(e,t));return r&&jr.has(r)?r:void 0}function Sr(e,t,r){$n(us(e,t),r)}const Mt=":records";function wr({ownerSlug:e,entityTypeSlug:t,create:r,onCreateChange:l,viewKey:n,shape:d}){const{orgContext:i,hasOrgContext:a}=Ee(),u=Tt(t,i),{data:o,isLoading:c,error:m}=u;yn(`/${e}`,i);const p=xn(),[f,y]=x.useState({key:"",page:0}),N=Qt({strict:!1}),v=ne(),C=Dt(),b=`/${e}/${Wt(t)}`,{session:w,isReady:j}=bn(),S=j&&!c&&o?.slug===t,g=w?.user?.email,E=x.useMemo(()=>g?{email:g}:void 0,[g]),{collection:k,error:L,presentation:M,presets:K,preset:$,edited:le,table:I}=x.useMemo(()=>Ea(N,o?.metadata_schema,!!n,E),[N,o?.metadata_schema,n,E]),z=S?L:void 0,G=x.useMemo(()=>La(N,k),[N,k]),[ms,Ke]=x.useState(!1),[$e,ps]=x.useState(0),Re=k.search??"",X=k.segment,fs=JSON.stringify(k),ae=X?vr(o).find(h=>h.name===X)??{name:X,description:""}:null,hs=h=>void v({to:".",search:_=>({...Ge(_,Z(h)),...G}),replace:!0}),J=vn(u.data),Xe=J?I.sort:Ma(I),Le=Xe?.field,et=Xe?.order,W=x.useMemo(()=>Le?[{id:Le,desc:et==="desc"}]:[],[Le,et]),ce=x.useCallback(h=>void v({to:".",search:{...n?Z(N):{},...G,$table:JSON.stringify(h)},replace:!0}),[v,n,N,G]),tt=x.useCallback(h=>{const _=typeof h=="function"?h(W):h;_[0]&&ce({...I,sort:{field:_[0].id,order:_[0].desc?"desc":"asc"}})},[W,ce,I]),de=r===!0,st=()=>l(!0),gs=()=>l(!1),ys=W[0]?.id,xs=W[0]?W[0].desc?"desc":"asc":void 0,Oe=u.data?.metadata_schema,ue=!!Ze(Oe)&&!J,bs=Xa(Oe,{isDerived:J}),P=Zt(i),vs=Be(P.data??[],t,k),re=(h,_=!1,A=Z(N))=>{const T=!n||!P.data||Be(P.data,t,h).some(ye=>ye.key===n);v({to:T?".":b,search:{...T&&n?A:{},...ka(h,$?.key),$table:JSON.stringify(I)},replace:_})},me=h=>{const _=h?je(h,void 0,E):{},A=!n||Be(P.data??[],t,_).some(T=>T.key===n);Ke(!1),ps(T=>T+1),v({to:A?".":b,search:h?{$preset:h.key}:{}})},{isAdmin:js}=jn(i.organizationId),Me=Nn(i),Ns=js&&!!o&&!u.isPlaceholderData,nt=x.useRef(N);nt.current=N;const Ss=async()=>{if(!$)return;const h=JSON.stringify(N),{data:_}=await u.refetch(),A=_?.metadata_schema,T=A?Qe(A[Ue]??{}):void 0,ye=T?.presets?.find(xe=>xe.key===$.key);if(!_||!A||!T||!ye){It.error("This saved filter changed. Reload and try again.");return}const De=_a(ye,k,I,T,void 0,E);await Me.mutateAsync({slug:_.slug,metadata_schema:{...A,[Ue]:{...T,presets:T.presets?.map(xe=>xe.key===De.key?De:xe)}}}).then(()=>!0,()=>!1)&&(await u.refetch(),JSON.stringify(nt.current)===h&&me(De))},ws=x.useMemo(()=>Nr(e,t),[e,t]),D=Sn(P.data??[],t,{viewKey:n,shape:d??(n?void 0:ws)},bs,k),V=D.kind==="builtin"?D.mode==="board"&&!ue?"table":D.mode:null,at=V==="graph";x.useEffect(()=>{d&&S&&V&&Sr(e,t,V)},[d,S,V,e,t]);const rt=["table",...ue?["board"]:[],"graph"],Y=D.kind==="view"?D.view:null,ot=D.kind==="missing"?D.key:null,Te=D.kind==="inapplicable"?D:null,oe=V==="table"?50:200,pe=`${t}?${fs}&sort=${JSON.stringify(I.sort)}&size=${oe}`,fe=f.key===pe?f.page:0,Ie=x.useCallback(h=>y(_=>({key:pe,page:h(_.key===pe?_.page:0)})),[pe]),he=Et(t,i,{limit:oe,offset:fe*oe,search:Re.trim()||void 0,sortBy:ys,sortOrder:xs,segment:X,filters:k.filters,enabled:S&&!n&&!z}),it=Et(t,i,{limit:1,offset:0,parentId:null,search:Re.trim()||void 0,segment:X,filters:k.filters,enabled:S&&!n&&!z&&!J}),{data:ge,error:Cs}=he,Es=he.isLoading||he.isPending&&he.fetchStatus==="paused",lt=z||m||(n?null:Cs),ks=!!n&&P.data===void 0&&P.isError,B=ge?.entities??[],Ae=ge?.metadata?.has_more??!1,F=ge?.metadata?.total_count??0,ct=B.length>0||Re.trim().length>0||fe>0||!!X||!!k.filters?.length,O=o?.name?.trim()||qe(t),ee=o?.icon||void 0,q=J,U=Oe,_s=!z&&(!a||!S||(n?P.data===void 0&&!P.isError:Es||!J&&it.isLoading)),dt=ge?.linked_entities??{},ut=it.data?.metadata?.total_count,mt=F>0&&typeof ut=="number"?ut<F:!1,pt=x.useMemo(()=>o?.measure_columns??[],[o?.measure_columns]),ft=x.useCallback(h=>ce({...I,columns:h}),[ce,I]),ht=x.useMemo(()=>({entities:B,owner:e,schema:U,entityTypeIcon:ee,isDerived:q,measureColumns:pt,linkedEntityLookups:dt,hasAnyParents:mt,sorting:W,onSortingChange:tt,visibleColumns:I.columns,columnChoices:Kn(U,q,B),onVisibleColumnsChange:ft,page:fe,pageSize:oe,totalCount:F,hasMore:Ae,pageTitle:O,onPrevPage:()=>Ie(h=>Math.max(0,h-1)),onNextPage:()=>Ie(h=>h+1)}),[B,e,U,ee,q,pt,dt,mt,W,I.columns,ft,tt,Ie,fe,oe,F,Ae,O]),gt=F>B.length,yt=`showing first ${B.length} of ${F} — narrow with search`,xt=x.useMemo(()=>({owner:e,entityType:o,entities:B,totalCount:F,schema:U,entityTypeIcon:ee}),[e,o,B,F,U,ee]),Pe=x.useMemo(()=>({tableState:ht,boardState:xt,owner:e,schema:U,entityType:o,entityTypeIcon:ee,totalCount:F,isTruncated:gt,truncationNotice:yt,canCreate:!q,addLabel:`Add ${o?.name||qe(t)}`}),[ht,xt,e,U,o,ee,F,gt,yt,q,t]),$s=x.useMemo(()=>tr({canShowBoard:ue,builtinData:Pe,builtInLabels:{table:be.table.label,board:be.board.label}}),[ue,Pe]),bt=V?$s.find(h=>h.id===V)??null:null,Rs=bt?.template??is,Ls=bt?.data??Pe,vt=h=>void v({to:h===Mt?b:`${b}${Je(h)}`,search:G}),Fe=Z(N),Os=ya(Y?.params,Fe,h=>void v({to:".",search:{...Z(h),...G}})),Ms=()=>re({...k,filters:[],segment:void 0},!1,xa(Y?.params,Fe)),jt={collection:k,schema:U,label:O,org:i??"",facetQuery:M.facetQuery,onChange:re,viewFilters:Os,onClearAll:Ms,segmentChip:ae?{id:"segment",label:"Segment",op:"is",value:qe(ae.name),title:ae.description||void 0,editor:ae.description?{kind:"custom",render:()=>s.jsx("p",{className:"p-3 text-sm text-muted-foreground",children:ae.description})}:void 0,onRemove:()=>re({...k,segment:void 0})}:void 0},Nt=`Moved on ${o?.name||o?.slug||t} board`,St=x.useMemo(()=>(h,_)=>p.mutateAsync({entityId:h,metadata:_,field_note:Nt}),[p,Nt]),Ts=x.useMemo(()=>({updateEntity:St,openCreate:()=>l(!0)}),[St,l]),wt=h=>C?s.jsx("span",{className:h,children:s.jsx(R,{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:()=>C.open({href:Ln(e,t),title:O}),children:s.jsx(Rn,{className:"h-4 w-4"})})}):null;return s.jsx(Xn,{title:s.jsx(br,{ownerSlug:e,typeSlug:t,title:O,shape:n?null:V}),actions:wt("hidden @sm:contents"),controls:s.jsxs(s.Fragment,{children:[de?s.jsx("div",{className:"max-w-3xl",children:s.jsx(ja,{onClose:gs,entityTypeSlug:t,orgContext:i})}):null,!de&&S&&s.jsxs("nav",{className:"mb-4 flex flex-wrap items-center gap-x-3 gap-y-2","aria-label":`${O} views`,children:[wt("-mr-1 @sm:hidden"),!n&&rt.length>1&&s.jsx("fieldset",{className:"flex items-center rounded-md border p-0.5","aria-label":"Record layout",children:rt.map(h=>{const _=be[h].icon,A=V===h;return s.jsx(R,{type:"button",variant:"ghost",size:"sm","aria-pressed":A,title:be[h].label,"data-testid":`shape-${h}`,className:ie("h-7 px-2",A&&"bg-accent text-accent-foreground"),onClick:()=>void v({to:`${b}/${Yt}/${h}`,search:G,replace:!0}),children:s.jsx(_,{className:"h-4 w-4"})},h)})}),n&&s.jsx(R,{variant:"ghost",onClick:()=>vt(Mt),children:"Records"}),!!K.length&&s.jsxs(Ht,{open:ms,onOpenChange:Ke,children:[s.jsx(Ut,{asChild:!0,children:s.jsxs(R,{variant:"outline",className:ie("gap-2",le&&"border-dashed border-primary"),"data-edited":le||void 0,title:"Choose saved filter",children:[$?.label??(k.filters?.length||k.search?"Custom filter":"All records"),le?s.jsx("span",{className:"text-xs font-normal text-primary",children:"Edited"}):null,s.jsx(zt,{className:"h-4 w-4 text-muted-foreground"})]})}),s.jsxs(Gt,{align:"start",className:"w-60 p-1",children:[s.jsx(R,{variant:$?"ghost":"secondary",className:"w-full justify-start",onClick:()=>me(),children:"All records"}),K.map(h=>s.jsx(R,{variant:$?.key===h.key?"secondary":"ghost",className:"w-full justify-start",onClick:()=>me(h),children:h.label},h.key))]})]}),$&&le?s.jsxs("div",{className:"-ml-2 mr-2 inline-flex items-center gap-1",children:[s.jsx(R,{variant:"ghost",size:"sm",onClick:()=>me($),children:"Reset"}),Ns?s.jsx(R,{size:"sm",disabled:Me.isPending,onClick:()=>void Ss(),children:Me.isPending?"Saving…":"Save"}):null]}):null,vs.map(h=>s.jsx(R,{"data-testid":`tab-${h.key}`,variant:n===h.key?"secondary":"ghost","aria-pressed":n===h.key,onClick:()=>vt(h.key),children:h.name},h.key)),!z&&s.jsx(Fa,{...jt},`filters:${t}:${$e}`),s.jsxs("div",{className:"ml-auto flex flex-wrap items-center justify-end gap-x-3 gap-y-2",children:[s.jsx(Aa,{label:O,search:k.search,onSearch:(h,_)=>re({...k,search:h},_),className:"w-64 max-w-full"},`search:${t}:${$e}`),!q&&!n?s.jsxs(R,{size:"sm","aria-label":`Add ${O||"entity"}`,onClick:()=>st(),children:[s.jsx(kn,{className:"mr-2 h-4 w-4"}),"Add"]}):null]})]}),!de&&S&&!z?s.jsx(Da,{...jt},`applied:${t}:${$e}`):null]}),children:de?null:_s?at?s.jsx(Xt,{label:`Loading ${O} graph`}):s.jsx(ea,{}):lt?s.jsxs("div",{role:"alert",className:"rounded-lg border border-destructive/30 bg-destructive/5 px-4 py-6 text-sm text-destructive",children:[lt.message||`Failed to load ${O.toLowerCase()}.`,z&&s.jsx(R,{variant:"outline",size:"sm",className:"ml-3",onClick:()=>re({}),children:"Clear filters"})]}):ks?s.jsx(ss,{onRetry:()=>void P.refetch()}):Te?s.jsxs("div",{className:"flex flex-col items-center justify-center py-16 text-center","data-testid":"inapplicable-view",children:[s.jsxs("h2",{className:"text-lg font-semibold",children:["“",Te.view.name,"” doesn’t apply to the current filters"]}),s.jsxs("p",{className:"text-muted-foreground mt-2 text-sm",children:["It appears when the selection includes"," ",Object.entries(Te.when).map(([h,_])=>`${h} is ${_===null?"not supplied":String(_)}`).join(" and "),"."]}),s.jsx(ke,{to:b,search:G,className:"mt-4 text-sm font-medium underline underline-offset-4",children:`Back to ${O}`})]}):ot?s.jsx(ns,{viewKey:ot,backTo:b,backLabel:`Back to ${O}`}):Y?s.jsx(as,{orgSlug:e,viewKey:Y.key,scope:{type:t,collection:k},params:Fe,onParamsChange:hs,paramDecls:Y.params,contentHash:Y.content_hash,title:Y.name,minHeight:320}):at&&ct?s.jsx(Qa,{ownerSlug:e,typeSlug:t,sourceBacked:J,records:B.map(h=>({...h,id:h.id??JSON.stringify([h.entity_type,h.slug])})),hasMore:Ae}):ct?s.jsx(da,{template:Rs,data:Ls,actions:Ts,components:xr}):s.jsx(Vt,{icon:wn,iconElement:s.jsx(Jt,{icon:o?.icon,className:"mb-4 h-12 w-12 opacity-50"}),title:`No ${O.toLowerCase()} yet`,description:q?"This view has no rows yet. They appear as the underlying data arrives.":`Get started by creating your first ${o?.name?.toLowerCase()||"entity"}.`,actionLabel:q?void 0:`Add ${o?.name||"Entity"}`,onAction:q?void 0:()=>st()})})}function Cr(e,t){return ie("inline-flex items-center justify-center rounded-md font-medium transition-colors focus-visible:outline-none focus-visible:ring-1 focus-visible:ring-ring",t,e?"bg-secondary text-secondary-foreground":"text-muted-foreground hover:bg-accent hover:text-accent-foreground")}const Er=12,kr=50;function _r({navigation:e,views:t,currentKey:r}){const l=ne(),[n,d]=x.useState(""),i=x.useMemo(()=>e.filter(c=>!c.external&&c.href.includes("/-/views/")),[e]),a=On(i,t,n,n.trim()?kr:Er),u=Mn(i,t,n),o=c=>{c.key==="Enter"&&a[0]&&(c.preventDefault(),l({href:a[0].href}))};return s.jsxs("nav",{"aria-label":"Workspace views",className:"flex shrink-0 flex-col gap-2",children:[s.jsx(se,{type:"search","aria-label":"Find a view",placeholder:"Find a view",value:n,onChange:c=>d(c.target.value),onKeyDown:o,className:"h-8 max-w-sm"}),a.length>0?s.jsx("ul",{className:"flex flex-wrap items-center gap-1",children:a.map(c=>{const m=c.key===r;return s.jsx("li",{children:s.jsxs(Tn,{item:{id:c.key,label:c.label,href:c.href,children:[]},active:m,className:Cr(m,"min-h-8 max-w-full gap-2 px-3 text-sm break-words"),children:[s.jsx("span",{children:c.label}),c.trail.length>0&&c.trail[0]!=="Views"?s.jsx("span",{className:"ml-1.5 text-xs text-muted-foreground",children:c.trail.join(" › ")}):null]})},c.key)})}):s.jsxs("p",{role:"status",className:"text-sm text-muted-foreground",children:["No view matches “",n.trim(),"”."]}),u>a.length?s.jsxs("p",{role:"status",className:"text-xs text-muted-foreground",children:["Showing ",a.length," of ",u,". Type to narrow the list."]}):null]})}function $r({ownerSlug:e,typeScope:t,create:r,viewKey:l,shape:n}){const d=ne(),i=Qt({strict:!1}),a=t?In(t):void 0,u=a==="$member",o=m=>{if(!a)return;const p=Un(e,a);d({to:p.to,params:p.params,search:m?{create:!0}:{},replace:!0})},c=a?s.jsx(wr,{ownerSlug:e,entityTypeSlug:a,create:r,onCreateChange:o,viewKey:l,shape:n}):l?s.jsx(Rr,{ownerSlug:e,viewKey:l,search:i}):null;return s.jsx("div",{className:"flex min-h-0 min-w-0 flex-1 flex-col gap-4",children:u?s.jsx(va,{children:c}):c})}function Rr({ownerSlug:e,viewKey:t,search:r}){const l=ne(),{orgContext:n}=Ee(),{data:d,isError:i,error:a,refetch:u}=Zt(n),o=An(n),c=Pn(e,`/${e}/data`),m=Fn(d??[],t),p=Dn(),f=Vn(d??[]),y=i?Bn(a,{subject:"Views"}):null;if(d===void 0)return i?s.jsx(ss,{error:a,onRetry:()=>void u()}):null;if(m.kind==="missing")return s.jsx(ns,{viewKey:m.key,backTo:`/${e}`,backLabel:"Back to Home"});const N=qn(o.data??[]),v=f.some(b=>!N.has(`/${e}/data${Je(b.key)}`)),C=f.length>0&&(p||o.data!==void 0&&v);return s.jsxs("div",{className:"flex min-h-0 min-w-0 flex-1 flex-col gap-4",children:[C?s.jsx(_r,{navigation:c.navigation,views:c.views,currentKey:Hn(`/${e}/data${Je(t)}`,r)}):null,p&&y?s.jsxs("p",{role:"status",className:"text-sm text-muted-foreground",children:[y.title,"."," ",y.retryable?s.jsx("button",{type:"button",onClick:()=>void u(),className:"underline underline-offset-4",children:"Retry"}):null]}):null,s.jsx(ba,{decls:m.view.params,params:Z(r),onParamsChange:b=>void l({to:".",search:w=>Ge(w,b)})}),s.jsx(as,{orgSlug:e,viewKey:m.view.key,scope:{},params:Z(r),onParamsChange:b=>void l({to:".",search:w=>Ge(w,b),replace:!0}),paramDecls:m.view.params,contentHash:m.view.content_hash,title:m.view.name,minHeight:400})]})}function qr({ownerSlug:e,typeScope:t,create:r,viewKey:l,shape:n}){return s.jsxs(zn,{inset:l?"flush":"page",className:l?"gap-0 pt-0 pb-0":"gap-6 pt-2.5 pb-8",children:[s.jsx(Jn,{}),s.jsx(Gn,{owner:e,children:d=>s.jsx("div",{className:"flex min-h-0 min-w-0 flex-1 flex-col",children:s.jsx($r,{ownerSlug:d.ownerSlug,typeScope:t,create:r,viewKey:l,shape:n})})})]})}export{qr as M};
74
+ //# sourceMappingURL=memory-browse-page-DvDtwrEI.js.map
@@ -1,2 +1,2 @@
1
- import{aJ as v,aK as N,j as s,gF as y,dq as m,a4 as p,i as f,B as w,gH as b}from"./index-C2TCKJDP.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-BrfaDwIg.js.map
1
+ import{aW as v,aX as N,j as s,gO as y,aO as m,a9 as p,i as f,B as w,gQ as b}from"./index-DByaMzsG.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-D3vSMLO2.js.map
@@ -0,0 +1,2 @@
1
+ import{r as N,j as e,ep as I,eq as $,er as B,es as b,M as S,et as E,eu as _,ev as f,B as O,a9 as P,by as j}from"./index-DByaMzsG.js";const T=5,Y=5;function D({entries:s,onMarkRead:t,disabled:o=!1}){const n=s.filter(r=>r.unreadIds.length>0);return n.length===0?null:e.jsxs("button",{type:"button",disabled:o,className:"ml-auto inline-flex items-center gap-1 text-xs text-muted-foreground hover:text-foreground",onClick:()=>t(n.flatMap(r=>r.unreadIds)),children:[e.jsx($,{"aria-hidden":"true",className:"h-3.5 w-3.5"}),"Mark ",n.length," read"]})}function q({owner:s,entries:t,pageIds:o,onMarkRead:n,markPending:r}){const[u,x]=N.useState(!1);if(t.length===0)return null;const a=u?t:t.slice(0,Y),d=t.length-a.length,p=i=>{const c=o.has(i.item.id)?"This page":w(i);return c?`Needs you · ${c}`:"Needs you"};return e.jsxs("ul",{"aria-label":"Needs you",className:"mb-4 divide-y overflow-hidden rounded-lg border",children:[t.length>1?e.jsxs("li",{className:"flex flex-wrap items-center gap-2 px-3 py-1.5",children:[e.jsxs("span",{className:"text-xs text-muted-foreground tabular-nums",children:[t.length," need you"]}),e.jsx(D,{entries:t,onMarkRead:n,disabled:r}),e.jsx(I,{owner:s,showMarkRead:!1})]}):null,e.jsx(y,{owner:s,entries:a,tag:p}),d>0?e.jsx("li",{children:e.jsxs("button",{type:"button",className:"w-full px-3 py-2 text-left text-xs text-muted-foreground hover:bg-muted/40 hover:text-foreground",onClick:()=>x(!0),children:["Show all ",t.length]})}):null]})}function F({owner:s,entries:t}){return t.length===0?null:e.jsx("ul",{className:"divide-y overflow-hidden rounded-lg border",children:e.jsx(y,{owner:s,entries:t,tag:w})})}const w=s=>s.repeats>1?`${s.repeats}×`:void 0;function y({owner:s,entries:t,tag:o}){return B(t).map(n=>e.jsx("li",{children:n.entries.length>1?e.jsx(z,{owner:s,group:n}):e.jsx(b,{owner:s,item:n.entries[0].item,variant:"row",tag:o(n.entries[0])})},n.key))}function z({owner:s,group:t}){const[o,n]=N.useState(!1),{orgContext:r}=S(),u=E(),x=_(r),{entries:a}=t,d=a[0],p=a[a.length-1],i=new Set(a.map(({card:l})=>l.run_id)).size,c=o?a:a.slice(0,T),g=a.length-c.length,m=a.flatMap(({item:l})=>l.approvalRunId!=null?[l.approvalRunId]:[]),k=u.isPending||x.isPending,R=d.card.automation_name?.trim(),A=d.card.at===p.card.at?f(d.card.at):`${f(p.card.at)} – ${f(d.card.at)}`,M=async()=>{const l=await u.mutateAsync({decision:"approve",runIds:m}),C=new Set(l.failedRunIds),v=a.flatMap(({item:h})=>h.approvalRunId!=null&&!C.has(h.approvalRunId)&&h.notificationId!=null?[h.notificationId]:[]);v.length>0&&await x.mutateAsync(v),l.failed>0?j.error(`${l.succeeded} approved; ${l.failed} failed.`):j.success(`${l.succeeded} approved.`)};return e.jsxs("section",{"aria-label":`${a.length} approvals`,className:"min-w-0",children:[e.jsxs("div",{className:"flex flex-wrap items-baseline gap-x-2 gap-y-0.5 px-3 pt-2.5 pb-1.5",children:[e.jsxs("h3",{className:"text-sm font-medium",children:[a.length," approvals waiting"]}),e.jsxs("p",{className:"text-xs text-muted-foreground",children:["Proposed by ",R??"this Automation"," ·"," ",i===1?"1 run":`${i} runs`," · ",A]})]}),e.jsx("ul",{className:"divide-y border-t",children:c.map(l=>e.jsx("li",{children:e.jsx(b,{owner:s,item:l.item,variant:"row",showMark:!1})},l.item.id))}),e.jsxs("div",{className:"flex flex-wrap items-center gap-2 border-t px-3 py-2 text-xs",children:[g>0?e.jsxs("button",{type:"button",className:"text-muted-foreground hover:text-foreground",onClick:()=>n(!0),children:[g," more · Review all"]}):null,m.length>1?e.jsxs(O,{type:"button",size:"sm",className:"ml-auto h-7 text-xs",disabled:k,onClick:()=>void M(),children:[e.jsx(P,{className:"mr-1 h-3 w-3"}),"Approve all ",m.length]}):null]})]})}export{D as M,q as N,F as a};
2
+ //# sourceMappingURL=needs-you-list-B5Bgd05M.js.map
@@ -0,0 +1,2 @@
1
+ import{c as S,n as C,cK as k,aU as A,s as T,r as g,j as e,at as L,au as P,ds as B,L as f,dt as R,dj as $,m as p,dz as w,aS as I}from"./index-DByaMzsG.js";import{C as O,A as D}from"./create-automation-form-CLicoPH5.js";import"./entity-options-B9hm9V87.js";import"./use-automations-CgWNoYio.js";import"./device-automation-Dp3faMvp.js";import"./model-selector-D3vSMLO2.js";import"./skill-editor-D_W3QlRz.js";import"./code-editor-mrKkAfcE.js";import"./index-Vcq4gwWv.js";import"./json-diff-mcDgyct_.js";import"./use-mention-search-D-kIKchD.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:a}=C(),[i,d]=g.useState({ready:!1,triggers:[]}),[u,j]=g.useState(),o=g.useCallback(s=>{d(m=>JSON.stringify(m)===JSON.stringify(s)?m:s)},[]),r=u??l;return e.jsx(O,{startFromScratch:!!l,organizationId:a?.id??"",prefillAgentId:n,conversationSetup:h,onClose:t,onPrefillTriggers:s=>j(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(D,{organizationId:a?.id??null,initialTriggers:r,onChange:o},JSON.stringify(r??"new"))})}function z({owner:n,prefilled:t}){const l=S(),{org:h}=C(),a=k(h?.id??null,{status:"active",limit:500}),i=A(h?.id??null),{data:d=[]}=T(),u=!!(t?.platform&&(t.listen||t.resource)),j=u&&(a.isLoading||i.isLoading),o=g.useMemo(()=>{if(!t?.platform||!t.listen&&!t.resource)return;const x=a.data??[],N=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&&!N)return;const b=t.events?.split(",").map(c=>c.trim()).filter(Boolean)??[];return[{kind:"event",source:"connector",connector_key:t.platform,...N?{connection_id:N.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}]},[a.data,t]),r=i.data?.find(x=>x.key===t?.platform)?.name,s=t?.label??t?.listen,m=g.useMemo(()=>t?.listen&&o&&s?{name:r?`${r}: ${s}`:s}:void 0,[s,r,o,t?.listen]),y=()=>void l({to:"/$owner",params:{owner:n},search:{section:"automation"}}),_=o?t?.resource?`React to changes on ${t.label??t.resource}.`:`React to messages in ${t?.label??t?.listen}.`:u&&!a.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(f,{to:"/$owner",params:{owner:n},search:{section:"automation"},className:R,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($,{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:_}),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(f,{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,j?e.jsxs("div",{className:"space-y-3",children:[e.jsx(p,{className:"h-10 w-full"}),e.jsx(p,{className:"h-32 w-full"})]}):u&&t?.connection&&!o?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:y,initialTriggers:o,conversationSetup:m})]})})}function Z(){const{owner:n}=w.useParams(),t=w.useSearch();return e.jsx(I,{owner:n,children:()=>e.jsx(z,{owner:n,prefilled:t})})}export{Z as component};
2
+ //# sourceMappingURL=new-BPW3V0Y1.js.map
@@ -0,0 +1,2 @@
1
+ import{i3 as o,c as l,y as x,H as h,n as b,s as w,j as a,at as j,au as A,dr as L,bd as f,ds as C,L as N,dt as S,dv as y,bc as k,c6 as E}from"./index-DByaMzsG.js";import{A as O}from"./agent-editor-form-DlavYg2q.js";import"./definition-comparison-4UYMI6BK.js";import"./json-diff-mcDgyct_.js";import"./code-editor-mrKkAfcE.js";import"./index-Vcq4gwWv.js";import"./schema-value-zTJGE4eh.js";import"./model-selector-D3vSMLO2.js";function W(){const{owner:e}=o.useParams(),t=o.useSearch(),r=l(),i=x(),{isAuthenticated:c}=h(),{isMember:m,isLoading:g}=b(),n=c&&m,{data:d=[],isLoading:u}=w({enabled:n});return a.jsx(j,{className:"gap-3 pt-2.5 pb-8",children:a.jsxs(A,{className:"flex flex-1 flex-col gap-6",children:[a.jsx(L,{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(y,{rows:1}):n?a.jsx(O,{mode:{kind:"create"},existingAgentIds:d.map(s=>s.agentId),onCreated:async s=>{const p=["agents",e];if(await i.refetchQueries({queryKey:p,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(k,{icon:E,title:"Workspace membership required",description:"Only workspace members can build managed agents."})]})})}export{W as component};
2
+ //# sourceMappingURL=new-Bk_flKQO.js.map
@@ -0,0 +1,2 @@
1
+ import{dn as s,M as n,c as r,j as t,at as p,au as i}from"./index-DByaMzsG.js";import{E as m}from"./entity-type-page-CkQm0yEu.js";import"./event-kind-options-fHAIXu24.js";import"./code-editor-mrKkAfcE.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-C5HtQdM_.js.map
@@ -0,0 +1,2 @@
1
+ import{c as z,H as F,Y as L,r,j as e,Z as v,$ as S,B as U,a0 as N,a1 as E}from"./index-DByaMzsG.js";import{C as A,a as I,b as T,c as $}from"./card-DtLIFq7D.js";import{F as k}from"./full-page-spinner-CYyCnKve.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-dLXsCHBd.js.map
@@ -0,0 +1,2 @@
1
+ import{y as ge,r as v,bM as Ie,bN as Be,bO as Ke,bP as Me,K as be,j as e,bQ as Y,B as N,bR as Ve,bc as Ue,bS as Ge,bT as He,bU as Ye,bV as Ze,bW as Je,bX as Xe,bY as es,E as ve,by as ie,bZ as ss,b_ as ts,b$ as ns,c0 as me,c1 as is,c2 as as,c as os,ad as We,M as rs,c3 as cs,c4 as ne,c5 as ls,Z as je,$ as Ne,c6 as ds,c7 as us,c8 as ms,al as Ce,c9 as hs,m as P,a0 as le,ca as ps,cb as _e,cc as ke,cd as gs,a1 as xs,ce as Se,at as fs,au as ys,S as bs,i as vs,cf as js}from"./index-DByaMzsG.js";import{P as he,a as De,A as Ns}from"./agent-permissions-matrix-C1L8IcYR.js";import{C as we,a as Ae,b as Oe,c as Pe}from"./card-DtLIFq7D.js";const ze=["auto","approval","deny"],Cs={matched_rule:"Matching policy rules apply.",default_approval:"No rule matches; approval is required.",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."},Le={read:"Reads",write:"Writes",destructive:"Destructive writes",non_destructive:"Non-destructive writes",unknown:"Unclassified writes"};function pe(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 de=s=>JSON.stringify(pe(s)),$e=s=>({...s,effect:s.effects.execute??"approval"});function F({label:s,value:n,onChange:a,children:c,disabled:h}){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=>a(r.target.value),disabled:h,className:"h-9 w-full rounded-lg border bg-background px-2 text-foreground",children:c})]})}function _s(s,n){const a=n.connections?.find(c=>c.id===s.connection_id);return s.connection_id?`Connection: ${a?.display_name||a?.connector_key||"Unavailable"} (#${s.connection_id})`:s.connector_key?`Connector: ${n.connectors?.find(c=>c.key===s.connector_key)?.name||s.connector_key}`:"All connectors"}function ks(s,n){return s.operation_key?n.connector_operations.find(a=>a.operation_key===s.operation_key)?.name||s.operation_key:s.operation_category?Le[s.operation_category]:"All actions"}function ue(s,n){return`${_s(s,n)} · ${ks(s,n)}`}function Ee(s){return s.connection_id?`connection:${s.connection_id}`:s.connector_key?`connector:${s.connector_key}`:"all"}function Te({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 Ss({label:s,ariaLabel:n,disabled:a,onRemove:c}){const[h,r]=v.useState(!1);return h?e.jsxs("div",{className:"flex gap-1",children:[e.jsx(N,{type:"button",variant:"destructive",size:"sm",disabled:a,"aria-label":"Confirm removal",onClick:async()=>{await c()&&r(!1)},children:"Confirm"}),e.jsx(N,{type:"button",variant:"ghost",size:"sm",disabled:a,onClick:()=>r(!1),children:"Cancel"})]}):e.jsx(N,{type:"button",variant:"ghost",size:"sm",disabled:a,"aria-label":n,onClick:()=>r(!0),children:s})}function ws({owner:s,connector:n,connection:a,agent:c}){const h=ge(),[r,y]=v.useState(c??""),C=Ie(s),l=C.data,u=l?.agents.some(t=>t.id===r)?r:"",m=Be(s,u),i=Ke(s,!u),[z,_]=v.useState(a?`connection:${a}`:n?`connector:${n}`:"all"),[M,Z]=v.useState(z),[I,W]=v.useState(!1),[k,D]=v.useState(""),[A,V]=v.useState("all"),[J,E]=v.useState("approval"),[g,S]=v.useState(!1),[L,T]=v.useState(null),[U,X]=v.useState(a?String(a):""),[G,Q]=v.useState(""),R=l?.connections?.some(t=>String(t.id)===U)?U:"",w=Me(s,R?Number(R):void 0,G,u||void 0);async function H(t,f){S(!0),T(null);try{if(u){const d={resource_class:"connector_action",...pe(t)};f?await Ye(s,u,{...d,effects:{execute:f}}):await Ze(s,u,d)||T("This rule was already removed. The list has been refreshed.")}else{const d=i.data;if(!d)return;const K=d.rules.filter(qe=>de(qe)!==de(t));f&&K.push({...pe(t),effect:f});const ce=await Je(s,{revision:d.revision,rules:K});h.setQueryData(Xe(s),ce)}return await Promise.all(["write-permissions","agent-permissions","available-operations","connector-operations","policy-explanation"].map(d=>h.invalidateQueries({queryKey:[d]}))),t}catch(d){d instanceof be&&d.status===409?(T("Policies changed in another session. Review the refreshed rules before saving again."),await i.refetch()):T(d instanceof Error?d.message:"Could not save policy.")}finally{S(!1)}}const q=C.error||(u?m.error:i.error);if(q instanceof be&&q.status===403)return e.jsx("p",{role:"status",className:"text-sm text-muted-foreground",children:"Only organization owners and admins can manage policies."});if(q)return e.jsxs("p",{role:"alert",className:"text-sm text-destructive",children:["Could not load policies. ",String(q)]});if(!l||(u?!m.data:!i.data))return e.jsx(Y,{label:"policies",rows:2});const b=t=>t==="all"||l.connectors?.some(f=>`connector:${f.key}`===t)||l.connections?.some(f=>`connection:${f.id}`===t)?t:"all",o=b(z),p=b(M),j=l.connections?.find(t=>`connection:${t.id}`===p),$=j?.connector_key??(p.startsWith("connector:")?p.slice(10):void 0),x=t=>p==="all"||Ee(t)==="all"?!0:t.connection_id?j?t.connection_id===j.id:l.connections?.some(f=>f.id===t.connection_id&&f.connector_key===$):t.connector_key===$;function B(t){return u?t.principal_kind==="agent"&&t.principal_id===u:!t.principal_kind}const ee=o.startsWith("connector:")?o.slice(10):o.startsWith("connection:")?l.connections?.find(t=>t.id===Number(o.slice(11)))?.connector_key:void 0,O=l.connector_operations.filter(t=>!ee||t.connector_key===ee),se=l.connections?.find(t=>t.id===Number(R))?.connector_key,ae=l.connector_operations.filter(t=>t.connector_key===se),oe=u?(m.data?.agent??[]).filter(t=>t.resource_class==="connector_action").map($e):i.data?.rules??[],te=(m.data?.floor??[]).filter(t=>t.resource_class==="connector_action"&&x(t)).map($e),Qe={connector_key:o.startsWith("connector:")?o.slice(10):o==="all"&&A==="specific"?O.find(t=>t.operation_key===k)?.connector_key??null:null,connection_id:o.startsWith("connection:")?Number(o.slice(11)):null,operation_key:A==="specific"?k:null,operation_category:A.startsWith("category:")?A.slice(9):null},re=oe.filter(x);function fe(){_(p),V("all"),D(""),E("approval"),W(!0)}const ye=(t,f=!1)=>e.jsx("div",{className:"divide-y rounded-lg border",children:t.map(d=>{const K=!f&&B(d);return e.jsxs(De,{controls:e.jsxs(e.Fragment,{children:[e.jsx(he,{options:ze,value:d.effect,floor:"auto",compact:!0,disabled:g||!K,ariaLabel:`Policy for ${ue(d,l)}`,onChange:ce=>void H(d,ce)}),K&&e.jsx(Ss,{label:"Remove",disabled:g,ariaLabel:`Remove rule: ${ue(d,l)}`,onRemove:()=>H(d)})]}),children:[e.jsx("p",{className:"text-sm break-words",children:ue(d,l)}),!K&&e.jsx("p",{className:"text-xs text-muted-foreground",children:d.principal_kind==="agent"&&!d.principal_id?"All agents":"Inherited restriction"})]},JSON.stringify([d.principal_kind,d.principal_id,de(d)]))})});return e.jsxs("div",{className:"space-y-4",children:[(p!==M||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 Ask. 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:"Agents and their Automations can only tighten organization policy. Internal browser steps inherit the parent approval; an explicit browser Block still wins."})]})]}),e.jsxs(F,{label:"Policy owner",value:u,onChange:y,disabled:g,children:[e.jsx("option",{value:"",children:"Organization"}),l.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 require approval (Ask)."}),e.jsx(F,{label:"Show rules for",value:p,onChange:Z,disabled:g,children:e.jsx(Te,{catalog:l})}),u&&te.length>0&&e.jsxs("div",{className:"space-y-2",children:[e.jsx("h3",{className:"text-sm font-medium",children:"Inherited organization rules"}),ye(te,!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&&re.length>0&&e.jsx(N,{variant:"outline",size:"sm",disabled:g,onClick:fe,children:"Add rule"})]}),I&&e.jsxs("form",{className:"space-y-3 border-t pt-4",onSubmit:t=>{t.preventDefault(),!g&&(A!=="specific"||k)&&H(Qe,J).then(f=>{f&&(W(!1),Z(Ee(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(F,{label:"Applies to",value:o,onChange:t=>{_(t),V("all"),D("")},disabled:g,children:e.jsx(Te,{catalog:l})}),e.jsxs(F,{label:"Actions",value:A,onChange:V,disabled:g,children:[e.jsx("option",{value:"all",children:"All actions"}),e.jsx("optgroup",{label:"Categories",children:l.operation_categories?.map(t=>e.jsx("option",{value:`category:${t}`,children:Le[t]},t))}),e.jsx("option",{value:"specific",children:"Specific action"})]})]}),A==="specific"&&e.jsxs(F,{label:"Specific action",value:k,onChange:D,disabled:g,children:[e.jsx("option",{value:"",children:"Choose action"}),O.map(t=>e.jsxs("option",{value:t.operation_key,children:[t.connector_name,": ",t.name]},t.operation_key))]}),e.jsxs("div",{className:"flex flex-wrap items-center justify-between gap-3",children:[e.jsx(he,{options:ze,value:J,floor:"auto",compact:!0,disabled:g,ariaLabel:"New rule decision",onChange:E}),e.jsx(Ve,{onCancel:()=>W(!1),cancelDisabled:g,children:e.jsx(N,{type:"submit",disabled:g||A==="specific"&&!k,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."})]}),re.length?ye(re):!I&&e.jsx(Ue,{icon:Ge,title:"No saved rules in this scope",description:"Add a rule for all actions, a category, or a specific action.",actionLabel:"Add rule",onAction:fe})]}),L&&e.jsx("p",{role:"alert",className:"rounded-md bg-destructive/10 px-3 py-2 text-sm text-destructive",children:L}),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(F,{label:"Check connection",value:R,onChange:t=>{X(t),Q("")},children:[e.jsx("option",{value:"",children:"Choose connection"}),l.connections?.map(t=>e.jsxs("option",{value:String(t.id),children:[t.display_name||t.connector_key," (#",t.id,")"]},t.id))]}),e.jsxs(F,{label:"Check action",value:G,onChange:Q,disabled:!R,children:[e.jsx("option",{value:"",children:"Choose action"}),ae.map(t=>e.jsx("option",{value:t.operation_key.slice(t.connector_key.length+2),children:t.name},t.operation_key))]})]}),w.error?e.jsxs("p",{role:"alert",className:"text-sm text-destructive",children:["Could not check policy. ",String(w.error)]}):e.jsx("p",{"aria-live":"polite",className:"text-sm",children:G?w.isPending?"Checking…":w.data?e.jsxs(e.Fragment,{children:[e.jsx("strong",{children:He[w.data.effect]})," ·"," ",Cs[w.data.reason]??"The server evaluated this action.",w.data.rule_ids.length>0?` · Rules ${w.data.rule_ids.map(t=>`#${t}`).join(", ")}`:""]}):"":""})]})]})}const As=[{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."}],Os=[{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 xe(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 Ps(s){return s.agent.find(xe)}function zs(s,n){return{...s,agent:[...s.agent.filter(a=>!xe(a)),n]}}function $s(s){return{...s,agent:s.agent.filter(n=>!xe(n))}}function Es({label:s,description:n,action:a,value:c,pending:h,onChange:r}){return e.jsxs(De,{controls:e.jsx(he,{options:as("entity_schema",a),value:c,floor:"auto",disabled:h,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 Re({title:s,actions:n,effects:a,pending:c,onChange:h}){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:y,description:C})=>e.jsx(Es,{action:r,label:y,description:C,value:a[r]??me.entity_schema[r]??"deny",pending:c,onChange:l=>h(r,l)},r))})]})}function Ts({owner:s}){const n=ge(),a=es(s),c=Ie(s),h=ve({mutationFn:m=>ss(s,{resource_class:"entity_schema",effects:m}),onSuccess:m=>{n.setQueryData(a,i=>i&&zs(i,m)),n.invalidateQueries({queryKey:a})},onError:m=>{ie.error(m instanceof Error?m.message:"Failed to save schema policy")}}),r=ve({mutationFn:()=>ts(s,{resource_class:"entity_schema"}),onSuccess:()=>{n.setQueryData(a,m=>m&&$s(m)),n.invalidateQueries({queryKey:a})},onError:m=>{ie.error(m instanceof Error?m.message:"Failed to reset schema policy")}});if(c.isLoading)return e.jsx(Y,{label:"schema policy",variant:"cards",cards:1});if(c.isError||!c.data)return e.jsx(ns,{label:"schema policy"});const y=Ps(c.data),C=y?.effects??me.entity_schema,l=h.isPending||r.isPending,u=(m,i)=>{h.mutate({...y?.effects??me.entity_schema,[m]:i})};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:y?"Custom policy":"Workspace defaults"}),y?e.jsxs(N,{type:"button",variant:"outline",size:"sm",disabled:l,onClick:()=>r.mutate(),children:[e.jsx(is,{className:"mr-1.5 h-3.5 w-3.5"}),"Remove custom policy"]}):null]}),e.jsxs("div",{className:"space-y-4",children:[e.jsx(Re,{title:"Entity types",actions:As,effects:C,pending:l,onChange:u}),e.jsx(Re,{title:"Relationship types",actions:Os,effects:C,pending:l,onChange:u})]})]})}function Fe(s){return s.toLowerCase().replace(/[^a-z0-9]+/g,"-").replace(/^-+|-+$/g,"")}function Rs(s,n,a){const c=s.split("/");return c[1]===n?(c[1]=a,c.join("/")||"/"):`/${a}`}function Fs({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(P,{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(P,{className:"h-4 w-32 rounded-none"})})]},n)),e.jsx(P,{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(P,{className:"mt-0.5 h-4 w-4 shrink-0 rounded-none"}),e.jsxs("div",{className:"flex-1 space-y-2",children:[e.jsx(P,{className:"h-4 w-16 rounded-none"}),e.jsx(P,{className:"h-3 w-full rounded-none"}),e.jsx(P,{className:"h-3 w-2/3 rounded-none"})]})]},n))})]}),e.jsxs("div",{"aria-hidden":"true",className:"flex justify-end gap-2",children:[e.jsx(P,{className:"h-9 w-20 rounded-none"}),e.jsx(P,{className:"h-9 w-28 rounded-none"})]})]})}function Is({owner:s,section:n="general",connector:a,connection:c,agent:h}){const r=os(),y=ge(),{data:C,error:l}=We(),{activeOrg:u,urlOrgSlug:m}=rs(),i=(C??[]).find(o=>o.slug===s&&o.is_member)??null,z=i?.id??s,_=cs(z,{name:i?.name??"",slug:i?.slug??"",visibility:i?.visibility??"private"}),[M,Z]=_.field("name"),[I,W]=_.field("slug"),[k,D]=_.field("visibility"),[A,V]=ne(z,!!i),[J,E]=ne(z,!1),[g,S]=ne(z,null),[L,T]=v.useState(!1),[U,X]=v.useState(!1),[G,Q]=ne(z,!1);if(ls(l)&&C===void 0)return e.jsxs(we,{role:"alert",children:[e.jsx(Ae,{children:e.jsx(Oe,{children:"Couldn't load organizations"})}),e.jsx(Pe,{children:e.jsx("p",{className:"text-sm text-muted-foreground",children:"Please try again in a moment."})})]});if(C===void 0)return e.jsx(Fs,{section:n});if(!i)return e.jsxs(we,{children:[e.jsx(Ae,{children:e.jsx(Oe,{children:"Organization not found"})}),e.jsx(Pe,{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(ws,{owner:s,connector:a,connection:c,agent:h},`${s}:${h??""}:${a??""}:${c??""}`)]})});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(Ns,{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(Ts,{owner:s})]})]});const R=o=>{const p=xs(o);if(p.kind==="cross-host"){window.location.assign(p.href);return}r({to:p.to})},w=o=>{if(o==="public"&&i.visibility!=="public"){E(!0);return}D(o),E(!1)},H=async()=>{if(!_.canSubmit)return;const o=M.trim();if(!o){S("Name is required");return}const p=I.trim()||Fe(o);if(!p){S("Slug is required");return}T(!0),S(null);try{const j=o!==i.name||p!==i.slug,$=k!==i.visibility;let x=i.slug;if(j){const O=await le.update({organizationId:i.id,data:{name:o,slug:p}});if(O.error){S(O.error.message||"Failed to update organization");return}x=O.data?.slug??p}$&&(x=(await ps(x,k)).slug),(j||$)&&(_.accept(_.values,{name:o,slug:x,visibility:k}),await y.invalidateQueries({queryKey:["organizations"]}),ie.success("Organization updated"));const B=u?.id===i.id||m===i.slug,ee=x!==i.slug;if(B&&ee){const O=_e(),se=ke();if(O===i.slug&&se){const oe=gs(window.location.pathname,i.slug)||"/",te=`${window.location.protocol}//${x}.${se}${oe}${window.location.search}${window.location.hash}`;window.location.assign(te);return}const ae=Rs(window.location.pathname,i.slug,x);r({to:`${ae}${window.location.search}${window.location.hash}`});return}}catch(j){S(j instanceof Error?j.message:"Failed to update organization")}finally{T(!1)}},q=async()=>{X(!0),S(null);try{const o=await le.delete({organizationId:i.id});if(o.error){S(o.error.message||"Failed to delete organization");return}await y.invalidateQueries({queryKey:["organizations"]}),ie.success("Organization deleted");const j=(C??[]).filter(x=>x.is_member).find(x=>x.id!==i.id)??null,$=u?.id===i.id||m===i.slug;if($&&j){await le.setActive({organizationId:j.id}),R(j.slug);return}if($){const x=_e(),B=ke();if(x===i.slug&&B){window.location.assign(`${window.location.protocol}//app.${B}/`);return}r({to:"/"});return}r({to:"/"})}catch(o){S(o instanceof Error?o.message:"Failed to delete organization")}finally{X(!1),Q(!1)}},b=L||U;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(je,{htmlFor:"org-name",children:"Name"}),e.jsx(Ne,{id:"org-name",value:M,onChange:o=>{Z(o.target.value),A||W(Fe(o.target.value))},placeholder:"e.g. My Team",disabled:b})]}),e.jsxs("div",{className:"space-y-1.5",children:[e.jsx(je,{htmlFor:"org-slug",children:"Slug"}),e.jsx(Ne,{id:"org-slug",value:I,onChange:o=>{V(!0),W(o.target.value)},placeholder:"e.g. my-team",disabled:b}),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:["/",i.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:()=>w("private"),disabled:b,className:`flex items-start gap-3 rounded-lg border p-3 text-left transition-colors ${k==="private"?"border-primary bg-primary/5":"border-border hover:bg-muted/40"}`,children:[e.jsx(ds,{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:()=>w("public"),disabled:b,className:`flex items-start gap-3 rounded-lg border p-3 text-left transition-colors ${k==="public"?"border-primary bg-primary/5":"border-border hover:bg-muted/40"}`,children:[e.jsx(us,{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."})]})]})]}),J&&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:()=>{D("public"),E(!1)},disabled:b,children:"Confirm public"}),e.jsx(N,{type:"button",size:"sm",variant:"ghost",onClick:()=>E(!1),disabled:b,children:"Cancel"})]})]})]}),g&&e.jsx("div",{className:"rounded-md bg-destructive/10 px-3 py-2 text-sm text-destructive",children:g}),e.jsx(ms,{visible:_.hasConflict,onReload:_.reset}),e.jsxs("div",{className:"flex justify-end gap-2",children:[e.jsx(N,{variant:"outline",onClick:()=>void r({to:`/${s}`}),disabled:b,children:"Cancel"}),e.jsxs(N,{onClick:H,disabled:b||!_.canSubmit,children:[L?e.jsx(Ce,{size:"lg",className:"mr-1.5"}):null,L?"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:i.is_personal?"Personal workspace":"Delete this organization"}),e.jsx("p",{className:"mt-1 text-xs text-muted-foreground",children:i.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."}),!i.is_personal&&e.jsx("div",{className:"mt-3",children:G?e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsxs(N,{variant:"destructive",size:"sm",onClick:q,disabled:b,children:[U?e.jsx(Ce,{className:"mr-1.5"}):null,"Confirm delete"]}),e.jsx(N,{variant:"ghost",size:"sm",onClick:()=>Q(!1),disabled:b,children:"Cancel"})]}):e.jsxs(N,{variant:"outline",size:"sm",className:"text-destructive hover:text-destructive",onClick:()=>Q(!0),disabled:b,children:[e.jsx(hs,{className:"mr-1.5 h-3.5 w-3.5"}),"Delete organization"]})})]})]})}function Qs(){const{owner:s}=Se.useParams(),n=Se.useSearch(),a=n.section??"general",c={general:"General",policies:"Policies",governance:"Governance"}[a],{data:h}=We(),r=(h??[]).find(y=>y.slug===s&&y.is_member)?.name;return e.jsx(fs,{className:"pt-2.5 pb-8",children:e.jsxs(ys,{className:vs("flex flex-1 flex-col gap-6",js(a)),children:[e.jsxs("div",{className:"space-y-1",children:[e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(bs,{className:"h-7 w-7"}),e.jsx("h1",{className:"text-3xl font-semibold leading-tight",children:c})]}),r?e.jsx("p",{className:"text-base font-medium text-foreground",children:r}):null]}),e.jsx(Is,{owner:s,...n,section:a})]})})}export{Qs as component};
2
+ //# sourceMappingURL=organization-DBfgBkzq.js.map
@@ -0,0 +1,2 @@
1
+ import{j as e,ej as de,jR as z,jS as ue,jT as ee,jU as me,jV as pe,r as g,jW as xe,u as D,aU as he,cK as fe,m as $,iy as ge,jm as ye,B as k,jX as je,jY as K,jZ as ve,dX as Ne,j_ as we,G as L,al as R,aw as te,cq as se,M as ne,dq as ke,bQ as be,b$ as Ae,cY as Ce,cJ as Se,x as Ie,gf as $e,P as Le,L as H,j$ as Re,cO as Pe,gi as Te,d8 as _e,k0 as Ee,gp as G,fl as Oe,aS as ze,k1 as De,n as Me,w as Fe,gC as Be,eW as Ke,fj as He,fm as Ue,fs as E,p as Ve,k2 as We,k3 as qe,ev as Ge,k4 as Ye,f0 as Qe,ac as Xe,k5 as Ze,A as Je,k6 as et}from"./index-DByaMzsG.js";import{b as re,u as tt,a as st,A as nt}from"./automation-run-now-MtxUTfzd.js";import{A as rt}from"./agent-loading-shells-DYqQphN7.js";import{s as it,h as at,R as ot,A as ct}from"./agent-thread-BopD-2k1.js";import{C as lt,a as dt,c as ut,A as mt}from"./connection-feed-detail-0VAJiZTP.js";import{O as pt}from"./connect-menu-C6iVtuSo.js";import{E as P,R as xt,b as ht,s as Y,p as Q,e as ft,f as gt}from"./events-feed-DmRzikZW.js";import{S as yt}from"./source-record-panels-CGmKIJdN.js";import{E as X}from"./entity-type-page-CkQm0yEu.js";import{c as jt,s as vt,m as Nt}from"./renderer-olRv_HMI.js";import{E as wt}from"./event-detail-CkzfakTK.js";import{V as kt,R as bt}from"./views-access-required-C35Dyt91.js";import{V as At,a as Ct}from"./view-param-filters-CUCj9Df-.js";import{S as St,g as It}from"./status-variants-DyRCXBzM.js";import{a as $t}from"./runs-C8sZQr4o.js";import{a as ie}from"./use-automations-CgWNoYio.js";import"./needs-you-list-B5Bgd05M.js";import"./scoped-feed-bar-BKyJSa3_.js";import"./event-kind-options-fHAIXu24.js";import"./filter-editors-CQoSj-20.js";import"./subDays-D8nHthaS.js";import"./create-automation-form-CLicoPH5.js";import"./entity-options-B9hm9V87.js";import"./device-automation-Dp3faMvp.js";import"./model-selector-D3vSMLO2.js";import"./skill-editor-D_W3QlRz.js";import"./code-editor-mrKkAfcE.js";import"./index-Vcq4gwWv.js";import"./json-diff-mcDgyct_.js";import"./use-mention-search-D-kIKchD.js";import"./proposal-review-shell-B-jYcKfB.js";import"./definition-comparison-4UYMI6BK.js";import"./schema-value-zTJGE4eh.js";import"./runs-list-CwtH-wmk.js";import"./run-initiator-DhE5v4z0.js";import"./list-skeleton-DsYGUHxi.js";import"./clients-xnzZeEdZ.js";import"./app-bridge-C4nPtae3.js";import"./pending-seed-CBhx2Ql-.js";import"./feed-event-kinds-BYuZCoU4.js";import"./copy-button-C3wMMv63.js";import"./card-DtLIFq7D.js";import"./table-C637cQxG.js";import"./dynamic-schema-form-BDT8x0Vg.js";import"./record-session-CAmGHMyM.js";function Lt(t){if(!t||typeof t!="object")return[];const s=t.properties;if(!s)return[];const r=Array.isArray(t.required)?new Set(t.required.map(String)):new Set;return Object.entries(s).map(([n,i])=>({name:n,type:String(i.type??"any"),required:r.has(n),description:typeof i.description=="string"?i.description:void 0}))}function Rt({fields:t}){return t.length===0?e.jsx("p",{className:"text-xs text-muted-foreground",children:"No fields."}):e.jsx("ul",{className:"space-y-2",children:t.map(s=>e.jsxs("li",{className:"space-y-0.5",children:[e.jsxs("div",{className:"flex flex-wrap items-baseline gap-x-2",children:[e.jsx("code",{className:"text-xs font-medium text-foreground",children:s.name}),e.jsx("span",{className:"text-[10px] uppercase tracking-wide text-muted-foreground/70",children:s.type}),s.required?e.jsx("span",{className:"text-[10px] font-medium text-amber-600 dark:text-amber-400",children:"required"}):null]}),s.description?e.jsx("p",{className:"text-xs text-muted-foreground",children:s.description}):null]},s.name))})}function M({item:t,hideHeading:s=!1}){const r=t.schemaSections;return r?e.jsxs("article",{className:s?"space-y-4":"space-y-4 px-5 py-5",children:[!s&&e.jsxs("div",{className:"flex items-start gap-3",children:[e.jsx(de,{className:"mt-0.5 h-4 w-4 shrink-0 text-muted-foreground"}),e.jsxs("div",{className:"min-w-0 flex-1 space-y-1",children:[e.jsx("h2",{className:"text-base font-medium text-foreground",children:t.title}),r.description?e.jsx("p",{className:"text-xs text-muted-foreground",children:r.description}):null]})]}),r.sections.map(n=>{const i=Lt(n.schema);return e.jsxs("section",{className:"space-y-1.5",children:[e.jsxs("div",{className:"flex items-baseline gap-2",children:[e.jsx("h3",{className:"text-xs font-medium uppercase tracking-wide text-muted-foreground",children:n.title}),n.description?e.jsx("span",{className:"truncate text-xs text-muted-foreground",children:n.description}):null]}),e.jsx(Rt,{fields:i})]},n.title)})]}):null}function Pt({actions:t}){const s=Object.entries(t).map(([r,n])=>{const i=n;return{id:r,name:i.name??r,description:i.description,action:i}});return e.jsx(z,{entries:s,label:"actions",renderDetail:({name:r,action:n})=>e.jsx(M,{hideHeading:!0,item:{href:"",title:r,schemaSections:ee(n)}})})}function Tt({feeds:t}){const s=Object.entries(t).map(([r,n])=>{const i=n;return{id:r,name:i.name??r,description:i.description,feed:i}});return e.jsx(z,{entries:s,label:"feed types",renderDetail:({name:r,feed:n})=>e.jsx(M,{hideHeading:!0,item:{href:"",title:r,schemaSections:ue(n)}})})}function _t(t){const s=[];return t.forEach((r,n)=>{s.push({id:`sep:${r.runId}`,role:"system",parts:[{type:"text",text:Et(r,n)}],createdAt:r.completedAt?new Date(r.completedAt).getTime():void 0});for(const i of r.messages)s.push({...i,id:`r${r.runId}:${i.id}`})}),s}function Et(t,s){const r=(t.pendingActionCount??0)>0?`Waiting for you (${t.pendingActionCount})`:t.status==="completed"?"Completed":t.status??"Completed",n=(t.autoAppliedCount??0)>0?` · ${t.autoAppliedCount} applied automatically`:"",i=t.completedAt?new Date(t.completedAt).toLocaleString():null;return i?`Run ${s+1} · ${r}${n} · ${i}`:`Run ${s+1} · ${r}${n}`}const ae=Symbol("trusted-automation-interaction");function Ot(t){return Object.defineProperty(t,ae,{value:!0}),t}function zt(t){return{title:`${t} items waiting for you`,icon:"entity",impact:{level:"normal"},tone:"default",blocks:[{type:"text",value:"Review the individual proposals below, or decide the whole run at once.",muted:!0}],actions:[{id:"approve-all",label:"Approve all",variant:"primary",icon:"check",confirm:!0,confirmPrompt:`Approve all ${t} proposals?`,tool:"manage_operations",args:{action:"approve"},resolvedLabel:`Approved all ${t} proposals.`},{id:"reject-all",label:"Reject all",variant:"outline",icon:"x",confirm:!0,confirmPrompt:`Reject all ${t} proposals?`,tool:"manage_operations",args:{action:"reject"},resolvedLabel:`Rejected all ${t} proposals.`}]}}const Dt=new Set(["automation-approval-batch"]);function Mt(t){return new Promise(s=>{t({onSettled:(r,n)=>s(!!n)})})}function Ft(){const t=me(),s=pe();return g.useMemo(()=>({toolNames:Dt,resolve:(r,n)=>{if(!n||typeof n!="object"||n[ae]!==!0)return null;const i=n;if(r==="automation-approval-batch"){const o=typeof i.runId=="number"&&Number.isSafeInteger(i.runId)&&i.runId>0?i.runId:null,c=typeof i.count=="number"&&Number.isSafeInteger(i.count)&&i.count>1?i.count:null,a=Array.isArray(i.runIds)?i.runIds.filter(d=>typeof d=="number"&&Number.isSafeInteger(d)&&d>0):[];return o===null||c===null||a.length!==c||new Set(a).size!==c?null:{view:zt(c),handlers:{manage_operations:d=>d.action!=="approve"&&d.action!=="reject"?Promise.resolve(!0):Mt(p=>d.action==="approve"?t.mutate({run_id:o,run_ids:a},p):s.mutate({run_id:o,run_ids:a},p))}}}return null}}),[t,s])}const Bt=/(?:^|\n)Run this Automation now/;function Kt(t){return t.role==="user"&&t.parts.some(s=>s.type==="text"&&Bt.test(s.text))}function Ht(t){return`history-interaction:${t.runId}:${t.eventId??"error"}`}function Ut({agentId:t,automationId:s,ownerSlug:r,runId:n}){const{data:i,isLoading:o}=xe(t,s,{orgSlug:r,...n!=null?{runId:n}:{}}),c=Ft(),a=D(),d=g.useCallback(m=>{a?.open({href:`/${r}/automations/${s}?view=activity&run_id=${m}`,title:`Automation run #${m}`,runId:m})},[a,r,s]),p=g.useMemo(()=>{const m=i?.runs??[],b=(n!=null?m.filter(x=>x.runId===n):m).slice().reverse();return _t(b.map(x=>{const y=x.messages.map(u=>it(u,{showToolCalls:!0})).filter(u=>u!==null&&!Kt(u));x.task?.trim()&&y.unshift({id:"task",role:"user",parts:[{type:"text",text:x.task.trim()}]});const N=x.actions??[],j=N.filter(u=>u.status==="pending");if(j.length>1){const u=j.map(h=>h.runId).sort((h,C)=>h-C);y.push({id:"approval-batch",role:"assistant",parts:[{type:"tool-call",toolCallId:`approval-batch-${x.runId}`,toolName:"automation-approval-batch",args:Ot({runId:x.runId,count:j.length,runIds:u})}]})}for(const u of N){const h=at([u],{workspaceSlug:r,agentId:t,webOrigin:typeof window>"u"?null:window.location.origin});h&&y.push({...h,id:Ht(u)})}return{runId:x.runId,completedAt:x.completedAt,status:x.status,pendingActionCount:x.pendingActionCount,autoAppliedCount:x.autoAppliedCount,messages:y}}))},[t,i,r,n]);return o?e.jsx(rt,{readOnly:!0}):p.length===0?e.jsx("p",{className:"text-sm text-muted-foreground",children:"No run transcripts yet. Recent runs will show here when the Automation fires (failed runs appear with their prompt even without a full transcript)."}):e.jsx("div",{className:"flex h-[calc(100dvh-12rem)] min-h-[24rem] min-w-0 flex-1 flex-col",children:e.jsx(ot,{messages:p,workspaceSlug:r,children:e.jsx(ct,{readOnly:!0,readerPositionMode:"runs",interactionExtension:c,onRunSelect:n==null&&a?d:void 0})})})}function Vt({panel:t}){const s=he(t.organizationId),r=t.section==="connections"||!!t.connectionId,n=fe(t.organizationId,{connectorKey:t.connectorKey,connectionIds:t.connectionId?[t.connectionId]:void 0,enabled:r}),i=s.data?.find(c=>c.key===t.connectorKey),o=n.data?.find(c=>c.id===t.connectionId&&c.connector_key===t.connectorKey);return s.isLoading||r&&n.isLoading?e.jsx("div",{className:"p-5",children:e.jsx($,{className:"h-28 w-full"})}):s.isError||r&&n.isError?e.jsx("p",{role:"alert",className:"p-5 text-sm",children:"Could not load this connector. Close the pane and try again."}):t.connectionId&&!o||!i&&!o&&t.section!=="connections"?e.jsx("p",{className:"p-5 text-sm",children:"This connection is no longer available."}):e.jsx("div",{className:"p-5",children:t.section==="connections"?e.jsx(ge,{connections:n.data??[],connector:i,connectorKey:t.connectorKey,ownerSlug:t.ownerSlug}):o&&t.section==="data"?e.jsx(lt,{connection:o,ownerSlug:t.ownerSlug}):o?e.jsx(Gt,{connection:o,connector:i,panel:t}):i?t.section==="oauth-apps"?e.jsx(pt,{connector:i,organizationId:t.organizationId,newApp:!!t.newApp}):t.section==="feeds"?e.jsx(Wt,{connector:i}):i.installed===!1?e.jsx(qt,{connector:i,ownerSlug:t.ownerSlug}):e.jsx(Qt,{connector:i,ownerSlug:t.ownerSlug}):null},`${t.connectorKey}:${t.connectionId??"connector"}:${t.section}`)}function Wt({connector:t}){return e.jsx(Tt,{feeds:t.feeds_schema??{}})}function qt({connector:t,ownerSlug:s}){return e.jsxs("div",{className:"space-y-4",children:[e.jsxs("p",{className:"text-sm text-muted-foreground",children:["Policy depends on connection."," ",e.jsx(K,{ownerSlug:s,connectorKey:t.key})]}),e.jsx(Pt,{actions:t.actions_schema??{}})]})}function Gt({connection:t,connector:s,panel:r}){const[n,i]=g.useState(!1);return e.jsxs(e.Fragment,{children:[e.jsx("div",{hidden:n,children:r.section==="feeds"?e.jsx(Yt,{connection:t,connector:s,ownerSlug:r.ownerSlug}):e.jsx(ye,{connection:t,ownerSlug:r.ownerSlug,inPeek:!0,onReviewPermissions:s?()=>i(!0):void 0})}),n&&s&&e.jsxs("div",{className:"space-y-4",children:[e.jsx(k,{variant:"ghost",size:"sm",onClick:()=>i(!1),children:"Back to actions"}),e.jsx("h2",{className:"text-base font-semibold",children:"Provider permissions"}),e.jsx(je,{connection:t,connectorDef:s})]})]})}function Yt({connection:t,connector:s,ownerSlug:r}){const{data:n=[],isLoading:i,isError:o}=Ne(t.id),[c,a]=g.useState(!1),d=t.facets?.chat??!1;if(i)return e.jsx($,{className:"h-28 w-full"});if(o)return e.jsx("p",{role:"alert",children:"Could not load sources. Close the pane and try again."});const p=n.map(m=>({id:String(m.id),name:m.display_name||m.feed_key,status:we(m)??(m.operations.includes("sync")?"Sync enabled":"Live access"),feed:m}));return e.jsxs(e.Fragment,{children:[e.jsx("div",{hidden:c,children:e.jsx(z,{entries:p,label:d?"channels":"feeds",action:Object.keys(s?.feeds_schema??{}).length>0?e.jsx(k,{size:"sm",variant:"outline",onClick:()=>a(!0),children:d?"Add channel":"Add feed"}):void 0,renderDetail:({feed:m})=>m.store==="channel_messages"?e.jsx(dt,{feed:m,hideHeader:!0}):e.jsx(ut,{feed:m,connectorDef:s,ownerSlug:r})})}),c&&s&&e.jsxs("div",{className:"space-y-4",children:[e.jsx("h2",{className:"text-base font-semibold",children:d?"Add channel":"Add feed"}),e.jsx(mt,{organizationId:t.organization_id,connections:[t],connectorDefinitions:[s],onClose:()=>a(!1)})]})]})}function Qt({connector:t,ownerSlug:s}){const{data:r=[],isLoading:n,isError:i}=ve(t.key);if(n)return e.jsx($,{className:"h-28 w-full"});if(i)return e.jsx("p",{role:"alert",children:"Could not load actions. Close the pane and try again."});const o=t.actions_schema??{},c=r.map(a=>({id:a.operation_key,name:a.name??a.operation_key,description:a.description,operation:a}));return e.jsxs("div",{className:"space-y-4",children:[e.jsxs("p",{className:"text-sm text-muted-foreground",children:["Policy depends on connection. Click an action to inspect its inputs."," ",e.jsx(K,{ownerSlug:s,connectorKey:t.key})]}),e.jsx(z,{entries:c,label:"actions",renderControl:()=>e.jsx(K,{ownerSlug:s,connectorKey:t.key}),renderDetail:({operation:a,name:d})=>o[a.operation_key]?e.jsx(M,{hideHeading:!0,item:{href:"",title:d,schemaSections:ee(o[a.operation_key])}}):e.jsx("p",{className:"text-sm text-muted-foreground",children:"No input fields."})})]})}function Xt({owner:t,name:s,agentId:r,clientIds:n}){const{data:i,isLoading:o}=L(t==="me"?null:t,{slug:t}),c=i?.workspace,a=t!=="me"&&c?.type==="organization"?c.id:null,d=n?.join(",")??"",p=g.useMemo(()=>({sortBy:"date",sortOrder:"desc",...r?{agentId:r}:{clientIds:d.split(",").filter(Boolean)}}),[r,d]);return t!=="me"&&o?e.jsxs("div",{className:"flex items-center justify-center py-12 text-muted-foreground",children:[e.jsx(R,{className:"mr-2"})," Loading…"]}):e.jsx("div",{className:"space-y-3 px-4 py-4",children:e.jsx(P,{organizationId:a,ownerSlug:t,filters:p,hideOriginator:!0,groupStretches:!0,emptyState:e.jsxs("p",{className:"px-4 py-8 text-center text-sm text-muted-foreground",children:["No activity from ",s," yet."]})})})}function Zt({owner:t,path:s}){const{data:r,isLoading:n}=L(t,{slug:t}),i=r?.workspace,o=i?.type==="organization"?i.id:null,c=o?{slug:t}:void 0,{data:a,isLoading:d}=te(`/${t}/${se(s)}`,c),p=a?.entity,m=p?.id;return n||d?e.jsxs("div",{className:"flex items-center justify-center py-12 text-muted-foreground",children:[e.jsx(R,{className:"mr-2"})," Loading…"]}):o?m==null?e.jsx("p",{className:"px-4 py-8 text-center text-sm text-muted-foreground",children:"Couldn't find this record. It may have been deleted, or it may live in a workspace you can't access."}):p?.is_derived?e.jsx(yt,{record:{type:p.entity_type,key:p.slug},orgContext:c}):e.jsx("div",{className:"px-4 py-4",children:e.jsx(P,{organizationId:o,ownerSlug:t,entityId:typeof m=="number"?m:void 0,filters:{sortBy:"date",sortOrder:"desc"},emptyState:e.jsx("div",{className:"px-4 py-8 text-center text-sm text-muted-foreground",children:"Nothing has happened to this record yet."})})}):e.jsx("p",{className:"px-4 py-8 text-center text-sm text-muted-foreground",children:"Couldn't resolve this workspace."})}function Jt({slug:t,onClose:s}){const{orgContext:r}=ne(),{data:n=[],isLoading:i,isError:o}=ke(r);if(t===null)return e.jsx(X,{entityType:null,orgContext:r,onClose:s,compact:!0});if(i)return e.jsx(be,{label:"entity type",variant:"panel"});if(o)return e.jsx(Ae,{label:"entity type"});const c=n.find(a=>a.slug===t)??null;return c?e.jsx(X,{entityType:c,orgContext:r,hideDelete:Ce(c),onClose:s,compact:!0}):e.jsx("p",{className:"text-sm text-muted-foreground",children:"Entity type not found."})}function es(t){if(Array.isArray(t.enum))return`One of ${t.enum.length}`;if(t.format==="date"||t.format==="date-time")return"Date";if(t.format==="uri")return"Link";if(t.format==="email")return"Email";const s=Array.isArray(t.type)?t.type[0]:t.type;return s==="array"?"List":s==="object"?"Group":s==="integer"||s==="number"?"Number":s==="boolean"?"Yes / no":"Text"}function ts({owner:t,typeSlug:s,view:r}){const{data:n,isLoading:i}=L(t,{slug:t}),o=n?.workspace,c=o?.type==="organization"?o.id:null,{isAdmin:a}=Se(c??void 0),{orgContext:d}=ne(),{data:p,isSuccess:m}=Ie(d),v=(p??[]).find(A=>A.slug===s),b=m&&!v,x=`/${t}/${$e(s)}`,{pathname:y}=Le(),N=y===x||y===`${x}/`||y.startsWith(`${x}/-/`),j=g.useMemo(()=>jt(v?.metadata_schema),[v?.metadata_schema]),u=D(),h=u?.close;g.useEffect(()=>{b&&h?.()},[b,h]);const C=g.useMemo(()=>({entityTypes:[s],sortBy:"date",sortOrder:"desc"}),[s]);if(i)return e.jsxs("div",{className:"flex items-center justify-center py-12 text-muted-foreground",children:[e.jsx(R,{className:"mr-2"})," Loading…"]});if(b)return e.jsx("p",{className:"px-4 py-8 text-center text-sm text-muted-foreground",children:"This entity type no longer exists."});if(!c)return e.jsx("p",{className:"px-4 py-8 text-center text-sm text-muted-foreground",children:"Couldn't resolve this workspace."});const T=v?.name??s;return e.jsxs("div",{className:"flex flex-col",children:[e.jsxs("div",{className:"flex items-center gap-2 border-b border-border px-4 py-2.5",children:[N?null:e.jsx(k,{asChild:!0,variant:"outline",size:"sm",className:"h-8 text-xs",children:e.jsxs(H,{...Pe(t,s),children:[e.jsx(Re,{className:"mr-1.5 h-3.5 w-3.5"}),"Browse records"]})}),v&&!N&&!Te(v)&&v.entity_count!==0?e.jsx(k,{asChild:!0,variant:"outline",size:"sm",className:"h-8 text-xs",children:e.jsxs(H,{to:"/$owner/$entityType/-/$shape",params:{owner:t,entityType:s,shape:"graph"},search:Ee(G(t,s)),children:[e.jsx(_e,{className:"mr-1.5 h-3.5 w-3.5"}),"Graph"]})}):null,r!=="activity"&&u?e.jsxs(k,{type:"button",variant:"ghost",size:"sm",className:"ml-auto h-8 gap-1.5 text-xs text-muted-foreground hover:text-foreground",onClick:()=>u.open({href:G(t,s,"activity"),title:`${T} activity`}),children:[e.jsx(Oe,{className:"h-3.5 w-3.5"}),"Activity"]}):null]}),r==="activity"?e.jsx("div",{className:"px-4 py-4",children:e.jsx(P,{organizationId:c,ownerSlug:t,filters:C,showEntityLinks:!0,emptyState:e.jsx("div",{className:"px-4 py-8 text-center text-sm text-muted-foreground",children:"Nothing has happened to these records yet."})})}):a?e.jsx("div",{className:"p-4",children:e.jsx(Jt,{slug:s,onClose:()=>h?.()})}):j.length>0?e.jsxs("section",{"aria-labelledby":"entity-type-peek-fields",className:"px-4 py-4",children:[e.jsx("h3",{id:"entity-type-peek-fields",className:"mb-1.5 text-xs font-semibold uppercase tracking-wide text-muted-foreground",children:"Fields"}),e.jsx("dl",{className:"divide-y divide-border/60 text-sm",children:j.map(A=>e.jsxs("div",{className:"flex items-baseline justify-between gap-3 py-1.5",title:A.prop.description,children:[e.jsx("dt",{className:"min-w-0 truncate",children:vt(A)}),e.jsx("dd",{className:"shrink-0 text-xs text-muted-foreground",children:es(A.prop)})]},A.key))})]}):e.jsx("p",{className:"px-4 py-8 text-center text-sm text-muted-foreground",children:"This type has no fields yet."})]})}function ss({owner:t,eventId:s,viewKey:r}){const n=D(),i=(o,c)=>e.jsx(wt,{owner:c,organizationId:o,eventId:s,viewKey:r,dense:!0,onSelectView:n?a=>n.retarget(a):void 0},`${c}/${s}/${r??""}`);return e.jsx("div",{className:"px-4 py-4",children:t==="me"?i(null,t):e.jsx(ze,{owner:t,children:({organizationId:o,ownerSlug:c})=>o?i(o,c):e.jsx("div",{className:"h-40 animate-pulse rounded-md bg-muted/40"})})})}function ns({owner:t,feedId:s,semanticTypes:r}){const{data:n,isLoading:i}=L(t==="me"?null:t,{slug:t}),o=n?.workspace,c=t!=="me"&&o?.type==="organization"?o.id:null,a=g.useMemo(()=>({feedIds:[s],...r?.length?{semanticTypes:r}:{},sortBy:"date",sortOrder:"desc"}),[s,r]);return t!=="me"&&i?e.jsxs("div",{className:"flex items-center justify-center py-12 text-muted-foreground",children:[e.jsx(R,{className:"mr-2"})," Loading…"]}):c==null?e.jsx("div",{className:"px-4 py-8 text-center text-sm text-muted-foreground",children:"Couldn't resolve this workspace."}):e.jsx("div",{className:"px-4 py-4",children:e.jsx(P,{organizationId:c,ownerSlug:t,filters:a,showEntityLinks:!0,hideOriginator:!0,emptyState:e.jsx("div",{className:"px-4 py-8 text-center text-sm text-muted-foreground",children:r?.length===1?`No ${r[0]} events from this feed yet.`:"No matching events from this feed yet."})})})}function O({owner:t,runId:s,runIds:r,contentIds:n}){const{data:i,isLoading:o}=L(t==="me"?null:t,{slug:t}),c=i?.workspace,a=t!=="me"&&c?.type==="organization"?c.id:null,d=g.useMemo(()=>{if(t==="me")return n?.length?{contentIds:n,sortBy:"date",sortOrder:"desc"}:void 0;const m=r??(s!=null?[s]:void 0);if(!(!m?.length&&!n?.length))return{...m?.length?{runIds:m}:{},...n?.length?{contentIds:n}:{}}},[t,n,s,r]),p=d!=null;return t!=="me"&&o?e.jsxs("div",{className:"flex items-center justify-center py-12 text-muted-foreground",children:[e.jsx(R,{className:"mr-2"})," Loading…"]}):t!=="me"&&a==null?e.jsx("div",{className:"px-4 py-8 text-center text-sm text-muted-foreground",children:"Couldn't resolve this workspace."}):p?e.jsx("div",{className:"px-4 py-4",children:e.jsx(P,{presentation:"detail",organizationId:a,ownerSlug:t,filters:d,emptyState:e.jsx("div",{className:"px-4 py-8 text-center text-sm text-muted-foreground",children:s!=null||r?.length?"No matching events from this run yet.":"No matching events yet."})})}):e.jsx("div",{className:"px-4 py-8 text-center text-sm text-muted-foreground",children:"Nothing to preview."})}const F=25;function rs({target:t}){const[s,r]=g.useState(0),{data:n,isLoading:i,isError:o,refetch:c}=De(t.entityId,t.orgContext,{relationshipType:t.relationshipType,limit:F,offset:s}),a=n?.total;return e.jsxs("div",{className:"space-y-3 px-5 py-4",children:[e.jsxs("p",{className:"text-xs text-muted-foreground",children:[t.label," · ",t.entityName,a!==void 0?` · ${a} current ${a===1?"link":"links"}`:n?` · ${n.rows.length} shown`:""]}),e.jsx(xt,{count:n?.failures?.length??0,onRetry:()=>void c()}),i?e.jsxs("div",{className:"space-y-2",children:[e.jsx($,{className:"h-6 w-full"}),e.jsx($,{className:"h-6 w-full"})]}):o||!n?e.jsxs("p",{className:"text-sm text-muted-foreground",children:["Could not load these links."," ",e.jsx("button",{type:"button",className:"underline",onClick:()=>void c(),children:"Retry"})]}):n.rows.length===0?e.jsx("p",{className:"text-sm text-muted-foreground",children:"No links on this page."}):e.jsx("ul",{className:"divide-y divide-border",children:n.rows.map(d=>e.jsx("li",{className:"flex items-center justify-between gap-3 py-1.5",children:e.jsx(ht,{row:d,entityId:t.entityId,ownerSlug:t.ownerSlug,orgContext:t.orgContext})},d.id))}),n&&(s>0||n.hasMore)?e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsx(k,{type:"button",variant:"outline",size:"sm",disabled:s===0,onClick:()=>r(Math.max(0,s-F)),children:"Previous"}),e.jsxs("span",{className:"text-xs tabular-nums text-muted-foreground",children:[n.rows.length," shown",a===void 0?"":` of ${a}`]}),e.jsx(k,{type:"button",variant:"outline",size:"sm",disabled:!n.hasMore,onClick:()=>r(s+F),children:"Next"})]}):null]})}function is({owner:t,path:s,viewKey:r}){const[n,i]=g.useState({}),{data:o,isLoading:c}=L(t,{slug:t}),a=o?.workspace,d=a?.type==="organization"?a.id:null,p=d?{slug:t,organizationId:d}:void 0,{data:m,isLoading:v}=te(`/${t}/${se(s)}`,p),{isMember:b,isPublic:x,isLoading:y}=Me(t),N=b||x,j=Fe({slug:t,organizationId:b?d:null}),u=m?.entity;if(c||v||y||N&&j.isLoading)return e.jsxs("div",{className:"flex items-center justify-center py-12 text-muted-foreground",children:[e.jsx(R,{className:"mr-2"})," Loading…"]});if(!N)return e.jsx(kt,{});if(j.isError)return e.jsx(At,{onRetry:()=>void j.refetch()});const h=u?Be(j.data??[],{type:u.entity_type,id:u.id??u.slug}).find(C=>C.key===r):void 0;return!d||!u||!h?e.jsx("p",{className:"px-4 py-8 text-center text-sm text-muted-foreground",children:"This view isn't attached to this record any more."}):e.jsx("div",{className:"px-4 py-4",children:e.jsx(Ct,{orgSlug:t,viewKey:h.key,scope:{type:u.entity_type,entity:u.is_derived?u.slug:u.id??u.slug},params:n,onParamsChange:i,paramDecls:h.params,contentHash:h.content_hash,title:h.name,minHeight:320})})}function oe({owner:t,runId:s}){const r=$t(t,s);if(t==="me")return null;if(r.isLoading)return e.jsx("p",{role:"status",className:"px-4 pt-4 text-xs text-muted-foreground",children:"Loading run…"});if(!r.data)return e.jsx("p",{role:"alert",className:"px-4 pt-4 text-sm text-destructive",children:"Could not load this run."});const n=r.data;return e.jsxs("section",{"aria-label":"Run outcome",className:"space-y-2 border-b px-4 py-4",children:[e.jsxs("div",{className:"flex flex-wrap items-center gap-2",children:[e.jsx(St,{status:It(n.status),children:n.status}),e.jsx("time",{dateTime:n.created_at,className:"text-xs text-muted-foreground",children:Ke(n.created_at)})]}),n.connection_display_name?e.jsx("p",{className:"text-sm",children:n.connection_display_name}):null,n.error_message?e.jsx("p",{className:"whitespace-pre-wrap break-words text-sm text-destructive",children:n.error_message}):null,r.isError?e.jsx("p",{role:"alert",className:"text-xs text-destructive",children:"Could not refresh this run. Showing its last known outcome."}):null]})}const Z=30;function I({label:t,children:s}){return e.jsxs("section",{className:"border-t px-4 py-3 first:border-t-0",children:[e.jsx("h3",{className:"mb-1.5 text-xs font-medium uppercase tracking-wide text-muted-foreground",children:t}),s]})}function B({label:t,detail:s}){return e.jsxs("div",{className:"flex items-baseline gap-3 py-0.5 text-sm",children:[e.jsx("span",{className:"min-w-0 flex-1 truncate",children:t}),e.jsx("span",{className:"shrink-0 truncate text-xs text-muted-foreground",children:s})]})}function as({stretch:t,ownerSlug:s,connectorDefinitions:r,connectionName:n,sourceConnection:i,showEntity:o}){const c=D(),a=g.useMemo(()=>He(t),[t]),d=g.useMemo(()=>Ue(t),[t]),[p,m]=g.useState(!1),[v,b]=g.useState(new Set),x=l=>e.jsx("li",{children:e.jsx(gt,{content:l,ownerSlug:s,connectorDefinitions:r,connectionName:n,showEntity:o})},l.id),y=l=>e.jsx("ul",{className:"-mx-1 divide-y overflow-hidden rounded-lg border",children:l.map(x)}),N=[...a.failedCalls.map(l=>l.content),...a.failedOperations.flatMap(l=>E(l)??[])],j=t.changes.flatMap(l=>E(l)??[]),u=[...t.calls.map(l=>l.content),...t.operations.flatMap(l=>E(l)??[])].sort((l,f)=>new Date(f.occurred_at).getTime()-new Date(l.occurred_at).getTime()),h=p?u:u.slice(0,Z),C=(l,f)=>e.jsxs(k,{variant:"ghost",size:"sm",className:"mt-2",onClick:f,children:["Show all ",l]});if(t.source){const{source:l}=t,f=t.flagged.flatMap(w=>E(w)??[]),le=d.reduce((w,W)=>w+W.items.length,0),_=i?.(l.connectionId)??null;return e.jsxs("div",{className:"pb-4",children:[e.jsxs("div",{className:"flex flex-wrap items-baseline gap-x-2 px-4 pt-3 pb-1 text-xs text-muted-foreground",children:[e.jsx("span",{children:l.name}),e.jsxs("span",{children:["· ",Y(t)]}),e.jsxs("span",{children:["· ",Q(le,"item")]}),f.length>0?e.jsxs("span",{children:["· ",f.length," failed"]}):null,_&&c?e.jsxs(k,{variant:"link",size:"sm",className:"h-auto p-0 text-xs",onClick:()=>c.open({href:`/${s}/connectors/${encodeURIComponent(_.connectorKey)}/${l.connectionId}`,key:`connection:${l.connectionId}`,title:l.name,connectorPanel:{section:"data",connectorKey:_.connectorKey,connectionId:l.connectionId,organizationId:_.organizationId,ownerSlug:s}}),children:["All data from ",l.name]}):null]}),f.length>0?e.jsx(I,{label:`Failed · ${f.length}`,children:y(f)}):null,d.map(w=>{const q=v.has(w.type)?w.items:w.items.slice(0,Z);return e.jsxs(I,{label:w.label,children:[y(q),w.items.length>q.length?C(w.items.length,()=>b(new Set([...v,w.type]))):null]},w.type)})]})}const T=a.did.reduce((l,f)=>l+f.count,0),A=a.lookedAt.reduce((l,f)=>l+f.count,0),S=t.apps.length===1?t.apps[0]:null,V=S?.key.startsWith("client:")?`/${s}/events?client_ids=${encodeURIComponent(S.key.slice(7))}`:S?.key.startsWith("agent:")?`/${s}/events?agent=${encodeURIComponent(S.key.slice(6))}`:null;return e.jsxs("div",{className:"pb-4",children:[e.jsxs("div",{className:"flex flex-wrap items-baseline gap-x-2 px-4 pt-3 pb-1 text-xs text-muted-foreground",children:[e.jsx("span",{children:ft(t)}),e.jsxs("span",{children:["· ",Y(t)]}),e.jsxs("span",{children:["· ",Q(t.calls.length,"call")]}),e.jsxs("span",{children:["· ",N.length," failed"]}),V&&S&&c?e.jsxs(k,{variant:"link",size:"sm",className:"h-auto p-0 text-xs",onClick:()=>c.open({href:V,title:S.name}),children:["All activity from ",S.name]}):null]}),N.length>0?e.jsx(I,{label:`Failed · ${N.length}`,children:y(N)}):null,t.kind==="background"?null:e.jsxs(I,{label:`Changed · ${j.length||a.changeSteps.reduce((l,f)=>l+f.count,0)}`,children:[j.length>0?y(j):null,a.changeSteps.map(l=>e.jsx(B,{label:l.title,detail:`${l.methods.join(" · ")} · ${l.count}`},l.title)),j.length===0&&a.changeSteps.length===0?e.jsx("p",{className:"text-sm text-muted-foreground",children:"Nothing changed."}):null]}),T>0?e.jsx(I,{label:`Did · ${T}`,children:a.did.map(l=>e.jsx(B,{label:l.group,detail:l.items.length>0?l.items.slice(0,5).map(f=>`${f.item} ${f.count}`).join(" · ")+(l.items.length>5?` · ${l.items.length-5} more`:""):String(l.count)},l.group))}):null,A>0?e.jsx(I,{label:`Looked at · ${A}`,children:a.lookedAt.map(l=>e.jsx(B,{label:l.title,detail:`${l.methods.join(" · ")} · ${l.count}`},l.title))}):null,e.jsxs(I,{label:`Raw calls · ${u.length}`,children:[y(h),u.length>h.length?C(u.length,()=>m(!0)):null]})]})}function en({item:t}){if(t.connectorPanel)return e.jsx(Vt,{panel:t.connectorPanel});if(t.schemaSections)return e.jsx(M,{item:t});if(t.recordField)return e.jsx(bt,{target:t.recordField});if(t.recordPeer)return e.jsx(Nt,{target:t.recordPeer});if(t.recordLinks)return e.jsx(rs,{target:t.recordLinks});if(t.workStretch)return e.jsx(as,{...t.workStretch});if(typeof t.browserUrl=="string"&&t.browserUrl.length>0)return e.jsx(J,{item:t});const s=t.href?Ve(t.href):null;return s?s.kind==="memory"?"runId"in s?e.jsxs(e.Fragment,{children:[e.jsx(oe,{owner:s.owner,runId:s.runId}),e.jsx(U,{title:"What it produced",children:e.jsx(O,{owner:s.owner,runId:s.runId})}),e.jsx(ce,{owner:s.owner,runId:s.runId})]}):"runIds"in s?e.jsx(O,{owner:s.owner,runIds:s.runIds}):e.jsx(O,{owner:s.owner,contentIds:s.contentIds}):s.kind==="entity"?e.jsx(Zt,{owner:s.owner,path:s.path}):s.kind==="entity-type"?e.jsx(ts,{owner:s.owner,typeSlug:s.typeSlug,view:s.view}):s.kind==="record-view"?e.jsx(is,{owner:s.owner,path:s.path,viewKey:s.viewKey}):s.kind==="event"?e.jsx(ss,{owner:s.owner,eventId:s.eventId,viewKey:s.viewKey}):s.kind==="feed"?e.jsx(ns,{owner:s.owner,feedId:s.feedId,semanticTypes:s.semanticTypes}):s.kind==="agent"?e.jsx(Xt,{owner:s.owner,name:t.title,agentId:s.agentId,clientIds:s.clientIds}):t.runId?e.jsx(os,{owner:s.owner,automationId:s.automationId,runId:t.runId}):e.jsx(cs,{owner:s.owner,automationId:s.automationId}):e.jsx(J,{item:t})}function J({item:t}){const s=t.body,r=t.notificationType??"generic",n=t.createdAt,i=t.browserUrl??null,o=t.browserHandoff??null;return e.jsxs("article",{className:"space-y-4 px-5 py-5",children:[e.jsxs("div",{className:"flex items-start gap-3",children:[e.jsx(We,{className:"mt-0.5 h-4 w-4 shrink-0 text-muted-foreground"}),e.jsxs("div",{className:"flex flex-wrap items-center gap-2 pt-0.5 text-xs text-muted-foreground",children:[e.jsx("span",{children:qe(r)}),n?e.jsx("span",{children:Ge(n)}):null]})]}),s?e.jsx("div",{className:"text-sm leading-6 text-foreground/90",children:e.jsx(Ye,{text:s,linkPolicy:r==="action_approval_needed"?"app-links":"strip"})}):e.jsx("p",{className:"text-sm text-muted-foreground",children:"No additional details were provided."}),t.owner&&t.sourceAttribution?e.jsxs("div",{className:"space-y-1",children:[e.jsx("p",{className:"text-xs font-medium uppercase tracking-wide text-muted-foreground/80",children:"Generated from"}),e.jsx(Qe,{owner:t.owner,source:t.sourceAttribution,className:"text-xs"})]}):null,i?e.jsx("div",{className:"space-y-2",children:o?.state==="expired"?e.jsx("p",{className:"text-sm text-amber-700 dark:text-amber-300",children:o.error_message??"This draft expired before the page was opened."}):o?.state==="completed"||o?.state==="preparing"?e.jsx("p",{className:"text-sm text-muted-foreground",children:o.state==="preparing"?"Preparing draft — keep your browser tab open.":"Draft prepared — review and post in your browser."}):e.jsxs(k,{type:"button",size:"sm",className:"h-8 text-sm",onClick:()=>{Ze(i)},children:[e.jsx(Xe,{className:"mr-1.5 h-3.5 w-3.5"}),"Open post"]})}):null]})}function U({title:t,children:s}){return e.jsxs("section",{"aria-label":t,className:"border-b",children:[e.jsx("h2",{className:"px-4 pt-4 text-xs font-medium uppercase tracking-wide text-muted-foreground",children:t}),s]})}function ce({owner:t,runId:s}){return t==="me"?null:e.jsx("div",{className:"px-4 py-3",children:e.jsxs(H,{to:"/$owner/events",params:{owner:t},search:{run_ids:String(s)},className:"inline-flex items-center gap-1 text-xs text-muted-foreground hover:text-foreground",children:["Open in Activity",e.jsx(Je,{"aria-hidden":"true",className:"h-3.5 w-3.5"})]})})}function os({owner:t,automationId:s,runId:r}){const{organizationId:n}=re(t),i=ie(s,void 0,n),o=et(i.data?.automation);return e.jsxs(e.Fragment,{children:[e.jsx(oe,{owner:t,runId:r}),e.jsx(U,{title:"What it produced",children:e.jsx(O,{owner:t,runId:r})}),o?e.jsx(U,{title:"How it ran",children:e.jsx(Ut,{agentId:o,automationId:s,ownerSlug:t,runId:r})}):i.isLoading?e.jsx($,{className:"m-4 h-24 rounded-lg"}):null,e.jsx(ce,{owner:t,runId:r})]})}function cs({owner:t,automationId:s}){const{organizationId:r}=re(t),n=ie(s,void 0,r),i=tt(t,s,n.data?.automation);return e.jsxs("div",{className:"flex flex-col gap-4 px-4 py-4",children:[e.jsx(st,{runNow:i}),e.jsx(nt,{owner:t,agentId:null,automationId:s,view:"activity",onDone:()=>{}})]})}export{en as PeekPaneContent};
2
+ //# sourceMappingURL=peek-pane-content-c2PG3TEX.js.map
@@ -1,2 +1,2 @@
1
- import{j as a,B as l,i as u}from"./index-C2TCKJDP.js";const c=({prompts:e,onPick:s,className:n})=>e.length===0?null:a.jsx("div",{className:u("flex flex-wrap gap-2",n),children:e.map(t=>a.jsx(l,{type:"button",variant:"outline",size:"sm",className:"h-auto rounded-full whitespace-normal px-3.5 py-1.5 text-left",title:t.message,"aria-label":`${t.title}: ${t.message}`,onClick:()=>s(t.message),children:t.title},`${t.title}\0${t.message}`))}),i=new Map;function d(e,s){const n=s.trim();n&&i.set(e,n)}function o(e){const s=i.get(e);return s===void 0?null:(i.delete(e),s)}export{c as P,d as s,o as t};
2
- //# sourceMappingURL=pending-seed-DYYOoCvj.js.map
1
+ import{j as a,B as l,i as u}from"./index-DByaMzsG.js";const c=({prompts:e,onPick:s,className:n})=>e.length===0?null:a.jsx("div",{className:u("flex flex-wrap gap-2",n),children:e.map(t=>a.jsx(l,{type:"button",variant:"outline",size:"sm",className:"h-auto rounded-full whitespace-normal px-3.5 py-1.5 text-left",title:t.message,"aria-label":`${t.title}: ${t.message}`,onClick:()=>s(t.message),children:t.title},`${t.title}\0${t.message}`))}),i=new Map;function d(e,s){const n=s.trim();n&&i.set(e,n)}function o(e){const s=i.get(e);return s===void 0?null:(i.delete(e),s)}export{c as P,d as s,o as t};
2
+ //# sourceMappingURL=pending-seed-CBhx2Ql-.js.map
@@ -1,2 +1,2 @@
1
- import{hI as f,hg as w,hh as y,r as C,j as e,a3 as N,B as d,T as P,eK as k}from"./index-C2TCKJDP.js";import{a as A}from"./runs-B_iywKWb.js";function B({resource:g,runId:r,children:h,onDone:l}){const c=!!r,{data:a,isLoading:E,isError:u,refetch:v}=A(g,c?r:void 0),s=f({isReview:c,isError:u,status:a?.status}),m=a?.status==="pending"?a.proposal:null,n=w(),i=y(),[p,x]=C.useState(""),o=n.isPending||i.isPending,j=s==="active"||s==="loading"||s==="error",b=()=>{r&&n.mutate({run_id:r},{onSuccess:()=>l?.()})},R=()=>{if(!r)return;const t=p.trim();i.mutate({run_id:r,...t?{reason:t}:{}},{onSuccess:()=>l?.()})};return e.jsxs("div",{className:"grid content-start gap-4",children:[s==="active"?e.jsx("div",{className:"rounded-lg border border-amber-200 bg-amber-50 p-3 text-sm text-amber-950 dark:border-amber-900/60 dark:bg-amber-950/30 dark:text-amber-100",children:e.jsxs("div",{className:"flex gap-2",children:[e.jsx(N,{className:"mt-0.5 h-4 w-4 shrink-0"}),e.jsxs("p",{children:["Review the change the builder agent proposed. Compare Current and Proposed, then ",e.jsx("strong",{children:"Approve"})," to apply, or"," ",e.jsx("strong",{children:"Reject"}),"."]})]})}):null,s==="gone"?e.jsx("div",{className:"rounded-lg border bg-muted/30 p-3 text-sm text-muted-foreground",children:"This change is no longer pending (it may have been approved or rejected already)."}):null,s==="error"?e.jsx("div",{className:"rounded-lg border border-destructive/40 bg-destructive/5 p-3 text-sm",children:e.jsxs("div",{className:"flex items-start justify-between gap-3",children:[e.jsx("p",{className:"text-destructive",children:"Couldn't load the proposed change to review. Editing is disabled until it loads — retry, or reopen the link."}),e.jsx(d,{type:"button",variant:"outline",size:"sm",onClick:()=>void v(),children:"Retry"})]})}):null,h({reviewMode:s,proposal:m,controlsDisabled:j}),s==="active"?e.jsxs("div",{className:"grid gap-3",children:[e.jsxs("div",{className:"grid gap-2",children:[e.jsx(P,{htmlFor:"review-reject-reason",children:"Reason (optional)"}),e.jsx(k,{id:"review-reject-reason",rows:2,value:p,onChange:t=>x(t.target.value),placeholder:"Why you're rejecting — shared back to the requester.",disabled:o})]}),e.jsxs("div",{className:"flex flex-col gap-2 sm:flex-row sm:justify-end",children:[e.jsx(d,{type:"button",variant:"outline",onClick:R,disabled:o,children:i.isPending?"Rejecting...":"Reject"}),e.jsx(d,{type:"button",onClick:b,disabled:o,children:n.isPending?"Approving...":"Approve"})]})]}):null]})}export{B as P};
2
- //# sourceMappingURL=proposal-review-shell-BVwOMoq9.js.map
1
+ import{hX as f,ht as w,hu as y,r as C,j as e,a8 as N,B as d,Z as P,f3 as k}from"./index-DByaMzsG.js";import{b as A}from"./runs-C8sZQr4o.js";function B({resource:g,runId:r,children:h,onDone:l}){const c=!!r,{data:a,isLoading:E,isError:u,refetch:v}=A(g,c?r:void 0),s=f({isReview:c,isError:u,status:a?.status}),m=a?.status==="pending"?a.proposal:null,n=w(),i=y(),[p,x]=C.useState(""),o=n.isPending||i.isPending,j=s==="active"||s==="loading"||s==="error",b=()=>{r&&n.mutate({run_id:r},{onSuccess:()=>l?.()})},R=()=>{if(!r)return;const t=p.trim();i.mutate({run_id:r,...t?{reason:t}:{}},{onSuccess:()=>l?.()})};return e.jsxs("div",{className:"grid content-start gap-4",children:[s==="active"?e.jsx("div",{className:"rounded-lg border border-amber-200 bg-amber-50 p-3 text-sm text-amber-950 dark:border-amber-900/60 dark:bg-amber-950/30 dark:text-amber-100",children:e.jsxs("div",{className:"flex gap-2",children:[e.jsx(N,{className:"mt-0.5 h-4 w-4 shrink-0"}),e.jsxs("p",{children:["Review the change the builder agent proposed. Compare Current and Proposed, then ",e.jsx("strong",{children:"Approve"})," to apply, or"," ",e.jsx("strong",{children:"Reject"}),"."]})]})}):null,s==="gone"?e.jsx("div",{className:"rounded-lg border bg-muted/30 p-3 text-sm text-muted-foreground",children:"This change is no longer pending (it may have been approved or rejected already)."}):null,s==="error"?e.jsx("div",{className:"rounded-lg border border-destructive/40 bg-destructive/5 p-3 text-sm",children:e.jsxs("div",{className:"flex items-start justify-between gap-3",children:[e.jsx("p",{className:"text-destructive",children:"Couldn't load the proposed change to review. Editing is disabled until it loads — retry, or reopen the link."}),e.jsx(d,{type:"button",variant:"outline",size:"sm",onClick:()=>void v(),children:"Retry"})]})}):null,h({reviewMode:s,proposal:m,controlsDisabled:j}),s==="active"?e.jsxs("div",{className:"grid gap-3",children:[e.jsxs("div",{className:"grid gap-2",children:[e.jsx(P,{htmlFor:"review-reject-reason",children:"Reason (optional)"}),e.jsx(k,{id:"review-reject-reason",rows:2,value:p,onChange:t=>x(t.target.value),placeholder:"Why you're rejecting — shared back to the requester.",disabled:o})]}),e.jsxs("div",{className:"flex flex-col gap-2 sm:flex-row sm:justify-end",children:[e.jsx(d,{type:"button",variant:"outline",onClick:R,disabled:o,children:i.isPending?"Rejecting...":"Reject"}),e.jsx(d,{type:"button",onClick:b,disabled:o,children:n.isPending?"Approving...":"Approve"})]})]}):null]})}export{B as P};
2
+ //# sourceMappingURL=proposal-review-shell-B-jYcKfB.js.map
@@ -0,0 +1,2 @@
1
+ import{r as e,eo as l}from"./index-DByaMzsG.js";function a(){return e.useEffect(()=>{l()},[]),null}export{a as P};
2
+ //# sourceMappingURL=public-shell-ready-D8TijlRY.js.map