@lobu/runtime-server 24.4.0 → 24.5.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 (279) hide show
  1. package/dist/catalogs/skills.json +2 -2
  2. package/dist/component.json +1 -1
  3. package/dist/connectors/postgres.ts +77 -48
  4. package/dist/dependencies.bun.lock +86 -117
  5. package/dist/owletto/dist/assets/_-CCWuGXtQ.js +2 -0
  6. package/dist/owletto/dist/assets/_-DOJW1D-I.js +3 -0
  7. package/dist/owletto/dist/assets/_agentId-CJhQbi6k.js +2 -0
  8. package/dist/owletto/dist/assets/_agentId-DD4K1i6V.js +2 -0
  9. package/dist/owletto/dist/assets/_automationId-Cbd7B0mP.js +2 -0
  10. package/dist/owletto/dist/assets/_connectorKey._connectionId-DFpPep9B.js +2 -0
  11. package/dist/owletto/dist/assets/_connectorKey.index-n3iSDT74.js +2 -0
  12. package/dist/owletto/dist/assets/_conversationId-B1yGIGA9.js +2 -0
  13. package/dist/owletto/dist/assets/_eventId-B1H0-vD7.js +2 -0
  14. package/dist/owletto/dist/assets/_name-D30_V03t.js +2 -0
  15. package/dist/owletto/dist/assets/_owner-Be8O41u8.js +3 -0
  16. package/dist/owletto/dist/assets/_shape-C6YbloRh.js +2 -0
  17. package/dist/owletto/dist/assets/_skillKey-BMPvvoOI.js +2 -0
  18. package/dist/owletto/dist/assets/_slug-Bc4YIEA2.js +2 -0
  19. package/dist/owletto/dist/assets/_view-aoFDwEld.js +2 -0
  20. package/dist/owletto/dist/assets/_viewKey-DuNHc3cc.js +2 -0
  21. package/dist/owletto/dist/assets/_viewKey-rJ7A1zNx.js +2 -0
  22. package/dist/owletto/dist/assets/accept-invitation-pUl-c1KQ.js +2 -0
  23. package/dist/owletto/dist/assets/activity-route-view-DN0ZEAzr.js +2 -0
  24. package/dist/owletto/dist/assets/{agent-card-controls-99mG6H5k.js → agent-card-controls-C5jNWgfq.js} +2 -2
  25. package/dist/owletto/dist/assets/{agent-client-setup-list-kMmqQSrf.js → agent-client-setup-list-DbXtJTsO.js} +2 -2
  26. package/dist/owletto/dist/assets/agent-connect-pages-DcTuiSt9.js +2 -0
  27. package/dist/owletto/dist/assets/agent-editor-form-CdA5vLr8.js +2 -0
  28. package/dist/owletto/dist/assets/agent-guardrails-route-BJyfalBY.js +2 -0
  29. package/dist/owletto/dist/assets/agent-list-row-rF5LH-3k.js +2 -0
  30. package/dist/owletto/dist/assets/{agent-loading-shells-Dnmb6W5Y.js → agent-loading-shells-ClY_O6lb.js} +2 -2
  31. package/dist/owletto/dist/assets/{agent-permissions-matrix-CbhXlbgY.js → agent-permissions-matrix-bP1Qihv7.js} +2 -2
  32. package/dist/owletto/dist/assets/{agent-skill-context-V__2i6Vl.js → agent-skill-context-BAaGpvfS.js} +2 -2
  33. package/dist/owletto/dist/assets/agent-skills-route-Bv5luNdw.js +2 -0
  34. package/dist/owletto/dist/assets/agent-tab-intro-ednTs4WF.js +2 -0
  35. package/dist/owletto/dist/assets/agent-thread-WNk2HapT.js +6 -0
  36. package/dist/owletto/dist/assets/agent-thread-storage-U6htL3ad.js +2 -0
  37. package/dist/owletto/dist/assets/agents-DY2S2SGE.js +2 -0
  38. package/dist/owletto/dist/assets/agents-workbench-bPTjdVS1.js +2 -0
  39. package/dist/owletto/dist/assets/app._appId-DrL5H5lB.js +2 -0
  40. package/dist/owletto/dist/assets/assist-composer-ClfFEVx7.js +2 -0
  41. package/dist/owletto/dist/assets/automation-detail-content-dFy1Huas.js +2 -0
  42. package/dist/owletto/dist/assets/automation-row-DCHM--aD.js +2 -0
  43. package/dist/owletto/dist/assets/automations-DY2S2SGE.js +2 -0
  44. package/dist/owletto/dist/assets/{calendar-DMq3Dtqy.js → calendar-Ck0yOLYu.js} +2 -2
  45. package/dist/owletto/dist/assets/{callback-B-CAz-bK.js → callback-DRABUOha.js} +2 -2
  46. package/dist/owletto/dist/assets/{card-SFtxv9f2.js → card-Bdi7VEwo.js} +2 -2
  47. package/dist/owletto/dist/assets/change-summary-PBoM6Asb.js +2 -0
  48. package/dist/owletto/dist/assets/{claim-DrxIRWKt.js → claim-CUIG1Oc-.js} +2 -2
  49. package/dist/owletto/dist/assets/{client-activity-scopes-boZOHuPW.js → client-activity-scopes-CXOWB5co.js} +2 -2
  50. package/dist/owletto/dist/assets/{client-rows-BJ2PxM4J.js → client-rows-36VnmgMK.js} +2 -2
  51. package/dist/owletto/dist/assets/{clients-C7Lnuc3S.js → clients-BJRcMk1A.js} +2 -2
  52. package/dist/owletto/dist/assets/code-editor-DNuRKde1.js +16 -0
  53. package/dist/owletto/dist/assets/connect-CMcEQWls.js +2 -0
  54. package/dist/owletto/dist/assets/connect-menu-C-B-1xGR.js +2 -0
  55. package/dist/owletto/dist/assets/connect._clientId-tGipxP5a.js +2 -0
  56. package/dist/owletto/dist/assets/connected._clientId-DSGU78eV.js +2 -0
  57. package/dist/owletto/dist/assets/connected._clientId.activity-CPLbry8R.js +2 -0
  58. package/dist/owletto/dist/assets/connected._clientId.index-jSnGvzYs.js +2 -0
  59. package/dist/owletto/dist/assets/{connection-feed-detail-D7pnWaFB.js → connection-feed-detail-BIlkK0Pd.js} +2 -2
  60. package/dist/owletto/dist/assets/connection-q1bdnxCN.js +2 -0
  61. package/dist/owletto/dist/assets/{connections-browser-DDJQh8Na.js → connections-browser-V-3td9DB.js} +2 -2
  62. package/dist/owletto/dist/assets/{connector-boxes-DDX7Ebc4.js → connector-boxes-lFc-WP83.js} +2 -2
  63. package/dist/owletto/dist/assets/connector-page-shell-Cs1SjrYB.js +2 -0
  64. package/dist/owletto/dist/assets/connector-provenance-aJFeeRIC.js +2 -0
  65. package/dist/owletto/dist/assets/{connector-scope-lists-BibdzKl1.js → connector-scope-lists--vNdbOn0.js} +2 -2
  66. package/dist/owletto/dist/assets/connectors-BsvDMdsQ.js +2 -0
  67. package/dist/owletto/dist/assets/consent-DJV78pnz.js +2 -0
  68. package/dist/owletto/dist/assets/copy-button-DjMWgrBf.js +2 -0
  69. package/dist/owletto/dist/assets/{core.esm-CHnfRiEM.js → core.esm-CQzL3ObT.js} +3 -3
  70. package/dist/owletto/dist/assets/create-BmKx5vq3.js +2 -0
  71. package/dist/owletto/dist/assets/create-Rt0RbiD4.js +2 -0
  72. package/dist/owletto/dist/assets/create-automation-form-PEmSLMD6.js +3 -0
  73. package/dist/owletto/dist/assets/create-jBEuveV1.js +2 -0
  74. package/dist/owletto/dist/assets/create._connectorKey-DcxhYIYC.js +2 -0
  75. package/dist/owletto/dist/assets/device-Ba3RsIgb.js +2 -0
  76. package/dist/owletto/dist/assets/device-pin-tombstone-C79KIAIK.js +2 -0
  77. package/dist/owletto/dist/assets/device._deviceId-CIaoq9co.js +2 -0
  78. package/dist/owletto/dist/assets/{entity-avatar-HloBoalJ.js → entity-avatar-TVKjZxWQ.js} +2 -2
  79. package/dist/owletto/dist/assets/entity-options-daOOQo7O.js +2 -0
  80. package/dist/owletto/dist/assets/entity-page-BfJXvbxn.js +2 -0
  81. package/dist/owletto/dist/assets/entity-type-page-BLwH6qa7.js +2 -0
  82. package/dist/owletto/dist/assets/event-card-DVUB8my6.js +2 -0
  83. package/dist/owletto/dist/assets/event-detail-DkY95e5b.js +2 -0
  84. package/dist/owletto/dist/assets/{events-feed-BysC9HgU.js → events-feed-B9CZHI_P.js} +2 -2
  85. package/dist/owletto/dist/assets/filter-bar-wPaR12SS.js +2 -0
  86. package/dist/owletto/dist/assets/{full-page-spinner-BMiXl54z.js → full-page-spinner-BqmckkOf.js} +2 -2
  87. package/dist/owletto/dist/assets/guardrails-Csusrok2.js +2 -0
  88. package/dist/owletto/dist/assets/identity-Dmg3STO8.js +2 -0
  89. package/dist/owletto/dist/assets/index--ZWegctR.js +2 -0
  90. package/dist/owletto/dist/assets/{index-CzoK57xp.js → index-B0kw2lFL.js} +2 -2
  91. package/dist/owletto/dist/assets/index-BKrdVwW9.js +2 -0
  92. package/dist/owletto/dist/assets/index-BUBcNNUY.js +2 -0
  93. package/dist/owletto/dist/assets/index-BUDr4-Yv.js +2 -0
  94. package/dist/owletto/dist/assets/index-BYPQWVwD.js +2 -0
  95. package/dist/owletto/dist/assets/index-BfpaPJPj.js +2 -0
  96. package/dist/owletto/dist/assets/index-BicNFLBW.js +2 -0
  97. package/dist/owletto/dist/assets/index-Bsdv5aks.js +2 -0
  98. package/dist/owletto/dist/assets/index-C186T2Rw.js +53 -0
  99. package/dist/owletto/dist/assets/index-CX0pJ9j9.js +2 -0
  100. package/dist/owletto/dist/assets/{index-B4wXJwQY.js → index-CsrT07TJ.js} +2 -2
  101. package/dist/owletto/dist/assets/index-DdBTTN3y.js +7899 -0
  102. package/dist/owletto/dist/assets/index-DdYWarql.css +1 -0
  103. package/dist/owletto/dist/assets/index-JYEIN8nM.js +2 -0
  104. package/dist/owletto/dist/assets/index-Vcq4gwWv.js +2 -0
  105. package/dist/owletto/dist/assets/{index-C-WaHj1Y.js → index-ijqrJaRB.js} +2 -2
  106. package/dist/owletto/dist/assets/{index-D4-uel59.js → index-ikp_mTsf.js} +2 -2
  107. package/dist/owletto/dist/assets/json-diff-BaLL4Fsu.js +14 -0
  108. package/dist/owletto/dist/assets/{list-skeleton-Bp4HNgJ9.js → list-skeleton-CXDLkYTg.js} +2 -2
  109. package/dist/owletto/dist/assets/login-u6LCgDYG.js +2 -0
  110. package/dist/owletto/dist/assets/{logout-DxmfsVKD.js → logout-JhmuWJEH.js} +2 -2
  111. package/dist/owletto/dist/assets/manage-gear-D8LMhehh.js +2 -0
  112. package/dist/owletto/dist/assets/{member-scope-gate-vp3FihBD.js → member-scope-gate-4FQ0aanZ.js} +2 -2
  113. package/dist/owletto/dist/assets/memory-browse-page-CNZJbCJC.js +74 -0
  114. package/dist/owletto/dist/assets/model-jL871x2J.js +2 -0
  115. package/dist/owletto/dist/assets/model-selector-CgU8SJMF.js +2 -0
  116. package/dist/owletto/dist/assets/models-jdemgIZk.js +2 -0
  117. package/dist/owletto/dist/assets/nav-pill-DrFkuyUQ.js +2 -0
  118. package/dist/owletto/dist/assets/new-CcJOd5aH.js +2 -0
  119. package/dist/owletto/dist/assets/{new-CvX8_gIb.js → new-DgE1pVV0.js} +2 -2
  120. package/dist/owletto/dist/assets/new-OWwrYckd.js +2 -0
  121. package/dist/owletto/dist/assets/organization-CKM_oFX3.js +2 -0
  122. package/dist/owletto/dist/assets/peek-pane-content-D68BjguQ.js +2 -0
  123. package/dist/owletto/dist/assets/pending-seed-sml8Uf6e.js +2 -0
  124. package/dist/owletto/dist/assets/permissions-BvA9SATv.js +2 -0
  125. package/dist/owletto/dist/assets/{proposal-review-shell-B4CSiyLB.js → proposal-review-shell-D6KABxah.js} +2 -2
  126. package/dist/owletto/dist/assets/public-shell-ready-BIVCHQHe.js +2 -0
  127. package/dist/owletto/dist/assets/record-activity-C9gVBbF0.js +2 -0
  128. package/dist/owletto/dist/assets/{record-session-CWXnCVln.js → record-session-R-uHNuby.js} +2 -2
  129. package/dist/owletto/dist/assets/{renderer-7EGgTVX0.js → renderer-DXfJaCCa.js} +23 -23
  130. package/dist/owletto/dist/assets/{reset-password-CFUzxH7m.js → reset-password-Mx3baeNc.js} +2 -2
  131. package/dist/owletto/dist/assets/run-activity-link-CaIBSRQj.js +2 -0
  132. package/dist/owletto/dist/assets/run-initiator-BvzQJYW9.js +2 -0
  133. package/dist/owletto/dist/assets/{runs-BPtQBTRN.js → runs-fFJ1lPnw.js} +2 -2
  134. package/dist/owletto/dist/assets/runs-panel-DEnZHTa5.js +2 -0
  135. package/dist/owletto/dist/assets/runs-table-XGnxJl7S.js +2 -0
  136. package/dist/owletto/dist/assets/{schema-type-editor-panel-CAhOB648.js → schema-type-editor-panel-C0_9VcSs.js} +2 -2
  137. package/dist/owletto/dist/assets/settings-CP4PjMQA.js +2 -0
  138. package/dist/owletto/dist/assets/settings-CgaUJMHH.js +2 -0
  139. package/dist/owletto/dist/assets/skills-D-e_h3a9.js +2 -0
  140. package/dist/owletto/dist/assets/{source-record-panels-Bh5F4C5K.js → source-record-panels-Bh0n4gGw.js} +2 -2
  141. package/dist/owletto/dist/assets/{status-dot-D3FoDRcc.js → status-dot-Cpq63I7p.js} +2 -2
  142. package/dist/owletto/dist/assets/{table-DFcJRNk7.js → table-BUqshjxa.js} +2 -2
  143. package/dist/owletto/dist/assets/{use-automations-BHoV0dLs.js → use-automations-BLNjxq2K.js} +2 -2
  144. package/dist/owletto/dist/assets/use-login-redirect-CmyQW7GT.js +2 -0
  145. package/dist/owletto/dist/assets/{use-mention-search-C3rWLuKm.js → use-mention-search-dn3ws1WB.js} +3 -3
  146. package/dist/owletto/dist/assets/use-scroll-sentinel-DRyBMueA.js +2 -0
  147. package/dist/owletto/dist/assets/view-param-filters-CER47Tlz.js +2 -0
  148. package/dist/owletto/dist/assets/{views-access-required-DHrDO333.js → views-access-required-C_b9itZ2.js} +2 -2
  149. package/dist/owletto/dist/index.html +2 -2
  150. package/dist/server-main.bundle.mjs +53989 -51632
  151. package/dist/server.bundle.mjs +5 -5
  152. package/dist/verify.mjs +1 -1
  153. package/npm-shrinkwrap.json +183 -217
  154. package/package.json +3 -4
  155. package/vendor/connector-sdk/dist/reaction-client-types.d.ts +8 -2
  156. package/vendor/connector-sdk/dist/reaction-sdk.d.ts +5 -1
  157. package/vendor/connector-sdk/package.json +1 -1
  158. package/vendor/core/dist/contracts/agent-settings.d.ts +61 -6
  159. package/vendor/core/dist/contracts/agent-settings.js +10 -7
  160. package/vendor/core/dist/contracts/tools/manage-agents.d.ts +473 -98
  161. package/vendor/core/dist/contracts/tools/manage-agents.js +111 -2
  162. package/vendor/core/dist/contracts/tools/manage-automations.d.ts +21 -18
  163. package/vendor/core/dist/contracts/tools/manage-automations.js +15 -15
  164. package/vendor/core/dist/contracts/tools/manage-entity-schema.js +2 -2
  165. package/vendor/core/dist/contracts/tools/manage-inference-providers.d.ts +445 -0
  166. package/vendor/core/dist/contracts/tools/manage-inference-providers.js +133 -0
  167. package/vendor/core/dist/contracts/tools/manage-views.d.ts +4 -4
  168. package/vendor/core/dist/contracts/tools/manage-views.js +5 -3
  169. package/vendor/core/dist/contracts/worker/device-automation.js +4 -2
  170. package/vendor/core/dist/error-report.d.ts +73 -0
  171. package/vendor/core/dist/error-report.js +346 -0
  172. package/vendor/core/dist/index.d.ts +3 -1
  173. package/vendor/core/dist/index.js +4 -1
  174. package/vendor/core/dist/logger.js +7 -4
  175. package/vendor/core/dist/otel-fetch.d.ts +19 -0
  176. package/vendor/core/dist/otel-fetch.js +96 -0
  177. package/vendor/core/dist/otel.d.ts +9 -0
  178. package/vendor/core/dist/otel.js +28 -7
  179. package/vendor/core/dist/reserved.d.ts +1 -1
  180. package/vendor/core/dist/reserved.js +6 -4
  181. package/vendor/core/dist/tool-result.d.ts +8 -0
  182. package/vendor/core/dist/tool-result.js +61 -0
  183. package/vendor/core/dist/utils/diagnostic-scrubber.js +1 -1
  184. package/vendor/core/dist/worker/auth.js +4 -0
  185. package/vendor/core/package.json +6 -1
  186. package/vendor/views/package.json +1 -1
  187. package/dist/owletto/dist/assets/_-DIK0ae_S.js +0 -2
  188. package/dist/owletto/dist/assets/_-gTbcArpS.js +0 -3
  189. package/dist/owletto/dist/assets/_agentId-DOmcJZfk.js +0 -2
  190. package/dist/owletto/dist/assets/_agentId-DW6wRCVC.js +0 -2
  191. package/dist/owletto/dist/assets/_automationId-B9IcDYBu.js +0 -2
  192. package/dist/owletto/dist/assets/_connectorKey._connectionId-C6PmMPTA.js +0 -2
  193. package/dist/owletto/dist/assets/_connectorKey.index-BrJ8Pzze.js +0 -2
  194. package/dist/owletto/dist/assets/_conversationId-BpJAeYYW.js +0 -2
  195. package/dist/owletto/dist/assets/_eventId-DarQJo0G.js +0 -2
  196. package/dist/owletto/dist/assets/_name-DtmNTcUm.js +0 -2
  197. package/dist/owletto/dist/assets/_owner-Db8at3hk.js +0 -3
  198. package/dist/owletto/dist/assets/_shape-6iFA8A86.js +0 -2
  199. package/dist/owletto/dist/assets/_skillKey-CXkHn3Nl.js +0 -2
  200. package/dist/owletto/dist/assets/_slug-DBOuBLoX.js +0 -2
  201. package/dist/owletto/dist/assets/_viewKey-DC27aIN9.js +0 -2
  202. package/dist/owletto/dist/assets/_viewKey-DuYDieln.js +0 -2
  203. package/dist/owletto/dist/assets/accept-invitation-BbDCVvur.js +0 -2
  204. package/dist/owletto/dist/assets/activity-route-view-V4ftmSN7.js +0 -2
  205. package/dist/owletto/dist/assets/agent-connect-pages-B-NPTFs6.js +0 -2
  206. package/dist/owletto/dist/assets/agent-editor-form-DfMTSIvj.js +0 -2
  207. package/dist/owletto/dist/assets/agent-guardrails-route-BvGgfd-h.js +0 -2
  208. package/dist/owletto/dist/assets/agent-skills-route-DFXr_bHp.js +0 -2
  209. package/dist/owletto/dist/assets/agent-subpage-shell-DWzljvFb.js +0 -2
  210. package/dist/owletto/dist/assets/agent-thread-DQIr20H-.js +0 -6
  211. package/dist/owletto/dist/assets/agents-CLbeiqTR.js +0 -2
  212. package/dist/owletto/dist/assets/agents-workbench-C8bTa2rv.js +0 -2
  213. package/dist/owletto/dist/assets/app._appId-Bsq40nak.js +0 -2
  214. package/dist/owletto/dist/assets/automation-detail-content-C9Cgr5Zj.js +0 -2
  215. package/dist/owletto/dist/assets/automations-CLbeiqTR.js +0 -2
  216. package/dist/owletto/dist/assets/code-editor-rX0t1g5C.js +0 -16
  217. package/dist/owletto/dist/assets/connect-BcwgytDV.js +0 -2
  218. package/dist/owletto/dist/assets/connect-menu-BF-AlunU.js +0 -2
  219. package/dist/owletto/dist/assets/connect._clientId-sDypRDeN.js +0 -2
  220. package/dist/owletto/dist/assets/connected._clientId-C9OkW1tv.js +0 -2
  221. package/dist/owletto/dist/assets/connected._clientId.activity-Dc6HYr55.js +0 -2
  222. package/dist/owletto/dist/assets/connected._clientId.index-C6qbqgwF.js +0 -2
  223. package/dist/owletto/dist/assets/connection-88YzIBK9.js +0 -2
  224. package/dist/owletto/dist/assets/connector-provenance-Th8ymGec.js +0 -2
  225. package/dist/owletto/dist/assets/connectors-BqwgLUUK.js +0 -2
  226. package/dist/owletto/dist/assets/consent-BR5U7dwb.js +0 -2
  227. package/dist/owletto/dist/assets/copy-button-2swYh4jb.js +0 -2
  228. package/dist/owletto/dist/assets/create-BsPVnRpG.js +0 -2
  229. package/dist/owletto/dist/assets/create-CVPYVOR5.js +0 -2
  230. package/dist/owletto/dist/assets/create-QFjmhOEU.js +0 -2
  231. package/dist/owletto/dist/assets/create-automation-form-DmCOFbRT.js +0 -3
  232. package/dist/owletto/dist/assets/create._connectorKey-DLDDVtLS.js +0 -2
  233. package/dist/owletto/dist/assets/cronstrue-CKwjNYgj.js +0 -2
  234. package/dist/owletto/dist/assets/device-CKup7kvB.js +0 -2
  235. package/dist/owletto/dist/assets/device-pin-tombstone-xGhCTU5_.js +0 -2
  236. package/dist/owletto/dist/assets/device._deviceId-B1H_ivDT.js +0 -2
  237. package/dist/owletto/dist/assets/entity-options-BSW_EG0W.js +0 -2
  238. package/dist/owletto/dist/assets/entity-page-D-WDWrAe.js +0 -2
  239. package/dist/owletto/dist/assets/entity-type-page-BCBdFndu.js +0 -2
  240. package/dist/owletto/dist/assets/event-card-Mcxv56DG.js +0 -2
  241. package/dist/owletto/dist/assets/event-detail-DXifj49J.js +0 -2
  242. package/dist/owletto/dist/assets/filter-bar-BQm-ubB1.js +0 -2
  243. package/dist/owletto/dist/assets/guardrails-D7W80sJO.js +0 -2
  244. package/dist/owletto/dist/assets/identity-N0cAO9BR.js +0 -2
  245. package/dist/owletto/dist/assets/index-4gCDI7m4.js +0 -7950
  246. package/dist/owletto/dist/assets/index-BNaI5GpS.js +0 -2
  247. package/dist/owletto/dist/assets/index-BUUrHuJJ.js +0 -2
  248. package/dist/owletto/dist/assets/index-BqrvJmLh.js +0 -2
  249. package/dist/owletto/dist/assets/index-CnvQEA5V.js +0 -2
  250. package/dist/owletto/dist/assets/index-Cq7P2c_E.js +0 -2
  251. package/dist/owletto/dist/assets/index-D3omC3Us.js +0 -2
  252. package/dist/owletto/dist/assets/index-DDGdlQrt.css +0 -1
  253. package/dist/owletto/dist/assets/index-DFEW7hMg.js +0 -2
  254. package/dist/owletto/dist/assets/index-DVV-WWuT.js +0 -2
  255. package/dist/owletto/dist/assets/index-DduQ_e9q.js +0 -2
  256. package/dist/owletto/dist/assets/index-DutlI1d-.js +0 -2
  257. package/dist/owletto/dist/assets/index-wHFQv1aT.js +0 -12
  258. package/dist/owletto/dist/assets/json-diff-E5D-NGYT.js +0 -4
  259. package/dist/owletto/dist/assets/login-7F48UJGx.js +0 -2
  260. package/dist/owletto/dist/assets/memory-browse-page-CfDmjhDl.js +0 -74
  261. package/dist/owletto/dist/assets/model-Dn40BUzs.js +0 -2
  262. package/dist/owletto/dist/assets/model-selector-88PJnyTq.js +0 -2
  263. package/dist/owletto/dist/assets/models-BBK_n2RP.js +0 -2
  264. package/dist/owletto/dist/assets/new-4ruWHLR5.js +0 -2
  265. package/dist/owletto/dist/assets/new-gMD1PHTL.js +0 -2
  266. package/dist/owletto/dist/assets/oauth-workspace-access-D9BNmyMY.js +0 -2
  267. package/dist/owletto/dist/assets/organization-BHcp5Pzg.js +0 -2
  268. package/dist/owletto/dist/assets/peek-pane-content-0sa10jER.js +0 -2
  269. package/dist/owletto/dist/assets/permissions-hhxosugv.js +0 -2
  270. package/dist/owletto/dist/assets/public-shell-ready-CsenJeXa.js +0 -2
  271. package/dist/owletto/dist/assets/record-activity-D7bRaMk2.js +0 -2
  272. package/dist/owletto/dist/assets/runs-panel-Bj63_hb9.js +0 -2
  273. package/dist/owletto/dist/assets/settings-Dg6nxKyw.js +0 -2
  274. package/dist/owletto/dist/assets/settings-KJJ6WihO.js +0 -2
  275. package/dist/owletto/dist/assets/skills-ayt06_o2.js +0 -2
  276. package/dist/owletto/dist/assets/use-scroll-sentinel-Ct-jt7O0.js +0 -2
  277. package/dist/owletto/dist/assets/view-param-filters-mKoqDsaD.js +0 -2
  278. /package/vendor/@better-auth-kysely-adapter/{.bun-tag-abf95749a412716 → .bun-tag-654b3a002b271269} +0 -0
  279. /package/vendor/postgres/{.bun-tag-22d644c2873790db → .bun-tag-c81dacd34e959a7a} +0 -0
