@lobu/runtime-server 24.5.0 → 24.6.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 (235) hide show
  1. package/dist/catalogs/connectors.json +342 -4
  2. package/dist/catalogs/skills.json +1 -1
  3. package/dist/component.json +1 -1
  4. package/dist/connectors/linkedin-identity.ts +43 -0
  5. package/dist/connectors/linkedin.ts +154 -3
  6. package/dist/connectors/x-like-follow.ts +329 -0
  7. package/dist/connectors/x.ts +709 -80
  8. package/dist/dependencies.bun.lock +18 -18
  9. package/dist/owletto/dist/assets/_-DT3E3BmS.js +3 -0
  10. package/dist/owletto/dist/assets/_-c1xy7bLu.js +2 -0
  11. package/dist/owletto/dist/assets/_agentId-CTfoi0-7.js +2 -0
  12. package/dist/owletto/dist/assets/_agentId-DV8utajn.js +2 -0
  13. package/dist/owletto/dist/assets/_automationId-DvP3qyYL.js +2 -0
  14. package/dist/owletto/dist/assets/_connectorKey._connectionId-CL5SivCn.js +2 -0
  15. package/dist/owletto/dist/assets/_connectorKey.index-tnMwC67b.js +2 -0
  16. package/dist/owletto/dist/assets/_conversationId-DXN_8m88.js +2 -0
  17. package/dist/owletto/dist/assets/_eventId-SdpFT7jB.js +2 -0
  18. package/dist/owletto/dist/assets/_name-CM1AMywz.js +2 -0
  19. package/dist/owletto/dist/assets/_owner-CaGsXXBW.js +3 -0
  20. package/dist/owletto/dist/assets/_shape-DGAkETDp.js +2 -0
  21. package/dist/owletto/dist/assets/_skillKey-Dd4ZHPY8.js +2 -0
  22. package/dist/owletto/dist/assets/_slug-cRvJQtNo.js +2 -0
  23. package/dist/owletto/dist/assets/_view-B5I7mmkl.js +2 -0
  24. package/dist/owletto/dist/assets/_viewKey-Bwn0dyLo.js +2 -0
  25. package/dist/owletto/dist/assets/_viewKey-YjSYD0wc.js +2 -0
  26. package/dist/owletto/dist/assets/{accept-invitation-pUl-c1KQ.js → accept-invitation-CQZQ0wwC.js} +2 -2
  27. package/dist/owletto/dist/assets/{activity-route-view-DN0ZEAzr.js → activity-route-view-CZykJXQp.js} +2 -2
  28. package/dist/owletto/dist/assets/{agent-card-controls-C5jNWgfq.js → agent-card-controls-DuQJhtqp.js} +2 -2
  29. package/dist/owletto/dist/assets/{agent-client-setup-list-DbXtJTsO.js → agent-client-setup-list-CpUTAjXf.js} +2 -2
  30. package/dist/owletto/dist/assets/{agent-connect-pages-DcTuiSt9.js → agent-connect-pages-Br_ycC0z.js} +2 -2
  31. package/dist/owletto/dist/assets/agent-editor-form-BXQBFHSv.js +2 -0
  32. package/dist/owletto/dist/assets/{agent-guardrails-route-BJyfalBY.js → agent-guardrails-route-CN7vpC0X.js} +2 -2
  33. package/dist/owletto/dist/assets/{agent-list-row-rF5LH-3k.js → agent-list-row-BnP6r4pm.js} +2 -2
  34. package/dist/owletto/dist/assets/{agent-loading-shells-ClY_O6lb.js → agent-loading-shells-_18OREnx.js} +2 -2
  35. package/dist/owletto/dist/assets/{agent-permissions-matrix-bP1Qihv7.js → agent-permissions-matrix-DSjidWHL.js} +2 -2
  36. package/dist/owletto/dist/assets/{agent-skill-context-BAaGpvfS.js → agent-skill-context-1DBn7Xc_.js} +2 -2
  37. package/dist/owletto/dist/assets/{agent-skills-route-Bv5luNdw.js → agent-skills-route-d5jh3oBR.js} +2 -2
  38. package/dist/owletto/dist/assets/{agent-tab-intro-ednTs4WF.js → agent-tab-intro-DKrC3SQt.js} +2 -2
  39. package/dist/owletto/dist/assets/{agent-thread-WNk2HapT.js → agent-thread-FyEO-y44.js} +3 -3
  40. package/dist/owletto/dist/assets/agents-kXojozTU.js +2 -0
  41. package/dist/owletto/dist/assets/{agents-workbench-bPTjdVS1.js → agents-workbench-CDpJmUVN.js} +2 -2
  42. package/dist/owletto/dist/assets/{app._appId-DrL5H5lB.js → app._appId-DwNeXRJp.js} +2 -2
  43. package/dist/owletto/dist/assets/{assist-composer-ClfFEVx7.js → assist-composer-Mn9EfX4X.js} +2 -2
  44. package/dist/owletto/dist/assets/automation-detail-content-Bs3vwAPd.js +2 -0
  45. package/dist/owletto/dist/assets/{automation-row-DCHM--aD.js → automation-row-B5Q1B10y.js} +2 -2
  46. package/dist/owletto/dist/assets/automation-source-list-Dhucq1sI.js +2 -0
  47. package/dist/owletto/dist/assets/automations-kXojozTU.js +2 -0
  48. package/dist/owletto/dist/assets/{callback-DRABUOha.js → callback-9xSHyA12.js} +2 -2
  49. package/dist/owletto/dist/assets/{card-Bdi7VEwo.js → card-g4yxo4Hr.js} +2 -2
  50. package/dist/owletto/dist/assets/{change-summary-PBoM6Asb.js → change-summary-DeuXQEpb.js} +2 -2
  51. package/dist/owletto/dist/assets/{claim-CUIG1Oc-.js → claim-B98IhDra.js} +2 -2
  52. package/dist/owletto/dist/assets/{client-activity-scopes-CXOWB5co.js → client-activity-scopes-BD2HBo-_.js} +2 -2
  53. package/dist/owletto/dist/assets/{client-rows-36VnmgMK.js → client-rows-x_CxeWkP.js} +2 -2
  54. package/dist/owletto/dist/assets/{clients-BJRcMk1A.js → clients-Cmp0LmOp.js} +2 -2
  55. package/dist/owletto/dist/assets/connect-menu-CezOH3s7.js +2 -0
  56. package/dist/owletto/dist/assets/connect-zUot_0kG.js +2 -0
  57. package/dist/owletto/dist/assets/connect._clientId-nsGxe6yO.js +2 -0
  58. package/dist/owletto/dist/assets/connected._clientId-DnclRRXk.js +2 -0
  59. package/dist/owletto/dist/assets/connected._clientId.activity-CDB8atTX.js +2 -0
  60. package/dist/owletto/dist/assets/{connected._clientId.index-jSnGvzYs.js → connected._clientId.index-DBNP2mZo.js} +2 -2
  61. package/dist/owletto/dist/assets/{connection-q1bdnxCN.js → connection-B6fM2KHN.js} +2 -2
  62. package/dist/owletto/dist/assets/{connection-feed-detail-BIlkK0Pd.js → connection-feed-detail-Ckq-qEbD.js} +2 -2
  63. package/dist/owletto/dist/assets/{connections-browser-V-3td9DB.js → connections-browser-BXsJqieG.js} +2 -2
  64. package/dist/owletto/dist/assets/{connector-boxes-lFc-WP83.js → connector-boxes-CbqSFeVm.js} +2 -2
  65. package/dist/owletto/dist/assets/{connector-page-shell-Cs1SjrYB.js → connector-page-shell-Di6XzkVo.js} +2 -2
  66. package/dist/owletto/dist/assets/{connector-provenance-aJFeeRIC.js → connector-provenance-BrnasBW4.js} +2 -2
  67. package/dist/owletto/dist/assets/{connector-scope-lists--vNdbOn0.js → connector-scope-lists-dQnZARCD.js} +2 -2
  68. package/dist/owletto/dist/assets/{connectors-BsvDMdsQ.js → connectors-DnOUxX_U.js} +2 -2
  69. package/dist/owletto/dist/assets/{consent-DJV78pnz.js → consent-Byli4yMs.js} +2 -2
  70. package/dist/owletto/dist/assets/{copy-button-DjMWgrBf.js → copy-button-Ddf7lBjZ.js} +2 -2
  71. package/dist/owletto/dist/assets/{core.esm-CQzL3ObT.js → core.esm-BsXtvNoI.js} +2 -2
  72. package/dist/owletto/dist/assets/create-B34eskZ_.js +2 -0
  73. package/dist/owletto/dist/assets/create-DLB9sXgU.js +2 -0
  74. package/dist/owletto/dist/assets/{create-jBEuveV1.js → create-YdAnh3ml.js} +2 -2
  75. package/dist/owletto/dist/assets/create-automation-form-C9PMX7N8.js +3 -0
  76. package/dist/owletto/dist/assets/create._connectorKey-Bz4OYRiC.js +2 -0
  77. package/dist/owletto/dist/assets/definition-comparison-B5WgZILB.js +2 -0
  78. package/dist/owletto/dist/assets/{device-Ba3RsIgb.js → device-DdCoCj-Q.js} +2 -2
  79. package/dist/owletto/dist/assets/device-pin-tombstone-B06J7Af1.js +2 -0
  80. package/dist/owletto/dist/assets/device._deviceId-Bh9S4bFp.js +2 -0
  81. package/dist/owletto/dist/assets/dynamic-schema-form-qWSRtOAv.js +2 -0
  82. package/dist/owletto/dist/assets/{entity-options-daOOQo7O.js → entity-options-BkU_En_f.js} +2 -2
  83. package/dist/owletto/dist/assets/entity-page-BPFDHY8q.js +2 -0
  84. package/dist/owletto/dist/assets/entity-pages-DxgbjLMt.js +2 -0
  85. package/dist/owletto/dist/assets/entity-type-page-D0ghgRgq.js +2 -0
  86. package/dist/owletto/dist/assets/event-card-CjA_dLzq.js +2 -0
  87. package/dist/owletto/dist/assets/{event-detail-DkY95e5b.js → event-detail-CmC-DVrK.js} +2 -2
  88. package/dist/owletto/dist/assets/{events-feed-B9CZHI_P.js → events-feed-CGzA1w3R.js} +2 -2
  89. package/dist/owletto/dist/assets/filter-bar-CQ_oE7a9.js +2 -0
  90. package/dist/owletto/dist/assets/{full-page-spinner-BqmckkOf.js → full-page-spinner-B5xXnKtV.js} +2 -2
  91. package/dist/owletto/dist/assets/guardrails-DkXatmea.js +2 -0
  92. package/dist/owletto/dist/assets/identity-BwJy3ixB.js +2 -0
  93. package/dist/owletto/dist/assets/{index--ZWegctR.js → index-35ehGReZ.js} +2 -2
  94. package/dist/owletto/dist/assets/index-B9hYiwBw.js +2 -0
  95. package/dist/owletto/dist/assets/{index-C186T2Rw.js → index-BDl1_w6U.js} +2 -2
  96. package/dist/owletto/dist/assets/{index-ijqrJaRB.js → index-BdNR51Ua.js} +2 -2
  97. package/dist/owletto/dist/assets/{index-DdBTTN3y.js → index-BjcZVe7n.js} +52 -52
  98. package/dist/owletto/dist/assets/{index-CsrT07TJ.js → index-BqAVebvY.js} +2 -2
  99. package/dist/owletto/dist/assets/index-BvK1fS1J.js +2 -0
  100. package/dist/owletto/dist/assets/{index-DdYWarql.css → index-CNEpTkgw.css} +1 -1
  101. package/dist/owletto/dist/assets/index-CRc73k1t.js +2 -0
  102. package/dist/owletto/dist/assets/index-CYGaSD3y.js +2 -0
  103. package/dist/owletto/dist/assets/index-CfZGe-zn.js +2 -0
  104. package/dist/owletto/dist/assets/{index-B0kw2lFL.js → index-CkiyxW4w.js} +2 -2
  105. package/dist/owletto/dist/assets/index-CzLDNB2E.js +2 -0
  106. package/dist/owletto/dist/assets/{index-BKrdVwW9.js → index-D-o5iOVd.js} +2 -2
  107. package/dist/owletto/dist/assets/index-DjYVV1Ml.js +2 -0
  108. package/dist/owletto/dist/assets/{index-ikp_mTsf.js → index-TkPy_P_u.js} +2 -2
  109. package/dist/owletto/dist/assets/index-VyAX-asP.js +2 -0
  110. package/dist/owletto/dist/assets/json-diff-DtZtra_g.js +28 -0
  111. package/dist/owletto/dist/assets/{list-skeleton-CXDLkYTg.js → list-skeleton-CIHWCi2a.js} +2 -2
  112. package/dist/owletto/dist/assets/{login-u6LCgDYG.js → login-TWR0vF4_.js} +2 -2
  113. package/dist/owletto/dist/assets/{logout-JhmuWJEH.js → logout-BA5kojS0.js} +2 -2
  114. package/dist/owletto/dist/assets/{manage-gear-D8LMhehh.js → manage-gear-C-0BAMbC.js} +2 -2
  115. package/dist/owletto/dist/assets/{member-scope-gate-4FQ0aanZ.js → member-scope-gate-BQiRAqtx.js} +2 -2
  116. package/dist/owletto/dist/assets/memory-browse-page-Ba32-vVL.js +74 -0
  117. package/dist/owletto/dist/assets/{model-jL871x2J.js → model-C2q7WDcS.js} +2 -2
  118. package/dist/owletto/dist/assets/{model-selector-CgU8SJMF.js → model-selector-B2cjCn0V.js} +2 -2
  119. package/dist/owletto/dist/assets/models-CZkH5gtj.js +2 -0
  120. package/dist/owletto/dist/assets/{nav-pill-DrFkuyUQ.js → nav-pill-Bam6s3jj.js} +2 -2
  121. package/dist/owletto/dist/assets/new-BJst6K0b.js +2 -0
  122. package/dist/owletto/dist/assets/{new-DgE1pVV0.js → new-Dc5Bbotb.js} +2 -2
  123. package/dist/owletto/dist/assets/new-DgbivfDe.js +2 -0
  124. package/dist/owletto/dist/assets/{organization-CKM_oFX3.js → organization-B9U1L-56.js} +2 -2
  125. package/dist/owletto/dist/assets/peek-pane-content-Cq8P38s3.js +2 -0
  126. package/dist/owletto/dist/assets/{pending-seed-sml8Uf6e.js → pending-seed-BP3xHM2d.js} +2 -2
  127. package/dist/owletto/dist/assets/{permissions-BvA9SATv.js → permissions-BVlbeY4u.js} +2 -2
  128. package/dist/owletto/dist/assets/proposal-review-shell-BED-DO9C.js +2 -0
  129. package/dist/owletto/dist/assets/public-shell-ready-Diq15_QW.js +2 -0
  130. package/dist/owletto/dist/assets/{record-activity-C9gVBbF0.js → record-activity-CTLwq8s1.js} +2 -2
  131. package/dist/owletto/dist/assets/{record-session-R-uHNuby.js → record-session-DOFgdd43.js} +2 -2
  132. package/dist/owletto/dist/assets/renderer-CHPS-1vD.js +96 -0
  133. package/dist/owletto/dist/assets/{reset-password-Mx3baeNc.js → reset-password-BmNM-apc.js} +2 -2
  134. package/dist/owletto/dist/assets/{run-activity-link-CaIBSRQj.js → run-activity-link-Dh1YyCfk.js} +2 -2
  135. package/dist/owletto/dist/assets/{run-initiator-BvzQJYW9.js → run-initiator-CCxNv0rK.js} +2 -2
  136. package/dist/owletto/dist/assets/{runs-fFJ1lPnw.js → runs-BntGAKQG.js} +2 -2
  137. package/dist/owletto/dist/assets/{runs-panel-DEnZHTa5.js → runs-panel-BwTVaRsE.js} +2 -2
  138. package/dist/owletto/dist/assets/{runs-table-XGnxJl7S.js → runs-table-CYS1jDdL.js} +2 -2
  139. package/dist/owletto/dist/assets/{schema-type-editor-panel-C0_9VcSs.js → schema-type-editor-panel-v3nR2Oa2.js} +2 -2
  140. package/dist/owletto/dist/assets/schema-value-BFb7jCBo.js +3 -0
  141. package/dist/owletto/dist/assets/settings-DBgT60nY.js +2 -0
  142. package/dist/owletto/dist/assets/{settings-CP4PjMQA.js → settings-DubSpJfg.js} +2 -2
  143. package/dist/owletto/dist/assets/skills-DDoeRGhJ.js +2 -0
  144. package/dist/owletto/dist/assets/{source-record-panels-Bh0n4gGw.js → source-record-panels-m8gECt82.js} +2 -2
  145. package/dist/owletto/dist/assets/{status-dot-Cpq63I7p.js → status-dot-BnQPFrcU.js} +2 -2
  146. package/dist/owletto/dist/assets/{table-BUqshjxa.js → table-DALHuXPE.js} +2 -2
  147. package/dist/owletto/dist/assets/{use-automations-BLNjxq2K.js → use-automations-D9hKpufo.js} +2 -2
  148. package/dist/owletto/dist/assets/{use-login-redirect-CmyQW7GT.js → use-login-redirect-ciwfc-7A.js} +2 -2
  149. package/dist/owletto/dist/assets/{use-mention-search-dn3ws1WB.js → use-mention-search-CJGCatFS.js} +2 -2
  150. package/dist/owletto/dist/assets/{use-scroll-sentinel-DRyBMueA.js → use-scroll-sentinel-BWCrmNIB.js} +2 -2
  151. package/dist/owletto/dist/assets/view-param-filters-CDvwie_f.js +2 -0
  152. package/dist/owletto/dist/assets/views-access-required-CZ1fvAks.js +2 -0
  153. package/dist/owletto/dist/index.html +2 -2
  154. package/dist/server-main.bundle.mjs +5596 -4000
  155. package/npm-shrinkwrap.json +99 -99
  156. package/package.json +1 -1
  157. package/vendor/connector-sdk/package.json +1 -1
  158. package/vendor/core/dist/contracts/tools/view-host.d.ts +7 -0
  159. package/vendor/core/dist/contracts/tools/view-host.js +28 -0
  160. package/vendor/core/dist/contracts/tools/view-runtime.d.ts +2 -4
  161. package/vendor/core/dist/contracts/tools/view-runtime.js +19 -7
  162. package/vendor/core/package.json +11 -1
  163. package/vendor/views/dist/api.d.ts +9 -4
  164. package/vendor/views/dist/api.js +33 -2
  165. package/vendor/views/dist/bridge.d.ts +8 -0
  166. package/vendor/views/dist/bridge.js +12 -2
  167. package/vendor/views/dist/components.d.ts +4 -2
  168. package/vendor/views/dist/components.js +29 -14
  169. package/vendor/views/dist/index.d.ts +1 -1
  170. package/vendor/views/dist/index.js +1 -1
  171. package/vendor/views/dist/native.d.ts +327 -0
  172. package/vendor/views/dist/native.js +57 -0
  173. package/vendor/views/package.json +1 -1
  174. package/dist/owletto/dist/assets/_-CCWuGXtQ.js +0 -2
  175. package/dist/owletto/dist/assets/_-DOJW1D-I.js +0 -3
  176. package/dist/owletto/dist/assets/_agentId-CJhQbi6k.js +0 -2
  177. package/dist/owletto/dist/assets/_agentId-DD4K1i6V.js +0 -2
  178. package/dist/owletto/dist/assets/_automationId-Cbd7B0mP.js +0 -2
  179. package/dist/owletto/dist/assets/_connectorKey._connectionId-DFpPep9B.js +0 -2
  180. package/dist/owletto/dist/assets/_connectorKey.index-n3iSDT74.js +0 -2
  181. package/dist/owletto/dist/assets/_conversationId-B1yGIGA9.js +0 -2
  182. package/dist/owletto/dist/assets/_eventId-B1H0-vD7.js +0 -2
  183. package/dist/owletto/dist/assets/_name-D30_V03t.js +0 -2
  184. package/dist/owletto/dist/assets/_owner-Be8O41u8.js +0 -3
  185. package/dist/owletto/dist/assets/_shape-C6YbloRh.js +0 -2
  186. package/dist/owletto/dist/assets/_skillKey-BMPvvoOI.js +0 -2
  187. package/dist/owletto/dist/assets/_slug-Bc4YIEA2.js +0 -2
  188. package/dist/owletto/dist/assets/_view-aoFDwEld.js +0 -2
  189. package/dist/owletto/dist/assets/_viewKey-DuNHc3cc.js +0 -2
  190. package/dist/owletto/dist/assets/_viewKey-rJ7A1zNx.js +0 -2
  191. package/dist/owletto/dist/assets/agent-editor-form-CdA5vLr8.js +0 -2
  192. package/dist/owletto/dist/assets/agents-DY2S2SGE.js +0 -2
  193. package/dist/owletto/dist/assets/automation-detail-content-dFy1Huas.js +0 -2
  194. package/dist/owletto/dist/assets/automations-DY2S2SGE.js +0 -2
  195. package/dist/owletto/dist/assets/calendar-Ck0yOLYu.js +0 -2
  196. package/dist/owletto/dist/assets/code-editor-DNuRKde1.js +0 -16
  197. package/dist/owletto/dist/assets/connect-CMcEQWls.js +0 -2
  198. package/dist/owletto/dist/assets/connect-menu-C-B-1xGR.js +0 -2
  199. package/dist/owletto/dist/assets/connect._clientId-tGipxP5a.js +0 -2
  200. package/dist/owletto/dist/assets/connected._clientId-DSGU78eV.js +0 -2
  201. package/dist/owletto/dist/assets/connected._clientId.activity-CPLbry8R.js +0 -2
  202. package/dist/owletto/dist/assets/create-BmKx5vq3.js +0 -2
  203. package/dist/owletto/dist/assets/create-Rt0RbiD4.js +0 -2
  204. package/dist/owletto/dist/assets/create-automation-form-PEmSLMD6.js +0 -3
  205. package/dist/owletto/dist/assets/create._connectorKey-DcxhYIYC.js +0 -2
  206. package/dist/owletto/dist/assets/device-pin-tombstone-C79KIAIK.js +0 -2
  207. package/dist/owletto/dist/assets/device._deviceId-CIaoq9co.js +0 -2
  208. package/dist/owletto/dist/assets/entity-avatar-TVKjZxWQ.js +0 -2
  209. package/dist/owletto/dist/assets/entity-page-BfJXvbxn.js +0 -2
  210. package/dist/owletto/dist/assets/entity-type-page-BLwH6qa7.js +0 -2
  211. package/dist/owletto/dist/assets/event-card-DVUB8my6.js +0 -2
  212. package/dist/owletto/dist/assets/filter-bar-wPaR12SS.js +0 -2
  213. package/dist/owletto/dist/assets/guardrails-Csusrok2.js +0 -2
  214. package/dist/owletto/dist/assets/identity-Dmg3STO8.js +0 -2
  215. package/dist/owletto/dist/assets/index-BUBcNNUY.js +0 -2
  216. package/dist/owletto/dist/assets/index-BUDr4-Yv.js +0 -2
  217. package/dist/owletto/dist/assets/index-BYPQWVwD.js +0 -2
  218. package/dist/owletto/dist/assets/index-BfpaPJPj.js +0 -2
  219. package/dist/owletto/dist/assets/index-BicNFLBW.js +0 -2
  220. package/dist/owletto/dist/assets/index-Bsdv5aks.js +0 -2
  221. package/dist/owletto/dist/assets/index-CX0pJ9j9.js +0 -2
  222. package/dist/owletto/dist/assets/index-JYEIN8nM.js +0 -2
  223. package/dist/owletto/dist/assets/json-diff-BaLL4Fsu.js +0 -14
  224. package/dist/owletto/dist/assets/memory-browse-page-CNZJbCJC.js +0 -74
  225. package/dist/owletto/dist/assets/models-jdemgIZk.js +0 -2
  226. package/dist/owletto/dist/assets/new-CcJOd5aH.js +0 -2
  227. package/dist/owletto/dist/assets/new-OWwrYckd.js +0 -2
  228. package/dist/owletto/dist/assets/peek-pane-content-D68BjguQ.js +0 -2
  229. package/dist/owletto/dist/assets/proposal-review-shell-D6KABxah.js +0 -2
  230. package/dist/owletto/dist/assets/public-shell-ready-BIVCHQHe.js +0 -2
  231. package/dist/owletto/dist/assets/renderer-DXfJaCCa.js +0 -97
  232. package/dist/owletto/dist/assets/settings-CgaUJMHH.js +0 -2
  233. package/dist/owletto/dist/assets/skills-D-e_h3a9.js +0 -2
  234. package/dist/owletto/dist/assets/view-param-filters-CER47Tlz.js +0 -2
  235. package/dist/owletto/dist/assets/views-access-required-C_b9itZ2.js +0 -2