@@ -1,2 +1,2 @@
1
- import{j as s,S as e}from"./index-4gCDI7m4.js";function m({label:r,actions:l=!1}){return s.jsx("div",{className:"overflow-hidden rounded-lg border",role:"status","aria-label":r,children:Array.from({length:4},(d,a)=>s.jsxs("div",{className:`flex items-center gap-3 px-3 py-2.5 ${a===3?"":"border-b"}`,children:[s.jsx(e,{className:"h-7 w-7 shrink-0 rounded-md"}),s.jsxs("div",{className:"min-w-0 flex-1 space-y-1.5",children:[s.jsx(e,{className:"h-4 w-40"}),s.jsx(e,{className:"h-3 w-24"})]}),l?s.jsxs("div",{className:"flex shrink-0 items-center gap-1",children:[s.jsx(e,{className:"h-8 w-8 rounded-md"}),s.jsx(e,{className:"h-8 w-8 rounded-md"})]}):null]},a))})}export{m as L};
2
- //# sourceMappingURL=list-skeleton-Bp4HNgJ9.js.map
1
+ import{j as s,S as e}from"./index-DdBTTN3y.js";function m({label:r,actions:l=!1}){return s.jsx("div",{className:"overflow-hidden rounded-lg border",role:"status","aria-label":r,children:Array.from({length:4},(d,a)=>s.jsxs("div",{className:`flex items-center gap-3 px-3 py-2.5 ${a===3?"":"border-b"}`,children:[s.jsx(e,{className:"h-7 w-7 shrink-0 rounded-md"}),s.jsxs("div",{className:"min-w-0 flex-1 space-y-1.5",children:[s.jsx(e,{className:"h-4 w-40"}),s.jsx(e,{className:"h-3 w-24"})]}),l?s.jsxs("div",{className:"flex shrink-0 items-center gap-1",children:[s.jsx(e,{className:"h-8 w-8 rounded-md"}),s.jsx(e,{className:"h-8 w-8 rounded-md"})]}):null]},a))})}export{m as L};
2
+ //# sourceMappingURL=list-skeleton-CXDLkYTg.js.map
@@ -0,0 +1,2 @@
1
+ import{c as Ne,a6 as Ce,q as Se,a7 as Ee,E as Le,r as s,a8 as Ue,a9 as Fe,aa as ie,j as e,ab as b,ac as ce,ad as $,ae as Pe,af as Ie,ag as Me,a3 as ze,Q as Ae,a4 as Re,ah as oe}from"./index-DdBTTN3y.js";import{s as qe}from"./index-C186T2Rw.js";import{C as $e,c as Be}from"./card-Bdi7VEwo.js";function B(l){if(!l||typeof l!="object")return null;const f=l.error;if(typeof f=="string")return f;if(f&&typeof f=="object"){const y=f.message;if(typeof y=="string"&&y.length>0)return y}const m=l.message;return typeof m=="string"&&m.length>0?m:null}async function le(l,f){if(typeof window>"u")return;const m=window.PasswordCredential;if(!(!m||!navigator.credentials?.store))try{const y=new m({id:l,password:f});await navigator.credentials.store(y)}catch{}}function Oe({domain:l}){const[f,m]=s.useState(!1);return!(l.length>0&&l.length<=253&&/^[A-Za-z0-9.-]+$/.test(l))||f?e.jsx(ce,{className:"w-4 h-4"}):e.jsx("img",{src:`https://www.google.com/s2/favicons?domain=${encodeURIComponent(l)}&sz=32`,alt:"",width:16,height:16,className:"h-4 w-4",onError:()=>m(!0)})}function E(l){return l?l.toLowerCase().replaceAll("_"," ").trim().includes("account not linked")?"This social account matches an existing Lobu user. Sign in with a magic link to verify ownership, then continue.":l:null}function He(){const l=Ne(),f=Ce(),{session:m,isReady:y}=Se(),{data:i,isLoading:U,error:O}=Ee(),a=Le({from:"/auth/login"}),de=a.invitationOrg,[p,j]=s.useState("social"),[d,P]=s.useState(a.intent??"sign-in"),[T,ue]=s.useState(""),[o,W]=s.useState(()=>a.loginHint??""),[k,me]=s.useState(""),[N,ge]=s.useState(""),[I,V]=s.useState(""),[fe,Q]=s.useState(!1),[c,u]=s.useState(null),[M,r]=s.useState(null),[J,G]=s.useState(!1),[pe,K]=s.useState(!1),[Z,he]=s.useState(!1),X=s.useRef(!1),L=a.callbackUrl?Ue(a.callbackUrl):void 0,z=Fe(de,a.loginHint),Y=a.mode==="extension",D=a.error==="account_not_linked",ee=E(a.errorDescription||a.error),A=Object.values(i?.social??{}).some(Boolean),w=!!i?.magicLink,R=!!i?.phone,h=!!i?.emailPassword,te=!!i?.passkey,x=!!i?.singleUserMode,ne=!!i?.hasUser,H=x,F=p==="magic-link"&&w&&J,v=s.useMemo(()=>{const t=[];return h&&t.push("email-password"),A&&t.push("social"),w&&t.push("magic-link"),R&&t.push("whatsapp"),t},[h,w,A,R]),xe=s.useMemo(()=>h?v.filter(t=>t!=="magic-link"&&t!=="social"):v,[v,h]),_=O instanceof Error?O.message:O?"Unable to load sign-in options.":null;s.useEffect(()=>{if(m){const t=ie(L);L?window.location.href=t:l({to:"/"})}},[m,l,L]),s.useEffect(()=>{!i||v.length===0||v.includes(p)||j(v[0])},[i,p,v]),s.useEffect(()=>{!w||!D||(j("magic-link"),a.loginHint&&!o&&W(a.loginHint))},[w,D,a.loginHint,o]),s.useEffect(()=>{a.intent&&P(a.intent)},[a.intent]),s.useEffect(()=>{if(!x||!i)return;const t=ne?"sign-in":"sign-up";d!==t&&P(t)},[x,ne,i,d]);const C=()=>L?ie(L):"/",se=async(t,{quiet:n=!1}={})=>{u(t),r(null);try{const g=await $.social({provider:t,callbackURL:C(),newUserCallbackURL:L?C():`/?onboard_provider=${encodeURIComponent(t)}`}),S=B(g);if(S&&!n){const q=E(S);q?.toLowerCase().includes("magic link")&&j("magic-link"),r(q)}}catch(g){if(n)return;r(E(g instanceof Error?g.message:`Failed to sign in with ${t}`))}finally{u(null)}};s.useEffect(()=>{if(X.current||!y||m||U||!i||a.error)return;const t=a.provider;if(!t)return;X.current=!0;const n=Object.hasOwn(i.social??{},t)&&!!i.social?.[t];se(t,{quiet:!n})},[i,U,m,y,a.provider,a.error]);const re=async()=>{if(o){u("magic-link"),r(null);try{return await $.magicLink({email:o,callbackURL:C()}),G(!0),!0}catch(t){return r(t instanceof Error?t.message:"Failed to send magic link"),!1}finally{u(null)}}},be=async t=>{t.preventDefault(),await re()},ye=async t=>{if(t.preventDefault(),!(!o||!k)){u("email-password"),r(null);try{if(d==="sign-up"){const n=await Ie.email({email:o,password:k,name:T||o.split("@")[0]||"User",callbackURL:C()}),g=B(n);if(g){r(E(g));return}if(await le(o,k),await f.invalidateQueries({queryKey:["organizations"]}),x&&te)try{await Me.passkey.addPasskey({name:T||`${navigator.platform||"This device"}`})}catch{}}else{const n=await $.email({email:o,password:k,callbackURL:C()}),g=B(n);if(g){r(E(g));return}if(!n?.data){r("Invalid email or password");return}await le(o,k)}}catch(n){const g=n instanceof Error?n.message:typeof n=="string"?n:B(n);r(g||"Authentication failed")}finally{u(null)}}},ae=async()=>{r(null),he(!0),u("local");try{const t=await Pe();if(!t.ok){const n=await t.json().catch(()=>null);r(n?.error_description??"Could not sign in to your local install.");return}window.location.href=C()}catch(t){r(t instanceof Error?t.message:"Could not sign in to your local install.")}finally{u(null)}};s.useEffect(()=>{H&&i&&!m&&!Z&&ae()},[H,i,m,Z]);const je=async()=>{if(!o){r("Enter your email address first to reset your password.");return}u("reset-password-request"),r(null);try{const t=`${window.location.origin}/auth/reset-password`,n=await ze(`${Ae}/api/auth/request-password-reset`,{method:"POST",headers:{"Content-Type":"application/json"},credentials:"include",body:JSON.stringify({email:o,redirectTo:t})});if(!n.ok)throw await Re(n);K(!0)}catch(t){r(t instanceof Error?t.message:"Failed to send password reset email")}finally{u(null)}},we=async t=>{if(t.preventDefault(),!!N){u("phone"),r(null);try{await oe.sendOtp({phoneNumber:N}),Q(!0)}catch(n){r(n instanceof Error?n.message:"Failed to send verification code")}finally{u(null)}}},ve=async t=>{if(t.preventDefault(),!(!N||!I)){u("verify"),r(null);try{await oe.verify({phoneNumber:N,code:I})}catch(n){r(n instanceof Error?n.message:"Invalid verification code"),u(null)}}};return e.jsx("div",{className:"min-h-[calc(100vh-3.5rem)] flex items-center justify-center",children:e.jsxs("div",{className:"w-full max-w-md p-8",children:[e.jsxs("div",{className:"text-center mb-8",children:[e.jsx("img",{src:"/lobu-logo.svg",alt:"Lobu",className:"mx-auto mb-6 h-8 w-auto"}),e.jsx("h1",{className:"text-2xl font-bold",children:z?z.title:x&&d==="sign-up"?"Set up your local install":x?"Welcome back":d==="sign-up"?"Create your account":"Sign in"}),e.jsx("p",{className:"text-muted-foreground mt-2",children:z?z.detail:x&&d==="sign-up"?"This account stays on this machine. Email is just an identifier — pick anything you’ll remember.":x?"Sign in to your local install.":Y?"Sign in to connect the browser extension":d==="sign-up"?"Choose a sign-up method":"Choose your preferred sign-in method"}),x&&e.jsxs("div",{className:"mt-3 inline-flex items-center gap-2 px-3 py-1.5 bg-muted text-muted-foreground rounded-full text-xs",children:[e.jsx("svg",{className:"w-3.5 h-3.5",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24","aria-hidden":"true",children:e.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M12 15v2m-6 4h12a2 2 0 002-2v-6a2 2 0 00-2-2H6a2 2 0 00-2 2v6a2 2 0 002 2zm10-10V7a4 4 0 00-8 0v4h8z"})}),"Local install · nothing sent to lobu.ai"]}),Y&&e.jsxs("div",{className:"mt-3 inline-flex items-center gap-2 px-3 py-1.5 bg-primary/10 text-primary rounded-full text-sm",children:[e.jsx("svg",{className:"w-4 h-4",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24","aria-hidden":"true",children:e.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M9 12l2 2 4-4m5.618-4.016A11.955 11.955 0 0112 2.944a11.955 11.955 0 01-8.618 3.04A12.02 12.02 0 003 9c0 5.591 3.824 10.29 9 11.622 5.176-1.332 9-6.03 9-11.622 0-1.042-.133-2.052-.382-3.016z"})}),"Browser Extension"]})]}),e.jsx($e,{children:e.jsx(Be,{children:H?e.jsx("div",{className:"space-y-4",children:M?e.jsxs(e.Fragment,{children:[e.jsx("div",{className:"rounded-md bg-destructive/10 px-3 py-2 text-sm text-destructive",children:M}),e.jsx("button",{type:"button",disabled:c!==null,onClick:ae,className:"flex h-10 w-full items-center justify-center rounded-md bg-primary px-4 py-2 text-sm font-medium text-primary-foreground transition-colors hover:bg-primary/90 disabled:opacity-50",children:"Try again"})]}):e.jsxs("div",{className:"flex items-center justify-center gap-2 py-6 text-sm text-muted-foreground",children:[e.jsx(b,{size:"lg"}),e.jsx("span",{children:"Signing you into your local install…"})]})}):e.jsxs(e.Fragment,{children:[U&&e.jsxs("div",{className:"flex items-center justify-center gap-2 py-6 text-sm text-muted-foreground",children:[e.jsx(b,{size:"lg"}),e.jsx("span",{children:"Loading sign-in options…"})]}),!U&&_&&e.jsxs("div",{className:"text-sm text-destructive",children:["Failed to load sign-in options. ",_]}),!U&&!_&&v.length===0&&e.jsx("div",{className:"text-sm text-muted-foreground",children:"No sign-in methods are configured. Contact support for access."}),h&&!F&&e.jsxs("div",{className:"mb-4 flex rounded-lg border p-1",children:[e.jsx("button",{type:"button",className:`flex-1 rounded-md px-3 py-2 text-sm font-medium transition-colors ${d==="sign-in"?"bg-primary text-primary-foreground":"text-muted-foreground hover:text-foreground"}`,onClick:()=>P("sign-in"),children:"Sign In"}),e.jsx("button",{type:"button",className:`flex-1 rounded-md px-3 py-2 text-sm font-medium transition-colors ${d==="sign-up"?"bg-primary text-primary-foreground":"text-muted-foreground hover:text-foreground"}`,onClick:()=>P("sign-up"),children:"Sign Up"})]}),!F&&xe.length>1&&e.jsxs("div",{className:"mb-6 flex rounded-lg border p-1",children:[h&&e.jsx("button",{type:"button",className:`flex-1 rounded-md px-3 py-2 text-sm font-medium transition-colors ${p==="email-password"?"bg-primary text-primary-foreground":"text-muted-foreground hover:text-foreground"}`,onClick:()=>j("email-password"),children:"Email + Password"}),A&&e.jsx("button",{type:"button",className:`flex-1 rounded-md px-3 py-2 text-sm font-medium transition-colors ${p==="social"?"bg-primary text-primary-foreground":"text-muted-foreground hover:text-foreground"}`,onClick:()=>j("social"),children:"Social"}),!h&&w&&e.jsx("button",{type:"button",className:`flex-1 rounded-md px-3 py-2 text-sm font-medium transition-colors ${p==="magic-link"?"bg-primary text-primary-foreground":"text-muted-foreground hover:text-foreground"}`,onClick:()=>j("magic-link"),children:"Magic Link"}),R&&e.jsx("button",{type:"button",className:`flex-1 rounded-md px-3 py-2 text-sm font-medium transition-colors ${p==="whatsapp"?"bg-primary text-primary-foreground":"text-muted-foreground hover:text-foreground"}`,onClick:()=>j("whatsapp"),children:"WhatsApp"})]}),D&&e.jsx("div",{className:"mb-4 rounded-lg border border-amber-300 bg-amber-50 p-3 text-sm text-amber-900",children:"We found an existing account for this identity. To protect the account, verify with a magic link before linking social sign-in."}),ee&&e.jsx("div",{className:"mb-4 p-3 text-sm text-destructive bg-destructive/10 rounded-lg",children:ee}),M&&e.jsx("div",{className:"mb-4 p-3 text-sm text-destructive bg-destructive/10 rounded-lg",children:M}),!F&&(h||p==="social")&&A&&e.jsxs("div",{className:"space-y-3",children:[Object.entries(i?.social??{}).filter(([,t])=>t).map(([t])=>{const n=qe.find(ke=>ke.provider===t),g=n?.icon,S=i?.socialMeta?.[t],q=n?.name??S?.name??t.charAt(0).toUpperCase()+t.slice(1);return e.jsxs("button",{type:"button",onClick:()=>se(t),disabled:c!==null,className:"w-full flex items-center justify-center gap-3 h-10 px-4 border border-input rounded-lg bg-background hover:bg-accent hover:text-accent-foreground transition-colors disabled:opacity-50",children:[c===t?e.jsx(b,{size:"lg"}):g?e.jsx(g,{className:"w-4 h-4"}):S?.faviconDomain?e.jsx(Oe,{domain:S.faviconDomain},S.faviconDomain):e.jsx(ce,{className:"w-4 h-4"}),"Continue with ",q]},t)}),h&&e.jsxs("div",{className:"relative my-2",children:[e.jsx("div",{className:"absolute inset-0 flex items-center",children:e.jsx("span",{className:"w-full border-t"})}),e.jsx("div",{className:"relative flex justify-center text-xs uppercase",children:e.jsx("span",{className:"bg-card px-2 text-muted-foreground",children:"or"})})]})]}),!F&&h&&e.jsxs("form",{onSubmit:ye,className:"space-y-4",children:[d==="sign-up"&&e.jsxs("div",{children:[e.jsx("label",{htmlFor:"full-name",className:"block text-sm font-medium",children:"Full name"}),e.jsx("input",{id:"full-name",type:"text",value:T,onChange:t=>ue(t.target.value),placeholder:"Jane Doe",className:"mt-1 block h-10 w-full rounded-md border border-input bg-background px-3 py-2 text-sm placeholder:text-muted-foreground focus:outline-none focus:ring-2 focus:ring-ring"})]}),e.jsxs("div",{children:[e.jsx("label",{htmlFor:"email-password-email",className:"block text-sm font-medium",children:"Email address"}),e.jsx("input",{id:"email-password-email",type:"email",value:o,onChange:t=>{W(t.target.value),K(!1)},placeholder:"you@example.com",required:!0,className:"mt-1 block h-10 w-full rounded-md border border-input bg-background px-3 py-2 text-sm placeholder:text-muted-foreground focus:outline-none focus:ring-2 focus:ring-ring"})]}),e.jsxs("div",{children:[e.jsx("label",{htmlFor:"email-password-password",className:"block text-sm font-medium",children:"Password"}),e.jsx("input",{id:"email-password-password",type:"password",value:k,onChange:t=>me(t.target.value),placeholder:"Enter a password",required:!0,minLength:8,className:"mt-1 block h-10 w-full rounded-md border border-input bg-background px-3 py-2 text-sm placeholder:text-muted-foreground focus:outline-none focus:ring-2 focus:ring-ring"})]}),e.jsx("button",{type:"submit",disabled:c!==null||!o||!k,className:"flex h-10 w-full items-center justify-center rounded-md bg-primary px-4 py-2 text-sm font-medium text-primary-foreground transition-colors hover:bg-primary/90 disabled:opacity-50",children:c==="email-password"?e.jsxs(e.Fragment,{children:[e.jsx(b,{size:"lg"}),e.jsx("span",{className:"ml-2",children:d==="sign-up"?"Creating account...":"Signing in..."})]}):d==="sign-up"?x?"Create local account":"Create Account":"Sign In"}),d==="sign-in"&&te&&e.jsx("button",{type:"button",disabled:c!==null,onClick:async()=>{r(null),u("passkey");try{const t=await $.passkey();if(t?.error){const n=t.error.message??"Passkey sign-in failed.";r(E(n)??n);return}window.location.href=C()}catch(t){const n=t instanceof Error?t.message:String(t);r(E(n)??n)}finally{u(null)}},className:"flex h-10 w-full items-center justify-center rounded-md border border-input bg-background px-4 py-2 text-sm font-medium transition-colors hover:bg-accent hover:text-accent-foreground disabled:opacity-50",children:c==="passkey"?e.jsxs(e.Fragment,{children:[e.jsx(b,{size:"lg"}),e.jsx("span",{className:"ml-2",children:"Waiting for passkey…"})]}):"Sign in with passkey"}),d==="sign-in"&&w&&e.jsx("button",{type:"button",disabled:c!==null||!o,onClick:async()=>{await re()&&j("magic-link")},className:"flex h-10 w-full items-center justify-center rounded-md border border-input bg-background px-4 py-2 text-sm font-medium transition-colors hover:bg-accent hover:text-accent-foreground disabled:opacity-50",children:c==="magic-link"?e.jsxs(e.Fragment,{children:[e.jsx(b,{size:"lg"}),e.jsx("span",{className:"ml-2",children:"Sending magic link..."})]}):"Send me a magic link instead"}),d==="sign-in"&&e.jsx("button",{type:"button",disabled:c!==null||!o,onClick:je,className:"flex h-10 w-full items-center justify-center rounded-md border border-input bg-background px-4 py-2 text-sm font-medium transition-colors hover:bg-accent hover:text-accent-foreground disabled:opacity-50",children:c==="reset-password-request"?e.jsxs(e.Fragment,{children:[e.jsx(b,{size:"lg"}),e.jsx("span",{className:"ml-2",children:"Sending reset email..."})]}):"Forgot password?"}),d==="sign-in"&&pe&&e.jsx("p",{className:"text-sm text-muted-foreground",children:"If this email exists, we sent a password reset link."})]}),p==="magic-link"&&w&&(J?e.jsxs("div",{className:"text-center",children:[e.jsx("div",{className:"mb-4 flex justify-center",children:e.jsx("svg",{className:"h-12 w-12 text-primary",fill:"none",viewBox:"0 0 24 24",stroke:"currentColor","aria-hidden":"true",children:e.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M3 8l7.89 5.26a2 2 0 002.22 0L21 8M5 19h14a2 2 0 002-2V7a2 2 0 00-2-2H5a2 2 0 00-2 2v10a2 2 0 002 2z"})})}),e.jsx("h2",{className:"text-lg font-medium",children:"Check your email"}),e.jsxs("p",{className:"mt-2 text-sm text-muted-foreground",children:["We sent a magic link to ",e.jsx("strong",{children:o}),".",e.jsx("br",{}),"Click the link in the email to sign in."]}),e.jsx("button",{type:"button",className:"mt-4 text-sm text-primary hover:underline",onClick:()=>G(!1),children:"Use a different email"})]}):e.jsxs("form",{onSubmit:be,className:"space-y-4",children:[e.jsxs("div",{children:[e.jsx("label",{htmlFor:"email",className:"block text-sm font-medium",children:"Email address"}),e.jsx("input",{id:"email",type:"email",value:o,onChange:t=>W(t.target.value),placeholder:"you@example.com",required:!0,className:"mt-1 block h-10 w-full rounded-md border border-input bg-background px-3 py-2 text-sm placeholder:text-muted-foreground focus:outline-none focus:ring-2 focus:ring-ring"})]}),e.jsx("button",{type:"submit",disabled:c!==null||!o,className:"flex h-10 w-full items-center justify-center rounded-md bg-primary px-4 py-2 text-sm font-medium text-primary-foreground transition-colors hover:bg-primary/90 disabled:opacity-50",children:c==="magic-link"?e.jsxs(e.Fragment,{children:[e.jsx(b,{size:"lg"}),e.jsx("span",{className:"ml-2",children:"Sending..."})]}):"Send Magic Link"})]})),!F&&p==="whatsapp"&&R&&(fe?e.jsxs("form",{onSubmit:ve,className:"space-y-4",children:[e.jsxs("div",{className:"text-center text-sm text-muted-foreground",children:["Enter the 6-digit code sent to ",e.jsx("strong",{children:N})]}),e.jsx("div",{children:e.jsx("input",{type:"text",value:I,onChange:t=>V(t.target.value),placeholder:"000000",maxLength:6,pattern:"[0-9]{6}",required:!0,className:"block h-12 w-full rounded-md border border-input bg-background px-3 py-2 text-center text-xl tracking-widest placeholder:text-muted-foreground focus:outline-none focus:ring-2 focus:ring-ring"})}),e.jsx("button",{type:"submit",disabled:c!==null||I.length!==6,className:"flex h-10 w-full items-center justify-center rounded-md bg-primary px-4 py-2 text-sm font-medium text-primary-foreground transition-colors hover:bg-primary/90 disabled:opacity-50",children:c==="verify"?e.jsxs(e.Fragment,{children:[e.jsx(b,{size:"lg"}),e.jsx("span",{className:"ml-2",children:"Verifying..."})]}):"Verify & Sign In"}),e.jsx("button",{type:"button",className:"w-full text-sm text-primary hover:underline",onClick:()=>{Q(!1),V("")},children:"Use a different number"})]}):e.jsxs("form",{onSubmit:we,className:"space-y-4",children:[e.jsxs("div",{children:[e.jsx("label",{htmlFor:"phone",className:"block text-sm font-medium",children:"WhatsApp Number"}),e.jsx("input",{id:"phone",type:"tel",value:N,onChange:t=>ge(t.target.value),placeholder:"+1234567890",required:!0,className:"mt-1 block h-10 w-full rounded-md border border-input bg-background px-3 py-2 text-sm placeholder:text-muted-foreground focus:outline-none focus:ring-2 focus:ring-ring"}),e.jsx("p",{className:"mt-1 text-xs text-muted-foreground",children:"Include country code (e.g., +1 for US)"})]}),e.jsx("button",{type:"submit",disabled:c!==null||!N,className:"flex h-10 w-full items-center justify-center rounded-md bg-primary px-4 py-2 text-sm font-medium text-primary-foreground transition-colors hover:bg-primary/90 disabled:opacity-50",children:c==="phone"?e.jsxs(e.Fragment,{children:[e.jsx(b,{size:"lg"}),e.jsx("span",{className:"ml-2",children:"Sending..."})]}):"Send Code via WhatsApp"})]}))]})})})]})})}export{He as component};
2
+ //# sourceMappingURL=login-u6LCgDYG.js.map
@@ -1,2 +1,2 @@
1
- import{r as n,a4 as o,j as e}from"./index-4gCDI7m4.js";function s(){return n.useEffect(()=>{o().catch(t=>console.error("Sign out failed:",t)).finally(()=>{window.location.href="/"})},[]),e.jsx("div",{className:"min-h-[calc(100vh-3.5rem)] flex items-center justify-center",children:e.jsx("p",{className:"text-muted-foreground",children:"Signing out..."})})}export{s as component};
2
- //# sourceMappingURL=logout-DxmfsVKD.js.map
1
+ import{r as n,a5 as o,j as e}from"./index-DdBTTN3y.js";function s(){return n.useEffect(()=>{o().catch(t=>console.error("Sign out failed:",t)).finally(()=>{window.location.href="/"})},[]),e.jsx("div",{className:"min-h-[calc(100vh-3.5rem)] flex items-center justify-center",children:e.jsx("p",{className:"text-muted-foreground",children:"Signing out..."})})}export{s as component};
2
+ //# sourceMappingURL=logout-JhmuWJEH.js.map
@@ -0,0 +1,2 @@
1
+ import{cP as c,cQ as i,j as r,L as s,ce as u}from"./index-DdBTTN3y.js";function p(o,n){return{to:"/$owner/connectors/$connectorKey/$connectionId",params:{owner:o,connectorKey:n.connector_key,connectionId:String(n.connection_id)},search:{feedId:n.id}}}function d(o,n){return{to:"/$owner/connectors/$connectorKey/$connectionId",params:{owner:o,connectorKey:n.connector_key,connectionId:String(n.id)}}}function l(o,n){return{to:"/$owner/agents/connected/$clientId",params:{owner:o,clientId:n}}}function y(o,n){return{to:"/$owner/automations/$automationId",params:{owner:o,automationId:n}}}function f(o,n,t){return{to:"/$owner/events",params:{owner:o},search:{agent:n,schedule:t}}}function g(o,n=!0){return c({queryKey:["automations-list","activity",o],queryFn:async()=>{const t=await Promise.all(["active","archived"].map(e=>i("manage_automations",{action:"list",status:e,include_details:!1},{slug:o})));return[...new Map(t.flatMap(e=>e.automations).map(e=>[Number(e.automation_id),e])).values()].sort((e,a)=>e.name.localeCompare(a.name))},enabled:n&&!!o,staleTime:3e4})}function $({to:o,params:n,search:t,label:e}){return r.jsx(s,{to:o,params:n,search:t,onClick:a=>a.stopPropagation(),onPointerDown:a=>a.stopPropagation(),className:"shrink-0 rounded-md p-1 text-muted-foreground opacity-0 transition-opacity hover:text-foreground group-hover:opacity-100 focus-visible:opacity-100","aria-label":`Manage ${e}`,children:r.jsx(u,{className:"h-3.5 w-3.5"})})}export{$ as M,y as a,l as b,d as c,p as f,f as s,g as u};
2
+ //# sourceMappingURL=manage-gear-D8LMhehh.js.map
@@ -1,2 +1,2 @@
1
- import{j as e,S as o,o as c,au as u,w as d,b4 as h,dt as b,B as p,L as x,y as g}from"./index-4gCDI7m4.js";function j({rows:t=5}){return e.jsx("div",{className:"space-y-2",role:"status","aria-label":"Loading members",children:Array.from({length:t}).map((n,s)=>e.jsxs("div",{className:"flex items-center gap-3 rounded-lg px-3 py-2",children:[e.jsx(o,{className:"h-8 w-8 shrink-0 rounded-full"}),e.jsx(o,{className:"h-4 w-40"})]},s))})}function l({title:t,body:n,ctaLabel:s,showCta:a,callbackUrl:r}){return e.jsx(h,{icon:b,title:t,description:n,children:s&&a?e.jsx(p,{asChild:!0,className:"mt-4",children:e.jsx(x,{to:"/auth/login",search:g({callbackUrl:r,intent:"sign-in"}),children:s})}):null})}function y({children:t}){const{isAuthenticated:n,isReady:s}=c(),{isMember:a,isLoading:r}=u(),i=d({select:m=>m.href});return!s||r?e.jsx(j,{}):n?a?e.jsx(e.Fragment,{children:t}):e.jsx(l,{title:"Join to see members",body:"Emails and member details are only visible to members of this workspace. Use the banner above to join.",callbackUrl:i}):e.jsx(l,{title:"Sign in to see members",body:"The members of this workspace are only visible to people who have signed in.",ctaLabel:"Sign in",showCta:!0,callbackUrl:i})}export{y as M};
2
- //# sourceMappingURL=member-scope-gate-vp3FihBD.js.map
1
+ import{j as e,S as o,q as c,at as d,w as u,b2 as h,dB as b,B as p,L as x,y as g}from"./index-DdBTTN3y.js";function j({rows:t=5}){return e.jsx("div",{className:"space-y-2",role:"status","aria-label":"Loading members",children:Array.from({length:t}).map((n,s)=>e.jsxs("div",{className:"flex items-center gap-3 rounded-lg px-3 py-2",children:[e.jsx(o,{className:"h-8 w-8 shrink-0 rounded-full"}),e.jsx(o,{className:"h-4 w-40"})]},s))})}function l({title:t,body:n,ctaLabel:s,showCta:a,callbackUrl:r}){return e.jsx(h,{icon:b,title:t,description:n,children:s&&a?e.jsx(p,{asChild:!0,className:"mt-4",children:e.jsx(x,{to:"/auth/login",search:g({callbackUrl:r,intent:"sign-in"}),children:s})}):null})}function y({children:t}){const{isAuthenticated:n,isReady:s}=c(),{isMember:a,isLoading:r}=d(),i=u({select:m=>m.href});return!s||r?e.jsx(j,{}):n?a?e.jsx(e.Fragment,{children:t}):e.jsx(l,{title:"Join to see members",body:"Emails and member details are only visible to members of this workspace. Use the banner above to join.",callbackUrl:i}):e.jsx(l,{title:"Sign in to see members",body:"The members of this workspace are only visible to people who have signed in.",ctaLabel:"Sign in",showCta:!0,callbackUrl:i})}export{y as M};
2
+ //# sourceMappingURL=member-scope-gate-4FQ0aanZ.js.map
@@ -0,0 +1,74 @@
1
+ import{r as b,j as t,B as Y,d6 as mt,fu as Os,fv as As,c0 as Ps,i as me,d5 as Rt,S as be,bs as Ds,fw as Fs,v as We,fx as tn,fy as zs,fz as Ws,fA as Bs,H as ze,bl as Ft,bm as zt,bn as Wt,bo as Bt,bp as yt,fB as Hs,I as at,fC as Vs,bP as Kn,fD as Yn,fE as Jn,fF as Us,l as It,fG as qs,c as ot,u as nn,eP as Qn,aH as Gs,aI as Ks,cD as Ys,fH as Js,aB as Qs,fI as Xn,b4 as Xs,b8 as Zs,b_ as Zn,$ as er,L as ve,X as tr,ex as es,c2 as nr,c3 as sr,fJ as rr,fK as ar,fL as or,c7 as ir,bt as ts,fM as ns,fN as nt,fO as jt,fP as cr,fQ as lr,fR as sn,fS as dr,fT as Kt,fU as Yt,fV as ur,fW as mr,cP as ss,cQ as Nt,dH as fr,da as pr,dE as rn,dG as an,fX as rs,dF as on,bN as hr,et as gr,el as yr,dR as as,b2 as os,fY as is,f1 as cs,fZ as Ge,fe as xr,cR as st,V as pt,f2 as br,dW as vr,f_ as wr,dh as kr,cY as jr,cI as ls,dI as Nr,dJ as Sr,dK as Er,dL as Cr,cT as wn,f$ as _r,g0 as Mr,cU as Tr,Y as Lr,g1 as ds,g2 as us,aq as Rr,g3 as Ir,E as ms,g4 as $r,ch as qe,k as fs,g5 as Ht,g6 as Or,g7 as Ar,c$ as kn,g8 as Pr,g9 as Dr,e_ as Fr,ga as zr,gb as Wr,bj as Br,gc as Hr,a as Vr,gd as Ur,ge as qr,ak as Gr,az as Kr}from"./index-DdBTTN3y.js";import{P as Yr}from"./public-shell-ready-BIVCHQHe.js";import{f as Jr,a as Qr,c as jn,d as Xr,A as Zr}from"./connector-boxes-lFc-WP83.js";import{u as ea}from"./use-automations-BLNjxq2K.js";import{c as ta}from"./connections-browser-V-3td9DB.js";import{d as na,e as sa}from"./model-jL871x2J.js";import{c as ra}from"./connection-label-BobuYiAG.js";import{f as aa}from"./feed-event-kinds-BYuZCoU4.js";import{S as oa}from"./schema-type-editor-panel-C0_9VcSs.js";import{D as ia,c as ca,l as la,p as Se,S as Nn,n as da,e as $t,a as ua,g as ma,f as Sn,b as fa,d as pa,J as ha}from"./renderer-DXfJaCCa.js";import{S as ga,E as cn}from"./entity-avatar-TVKjZxWQ.js";import{F as ya}from"./filter-bar-wPaR12SS.js";import{T as xa,a as ba,b as Vt,c as En,d as va,e as Ut}from"./table-BUqshjxa.js";import{u as wa,a as ka,D as ja,P as Na,b as ps,c as Sa,C as Ea}from"./core.esm-CQzL3ObT.js";import{v as Ca,V as hs,M as gs,a as ys,w as _a,b as Ma}from"./view-param-filters-CER47Tlz.js";import{E as Ta}from"./entity-type-page-BLwH6qa7.js";import{n as La}from"./nav-pill-DrFkuyUQ.js";import{M as Ra}from"./member-scope-gate-4FQ0aanZ.js";function Cn(e){let n=Number.POSITIVE_INFINITY,s=Number.POSITIVE_INFINITY,a=Number.NEGATIVE_INFINITY,r=Number.NEGATIVE_INFINITY;for(const i of e)n=Math.min(n,i.x-i.w/2),a=Math.max(a,i.x+i.w/2),s=Math.min(s,i.y-i.h/2),r=Math.max(r,i.y+i.h/2);return Number.isFinite(n)?{x0:n,y0:s,x1:a,y1:r}:null}const St=(e,n,s)=>e<n?n:e>s?s:e;function Ia(e,n,s,{padding:a=.12,minZoom:r=.2,maxZoom:i=1.2}={}){const o=Math.max(1,e.x1-e.x0),l=Math.max(1,e.y1-e.y0),y=St(Math.min(n/(o*(1+a)),s/(l*(1+a))),r,i);return{z:y,x:n/2-(e.x0+e.x1)/2*y,y:s/2-(e.y0+e.y1)/2*y}}function $a(e,n,s=0){if(e===n){const v=e.x+e.w/2,j=e.y-e.h/2;return[{x:v-30,y:j},{x:v-30,y:j-26},{x:v+22,y:j-26},{x:v+22,y:e.y-6},{x:v,y:e.y-6}]}const a=s*8,r=e.x+e.w/2,i=e.y+St(a,-e.h/2+6,e.h/2-6),o=n.x-n.w/2,l=n.y+St(a,-n.h/2+6,n.h/2-6);if(o-r>=40){const v=(r+o)/2+a;return[{x:r,y:i},{x:v,y:i},{x:v,y:l},{x:o,y:l}]}const y=Math.max(e.y+e.h/2,n.y+n.h/2)+24+Math.abs(a),c=Math.min(e.y-e.h/2,n.y-n.h/2)-24-Math.abs(a),g=(i+l)/2,p=Math.abs(y-g)<=Math.abs(c-g)?y:c,f=r+24+Math.abs(a),m=o-24-Math.abs(a);return[{x:r,y:i},{x:f,y:i},{x:f,y:p},{x:m,y:p},{x:m,y:l},{x:o,y:l}]}function Oa(e,n,s){const a=s.x-n.x,r=s.y-n.y,i=a*a+r*r,o=i?St(((e.x-n.x)*a+(e.y-n.y)*r)/i,0,1):0;return Math.hypot(e.x-(n.x+o*a),e.y-(n.y+o*r))}function Aa(e,n){let s=Number.POSITIVE_INFINITY;for(let a=0;a<n.length-1;a++)s=Math.min(s,Oa(e,n[a],n[a+1]));return s}function Pa(e,n){return Math.abs(n.x-e.x)<=e.w/2&&Math.abs(n.y-e.y)<=e.h/2}class tt{cells=new Set;static CELL_W=12;static CELL_H=16;keys(n){const s=[],a=Math.floor(n.x0/tt.CELL_W),r=Math.floor(n.x1/tt.CELL_W),i=Math.floor(n.y0/tt.CELL_H),o=Math.floor(n.y1/tt.CELL_H);for(let l=a;l<=r;l++)for(let y=i;y<=o;y++)s.push(l*1e5+y);return s}isFree(n){return this.keys(n).every(s=>!this.cells.has(s))}reserve(n){for(const s of this.keys(n))this.cells.add(s)}}function Da(e,n,s,a,r){const i=e.slice(0,-1).map((p,f)=>({i:f,length:Math.hypot(e[f+1].x-p.x,e[f+1].y-p.y)})).sort((p,f)=>f.length-p.length);if(i.length===0)return null;const o=p=>({x0:p.x-n/2,x1:p.x+n/2,y0:p.y-s/2,y1:p.y+s/2}),l=p=>({x:(e[p].x+e[p+1].x)/2,y:(e[p].y+e[p+1].y)/2});for(const{i:p,length:f}of i){if(!r&&f<n*.7)break;const m=l(p);if(a.isFree(o(m)))return a.reserve(o(m)),m}if(!r)return null;const y=l(i[0].i),g=[-1,1,-1.6,1.6].map(p=>({x:y.x,y:y.y+p*(s+12)})).find(p=>a.isFree(o(p)))??y;return a.reserve(o(g)),g}const Fa=e=>t.jsx(Rt,{icon:e||null,className:"h-4 w-4"}),za='600 14px "DM Sans", system-ui, sans-serif',Wa='400 11px "DM Sans", system-ui, sans-serif',Ba='500 9px "DM Sans", system-ui, sans-serif',Ha='500 11px "DM Sans", system-ui, sans-serif',dt=18,_n=8;function Mn(e){const n=getComputedStyle(e),s=(a,r)=>n.getPropertyValue(a).trim()||r;return{foreground:s("--foreground","#141414"),muted:s("--muted-foreground","#545454"),card:s("--card","#ffffff"),background:s("--background","#fcfcfb"),border:s("--border","#e7e4dc"),primary:s("--primary","#2f63e8"),mutedSurface:s("--muted","#f3f1ea")}}function xt(e,n,s){if(e.measureText(n).width<=s)return n;let a=0,r=n.length;for(;a<r;){const i=Math.ceil((a+r)/2);e.measureText(`${n.slice(0,i)}…`).width<=s?a=i:r=i-1}return`${n.slice(0,a)}…`}function Va(e,n,s,a){const r=Math.hypot(s.x-n.x,s.y-n.y);if(r<1)return;const i=(s.x-n.x)/r,o=(s.y-n.y)/r;e.moveTo(s.x-i*a-o*a*.55,s.y-o*a+i*a*.55),e.lineTo(s.x,s.y),e.lineTo(s.x-i*a+o*a*.55,s.y-o*a-i*a*.55)}function xs({boxes:e,edges:n,label:s,onOpenBox:a,openLabel:r,onConnect:i,renderIcon:o=Fa,className:l}){const y=b.useRef(null),c=b.useRef(null),g=b.useRef(null),p=b.useRef({z:1,x:0,y:0}),f=b.useRef({w:0,h:0,dpr:1}),m=b.useRef(!0),v=b.useRef(new Map),j=b.useRef(null),d=b.useRef(null),S=b.useRef(new Map),N=b.useRef(null),E=b.useRef(""),k=b.useRef(!1),[h,x]=b.useState(()=>new Map),[M,O]=b.useState(null),[z,P]=b.useState(null),[Q,G]=b.useState(null),[ne,V]=b.useState(null),[ge,se]=b.useState(0),{placed:$,movedIds:I}=b.useMemo(()=>{const C=new Map,u=new Set;for(const T of e){const w=h.get(T.id);w&&w.from.x===T.x&&w.from.y===T.y?(C.set(T.id,{...T,x:w.at.x,y:w.at.y}),u.add(T.id)):C.set(T.id,T)}return{placed:C,movedIds:u}},[e,h]),q=b.useMemo(()=>{const C=new Map;for(const T of n){const w=[T.source,T.target].sort().join("|");C.set(w,[...C.get(w)??[],T])}const u=new Map;for(const T of n){const w=$.get(T.source),_=$.get(T.target);if(!w||!_)continue;if(T.route&&!I.has(w.id)&&!I.has(_.id)){u.set(T.id,T.route);continue}const L=C.get([T.source,T.target].sort().join("|"))??[T];u.set(T.id,$a(w,_,L.indexOf(T)-(L.length-1)/2))}return u},[n,$,I]),U=b.useCallback(()=>{m.current=!0},[]),B=b.useCallback(()=>{const C=Cn([...$.values()]),{w:u,h:T}=f.current;!C||!u||!T||(p.current=Ia(C,u,T),k.current=!0,U())},[$,U]),J=C=>{p.current=C,k.current=!1,U()},re=C=>{const u=Cn(C),{w:T,h:w}=f.current;if(!u||!T||!w)return;const _=p.current,L=24;u.x0*_.z+_.x>=L&&u.y0*_.z+_.y>=L&&u.x1*_.z+_.x<=T-L&&u.y1*_.z+_.y<=w-L||J({..._,x:T/2-(u.x0+u.x1)/2*_.z,y:w/2-(u.y0+u.y1)/2*_.z})},fe=C=>{V(C);const u=$.get(C);u&&re([u])},le=e.map(C=>`${C.id}@${Math.round(C.x)},${Math.round(C.y)}`).join(";");b.useEffect(()=>{!le||E.current===le||f.current.w&&(E.current=le,B())},[le,B]);const Ee=b.useRef(B);Ee.current=B;const Be=b.useRef(le);Be.current=le,b.useEffect(()=>{const C=y.current,u=c.current;if(!C||!u||typeof ResizeObserver>"u")return;const T=()=>{const _=window.devicePixelRatio||1,L=C.clientWidth,H=C.clientHeight;f.current={w:L,h:H,dpr:_},u.width=Math.round(L*_),u.height=Math.round(H*_);const F=Be.current;F&&L&&H&&(E.current!==F||k.current)&&(E.current=F,Ee.current()),U()};T();const w=new ResizeObserver(T);return w.observe(C),()=>w.disconnect()},[U]);const[Ie,$e]=b.useState(0);b.useEffect(()=>{const C=g.current,u=c.current;if(!C||!u)return;const T=Mn(u).muted;for(const w of C.querySelectorAll("[data-icon-key]")){const _=w.dataset.iconKey??"";if(v.current.has(_))continue;const L=w.querySelector("svg"),H=L?null:w.querySelector("img")?.src;if(!L&&!H){v.current.set(_,w.textContent??"");continue}const F=new Image;if(F.onload=U,F.onerror=()=>{v.current.delete(_),$e(D=>D+1)},L){const D=L.cloneNode(!0);D.getAttribute("width")||D.setAttribute("width","24"),D.getAttribute("height")||D.setAttribute("height","24");const W=new XMLSerializer().serializeToString(D).replaceAll("currentColor",T);F.src=`data:image/svg+xml;charset=utf-8,${encodeURIComponent(W)}`}else H&&(F.src=H);v.current.set(_,F)}},[e,ge,Ie,U]);const Ce=(C,u)=>{const T=p.current;return{x:(C-T.x)/T.z,y:(u-T.y)/T.z}},He=(C,u)=>{const T=p.current,w=Ce(C,u),_=M&&M.kind!=="edge"?$.get(M.box.id):void 0;if(_&&i){const D=Tn(_);if(Math.hypot(D.x*T.z+T.x-C,D.y*T.z+T.y-u)<=_n+3)return{kind:"handle",box:_}}const L=[...$.values()];for(let D=L.length-1;D>=0;D--)if(Pa(L[D],w))return{kind:"box",box:L[D]};let H=null,F=7/T.z;for(const D of n){const W=q.get(D.id);if(!W)continue;const de=Aa(w,W);de<F&&(F=de,H=D)}return H?{kind:"edge",edge:H}:null},ye=b.useMemo(()=>{const C=new Set;for(const T of[z,Q])T&&C.add(T);M?.kind==="edge"&&C.add(M.edge.id);const u=M&&M.kind!=="edge"?M.box.id:ne;if(u)for(const T of n)(T.source===u||T.target===u)&&C.add(T.id);for(const T of n)T.dimmed&&C.delete(T.id);return C},[n,M,z,Q,ne]);b.useEffect(U,[$,q,ye,M,ne,U]);const _e=b.useCallback(()=>{const C=c.current,u=C?.getContext("2d");if(!C||!u)return;const{w:T,h:w,dpr:_}=f.current,L=Mn(C),H=getComputedStyle(C),F=new Map,D=A=>{let Z=F.get(A);return Z===void 0&&(Z=H.getPropertyValue(A).trim(),F.set(A,Z)),Z},{z:W,x:de,y:ce}=p.current,Ne=A=>({x:A.x*W+de,y:A.y*W+ce});u.setTransform(_,0,0,_,0,0),u.clearRect(0,0,T,w);const Pe=M&&M.kind!=="edge"?M.box.id:null;u.lineJoin="round";for(const A of n){const Z=q.get(A.id);if(!Z)continue;const te=Z.map(Ne),K=ye.has(A.id);u.globalAlpha=A.dimmed?.15:K?.95:.55,u.strokeStyle=K?L.foreground:L.muted,u.lineWidth=K?1.75:1.25,u.beginPath(),u.moveTo(te[0].x,te[0].y);for(const ae of te.slice(1))u.lineTo(ae.x,ae.y);A.directed&&Va(u,te[te.length-2],te[te.length-1],8),u.stroke()}const Ye=new tt;for(const A of $.values()){const Z=Ne(A),te=A.w*W,K=A.h*W,ae=Z.x-te/2,X=Z.y-K/2;if(Ye.reserve({x0:ae,y0:X,x1:ae+te,y1:X+K}),ae>T||X>w||ae+te<0||X+K<0)continue;const Fe=Pe===A.id||N.current?.over?.id===A.id;u.globalAlpha=A.dimmed?.25:1,u.beginPath(),u.roundRect(ae,X,te,K,8*W),u.fillStyle=A.muted?L.mutedSurface:L.card,u.fill(),u.lineWidth=Fe||ne===A.id?1.5:1,u.strokeStyle=Fe||ne===A.id?L.primary:L.border,u.stroke();const ie=A.accent&&D(A.accent);if(ie&&(u.save(),u.clip(),u.fillStyle=ie,u.fillRect(ae,X,3*W,K),u.restore()),14*W<5)continue;const he=12*W,oe=16*W,ue=A.meta?X+K/2-8*W:X+K/2,Le=v.current.get(A.icon??"");Le instanceof HTMLImageElement&&Le.complete&&Le.naturalWidth>0?u.drawImage(Le,ae+he,ue-oe/2,oe,oe):typeof Le=="string"&&Le&&(u.font=`${14*W}px system-ui, sans-serif`,u.textBaseline="middle",u.textAlign="left",u.fillText(Le,ae+he,ue));const Ve=ae+he+oe+8*W,it=12*W;u.textBaseline="middle",u.textAlign="left";let Xe=ae+te-it-Ve;if(A.badge){u.font=Ba.replace("9px",`${9*W}px`);const ct=xt(u,A.badge.toUpperCase(),Xe*.35),Ze=u.measureText(ct).width+8*W,lt=ae+te-it-Ze;u.strokeStyle=L.border,u.lineWidth=1,u.beginPath(),u.roundRect(lt,ue-7*W,Ze,14*W,3*W),u.stroke(),u.fillStyle=L.muted,u.fillText(ct,lt+4*W,ue+.5),Xe-=Ze+6*W}u.font=za.replace("14px",`${14*W}px`),u.fillStyle=L.foreground,u.fillText(xt(u,A.title,Xe),Ve,ue+.5),A.meta&&(u.font=Wa.replace("11px",`${11*W}px`),u.fillStyle=L.muted,u.fillText(xt(u,A.meta,ae+te-he-Ve),Ve,X+K/2+10*W))}const De=N.current,Je=De?.from??(Pe?$.get(Pe):void 0);if(i&&Je&&Je.w*W>=60){const A=Ne(Tn(Je));if(u.globalAlpha=1,De){const Z=Ne(De.to);u.strokeStyle=L.primary,u.lineWidth=2,u.setLineDash([6,4]),u.beginPath(),u.moveTo(A.x,A.y),u.lineTo(Z.x,Z.y),u.stroke(),u.setLineDash([])}u.fillStyle=L.card,u.strokeStyle=L.primary,u.lineWidth=1.5,u.beginPath(),u.arc(A.x,A.y,_n,0,Math.PI*2),u.fill(),u.stroke(),u.beginPath(),u.moveTo(A.x-4,A.y),u.lineTo(A.x+4,A.y),u.moveTo(A.x,A.y-4),u.lineTo(A.x,A.y+4),u.stroke()}u.font=Ha,u.textAlign="center",u.textBaseline="middle";const Qe=(A,Z,te,K)=>{u.globalAlpha=1,u.fillStyle=L.background,u.strokeStyle=te?L.foreground:L.border,u.lineWidth=1,u.beginPath(),u.roundRect(A.x-K/2,A.y-dt/2,K,dt,5),u.fill(),u.stroke(),u.fillStyle=te?L.foreground:L.muted,u.fillText(Z,A.x,A.y+.5)},Ot=[...n].sort((A,Z)=>Number(ye.has(Z.id))-Number(ye.has(A.id)));for(const A of Ot){const Z=q.get(A.id);if(!Z||A.dimmed&&!ye.has(A.id))continue;const te=Z.map(Ne),K=ye.has(A.id),X=(K?A.details:[A.summary]).map(oe=>xt(u,oe,200)),Fe=Math.max(...X.map(oe=>u.measureText(oe).width))+14,ie=X.length*(dt+2);if(!K&&W<.45)continue;const he=Da(te,Fe,ie,Ye,K);he&&X.forEach((oe,ue)=>{Qe({x:he.x,y:he.y-ie/2+(dt+2)*ue+dt/2},oe,K,Fe)})}u.globalAlpha=1},[n,q,$,ye,M,ne,i]);b.useEffect(()=>{let C=0;const u=()=>{C=requestAnimationFrame(u),m.current&&(m.current=!1,_e())};return C=requestAnimationFrame(u),document.addEventListener("visibilitychange",U),()=>{cancelAnimationFrame(C),document.removeEventListener("visibilitychange",U)}},[_e,U]),b.useEffect(()=>{const C=new MutationObserver(()=>{v.current.clear(),se(u=>u+1),U()});return C.observe(document.documentElement,{attributes:!0,attributeFilter:["class","data-theme","style"]}),()=>C.disconnect()},[U]);const ke=(C,u,T)=>{const w=p.current,_=Math.min(3,Math.max(.15,w.z*C));J({z:_,x:u-(u-w.x)*(_/w.z),y:T-(T-w.y)*(_/w.z)})},Me=C=>{const u=c.current?.getBoundingClientRect();return{x:C.clientX-(u?.left??0),y:C.clientY-(u?.top??0)}},pe=C=>{if(C.button!==0&&C.pointerType==="mouse")return;C.currentTarget.setPointerCapture(C.pointerId);const u=Me(C);if(C.pointerType==="touch"&&(S.current.set(C.pointerId,u),S.current.size===2)){const[_,L]=[...S.current.values()];j.current=null,N.current=null,d.current={d:Math.hypot(_.x-L.x,_.y-L.y)||1,mid:{x:(_.x+L.x)/2,y:(_.y+L.y)/2}};return}const T=He(u.x,u.y),w={start:u,last:u,hit:T,moved:!1};if(T?.kind==="handle")N.current={from:T.box,to:Ce(u.x,u.y),over:null};else if(T?.kind==="box"){const _=Ce(u.x,u.y);w.grab={x:T.box.x-_.x,y:T.box.y-_.y}}j.current=w},Oe=C=>{const u=Me(C);S.current.has(C.pointerId)&&S.current.set(C.pointerId,u);const T=d.current;if(T&&S.current.size===2){const[D,W]=[...S.current.values()],de=Math.hypot(D.x-W.x,D.y-W.y)||1,ce={x:(D.x+W.x)/2,y:(D.y+W.y)/2};J({...p.current,x:p.current.x+ce.x-T.mid.x,y:p.current.y+ce.y-T.mid.y}),ke(de/T.d,ce.x,ce.y),d.current={d:de,mid:ce};return}const w=j.current;if(!w){const D=He(u.x,u.y);O(de=>Ua(de,D)?de:D);const W=c.current;W&&(W.style.cursor=D?.kind==="handle"?"crosshair":D?"pointer":"grab");return}const _=u.x-w.last.x,L=u.y-w.last.y;if(w.last=u,!w.moved&&Math.hypot(u.x-w.start.x,u.y-w.start.y)>4&&(w.moved=!0),!w.moved)return;const H=N.current;if(H){H.to=Ce(u.x,u.y);const D=He(u.x,u.y);H.over=D?.kind==="box"?D.box:null,U();return}const F=w.hit;if(F?.kind==="box"&&w.grab){const D=Ce(u.x,u.y),W=e.find(ce=>ce.id===F.box.id);if(!W)return;const de={x:D.x+w.grab.x,y:D.y+w.grab.y};x(ce=>new Map(ce).set(W.id,{at:de,from:{x:W.x,y:W.y}}));return}J({...p.current,x:p.current.x+_,y:p.current.y+L}),c.current&&(c.current.style.cursor="grabbing")},Te=C=>{if(S.current.delete(C.pointerId),d.current){S.current.size<2&&(d.current=null),j.current=null;return}const u=j.current;j.current=null;const T=N.current;if(N.current=null,!u)return;if(c.current&&(c.current.style.cursor="grab"),T){U(),T.over&&i&&i(T.from.id,T.over.id);return}if(u.moved)return;const w=u.hit;w?.kind==="box"?a(w.box.id):w?.kind==="edge"?P(_=>_===w.edge.id?null:w.edge.id):P(null)},je=C=>{S.current.delete(C.pointerId),d.current=null,j.current=null,N.current=null,U()};b.useEffect(()=>{const C=c.current;if(!C)return;const u=T=>{T.preventDefault();const w=Me(T);T.ctrlKey||T.metaKey?ke(Math.exp(-T.deltaY*(T.ctrlKey?.01:.002)),w.x,w.y):J({...p.current,x:p.current.x-T.deltaX,y:p.current.y-T.deltaY})};return C.addEventListener("wheel",u,{passive:!1}),()=>C.removeEventListener("wheel",u)});const Ke=C=>ke(C,f.current.w/2,f.current.h/2),Ae=[...new Set(e.map(C=>C.icon??""))];return t.jsxs("div",{ref:y,className:me("relative h-full w-full overflow-hidden",l),children:[t.jsx("canvas",{ref:c,"aria-hidden":"true",className:"block h-full w-full cursor-grab touch-none",onPointerDown:pe,onPointerMove:Oe,onPointerUp:Te,onPointerCancel:je,onPointerLeave:()=>{j.current||O(null)}}),t.jsxs("ul",{ref:g,"aria-label":s,className:"sr-only",children:[Ae.map(C=>t.jsx("li",{"aria-hidden":"true","data-icon-key":C,children:o(C)},`icon:${C}`)),e.map(C=>t.jsx("li",{children:t.jsx("button",{type:"button",onClick:()=>a(C.id),onFocus:()=>fe(C.id),onBlur:()=>V(null),children:r(C)})},C.id)),n.map(C=>t.jsx("li",{"data-revealed":ye.has(C.id)||void 0,children:t.jsx("button",{type:"button","aria-pressed":z===C.id,onClick:()=>P(u=>u===C.id?null:C.id),onFocus:()=>{G(C.id);const u=q.get(C.id);u&&re(u.map(T=>({...T,w:0,h:0})))},onBlur:()=>G(null),children:C.ariaLabel})},C.id))]}),t.jsxs("div",{className:"absolute bottom-3 left-3 flex flex-col gap-1",children:[t.jsx(Y,{type:"button",variant:"outline",size:"icon",className:"h-7 w-7","aria-label":"Zoom in",onClick:()=>Ke(1.25),children:t.jsx(mt,{className:"h-3.5 w-3.5"})}),t.jsx(Y,{type:"button",variant:"outline",size:"icon",className:"h-7 w-7","aria-label":"Zoom out",onClick:()=>Ke(.8),children:t.jsx(Os,{className:"h-3.5 w-3.5"})}),t.jsx(Y,{type:"button",variant:"outline",size:"icon",className:"h-7 w-7","aria-label":"Fit to view",onClick:B,children:t.jsx(As,{className:"h-3.5 w-3.5"})}),I.size>0?t.jsx(Y,{type:"button",variant:"outline",size:"icon",className:"h-7 w-7","aria-label":"Reset layout",onClick:()=>x(new Map),children:t.jsx(Ps,{className:"h-3.5 w-3.5"})}):null]})]})}const Tn=e=>({x:e.x+e.w/2,y:e.y});function Ua(e,n){return!e||!n?e===n:e.kind==="edge"||n.kind==="edge"?e.kind==="edge"&&n.kind==="edge"&&e.edge.id===n.edge.id:e.kind===n.kind&&e.box.id===n.box.id}function ln({label:e,fill:n=!1,schemaActions:s=!1}){return t.jsxs("div",{role:"status","aria-label":e,"aria-busy":"true",className:me("flex min-w-0 flex-col gap-3",n&&"min-h-0 flex-1"),children:[t.jsx("div",{"aria-hidden":"true",children:t.jsx(be,{className:"h-5 w-3/4 max-w-xl rounded-none"})}),t.jsxs("div",{className:me("relative flex min-h-0 flex-col",n&&"flex-1"),"aria-hidden":"true",children:[s?t.jsxs("div",{className:"z-10 flex flex-wrap justify-end gap-2 lg:absolute lg:top-0 lg:right-0",children:[t.jsx(be,{className:"h-8 w-40 rounded-none"}),t.jsx(be,{className:"h-8 w-36 rounded-none"})]}):null,t.jsxs("div",{className:me("relative min-h-[420px]",n?"flex-1":"h-[70vh]"),children:[t.jsxs("div",{className:"absolute top-1/2 left-1/2 flex h-16 w-52 -translate-x-1/2 -translate-y-1/2 items-center gap-3 rounded-xl border border-border bg-card px-4",children:[t.jsx(be,{className:"h-4 w-4 shrink-0 rounded-none"}),t.jsxs("div",{className:"flex flex-1 flex-col gap-2",children:[t.jsx(be,{className:"h-3.5 w-24 rounded-none"}),t.jsx(be,{className:"h-2.5 w-32 rounded-none"})]})]}),t.jsx("div",{className:"absolute bottom-3 left-3 flex flex-col gap-1",children:["in","out","fit"].map(a=>t.jsx("div",{className:"flex h-7 w-7 items-center justify-center border border-input bg-background",children:t.jsx(be,{className:"h-3 w-3 rounded-none"})},a))})]})]})]})}function bt(e){throw new Error('Could not dynamically require "'+e+'". Please configure the dynamicRequireTargets or/and ignoreDynamicRequires option of @rollup/plugin-commonjs appropriately for this require call to work.')}var qt={exports:{}},Ln;function qa(){return Ln||(Ln=1,(function(e,n){(function(s){e.exports=s()})(function(){return(function(){function s(a,r,i){function o(c,g){if(!r[c]){if(!a[c]){var p=typeof bt=="function"&&bt;if(!g&&p)return p(c,!0);if(l)return l(c,!0);var f=new Error("Cannot find module '"+c+"'");throw f.code="MODULE_NOT_FOUND",f}var m=r[c]={exports:{}};a[c][0].call(m.exports,function(v){var j=a[c][1][v];return o(j||v)},m,m.exports,s,a,r,i)}return r[c].exports}for(var l=typeof bt=="function"&&bt,y=0;y<i.length;y++)o(i[y]);return o}return s})()({1:[function(s,a,r){Object.defineProperty(r,"__esModule",{value:!0}),r.default=void 0;function i(f){"@babel/helpers - typeof";return i=typeof Symbol=="function"&&typeof Symbol.iterator=="symbol"?function(m){return typeof m}:function(m){return m&&typeof Symbol=="function"&&m.constructor===Symbol&&m!==Symbol.prototype?"symbol":typeof m},i(f)}function o(f,m){if(!(f instanceof m))throw new TypeError("Cannot call a class as a function")}function l(f,m){for(var v=0;v<m.length;v++){var j=m[v];j.enumerable=j.enumerable||!1,j.configurable=!0,"value"in j&&(j.writable=!0),Object.defineProperty(f,c(j.key),j)}}function y(f,m,v){return m&&l(f.prototype,m),Object.defineProperty(f,"prototype",{writable:!1}),f}function c(f){var m=g(f,"string");return i(m)=="symbol"?m:m+""}function g(f,m){if(i(f)!="object"||!f)return f;var v=f[Symbol.toPrimitive];if(v!==void 0){var j=v.call(f,m);if(i(j)!="object")return j;throw new TypeError("@@toPrimitive must return a primitive value.")}return String(f)}r.default=(function(){function f(){var m=this,v=arguments.length>0&&arguments[0]!==void 0?arguments[0]:{},j=v.defaultLayoutOptions,d=j===void 0?{}:j,S=v.algorithms,N=S===void 0?["layered","stress","mrtree","radial","force","disco","sporeOverlap","sporeCompaction","rectpacking"]:S,E=v.workerFactory,k=v.workerUrl;if(o(this,f),this.defaultLayoutOptions=d,this.initialized=!1,typeof k>"u"&&typeof E>"u")throw new Error("Cannot construct an ELK without both 'workerUrl' and 'workerFactory'.");var h=E;typeof k<"u"&&typeof E>"u"&&(h=function(O){return new Worker(O)});var x=h(k);if(typeof x.postMessage!="function")throw new TypeError("Created worker does not provide the required 'postMessage' function.");this.worker=new p(x),this.worker.postMessage({cmd:"register",algorithms:N}).then(function(M){return m.initialized=!0}).catch(console.err)}return y(f,[{key:"layout",value:function(v){var j=arguments.length>1&&arguments[1]!==void 0?arguments[1]:{},d=j.layoutOptions,S=d===void 0?this.defaultLayoutOptions:d,N=j.logging,E=N===void 0?!1:N,k=j.measureExecutionTime,h=k===void 0?!1:k;return v?this.worker.postMessage({cmd:"layout",graph:v,layoutOptions:S,options:{logging:E,measureExecutionTime:h}}):Promise.reject(new Error("Missing mandatory parameter 'graph'."))}},{key:"knownLayoutAlgorithms",value:function(){return this.worker.postMessage({cmd:"algorithms"})}},{key:"knownLayoutOptions",value:function(){return this.worker.postMessage({cmd:"options"})}},{key:"knownLayoutCategories",value:function(){return this.worker.postMessage({cmd:"categories"})}},{key:"terminateWorker",value:function(){this.worker&&this.worker.terminate()}}])})();var p=(function(){function f(m){var v=this;if(o(this,f),m===void 0)throw new Error("Missing mandatory parameter 'worker'.");this.resolvers={},this.worker=m,this.worker.onmessage=function(j){setTimeout(function(){v.receive(v,j)},0)}}return y(f,[{key:"postMessage",value:function(v){var j=this.id||0;this.id=j+1,v.id=j;var d=this;return new Promise(function(S,N){d.resolvers[j]=function(E,k){E?(d.convertGwtStyleError(E),N(E)):S(k)},d.worker.postMessage(v)})}},{key:"receive",value:function(v,j){var d=j.data,S=v.resolvers[d.id];S&&(delete v.resolvers[d.id],d.error?S(d.error):S(null,d.data))}},{key:"terminate",value:function(){this.worker&&this.worker.terminate()}},{key:"convertGwtStyleError",value:function(v){if(v){var j=v.__java$exception;j&&(j.cause&&j.cause.backingJsObject&&(v.cause=j.cause.backingJsObject,this.convertGwtStyleError(v.cause)),delete v.__java$exception)}}}])})()},{}],2:[function(s,a,r){var i=s("./elk-api.js").default;Object.defineProperty(a.exports,"__esModule",{value:!0}),a.exports=i,i.default=i},{"./elk-api.js":1}]},{},[2])(2)})})(qt)),qt.exports}var Ga=qa();const Ka=Ds(Ga);function Ya(e){return new Worker("/assets/elk-worker.min-BENGc9gn.js",{name:e?.name})}const Ja=200,Qa=320,rt=56,Xa=7.4,Za=5.9,eo=84,to=48;function ft(e,n){return Math.round(Math.min(Qa,Math.max(Ja,eo+e.length*Xa,to+n.length*Za)))}function no(e,n){const s=[];return e>0&&s.push(`${e} ${e===1?"field":"fields"}`),typeof n=="number"&&s.push(`${n.toLocaleString()} ${n===1?"record":"records"}`),s.join(" · ")}function Rn(e,n){return e.slug<n.slug?-1:e.slug>n.slug?1:0}function bs(e,n){const s=new Set;return e.filter(a=>a.status!=="active"||a.organization_slug&&a.organization_slug!==n||s.has(a.slug)?!1:(s.add(a.slug),!0))}function so(e){const n=e.metadata_schema;if(!n||typeof n!="object")return 0;const s=n.properties;return!s||typeof s!="object"?0:Object.keys(s).length}function vs(e){const{entityTypes:n,relationshipTypes:s,rulesBySlug:a}=e,r=e.ownerSlug??"",i=[...n].sort(Rn),o=bs(s,r).sort(Rn),l=h=>!h.organization_slug||h.organization_slug===r,y=h=>h.organization_slug||r,c=new Map;for(const h of i)c.set(h.slug,[...c.get(h.slug)??[],h]);const g=h=>(c.get(h.slug)?.length??0)>1?`${y(h)}:${h.slug}`:h.slug,p=new Set(i.filter(l).map(g)),f=h=>{const x=c.get(h)??[];return x.find(l)??(x.length===1?x[0]:void 0)},m=new Set(p),v=o.flatMap(h=>[...a[h.slug]??[]].sort((x,M)=>x.id-M.id).flatMap(x=>{const M=f(x.source_entity_type_slug),O=f(x.target_entity_type_slug);if(!M||!O)return[];const z=g(M),P=g(O);return!p.has(z)&&!p.has(P)?[]:(m.add(z),m.add(P),[{rt:h,source:z,target:P}])})),j=i.filter(h=>m.has(g(h))),d=[],S=new Map,N=new Map;for(const{rt:h,source:x,target:M}of v){const O=`${h.slug}|${x}|${M}`,z=N.get(O);if(z){z.ruleCount+=1;continue}const P={slug:h.slug,label:h.name||h.slug,ruleCount:1};N.set(O,P);const Q=`${x}|${M}`,G=S.get(Q);if(G){G.data.relationships.push(P),G.data.isSymmetric=G.data.isSymmetric&&h.is_symmetric;continue}const ne={id:`pair:${x}|${M}`,source:x,target:M,data:{relationships:[P],isSymmetric:h.is_symmetric}};S.set(Q,ne),d.push(ne)}const E=new Map;for(const{rt:h,source:x,target:M}of v){const O=E.get(h.slug)??new Set;O.add(`${x}|${M}`),E.set(h.slug,O)}for(const{rt:h}of v)if(E.get(h.slug)?.size===1&&typeof h.relationship_count=="number")for(const x of N.values())x.slug===h.slug&&(x.linkCount=h.relationship_count);return{nodes:j.map(h=>{const x=h.name||h.slug,M=so(h),O=no(M,h.entity_count);return{id:g(h),width:ft(x,O),height:rt,data:{slug:h.slug,label:x,icon:h.icon,isSystem:Fs(h),organizationSlug:l(h)?void 0:y(h),metaLabel:O}}}),edges:d}}const Ue=24,ro=72,ao=16;let In=null;function oo(){return In??=new Ka({workerFactory:()=>new Ya}),In}const Gt={"elk.algorithm":"layered","elk.direction":"RIGHT","elk.edgeRouting":"ORTHOGONAL","elk.layered.spacing.edgeEdgeBetweenLayers":"12","elk.layered.spacing.edgeNodeBetweenLayers":"24","elk.layered.spacing.nodeNodeBetweenLayers":"80","elk.spacing.nodeNode":"48","elk.spacing.edgeEdge":"14","elk.spacing.edgeNode":"24","elk.layered.considerModelOrder.strategy":"NODES_AND_EDGES","elk.layered.crossingMinimization.semiInteractive":"true"};async function dn(e,{elk:n=oo(),targetAspect:s}={}){const a=new Set;for(const d of e.edges)a.add(d.source),a.add(d.target);const r=e.nodes.some(d=>d.lane!==void 0),i=e.nodes.filter(d=>r||a.has(d.id)),o=e.nodes.filter(d=>!r&&!a.has(d.id)),l=o.reduce((d,S)=>Math.max(d,S.width),0),y=o.length>0?Ue+l+ro:0,c=d=>({x:d.x+Ue+y,y:d.y+Ue});let g=[];const p=new Map;if(i.length>0){const d=e.edges.filter(h=>h.source!==h.target),S=h=>n.layout({id:"root",layoutOptions:r?{...h,"elk.partitioning.activate":"true"}:h,children:i.map(x=>({id:x.id,width:x.width,height:x.height,...r?{layoutOptions:{"elk.partitioning.partition":String(x.lane??1)}}:{}})),edges:d.map(x=>({id:x.id,sources:[x.layoutReversed?x.target:x.source],targets:[x.layoutReversed?x.source:x.target]}))});let N=await S(Gt);const E=s&&N.width&&N.height?s*N.width/N.height:1;if(E>1.08){const h=Number(Gt["elk.spacing.nodeNode"]),x=Math.min(E,2.2);N=await S({...Gt,"elk.spacing.nodeNode":String(Math.round(Math.min(180,h*x+rt*(x-1))))})}const k=new Map((N.children??[]).map(h=>[h.id,h]));g=i.map(h=>{const x=k.get(h.id);return{...h,position:c({x:x?.x??0,y:x?.y??0})}});for(const h of N.edges??[]){const x=(h.sections??[]).flatMap(O=>[O.startPoint,...O.bendPoints??[],O.endPoint]);if(x.length<2)continue;const M=e.edges.find(O=>O.id===h.id)?.layoutReversed;p.set(h.id,(M?[...x].reverse():x).map(c))}}let f=Ue;const m=o.map(d=>{const S={x:Ue,y:f};return f+=d.height+ao,{...d,position:S}}),v=new Map([...g,...m].map(d=>[d.id,d]));return{nodes:e.nodes.map(d=>v.get(d.id)??{...d,position:{x:Ue,y:Ue}}),edges:e.edges.map(d=>({...d,route:p.get(d.id)??null}))}}function io(e,n){return dn(vs(e),n)}const Jt="connector:",$n=e=>`${Jt}${e}`,co={event:"Zap",schedule:"CalendarClock",manual:"Hand"},lo=0,uo=1,On=2;function mo(e,n){const s=new Map;for(const{kind:a,targets:r}of aa(e?.feeds_schema?.[n]))for(const{entityType:i,creates:o}of r){const l=s.get(i)??{creates:!1,eventKinds:new Set};l.creates||=o,l.eventKinds.add(a),s.set(i,l)}return s}function fo(e,n){const s=new Map(e.connectorDefs.map(d=>[d.key,d])),a=new Map(e.connectorDefs.map(d=>[d.key,d.name])),r=new Map(e.connections.map(d=>[d.id,d])),i=Jr(e.feeds),o=d=>`connection:${d}`,l=d=>`automation:${d}`,y=[],c=new Set,g=(d,S,N,E,k=!1)=>{y.push({id:`flow:${d}->${S}`,source:d,target:S,layoutReversed:k,data:{relationships:[],isSymmetric:!1,flow:{summary:N,details:E}}}),c.add(d),c.add(S)},p=new Set(e.connections.map(d=>d.id));for(const d of e.connections){const S=new Map;for(const N of i.get(d.id)??[]){const E=mo(s.get(d.connector_key),N.feed_key);for(const[k,h]of E){const x=S.get(k)??{creates:!1,eventKinds:new Set};x.creates||=h.creates;for(const M of h.eventKinds)x.eventKinds.add(M);S.set(k,x)}}for(const[N,E]of S){const k=n.get(N);k&&g(o(d.id),k,E.creates?"creates records":"links records",[`From ${[...E.eventKinds].sort().join(", ")} events`])}}const f=Qr(e.automations);for(const[d,S]of f)if(p.has(d))for(const{automation:N,reason:E,eventTypes:k}of S){const h=l(N.automation_id);E==="trigger"?g(o(d),h,jn.trigger,k.length>0?[`On ${[...k].sort().join(", ")}`]:[]):g(h,o(d),jn.delivery,[],!0)}const m=[];for(const d of e.automations){const S=l(d.automation_id),N=d.entity_type?n.get(d.entity_type):void 0;N&&g(N,S,"anchored here",[d.entity_name?`On ${d.entity_name}`:""].filter(Boolean));const E=na(d,a,r),k=sa(d),h=d.health==="degraded"?"Needs attention":void 0;m.push({id:S,lane:On,width:ft(`${E.does} ${h??""}`,E.when),height:rt,data:{slug:S,label:E.does,icon:k?$n(k):co[E.kind],isSystem:!1,badge:h,metaLabel:E.when,ref:{kind:"automation",automationId:d.automation_id}}})}const v=[];for(const d of e.metrics){const S=n.get(d.typeSlug);if(!S)continue;const N=`metric:${d.typeSlug}:${d.name}`;g(S,N,"measures",[d.description].filter(Boolean)),v.push({id:N,lane:On,width:ft(d.name,d.agg),height:rt,data:{slug:N,label:d.name,icon:"ChartColumn",isSystem:!1,metaLabel:d.agg,ref:{kind:"metric",typeSlug:d.typeSlug,name:d.name}}})}return{nodes:[...e.connections.filter(d=>c.has(o(d.id))).map(d=>{const S=ra(d),N=ta(d,s.get(d.connector_key)),E=Xr({feeds:i.get(d.id)?.length||d.feed_count,actions:d.operations_summary?.total??0,automations:f.get(d.id)?.length??0}),k=N.needsAttention?"Needs attention":d.device_label??void 0;return{id:o(d.id),lane:lo,width:ft(`${S} ${k??""}`,E),height:rt,data:{slug:o(d.id),label:S,icon:$n(d.connector_key),isSystem:!1,badge:k,metaLabel:E,ref:{kind:"connection",connectorKey:d.connector_key,connectionId:d.id}}}}),...m,...v],edges:y}}function ut(e){switch(e.data.ref?.kind){case"connection":return"connections";case"automation":return"automations";case"metric":return"metrics";default:return"entities"}}function po(e,n){const s=new Map;for(const g of e.nodes)(!g.data.organizationSlug||!s.has(g.data.slug))&&s.set(g.data.slug,g.id);const a=fo(n,s),{layers:r}=n,i=[...a.nodes,...e.nodes.map(g=>({...g,lane:uo}))],o=new Set(i.filter(g=>r[ut(g)]).map(g=>g.id)),l=[...e.edges,...a.edges].filter(g=>o.has(g.source)&&o.has(g.target)),y=new Set(l.flatMap(g=>[g.source,g.target]));return{graph:{nodes:i.filter(g=>o.has(g.id)&&(ut(g)==="entities"||ut(g)==="automations"||y.has(g.id))),edges:l},hidden:{connections:r.connections?n.connections.length-a.nodes.filter(g=>ut(g)==="connections").length:0}}}const An="__new__";function Pn(e){return e.toLowerCase().replace(/[^a-z0-9]+/g,"_").replace(/^_+|_+$/g,"")}function ho({entityTypes:e,initialSource:n="",initialTarget:s="",onDone:a}){const r=b.useId(),i=`${r}-relationship`,o=`${r}-name`,l=`${r}-symmetric`,y=`${r}-source`,c=`${r}-target`,{orgContext:g}=We(),{data:p=[]}=tn(g),f=zs(),m=Ws(),[v,j]=b.useState(""),[d,S]=b.useState(""),[N,E]=b.useState(!1),[k,h]=b.useState(n),[x,M]=b.useState(s),[O,z]=b.useState(null),P=v===An,Q=p.filter(V=>V.status==="active"&&V.purpose!==Bs&&(!V.organization_slug||V.organization_slug===g?.slug)),G=f.isPending||m.isPending,ne=async()=>{if(z(null),!v)return z("Pick a relationship");if(!k||!x)return z("Pick both ends");try{let V=v;if(P){const ge=d.trim();if(!ge)return z("Name the relationship");const se=Pn(ge);if(!se)return z("Name must contain a letter or number");V=(await f.mutateAsync({slug:se,name:ge,is_symmetric:N})).relationship_type.slug,j(V)}await m.mutateAsync({slug:V,source_entity_type_slug:k,target_entity_type_slug:x}),a()}catch(V){z(V instanceof Error?V.message:"Could not save")}};return t.jsxs("div",{className:"flex flex-col gap-3 rounded-lg border border-border bg-muted/30 p-3",children:[t.jsx("p",{className:"text-[11px] leading-relaxed text-muted-foreground",children:"Relationships are defined once for the workspace, then paired with the types they connect."}),t.jsxs("div",{className:"space-y-1.5",children:[t.jsx(ze,{htmlFor:i,className:"text-xs after:ml-1 after:text-destructive after:content-['*']",children:"Relationship"}),t.jsxs(Ft,{value:v,onValueChange:j,children:[t.jsx(zt,{id:i,className:"h-8 text-xs",children:t.jsx(Wt,{placeholder:"Pick or define one"})}),t.jsxs(Bt,{children:[Q.map(V=>t.jsx(yt,{value:V.slug,children:V.name||V.slug},V.slug)),Q.length>0?t.jsx(Hs,{}):null,t.jsx(yt,{value:An,children:"Define a new one…"})]})]})]}),P?t.jsxs(t.Fragment,{children:[t.jsxs("div",{className:"space-y-1.5",children:[t.jsx(ze,{htmlFor:o,className:"text-xs after:ml-1 after:text-destructive after:content-['*']",children:"Name"}),t.jsx(at,{id:o,value:d,onChange:V=>S(V.target.value),placeholder:"works at",className:"h-8 text-xs"}),d.trim()?t.jsxs("p",{className:"text-[11px] text-muted-foreground",children:["Slug: ",t.jsx("code",{children:Pn(d)||"—"})]}):null]}),t.jsxs("div",{className:"flex items-start justify-between gap-2",children:[t.jsxs(ze,{htmlFor:l,className:"text-xs font-normal",children:["Symmetric",t.jsx("span",{className:"mt-0.5 block text-[11px] text-muted-foreground",children:"Both ends mean the same thing, like “connected with”."})]}),t.jsx(Vs,{id:l,checked:N,onCheckedChange:E})]})]}):null,t.jsxs("div",{className:"space-y-1.5",children:[t.jsx(ze,{htmlFor:y,className:"text-xs after:ml-1 after:text-destructive after:content-['*']",children:"From"}),t.jsxs(Ft,{value:k,onValueChange:h,children:[t.jsx(zt,{id:y,className:"h-8 text-xs",children:t.jsx(Wt,{placeholder:"Type"})}),t.jsx(Bt,{children:e.map(V=>t.jsx(yt,{value:V.slug,children:V.label},V.slug))})]})]}),t.jsxs("div",{className:"space-y-1.5",children:[t.jsx(ze,{htmlFor:c,className:"text-xs after:ml-1 after:text-destructive after:content-['*']",children:"To"}),t.jsxs(Ft,{value:x,onValueChange:M,children:[t.jsx(zt,{id:c,className:"h-8 text-xs",children:t.jsx(Wt,{placeholder:"Type"})}),t.jsx(Bt,{children:e.map(V=>t.jsx(yt,{value:V.slug,children:V.label},V.slug))})]})]}),O?t.jsx("p",{className:"rounded-md bg-destructive/10 px-3 py-2 text-sm text-destructive",children:O}):null,t.jsx(Kn,{onCancel:a,cancelDisabled:G,className:"[&>button]:h-7 [&>button]:px-3 [&>button]:text-xs",children:t.jsx(Y,{type:"button",size:"sm",onClick:ne,disabled:G,children:G?"Saving…":"Add relationship"})})]})}const ws=288,go=440,Et=240,Ct=720,yo=320,un="lobu.schema-panel-width:v1";function _t(e,n){if(!Number.isFinite(e))return ws;const s=Math.max(Et,Math.min(Ct,n-yo));return Math.round(Math.min(s,Math.max(Et,e)))}function xo(){const e=Yn(un);if(e===null)return null;const n=Number.parseInt(e,10);return!Number.isFinite(n)||n<Et||n>Ct?null:n}function bo(e){Jn(un,String(Math.round(e)))}function vo(){Us(un)}const Dn={nodes:[],edges:[]};function wo(e,n,s){const{orgContext:a}=We(),{data:r=[],isLoading:i,isError:o}=It(a),{data:l=[],isLoading:y,isError:c}=tn(a),g=b.useMemo(()=>bs(l,e),[l,e]),{data:p,isLoading:f,isError:m}=qs(a),v=b.useMemo(()=>{const k=new Map(g.map(x=>[x.id,x.slug])),h={};for(const x of p??[]){const M=k.get(x.relationship_type_id);M&&(h[M]??=[]).push(x)}return h},[p,g]),j=b.useMemo(()=>({entityTypes:r,relationshipTypes:g,rulesBySlug:v,ownerSlug:e,targetAspect:n,flow:s}),[r,g,v,e,n,s]),[d,S]=b.useState(null),N=i||y||f,E=o||c||m;return b.useEffect(()=>{if(N||E)return;let k=!1;const h={targetAspect:j.targetAspect};let x,M;if(j.flow){const O=po(vs(j),j.flow);x=O.hidden,M=dn(O.graph,h)}else M=io(j,h);return M.then(O=>{k||S({graph:O,isError:!1,hidden:x})}).catch(()=>{k||S({graph:Dn,isError:!0})}),()=>{k=!0}},[j,N,E]),{graph:d?.graph??Dn,hidden:d?.hidden,isLoading:!E&&!d,isError:E||d?.isError===!0}}function Fn(e){const n=e.ruleCount>1?` ×${e.ruleCount}`:"",s=typeof e.linkCount=="number"?` · ${e.linkCount.toLocaleString()}`:"";return`${e.label}${n}${s}`}const Qt={connections:"--chart-3",entities:"--chart-5",automations:"--chart-2",metrics:"--chart-4"};function ko(e,n){const s=e.nodes.some(o=>o.data.ref),a=new Map(e.nodes.map(o=>[o.id,o.data.label])),r=e.nodes.map(o=>({id:o.id,x:o.position.x+o.width/2,y:o.position.y+o.height/2,w:o.width,h:o.height,title:o.data.label,meta:o.data.metaLabel,icon:o.data.icon,badge:o.data.badge??o.data.organizationSlug,muted:o.data.isSystem,dimmed:n?!n.nodes.has(o.id):!1,accent:s?Qt[ut(o)]:void 0})),i=e.edges.map(o=>{const{relationships:l,isSymmetric:y,flow:c}=o.data;if(c)return{id:o.id,source:o.source,target:o.target,route:o.route??null,summary:c.summary,details:[c.summary,...c.details],directed:!0,dimmed:n?!n.edges.has(o.id):!1,ariaLabel:`${a.get(o.source)??o.source} to ${a.get(o.target)??o.target}: ${c.summary}`};const g=l.map(p=>p.label).join(", ");return{id:o.id,source:o.source,target:o.target,route:o.route??null,summary:l.length===1?Fn(l[0]):`${l.length} relationships`,details:l.map(Fn),directed:!y,dimmed:n?!n.edges.has(o.id):!1,ariaLabel:`${a.get(o.source)??o.source} ${y?"and":"to"} ${a.get(o.target)??o.target}: ${g}`}});return{boxes:r,edges:i}}const zn=[{key:"connections",label:"Connections"},{key:"entities",label:"Entities"},{key:"automations",label:"Automations"},{key:"metrics",label:"Metrics"}],jo={count:"Count",count_distinct:"Distinct count",sum:"Sum",min:"Minimum",max:"Maximum"};function No({metric:e,ownerSlug:n}){const s=(a,r)=>r.length>0?t.jsxs("section",{className:"flex flex-col gap-1.5",children:[t.jsx("h3",{className:"text-xs font-semibold uppercase tracking-wide text-muted-foreground",children:a}),t.jsx("ul",{className:"flex flex-col gap-1 text-sm",children:r.map(i=>t.jsxs("li",{children:[t.jsx("span",{className:"font-medium",children:i.name}),i.description?t.jsx("span",{className:"text-muted-foreground",children:` · ${i.description}`}):null]},i.name))})]}):null;return t.jsxs(t.Fragment,{children:[t.jsxs("section",{className:"flex flex-col gap-1",children:[t.jsxs("p",{className:"text-sm",children:[jo[e.agg]??e.agg," of"," ",t.jsx("code",{className:"rounded bg-muted px-1 text-xs",children:e.eventSet})," ","events, per ",e.typeLabel]}),e.description?t.jsx("p",{className:"text-sm text-muted-foreground",children:e.description}):null]}),s("Data from",e.sources.map(a=>({name:a,description:""}))),s("Group by",e.dimensions),s("Segments",e.segments),t.jsx(Y,{asChild:!0,variant:"outline",size:"sm",className:"self-start",children:t.jsxs(ve,{to:"/$owner/$entityType",params:{owner:n,entityType:e.typeSlug},children:["Open ",e.typeLabel]})})]})}function So({ownerSlug:e,metric:n,endpointOptions:s,canAuthor:a,mode:r,onModeChange:i}){const o=()=>i({kind:"index"});return r.kind==="metric"?n?t.jsx(No,{metric:n,ownerSlug:e}):null:a?r.kind==="create-type"?t.jsx(oa,{slug:null,onClose:o}):r.kind==="new-relationship"?t.jsx(ho,{entityTypes:s,initialSource:r.source,initialTarget:r.target,onDone:o},`${r.source??""}|${r.target??""}`):null:null}function Eo(e){const{mode:n,canAuthor:s,onModeChange:a,isPeekOpen:r}=e,i=s&&n.kind==="create-type",o=n.kind==="metric"?n.name:s&&n.kind==="new-relationship"?"New relationship":i?"New entity type":"Schema",l=b.useRef(null),y=JSON.stringify(n),c=b.useRef(y);return b.useEffect(()=>{c.current!==y&&(c.current=y,l.current?.focus({preventScroll:!0}))},[y]),t.jsx("aside",{style:{"--schema-panel-width":`${e.width}px`},className:me("order-first flex w-full shrink-0 flex-col lg:order-none lg:w-[var(--schema-panel-width)]",n.kind==="index"?"lg:absolute lg:top-0 lg:right-6 lg:z-10 lg:w-max lg:max-w-[calc(100%-3rem)] lg:max-h-[calc(100%-2rem)]":"bg-background lg:relative",r&&"lg:hidden"),children:t.jsxs("div",{className:me("flex min-h-0 flex-1 flex-col",n.kind!=="index"&&"lg:absolute lg:inset-0"),children:[t.jsxs("div",{className:n.kind==="index"?"sr-only":"flex h-11 shrink-0 items-center gap-1 border-b border-border px-3",children:[t.jsx("h2",{ref:l,tabIndex:-1,className:"min-w-0 flex-1 truncate text-sm font-medium text-foreground outline-none",children:o}),n.kind!=="index"?t.jsx(Y,{type:"button",variant:"ghost",size:"icon",className:"size-7 shrink-0 text-muted-foreground hover:text-foreground","aria-label":"Close",onClick:()=>a({kind:"index"}),children:t.jsx(tr,{className:"h-4 w-4"})}):null]}),t.jsx("div",{className:me("flex min-h-0 flex-1 flex-col gap-4 overflow-y-auto",n.kind==="index"?"pb-1":"p-4"),children:t.jsx(So,{...e})})]})})}function ks(e){const n=e.previousElementSibling,s=e.nextElementSibling;if(n instanceof HTMLElement&&s instanceof HTMLElement){const a=n.clientWidth+s.clientWidth;if(a>0)return a}return 0}function Co({width:e,maxWidth:n,onResize:s,onCommit:a,onReset:r,className:i}){const[o,l]=b.useState(!1),y=b.useRef(0),c=f=>{const m=ks(f);return m>0?m:f.parentElement?.clientWidth??0},g=f=>{if(f.button!==0)return;const m=f.currentTarget;if(!m.parentElement)return;f.preventDefault(),y.current=c(m);const j=f.clientX,d=e;l(!0),m.setPointerCapture(f.pointerId);const S=h=>_t(d-(h-j),y.current);let N=d;const E=h=>{N=S(h.clientX),s(N)},k=h=>{m.removeEventListener("pointermove",E),m.removeEventListener("pointerup",k),m.removeEventListener("pointercancel",k),l(!1),a(h.type==="pointercancel"?N:S(h.clientX))};m.addEventListener("pointermove",E),m.addEventListener("pointerup",k),m.addEventListener("pointercancel",k)},p=f=>{const m=c(f.currentTarget),v=j=>{f.preventDefault(),a(_t(e+j,m))};f.key==="ArrowLeft"?v(16):f.key==="ArrowRight"?v(-16):f.key==="Home"&&(f.preventDefault(),r())};return t.jsx("div",{role:"separator","aria-orientation":"vertical","aria-label":"Resize schema panel","aria-valuenow":e,"aria-valuemin":Et,"aria-valuemax":n,tabIndex:0,onPointerDown:g,onKeyDown:p,onDoubleClick:r,className:me("group hidden shrink-0 cursor-col-resize touch-none items-stretch justify-center px-1.5 outline-none lg:flex",o&&"cursor-col-resize",i),children:t.jsx("div",{className:me("w-px rounded-full bg-border transition-[background-color,width] group-hover:w-0.5 group-hover:bg-primary/60 group-focus-visible:w-0.5 group-focus-visible:bg-primary",o&&"w-0.5 bg-primary")})})}function _o({ownerSlug:e}){const n=ot(),s=nn(),a=s?.item!=null,{orgContext:r}=We(),{isAdmin:i}=Qn(r.organizationId),[o,l]=b.useState({connections:!0,entities:!0,automations:!0,metrics:!0}),[y,c]=b.useState({kind:"index"}),g=s?.close,p=b.useCallback(w=>{w.kind!=="index"&&a&&g?.(),c(w)},[a,g]),[f,m]=b.useState(),v=b.useRef(null),j=b.useCallback(w=>{if(v.current?.disconnect(),v.current=null,!w||typeof ResizeObserver>"u")return;const _=()=>{if(!w.clientWidth||!w.clientHeight)return;const H=Math.round(w.clientHeight/w.clientWidth*10)/10;m(F=>F===H?F:H)};_();const L=new ResizeObserver(_);L.observe(w),v.current=L},[]),d=r.organizationId,S=Gs(d),N=Ks(d),E=Ys(d),k=ea(d??void 0),{data:h}=It(r),x=b.useMemo(()=>h?.filter(w=>Js(w,e)),[h,e]),M=b.useMemo(()=>(x??[]).flatMap(w=>Object.entries(w.metrics_config?.measures??{}).map(([_,L])=>({typeSlug:w.slug,name:_,agg:L.agg,description:L.description}))),[x]),O=S.isLoading||N.isLoading||E.isLoading||k.isLoading,z=b.useMemo(()=>O?null:{connections:S.data??[],feeds:N.data??[],connectorDefs:E.data??[],automations:k.data??[],metrics:M,layers:o},[O,S.data,N.data,E.data,k.data,M,o]),{graph:P,isLoading:Q,isError:G,hidden:ne}=wo(e,f,z),V=Q||O,ge={connections:!O&&(S.data??[]).length===0,entities:!1,automations:!O&&(k.data??[]).length===0,metrics:!O&&M.length===0},se=y.kind==="metric"?y:null,$=b.useMemo(()=>{if(!se)return null;const w=`metric:${se.typeSlug}:${se.name}`,_=P.edges.find(F=>F.target===w);if(!_)return null;const L=_.source,H=P.edges.filter(F=>F.target===L&&P.nodes.find(D=>D.id===F.source)?.data.ref?.kind==="connection");return{typeId:L,nodes:new Set([w,L,...H.map(F=>F.source)]),edges:new Set([_.id,...H.map(F=>F.id)]),sources:H.map(F=>P.nodes.find(D=>D.id===F.source)?.data.label??F.source)}},[se,P]),{boxes:I,edges:q}=b.useMemo(()=>ko(P,$),[P,$]),U=b.useMemo(()=>{if(!se)return null;const w=x?.find(H=>H.slug===se.typeSlug),_=w?.metrics_config,L=_?.measures?.[se.name];return!w||!L?null:{name:se.name,typeSlug:w.slug,typeLabel:w.name||w.slug,agg:L.agg,eventSet:L.eventSet,description:L.description,dimensions:Object.entries(_?.dimensions??{}).map(([H,F])=>({name:H,description:F.description})),segments:Object.entries(_?.segments??{}).map(([H,F])=>({name:H,description:F.description})),sources:$?.sources??[]}},[se,x,$]),B=b.useMemo(()=>new Map(P.nodes.map(w=>[w.id,w.data.slug])),[P.nodes]),J=b.useMemo(()=>new Map(P.nodes.flatMap(w=>w.data.ref?[[w.id,w.data.ref]]:[])),[P.nodes]),{data:re=[]}=Qs(r.organizationId),fe=b.useMemo(()=>{const w=new Map;for(const _ of P.nodes)_.data.ref||(!_.data.organizationSlug||!w.has(_.data.slug))&&w.set(_.data.slug,{slug:_.data.slug,label:_.data.label});return[...w.values()]},[P.nodes]),le=b.useCallback(w=>{const _=J.get(w);if(_?.kind==="connection"){n({to:"/$owner/connectors/$connectorKey/$connectionId",params:{owner:e,connectorKey:_.connectorKey,connectionId:String(_.connectionId)},search:{}});return}if(_?.kind==="metric"){p({kind:"metric",typeSlug:_.typeSlug,name:_.name});return}if(_?.kind==="automation"){n({to:"/$owner/automations/$automationId",params:{owner:e,automationId:_.automationId},search:{view:"activity",run_id:void 0}});return}n(Xn(e,B.get(w)??w))},[n,e,B,J,p]),Ee=b.useCallback((w,_)=>{J.has(w)||J.has(_)||p({kind:"new-relationship",source:B.get(w)??w,target:B.get(_)??_})},[B,J,p]),Be=P.nodes.some(w=>!w.data.ref&&!w.data.isSystem&&!w.data.organizationSlug),Ie=P.nodes.some(w=>w.data.ref),$e="size-6 text-muted-foreground hover:text-foreground",Ce={connections:t.jsx(Zr,{ownerSlug:e,catalog:re,trigger:t.jsx(Y,{type:"button",variant:"ghost",size:"icon",className:$e,"aria-label":"New connector",title:"New connector",children:t.jsx(mt,{className:"size-3.5"})})}),entities:t.jsx(Y,{type:"button",variant:"ghost",size:"icon",className:$e,"aria-label":"Create entity type",title:"Create entity type",onClick:()=>p({kind:"create-type"}),children:t.jsx(mt,{className:"size-3.5"})}),automations:t.jsx(Y,{asChild:!0,variant:"ghost",size:"icon",className:$e,children:t.jsx(ve,{to:"/$owner/automations/new",params:{owner:e},"aria-label":"New Automation",title:"New Automation",children:t.jsx(mt,{className:"size-3.5"})})})},He=b.useCallback(w=>{const _=w.startsWith(Jt)?w.slice(Jt.length):null;if(!_)return t.jsx(Rt,{icon:w||null,className:"h-4 w-4"});const L=Xs(_,E.data??[],{name:S.data?.find(H=>H.connector_key===_)?.connector_name??_});return t.jsx(Zs,{plain:!0,icon:L.icon,iconUrl:L.iconUrl,name:L.name,faviconDomain:L.faviconDomain})},[E.data,S.data]),ye=i&&y.kind==="create-type",_e=y.kind==="metric"||i&&y.kind!=="index",[ke,Me]=b.useState(()=>xo()),pe=ke??(ye?go:ws),[Oe,Te]=b.useState(null),je=b.useRef(null),Ke=b.useCallback(w=>{if(je.current?.disconnect(),je.current=null,!w||typeof ResizeObserver>"u")return;const _=w.children[1];if(!_)return;const L=()=>{const F=ks(_);F>0&&Te(D=>D===F?D:F)};L();const H=new ResizeObserver(L);H.observe(w),je.current=H},[]),Ae=Oe===null?pe:_t(pe,Oe),C=Oe===null?Ct:_t(Ct,Oe),u=b.useCallback(w=>{Me(w),bo(w)},[]),T=b.useCallback(()=>{Me(null),vo()},[]);return V?t.jsx(ln,{label:"Loading workspace schema",fill:!0,schemaActions:i}):G?t.jsx(Zn,{label:"workspace schema"}):t.jsxs("div",{className:"flex min-h-0 min-w-0 flex-1 flex-col gap-3",children:[t.jsxs("div",{className:me("flex flex-wrap items-center justify-between gap-3",_e&&"hidden lg:flex"),children:[t.jsx("p",{className:"text-sm text-muted-foreground",children:Ie?`Where records come from, the types they land in, and what uses them. Click a box to open it${i?", or drag a type's ⊕ onto another to relate them":""}. Only stored links are drawn${ne?.connections?`; ${ne.connections} connections have none yet`:""}.`:Be?P.edges.length>0?`Your workspace schema. Hover a type or select a line to name its relationships, click a type to open it${i?", or drag its ⊕ to relate types.":"."}`:"Your workspace schema. Click a type to open it — relationships appear here once you add one to a type.":i?"Member is already here: everyone in this workspace. Create the first type of record you track — a company, a deal, a ticket — then drag its ⊕ onto Member to relate them.":"Member is already here: everyone in this workspace. An admin can add the types of record this workspace tracks."}),t.jsxs("fieldset",{className:"m-0 flex min-w-0 shrink-0 flex-wrap items-center gap-x-4 gap-y-1 border-0 p-0 text-sm",children:[t.jsx("legend",{className:"sr-only",children:"Show on the map"}),zn.map(({key:w,label:_})=>{const L=`memory-map-show-${w}`,H=o[w]&&!ge[w]&&zn.filter(({key:F})=>o[F]&&!ge[F]).length===1;return t.jsxs("span",{className:"inline-flex items-center gap-1.5",children:[t.jsx(er,{id:L,checked:o[w],disabled:H,style:{borderColor:`var(${Qt[w]})`,backgroundColor:o[w]?`var(${Qt[w]})`:void 0},onCheckedChange:F=>l(D=>({...D,[w]:F===!0}))}),t.jsx("label",{htmlFor:L,className:"inline-flex cursor-pointer select-none items-center",children:_}),i?Ce[w]:null]},w)})]})]}),t.jsxs("div",{ref:Ke,className:"relative flex min-h-0 min-w-0 flex-1 flex-col gap-3 lg:-mr-6 lg:-mb-8 lg:flex-row lg:gap-0",children:[t.jsx("div",{className:me("flex min-w-0 flex-1 flex-col lg:pb-8",_e&&"hidden lg:flex"),children:t.jsx("div",{ref:j,className:"min-h-[420px] min-w-0 flex-1 overflow-hidden rounded-lg bg-background",children:t.jsx(xs,{boxes:I,edges:q,label:"Workspace schema",onOpenBox:le,openLabel:w=>`Open ${w.title}`,onConnect:i?Ee:void 0,renderIcon:He})})}),t.jsx(Co,{width:Ae,maxWidth:C,onResize:Me,onCommit:u,onReset:T,className:a||y.kind==="index"?"lg:hidden":void 0}),t.jsx(Eo,{width:Ae,metric:U,ownerSlug:e,endpointOptions:fe,canAuthor:i,mode:y,onModeChange:p,isPeekOpen:a})]})]})}function Mo({onClose:e,entityTypeSlug:n,orgContext:s,onSuccess:a}){const{data:r,isLoading:i}=es(n,s),o=`${s.organizationId??s.slug}:${n}`,l=nr(o,{name:"",customSlug:"",useCustomSlug:!1,metadata:{}},r?.metadata_schema),[y,c]=l.field("name"),[g,p]=l.field("customSlug"),[f,m]=l.field("useCustomSlug"),[v,j]=l.field("metadata"),[d,S]=sr(o,null),N=rr(),E=f?g:ar(y),k=async z=>{if(z.preventDefault(),!l.canSubmit)return;if(S(null),!y.trim()){S("Name is required");return}const P=ca(v),Q={entityType:n,name:y.trim(),slug:f?g:void 0,metadata:Object.keys(P).length>0?P:void 0};try{const G=await N.mutateAsync(Q);if(e(),G.approval_queued||!G.entity){ts.info("Create queued for approval");return}typeof G.entity.id=="number"&&a?.(G.entity.id)}catch(G){S(G instanceof Error?G.message:"Failed to create entity")}},h=r?.name||n,x=l.revision,M=`Create ${h}`,O=`Add a new ${h.toLowerCase()} to your workspace.`;return i?t.jsx(or,{rows:6}):t.jsxs("form",{onSubmit:k,children:[t.jsx(ir,{visible:l.hasConflict,onReload:l.reset}),t.jsxs("div",{className:"space-y-1.5",children:[t.jsx("h1",{className:"text-2xl font-semibold leading-tight",children:M}),t.jsx("p",{className:"text-sm text-muted-foreground",children:O})]}),t.jsxs("div",{className:"grid gap-4 py-4",children:[t.jsxs("div",{className:"grid gap-2",children:[t.jsxs(ze,{htmlFor:"name",children:["Name ",t.jsx("span",{className:"text-destructive",children:"*"})]}),t.jsx(at,{id:"name",value:y,onChange:z=>c(z.target.value),placeholder:`Enter ${h.toLowerCase()} name`,autoFocus:!0})]}),t.jsxs("div",{className:"grid gap-2",children:[t.jsxs("div",{className:"flex items-center justify-between",children:[t.jsx(ze,{htmlFor:"slug",children:"URL Slug"}),t.jsx("button",{type:"button",onClick:()=>m(!f),className:"text-xs text-muted-foreground hover:text-foreground",children:f?"Auto-generate":"Customize"})]}),f?t.jsx(at,{id:"slug",value:g,onChange:z=>p(z.target.value.toLowerCase().replace(/[^a-z0-9-]/g,"")),placeholder:"custom-slug"}):t.jsx("div",{className:"flex h-9 items-center rounded-md border border-input bg-muted px-3 text-sm text-muted-foreground",children:E||"slug-preview"})]}),x&&Object.keys(x).length>0?t.jsxs(t.Fragment,{children:[t.jsx(ga,{className:"my-2"}),t.jsxs("div",{className:"grid gap-2",children:[t.jsx(ze,{className:"text-sm font-medium",children:"Additional Fields"}),t.jsx(ia,{schema:l.revision,values:v,onValuesChange:j,orgContext:s})]})]}):null,d&&t.jsx("div",{className:"rounded-md bg-destructive/10 px-3 py-2 text-sm text-destructive",children:d})]}),t.jsx(Kn,{onCancel:e,cancelDisabled:N.isPending,className:"mt-2",children:t.jsx(Y,{type:"submit",disabled:!l.canSubmit||N.isPending||!y.trim(),children:N.isPending?"Creating...":`Create ${h}`})})]})}function To(e){const n=e?.properties??{},s=ur(e);return Object.entries(n).flatMap(([a,r])=>{const i=s.find(p=>p.field===a);if(!/^[A-Za-z_][A-Za-z0-9_]*$/.test(a)||!r||r.const!==void 0||r["x-table-column"]!==!0&&r["x-facet"]!==!0&&!i)return[];const o=[r,...Array.isArray(r.anyOf)?r.anyOf:[]],l=i?.options??[],y=l.find(p=>p.value!==null)?.value,c=o.find(p=>["string","number","integer","boolean"].includes(String(p.type)))??(y===void 0?void 0:{type:typeof y});if(!c)return[];const g=r.format==="date-time"||c.format==="date-time"?"datetime-local":r.format==="date"||c.format==="date"?"date":c.type==="number"||c.type==="integer"?"number":c.type==="boolean"?"boolean":"string";return[{field:a,label:String(r["x-table-label"]??r.title??a.replaceAll("_"," ")),type:g,options:g==="boolean"&&!l.some(p=>typeof p.value=="boolean")?[{value:!0,label:"Yes"},{value:!1,label:"No"},...l]:l}]})}function Lo(e){const n=e?.[Yt];return n===void 0?{}:sn(n)}function Ro(e,n,s){try{const a=Lo(n),r=e[ns],i=r===void 0?void 0:a.presets?.find(g=>g.key===r);if(r!==void 0&&!i)throw new Error("This saved filter is unavailable. Choose another filter.");if(i&&!s&&typeof e.segment=="string"&&e.segment)throw new Error("A saved filter and an explicit selection cannot be combined.");const o=i&&e[nt]===void 0?{collection:jt(i)}:cr(e,s);if(o.error)throw o.error;const l=e[lr],y=l===void 0?i?.table??a.table??{}:sn({table:typeof l=="string"?JSON.parse(l):l}).table??{},c=!!i&&(Wn(o.collection)!==Wn(jt(i))||Mt(y)!==Mt(i.table??a.table??{}));return{...o,presentation:a,preset:i,table:y,edited:c}}catch(a){return{collection:{},presentation:{},table:{},edited:!1,error:a instanceof Error?a:new Error("Invalid collection configuration")}}}function Wn(e){return JSON.stringify([e.search??"",e.segment??"",(e.filters??[]).map(wt)])}function wt(e){return JSON.stringify([e.field,e.op,e.value])}function Mt(e){return JSON.stringify([e.columns??null,e.sort?.field??null,e.sort?.order??null])}function Io(e,n){return n?{[ns]:n,[nt]:Kt(e)[nt]??"{}"}:Kt(e)}function $o(e,n,s,a,r=new Date){let i=n.filters??[],o=e.relativeDate;if(o){const l=(jt({...e,selection:{}},r).filters??[]).map(wt),y=i.map(wt);l.every(c=>y.includes(c))?i=i.filter(c=>!l.includes(wt(c))):o=void 0}return{key:e.key,label:e.label,selection:{...n.search?{search:n.search}:{},...i.length?{filters:i}:{},...n.segment?{segment:n.segment}:{}},...Mt(s)!==Mt(a.table??{})?{table:s}:{},...o?{relativeDate:o}:{}}}function Oo(e,n,s){const a=[...e.filters??[]],r=s??(n.length===1&&n[0].op==="eq"?a.findIndex(o=>o.field===n[0].field&&o.op==="eq"):-1),i=r>=0?[...a.slice(0,r),...n,...a.slice(r+1)]:[...a,...n];return{...e,filters:mr({filters:i}).filters}}function Ao(e,n){return{...e,filters:e.filters?.filter((s,a)=>a!==n)}}function Po(e,n){return{...typeof e.$preset=="string"?e[nt]===void 0?{$preset:e.$preset}:{$preset:e.$preset,[nt]:String(dr(e[nt]))}:Kt(n),...e.$table===void 0?{}:{$table:typeof e.$table=="string"?e.$table:JSON.stringify(e.$table)}}}const Do=[{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 Fo(e){return e.sort&&Do.some(n=>n.field===e.sort?.field)?e.sort:{field:"created_at",order:"desc"}}function zo(e,n,s,a,r){const i={...a,filters:a.filters?.filter(o=>o.field!==s)};return ss({queryKey:["collection-facets",e,n,s,i],enabled:!!n&&!!s,staleTime:3e4,retry:!1,queryFn:async({signal:o})=>{const l=await Nt("query_sdk",{title:`Value counts query for ${s}`,script:`const input = ${JSON.stringify({field:s,collection:i})};
2
+ ${n}`},e,{signal:o}),y=l.return_value;if(!l.success||typeof y?.connection!="string"||typeof y.sql!="string")throw new Error(l.error?.message??"Value distribution is unavailable");if(o.aborted)throw new DOMException("Aborted","AbortError");const c=await Nt("query_sql",{title:`Value counts for ${s}`,connection:y.connection,sql:y.sql,limit:51},e,{signal:o});if(c.error)throw new Error(c.error);if(!Array.isArray(c.rows))throw new Error("Source did not return value counts");const g=c.rows.map(p=>{const f=p,m=typeof f.count=="string"&&/^\d+$/.test(f.count)?Number(f.count):f.count;if(!(f.value===null||["string","number","boolean"].includes(typeof f.value))||typeof m!="number"||!Number.isSafeInteger(m)||m<0)throw new Error("Source returned an invalid value distribution");return{value:f.value,count:m}});return{values:g.slice(0,50),truncated:g.length>50||c.truncated===!0}}})}const Wo=300;function Bo({label:e,search:n,onSearch:s,className:a}){const r=n??"",[i,o]=b.useState(r),l=b.useRef({search:n,onSearch:s});l.current={search:n,onSearch:s};const y=b.useRef(void 0);b.useEffect(()=>{const g=()=>{clearTimeout(y.current),o(l.current.search??"")};return window.addEventListener("popstate",g),()=>window.removeEventListener("popstate",g)},[]);const c=b.useRef(r);return b.useEffect(()=>{r!==c.current&&(c.current=r,o(r))},[r]),b.useEffect(()=>{if(i===(l.current.search??""))return;const g=setTimeout(()=>{const p=l.current.onSearch;c.current=i,p(i||void 0,!0)},Wo);return y.current=g,()=>clearTimeout(g)},[i]),t.jsxs("div",{className:`relative${a?` ${a}`:""}`,children:[t.jsx(pr,{"aria-hidden":"true",className:"absolute left-3 top-1/2 h-4 w-4 -translate-y-1/2 text-muted-foreground"}),t.jsx(at,{type:"search","aria-label":`Search ${e.toLowerCase()}`,placeholder:`Search ${e.toLowerCase()}...`,maxLength:512,value:i,onChange:g=>o(g.target.value),className:"pl-9"})]})}const Ho={eq:"is",neq:"is not",lt:"<",lte:"≤",gt:">",gte:"≥"};function Vo({field:e,initial:n,org:s,facetQuery:a,collection:r,onApply:i,close:o}){const[l,y]=b.useState(n?.op??"eq"),[c,g]=b.useState(n?.value==null?"":String(n.value)),[p,f]=b.useState(""),[m,v]=b.useState(!1),[j,d]=b.useState(),S=e.type==="date"||e.type==="datetime-local"||e.type==="number"?e.type:"text",N=zo(s,a,e.field,r),E=x=>{try{const M=m?[{field:e.field,op:"gte",value:e.type==="number"?Number(c):c},{field:e.field,op:"lte",value:e.type==="number"?Number(p):p}]:[{field:e.field,op:l,value:x}];if(e.type==="datetime-local")for(const P of M)typeof P.value=="string"&&(P.value=new Date(P.value).toISOString());if(M.some(P=>typeof P.value=="number"&&!Number.isFinite(P.value)))throw new Error("Enter a valid number.");const O=M[0].value,z=M[1]?.value;if(m&&O!=null&&z!=null&&O>z)throw new Error("The lower bound must be before the upper bound.");i(M),o()}catch(M){d(M instanceof Error?M.message:"Could not apply filter")}},k=[...e.options];for(const x of N.data?.values??[])k.some(M=>M.value===x.value)||k.push({value:x.value,label:x.value===null?"Not supplied":String(x.value)});const h=Math.max(1,...N.data?.values.map(x=>x.count)??[]);return t.jsxs("div",{className:"min-w-0 space-y-3 p-3",children:[t.jsxs("select",{"aria-label":"Filter operator",className:"h-8 w-full rounded-md border bg-background px-2 text-sm",value:m?"range":l,onChange:x=>{v(x.target.value==="range"),x.target.value!=="range"&&y(x.target.value)},children:[t.jsx("option",{value:"eq",children:"is"}),t.jsx("option",{value:"neq",children:"is not"}),(e.type==="number"||e.type==="date"||e.type==="datetime-local")&&t.jsxs(t.Fragment,{children:[t.jsx("option",{value:"lt",children:"less than / before"}),t.jsx("option",{value:"lte",children:"at most / on or before"}),t.jsx("option",{value:"gt",children:"greater than / after"}),t.jsx("option",{value:"gte",children:"at least / on or after"}),n?null:t.jsx("option",{value:"range",children:"between"})]})]}),e.type!=="boolean"&&t.jsxs("form",{className:"space-y-2",onSubmit:x=>{x.preventDefault(),E(e.type==="number"?Number(c):c)},children:[t.jsx(at,{required:!0,"aria-label":m?"From value":"Filter value",type:S,step:e.type==="number"?"any":void 0,value:c,onChange:x=>g(x.target.value),placeholder:"Enter a value…"}),m&&t.jsx(at,{required:!0,"aria-label":"To value",type:S,step:e.type==="number"?"any":void 0,value:p,onChange:x=>f(x.target.value)}),t.jsx(Y,{size:"sm",type:"submit",className:"w-full",children:"Apply filter"})]}),!m&&(l==="eq"||l==="neq")&&t.jsx("div",{className:"max-h-48 space-y-1 overflow-y-auto",children:k.filter(x=>!c||x.label.toLowerCase().includes(c.toLowerCase())).map(x=>{const M=N.data?.values.find(O=>O.value===x.value)?.count;return t.jsxs("button",{type:"button","aria-label":x.label,onClick:()=>E(x.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:[M!==void 0&&t.jsx("span",{"aria-hidden":"true",className:"absolute inset-y-0 left-0 bg-primary/10",style:{width:`${M/h*100}%`}}),t.jsx("span",{className:"relative truncate",children:x.label}),t.jsx("span",{className:"relative text-xs tabular-nums text-muted-foreground",children:M?.toLocaleString()})]},JSON.stringify(x.value))})}),a&&N.isFetching&&t.jsx("p",{role:"status",className:"text-xs text-muted-foreground",children:"Loading distribution…"}),N.isError&&t.jsx("p",{role:"status",className:"text-xs text-muted-foreground",children:"Counts unavailable. You can still enter a value."}),N.data?.truncated&&t.jsx("p",{className:"text-xs text-muted-foreground",children:"Top 50 values. Enter any other value above."}),j&&t.jsx("p",{role:"alert",className:"text-xs text-destructive",children:j})]})}function Uo({choices:e,visible:n,onChange:s}){return t.jsxs(rn,{children:[t.jsx(an,{asChild:!0,children:t.jsx(Y,{variant:"ghost",size:"icon",className:"size-7 text-muted-foreground hover:text-foreground","aria-label":"Choose columns",title:"Choose columns",children:t.jsx(rs,{className:"h-4 w-4"})})}),t.jsxs(on,{align:"end",className:"max-h-80 overflow-y-auto p-3",children:[t.jsx("p",{className:"mb-2 text-sm font-medium",children:"Visible columns"}),e.map(a=>t.jsxs("label",{className:"flex cursor-pointer items-center gap-2 py-1.5 text-sm",children:[t.jsx("input",{type:"checkbox",checked:!n||n.includes(a.field),onChange:r=>{const i=n??e.map(o=>o.field);s(r.target.checked?[...i,a.field]:i.filter(o=>o!==a.field))}}),a.label]},a.field))]})]})}function qo({collection:e,schema:n,label:s,onChange:a,org:r,facetQuery:i,segmentChip:o,viewFilters:l,onClearAll:y}){const c=To(n),g=(v,j)=>({kind:"custom",className:"w-80",render:d=>t.jsx(Vo,{field:v,initial:j==null?void 0:e.filters?.[j],org:r,facetQuery:i,collection:e,onApply:S=>a(Oo(e,S,j)),close:d})}),p=c.map(v=>({key:v.field,label:v.label,icon:t.jsx(fr,{className:"h-4 w-4"}),editor:g(v)})),f=new Map,m=(e.filters??[]).map((v,j)=>{const d=`${v.field}:${v.op}:${JSON.stringify(v.value)}`,S=f.get(d)??0;f.set(d,S+1);const N=c.find(k=>k.field===v.field),E=N?.options.find(k=>k.value===v.value)?.label??String(v.value??"Not supplied");return{id:`${d}:${S}`,label:N?.label??v.field,op:Ho[v.op],value:E,editor:N?g(N,j):void 0,onRemove:()=>a(Ao(e,j))}});if(o&&m.unshift(o),l?.fields.length){for(const v of p)v.group=s;p.push(...l.fields),m.push(...l.chips)}return!p.length&&!m.length?null:t.jsx(ya,{label:`${s} filters`,fields:p,chips:m,onClearAll:y??(()=>a({...e,filters:[],segment:void 0}))})}const Tt=120,Re=12;function Bn(e,n){return typeof e.linkId=="number"&&typeof n.linkId=="number"?e.linkId-n.linkId:String(e.linkId).localeCompare(String(n.linkId))}function Go(e){const n=e.records.slice(0,Tt),s=c=>e.types.get(c)??{label:c},a=new Map;for(const c of n)a.set(String(c.id),{source:c.source,entityType:e.typeSlug,slug:c.slug,name:c.name,isFocus:!0,hasMoreLinks:!1});const r=new Map;for(const c of e.links){if(!a.has(String(c.recordId)))continue;const g=r.get(c.recordId)??new Map;g.set(c.linkId,c),r.set(c.recordId,g)}const i=new Map;for(const[c,g]of r){const p=[...g.values()].sort(Bn),f=a.get(String(c));f&&p.length>Re&&(f.hasMoreLinks=!0);for(const m of p.slice(0,Re)){i.set(m.linkId,m);const v=String(m.peer.id);a.has(v)||a.set(v,{source:m.peer.source,...m.peer.remote?{remote:m.peer.remote}:{},entityType:m.peer.type,slug:m.peer.slug,name:m.peer.name,isFocus:!1,hasMoreLinks:!1})}}const o=[];for(const[c,g]of a){const p=g.remote?{label:g.entityType}:s(g.entityType),f=g.name||g.slug,m=g.hasMoreLinks?`${p.label} · ${Re}+ links`:p.label;o.push({id:c,data:{slug:g.slug,label:f,icon:p.icon,isSystem:!1,metaLabel:m},width:ft(f,m),height:rt})}const l=new Map;for(const c of[...i.values()].sort(Bn)){const g=String(c.fromId),p=String(c.toId),f=JSON.stringify([g,p]),m=l.get(f)??{source:g,target:p,rels:new Map,symmetric:!0};m.symmetric&&=c.isSymmetric,m.rels.has(c.relSlug)||m.rels.set(c.relSlug,{slug:c.relSlug,label:c.relName,ruleCount:1}),l.set(f,m)}const y=[...l.entries()].map(([c,g])=>({id:`link:${c}`,source:g.source,target:g.target,data:{relationships:[...g.rels.values()],isSymmetric:g.symmetric}}));return{nodes:o,edges:y,records:a,hasMoreRecords:e.hasMore===!0||e.records.length>Tt,listedCount:n.length,focusCount:n.length}}async function Ko(e,n){const s=Go(e);return{...await dn({nodes:s.nodes,edges:s.edges},n),records:s.records,hasMoreRecords:s.hasMoreRecords,listedCount:s.listedCount,focusCount:s.focusCount}}const Yo=8,Jo=3,Qo=4;function kt(e){return`source:${JSON.stringify([e.type,e.key])}`}function Xo(e,n){return n.map(s=>{const a={type:e,key:s.slug};return{...s,id:kt(a),source:a}})}function Hn(e){return JSON.stringify([e.relationship_type,e.direction,e.entity_type,e.key])}async function Zo(e,n,s){const a=e.slice(0,Yo),r=[];let i=0;return await Promise.all(Array.from({length:Math.min(Jo,a.length)},async()=>{for(;i<a.length;){const o=i++,l=a[o];try{if(s?.aborted)throw s.reason;const y=await n(l),c=new Map(l.links.map(d=>[Hn(d),d]));for(const d of y.record_links){const S=Hn(d),N=c.get(S);(!N||N.occurred_at<d.occurred_at)&&c.set(S,d)}const g=new Map((l.relationships??[]).map(d=>[d.id,d]));for(const d of y.relationships??[])g.set(d.id,d);const p=[...g.values()].slice(0,Re+1),f=[...c.values()].slice(0,Re+1),m=(l.pagesRead??0)+1,v=!!y.next_cursor&&m>=Qo,j=y.record_failures.length>0||!!y.relationship_failures?.length||v;r[o]={read:{record:l.record,links:f,failed:j,entityId:l.entityId,relationships:p},...!v&&(j||y.next_cursor&&f.length+p.length<=Re)?{next:{record:l.record,entityId:l.entityId,relationships:p,pagesRead:m,cursor:y.next_cursor??l.cursor,links:f}}:{}}}catch(y){if(s?.aborted)throw y;r[o]={read:{record:l.record,links:l.links,failed:!0,entityId:l.entityId,relationships:l.relationships},next:{...l,cursor:y instanceof hr&&y.status===400?null:l.cursor}}}}})),{reads:r.map(o=>o.read),pending:[...r.flatMap(o=>o.next?[o.next]:[]),...e.slice(a.length)]}}function ei(e,n){const s=new Map;for(const i of e)for(const o of i.reads)s.set(String(o.entityId??kt(o.record)),o);const a=new Map(n.map(i=>[i.slug,i])),r=[];for(const[i,o]of s){for(const l of o.relationships??[]){const y=(d,S,N)=>N?`remote:${N}`:typeof d=="number"?d:kt({type:S,key:d}),c=y(l.from_entity_id,l.from_entity_type,l.from_entity_url),g=y(l.to_entity_id,l.to_entity_type,l.to_entity_url),p=String(c)===i,f=p?g:c,m=p?l.to_entity_id:l.from_entity_id,v=p?l.to_entity_url:l.from_entity_url,j=(p?l.to_entity_type:l.from_entity_type)??"";r.push({recordId:i,linkId:l.id,fromId:c,toId:g,relSlug:l.relationship_type_slug,relName:l.relationship_type_name,isSymmetric:l.is_symmetric,peer:{id:f,name:(p?l.to_entity_name:l.from_entity_name)??String(m),slug:(p?l.to_entity_slug:l.from_entity_slug)??String(m),type:j,...v?{remote:{url:gr(v)}}:typeof m=="string"?{source:{type:j,key:m}}:{}}})}for(const l of o.links){const y={type:l.entity_type,key:l.key},c=kt(y),g=a.get(l.relationship_type);let p=l.direction==="incoming"?c:i,f=l.direction==="incoming"?i:c;g?.is_symmetric&&p>f&&([p,f]=[f,p]),r.push({recordId:i,linkId:JSON.stringify([p,f,l.relationship_type]),fromId:p,toId:f,relSlug:l.relationship_type,relName:g?.name||l.relationship_type.replaceAll("_"," "),isSymmetric:g?.is_symmetric??!1,peer:{id:c,name:l.name||l.key,slug:l.key,type:l.entity_type,source:y}})}}return{links:r,checked:s.size,failed:[...s.values()].filter(i=>i.failed).length}}function ti(e,n,s,a,r,i=!1){const{orgContext:o}=We(),l=It(o),y=tn(o),c=b.useMemo(()=>i?Xo(n,s):s,[i,n,s]),g=b.useMemo(()=>c.slice(0,Tt).flatMap(k=>k.source?[{record:k.source,cursor:null,links:[]}]:typeof k.id=="number"?[{entityId:k.id,record:{type:n,key:k.slug},cursor:null,links:[]}]:[]),[c,n]),p=yr({queryKey:["source-records-graph",o.organizationId,e,n,g.map(k=>[k.record,k.entityId])],enabled:!0,initialPageParam:g,queryFn:({pageParam:k,signal:h})=>Zo(k,async x=>{const M=await Nt("manage_entity",{action:"list_links",...x.entityId===void 0?{record:x.record,cursor:x.cursor}:{entity_id:x.entityId,offset:Number(x.cursor??0)},limit:Re+1},e,{signal:h});return{...M,record_links:M.record_links??[],record_failures:M.record_failures??[],next_cursor:x.entityId===void 0?M.next_cursor:M.metadata?.has_more?String(Number(x.cursor??0)+Re+1):null}},h),getNextPageParam:k=>k.pending.length?k.pending:void 0,staleTime:3e4,retry:!1}),f=b.useMemo(()=>p.data?ei(p.data.pages,y.data??[]):void 0,[p.data,y.data]),m=f?.links,v=p.isError,j=JSON.stringify([o.organizationId,e,n,i,c.map(k=>[k.id,k.name,k.slug]),a]),d=b.useMemo(()=>new Map((l.data??[]).map(k=>[k.slug,{label:k.name||k.slug,icon:k.icon}])),[l.data]),[S,N]=b.useState(null);b.useEffect(()=>{if(!m)return;let k=!1;return Ko({typeSlug:n,records:c,hasMore:a,links:m,types:d},{targetAspect:r}).then(h=>{k||N({graph:h,key:j,isError:!1})}).catch(()=>{k||N({graph:null,key:j,isError:!0})}),()=>{k=!0}},[m,n,c,a,d,r,j]);const E=S?.key===j?S:null;return{graph:E?.graph??null,isLoading:!v&&!E,isError:v||E?.isError===!0,sourceProgress:{checked:f?.checked??0,total:Math.min(s.length,Tt),failed:f?.failed??0,hasMore:!!p.hasNextPage,isFetching:p.isFetching,loadMore:()=>{p.isFetching||p.fetchNextPage()}}}}function ni(e){const n=new Map(e.nodes.map(r=>[r.id,r.data.label])),s=e.nodes.map(r=>({id:r.id,x:r.position.x+r.width/2,y:r.position.y+r.height/2,w:r.width,h:r.height,title:r.data.label,meta:r.data.metaLabel,icon:r.data.icon,muted:e.records.get(r.id)?.isFocus===!1})),a=e.edges.map(r=>{const{relationships:i,isSymmetric:o}=r.data,l=i.map(y=>y.label);return{id:r.id,source:r.source,target:r.target,route:r.route??null,summary:l.length===1?l[0]:`${l.length} relationships`,details:l,directed:!o,ariaLabel:`${n.get(r.source)??r.source} ${o?"and":"to"} ${n.get(r.target)??r.target}: ${l.join(", ")}`}});return{boxes:s,edges:a}}function si({ownerSlug:e,typeSlug:n,records:s,hasMore:a,sourceBacked:r=!1}){const i=ot(),o=nn(),{orgContext:l}=We(),{data:y=[]}=It(l),c=y.find(h=>h.slug===n)?.name??n,[g,p]=b.useState(),f=b.useRef(null),m=b.useCallback(h=>{if(f.current?.disconnect(),f.current=null,!h||typeof ResizeObserver>"u")return;const x=()=>{if(!h.clientWidth||!h.clientHeight)return;const O=Math.round(h.clientHeight/h.clientWidth*10)/10;p(z=>z===O?z:O)};x();const M=new ResizeObserver(x);M.observe(h),f.current=M},[]),{graph:v,isLoading:j,isError:d,sourceProgress:S}=ti(e,n,s,a,g,r),N=b.useMemo(()=>v?ni(v):null,[v]),E=b.useCallback(h=>{const x=v?.records.get(h);if(x){if(x.remote){x.remote.url&&window.open(x.remote.url,"_blank","noopener,noreferrer");return}if(o){o.open(la({...x.source?{record:x.source}:{entityId:Number(h)},ownerSlug:e,orgContext:l,name:x.name||x.slug}));return}i({to:as(e,[{entity_type:x.entityType,slug:x.slug}])})}},[v,e,l,o,i]);if(d)return t.jsx(Zn,{label:`${c} graph`});if(j||!v||!N)return t.jsx(ln,{label:`Loading ${c} graph`});const k=S?t.jsxs("div",{className:"flex flex-wrap items-center justify-between gap-3",children:[t.jsxs("div",{className:"text-sm text-muted-foreground",role:"status",children:[t.jsxs("p",{children:["Checked ",S.checked," of ",S.total," records. Up to ",Re," relationships per record."]}),S.failed>0?t.jsx("p",{role:"alert",children:"Some sources could not be read. These relationships are incomplete."}):null]}),S.hasMore?t.jsx(Y,{variant:"outline",size:"sm",disabled:S.isFetching,onClick:S.loadMore,children:S.isFetching?"Loading…":S.failed>0?"Retry sources":"Load more relationships"}):null]}):null;return v.focusCount===0?t.jsxs("div",{className:"space-y-3",children:[k,t.jsx(os,{icon:is,title:`No ${c} records match`,description:"Change the search or filters to see records here."})]}):t.jsxs("div",{className:"flex flex-col gap-2",children:[k,t.jsxs("p",{className:"text-sm text-muted-foreground",children:["Showing ",v.hasMoreRecords?"the first ":"",v.focusCount," ",c," record",v.focusCount===1?"":"s",". Click a record to see it."]}),t.jsx("div",{ref:m,className:"h-[70vh] min-h-[420px] min-w-0 overflow-hidden",children:t.jsx(xs,{boxes:N.boxes,edges:N.edges,label:`${c} records`,onOpenBox:E,openLabel:h=>`Show ${h.title}`})})]})}function ri({direction:e}){return e?t.jsxs("svg",{className:"h-4 w-4",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:[t.jsx("title",{children:e==="asc"?"Sort ascending":"Sort descending"}),e==="asc"?t.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M5 15l7-7 7 7"}):t.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M19 9l-7 7-7-7"})]}):t.jsxs("svg",{className:"h-4 w-4 text-muted-foreground/50",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:[t.jsx("title",{children:"Sort"}),t.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M7 16V4m0 0L3 8m4-4l4 4m6 0v12m0 0l4-4m-4 4l-4-4"})]})}function et({column:e,children:n,alignRight:s=!1}){return t.jsxs("button",{type:"button",className:`flex items-center gap-1.5 whitespace-nowrap text-left transition-colors hover:text-foreground [&>svg]:shrink-0${s?" ml-auto":""}`,onClick:()=>e.toggleSorting(e.getIsSorted()==="asc"),children:[n,t.jsx(ri,{direction:e.getIsSorted()})]})}function Xt(e,n,s){const a=cs(e?.properties).filter(([i,o])=>(!n||i!=="name")&&!o["x-image"]&&o["x-table-column"]===!0);if(a.length)return a.map(([i,o])=>({field:i,label:o["x-table-label"]??Ge(i.replaceAll("_"," "))}));if(!n)return[];const r=s.find(i=>Object.keys(Se(i.metadata)).length>0);return Object.keys(Se(r?.metadata)).filter(i=>i!=="id"&&i!=="slug"&&i!=="name"&&!xr(e?.properties?.[i])).map(i=>({field:i,label:Ge(i.replaceAll("_"," "))}))}function ai(e){return e.some(n=>Object.hasOwn(Se(n.metadata),"name"))}function oi(e,n){return st(e,$t(n))}function ii(e){return`${e.entityType}:${e.lookupField}`}const ci=new Set(["stage","category","round_type","investor_type"]);function li(e,n){const s=e.toLowerCase();return s==="mrr"||s==="arr"||s==="revenue"||s==="valuation"||s==="funding_raised"||s==="fund_size"||s.endsWith("_usd")||n.description?.toLowerCase().includes("usd")===!0}function di(e,n){if(li(e,n))return"currency";if(ci.has(e)||e.endsWith("_slug"))return"enum"}function ui({entities:e,owner:n,schema:s,entityTypeIcon:a,isDerived:r,measureColumns:i,linkedEntityLookups:o,hasAnyParents:l,sorting:y,onSortingChange:c,visibleColumns:g,columnChoices:p,onVisibleColumnsChange:f,page:m,pageSize:v,totalCount:j,hasMore:d,pageTitle:S,onPrevPage:N,onNextPage:E}){const k=p?.length&&f?t.jsx(Uo,{choices:p,visible:g,onChange:f}):null,h=s?.properties,x=!r||ai(e),M=b.useMemo(()=>h?Object.fromEntries(Object.entries(h).flatMap(([$,I])=>I["x-link-entity-type"]?[[$,{entityType:I["x-link-entity-type"],lookupField:I["x-link-lookup-field"]||"slug"}]]:[])):{},[h]),O=b.useMemo(()=>h?Xt({properties:h},r,[]).map(({field:I})=>[I,h[I]]).map(([I,q])=>{const U=M[I],B=U?o[ii(U)]:void 0;return{id:r?I:`meta_${I}`,accessorFn:J=>{const re=Se(J.metadata);return da(re[I],q.enum)},header:({column:J})=>{const re=q["x-table-label"]||q.title||q.description||Ge(I.replace(/_/g," "));return r?t.jsx(et,{column:J,children:re}):re},cell:({getValue:J})=>t.jsx(Nn,{value:J(),prop:q,format:di(I,q),className:"text-muted-foreground",resolveLink:B?re=>{const fe=B[re];return fe?{label:fe.name,to:st(n,[{entity_type:fe.entity_type,slug:fe.slug}])}:void 0}:void 0})}}):[],[r,M,o,n,h]),z=b.useMemo(()=>new Set(i),[i]),P=b.useMemo(()=>!r||O.length>0?[]:Xt({properties:h},!0,e).map(({field:I})=>I).map(I=>{const q=z.has(I);return{id:I,accessorFn:U=>Se(U.metadata)[I],header:({column:U})=>t.jsxs(et,{column:U,children:[q?I:Ge(I.replace(/_/g," ")),q&&t.jsx(pt,{variant:"secondary",className:"font-normal lowercase",children:"measure"})]}),cell:({getValue:U})=>t.jsx(Nn,{value:U(),prop:h?.[I],className:q?"tabular-nums":"text-muted-foreground"}),meta:q?{align:"right"}:void 0}}),[r,O,e,z,h]),Q=b.useMemo(()=>{const $=s?.["x-table-relationships"];return!$||$.length===0?[]:$.map(I=>({id:`rel_${I.relationship_type}`,accessorFn:q=>q.relationships?.[I.relationship_type]??[],header:I.label,cell:({getValue:q})=>{const U=q();return!U||U.length===0?t.jsx("span",{className:"text-muted-foreground",children:"-"}):t.jsx("div",{className:"flex flex-wrap gap-1",children:U.map((B,J)=>{const re=st(n,[{entity_type:B.entity_type,slug:B.slug}]);return t.jsxs("span",{children:[t.jsx(ve,{to:re,className:"text-primary hover:underline",onClick:fe=>fe.stopPropagation(),children:B.name}),J<U.length-1&&","]},B.id)})})}}))},[n,s]),G=b.useMemo(()=>l||e.some(I=>I.parent_name&&I.parent_slug&&I.parent_entity_type)?[{id:"parent",accessorFn:I=>I.parent_name,header:"Parent",cell:({row:I})=>{if(!I.original.parent_name||!I.original.parent_slug||!I.original.parent_entity_type)return t.jsx("span",{className:"text-muted-foreground",children:"-"});const q=st(n,[{entity_type:I.original.parent_entity_type,slug:I.original.parent_slug}]);return t.jsx(ve,{to:q,className:"text-primary hover:underline",children:I.original.parent_name})}}]:[],[e,l,n]),ne=b.useMemo(()=>{const $=[],I=e.some(B=>(B.total_content??0)>0),q=e.some(B=>(B.active_connections??0)>0),U=e.some(B=>(B.automations_count??0)>0);return I&&$.push({accessorKey:"total_content",header:({column:B})=>t.jsx(et,{column:B,alignRight:!0,children:"Activity"}),cell:({row:B,getValue:J})=>{const re=J()??0;if(re===0)return t.jsx("span",{className:"tabular-nums",children:"0"});const fe=$t(B.original);return t.jsx(ve,{to:as(n,fe),className:"tabular-nums hover:underline",children:re})},meta:{align:"right"}}),q&&$.push({accessorKey:"active_connections",header:"Connectors",cell:({getValue:B})=>{const J=B();return J&&J>0?t.jsxs(pt,{variant:"outline",className:"text-green-600 dark:text-green-400",children:[J," active"]}):t.jsx("span",{className:"text-muted-foreground",children:"-"})},meta:{align:"right"}}),U&&$.push({accessorKey:"automations_count",header:({column:B})=>t.jsx(et,{column:B,alignRight:!0,children:"Automations"}),cell:({getValue:B})=>t.jsx("span",{className:"tabular-nums",children:B()??0}),meta:{align:"right"}}),$},[e,n]),V=b.useMemo(()=>[{accessorKey:"name",header:({column:$})=>x?t.jsx(et,{column:$,children:"Name"}):"Name",cell:({row:$})=>{const I=Se($.original.metadata);return t.jsxs("div",{className:"flex items-center gap-2",children:[t.jsx(cn,{metadata:I,metadataSchema:s,name:$.original.name,typeIcon:a,className:"h-6 w-6 shrink-0"}),t.jsx("div",{className:"min-w-0",children:(()=>{const q=oi(n,$.original);return t.jsx(ve,{to:q,className:"block max-w-56 truncate font-medium hover:underline",title:$.original.name,children:$.original.name})})()})]})}},...G,...O,...P,...Q,...ne,...r?[]:[{accessorKey:"created_at",header:({column:$})=>t.jsx(et,{column:$,children:"Created"}),cell:({getValue:$})=>t.jsx("span",{className:"whitespace-nowrap text-muted-foreground",children:new Date($()).toLocaleDateString("en-US",{month:"short",day:"numeric",year:"numeric"})})}]],[n,G,O,P,Q,ne,s,a,r,x]),ge=ua({data:e,columns:V,state:{sorting:y,columnVisibility:Object.fromEntries([...O,...P].flatMap($=>$.id?[[$.id,!g||g.includes(r?$.id:$.id.replace(/^meta_/,""))]]:[]))},onSortingChange:c,getCoreRowModel:ma(),manualSorting:!0,enableSortingRemoval:!1}),se=e.length>0||m>0;return t.jsxs("div",{className:"space-y-4",children:[t.jsx("div",{className:"rounded-lg border",children:t.jsxs(xa,{className:"min-w-[48rem]",children:[t.jsx(ba,{children:ge.getHeaderGroups().map($=>t.jsxs(Vt,{children:[$.headers.map(I=>t.jsx(En,{"aria-sort":I.column.getIsSorted()==="asc"?"ascending":I.column.getIsSorted()==="desc"?"descending":void 0,className:I.column.columnDef.meta?.align==="right"?"text-right":"",children:I.isPlaceholder?null:Sn(I.column.columnDef.header,I.getContext())},I.id)),k?t.jsx(En,{className:"w-10 pr-2 text-right",children:k}):null]},$.id))}),t.jsx(va,{children:ge.getRowModel().rows.length?ge.getRowModel().rows.map($=>t.jsxs(Vt,{children:[$.getVisibleCells().map(I=>t.jsx(Ut,{className:I.column.columnDef.meta?.align==="right"?"whitespace-nowrap text-right":"",children:Sn(I.column.columnDef.cell,I.getContext())},I.id)),k?t.jsx(Ut,{}):null]},$.id)):t.jsx(Vt,{children:t.jsx(Ut,{colSpan:V.length+(k?1:0),className:"h-24 text-center",children:"No results found."})})})]})}),se&&t.jsxs("div",{className:"mt-4 flex flex-col gap-2 text-sm text-muted-foreground sm:flex-row sm:items-center sm:justify-between",children:[t.jsxs("div",{children:["Showing ",e.length," of ",j," ",S.toLowerCase()]}),t.jsxs("div",{className:"flex items-center gap-2",children:[t.jsxs("span",{children:["Page ",m+1," of ",Math.max(1,Math.ceil(j/v))]}),t.jsx(Y,{variant:"outline",size:"sm",onClick:N,disabled:m===0,children:"Previous"}),t.jsx(Y,{variant:"outline",size:"sm",onClick:E,disabled:!d,children:"Next"})]})]})]})}function mi(e){return String(e??"").replace(/[_-]+/g," ").replace(/\b\w/g,n=>n.toUpperCase())}function js(e){return e["x-lobu"]?.role||e["x-lobu-role"]}function mn(e){const n=e?.properties;if(!n)return null;const r=cs(n).find(([,c])=>js(c)==="workflowState");if(!r)return null;const[i,o]=r,l=o["x-lobu"]?.states,y=Array.isArray(l)&&l.length>0?l:(o.enum??[]).map(c=>({value:c}));return y.length===0||y.some(c=>typeof c.value!="string")?null:{field:i,states:y.map(c=>({...c,label:c.label||br(o,c.value)||mi(c.value),terminal:c.terminal??["done","complete","completed","closed","archived"].includes(c.value.toLowerCase())}))}}function fi(e){const n=e?.properties;if(!n)return null;const s=Object.entries(n),a=s.find(([,o])=>js(o)==="sortRank"),r=s.find(([o])=>["rank","sort_rank","order"].includes(o)),i=a??r;return i?{field:i[0]}:null}function pi(e,{isDerived:n}){const s=e?.["x-lobu"]?.defaultView;return(s==="table"||s==="board")&&!(n&&s!=="table")?s:n?"table":mn(e)?"board":"table"}const Ns={version:1,root:{type:"entity-table",props:{state:"{{tableState}}"}}},hi={version:1,root:{type:"entity-board",props:{state:"{{boardState}}",onUpdate:"@updateEntity"}}};function gi(e){const{canShowBoard:n,builtinData:s,builtInLabels:a}=e,r=["table",...n?["board"]:[]],i={table:Ns,board:hi};return r.map(o=>({id:o,label:a[o],builtInMode:o,template:i[o],data:s}))}function Zt(e){return e.replace(/[_-]+/g," ").replace(/\b\w/g,n=>n.toUpperCase())}function Lt(e,n){if(!n)return e.created_at??String(e.id);const s=Se(e.metadata);return String(s[n.field]??e.created_at??e.id)}function yi(e,n){const s=e?Number(e):Number.NaN,a=n?Number(n):Number.NaN;return Number.isFinite(s)&&Number.isFinite(a)&&s<a?String((s+a)/2):Number.isFinite(s)?String(s+1):Number.isFinite(a)?String(a-1):String(Date.now())}function en(e,n){const s=Se(e.metadata);return String(s[n]??"")}function Ss(e,n){return[...e].sort((s,a)=>Lt(s,n).localeCompare(Lt(a,n)))}function xi(e,n,s,a,r){if(!n.startsWith("card:")||!s)return null;const i=Number(n.slice(5)),o=e.find(N=>N.id===i);if(!o)return null;const l=s.startsWith("column:")?s.slice(7):en(e.find(N=>`card:${N.id}`===s)??o,a.field);if(!l)return null;const y=Ss(e.filter(N=>N.id!==i&&en(N,a.field)===l),r),c=s.startsWith("card:")?y.findIndex(N=>`card:${N.id}`===s):y.length,g=c>=0?c:y.length,p=g>0?y[g-1]:void 0,f=y[g],m=r?yi(p?Lt(p,r):void 0,f?Lt(f,r):void 0):void 0,v=Se(o.metadata),j={[a.field]:l,...r&&m?{[r.field]:m}:{}};a.states.find(N=>N.value===l)?.terminal&&!v.completed_at&&(j.completed_at=new Date().toISOString());const S={...v,...j};return{entityId:i,changedMetadata:j,nextMetadata:S}}function Vn(e,n,s){return e.map(a=>a.id===n?{...a,metadata:s}:a)}function bi({id:e,children:n,className:s}){const{setNodeRef:a,isOver:r}=ps({id:`column:${e}`});return t.jsx("div",{ref:a,className:me("min-h-[220px] rounded-lg bg-card p-2 transition-colors",r?"bg-accent/50":"",s),children:n})}function vi({entity:e,owner:n,statusField:s,entityTypeIcon:a,schema:r,didDragRef:i}){const o=Se(e.metadata),{attributes:l,listeners:y,setNodeRef:c,transform:g,isDragging:p}=Sa({id:`card:${e.id}`}),{setNodeRef:f,isOver:m}=ps({id:`card:${e.id}`}),v=st(n,$t(e)),j=d=>{i.current&&(d.preventDefault(),d.stopPropagation())};return t.jsx("div",{ref:d=>{c(d),f(d)},style:{transform:Ea.Translate.toString(g)},className:me(kr,"p-3 text-sm text-muted-foreground transition-colors hover:bg-accent/50 hover:text-foreground",p?"opacity-60":"",m?"ring-1 ring-ring":""),children:t.jsxs("div",{className:"flex items-start gap-2",children:[t.jsx("button",{type:"button",className:"mt-0.5 shrink-0 cursor-grab touch-none text-muted-foreground/60 hover:text-foreground active:cursor-grabbing","aria-label":`Drag ${e.name}`,...l,...y,children:t.jsx(wr,{className:"h-4 w-4"})}),t.jsx(cn,{metadata:o,metadataSchema:r,name:e.name,typeIcon:a,className:"mt-0.5 h-6 w-6 shrink-0",initialsFallback:!0}),t.jsxs("div",{className:"min-w-0 flex-1",children:[t.jsx(ve,{to:v,className:"font-medium text-foreground hover:underline",onClick:j,children:e.name}),t.jsxs("div",{className:"mt-1 flex flex-wrap gap-1.5",children:[typeof o.priority=="string"&&o.priority?t.jsx(pt,{variant:"outline",className:"text-xs",children:Zt(o.priority)}):null,typeof o[s]=="string"&&o[s]?t.jsx(pt,{variant:"secondary",className:"text-xs",children:Zt(String(o[s]))}):null]})]})]})})}function wi({owner:e,entities:n,totalCount:s,schema:a,entityTypeIcon:r,onUpdate:i}){const o=b.useMemo(()=>mn(a),[a]),l=b.useMemo(()=>fi(a),[a]),[y,c]=b.useState(n),[g,p]=b.useState(()=>new Set),f=b.useRef(!1),m=wa(ka(Na,{activationConstraint:{distance:6}})),v=b.useCallback(()=>{window.setTimeout(()=>{f.current=!1},0)},[]);b.useEffect(()=>{c(n)},[n]);const j=b.useMemo(()=>{if(!o)return new Map;const E=new Map(o.states.map(k=>[k.value,[]]));for(const k of y){const h=en(k,o.field),x=E.has(h)?h:o.states[0]?.value;x&&E.get(x)?.push(k)}for(const[k,h]of E)E.set(k,Ss(h,l));return E},[y,l,o]);if(!o)return null;const d=E=>{p(k=>{const h=new Set(k);return h.has(E)?h.delete(E):h.add(E),h})},S=()=>{f.current=!0},N=E=>{const k=String(E.active.id),h=E.over?String(E.over.id):null,x=xi(y,k,h,o,l);if(!x){v();return}const{entityId:M,changedMetadata:O,nextMetadata:z}=x,Q=y.find(G=>G.id===M)?.metadata;c(G=>Vn(G,M,z)),i(M,O).catch(()=>{c(G=>Vn(G,M,Q))}),v()};return t.jsxs("div",{className:"space-y-4",children:[t.jsxs("div",{children:[t.jsx("h2",{className:"text-base font-semibold",children:"Board"}),t.jsxs("p",{className:"text-sm text-muted-foreground",children:["Grouped by ",Zt(o.field),typeof s=="number"&&s>y.length?t.jsxs(t.Fragment,{children:[" · ",t.jsxs("span",{className:"text-amber-600 dark:text-amber-500",children:["showing first ",y.length," of ",s," — narrow with search"]})]}):null]})]}),t.jsx(ja,{sensors:m,onDragStart:S,onDragEnd:N,children:t.jsx("div",{className:"grid gap-3 md:grid-cols-2 xl:grid-cols-4",children:o.states.map(E=>{const k=j.get(E.value)??[],h=E.collapsed??E.terminal,x=h&&!g.has(E.value);return t.jsxs(bi,{id:E.value,children:[t.jsxs("div",{className:"mb-2 flex items-center justify-between gap-2 px-1",children:[t.jsxs("div",{className:"flex items-center gap-1.5",children:[E.terminal?t.jsx(vr,{className:"h-4 w-4 text-muted-foreground"}):null,t.jsx("h3",{className:"text-sm font-medium",children:E.label})]}),t.jsxs("div",{className:"flex items-center gap-1.5",children:[t.jsx(pt,{variant:"secondary",className:"text-xs",children:k.length}),h?t.jsx(Y,{type:"button",variant:"ghost",size:"sm",className:"h-6 px-1.5 text-xs",onClick:()=>d(E.value),children:x?"Show":"Hide"}):null]})]}),x?t.jsxs("p",{className:"py-4 text-center text-xs text-muted-foreground/60",children:[k.length," hidden ",E.label?.toLowerCase()," item",k.length===1?"":"s"]}):t.jsx("div",{className:"space-y-2",children:k.length>0?k.map(M=>t.jsx(vi,{entity:M,owner:e,statusField:o.field,entityTypeIcon:r,schema:a,didDragRef:f},M.id)):t.jsxs("p",{className:"py-4 text-center text-xs text-muted-foreground/60",children:["No ",E.label?.toLowerCase()," items"]})})]},E.value)})})})]})}const ki=b.memo(wi);function ji(e){let n=0;for(let s=0;s<e.length;s++)n=(n<<5)-n+e.charCodeAt(s),n|=0;return n.toString(36)}function Es(e,n){return{queryKey:["metric_series",e,ji(n)],queryFn:()=>Nt("metric_series",{sql:n},{slug:e}),staleTime:6e4}}function Cs(e,n){const s=!!e&&!!n,a=Es(e??"",n??"");return ss({...a,enabled:s})}Cs.queryOptions=(e,n)=>Es(e,n);function Ni(e,n){if(!e?.columns?.length||!e.rows)return[];const s=e.columns.indexOf(n);return s<0?[]:e.rows.map(a=>Number(a[s])||0)}const Un=/^[a-z][a-z0-9_]*$/;function Si(e){const n=Object.entries(e);for(const[r,i]of n){if(!Un.test(r))throw new Error(`lifecycleCumulativeStatsSql: unsafe column name '${r}'`);if(!Un.test(i))throw new Error(`lifecycleCumulativeStatsSql: unsafe entity_type '${i}'`)}const s=n.flatMap(([r,i])=>[`COUNT(*) FILTER (
3
+ WHERE semantic_type = 'change'
4
+ AND metadata->>'category' = 'lifecycle'
5
+ AND metadata->>'entity_type' = '${i}'
6
+ AND metadata->>'op' = 'created'
7
+ ) AS ${r}_added`,`COUNT(*) FILTER (
8
+ WHERE semantic_type = 'change'
9
+ AND metadata->>'category' = 'lifecycle'
10
+ AND metadata->>'entity_type' = '${i}'
11
+ AND metadata->>'op' = 'deleted'
12
+ ) AS ${r}_removed`]).join(`,
13
+ `),a=n.map(([r])=>` SUM(COALESCE(b.${r}_added, 0) - COALESCE(b.${r}_removed, 0))
14
+ OVER (ORDER BY d.bucket) AS ${r}`).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
+ ${s}
27
+ FROM events
28
+ WHERE created_at > now() - interval '14 days'
29
+ GROUP BY 1
30
+ )
31
+ SELECT d.bucket,
32
+ ${a}
33
+ FROM days d
34
+ LEFT JOIN buckets b ON b.bucket = d.bucket
35
+ ORDER BY d.bucket
36
+ `}const Ei={"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 Ci(e){if(typeof e.sql=="string"&&e.sql.trim())return e.sql;if(e.lifecycle&&typeof e.lifecycle=="object"){const n=Object.fromEntries(Object.entries(e.lifecycle).map(([s,a])=>[s,String(a)]));if(Object.keys(n).length>0)try{return Si(n)}catch{return null}}return typeof e.preset=="string"?Ei[e.preset]??null:null}function _i({owner:e,sql:n,lifecycle:s,preset:a,column:r,chart:i,height:o,width:l,color:y,label:c,className:g}){const p=b.useMemo(()=>Ci({sql:n,lifecycle:s,preset:a}),[n,s,a]),f=typeof e=="string"&&e?e:null,{data:m}=Cs(f,p),v=String(r??""),j=b.useMemo(()=>Ni(m,v),[m,v]),d=b.useMemo(()=>!m?.columns?.length||!m.rows?[]:m.rows.map((N,E)=>({label:String(N[0]??"").slice(0,10),value:j[E]??0})),[m,j]);if(!f||!p||!v)return null;const S=i==="line"?t.jsx(fa,{data:d,height:typeof o=="number"?o:void 0}):t.jsx(pa,{data:j,height:typeof o=="number"?o:void 0,width:typeof l=="number"?l:void 0,color:typeof y=="string"?y:void 0});return c==null?t.jsx("div",{className:g,children:S}):t.jsxs("div",{className:g,children:[t.jsx("p",{className:"text-sm text-muted-foreground",children:String(c)}),S]})}function Mi({metadata:e,metadataSchema:n,name:s,typeIcon:a,initialsFallback:r,className:i}){return t.jsx(cn,{metadata:e,metadataSchema:n,name:String(s??""),typeIcon:a,initialsFallback:!!r,className:i})}function Ti({entity:e,owner:n,className:s,onClick:a,children:r}){const i=e;if(!i)return t.jsx(t.Fragment,{children:r});const o=st(String(n??""),$t(i));return t.jsx(ve,{to:o,className:s,onClick:a,children:r})}function Li({state:e}){return e?t.jsx(ui,{...e}):null}function Ri({state:e,onUpdate:n}){return e?t.jsx(ki,{...e,onUpdate:n}):null}const Ii={"entity-avatar":Mi,"entity-link":Ti,"entity-table":Li,"entity-board":Ri,"metric-series":_i};function $i({ownerSlug:e,typeSlug:n,title:s,shape:a}){const[r,i]=b.useState(!1),o=ot(),{visible:l,system:y,isTypesLoading:c}=jr(e),g=f=>{i(!1);const m=`/${e}/${ds(f)}`;o({to:a?`${m}/${us}/${a}`:m})},p=f=>t.jsxs(Tr,{value:`${f.name} ${f.slug}`,onSelect:()=>g(f.slug),children:[t.jsx(Rt,{icon:f.icon,className:"mr-2 h-4 w-4 shrink-0"}),t.jsx("span",{className:"flex-1 truncate",children:f.name||f.slug}),f.slug===n?t.jsx(Lr,{className:"ml-2 h-3.5 w-3.5 shrink-0","aria-label":"Current"}):null,f.entity_count!=null?t.jsx("span",{className:"ml-2 shrink-0 text-xs tabular-nums text-muted-foreground",children:f.entity_count.toLocaleString()}):null]},f.slug);return t.jsxs(rn,{open:r,onOpenChange:i,children:[t.jsx("h1",{className:"text-2xl font-semibold tracking-tight",children:t.jsx(an,{asChild:!0,children:t.jsxs(Y,{type:"button",variant:"ghost",className:"-ml-2 h-auto gap-1.5 px-2 py-1 text-2xl font-semibold tracking-tight",children:[s,t.jsx(ls,{className:"h-5 w-5 text-muted-foreground"})]})})}),t.jsx(on,{align:"start",className:"w-72 p-0",children:t.jsxs(Nr,{children:[t.jsx(Sr,{autoFocus:!0,placeholder:"Find a type…"}),t.jsxs(Er,{children:[t.jsx(Cr,{children:c?"Loading types…":"No type matches."}),l.length>0?t.jsx(wn,{heading:"Types",children:l.map(p)}):null,y.length>0?t.jsx(wn,{heading:"System",children:y.map(p)}):null]}),t.jsx(_r,{}),t.jsxs(ve,{to:"/$owner/data",params:{owner:e},onClick:()=>i(!1),className:"flex items-center gap-2 px-3 py-2 text-sm text-muted-foreground hover:text-foreground",children:[t.jsx(Mr,{className:"h-4 w-4"}),"Schema map"]})]})})]})}function Oi(e){return Object.entries(e?.metrics_config?.segments??{}).filter(([,n])=>n.on==="entity").map(([n,s])=>({name:n,description:s.description}))}const vt={table:{label:"Table",icon:Pr},board:{label:"Board",icon:rs},graph:{label:"Graph",icon:is}},_s=(e,n)=>`lobu.record-shape:v1:${e}/${n}`,Ai=new Set(["table","board","graph"]);function Pi(e,n){const s=Yn(_s(e,n));return s&&Ai.has(s)?s:void 0}function Di(e,n,s){Jn(_s(e,n),s)}const qn=":records";function Fi({ownerSlug:e,entityTypeSlug:n,create:s,onCreateChange:a,viewKey:r,shape:i}){const{orgContext:o,hasOrgContext:l}=We(),y=es(n,o),{data:c,isLoading:g,error:p}=y;Rr(`/${e}`,o);const f=Ir(),[m,v]=b.useState({key:"",page:0}),j=ms({strict:!1}),d=ot(),S=nn(),N=`/${e}/${ds(n)}`,E=!g&&c?.slug===n,{collection:k,error:h,presentation:x,preset:M,edited:O,table:z}=b.useMemo(()=>Ro(j,c?.metadata_schema,!!r),[j,c?.metadata_schema,r]),P=E?h:void 0,Q=b.useMemo(()=>Po(j,k),[j,k]),[G,ne]=b.useState(!1),[V,ge]=b.useState(0),se=k.search??"",$=k.segment,I=JSON.stringify(k),q=$?Oi(c).find(R=>R.name===$)??{name:$,description:""}:null,U=R=>void d({to:".",search:{...qe(R),...Q},replace:!0}),B=$r(y.data),J=B?z.sort:Fo(z),re=J?.field,fe=J?.order,le=b.useMemo(()=>re?[{id:re,desc:fe==="desc"}]:[],[re,fe]),Ee=b.useCallback(R=>void d({to:".",search:{...r?qe(j):{},...Q,$table:JSON.stringify(R)},replace:!0}),[d,r,j,Q]),Be=b.useCallback(R=>{const ee=typeof R=="function"?R(le):R;ee[0]&&Ee({...z,sort:{field:ee[0].id,order:ee[0].desc?"desc":"asc"}})},[le,Ee,z]),Ie=s===!0,$e=()=>a(!0),Ce=()=>a(!1),He=le[0]?.id,ye=le[0]?le[0].desc?"desc":"asc":void 0,_e=y.data?.metadata_schema,ke=!!mn(_e)&&!B,Me=pi(_e,{isDerived:B}),pe=fs(o),Oe=Ht(pe.data??[],n,k),Te=(R,ee=!1,we=qe(j))=>{const xe=!r||!pe.data||Ht(pe.data,n,R).some(ht=>ht.key===r);d({to:xe?".":N,search:{...xe&&r?we:{},...Io(R,M?.key),$table:JSON.stringify(z)},replace:ee})},je=R=>{const ee=R?jt(R):{},we=!r||Ht(pe.data??[],n,ee).some(xe=>xe.key===r);ne(!1),ge(xe=>xe+1),d({to:we?".":N,search:R?{$preset:R.key}:{}})},{isAdmin:Ke}=Qn(o.organizationId),Ae=Or(o),C=Ke&&!!c&&!y.isPlaceholderData,u=b.useRef(j);u.current=j;const T=async()=>{if(!M)return;const R=JSON.stringify(j),{data:ee}=await y.refetch(),we=ee?.metadata_schema,xe=we?sn(we[Yt]??{}):void 0,ht=xe?.presets?.find(gt=>gt.key===M.key);if(!ee||!we||!xe||!ht){ts.error("This saved filter changed. Reload and try again.");return}const Dt=$o(ht,k,z,xe);await Ae.mutateAsync({slug:ee.slug,metadata_schema:{...we,[Yt]:{...xe,presets:xe.presets?.map(gt=>gt.key===Dt.key?Dt:gt)}}}).then(()=>!0,()=>!1)&&(await y.refetch(),JSON.stringify(u.current)===R&&je(Dt))},w=b.useMemo(()=>Pi(e,n),[e,n]),_=Ar(pe.data??[],n,{viewKey:r,shape:i??(r?void 0:w)},Me,k),L=_.kind==="builtin"?_.mode==="board"&&!ke?"table":_.mode:null,H=L==="graph";b.useEffect(()=>{i&&E&&L&&Di(e,n,L)},[i,E,L,e,n]);const F=["table",...ke?["board"]:[],"graph"],D=_.kind==="view"?_.view:null,W=_.kind==="missing"?_.key:null,de=_.kind==="inapplicable"?_:null,ce=L==="table"?50:200,Ne=`${n}?${I}&sort=${JSON.stringify(z.sort)}&size=${ce}`,Pe=m.key===Ne?m.page:0,Ye=b.useCallback(R=>v(ee=>({key:Ne,page:R(ee.key===Ne?ee.page:0)})),[Ne]),De=kn(n,o,{limit:ce,offset:Pe*ce,search:se.trim()||void 0,sortBy:He,sortOrder:ye,segment:$,filters:k.filters,enabled:E&&!r&&!P}),Je=kn(n,o,{limit:1,offset:0,parentId:null,search:se.trim()||void 0,segment:$,filters:k.filters,enabled:E&&!r&&!P&&!B}),{data:Qe,error:Ot}=De,A=De.isLoading||De.isPending&&De.fetchStatus==="paused",Z=P||p||(r?null:Ot),te=!!r&&pe.data===void 0&&pe.isError,K=Qe?.entities??[],ae=Qe?.metadata?.has_more??!1,X=Qe?.metadata?.total_count??0,Fe=K.length>0||se.trim().length>0||Pe>0||!!$||!!k.filters?.length,ie=c?.name?.trim()||Ge(n),he=c?.icon||void 0,oe=B,ue=_e,Le=!P&&(!l||!E||(r?pe.data===void 0&&!pe.isError:A||!B&&Je.isLoading)),Ve=Qe?.linked_entities??{},it=Je.data?.metadata?.total_count,Xe=X>0&&typeof it=="number"?it<X:!1,ct=b.useMemo(()=>c?.measure_columns??[],[c?.measure_columns]),Ze=b.useCallback(R=>Ee({...z,columns:R}),[Ee,z]),lt=b.useMemo(()=>({entities:K,owner:e,schema:ue,entityTypeIcon:he,isDerived:oe,measureColumns:ct,linkedEntityLookups:Ve,hasAnyParents:Xe,sorting:le,onSortingChange:Be,visibleColumns:z.columns,columnChoices:Xt(ue,oe,K),onVisibleColumnsChange:Ze,page:Pe,pageSize:ce,totalCount:X,hasMore:ae,pageTitle:ie,onPrevPage:()=>Ye(R=>Math.max(0,R-1)),onNextPage:()=>Ye(R=>R+1)}),[K,e,ue,he,oe,ct,Ve,Xe,le,z.columns,Ze,Be,Ye,Pe,ce,X,ae,ie]),fn=X>K.length,pn=`showing first ${K.length} of ${X} — narrow with search`,hn=b.useMemo(()=>({owner:e,entityType:c,entities:K,totalCount:X,schema:ue,entityTypeIcon:he}),[e,c,K,X,ue,he]),At=b.useMemo(()=>({tableState:lt,boardState:hn,owner:e,schema:ue,entityType:c,entityTypeIcon:he,totalCount:X,isTruncated:fn,truncationNotice:pn,canCreate:!oe,addLabel:`Add ${c?.name||Ge(n)}`}),[lt,hn,e,ue,c,he,X,fn,pn,oe,n]),Ms=b.useMemo(()=>gi({canShowBoard:ke,builtinData:At,builtInLabels:{table:vt.table.label,board:vt.board.label}}),[ke,At]),gn=L?Ms.find(R=>R.id===L)??null:null,Ts=gn?.template??Ns,Ls=gn?.data??At,yn=R=>void d({to:R===qn?N:`${N}${Wr(R)}`,search:Q}),Pt=qe(j),Rs=Ca(D?.params,Pt,R=>void d({to:".",search:{...qe(R),...Q}})),Is=()=>Te({...k,filters:[],segment:void 0},!1,_a(D?.params,Pt)),xn=`Moved on ${c?.name||c?.slug||n} board`,bn=b.useMemo(()=>(R,ee)=>f.mutateAsync({entityId:R,metadata:ee,field_note:xn}),[f,xn]),$s=b.useMemo(()=>({updateEntity:bn,openCreate:()=>a(!0)}),[bn,a]),vn=R=>S?t.jsx(Y,{type:"button",variant:"ghost",size:"icon",className:me("size-8 text-muted-foreground hover:text-foreground",R),"aria-label":"Edit type",title:"Edit type",onClick:()=>S.open({href:zr(e,n),title:ie}),children:t.jsx(Fr,{className:"h-4 w-4"})}):null;return t.jsxs("div",{className:"@container space-y-4",children:[t.jsxs("div",{className:"flex flex-wrap items-center gap-2",children:[t.jsx($i,{ownerSlug:e,typeSlug:n,title:ie,shape:r?null:L}),vn(Ie||!E?"":"hidden @lg:inline-flex")]}),t.jsxs("div",{children:[Ie?t.jsx("div",{className:"max-w-3xl",children:t.jsx(Mo,{onClose:Ce,entityTypeSlug:n,orgContext:o})}):null,!Ie&&E&&t.jsxs("nav",{className:"mb-4 flex flex-wrap items-center gap-x-3 gap-y-2","aria-label":`${ie} views`,children:[vn("-mr-1 @lg:hidden"),!r&&F.length>1&&t.jsx("fieldset",{className:"flex items-center rounded-md border p-0.5","aria-label":"Record layout",children:F.map(R=>{const ee=vt[R].icon,we=L===R;return t.jsx(Y,{type:"button",variant:"ghost",size:"sm","aria-pressed":we,title:vt[R].label,"data-testid":`shape-${R}`,className:me("h-7 px-2",we&&"bg-accent text-accent-foreground"),onClick:()=>void d({to:`${N}/${us}/${R}`,search:Q,replace:!0}),children:t.jsx(ee,{className:"h-4 w-4"})},R)})}),r&&t.jsx(Y,{variant:"ghost",onClick:()=>yn(qn),children:"Records"}),!!x.presets?.length&&t.jsxs(rn,{open:G,onOpenChange:ne,children:[t.jsx(an,{asChild:!0,children:t.jsxs(Y,{variant:"outline",className:me("gap-2",O&&"border-dashed border-primary"),"data-edited":O||void 0,title:"Choose saved filter",children:[M?.label??(k.filters?.length||k.search?"Custom filter":"All records"),O?t.jsx("span",{className:"text-xs font-normal text-primary",children:"Edited"}):null,t.jsx(ls,{className:"h-4 w-4 text-muted-foreground"})]})}),t.jsxs(on,{align:"start",className:"w-60 p-1",children:[t.jsx(Y,{variant:M?"ghost":"secondary",className:"w-full justify-start",onClick:()=>je(),children:"All records"}),x.presets.map(R=>t.jsx(Y,{variant:M?.key===R.key?"secondary":"ghost",className:"w-full justify-start",onClick:()=>je(R),children:R.label},R.key))]})]}),M&&O?t.jsxs("div",{className:"-ml-2 mr-2 inline-flex items-center gap-1",children:[t.jsx(Y,{variant:"ghost",size:"sm",onClick:()=>je(M),children:"Reset"}),C?t.jsx(Y,{size:"sm",disabled:Ae.isPending,onClick:()=>void T(),children:Ae.isPending?"Saving…":"Save"}):null]}):null,!P&&t.jsx(qo,{collection:k,schema:ue,label:ie,org:o??"",facetQuery:x.facetQuery,onChange:Te,viewFilters:Rs,onClearAll:Is,segmentChip:q?{id:"segment",label:"Segment",op:"is",value:Ge(q.name),title:q.description||void 0,editor:q.description?{kind:"custom",render:()=>t.jsx("p",{className:"p-3 text-sm text-muted-foreground",children:q.description})}:void 0,onRemove:()=>Te({...k,segment:void 0})}:void 0},`filters:${n}:${V}`),Oe.map(R=>t.jsx(Y,{"data-testid":`tab-${R.key}`,variant:r===R.key?"secondary":"ghost","aria-pressed":r===R.key,onClick:()=>yn(R.key),children:R.name},R.key)),t.jsx(Bo,{label:ie,search:k.search,onSearch:(R,ee)=>Te({...k,search:R},ee),className:"ml-auto min-w-40 max-w-64 flex-1"},`search:${n}:${V}`),!oe&&!r?t.jsxs(Y,{size:"sm","aria-label":`Add ${ie||"entity"}`,onClick:()=>$e(),children:[t.jsx(mt,{className:"mr-2 h-4 w-4"}),"Add"]}):null]}),Ie?null:Le?H?t.jsx(ln,{label:`Loading ${ie} graph`}):t.jsx(zi,{}):Z?t.jsxs("div",{role:"alert",className:"rounded-lg border border-destructive/30 bg-destructive/5 px-4 py-6 text-sm text-destructive",children:[Z.message||`Failed to load ${ie.toLowerCase()}.`,P&&t.jsx(Y,{variant:"outline",size:"sm",className:"ml-3",onClick:()=>Te({}),children:"Clear filters"})]}):te?t.jsx(hs,{onRetry:()=>void pe.refetch()}):de?t.jsxs("div",{className:"flex flex-col items-center justify-center py-16 text-center","data-testid":"inapplicable-view",children:[t.jsxs("h2",{className:"text-lg font-semibold",children:["“",de.view.name,"” doesn’t apply to the current filters"]}),t.jsxs("p",{className:"text-muted-foreground mt-2 text-sm",children:["It appears when the selection includes"," ",Object.entries(de.when).map(([R,ee])=>`${R} is ${ee===null?"not supplied":String(ee)}`).join(" and "),"."]}),t.jsx(ve,{to:N,search:Q,className:"mt-4 text-sm font-medium underline underline-offset-4",children:`Back to ${ie}`})]}):W?t.jsx(gs,{viewKey:W,backTo:N,backLabel:`Back to ${ie}`}):D?t.jsx(ys,{orgSlug:e,viewKey:D.key,scope:{type:n,collection:k},params:Pt,onParamsChange:U,contentHash:D.content_hash,title:D.name,minHeight:320}):H&&Fe?t.jsx(si,{ownerSlug:e,typeSlug:n,sourceBacked:B,records:K.map(R=>({...R,id:R.id??JSON.stringify([R.entity_type,R.slug])})),hasMore:ae}):Fe?t.jsx(ha,{template:Ts,data:Ls,actions:$s,components:Ii}):t.jsx(os,{icon:Dr,iconElement:t.jsx(Rt,{icon:c?.icon,className:"mb-4 h-12 w-12 opacity-50"}),title:`No ${ie.toLowerCase()} yet`,description:oe?"This view has no rows yet. They appear as the underlying data arrives.":`Get started by creating your first ${c?.name?.toLowerCase()||"entity"}.`,actionLabel:oe?void 0:`Add ${c?.name||"Entity"}`,onAction:oe?void 0:()=>$e()})]})]})}function zi(){return t.jsxs("div",{className:"space-y-4","aria-label":"Loading entities",role:"status",children:[t.jsxs("div",{className:"flex items-center justify-between gap-3",children:[t.jsx(be,{className:"h-9 max-w-sm flex-1"}),t.jsx(be,{className:"h-9 w-28"})]}),t.jsxs("div",{className:"overflow-hidden rounded-lg border",children:[t.jsx("div",{className:"border-b px-4 py-3",children:t.jsx(be,{className:"h-3 w-1/3"})}),t.jsx("div",{className:"divide-y",children:Array.from({length:5}).map((e,n)=>t.jsxs("div",{className:"flex items-center gap-3 px-4 py-3",children:[t.jsx(be,{className:"h-3 flex-1"}),t.jsx(be,{className:"h-3 w-16 shrink-0"})]},n))})]})]})}function Wi({ownerSlug:e,typeScope:n,create:s,createType:a=!1,viewKey:r,shape:i}){const o=ot(),{orgContext:l}=We(),y=ms({strict:!1}),c=n?Br(n):void 0,g=c==="$member",p=()=>{o({to:"/$owner/data",params:{owner:e},search:{}})},f=v=>{if(!c)return;const j=Xn(e,c);o({to:j.to,params:j.params,search:v?{create:!0}:{},replace:!0})},m=a?t.jsx("div",{className:"mx-auto w-full max-w-3xl",children:t.jsx(Ta,{entityType:null,orgContext:l,onClose:p})}):c?t.jsx(Fi,{ownerSlug:e,entityTypeSlug:c,create:s,onCreateChange:f,viewKey:r,shape:i}):t.jsx(Bi,{ownerSlug:e,viewKey:r,search:y});return t.jsx("div",{className:"flex min-h-0 min-w-0 flex-1 flex-col gap-4",children:g?t.jsx(Ra,{children:m}):m})}function Bi({ownerSlug:e,viewKey:n,search:s}){const a=ot(),{orgContext:r}=We(),{data:i,isError:o,error:l,refetch:y}=fs(r),c=Hr(i??[],n),g=Vr(),p=Ur(i??[]),f=o?qr(l,{subject:"Views"}):null;return n&&i===void 0?o?t.jsx(hs,{error:l,onRetry:()=>void y()}):null:c.kind==="missing"?t.jsx(gs,{viewKey:c.key,backTo:`/${e}/data`,backLabel:"Back to Memory"}):t.jsxs("div",{className:"flex min-h-0 min-w-0 flex-1 flex-col gap-4",children:[g&&p.length>0?t.jsxs("nav",{"aria-label":"Workspace views",className:"flex shrink-0 flex-wrap gap-1",children:[t.jsx(ve,{to:"/$owner/data",params:{owner:e},search:{},activeOptions:{exact:!0},"aria-current":n?void 0:"page",className:Gn(!n),children:"Overview"}),p.map(m=>t.jsx(ve,{to:"/$owner/data/-/views/$viewKey",params:{owner:e,viewKey:m.key},search:{},activeOptions:{exact:!0},"aria-current":n===m.key?"page":void 0,className:Gn(n===m.key),children:m.name},m.key))]}):null,g&&f?t.jsxs("p",{role:"status",className:"text-sm text-muted-foreground",children:[f.title,"."," ",f.retryable?t.jsx("button",{type:"button",onClick:()=>void y(),className:"underline underline-offset-4",children:"Retry"}):null]}):null,c.kind==="view"?t.jsxs(t.Fragment,{children:[t.jsx(Ma,{decls:c.view.params,params:qe(s),onParamsChange:m=>void a({to:".",search:m})}),t.jsx(ys,{orgSlug:e,viewKey:c.view.key,scope:{},params:qe(s),onParamsChange:m=>void a({to:".",search:m,replace:!0}),contentHash:c.view.content_hash,title:c.view.name,minHeight:400})]}):t.jsx(_o,{ownerSlug:e})]})}const Gn=e=>La(e,"min-h-10 max-w-full gap-2 px-3 text-sm break-words");function cc({ownerSlug:e,typeScope:n,create:s,createType:a=!1,viewKey:r,shape:i}){return t.jsxs(Gr,{className:"gap-6 pt-2.5 pb-8",children:[t.jsx(Yr,{}),t.jsx(Kr,{owner:e,children:o=>t.jsx("div",{className:"flex min-h-0 min-w-0 flex-1 flex-col",children:t.jsx(Wi,{ownerSlug:o.ownerSlug,typeScope:n,create:s,createType:a,viewKey:r,shape:i})})})]})}export{cc as M};
74
+ //# sourceMappingURL=memory-browse-page-CNZJbCJC.js.map
@@ -0,0 +1,2 @@
1
+ import{bs as C,ft as R}from"./index-DdBTTN3y.js";var U={exports:{}},I;function W(){return I||(I=1,(function(u,d){(function(O,_){u.exports=_()})(globalThis,()=>(()=>{var y={949(X,v,m){Object.defineProperty(v,"__esModule",{value:!0}),v.CronParser=void 0;var r=m(515),T=(function(){function f(t,e,o){e===void 0&&(e=!0),o===void 0&&(o=!1),this.expression=t,this.dayOfWeekStartIndexZero=e,this.monthStartIndexZero=o}return f.prototype.parse=function(){var t,e,o=(t=this.expression)!==null&&t!==void 0?t:"";if(o==="@reboot")return e=["@reboot","","","","","",""],e;if(o.startsWith("@")){var n=this.parseSpecial(this.expression);e=this.extractParts(n)}else e=this.extractParts(this.expression);return this.normalize(e),this.validate(e),e},f.prototype.parseSpecial=function(t){var e={"@yearly":"0 0 1 1 *","@annually":"0 0 1 1 *","@monthly":"0 0 1 * *","@weekly":"0 0 * * 0","@daily":"0 0 * * *","@midnight":"0 0 * * *","@hourly":"0 * * * *","@reboot":"@reboot"},o=e[t];if(!o)throw new Error("Unknown special expression.");return o},f.prototype.extractParts=function(t){if(!this.expression)throw new Error("cron expression is empty");for(var e=t.trim().split(/[ ]+/),o=0;o<e.length;o++)if(e[o].includes(",")){var n=e[o].split(",").map(function(a){return a.trim()}).filter(function(a){return a!==""}).map(function(a){return isNaN(Number(a))?a:Number(a)}).filter(function(a){return a!==null&&a!==""});n.length===0&&n.push("*"),n.sort(function(a,s){return a!==null&&s!==null?a-s:0}),e[o]=n.map(function(a){return a!==null?a.toString():""}).join(",")}if(e.length<5)throw new Error("Expression has only ".concat(e.length," part").concat(e.length==1?"":"s",". At least 5 parts are required."));if(e.length==5)e.unshift(""),e.push("");else if(e.length==6){var i=/\d{4}$/.test(e[5])||e[4]=="?"||e[2]=="?";i?e.unshift(""):e.push("")}else if(e.length>7)throw new Error("Expression has ".concat(e.length," parts; too many!"));return e},f.prototype.normalize=function(t){var e=this;if(t[3]=t[3].replace("?","*"),t[5]=t[5].replace("?","*"),t[2]=t[2].replace("?","*"),t[0].indexOf("0/")==0&&(t[0]=t[0].replace("0/","*/")),t[1].indexOf("0/")==0&&(t[1]=t[1].replace("0/","*/")),t[2].indexOf("0/")==0&&(t[2]=t[2].replace("0/","*/")),t[3].indexOf("1/")==0&&(t[3]=t[3].replace("1/","*/")),t[4].indexOf("1/")==0&&(t[4]=t[4].replace("1/","*/")),t[6].indexOf("1/")==0&&(t[6]=t[6].replace("1/","*/")),t[5]=t[5].replace(/(^\d)|([^#/\s]\d)/g,function(l){var g=l.replace(/\D/,""),h=g;return e.dayOfWeekStartIndexZero?g=="7"&&(h="0"):h=(parseInt(g)-1).toString(),l.replace(g,h)}),t[5]=="L"&&(t[5]="6"),t[3]=="?"&&(t[3]="*"),t[3].indexOf("W")>-1&&(t[3].indexOf(",")>-1||t[3].indexOf("-")>-1))throw new Error("The 'W' character can be specified only when the day-of-month is a single day, not a range or list of days.");var o={SUN:0,MON:1,TUE:2,WED:3,THU:4,FRI:5,SAT:6};for(var n in o)t[5]=t[5].replace(new RegExp(n,"gi"),o[n].toString());t[4]=t[4].replace(/(^\d{1,2})|([^#/\s]\d{1,2})/g,function(l){var g=l.replace(/\D/,""),h=g;return e.monthStartIndexZero&&(h=(parseInt(g)+1).toString()),l.replace(g,h)});var i={JAN:1,FEB:2,MAR:3,APR:4,MAY:5,JUN:6,JUL:7,AUG:8,SEP:9,OCT:10,NOV:11,DEC:12};for(var a in i)t[4]=t[4].replace(new RegExp(a,"gi"),i[a].toString());t[0]=="0"&&(t[0]=""),!/\*|\-|\,|\//.test(t[2])&&(/\*|\//.test(t[1])||/\*|\//.test(t[0]))&&(t[2]+="-".concat(t[2]));for(var s=0;s<t.length;s++)if(t[s].indexOf(",")!=-1&&(t[s]=t[s].split(",").filter(function(l){return l!==""}).join(",")||"*"),t[s]=="*/1"&&(t[s]="*"),t[s].indexOf("/")>-1&&!/^\*|\-|\,/.test(t[s])){var c=null;switch(s){case 4:c="12";break;case 5:c="6";break;case 6:c="9999";break;default:c=null;break}if(c!==null){var p=t[s].split("/");t[s]="".concat(p[0],"-").concat(c,"/").concat(p[1])}}},f.prototype.validate=function(t){var e="0-9,\\-*/";this.validateOnlyExpectedCharactersFound(t[0],e),this.validateOnlyExpectedCharactersFound(t[1],e),this.validateOnlyExpectedCharactersFound(t[2],e),this.validateOnlyExpectedCharactersFound(t[3],"0-9,\\-*/LW"),this.validateOnlyExpectedCharactersFound(t[4],e),this.validateOnlyExpectedCharactersFound(t[5],"0-9,\\-*/L#"),this.validateOnlyExpectedCharactersFound(t[6],e),this.validateAnyRanges(t)},f.prototype.validateAnyRanges=function(t){r.default.secondRange(t[0]),r.default.minuteRange(t[1]),r.default.hourRange(t[2]),r.default.dayOfMonthRange(t[3]),r.default.monthRange(t[4],this.monthStartIndexZero),r.default.dayOfWeekRange(t[5],this.dayOfWeekStartIndexZero)},f.prototype.validateOnlyExpectedCharactersFound=function(t,e){var o=t.match(new RegExp("[^".concat(e,"]+"),"gi"));if(o&&o.length)throw new Error("Expression contains invalid values: '".concat(o.toString(),"'"))},f})();v.CronParser=T},333(X,v,m){Object.defineProperty(v,"__esModule",{value:!0}),v.ExpressionDescriptor=void 0;var r=m(823),T=m(949),f=(function(){function t(e,o){if(this.expression=e,this.options=o,this.expressionParts=new Array(5),!this.options.locale&&t.defaultLocale&&(this.options.locale=t.defaultLocale),!t.locales[this.options.locale]){var n=Object.keys(t.locales)[0];console.warn("Locale '".concat(this.options.locale,"' could not be found; falling back to '").concat(n,"'.")),this.options.locale=n}this.i18n=t.locales[this.options.locale],o.use24HourTimeFormat===void 0&&(o.use24HourTimeFormat=this.i18n.use24HourTimeFormatByDefault())}return t.toString=function(e,o){var n=o===void 0?{}:o,i=n.throwExceptionOnParseError,a=i===void 0?!0:i,s=n.verbose,c=s===void 0?!1:s,p=n.dayOfWeekStartIndexZero,l=p===void 0?!0:p,g=n.monthStartIndexZero,h=g===void 0?!1:g,S=n.use24HourTimeFormat,x=n.trimHoursLeadingZero,b=x===void 0?!1:x,k=n.locale,D=k===void 0?null:k,E=n.logicalAndDayFields,A=E===void 0?!1:E,M={throwExceptionOnParseError:a,verbose:c,dayOfWeekStartIndexZero:l,monthStartIndexZero:h,use24HourTimeFormat:S,trimHoursLeadingZero:b,locale:D,logicalAndDayFields:A};M.tzOffset&&console.warn("'tzOffset' option has been deprecated and is no longer supported.");var H=new t(e,M);return H.getFullDescription()},t.initialize=function(e,o){o===void 0&&(o="en"),t.specialCharacters=["/","-",",","*"],t.defaultLocale=o,e.load(t.locales)},t.prototype.getFullDescription=function(){var e,o,n="";try{var i=new T.CronParser(this.expression,this.options.dayOfWeekStartIndexZero,this.options.monthStartIndexZero);if(this.expressionParts=i.parse(),this.expressionParts[0]==="@reboot")return((o=(e=this.i18n).atReboot)===null||o===void 0?void 0:o.call(e))||"Run once, at startup";var a=this.getTimeOfDayDescription(),s=this.getDayOfMonthDescription(),c=this.getMonthDescription(),p=this.getDayOfWeekDescription(),l=this.getYearDescription();n+=a+s+p+c+l,n=this.transformVerbosity(n,!!this.options.verbose),n=n.charAt(0).toLocaleUpperCase()+n.substr(1)}catch(g){if(!this.options.throwExceptionOnParseError)n=this.i18n.anErrorOccuredWhenGeneratingTheExpressionD();else throw"".concat(g)}return n},t.prototype.getTimeOfDayDescription=function(){var e=this.expressionParts[0],o=this.expressionParts[1],n=this.expressionParts[2],i="";if(!r.StringUtilities.containsAny(o,t.specialCharacters)&&!r.StringUtilities.containsAny(n,t.specialCharacters)&&!r.StringUtilities.containsAny(e,t.specialCharacters))i+=this.i18n.atSpace()+this.formatTime(n,o,e);else if(!e&&o.indexOf("-")>-1&&!(o.indexOf(",")>-1)&&!(o.indexOf("/")>-1)&&!r.StringUtilities.containsAny(n,t.specialCharacters)){var a=o.split("-");i+=r.StringUtilities.format(this.i18n.everyMinuteBetweenX0AndX1(),this.formatTime(n,a[0],""),this.formatTime(n,a[1],""))}else if(!e&&n.indexOf(",")>-1&&n.indexOf("-")==-1&&n.indexOf("/")==-1&&!r.StringUtilities.containsAny(o,t.specialCharacters)){var s=n.split(",");i+=this.i18n.at();for(var c=0;c<s.length;c++)i&&(i+=" "),i+=this.formatTime(s[c],o,""),c<s.length-2&&(i+=","),c==s.length-2&&(i+=this.i18n.spaceAnd())}else{var p=this.getSecondsDescription(),l=this.getMinutesDescription(),g=this.getHoursDescription();if(i+=p,i&&l&&(i+=", "),i+=l,l===g)return i;i&&g&&(i+=", "),i+=g}return i},t.prototype.getSecondsDescription=function(){var e=this,o=this.getSegmentDescription(this.expressionParts[0],this.i18n.everySecond(),function(n){return n},function(n){return r.StringUtilities.format(e.i18n.everyX0Seconds(n),n)},function(n){return e.i18n.secondsX0ThroughX1PastTheMinute()},function(n){return n=="0"?"":parseInt(n)<20?e.i18n.atX0SecondsPastTheMinute(n):e.i18n.atX0SecondsPastTheMinuteGt20()||e.i18n.atX0SecondsPastTheMinute(n)});return o},t.prototype.getMinutesDescription=function(){var e=this,o=this.expressionParts[0],n=this.expressionParts[2],i=this.getSegmentDescription(this.expressionParts[1],this.i18n.everyMinute(),function(a){return a},function(a){return r.StringUtilities.format(e.i18n.everyX0Minutes(a),a)},function(a){return e.i18n.minutesX0ThroughX1PastTheHour()},function(a){var s,c;try{return a=="0"&&n.indexOf("/")==-1&&o==""?e.i18n.everyHour():a=="0"?((c=(s=e.i18n).onTheHour)===null||c===void 0?void 0:c.call(s))||e.i18n.atX0MinutesPastTheHour(a):parseInt(a)<20?e.i18n.atX0MinutesPastTheHour(a):e.i18n.atX0MinutesPastTheHourGt20()||e.i18n.atX0MinutesPastTheHour(a)}catch{return e.i18n.atX0MinutesPastTheHour(a)}});return i},t.prototype.getHoursDescription=function(){var e=this,o=this.expressionParts[2],n=0,i=[];o.split("/")[0].split(",").forEach(function(c){var p=c.split("-");p.length===2&&i.push({value:p[1],index:n+1}),n+=p.length});var a=0,s=this.getSegmentDescription(o,this.i18n.everyHour(),function(c){var p=i.find(function(g){return g.value===c&&g.index===a}),l=p&&e.expressionParts[1]!=="0";return a++,l?e.formatTime(c,"59",""):e.formatTime(c,"0","")},function(c){return r.StringUtilities.format(e.i18n.everyX0Hours(c),c)},function(c){return e.i18n.betweenX0AndX1()},function(c){return e.i18n.atX0()});return s},t.prototype.getDayOfWeekDescription=function(){var e=this,o=this.i18n.daysOfTheWeek(),n=null;return this.expressionParts[5]=="*"?n="":n=this.getSegmentDescription(this.expressionParts[5],this.i18n.commaEveryDay(),function(i,a){var s=i;i.indexOf("#")>-1?s=i.substring(0,i.indexOf("#")):i.indexOf("L")>-1&&(s=s.replace("L",""));var c=parseInt(s),p=e.i18n.daysOfTheWeekInCase?e.i18n.daysOfTheWeekInCase(a)[c]:o[c];if(i.indexOf("#")>-1){var l=null,g=i.substring(i.indexOf("#")+1),h=i.substring(0,i.indexOf("#"));switch(g){case"1":l=e.i18n.first(h);break;case"2":l=e.i18n.second(h);break;case"3":l=e.i18n.third(h);break;case"4":l=e.i18n.fourth(h);break;case"5":l=e.i18n.fifth(h);break}p=l+" "+p}return p},function(i){return parseInt(i)==1?"":r.StringUtilities.format(e.i18n.commaEveryX0DaysOfTheWeek(i),i)},function(i){var a=i.substring(0,i.indexOf("-")),s=e.expressionParts[3]!="*";return s?e.i18n.commaAndX0ThroughX1(a):e.i18n.commaX0ThroughX1(a)},function(i){var a=null;if(i.indexOf("#")>-1){var s=i.substring(i.indexOf("#")+1),c=i.substring(0,i.indexOf("#"));a=e.i18n.commaOnThe(s,c).trim()+e.i18n.spaceX0OfTheMonth()}else if(i.indexOf("L")>-1)a=e.i18n.commaOnTheLastX0OfTheMonth(i.replace("L",""));else{var p=e.expressionParts[3]!="*";p?e.options.logicalAndDayFields?a=e.i18n.commaOnlyOnX0(i):a=e.i18n.commaAndOnX0():a=e.i18n.commaOnlyOnX0(i)}return a}),n},t.prototype.getMonthDescription=function(){var e=this,o=this.i18n.monthsOfTheYear(),n=this.getSegmentDescription(this.expressionParts[4],"",function(i,a){return a&&e.i18n.monthsOfTheYearInCase?e.i18n.monthsOfTheYearInCase(a)[parseInt(i)-1]:o[parseInt(i)-1]},function(i){return parseInt(i)==1?"":r.StringUtilities.format(e.i18n.commaEveryX0Months(i),i)},function(i){return e.i18n.commaMonthX0ThroughMonthX1()||e.i18n.commaX0ThroughX1()},function(i){return e.i18n.commaOnlyInMonthX0?e.i18n.commaOnlyInMonthX0():e.i18n.commaOnlyInX0()});return n},t.prototype.getDayOfMonthDescription=function(){var e=this,o=null,n=this.expressionParts[3];switch(n){case"L":o=this.i18n.commaOnTheLastDayOfTheMonth();break;case"WL":case"LW":o=this.i18n.commaOnTheLastWeekdayOfTheMonth();break;default:var i=n.match(/(\d{1,2}W)|(W\d{1,2})/);if(i){var a=parseInt(i[0].replace("W","")),s=a==1?this.i18n.firstWeekday():r.StringUtilities.format(this.i18n.weekdayNearestDayX0(),a.toString());o=r.StringUtilities.format(this.i18n.commaOnTheX0OfTheMonth(),s);break}else{var c=n.match(/L-(\d{1,2})/);if(c){var p=c[1];o=r.StringUtilities.format(this.i18n.commaDaysBeforeTheLastDayOfTheMonth(p),p);break}else{if(n=="*"&&this.expressionParts[5]!="*")return"";o=this.getSegmentDescription(n,this.i18n.commaEveryDay(),function(l){return l=="L"?e.i18n.lastDay():e.i18n.dayX0?r.StringUtilities.format(e.i18n.dayX0(),l):l},function(l){return l=="1"?e.i18n.commaEveryDay():e.i18n.commaEveryX0Days(l)},function(l){return e.i18n.commaBetweenDayX0AndX1OfTheMonth(l)},function(l){return e.i18n.commaOnDayX0OfTheMonth(l)})}break}}return o},t.prototype.getYearDescription=function(){var e=this,o=this.getSegmentDescription(this.expressionParts[6],"",function(n){return/^\d+$/.test(n)?new Date(parseInt(n),1).getFullYear().toString():n},function(n){return r.StringUtilities.format(e.i18n.commaEveryX0Years(n),n)},function(n){return e.i18n.commaYearX0ThroughYearX1()||e.i18n.commaX0ThroughX1()},function(n){return e.i18n.commaOnlyInYearX0?e.i18n.commaOnlyInYearX0():e.i18n.commaOnlyInX0()});return o},t.prototype.getSegmentDescription=function(e,o,n,i,a,s){var c=null,p=e.indexOf("/")>-1,l=e.indexOf("-")>-1,g=e.indexOf(",")>-1;if(!e)c="";else if(e==="*")c=o;else if(!p&&!l&&!g)c=r.StringUtilities.format(s(e),n(e));else if(g){for(var h=e.split(","),S="",x=this.i18n.spaceAnd(),b=0;b<h.length;b++)if(b>0&&h.length>2&&(S+=",",b<h.length-1&&(S+=" ")),b>0&&h.length>1&&(b==h.length-1||h.length==2)&&(S+=x==","&&h.length>2?" ":"".concat(x," ")),h[b].indexOf("/")>-1||h[b].indexOf("-")>-1){var k=h[b].indexOf("-")>-1&&h[b].indexOf("/")==-1,D=this.getSegmentDescription(h[b],o,n,i,k?this.i18n.commaX0ThroughX1:a,s);k&&(D=D.replace(", ","")),S+=D}else if(!p)S+=n(h[b]);else{var E=this.getSegmentDescription(h[b],o,n,i,a,s);E&&E.startsWith(", ")&&(E=E.substring(2)),S+=E}p?c=S:c=r.StringUtilities.format(s(e),S)}else if(p){var h=e.split("/");if(c=r.StringUtilities.format(i(h[1]),h[1]),h[0].indexOf("-")>-1){var A=this.generateRangeSegmentDescription(h[0],a,n);A.indexOf(", ")!=0&&(c+=", "),c+=A}else if(h[0].indexOf("*")==-1){var M=r.StringUtilities.format(s(h[0]),n(h[0]));M=M.replace(", ",""),c+=r.StringUtilities.format(this.i18n.commaStartingX0(),M)}}else l&&(c=this.generateRangeSegmentDescription(e,a,n));return c},t.prototype.generateRangeSegmentDescription=function(e,o,n){var i="",a=e.split("-"),s=n(a[0],1),c=n(a[1],2),p=o(e);return i+=r.StringUtilities.format(p,s,c),i},t.prototype.formatTime=function(e,o,n){var i=0,a=0,s=parseInt(e)+i,c=parseInt(o)+a;c>=60?(c-=60,s+=1):c<0&&(c+=60,s-=1),s>=24?s=s-24:s<0&&(s=24+s);var p="",l=!1;this.options.use24HourTimeFormat||(l=!!(this.i18n.setPeriodBeforeTime&&this.i18n.setPeriodBeforeTime()),p=l?"".concat(this.getPeriod(s)," "):" ".concat(this.getPeriod(s)),s>12&&(s-=12),s===0&&(s=12));var g="";n&&(g=":".concat(("00"+n).substring(n.length)));var h=s.toString(),S=("00"+h).substring(h.length),x=c.toString(),b=("00"+x).substring(x.length),k=this.options.trimHoursLeadingZero?h:S;return"".concat(l?p:"").concat(k,":").concat(b).concat(g).concat(l?"":p)},t.prototype.transformVerbosity=function(e,o){if(!o&&(e=e.replace(new RegExp(", ".concat(this.i18n.everyMinute()),"g"),""),e=e.replace(new RegExp(", ".concat(this.i18n.everyHour()),"g"),""),e=e.replace(new RegExp(this.i18n.commaEveryDay(),"g"),""),e=e.replace(/\, ?$/,""),this.i18n.conciseVerbosityReplacements))for(var n=0,i=Object.entries(this.i18n.conciseVerbosityReplacements());n<i.length;n++){var a=i[n],s=a[0],c=a[1];e=e.replace(new RegExp(s,"g"),c)}return e},t.prototype.getPeriod=function(e){return e>=12?this.i18n.pm&&this.i18n.pm()||"PM":this.i18n.am&&this.i18n.am()||"AM"},t.locales={},t})();v.ExpressionDescriptor=f},747(X,v,m){Object.defineProperty(v,"__esModule",{value:!0}),v.enLocaleLoader=void 0;var r=m(486),T=(function(){function f(){}return f.prototype.load=function(t){t.en=new r.en},f})();v.enLocaleLoader=T},486(X,v){Object.defineProperty(v,"__esModule",{value:!0}),v.en=void 0;var m=(function(){function r(){}return r.prototype.atX0SecondsPastTheMinuteGt20=function(){return null},r.prototype.atX0MinutesPastTheHourGt20=function(){return null},r.prototype.commaMonthX0ThroughMonthX1=function(){return null},r.prototype.commaYearX0ThroughYearX1=function(){return null},r.prototype.use24HourTimeFormatByDefault=function(){return!1},r.prototype.anErrorOccuredWhenGeneratingTheExpressionD=function(){return"An error occurred when generating the expression description. Check the cron expression syntax."},r.prototype.everyMinute=function(){return"every minute"},r.prototype.everyHour=function(){return"every hour"},r.prototype.atSpace=function(){return"At "},r.prototype.everyMinuteBetweenX0AndX1=function(){return"Every minute between %s and %s"},r.prototype.at=function(){return"At"},r.prototype.spaceAnd=function(){return" and"},r.prototype.everySecond=function(){return"every second"},r.prototype.everyX0Seconds=function(){return"every %s seconds"},r.prototype.secondsX0ThroughX1PastTheMinute=function(){return"seconds %s through %s past the minute"},r.prototype.atX0SecondsPastTheMinute=function(){return"at %s seconds past the minute"},r.prototype.everyX0Minutes=function(){return"every %s minutes"},r.prototype.minutesX0ThroughX1PastTheHour=function(){return"minutes %s through %s past the hour"},r.prototype.atX0MinutesPastTheHour=function(){return"at %s minutes past the hour"},r.prototype.everyX0Hours=function(){return"every %s hours"},r.prototype.betweenX0AndX1=function(){return"between %s and %s"},r.prototype.atX0=function(){return"at %s"},r.prototype.commaEveryDay=function(){return", every day"},r.prototype.commaEveryX0DaysOfTheWeek=function(){return", every %s days of the week"},r.prototype.commaX0ThroughX1=function(){return", %s through %s"},r.prototype.commaAndX0ThroughX1=function(){return", %s through %s"},r.prototype.first=function(){return"first"},r.prototype.second=function(){return"second"},r.prototype.third=function(){return"third"},r.prototype.fourth=function(){return"fourth"},r.prototype.fifth=function(){return"fifth"},r.prototype.commaOnThe=function(){return", on the "},r.prototype.spaceX0OfTheMonth=function(){return" %s of the month"},r.prototype.lastDay=function(){return"the last day"},r.prototype.commaOnTheLastX0OfTheMonth=function(){return", on the last %s of the month"},r.prototype.commaOnlyOnX0=function(){return", only on %s"},r.prototype.commaAndOnX0=function(){return", and on %s"},r.prototype.commaEveryX0Months=function(){return", every %s months"},r.prototype.commaOnlyInX0=function(){return", only in %s"},r.prototype.commaOnTheLastDayOfTheMonth=function(){return", on the last day of the month"},r.prototype.commaOnTheLastWeekdayOfTheMonth=function(){return", on the last weekday of the month"},r.prototype.commaDaysBeforeTheLastDayOfTheMonth=function(){return", %s days before the last day of the month"},r.prototype.firstWeekday=function(){return"first weekday"},r.prototype.weekdayNearestDayX0=function(){return"weekday nearest day %s"},r.prototype.commaOnTheX0OfTheMonth=function(){return", on the %s of the month"},r.prototype.commaEveryX0Days=function(){return", every %s days in a month"},r.prototype.commaBetweenDayX0AndX1OfTheMonth=function(){return", between day %s and %s of the month"},r.prototype.commaOnDayX0OfTheMonth=function(){return", on day %s of the month"},r.prototype.commaEveryHour=function(){return", every hour"},r.prototype.commaEveryX0Years=function(){return", every %s years"},r.prototype.commaStartingX0=function(){return", starting %s"},r.prototype.daysOfTheWeek=function(){return["Sunday","Monday","Tuesday","Wednesday","Thursday","Friday","Saturday"]},r.prototype.monthsOfTheYear=function(){return["January","February","March","April","May","June","July","August","September","October","November","December"]},r.prototype.atReboot=function(){return"Run once, at startup"},r.prototype.onTheHour=function(){return"on the hour"},r})();v.en=m},515(X,v){Object.defineProperty(v,"__esModule",{value:!0});function m(T,f){if(!T)throw new Error(f)}var r=(function(){function T(){}return T.secondRange=function(f){for(var t=f.split(","),e=0;e<t.length;e++)if(!isNaN(parseInt(t[e],10))){var o=parseInt(t[e],10);m(o>=0&&o<=59,"seconds part must be >= 0 and <= 59")}},T.minuteRange=function(f){for(var t=f.split(","),e=0;e<t.length;e++)if(!isNaN(parseInt(t[e],10))){var o=parseInt(t[e],10);m(o>=0&&o<=59,"minutes part must be >= 0 and <= 59")}},T.hourRange=function(f){for(var t=f.split(","),e=0;e<t.length;e++)if(!isNaN(parseInt(t[e],10))){var o=parseInt(t[e],10);m(o>=0&&o<=23,"hours part must be >= 0 and <= 23")}},T.dayOfMonthRange=function(f){for(var t=f.split(","),e=0;e<t.length;e++)if(!isNaN(parseInt(t[e],10))){var o=parseInt(t[e],10);m(o>=1&&o<=31,"DOM part must be >= 1 and <= 31")}},T.monthRange=function(f,t){for(var e=f.split(","),o=0;o<e.length;o++)if(!isNaN(parseInt(e[o],10))){var n=parseInt(e[o],10);m(n>=1&&n<=12,t?"month part must be >= 0 and <= 11":"month part must be >= 1 and <= 12")}},T.dayOfWeekRange=function(f,t){for(var e=f.split(","),o=0;o<e.length;o++)if(!isNaN(parseInt(e[o],10))){var n=parseInt(e[o],10);m(n>=0&&n<=6,t?"DOW part must be >= 0 and <= 6":"DOW part must be >= 1 and <= 7")}},T})();v.default=r},823(X,v){Object.defineProperty(v,"__esModule",{value:!0}),v.StringUtilities=void 0;var m=(function(){function r(){}return r.format=function(T){for(var f=[],t=1;t<arguments.length;t++)f[t-1]=arguments[t];return T.replace(/%s/g,function(e){return f.shift()})},r.containsAny=function(T,f){return f.some(function(t){return T.indexOf(t)>-1})},r})();v.StringUtilities=m}},O={};function _(X){var v=O[X];if(v!==void 0)return v.exports;var m=O[X]={exports:{}};return y[X](m,m.exports,_),m.exports}var w={};return(()=>{var X=w;Object.defineProperty(X,"__esModule",{value:!0}),X.toString=void 0;var v=_(333),m=_(747);v.ExpressionDescriptor.initialize(new m.enLocaleLoader),X.default=v.ExpressionDescriptor;var r=v.ExpressionDescriptor.toString;X.toString=r})(),w})())})(U)),U.exports}var F=W();const N=C(F);function j(u){const d=u?.execution_config?.executor;if(d&&typeof d=="object"&&"kind"in d){if(d.kind==="external")return"external";if(d.kind==="script")return"script"}return u?.device_worker_id?"device":u?.managed_agent_id?"agent":"manual"}function K(u){const d=j(u);return d==="agent"||d==="device"?u?.managed_agent_id??null:null}function Y(u){try{return N.toString(u.trim(),{throwExceptionOnParseError:!0})}catch{return`On schedule ${u.trim()}`}}function Z(u,d){return d.get(u)??u}function B(u){return R(u.replace(/^\$/,""))}function $(u,d){const y=d?.display_name?.trim();return y&&d?.external_tenant_id===u?y:`#${u}`}function V(u,d){if(!u||typeof u!="object"||Array.isArray(u))return"";const y=u;return typeof y.repository=="string"?` in ${y.repository}`:typeof y.channel_id=="string"?` in ${$(y.channel_id,d)}`:typeof y.resource_ref=="string"?` for ${y.resource_ref}`:""}function P(u){return Array.isArray(u.triggers)?u.triggers.filter(d=>!!d&&typeof d=="object"):[]}function G(u,d,y){if(u.kind==="schedule"&&typeof u.cron=="string")return Y(u.cron);if(u.kind==="event"&&u.source!=="workspace"&&typeof u.connector_key=="string"){const O=Array.isArray(u.event_types)?u.event_types.filter(X=>typeof X=="string"):[],_=O.length>0?O.join(" or "):"an event",w=typeof u.connection_id=="number"?y.get(u.connection_id):void 0;return`${Z(u.connector_key,d)} sends ${_}${V(u.match,w)}`}if(u.kind==="event"&&u.source==="workspace"){const O=Array.isArray(u.event_types)?u.event_types.filter(X=>typeof X=="string"):[],_=O.length>0?O.join(" or "):"an event",w=typeof u.entity_type=="string"?` on ${B(u.entity_type)}`:"";return`another Automation writes ${_}${w}`}return null}function z(u){return u.health==="degraded"?"error":"enabled"}function J(u,d=new Map,y=new Map){const O=P(u),_=u.name?.trim()||"Untitled automation",w=O.some(f=>f.kind==="event"),X=O.some(f=>f.kind==="schedule"),v=w?"event":X?"schedule":"manual",m=O.map(f=>G(f,d,y)).filter(f=>!!f);let r="When started manually";m.length===1?r=`When ${m[0]}`:m.length>1&&(r=`When ${m[0]}${m.slice(1).map(f=>`, or when ${f}`).join("")}`);const T=O.some(f=>f.kind==="event"&&f.output==="reply_to_source")?"source":"silent";return{key:`automation:${u.automation_id}`,kind:v,when:r,does:_,output:{destination:T},state:z(u),sortTime:u.next_run_at?Date.parse(u.next_run_at):null,automation:u}}const L={event:0,schedule:1,manual:2};function Q(u,d=new Map,y=new Map){return u.map(O=>J(O,d,y)).sort((O,_)=>O.state!==_.state?O.state==="enabled"?-1:1:L[O.kind]!==L[_.kind]?L[O.kind]-L[_.kind]:O.sortTime!==_.sortTime?O.sortTime===null?1:_.sortTime===null?-1:O.sortTime-_.sortTime:O.when.localeCompare(_.when)||O.key.localeCompare(_.key))}const ee={kind:"all",output:"any",state:"any"};function te(u,d){return u.filter(y=>(d.kind==="all"||y.kind===d.kind)&&(d.output==="any"||(d.output==="reply"?y.output.destination==="source":y.output.destination==="silent"))&&(d.state==="any"||(d.state==="active"?y.state==="enabled":y.state==="error")))}function ne(u){const d=Array.isArray(u.triggers)?u.triggers:[];for(const y of d)if(y&&typeof y=="object"&&y.kind==="event"&&y.source!=="workspace"&&typeof y.connector_key=="string")return y.connector_key;return null}export{ee as D,j as a,K as b,N as c,J as d,ne as e,te as f,Q as m};
2
+ //# sourceMappingURL=model-jL871x2J.js.map
@@ -0,0 +1,2 @@
1
+ import{aD as g,aE as N,j as s,fa as y,cU as m,Y as p,i as f,B as w,fc as b}from"./index-DdBTTN3y.js";function D(o,r){const l=new Map(r.map(e=>[e.slug,e])),i=new Map,d=e=>{const a=e.model?.trim();if(!a)return;const t=`${e.slug}/${a}`;i.has(t)||i.set(t,{value:t,provider:e.provider,model:a,isDefault:e.isDefault})};for(const e of o){const a=l.get(e.kind)??l.get(e.slug),t={slug:e.slug,provider:e.displayName||e.slug,isDefault:e.isDefault};d({...t,model:e.capabilities.text?.model}),d({...t,model:a?.defaultModel});for(const x of a?.models??[])d({...t,model:x})}for(const e of r){if(!e.systemAvailable)continue;const a={slug:e.slug,provider:e.displayName||e.slug,isDefault:!1};d({...a,model:e.defaultModel});for(const t of e.models)d({...a,model:t})}return[...i.values()]}function M(o,r){const l=o.trim();return l.length>0&&l!=="auto"&&!r.some(i=>i.value===l)}function S({value:o,onChange:r,placeholder:l,disabled:i,className:d}){const{data:e=[]}=g(),{data:a=[]}=N(),t=D(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(),v=M(u,t);return s.jsxs(s.Fragment,{children:[s.jsxs(m,{value:"__inherit__ use default inherit",onSelect:()=>{r(""),c()},className:"cursor-pointer",children:[s.jsx(p,{className:f("mr-2 h-4 w-4",o===""?"opacity-100":"opacity-0")}),s.jsx("span",{className:"text-muted-foreground",children:l})]}),s.jsxs(m,{value:"auto newest latest",onSelect:()=>{r("auto"),c()},className:"cursor-pointer",children:[s.jsx(p,{className:f("mr-2 h-4 w-4",o==="auto"?"opacity-100":"opacity-0")}),s.jsxs("span",{children:["auto"," ",s.jsx("span",{className:"text-muted-foreground text-xs",children:"(newest for the provider)"})]})]}),t.map(n=>s.jsxs(m,{value:`${n.provider} ${n.model} ${n.value}`,onSelect:()=>{r(n.value),c()},className:"cursor-pointer",children:[s.jsx(p,{className:f("mr-2 h-4 w-4",o===n.value?"opacity-100":"opacity-0")}),s.jsxs("span",{className:"truncate",children:[n.provider," ",s.jsx("span",{className:"text-muted-foreground text-xs",children:n.model}),n.isDefault?s.jsx("span",{className:"ml-1.5 text-muted-foreground text-xs",children:"· org default"}):null]})]},n.value)),v?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,D as b,M as s};
2
+ //# sourceMappingURL=model-selector-CgU8SJMF.js.map
@@ -0,0 +1,2 @@
1
+ import{j3 as r,j as e}from"./index-DdBTTN3y.js";import{a as m}from"./agents-workbench-bPTjdVS1.js";import"./agent-editor-form-CdA5vLr8.js";import"./model-selector-CgU8SJMF.js";import"./proposal-review-shell-D6KABxah.js";import"./runs-fFJ1lPnw.js";import"./nav-pill-DrFkuyUQ.js";function f(){const{owner:o,agentId:t}=r.useParams();return e.jsx(m,{owner:o,agentId:t,tab:"models"})}export{f as component};
2
+ //# sourceMappingURL=models-jdemgIZk.js.map
@@ -0,0 +1,2 @@
1
+ import{i as o}from"./index-DdBTTN3y.js";function i(e,n){return o("inline-flex items-center justify-center rounded-md font-medium transition-colors focus-visible:outline-none focus-visible:ring-1 focus-visible:ring-ring",n,e?"bg-secondary text-secondary-foreground":"text-muted-foreground hover:bg-accent hover:text-accent-foreground")}export{i as n};
2
+ //# sourceMappingURL=nav-pill-DrFkuyUQ.js.map
@@ -0,0 +1,2 @@
1
+ import{hB as o,c as p,a6 as x,q as b,at as h,bb as w,j as a,ak as L,al as f,gR as j,b3 as A,gS as S,L as C,gT as N,fL as k,b2 as y,c5 as E}from"./index-DdBTTN3y.js";import{A as R}from"./agent-editor-form-CdA5vLr8.js";import"./model-selector-CgU8SJMF.js";function q(){const{owner:e}=o.useParams(),t=o.useSearch(),r=p(),i=x(),{isAuthenticated:c}=b(),{isMember:g,isLoading:m}=h(),n=c&&g,{data:u=[],isLoading:d}=w({enabled:n});return a.jsx(L,{className:"gap-3 pt-2.5 pb-8",children:a.jsxs(f,{className:"flex flex-1 flex-col gap-6",children:[a.jsx(j,{breadcrumb:a.jsx(S,{crumbs:[a.jsx(C,{to:"/$owner/agents",params:{owner:e},className:N,children:"Agents"},"agents")]}),icon:a.jsx(A.agents.icon,{className:"h-6 w-6"}),title:"Build a managed agent",caption:"Create an agent that Lobu runs and manages for this workspace."}),m||n&&d?a.jsx(k,{rows:1}):n?a.jsx(R,{mode:{kind:"create"},existingAgentIds:u.map(s=>s.agentId),onCreated:async s=>{const l=["agents",e];if(await i.refetchQueries({queryKey:l,exact:!0}),t.platform&&t.listen){await r({to:"/$owner/automations/new",params:{owner:e},search:{...t,agent:s}});return}await r({to:"/$owner/agents/$agentId/settings",params:{owner:e,agentId:s},search:{run_id:void 0}})}}):a.jsx(y,{icon:E,title:"Workspace membership required",description:"Only workspace members can build managed agents."})]})})}export{q as component};
2
+ //# sourceMappingURL=new-CcJOd5aH.js.map
@@ -1,2 +1,2 @@
1
- import{v as z,o as F,G as L,r,j as e,H as w,I as S,B as U,J as N,K as E}from"./index-4gCDI7m4.js";import{C as I,a as A,b as T,c as k}from"./card-SFtxv9f2.js";import{F as B}from"./full-page-spinner-BMiXl54z.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(B,{});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(),v=(g.trim()||c(s)).trim();if(!s){o("Name is required");return}if(!v){o("Slug is required");return}p(!0);try{const t=await N.create({name:s,slug:v});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(I,{children:[e.jsx(A,{children:e.jsx(T,{children:"Create organization"})}),e.jsx(k,{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(w,{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(w,{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-CvX8_gIb.js.map
1
+ import{c as z,q as F,G as L,r,j as e,H as v,I as S,B as U,J as N,K as E}from"./index-DdBTTN3y.js";import{C as I,a as A,b as T,c as k}from"./card-Bdi7VEwo.js";import{F as q}from"./full-page-spinner-BqmckkOf.js";function c(l){return l.toLowerCase().replace(/[^a-z0-9]+/g,"-").replace(/^-+|-+$/g,"")}function $(){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(q,{});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(I,{children:[e.jsx(A,{children:e.jsx(T,{children:"Create organization"})}),e.jsx(k,{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{$ as component};
2
+ //# sourceMappingURL=new-DgE1pVV0.js.map
@@ -0,0 +1,2 @@
1
+ import{c as S,at as C,aH as k,aB as A,bb as T,r as g,j as e,ak as L,al as B,gS as P,L as p,gT as R,d1 as $,S as f,hl as w,az as I}from"./index-DdBTTN3y.js";import{C as O,A as D}from"./create-automation-form-PEmSLMD6.js";import"./model-jL871x2J.js";import"./entity-options-daOOQo7O.js";import"./connection-label-BobuYiAG.js";import"./use-automations-BLNjxq2K.js";import"./model-selector-CgU8SJMF.js";import"./skill-editor-D_W3QlRz.js";import"./code-editor-DNuRKde1.js";import"./json-diff-BaLL4Fsu.js";import"./index-Vcq4gwWv.js";import"./use-mention-search-dn3ws1WB.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(),[c,d]=g.useState({ready:!1,triggers:[]}),[u,N]=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=>N(s.length>0?s:void 0),onSuccess:t,hideHeader:!0,hideCancel:!0,submitLabel:"Create Automation",submitDisabled:!c.ready,createFields:{triggers:c.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}),c=A(h?.id??null),{data:d=[]}=T(),u=!!(t?.platform&&(t.listen||t.resource)),N=u&&(a.isLoading||c.isLoading),o=g.useMemo(()=>{if(!t?.platform||!t.listen&&!t.resource)return;const x=a.data??[],j=t.connection?x.find(i=>i.slug===t.connection):(()=>{const i=x.filter(v=>v.connector_key!==t.platform?!1:t.resource?!0:v.facets.chat&&(v.external_tenant_id??"")===(t.team??""));return i.length===1?i[0]:void 0})();if(t.connection&&!j)return;const b=t.events?.split(",").map(i=>i.trim()).filter(Boolean)??[];return[{kind:"event",source:"connector",connector_key:t.platform,...j?{connection_id:j.id}:{},event_types:b.length>0?b:t.listen?["message.created"]:[],match:t.resource?{resource_ref:t.resource,...t.resource_type?{resource_type:t.resource_type}:{}}:{channel_id:E(t.listen??"")},execution:"turn",active_run:t.listen?"steer":"queue",output:t.listen?"reply_to_source":"silent",skip_if_unchanged:!t.listen}]},[a.data,t]),r=c.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/automations",params:{owner:n}}),_=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(B,{className:"flex min-w-0 flex-col gap-4",children:[e.jsx(P,{crumbs:[e.jsx(p,{to:"/$owner/automations",params:{owner:n},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(p,{to:"/$owner/agents/new",params:{owner:n},search:t,className:"underline underline-offset-4",children:d.length===0?"Create an agent":"create an agent"})," ","and come back to finish this setup."]}):null,N?e.jsxs("div",{className:"space-y-3",children:[e.jsx(f,{className:"h-10 w-full"}),e.jsx(f,{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 K(){const{owner:n}=w.useParams(),t=w.useSearch();return e.jsx(I,{owner:n,children:()=>e.jsx(z,{owner:n,prefilled:t})})}export{K as component};
2
+ //# sourceMappingURL=new-OWwrYckd.js.map