@@ -1,74 +0,0 @@
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
@@ -1,2 +0,0 @@
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
@@ -1,2 +0,0 @@
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 +0,0 @@
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
@@ -1,2 +0,0 @@
1
- import{jr as H,js as q,r as f,hz as V,u as A,j as e,dw as U,aB as G,aH as W,S as b,iL as Q,B as N,jt as Y,ju as C,jv as Z,jw as R,jx as z,jy as J,d3 as X,o as S,aq as D,cm as B,ab as I,eP as ee,v as te,l as se,g1 as ne,w as re,L as $,jz as ie,fI as oe,g4 as ae,fY as ce,jA as le,ga as E,cz as de,az as ue,jB as me,at as pe,k as xe,jC as he,cP as fe,dZ as ye,cQ as ge,p as je,gx as ve,eJ as Ne,jD as we,e5 as be,jE as ke,eO as Ae,a0 as Ce,jF as Se}from"./index-DdBTTN3y.js";import{u as Ie,A as Pe}from"./automation-detail-content-dFy1Huas.js";import{A as Le}from"./agent-loading-shells-ClY_O6lb.js";import{s as _e,h as Re,R as Te,A as $e}from"./agent-thread-WNk2HapT.js";import{C as Ee,b as Oe,A as ze}from"./connection-feed-detail-BIlkK0Pd.js";import{O as De}from"./connect-menu-C-B-1xGR.js";import{a as Be}from"./connections-browser-V-3td9DB.js";import{f as Fe}from"./connector-scope-lists--vNdbOn0.js";import{S as Me}from"./source-record-panels-Bh0n4gGw.js";import{E as T}from"./events-feed-B9CZHI_P.js";import{S as Ke}from"./schema-type-editor-panel-C0_9VcSs.js";import{h as He,s as qe,i as Ve}from"./renderer-DXfJaCCa.js";import{E as Ue}from"./event-detail-DkY95e5b.js";import{V as Ge,R as We}from"./views-access-required-C_b9itZ2.js";import{R as Qe,b as Ye}from"./event-card-DVUB8my6.js";import{V as Ze,a as Je}from"./view-param-filters-CER47Tlz.js";import{S as Xe,g as et}from"./runs-table-XGnxJl7S.js";import{R as tt}from"./runs-panel-DEnZHTa5.js";import{b as st}from"./use-automations-BLNjxq2K.js";import{b as nt}from"./model-jL871x2J.js";import"./create-automation-form-PEmSLMD6.js";import"./entity-options-daOOQo7O.js";import"./connection-label-BobuYiAG.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";import"./proposal-review-shell-D6KABxah.js";import"./runs-fFJ1lPnw.js";import"./app-bridge-C4nPtae3.js";import"./pending-seed-sml8Uf6e.js";import"./feed-event-kinds-BYuZCoU4.js";import"./status-dot-Cpq63I7p.js";import"./client-activity-scopes-CXOWB5co.js";import"./client-rows-36VnmgMK.js";import"./use-scroll-sentinel-DRyBMueA.js";import"./entity-type-page-BLwH6qa7.js";import"./change-summary-PBoM6Asb.js";import"./calendar-Ck0yOLYu.js";import"./table-BUqshjxa.js";import"./card-Bdi7VEwo.js";import"./record-session-R-uHNuby.js";import"./run-initiator-BvzQJYW9.js";import"./clients-BJRcMk1A.js";import"./copy-button-DjMWgrBf.js";import"./agent-list-row-rF5LH-3k.js";import"./automation-row-DCHM--aD.js";import"./filter-bar-wPaR12SS.js";import"./manage-gear-D8LMhehh.js";function rt(t){const n=[];return t.forEach((s,r)=>{n.push({id:`sep:${s.runId}`,role:"system",parts:[{type:"text",text:it(s,r)}],createdAt:s.completedAt?new Date(s.completedAt).getTime():void 0});for(const i of s.messages)n.push({...i,id:`r${s.runId}:${i.id}`})}),n}function it(t,n){const s=(t.pendingActionCount??0)>0?`Waiting for you (${t.pendingActionCount})`:t.status==="completed"?"Completed":t.status??"Completed",r=(t.autoAppliedCount??0)>0?` · ${t.autoAppliedCount} applied automatically`:"",i=t.completedAt?new Date(t.completedAt).toLocaleString():null;return i?`Run ${n+1} · ${s}${r} · ${i}`:`Run ${n+1} · ${s}${r}`}const F=Symbol("trusted-automation-interaction");function ot(t){return Object.defineProperty(t,F,{value:!0}),t}function at(t){return{title:`${t} items waiting for you`,icon:"entity",impact:{level:"normal"},tone:"default",blocks:[{type:"text",value:"Review the individual proposals below, or decide the whole run at once.",muted:!0}],actions:[{id:"approve-all",label:"Approve all",variant:"primary",icon:"check",confirm:!0,confirmPrompt:`Approve all ${t} proposals?`,tool:"manage_operations",args:{action:"approve"},resolvedLabel:`Approved all ${t} proposals.`},{id:"reject-all",label:"Reject all",variant:"outline",icon:"x",confirm:!0,confirmPrompt:`Reject all ${t} proposals?`,tool:"manage_operations",args:{action:"reject"},resolvedLabel:`Rejected all ${t} proposals.`}]}}const ct=new Set(["automation-approval-batch"]);function lt(t){return new Promise(n=>{t({onSettled:(s,r)=>n(!!r)})})}function dt(){const t=H(),n=q();return f.useMemo(()=>({toolNames:ct,resolve:(s,r)=>{if(!r||typeof r!="object"||r[F]!==!0)return null;const i=r;if(s==="automation-approval-batch"){const o=typeof i.runId=="number"&&Number.isSafeInteger(i.runId)&&i.runId>0?i.runId:null,c=typeof i.count=="number"&&Number.isSafeInteger(i.count)&&i.count>1?i.count:null,a=Array.isArray(i.runIds)?i.runIds.filter(l=>typeof l=="number"&&Number.isSafeInteger(l)&&l>0):[];return o===null||c===null||a.length!==c||new Set(a).size!==c?null:{view:at(c),handlers:{manage_operations:l=>l.action!=="approve"&&l.action!=="reject"?Promise.resolve(!0):lt(p=>l.action==="approve"?t.mutate({run_id:o,run_ids:a},p):n.mutate({run_id:o,run_ids:a},p))}}}return null}}),[t,n])}const ut=/(?:^|\n)Run this Automation now/;function mt(t){return t.role==="user"&&t.parts.some(n=>n.type==="text"&&ut.test(n.text))}function pt(t){return`history-interaction:${t.runId}:${t.eventId??"error"}`}function xt({agentId:t,automationId:n,ownerSlug:s,runId:r}){const{data:i,isLoading:o}=V(t,n,{orgSlug:s,...r!=null?{runId:r}:{}}),c=dt(),a=A(),l=f.useCallback(d=>{a?.open({href:`/${s}/automations/${n}?view=activity&run_id=${d}`,title:`Automation run #${d}`,runId:d})},[a,s,n]),p=f.useMemo(()=>{const d=i?.runs??[],j=(r!=null?d.filter(m=>m.runId===r):d).slice().reverse();return rt(j.map(m=>{const g=m.messages.map(u=>_e(u,{showToolCalls:!0})).filter(u=>u!==null&&!mt(u));m.task?.trim()&&g.unshift({id:"task",role:"user",parts:[{type:"text",text:m.task.trim()}]});const v=m.actions??[],h=v.filter(u=>u.status==="pending");if(h.length>1){const u=h.map(x=>x.runId).sort((x,k)=>x-k);g.push({id:"approval-batch",role:"assistant",parts:[{type:"tool-call",toolCallId:`approval-batch-${m.runId}`,toolName:"automation-approval-batch",args:ot({runId:m.runId,count:h.length,runIds:u})}]})}for(const u of v){const x=Re([u],{workspaceSlug:s,agentId:t,webOrigin:typeof window>"u"?null:window.location.origin});x&&g.push({...x,id:pt(u)})}return{runId:m.runId,completedAt:m.completedAt,status:m.status,pendingActionCount:m.pendingActionCount,autoAppliedCount:m.autoAppliedCount,messages:g}}))},[t,i,s,r]);return o?e.jsx(Le,{readOnly:!0}):p.length===0?e.jsx("p",{className:"text-sm text-muted-foreground",children:"No run transcripts yet. Recent runs will show here when the Automation fires (failed runs appear with their prompt even without a full transcript)."}):e.jsx("div",{className:"flex h-[calc(100dvh-12rem)] min-h-[24rem] min-w-0 flex-1 flex-col",children:e.jsx(Te,{messages:p,workspaceSlug:s,children:e.jsx($e,{readOnly:!0,readerPositionMode:"runs",interactionExtension:c,onRunSelect:r==null&&a?l:void 0})})})}function ht(t){if(!t||typeof t!="object")return[];const n=t.properties;if(!n)return[];const s=Array.isArray(t.required)?new Set(t.required.map(String)):new Set;return Object.entries(n).map(([r,i])=>({name:r,type:String(i.type??"any"),required:s.has(r),description:typeof i.description=="string"?i.description:void 0}))}function ft({fields:t}){return t.length===0?e.jsx("p",{className:"text-xs text-muted-foreground",children:"No fields."}):e.jsx("ul",{className:"space-y-2",children:t.map(n=>e.jsxs("li",{className:"space-y-0.5",children:[e.jsxs("div",{className:"flex flex-wrap items-baseline gap-x-2",children:[e.jsx("code",{className:"text-xs font-medium text-foreground",children:n.name}),e.jsx("span",{className:"text-[10px] uppercase tracking-wide text-muted-foreground/70",children:n.type}),n.required?e.jsx("span",{className:"text-[10px] font-medium text-amber-600 dark:text-amber-400",children:"required"}):null]}),n.description?e.jsx("p",{className:"text-xs text-muted-foreground",children:n.description}):null]},n.name))})}function P({item:t,hideHeading:n=!1}){const s=t.schemaSections;return s?e.jsxs("article",{className:n?"space-y-4":"space-y-4 px-5 py-5",children:[!n&&e.jsxs("div",{className:"flex items-start gap-3",children:[e.jsx(U,{className:"mt-0.5 h-4 w-4 shrink-0 text-muted-foreground"}),e.jsxs("div",{className:"min-w-0 flex-1 space-y-1",children:[e.jsx("h2",{className:"text-base font-medium text-foreground",children:t.title}),s.description?e.jsx("p",{className:"text-xs text-muted-foreground",children:s.description}):null]})]}),s.sections.map(r=>{const i=ht(r.schema);return e.jsxs("section",{className:"space-y-1.5",children:[e.jsxs("div",{className:"flex items-baseline gap-2",children:[e.jsx("h3",{className:"text-xs font-medium uppercase tracking-wide text-muted-foreground",children:r.title}),r.description?e.jsx("span",{className:"truncate text-xs text-muted-foreground",children:r.description}):null]}),e.jsx(ft,{fields:i})]},r.title)})]}):null}function yt({panel:t}){const n=G(t.organizationId),s=t.section==="connections"||!!t.connectionId,r=W(t.organizationId,{connectorKey:t.connectorKey,connectionIds:t.connectionId?[t.connectionId]:void 0,enabled:s}),i=n.data?.find(c=>c.key===t.connectorKey),o=r.data?.find(c=>c.id===t.connectionId&&c.connector_key===t.connectorKey);return n.isLoading||s&&r.isLoading?e.jsx("div",{className:"p-5",children:e.jsx(b,{className:"h-28 w-full"})}):n.isError||s&&r.isError?e.jsx("p",{role:"alert",className:"p-5 text-sm",children:"Could not load this connector. Close the pane and try again."}):t.connectionId&&!o||!i&&!o&&t.section!=="connections"?e.jsx("p",{className:"p-5 text-sm",children:"This connection is no longer available."}):e.jsx("div",{className:"p-5",children:t.section==="connections"?e.jsx(Be,{connections:r.data??[],connector:i,connectorKey:t.connectorKey,ownerSlug:t.ownerSlug}):o?e.jsx(vt,{connection:o,connector:i,panel:t}):i?t.section==="oauth-apps"?e.jsx(De,{connector:i,organizationId:t.organizationId,newApp:!!t.newApp}):t.section==="feeds"?e.jsx(gt,{connector:i}):i.installed===!1?e.jsx(jt,{connector:i,ownerSlug:t.ownerSlug}):e.jsx(wt,{connector:i,ownerSlug:t.ownerSlug}):null},`${t.connectorKey}:${t.connectionId??"connector"}:${t.section}`)}function gt({connector:t}){const n=Object.entries(t.feeds_schema??{}).map(([s,r])=>{const i=r;return{id:s,name:i.name??s,description:i.description,feed:i}});return e.jsx(C,{entries:n,label:"feed types",renderDetail:({name:s,feed:r})=>e.jsx(P,{item:{href:"",title:s,schemaSections:Z(r)},hideHeading:!0})})}function jt({connector:t,ownerSlug:n}){const s=Object.entries(t.actions_schema??{}).map(([r,i])=>{const o=i;return{id:r,name:o.name??r,description:o.description,action:o}});return e.jsxs("div",{className:"space-y-4",children:[e.jsxs("p",{className:"text-sm text-muted-foreground",children:["Policy depends on connection."," ",e.jsx(R,{ownerSlug:n,connectorKey:t.key})]}),e.jsx(C,{entries:s,label:"actions",renderDetail:({name:r,action:i})=>e.jsx(P,{hideHeading:!0,item:{href:"",title:r,schemaSections:z(i)}})})]})}function vt({connection:t,connector:n,panel:s}){const[r,i]=f.useState(!1);return e.jsxs(e.Fragment,{children:[e.jsx("div",{hidden:r,children:s.section==="feeds"?e.jsx(Nt,{connection:t,connector:n,ownerSlug:s.ownerSlug}):e.jsx(Q,{connection:t,ownerSlug:s.ownerSlug,inPeek:!0,onReviewPermissions:n?()=>i(!0):void 0})}),r&&n&&e.jsxs("div",{className:"space-y-4",children:[e.jsx(N,{variant:"ghost",size:"sm",onClick:()=>i(!1),children:"Back to actions"}),e.jsx("h2",{className:"text-base font-semibold",children:"Provider permissions"}),e.jsx(Y,{connection:t,connectorDef:n})]})]})}function Nt({connection:t,connector:n,ownerSlug:s}){const{data:r=[],isLoading:i,isError:o}=X(t.id),[c,a]=f.useState(!1),l=t.facets?.chat??!1;if(i)return e.jsx(b,{className:"h-28 w-full"});if(o)return e.jsx("p",{role:"alert",children:"Could not load sources. Close the pane and try again."});const p=r.map(d=>({id:String(d.id),name:d.display_name||d.feed_key,status:Fe(d)??(d.operations.includes("sync")?"Sync enabled":"Live access"),feed:d}));return e.jsxs(e.Fragment,{children:[e.jsx("div",{hidden:c,children:e.jsx(C,{entries:p,label:l?"channels":"feeds",action:Object.keys(n?.feeds_schema??{}).length>0?e.jsx(N,{size:"sm",variant:"outline",onClick:()=>a(!0),children:l?"Add channel":"Add feed"}):void 0,renderDetail:({feed:d})=>d.store==="channel_messages"?e.jsx(Ee,{feed:d,hideHeader:!0}):e.jsx(Oe,{feed:d,connectorDef:n,ownerSlug:s})})}),c&&n&&e.jsxs("div",{className:"space-y-4",children:[e.jsx("h2",{className:"text-base font-semibold",children:l?"Add channel":"Add feed"}),e.jsx(ze,{organizationId:t.organization_id,connections:[t],connectorDefinitions:[n],onClose:()=>a(!1)})]})]})}function wt({connector:t,ownerSlug:n}){const{data:s=[],isLoading:r,isError:i}=J(t.key);if(r)return e.jsx(b,{className:"h-28 w-full"});if(i)return e.jsx("p",{role:"alert",children:"Could not load actions. Close the pane and try again."});const o=t.actions_schema??{},c=s.map(a=>({id:a.operation_key,name:a.name??a.operation_key,description:a.description,operation:a}));return e.jsxs("div",{className:"space-y-4",children:[e.jsxs("p",{className:"text-sm text-muted-foreground",children:["Policy depends on connection. Click an action to inspect its inputs."," ",e.jsx(R,{ownerSlug:n,connectorKey:t.key})]}),e.jsx(C,{entries:c,label:"actions",renderControl:()=>e.jsx(R,{ownerSlug:n,connectorKey:t.key}),renderDetail:({operation:a,name:l})=>o[a.operation_key]?e.jsx(P,{hideHeading:!0,item:{href:"",title:l,schemaSections:z(o[a.operation_key])}}):e.jsx("p",{className:"text-sm text-muted-foreground",children:"No input fields."})})]})}function bt({owner:t,path:n}){const{data:s,isLoading:r}=S(t,{slug:t}),i=s?.workspace,o=i?.type==="organization"?i.id:null,c=o?{slug:t}:void 0,{data:a,isLoading:l}=D(`/${t}/${B(n)}`,c),p=a?.entity,d=p?.id;return r||l?e.jsxs("div",{className:"flex items-center justify-center py-12 text-muted-foreground",children:[e.jsx(I,{className:"mr-2"})," Loading…"]}):o?d==null?e.jsx("p",{className:"px-4 py-8 text-center text-sm text-muted-foreground",children:"Couldn't find this record. It may have been deleted, or it may live in a workspace you can't access."}):p?.is_derived?e.jsx(Me,{record:{type:p.entity_type,key:p.slug},orgContext:c}):e.jsx("div",{className:"px-4 py-4",children:e.jsx(T,{organizationId:o,ownerSlug:t,entityId:typeof d=="number"?d:void 0,filters:{sortBy:"date",sortOrder:"desc"},emptyState:e.jsx("div",{className:"px-4 py-8 text-center text-sm text-muted-foreground",children:"Nothing has happened to this record yet."})})}):e.jsx("p",{className:"px-4 py-8 text-center text-sm text-muted-foreground",children:"Couldn't resolve this workspace."})}function kt(t){if(Array.isArray(t.enum))return`One of ${t.enum.length}`;if(t.format==="date"||t.format==="date-time")return"Date";if(t.format==="uri")return"Link";if(t.format==="email")return"Email";const n=Array.isArray(t.type)?t.type[0]:t.type;return n==="array"?"List":n==="object"?"Group":n==="integer"||n==="number"?"Number":n==="boolean"?"Yes / no":"Text"}function At({owner:t,typeSlug:n,view:s}){const{data:r,isLoading:i}=S(t,{slug:t}),o=r?.workspace,c=o?.type==="organization"?o.id:null,{isAdmin:a}=ee(c??void 0),{orgContext:l}=te(),{data:p,isSuccess:d}=se(l),y=(p??[]).find(w=>w.slug===n),j=d&&!y,m=`/${t}/${ne(n)}`,{pathname:g}=re(),v=g===m||g===`${m}/`||g.startsWith(`${m}/-/`),h=f.useMemo(()=>He(y?.metadata_schema),[y?.metadata_schema]),u=A(),x=u?.close;f.useEffect(()=>{j&&x?.()},[j,x]);const k=f.useMemo(()=>({entityTypes:[n],sortBy:"date",sortOrder:"desc"}),[n]);if(i)return e.jsxs("div",{className:"flex items-center justify-center py-12 text-muted-foreground",children:[e.jsx(I,{className:"mr-2"})," Loading…"]});if(j)return e.jsx("p",{className:"px-4 py-8 text-center text-sm text-muted-foreground",children:"This entity type no longer exists."});if(!c)return e.jsx("p",{className:"px-4 py-8 text-center text-sm text-muted-foreground",children:"Couldn't resolve this workspace."});const K=y?.name??n;return e.jsxs("div",{className:"flex flex-col",children:[e.jsxs("div",{className:"flex items-center gap-2 border-b border-border px-4 py-2.5",children:[v?null:e.jsx(N,{asChild:!0,variant:"outline",size:"sm",className:"h-8 text-xs",children:e.jsxs($,{...oe(t,n),children:[e.jsx(ie,{className:"mr-1.5 h-3.5 w-3.5"}),"Browse records"]})}),y&&!v&&!ae(y)&&y.entity_count!==0?e.jsx(N,{asChild:!0,variant:"outline",size:"sm",className:"h-8 text-xs",children:e.jsxs($,{to:"/$owner/$entityType/-/$shape",params:{owner:t,entityType:n,shape:"graph"},search:le(E(t,n)),children:[e.jsx(ce,{className:"mr-1.5 h-3.5 w-3.5"}),"Graph"]})}):null,s!=="activity"&&u?e.jsxs(N,{type:"button",variant:"ghost",size:"sm",className:"ml-auto h-8 gap-1.5 text-xs text-muted-foreground hover:text-foreground",onClick:()=>u.open({href:E(t,n,"activity"),title:`${K} activity`}),children:[e.jsx(de,{className:"h-3.5 w-3.5"}),"Activity"]}):null]}),s==="activity"?e.jsx("div",{className:"px-4 py-4",children:e.jsx(T,{organizationId:c,ownerSlug:t,filters:k,showEntityLinks:!0,emptyState:e.jsx("div",{className:"px-4 py-8 text-center text-sm text-muted-foreground",children:"Nothing has happened to these records yet."})})}):a?e.jsx("div",{className:"p-4",children:e.jsx(Ke,{slug:n,onClose:()=>x?.()})}):h.length>0?e.jsxs("section",{"aria-labelledby":"entity-type-peek-fields",className:"px-4 py-4",children:[e.jsx("h3",{id:"entity-type-peek-fields",className:"mb-1.5 text-xs font-semibold uppercase tracking-wide text-muted-foreground",children:"Fields"}),e.jsx("dl",{className:"divide-y divide-border/60 text-sm",children:h.map(w=>e.jsxs("div",{className:"flex items-baseline justify-between gap-3 py-1.5",title:w.prop.description,children:[e.jsx("dt",{className:"min-w-0 truncate",children:qe(w)}),e.jsx("dd",{className:"shrink-0 text-xs text-muted-foreground",children:kt(w.prop)})]},w.key))})]}):e.jsx("p",{className:"px-4 py-8 text-center text-sm text-muted-foreground",children:"This type has no fields yet."})]})}function Ct({owner:t,eventId:n,viewKey:s}){const r=A(),i=(o,c)=>e.jsx(Ue,{owner:c,organizationId:o,eventId:n,viewKey:s,dense:!0,onSelectView:r?a=>r.retarget(a):void 0},`${c}/${n}/${s??""}`);return e.jsx("div",{className:"px-4 py-4",children:t==="me"?i(null,t):e.jsx(ue,{owner:t,children:({organizationId:o,ownerSlug:c})=>o?i(o,c):e.jsx("div",{className:"h-40 animate-pulse rounded-md bg-muted/40"})})})}function L({owner:t,runId:n,runIds:s,contentIds:r}){const{data:i,isLoading:o}=S(t==="me"?null:t,{slug:t}),c=i?.workspace,a=t!=="me"&&c?.type==="organization"?c.id:null,l=f.useMemo(()=>{if(t==="me")return r?.length?{contentIds:r,sortBy:"date",sortOrder:"desc"}:void 0;const d=s??(n!=null?[n]:void 0);if(!(!d?.length&&!r?.length))return{...d?.length?{runIds:d}:{},...r?.length?{contentIds:r}:{}}},[t,r,n,s]),p=l!=null;return t!=="me"&&o?e.jsxs("div",{className:"flex items-center justify-center py-12 text-muted-foreground",children:[e.jsx(I,{className:"mr-2"})," Loading…"]}):t!=="me"&&a==null?e.jsx("div",{className:"px-4 py-8 text-center text-sm text-muted-foreground",children:"Couldn't resolve this workspace."}):p?e.jsx("div",{className:"px-4 py-4",children:e.jsx(T,{presentation:"detail",organizationId:a,ownerSlug:t,filters:l,emptyState:e.jsx("div",{className:"px-4 py-8 text-center text-sm text-muted-foreground",children:n!=null||s?.length?"No matching events from this run yet.":"No matching events yet."})})}):e.jsx("div",{className:"px-4 py-8 text-center text-sm text-muted-foreground",children:"Nothing to preview."})}const _=25;function St({target:t}){const[n,s]=f.useState(0),{data:r,isLoading:i,isError:o,refetch:c}=me(t.entityId,t.orgContext,{relationshipType:t.relationshipType,limit:_,offset:n}),a=r?.total;return e.jsxs("div",{className:"space-y-3 px-5 py-4",children:[e.jsxs("p",{className:"text-xs text-muted-foreground",children:[t.label," · ",t.entityName,a!==void 0?` · ${a} current ${a===1?"link":"links"}`:r?` · ${r.rows.length} shown`:""]}),e.jsx(Qe,{count:r?.failures?.length??0,onRetry:()=>void c()}),i?e.jsxs("div",{className:"space-y-2",children:[e.jsx(b,{className:"h-6 w-full"}),e.jsx(b,{className:"h-6 w-full"})]}):o||!r?e.jsxs("p",{className:"text-sm text-muted-foreground",children:["Could not load these links."," ",e.jsx("button",{type:"button",className:"underline",onClick:()=>void c(),children:"Retry"})]}):r.rows.length===0?e.jsx("p",{className:"text-sm text-muted-foreground",children:"No links on this page."}):e.jsx("ul",{className:"divide-y divide-border",children:r.rows.map(l=>e.jsx("li",{className:"flex items-center justify-between gap-3 py-1.5",children:e.jsx(Ye,{row:l,entityId:t.entityId,ownerSlug:t.ownerSlug,orgContext:t.orgContext})},l.id))}),r&&(n>0||r.hasMore)?e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsx(N,{type:"button",variant:"outline",size:"sm",disabled:n===0,onClick:()=>s(Math.max(0,n-_)),children:"Previous"}),e.jsxs("span",{className:"text-xs tabular-nums text-muted-foreground",children:[r.rows.length," shown",a===void 0?"":` of ${a}`]}),e.jsx(N,{type:"button",variant:"outline",size:"sm",disabled:!r.hasMore,onClick:()=>s(n+_),children:"Next"})]}):null]})}function It({owner:t,path:n,viewKey:s}){const[r,i]=f.useState({}),{data:o,isLoading:c}=S(t,{slug:t}),a=o?.workspace,l=a?.type==="organization"?a.id:null,p=l?{slug:t,organizationId:l}:void 0,{data:d,isLoading:y}=D(`/${t}/${B(n)}`,p),{isMember:j,isPublic:m,isLoading:g}=pe(t),v=j||m,h=xe({slug:t,organizationId:j?l:null}),u=d?.entity;if(c||y||g||v&&h.isLoading)return e.jsxs("div",{className:"flex items-center justify-center py-12 text-muted-foreground",children:[e.jsx(I,{className:"mr-2"})," Loading…"]});if(!v)return e.jsx(Ge,{});if(h.isError)return e.jsx(Ze,{onRetry:()=>void h.refetch()});const x=u?he(h.data??[],{type:u.entity_type,id:u.id??u.slug}).find(k=>k.key===s):void 0;return!l||!u||!x?e.jsx("p",{className:"px-4 py-8 text-center text-sm text-muted-foreground",children:"This view isn't attached to this record any more."}):e.jsx("div",{className:"px-4 py-4",children:e.jsx(Je,{orgSlug:t,viewKey:x.key,scope:{type:u.entity_type,entity:u.is_derived?u.slug:u.id??u.slug},params:r,onParamsChange:i,contentHash:x.content_hash,title:x.name,minHeight:320})})}function M({owner:t,runId:n}){const s=fe({queryKey:["run-outcome",t,n],queryFn:async()=>{const i=await ge("manage_operations",{action:"get_run",run_id:n},{slug:t});if(!i.run)throw new Error(i.error||"Run not found");return i.run},enabled:t!=="me",staleTime:15e3,refetchInterval:i=>["pending","claimed","running"].includes(i.state.data?.status??"")?5e3:!1});if(t==="me")return null;if(s.isLoading)return e.jsx("p",{role:"status",className:"px-4 pt-4 text-xs text-muted-foreground",children:"Loading run…"});if(!s.data)return e.jsx("p",{role:"alert",className:"px-4 pt-4 text-sm text-destructive",children:"Could not load this run."});const r=s.data;return e.jsxs("section",{"aria-label":"Run outcome",className:"space-y-2 border-b px-4 py-4",children:[e.jsxs("div",{className:"flex flex-wrap items-center gap-2",children:[e.jsx(Xe,{status:et(r.status),children:r.status}),e.jsx("time",{dateTime:r.created_at,className:"text-xs text-muted-foreground",children:ye(r.created_at)})]}),r.connection_display_name?e.jsx("p",{className:"text-sm",children:r.connection_display_name}):null,r.error_message?e.jsx("p",{className:"whitespace-pre-wrap break-words text-sm text-destructive",children:r.error_message}):null,s.isError?e.jsx("p",{role:"alert",className:"text-xs text-destructive",children:"Could not refresh this run. Showing its last known outcome."}):null]})}function Is({item:t}){const n=A();if(t.connectorPanel)return e.jsx(yt,{panel:t.connectorPanel});if(t.schemaSections)return e.jsx(P,{item:t});if(t.recordField)return e.jsx(We,{target:t.recordField});if(t.recordPeer)return e.jsx(Ve,{target:t.recordPeer});if(t.recordLinks)return e.jsx(St,{target:t.recordLinks});if(typeof t.browserUrl=="string"&&t.browserUrl.length>0)return e.jsx(O,{item:t});const s=t.href?je(t.href):null;return s?s.kind==="runs"?e.jsx("section",{"aria-label":"Runs history",className:"p-4",children:e.jsx(tt,{scope:{workspace:!0},ownerSlug:s.owner,filterState:s.filters,onFilterChange:r=>n?.retarget(ve(s.owner,r))})}):s.kind==="memory"?"runId"in s?e.jsxs(e.Fragment,{children:[e.jsx(M,{owner:s.owner,runId:s.runId}),e.jsx(L,{owner:s.owner,runId:s.runId})]}):"runIds"in s?e.jsx(L,{owner:s.owner,runIds:s.runIds}):e.jsx(L,{owner:s.owner,contentIds:s.contentIds}):s.kind==="entity"?e.jsx(bt,{owner:s.owner,path:s.path}):s.kind==="entity-type"?e.jsx(At,{owner:s.owner,typeSlug:s.typeSlug,view:s.view}):s.kind==="record-view"?e.jsx(It,{owner:s.owner,path:s.path,viewKey:s.viewKey}):s.kind==="event"?e.jsx(Ct,{owner:s.owner,eventId:s.eventId,viewKey:s.viewKey}):t.runId?e.jsx(Pt,{owner:s.owner,automationId:s.automationId,runId:t.runId}):e.jsx(Lt,{owner:s.owner,automationId:s.automationId}):e.jsx(O,{item:t})}function O({item:t}){const n=t.body,s=t.notificationType??"generic",r=t.createdAt,i=t.browserUrl??null,o=t.browserHandoff??null;return e.jsxs("article",{className:"space-y-4 px-5 py-5",children:[e.jsxs("div",{className:"flex items-start gap-3",children:[e.jsx(Ne,{className:"mt-0.5 h-4 w-4 shrink-0 text-muted-foreground"}),e.jsxs("div",{className:"flex flex-wrap items-center gap-2 pt-0.5 text-xs text-muted-foreground",children:[e.jsx("span",{children:we(s)}),r?e.jsx("span",{children:be(r)}):null]})]}),n?e.jsx("div",{className:"text-sm leading-6 text-foreground/90",children:e.jsx(ke,{text:n,linkPolicy:s==="action_approval_needed"?"app-links":"strip"})}):e.jsx("p",{className:"text-sm text-muted-foreground",children:"No additional details were provided."}),t.owner&&t.sourceAttribution?e.jsxs("div",{className:"space-y-1",children:[e.jsx("p",{className:"text-xs font-medium uppercase tracking-wide text-muted-foreground/80",children:"Generated from"}),e.jsx(Ae,{owner:t.owner,source:t.sourceAttribution,className:"text-xs"})]}):null,i?e.jsx("div",{className:"space-y-2",children:o?.state==="expired"?e.jsx("p",{className:"text-sm text-amber-700 dark:text-amber-300",children:o.error_message??"This draft expired before the page was opened."}):o?.state==="completed"||o?.state==="preparing"?e.jsx("p",{className:"text-sm text-muted-foreground",children:o.state==="preparing"?"Preparing draft — keep your browser tab open.":"Draft prepared — review and post in your browser."}):e.jsxs(N,{type:"button",size:"sm",className:"h-8 text-sm",onClick:()=>{Se(i)},children:[e.jsx(Ce,{className:"mr-1.5 h-3.5 w-3.5"}),"Open post"]})}):null]})}function Pt({owner:t,automationId:n,runId:s}){const{organizationId:r}=Ie(t),i=st(n,void 0,r),o=nt(i.data?.automation);return o?e.jsx(xt,{agentId:o,automationId:n,ownerSlug:t,runId:s}):i.isLoading?e.jsx(b,{className:"h-24 w-full rounded-lg"}):e.jsx(M,{owner:t,runId:s})}function Lt({owner:t,automationId:n}){return e.jsx(Pe,{owner:t,agentId:null,automationId:n,view:"activity",onDone:()=>{}})}export{Is as PeekPaneContent};
2
- //# sourceMappingURL=peek-pane-content-D68BjguQ.js.map
@@ -1,2 +0,0 @@
1
- import{hA as w,h8 as f,h9 as y,r as N,j as e,W as k,B as d,H as A,eS as C}from"./index-DdBTTN3y.js";import{a as P}from"./runs-fFJ1lPnw.js";function B({resource:g,runId:t,children:h,onDone:l}){const c=!!t,{data:a,isLoading:S,isError:u,refetch:v}=P(g,c?t:void 0),s=w({isReview:c,isError:u,status:a?.status}),m=a?.status==="pending"?a.proposal:null,n=f(),i=y(),[p,x]=N.useState(""),o=n.isPending||i.isPending,j=s==="active"||s==="loading"||s==="error",b=()=>{t&&n.mutate({run_id:t},{onSuccess:()=>l?.()})},R=()=>{if(!t)return;const r=p.trim();i.mutate({run_id:t,...r?{reason:r}:{}},{onSuccess:()=>l?.()})};return e.jsxs("div",{className:"grid content-start gap-4",children:[s==="active"?e.jsx("div",{className:"rounded-lg border border-amber-200 bg-amber-50 p-3 text-sm text-amber-950 dark:border-amber-900/60 dark:bg-amber-950/30 dark:text-amber-100",children:e.jsxs("div",{className:"flex gap-2",children:[e.jsx(k,{className:"mt-0.5 h-4 w-4 shrink-0"}),e.jsxs("p",{children:["Review the change the builder agent proposed. The values below show the proposed change — ",e.jsx("strong",{children:"Approve"})," to apply, or"," ",e.jsx("strong",{children:"Reject"}),"."]})]})}):null,s==="gone"?e.jsx("div",{className:"rounded-lg border bg-muted/30 p-3 text-sm text-muted-foreground",children:"This change is no longer pending (it may have been approved or rejected already)."}):null,s==="error"?e.jsx("div",{className:"rounded-lg border border-destructive/40 bg-destructive/5 p-3 text-sm",children:e.jsxs("div",{className:"flex items-start justify-between gap-3",children:[e.jsx("p",{className:"text-destructive",children:"Couldn't load the proposed change to review. Editing is disabled until it loads — retry, or reopen the link."}),e.jsx(d,{type:"button",variant:"outline",size:"sm",onClick:()=>void v(),children:"Retry"})]})}):null,h({reviewMode:s,proposal:m,controlsDisabled:j}),s==="active"?e.jsxs("div",{className:"grid gap-3",children:[e.jsxs("div",{className:"grid gap-2",children:[e.jsx(A,{htmlFor:"review-reject-reason",children:"Reason (optional)"}),e.jsx(C,{id:"review-reject-reason",rows:2,value:p,onChange:r=>x(r.target.value),placeholder:"Why you're rejecting — shared back to the requester.",disabled:o})]}),e.jsxs("div",{className:"flex flex-col gap-2 sm:flex-row sm:justify-end",children:[e.jsx(d,{type:"button",variant:"outline",onClick:R,disabled:o,children:i.isPending?"Rejecting...":"Reject"}),e.jsx(d,{type:"button",onClick:b,disabled:o,children:n.isPending?"Approving...":"Approve"})]})]}):null]})}export{B as P};
2
- //# sourceMappingURL=proposal-review-shell-D6KABxah.js.map
@@ -1,2 +0,0 @@
1
- import{r as e,dA as l}from"./index-DdBTTN3y.js";function a(){return e.useEffect(()=>{l()},[]),null}export{a as P};
2
- //# sourceMappingURL=public-shell-ready-BIVCHQHe.js.map