@lobu/runtime-server 24.1.1 → 24.2.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.
- package/dist/catalogs/connectors.json +151 -37
- package/dist/catalogs/skills.json +2 -2
- package/dist/component.json +1 -1
- package/dist/connectors/google_gmail.ts +70 -41
- package/dist/connectors/google_gmail_references.ts +406 -0
- package/dist/connectors/linkedin-inbox-adapter.js +107 -36
- package/dist/connectors/linkedin-inbox.ts +13 -0
- package/dist/connectors/linkedin.ts +1 -1
- package/dist/connectors/postgres.ts +5 -3
- package/dist/connectors/reddit.ts +171 -5
- package/dist/connectors/whatsapp-web-adapter.js +147 -61
- package/dist/connectors/whatsapp-web-helpers.ts +6 -2
- package/dist/connectors/whatsapp_web.ts +48 -17
- package/dist/connectors/x-dm-adapter.js +252 -35
- package/dist/connectors/x.ts +189 -13
- package/dist/db/migrations/20261020140000_view_attachments_by_page.sql +3 -1
- package/dist/db/migrations/20261024050000_events_source_reference_arrival.sql +27 -0
- package/dist/db/migrations/20261026000000_turn_write_receipts.sql +36 -0
- package/dist/db/migrations/20261026190000_federated_relationship_endpoints.sql +143 -0
- package/dist/dependencies.bun.lock +81 -83
- package/dist/embeddings-server.mjs +81 -11
- package/dist/guest.bundle.js +62 -25
- package/dist/owletto/dist/assets/_-Cjvw31gU.js +2 -0
- package/dist/owletto/dist/assets/_-iToIRRFt.js +3 -0
- package/dist/owletto/dist/assets/_agentId-CLdj0X7j.js +2 -0
- package/dist/owletto/dist/assets/_agentId-D5cAWjrP.js +2 -0
- package/dist/owletto/dist/assets/_automationId-BhEZmkJU.js +2 -0
- package/dist/owletto/dist/assets/_connectorKey._connectionId-DZtLc3WW.js +2 -0
- package/dist/owletto/dist/assets/_connectorKey.index-BoYpah_l.js +2 -0
- package/dist/owletto/dist/assets/_conversationId-ML2TjCwN.js +2 -0
- package/dist/owletto/dist/assets/_eventId-BYc3I2EL.js +2 -0
- package/dist/owletto/dist/assets/_name-BsOZmvlH.js +2 -0
- package/dist/owletto/dist/assets/_owner-UuyQLJ-0.js +3 -0
- package/dist/owletto/dist/assets/_shape-BpnVAYWH.js +2 -0
- package/dist/owletto/dist/assets/_skillKey-CYrGvNn-.js +2 -0
- package/dist/owletto/dist/assets/_slug-MHQU8ftJ.js +2 -0
- package/dist/owletto/dist/assets/_viewKey-CGAJ1ucr.js +2 -0
- package/dist/owletto/dist/assets/_viewKey-CMkhfs1k.js +2 -0
- package/dist/owletto/dist/assets/accept-invitation-D2T_a2dj.js +2 -0
- package/dist/owletto/dist/assets/activity-route-view-_G_lDz5K.js +2 -0
- package/dist/owletto/dist/assets/agent-card-controls-ColL5rdd.js +2 -0
- package/dist/owletto/dist/assets/{agent-client-setup-list-BlXB4SE5.js → agent-client-setup-list-BgyLhJCo.js} +2 -2
- package/dist/owletto/dist/assets/agent-connect-pages-BryZas7Z.js +2 -0
- package/dist/owletto/dist/assets/{agent-editor-form-DsSoeQeF.js → agent-editor-form-C24p9LLg.js} +2 -2
- package/dist/owletto/dist/assets/agent-guardrails-route-D9PpDgR-.js +2 -0
- package/dist/owletto/dist/assets/{agent-loading-shells-B7v6Cffw.js → agent-loading-shells-jkf9DjdO.js} +2 -2
- package/dist/owletto/dist/assets/agent-permissions-matrix-C8j8kRB1.js +2 -0
- package/dist/owletto/dist/assets/{agent-skill-context-DFucg4c4.js → agent-skill-context-B9giw2u2.js} +2 -2
- package/dist/owletto/dist/assets/agent-skills-route-BMZ3r1bP.js +2 -0
- package/dist/owletto/dist/assets/agent-subpage-shell-D49f-bzP.js +2 -0
- package/dist/owletto/dist/assets/{agent-thread-D38STyeu.js → agent-thread-BGHYHWDO.js} +4 -4
- package/dist/owletto/dist/assets/agents-C05k-Xw6.js +2 -0
- package/dist/owletto/dist/assets/agents-workbench-D1YL3VAB.js +2 -0
- package/dist/owletto/dist/assets/app._appId-A51tx2jU.js +2 -0
- package/dist/owletto/dist/assets/automation-detail-content-DCAZBKle.js +2 -0
- package/dist/owletto/dist/assets/automations-C05k-Xw6.js +2 -0
- package/dist/owletto/dist/assets/callback-WmyCei3R.js +2 -0
- package/dist/owletto/dist/assets/{card-jzhQrMDP.js → card-Cspo-4M6.js} +2 -2
- package/dist/owletto/dist/assets/{claim-B-wq745Q.js → claim-CCKdBtFt.js} +2 -2
- package/dist/owletto/dist/assets/client-activity-scopes-CmK3DkSP.js +2 -0
- package/dist/owletto/dist/assets/client-rows-fFuxzFtE.js +2 -0
- package/dist/owletto/dist/assets/{code-editor-CEqoCky-.js → code-editor-C8FJbT2P.js} +3 -3
- package/dist/owletto/dist/assets/connect-BmCUJ3lr.js +2 -0
- package/dist/owletto/dist/assets/connect._clientId-B6StGCPK.js +2 -0
- package/dist/owletto/dist/assets/connected._clientId-CPiMA6Bx.js +2 -0
- package/dist/owletto/dist/assets/connected._clientId.activity-BialEDmu.js +2 -0
- package/dist/owletto/dist/assets/connected._clientId.index-X1wVi6v0.js +2 -0
- package/dist/owletto/dist/assets/{connection-CNm2ukrI.js → connection-DJd9bnEc.js} +2 -2
- package/dist/owletto/dist/assets/{connection-feed-detail-WcGCA6qY.js → connection-feed-detail-IO6G5QjL.js} +2 -2
- package/dist/owletto/dist/assets/connections-browser-CzdcZeiU.js +2 -0
- package/dist/owletto/dist/assets/{connector-provenance-D-ECOlMJ.js → connector-provenance-bmBJJ9B4.js} +2 -2
- package/dist/owletto/dist/assets/connector-scope-lists-B44Q9W-j.js +2 -0
- package/dist/owletto/dist/assets/{connectors-CH4KBZyT.js → connectors-CTWPDH8f.js} +2 -2
- package/dist/owletto/dist/assets/{consent-C9ZpHb7V.js → consent-C_WBfmQ8.js} +2 -2
- package/dist/owletto/dist/assets/copy-button-kcjg8Giw.js +2 -0
- package/dist/owletto/dist/assets/{core.esm-BupT3V0i.js → core.esm-CoJ5Splc.js} +2 -2
- package/dist/owletto/dist/assets/create-CQE5rD0i.js +2 -0
- package/dist/owletto/dist/assets/create-DQNlRTUX.js +2 -0
- package/dist/owletto/dist/assets/create-automation-form-y3tq2QIJ.js +3 -0
- package/dist/owletto/dist/assets/create-lOFSQV_5.js +2 -0
- package/dist/owletto/dist/assets/create._connectorKey-icyNicvn.js +2 -0
- package/dist/owletto/dist/assets/{cronstrue-CWImw-kf.js → cronstrue-CeUS_78Q.js} +2 -2
- package/dist/owletto/dist/assets/{device-D-7WBe9E.js → device-Br9JHadR.js} +2 -2
- package/dist/owletto/dist/assets/device-pin-tombstone-7UpeD4Sq.js +2 -0
- package/dist/owletto/dist/assets/device._deviceId-DGMmjr01.js +2 -0
- package/dist/owletto/dist/assets/elk-worker.min-BENGc9gn.js +23 -0
- package/dist/owletto/dist/assets/{entity-avatar-mdh7Kq5D.js → entity-avatar-BZIa-7i5.js} +2 -2
- package/dist/owletto/dist/assets/entity-options-BcTafZ2e.js +2 -0
- package/dist/owletto/dist/assets/entity-page-CY7PF3X9.js +2 -0
- package/dist/owletto/dist/assets/entity-type-page-BzMZttzh.js +2 -0
- package/dist/owletto/dist/assets/{event-detail-DV_zfWnC.js → event-detail-C25TvOb_.js} +2 -2
- package/dist/owletto/dist/assets/events-feed-C4VrjIc1.js +2 -0
- package/dist/owletto/dist/assets/filter-editors-oNjBX9a2.js +2 -0
- package/dist/owletto/dist/assets/{full-page-spinner-BVbcpW3R.js → full-page-spinner-DtmqQmgl.js} +2 -2
- package/dist/owletto/dist/assets/guardrails-Acfam-JF.js +2 -0
- package/dist/owletto/dist/assets/identity-BkK8ggdp.js +2 -0
- package/dist/owletto/dist/assets/index-BhBYXtEN.js +2 -0
- package/dist/owletto/dist/assets/{index-BTlx9K_t.js → index-Bhop_otG.js} +2 -2
- package/dist/owletto/dist/assets/index-Bw5iV_J7.js +2 -0
- package/dist/owletto/dist/assets/index-C3dpyynY.js +2 -0
- package/dist/owletto/dist/assets/index-C3zAbslo.js +2 -0
- package/dist/owletto/dist/assets/index-CGKN_WN_.js +2 -0
- package/dist/owletto/dist/assets/{index-DB1iWI_a.js → index-CgRaCOzW.js} +2 -2
- package/dist/owletto/dist/assets/{index-D7gHOpfg.js → index-DRbaESbJ.js} +2 -2
- package/dist/owletto/dist/assets/index-DfIoxD5Q.js +2 -0
- package/dist/owletto/dist/assets/index-DijuudSs.js +2 -0
- package/dist/owletto/dist/assets/index-Dr7bouPX.css +1 -0
- package/dist/owletto/dist/assets/index-JmEl29py.js +7950 -0
- package/dist/owletto/dist/assets/index-NK2VKPoL.js +2 -0
- package/dist/owletto/dist/assets/index-_5qsmBkt.js +2 -0
- package/dist/owletto/dist/assets/{index-B64PGxQm.js → index-qkOKpRYs.js} +2 -2
- package/dist/owletto/dist/assets/index-wHFQv1aT.js +12 -0
- package/dist/owletto/dist/assets/index-wzYkECAe.js +2 -0
- package/dist/owletto/dist/assets/json-diff-4sMmayDd.js +4 -0
- package/dist/owletto/dist/assets/linked-record-peek-B0_B4PnF.js +97 -0
- package/dist/owletto/dist/assets/{list-skeleton-CepswBka.js → list-skeleton-BafzvpOM.js} +2 -2
- package/dist/owletto/dist/assets/login-XL5XxN6y.js +2 -0
- package/dist/owletto/dist/assets/{logout-Bkzc7J44.js → logout-CMxdhLbM.js} +2 -2
- package/dist/owletto/dist/assets/{member-scope-gate-DD4YBFn-.js → member-scope-gate-Dit3MXBQ.js} +2 -2
- package/dist/owletto/dist/assets/memory-browse-page-DTlM_9MY.js +74 -0
- package/dist/owletto/dist/assets/{model-selector-CDrAjH31.js → model-selector-BeFuFH7p.js} +2 -2
- package/dist/owletto/dist/assets/models-BAVaDnKN.js +2 -0
- package/dist/owletto/dist/assets/new-1QLuS1o-.js +2 -0
- package/dist/owletto/dist/assets/{new-ktz9Cs_P.js → new-ChwqLmVY.js} +2 -2
- package/dist/owletto/dist/assets/new-D21LGMl6.js +2 -0
- package/dist/owletto/dist/assets/{oauth-workspace-access-lZNZ9gul.js → oauth-workspace-access-D15LYKSe.js} +2 -2
- package/dist/owletto/dist/assets/organization-CoUJYXx7.js +2 -0
- package/dist/owletto/dist/assets/peek-pane-content-BvkYk72J.js +2 -0
- package/dist/owletto/dist/assets/permissions-C6UFdvz2.js +2 -0
- package/dist/owletto/dist/assets/proposal-review-shell-CmLy1MZf.js +2 -0
- package/dist/owletto/dist/assets/public-shell-ready-_awBxu2Y.js +2 -0
- package/dist/owletto/dist/assets/record-activity-Doeu5kPO.js +2 -0
- package/dist/owletto/dist/assets/{record-session-Pbr5czGw.js → record-session-CJzFoVKc.js} +2 -2
- package/dist/owletto/dist/assets/{reset-password-CzZw6RcC.js → reset-password-Y-WO77iR.js} +2 -2
- package/dist/owletto/dist/assets/runs-B0zVYb-w.js +2 -0
- package/dist/owletto/dist/assets/runs-panel-Dkyybqos.js +2 -0
- package/dist/owletto/dist/assets/{runs-table-B1APZv7d.js → runs-table-9OVdfPXZ.js} +2 -2
- package/dist/owletto/dist/assets/schema-type-editor-panel-DcJqbCrU.js +2 -0
- package/dist/owletto/dist/assets/settings-Cfy9tCOF.js +2 -0
- package/dist/owletto/dist/assets/settings-Dg0D_l_w.js +2 -0
- package/dist/owletto/dist/assets/skills-oxA7P5Fe.js +2 -0
- package/dist/owletto/dist/assets/source-record-panels-BeAZeMLy.js +2 -0
- package/dist/owletto/dist/assets/status-dot-_LQZmEIX.js +2 -0
- package/dist/owletto/dist/assets/use-automations-DS3uz3pb.js +2 -0
- package/dist/owletto/dist/assets/{use-mention-search-Dcunv4L0.js → use-mention-search-CAFbh-Dk.js} +4 -4
- package/dist/owletto/dist/assets/use-scroll-sentinel-BpQ70c28.js +2 -0
- package/dist/owletto/dist/assets/view-param-filters-FuOZyjMg.js +2 -0
- package/dist/owletto/dist/assets/views-access-required-CWwlobOd.js +2 -0
- package/dist/owletto/dist/index.html +2 -2
- package/dist/server-main.bundle.mjs +44298 -40801
- package/npm-shrinkwrap.json +389 -402
- package/package.json +1 -1
- package/vendor/connector-sdk/dist/browser-requirement.js +1 -1
- package/vendor/connector-sdk/dist/connector-types.d.ts +5 -1
- package/vendor/connector-sdk/package.json +1 -1
- package/vendor/core/dist/agent-tooling.d.ts +8 -0
- package/vendor/core/dist/agent-tooling.js +9 -1
- package/vendor/core/dist/capabilities.d.ts +1 -1
- package/vendor/core/dist/capabilities.js +5 -0
- package/vendor/core/dist/contracts/entity-reference.d.ts +3 -0
- package/vendor/core/dist/contracts/entity-reference.js +31 -0
- package/vendor/core/dist/contracts/tools/manage-automations.d.ts +3 -0
- package/vendor/core/dist/contracts/tools/manage-automations.js +3 -0
- package/vendor/core/dist/contracts/tools/manage-connections.js +1 -1
- package/vendor/core/dist/contracts/tools/manage-entity-schema.js +1 -1
- package/vendor/core/dist/contracts/tools/manage-entity.d.ts +113 -34
- package/vendor/core/dist/contracts/tools/manage-entity.js +41 -14
- package/vendor/core/dist/contracts/tools/manage-operations.d.ts +13 -4
- package/vendor/core/dist/contracts/tools/manage-operations.js +19 -7
- package/vendor/core/dist/contracts/tools/read-knowledge.d.ts +6 -1
- package/vendor/core/dist/contracts/tools/read-knowledge.js +20 -1
- package/vendor/core/dist/contracts/tools/view-attach.d.ts +1 -1
- package/vendor/core/dist/contracts/tools/view-runtime.d.ts +2 -0
- package/vendor/core/dist/contracts/tools/view-runtime.js +3 -1
- package/vendor/core/dist/contracts/worker/device-automation.d.ts +4 -9
- package/vendor/core/dist/contracts/worker/device-automation.js +10 -15
- package/vendor/core/dist/contracts/worker/protocol.d.ts +20 -0
- package/vendor/core/dist/contracts/worker/protocol.js +20 -0
- package/vendor/core/dist/reserved.d.ts +6 -3
- package/vendor/core/dist/reserved.js +6 -3
- package/vendor/core/dist/worker/auth.d.ts +3 -2
- package/vendor/core/package.json +6 -1
- package/vendor/postgres/cf/src/query.js +3 -1
- package/vendor/postgres/cjs/src/query.js +3 -1
- package/vendor/postgres/src/query.js +3 -1
- package/vendor/views/dist/api.js +31 -7
- package/vendor/views/dist/bridge.d.ts +2 -1
- package/vendor/views/dist/bridge.js +10 -1
- package/vendor/views/package.json +1 -1
- package/dist/owletto/dist/assets/_-BorucF19.js +0 -3
- package/dist/owletto/dist/assets/_-CkGyNi0G.js +0 -2
- package/dist/owletto/dist/assets/_agentId-BrhcaxUk.js +0 -2
- package/dist/owletto/dist/assets/_agentId-DgRrCE2B.js +0 -2
- package/dist/owletto/dist/assets/_automationId-DSrZIYcs.js +0 -2
- package/dist/owletto/dist/assets/_connectorKey._connectionId-DWxv1uoi.js +0 -2
- package/dist/owletto/dist/assets/_connectorKey.index-BTP5ijdT.js +0 -2
- package/dist/owletto/dist/assets/_conversationId-98Y3RuRO.js +0 -2
- package/dist/owletto/dist/assets/_deploymentId-B1UWPY0i.js +0 -2
- package/dist/owletto/dist/assets/_eventId-BAnr8g8z.js +0 -2
- package/dist/owletto/dist/assets/_name-BUfFO_A0.js +0 -2
- package/dist/owletto/dist/assets/_owner-C79BwQ0I.js +0 -3
- package/dist/owletto/dist/assets/_shape-Ep6JpyFX.js +0 -2
- package/dist/owletto/dist/assets/_skillKey-B24alBfT.js +0 -2
- package/dist/owletto/dist/assets/_slug-DbPdDc-5.js +0 -2
- package/dist/owletto/dist/assets/_viewKey-DDUxjjFD.js +0 -2
- package/dist/owletto/dist/assets/_viewKey-hdpq3RoX.js +0 -2
- package/dist/owletto/dist/assets/accept-invitation-UXU5Fx2G.js +0 -2
- package/dist/owletto/dist/assets/activity-route-view-D7ORHntE.js +0 -2
- package/dist/owletto/dist/assets/agent-card-controls-CplnPhbv.js +0 -2
- package/dist/owletto/dist/assets/agent-connect-pages-BmknviTI.js +0 -2
- package/dist/owletto/dist/assets/agent-guardrails-route-TdvvIc_J.js +0 -2
- package/dist/owletto/dist/assets/agent-permissions-matrix-BkZu1LYE.js +0 -2
- package/dist/owletto/dist/assets/agent-skills-route-B3vvvZZe.js +0 -2
- package/dist/owletto/dist/assets/agent-subpage-shell-CZJvnjNC.js +0 -2
- package/dist/owletto/dist/assets/agents-DAOln24A.js +0 -2
- package/dist/owletto/dist/assets/agents-workbench-DJ67GZ93.js +0 -2
- package/dist/owletto/dist/assets/app._appId-Cp78oEZ9.js +0 -2
- package/dist/owletto/dist/assets/automation-detail-content-DSwbRpbx.js +0 -2
- package/dist/owletto/dist/assets/automations-DAOln24A.js +0 -2
- package/dist/owletto/dist/assets/callback-CBexCo3F.js +0 -2
- package/dist/owletto/dist/assets/client-rows-BYbsXGy9.js +0 -2
- package/dist/owletto/dist/assets/clients-BhNl1tVq.js +0 -2
- package/dist/owletto/dist/assets/connect-wx-qqLir.js +0 -2
- package/dist/owletto/dist/assets/connect._clientId-kk0_4Svo.js +0 -2
- package/dist/owletto/dist/assets/connected._clientId-QR8o-7M5.js +0 -2
- package/dist/owletto/dist/assets/connected._clientId.activity-BqprYeOX.js +0 -2
- package/dist/owletto/dist/assets/connected._clientId.index-DhRoSzBr.js +0 -2
- package/dist/owletto/dist/assets/connections-browser-CrtnAs0Q.js +0 -2
- package/dist/owletto/dist/assets/connector-scope-lists-CRFEpSvk.js +0 -2
- package/dist/owletto/dist/assets/conversations-table-D_HOe1jN.js +0 -2
- package/dist/owletto/dist/assets/create-C4lptGWj.js +0 -2
- package/dist/owletto/dist/assets/create-CCjZxIkK.js +0 -2
- package/dist/owletto/dist/assets/create-DkgUQAbB.js +0 -2
- package/dist/owletto/dist/assets/create-automation-form-Bpy92SM5.js +0 -3
- package/dist/owletto/dist/assets/create._connectorKey-D6Kc-YQ3.js +0 -2
- package/dist/owletto/dist/assets/deployments-C5hvipQh.js +0 -2
- package/dist/owletto/dist/assets/deployments-CPpFAd_w.js +0 -2
- package/dist/owletto/dist/assets/deployments-body-DGII20dQ.js +0 -2
- package/dist/owletto/dist/assets/device-pin-tombstone-2U0UMu3_.js +0 -2
- package/dist/owletto/dist/assets/device._deviceId-Bn37UpWH.js +0 -2
- package/dist/owletto/dist/assets/entity-options-Clz_WXK-.js +0 -2
- package/dist/owletto/dist/assets/entity-page-D3e4iPle.js +0 -2
- package/dist/owletto/dist/assets/entity-type-page-DebN1vCM.js +0 -2
- package/dist/owletto/dist/assets/events-feed-DO3IiJO2.js +0 -2
- package/dist/owletto/dist/assets/filter-editors-Bwhqj7lY.js +0 -2
- package/dist/owletto/dist/assets/guardrails-BiJollCA.js +0 -2
- package/dist/owletto/dist/assets/identity-HCFWtdaI.js +0 -2
- package/dist/owletto/dist/assets/index-8wxsyxqt.js +0 -2
- package/dist/owletto/dist/assets/index-9YuSRymd.js +0 -7950
- package/dist/owletto/dist/assets/index-B3c-0eZG.js +0 -2
- package/dist/owletto/dist/assets/index-BSH07yVD.css +0 -1
- package/dist/owletto/dist/assets/index-BX0EA_oB.js +0 -2
- package/dist/owletto/dist/assets/index-CDz3-ieP.js +0 -12
- package/dist/owletto/dist/assets/index-CdJJaQDX.js +0 -2
- package/dist/owletto/dist/assets/index-CfT_W8Vo.js +0 -2
- package/dist/owletto/dist/assets/index-CxF2XXzl.js +0 -2
- package/dist/owletto/dist/assets/index-D3WHeGql.js +0 -2
- package/dist/owletto/dist/assets/index-DMNzF8Lf.js +0 -2
- package/dist/owletto/dist/assets/index-DyB3IzOA.js +0 -2
- package/dist/owletto/dist/assets/index-Vcq4gwWv.js +0 -2
- package/dist/owletto/dist/assets/index-fgAJydgX.js +0 -2
- package/dist/owletto/dist/assets/json-diff-DIN5Jhfx.js +0 -4
- package/dist/owletto/dist/assets/login-DxGYyE4n.js +0 -2
- package/dist/owletto/dist/assets/memory-browse-page-BnuhLJ6X.css +0 -1
- package/dist/owletto/dist/assets/memory-browse-page-D_UlBa27.js +0 -103
- package/dist/owletto/dist/assets/models-BAVeysNq.js +0 -2
- package/dist/owletto/dist/assets/new-C2av0diq.js +0 -2
- package/dist/owletto/dist/assets/new-snm1ctHn.js +0 -2
- package/dist/owletto/dist/assets/organization-Cb0W823y.js +0 -2
- package/dist/owletto/dist/assets/peek-pane-content-BNR9ImQY.js +0 -2
- package/dist/owletto/dist/assets/permissions-Dv39zWKt.js +0 -2
- package/dist/owletto/dist/assets/proposal-review-shell-CFhOqCLf.js +0 -2
- package/dist/owletto/dist/assets/public-shell-ready-DqX8AXfw.js +0 -2
- package/dist/owletto/dist/assets/recent-QhnLDU1_.js +0 -2
- package/dist/owletto/dist/assets/record-activity-ZJntBfN_.js +0 -2
- package/dist/owletto/dist/assets/record-field-peek-Brh1IQGy.js +0 -2
- package/dist/owletto/dist/assets/runs-panel-C0_DNTcq.js +0 -2
- package/dist/owletto/dist/assets/schema-value-normalization-CKdPjdPC.js +0 -97
- package/dist/owletto/dist/assets/settings-CgZ5Z7wD.js +0 -2
- package/dist/owletto/dist/assets/settings-VDNiffKU.js +0 -2
- package/dist/owletto/dist/assets/skills-DgDGscm5.js +0 -2
- package/dist/owletto/dist/assets/source-record-panels-BdfOVPWn.js +0 -2
- package/dist/owletto/dist/assets/view-param-filters-B0quibBi.js +0 -2
- /package/vendor/postgres/{.bun-tag-2f292c6554a8475e → .bun-tag-22d644c2873790db} +0 -0
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import{r as a,j as l,
|
|
2
|
-
//# sourceMappingURL=entity-avatar-
|
|
1
|
+
import{r as a,j as l,fW as A,T as f,d2 as O}from"./index-JmEl29py.js";var S="Separator",m="horizontal",k=["horizontal","vertical"],b=a.forwardRef((e,t)=>{const{decorative:r,orientation:o=m,...i}=e,n=T(o)?o:m,c=r?{role:"none"}:{"aria-orientation":n==="vertical"?n:void 0,role:"separator"};return l.jsx(A.div,{"data-orientation":n,...c,...i,ref:t})});b.displayName=S;function T(e){return k.includes(e)}var y=b;const I=a.forwardRef(({className:e,orientation:t="horizontal",decorative:r=!0,...o},i)=>l.jsx(y,{ref:i,decorative:r,orientation:t,className:f("shrink-0 bg-border",t==="horizontal"?"h-[1px] w-full":"h-full w-[1px]",e),...o}));I.displayName=y.displayName;function g(e,t){const r=e?.properties;if(r)return Object.entries(r).find(([,o])=>o[t])?.[0]}function P(e){const t=e.trim(),r=t.split(/[\s._@/-]+/).filter(Boolean),o=r.length>=2?`${r[0][0]}${r[1][0]}`:(r[0]??t).slice(0,2);let i=0;for(let n=0;n<t.length;n++)i=i*31+t.charCodeAt(n)>>>0;return{initials:o.toUpperCase()||"?",hue:i%360}}function R(e){const[t,r]=a.useState();return a.useEffect(()=>{if(!e){r(void 0);return}let o=!1;const i=e.trim().toLowerCase();return crypto.subtle.digest("SHA-256",new TextEncoder().encode(i)).then(n=>{o||r(Array.from(new Uint8Array(n)).map(s=>s.toString(16).padStart(2,"0")).join(""))}),()=>{o=!0}},[e]),t?`https://www.gravatar.com/avatar/${t}?d=identicon&s=80`:void 0}function $({metadata:e,metadataSchema:t,name:r,typeIcon:o,className:i="h-6 w-6",iconClassName:n="h-5 w-5",initialsFallback:s=!1}){const c=g(t,"x-image"),u=g(t,"x-email"),p=c&&e?.[c]||void 0,v=u&&e?.[u]||void 0,x=R(p?void 0:v),d=p||x,[w,h]=a.useState(!1);if(a.useEffect(()=>{h(!1)},[d]),d&&!w)return l.jsx("img",{src:d,alt:r,referrerPolicy:"no-referrer",onError:()=>h(!0),className:f("rounded-full object-cover border border-border",i)});if(s){const E=r.trim()||v||z(e,t)||r,{initials:j,hue:N}=P(E);return l.jsx("span",{role:"img","aria-label":r,className:f("inline-grid place-items-center rounded-full border border-border font-semibold text-white select-none",i),style:{background:`oklch(0.55 0.13 ${N})`,fontSize:"0.85em"},children:j})}return l.jsx(O,{icon:o,className:n})}function z(e,t){if(!e)return;const r=t?.properties,o=["email","handle","username","login","github","x_handle","slug"],i=Object.keys(r||e);for(const n of i)if(o.includes(n.toLowerCase())){const s=e[n];if(typeof s=="string"&&s.trim())return s}}export{$ as E,I as S};
|
|
2
|
+
//# sourceMappingURL=entity-avatar-BZIa-7i5.js.map
|
|
@@ -0,0 +1,2 @@
|
|
|
1
|
+
import{q as x,an as m,j as e,bn as C,bo as _,bp as S,bq as b,br as i,f3 as u}from"./index-JmEl29py.js";import{c as w}from"./connection-label-BobuYiAG.js";const h="__connection_picker_create_new__";function y({connections:s,value:r,onValueChange:n,connectorKey:a,disabled:p,placeholder:d="Choose a connection",includeWorkspaceEvents:c=!1,ariaLabel:f="Connection"}){const g=x(),l=m().org?.slug,o=a?s.filter(t=>t.connector_key===a):s,j=t=>{if(t===h){if(!l)return;g({to:"/$owner/connectors/create",params:{owner:l},search:a?{connector:a}:{}});return}n(t)};return e.jsxs(C,{value:r,onValueChange:j,disabled:p,children:[e.jsx(_,{"aria-label":f,children:e.jsx(S,{placeholder:d})}),e.jsxs(b,{children:[c?e.jsxs(e.Fragment,{children:[e.jsx(i,{value:"workspace",children:"Current workspace"}),o.length>0?e.jsx(u,{}):null]}):null,o.map(t=>e.jsx(i,{value:String(t.id),children:w(t)},t.id)),l?e.jsxs(e.Fragment,{children:[o.length>0||c?e.jsx(u,{}):null,e.jsx(i,{value:h,children:"Connect an app…"})]}):null]})]})}function v(s){const r=[];for(const n of s)typeof n.id=="number"&&r.push({id:n.id,name:n.name,entityType:n.entity_type}),n.children&&n.children.length>0&&r.push(...v(n.children));return r}export{y as C,v as f};
|
|
2
|
+
//# sourceMappingURL=entity-options-BcTafZ2e.js.map
|
|
@@ -0,0 +1,2 @@
|
|
|
1
|
+
import{dg as ke,r as F,bO as Ne,jw as R,fA as Se,dU as se,j as e,B as S,u as X,jq as we,S as ae,fH as he,jx as Re,x as Fe,q as pe,jy as Ee,bP as B,an as De,g as Ce,dW as G,fb as Le,jr as Be,jz as Pe,b8 as Ve,b$ as ne,eN as $e,fu as Oe,fh as Te,gS as Ie,gT as Me,gU as Ae,gV as ze,gW as Ue,jA as He,bS as Ke,E as H,I as ie,fP as We,b7 as qe,fy as re,dQ as K,ge as Ge,L as W,gf as q}from"./index-JmEl29py.js";import{R as Qe}from"./record-activity-Doeu5kPO.js";import{m as Xe,o as Q,j as Ye,q as oe,h as Y,R as xe,r as Je,t as Ze,D as et,S as tt}from"./linked-record-peek-B0_B4PnF.js";import{r as st,V as at}from"./views-access-required-CWwlobOd.js";import{S as nt,E as it}from"./entity-avatar-BZIa-7i5.js";import{a as fe,V as le,M as rt,b as ot}from"./view-param-filters-FuOZyjMg.js";import{a as lt}from"./source-record-panels-BeAZeMLy.js";import{r as ct,R as ce,d as dt}from"./events-feed-C4VrjIc1.js";import{a as ut}from"./record-session-CJzFoVKc.js";import"./filter-editors-oNjBX9a2.js";import"./connection-label-BobuYiAG.js";import"./runs-B0zVYb-w.js";import"./client-rows-fFuxzFtE.js";import"./client-activity-scopes-CmK3DkSP.js";import"./agent-loading-shells-jkf9DjdO.js";import"./member-scope-gate-Dit3MXBQ.js";import"./card-Cspo-4M6.js";import"./app-bridge-BCm4muqj.js";import"./use-automations-DS3uz3pb.js";import"./json-diff-4sMmayDd.js";import"./index-wHFQv1aT.js";import"./copy-button-kcjg8Giw.js";import"./use-scroll-sentinel-BpQ70c28.js";function mt(t,s){if(t===void 0)return{shouldBlockFn:()=>!0,withResolver:!1};if("shouldBlockFn"in t)return t;if(typeof t=="function")return{shouldBlockFn:async()=>await t(),enableBeforeUnload:!0,withResolver:!1};const i=!!(t.condition??!0),n=t.blockerFn;return{shouldBlockFn:async()=>i&&n!==void 0?await n():i,enableBeforeUnload:i,withResolver:n===void 0}}function ht(t,s){const{shouldBlockFn:i,enableBeforeUnload:n=!0,disabled:a=!1,withResolver:c=!1}=mt(t),r=ke(),{history:o}=r,[u,g]=F.useState({status:"idle",current:void 0,next:void 0,action:void 0,proceed:void 0,reset:void 0});return F.useEffect(()=>{const p=async x=>{function l(f){const j=r.parseLocation(f),y=r.getMatchedRoutes(j.pathname);return y.foundRoute===void 0?{routeId:"__notFound__",fullPath:j.pathname,pathname:j.pathname,params:y.routeParams,search:r.options.parseSearch(f.search)}:{routeId:y.foundRoute.id,fullPath:y.foundRoute.fullPath,pathname:j.pathname,params:y.routeParams,search:r.options.parseSearch(f.search)}}const m=l(x.currentLocation),d=l(x.nextLocation);if(m.routeId==="__notFound__"&&d.routeId!=="__notFound__")return!1;const h=await i({action:x.action,current:m,next:d});if(!c)return h;if(!h)return!1;const N=await new Promise(f=>{g({status:"blocked",current:m,next:d,action:x.action,proceed:()=>f(!1),reset:()=>f(!0)})});return g({status:"idle",current:void 0,next:void 0,action:void 0,proceed:void 0,reset:void 0}),N};return a?void 0:o.block({blockerFn:p,enableBeforeUnload:n})},[i,n,a,c,o,r]),u}function A(t,s){return se(Q(t))===se(Q(s))}function pt(t,s){const i={};for(const n of new Set([...Object.keys(t),...Object.keys(s)]))A(t[n],s[n])||(i[n]=Q(t[n])??null);return Object.keys(i).length>0?i:void 0}function xt(t,s){return[...new Set([...Object.keys(t),...Object.keys(s)])].filter(i=>{try{return!A(t[i],s[i])}catch{return!0}})}function de(t,s){return{name:t.name,slug:t.slug,metadata:Xe(t.metadata??{},s)}}function ft(t,s,i){const n=new Set(i),a={},c={},r=new Set([...Object.keys(t.values.metadata),...Object.keys(t.baseline.metadata),...Object.keys(s.metadata)]);for(const o of r){const u=n.has(o),g=u?t.values.metadata[o]:t.baseline.metadata[o],p=A(g,s.metadata[o])?g:s.metadata[o];p!==void 0&&(a[o]=p);let x=!1;if(!u)try{x=!A(t.values.metadata[o],t.baseline.metadata[o])}catch{x=!0}const l=x?t.values.metadata[o]:p;l!==void 0&&(c[o]=l)}return{baseline:{name:s.name,slug:s.slug,metadata:a},values:{name:s.name,slug:s.slug,metadata:c}}}function gt({entity:t,schema:s,orgContext:i}){const n=F.useMemo(()=>de(t,s),[t,s]),a=Ne(R(t),n,s),c=Se(i),{values:r,baseline:o,commit:u}=a,g=F.useMemo(()=>xt(r.metadata,o.metadata),[r.metadata,o.metadata]),p=r.name!==o.name||r.slug!==o.slug,x=F.useCallback((m,d)=>a.setValues(h=>({...h,metadata:{...h.metadata,[m]:d}})),[a.setValues]),l=async({note:m}={})=>{if(typeof t.id!="number")throw new Error("Source records are read-only");if(!a.canSubmit)return null;const d=pt(r.metadata,o.metadata),h=r.name.trim()!==o.name.trim();if(!d&&!p)return null;const N=await c.mutateAsync({entityId:t.id,name:h?r.name.trim():void 0,slug:r.slug,metadata:d,field_note:d&&m?.trim()||void 0}),f=de(N.entity,s);return u(j=>ft(j,f,Object.keys(d??{})),f),{held:N.blocked_fields??[],approvalUrl:N.approval_url}};return{values:r,baseline:o,revision:a.revision,setValues:a.setValues,setMetadataField:x,reset:a.reset,save:l,saving:c.isPending,dirtyKeys:g,identityDirty:p,isDirty:p||g.length>0,canSubmit:a.canSubmit,hasConflict:a.hasConflict,hasInvalidInput:a.hasInvalidInput}}const vt=3,jt=50;function ge(t){const s=F.useRef(null);return F.useEffect(()=>{t&&(s.current?.scrollIntoView?.({block:"start"}),s.current?.focus())},[t]),s}function $({headingRef:t,children:s}){return e.jsx("h3",{ref:t,tabIndex:-1,className:"text-xs font-medium uppercase tracking-wide text-muted-foreground outline-none",children:s})}function yt({entityId:t,entityName:s,ownerSlug:i,orgContext:n,focus:a,collapsed:c=!1}){const r=X(),o=ge(a),{data:u,isLoading:g,isError:p,refetch:x}=we(t,n,{limit:jt});if(t===void 0)return null;if(g)return e.jsxs("section",{className:"space-y-2","aria-busy":"true",children:[e.jsx($,{headingRef:o,children:"Linked"}),e.jsx(ae,{className:"h-4 w-24"}),e.jsx(ae,{className:"h-6 w-full rounded-md"})]});if(p||!u)return e.jsxs("section",{className:"space-y-2",children:[e.jsx($,{headingRef:o,children:"Linked"}),e.jsxs("p",{className:"text-xs text-muted-foreground",children:["Could not load this record's links."," ",e.jsx("button",{type:"button",className:"underline",onClick:()=>void x(),children:"Retry"})]})]});if(u.countsByType.length===0&&!u.hasMore&&!u.failures?.length)return a?e.jsxs("section",{className:"space-y-2",children:[e.jsx($,{headingRef:o,children:"Linked"}),e.jsx("p",{className:"text-xs text-muted-foreground",children:"No links to other records yet."})]}):null;if(c){const l=u.countsByType.flatMap(m=>{const d=m.count===1?u.rows.find(h=>h.relationship_type_slug===m.relationship_type_slug):void 0;return d?[ct(d,m.relationship_type_name)]:[m.relationship_type_name,String(m.count)]});return e.jsxs("section",{className:"space-y-1","aria-label":"Linked records",children:[e.jsx($,{headingRef:o,children:"Linked"}),e.jsx(ce,{count:u.failures?.length??0,onRetry:()=>void x()}),e.jsx("p",{"data-testid":"linked-summary",className:"truncate text-sm text-muted-foreground",children:l.join(" · ")})]})}return e.jsxs("section",{className:"space-y-3","aria-label":"Linked records",children:[e.jsx($,{headingRef:o,children:"Linked"}),e.jsx(ce,{count:u.failures?.length??0,onRetry:()=>void x()}),u.hasMore&&r?e.jsx(S,{type:"button",variant:"ghost",size:"sm",onClick:()=>r.open({href:"",key:`record-links:${t}`,title:"Linked records",recordLinks:{entityId:t,entityName:s,ownerSlug:i,orgContext:n,label:"Linked records"}}),children:"Browse linked records"}):null,u.countsByType.map(l=>{const m=u.rows.filter(h=>h.relationship_type_slug===l.relationship_type_slug).slice(0,vt),d=l.count>m.length;return e.jsxs("div",{className:"space-y-1 text-sm",children:[d||m.length===0?e.jsxs("p",{className:"text-muted-foreground",children:[l.relationship_type_name,d?e.jsxs("span",{className:"tabular-nums text-muted-foreground/70",children:[" ","· ",l.count,u.countsScope==="page"?" shown":""]}):null]}):null,e.jsxs("div",{className:"flex min-w-0 flex-col items-start gap-1",children:[m.map(h=>e.jsx(dt,{row:h,label:l.relationship_type_name,entityId:t,ownerSlug:i,orgContext:n},h.id)),d&&r?e.jsxs(S,{type:"button",variant:"ghost",size:"sm",className:"h-8 px-2 text-primary hover:text-primary",onClick:()=>r.open({href:"",key:`record-links:${t}:${l.relationship_type_slug}`,title:`${l.relationship_type_name} · ${l.count}`,recordLinks:{entityId:t,entityName:s,ownerSlug:i,orgContext:n,relationshipType:l.relationship_type_slug,label:l.relationship_type_name}}),children:["Show all ",l.count]}):null]})]},l.relationship_type_slug)})]})}function bt({record:t,ownerSlug:s,orgContext:i,focus:n}){const[a,c]=F.useState(n),r=ge(n);return e.jsxs("section",{className:"space-y-2",children:[e.jsx($,{headingRef:r,children:"Linked"}),a?e.jsx(lt,{record:t,ownerSlug:s,orgContext:i}):e.jsx(S,{type:"button",variant:"outline",size:"sm",className:"h-7",onClick:()=>c(!0),children:"Find linked records"})]})}const _t="$name";function ve({outcome:t,schema:s}){if(!t||t.held.length===0)return null;const i=s?.properties??{},n=t.held.map(a=>a===_t?"Name":Ye(a,i[a]??{}));return e.jsxs("div",{role:"status",className:"rounded-md bg-amber-500/10 px-3 py-2 text-sm text-amber-700 dark:text-amber-300",children:[n.join(", ")," ",n.length===1?"needs":"need"," approval before ",n.length===1?"it changes":"they change",".",t.approvalUrl?e.jsxs(e.Fragment,{children:[" ",e.jsx("a",{href:t.approvalUrl,className:"underline",children:"Review"})]}):null]})}const kt=320,Nt={},St=()=>{};function wt({view:t,orgSlug:s,recordUrl:i,scope:n}){const a=X(),c=`${i}${he(t.key)}`,r=a?()=>a.open({href:c,title:t.name}):void 0;return e.jsxs("section",{className:"min-w-0 rounded-lg border","data-testid":"view-card","data-view":t.key,children:[e.jsxs("header",{className:"flex items-start justify-between gap-3 px-4 pt-3 pb-2",children:[e.jsxs("div",{className:"min-w-0",children:[e.jsx("h3",{className:"truncate text-sm font-medium",children:t.name}),t.description?e.jsx("p",{className:"truncate text-xs text-muted-foreground",children:t.description}):null]}),r?e.jsxs(S,{type:"button",variant:"ghost",size:"sm",className:"h-7 shrink-0 gap-1.5 px-2 text-muted-foreground hover:text-foreground",onClick:r,"aria-label":`Open ${t.name}`,children:[e.jsx(Re,{className:"h-3.5 w-3.5"}),"Open"]}):null]}),e.jsx("div",{className:"px-4 pb-3",children:e.jsx(fe,{orgSlug:s,viewKey:t.key,scope:n,params:Nt,onParamsChange:St,contentHash:t.content_hash,title:t.name,minHeight:64,displayMode:"inline",maxHeight:kt,onRequestDisplayMode:r?o=>{o==="fullscreen"&&r()}:void 0})})]})}function Rt({recordUrl:t,dirty:s,onDiscard:i}){const n=ht({disabled:!s,enableBeforeUnload:s,withResolver:!0,shouldBlockFn:({next:c})=>c.pathname!==t&&!c.pathname.startsWith(`${t}${he("")}`)}),a=n.status==="blocked";return e.jsx(Ie,{open:a,onOpenChange:c=>{!c&&a&&n.reset()},children:e.jsxs(Me,{className:"max-w-sm",children:[e.jsxs(Ae,{children:[e.jsx(ze,{children:"Discard unsaved changes?"}),e.jsx(Ue,{children:"This record has edits that are not saved. Leaving discards them."})]}),e.jsxs("div",{className:"flex justify-end gap-2",children:[e.jsx(S,{type:"button",variant:"ghost",onClick:()=>a&&n.reset(),children:"Keep editing"}),e.jsx(S,{type:"button",variant:"destructive",onClick:()=>{a&&(i(),n.proceed())},children:"Discard"})]})]})})}const ue=6;function Ft({entity:t,ownerSlug:s,orgContext:i,recordUrl:n,schema:a,entityTypeName:c,isTypeLoading:r,record:o,canEdit:u,editing:g,onEditingChange:p,outcome:x,onSaved:l,formId:m,fieldLimit:d,onDeleted:h}){const N=g&&u,f=X(),j={entity:{id:R(t),name:t.name,entity_type:t.entity_type},ownerSlug:s,orgContext:i,schema:a,record:o,editing:N};ut(j);const y=f?.item?.recordField,w={ownerSlug:s,orgContext:i,controls:t.field_controls,dirtyKeys:o.dirtyKeys,openField:f?E=>f.open(st(j,E.key)):void 0,openFieldKey:y?.entityId===R(t)?y.field:void 0},D=e.jsx(Rt,{recordUrl:n,dirty:N&&o.isDirty,onDiscard:()=>{o.reset(),p(!1)}});if(r)return e.jsx(Te,{rows:6});if(N)return e.jsxs(e.Fragment,{children:[D,e.jsx(Et,{formId:m,entity:t,entityTypeName:c,schema:a,record:o,orgContext:i,renderControl:(E,b,C)=>Je(b)?e.jsx(Ze,{field:{key:E,prop:b},value:C,context:w}):void 0,onSaved:l,onDeleted:h,onDone:()=>p(!1)})]});const O=Y(o.revision);return e.jsxs("div",{className:"space-y-3",children:[e.jsx(ve,{outcome:x,schema:a}),e.jsx(xe,{fields:O,fieldLimit:d,values:o.values.metadata,context:w})]})}function Et({formId:t,entity:s,entityTypeName:i,schema:n,record:a,orgContext:c,renderControl:r,onSaved:o,onDeleted:u,onDone:g}){const p=He(),x=s.field_controls,{name:l,slug:m,metadata:d}=a.values,h=v=>a.setValues(_=>({..._,name:v})),N=v=>a.setValues(_=>({..._,slug:v})),f=v=>a.setValues(_=>({..._,metadata:v})),[j,y]=B(R(s),""),[w,D]=B(R(s),null),[O,E]=B(R(s),null),[b,C]=B(R(s),!1),[P,V]=B(R(s),null),z=a.dirtyKeys.length>0,U=async v=>{if(v.preventDefault(),!!a.canSubmit){if(D(null),!l.trim()){D("Name is required");return}try{const _=await a.save({note:j});E(_),o(_),y(""),_?.held.length||g()}catch(_){D(_ instanceof Error?_.message:"Failed to update entity")}}},M=async()=>{V(null);try{if(typeof s.id!="number")throw new Error("Source records are read-only");await p.mutateAsync({entityId:s.id}),C(!1),u?.()}catch(v){V(v instanceof Error?v.message:"Failed to delete entity")}},L=[s.total_content>0&&`${s.total_content} content item${s.total_content===1?"":"s"}`,s.automations_count>0&&`${s.automations_count} Automation${s.automations_count===1?"":"s"}`,s.active_connections>0&&`${s.active_connections} connector${s.active_connections===1?"":"s"}`].filter(Boolean).join(", ");return e.jsxs("form",{id:t,onSubmit:U,className:"space-y-4",children:[e.jsx(Ke,{visible:a.hasConflict,onReload:a.reset}),e.jsxs("div",{className:"grid gap-2",children:[e.jsxs(H,{htmlFor:"sidebar-name",children:["Name ",e.jsx("span",{className:"text-destructive",children:"*"})]}),e.jsx(ie,{id:"sidebar-name",value:l,onChange:v=>h(v.target.value)})]}),e.jsxs("div",{className:"grid gap-2",children:[e.jsx(H,{htmlFor:"sidebar-slug",children:"URL Slug"}),e.jsx(ie,{id:"sidebar-slug",value:m,onChange:v=>N(v.target.value.toLowerCase().replace(/[^a-z0-9-]/g,""))})]}),a.revision&&Object.keys(a.revision).length>0&&e.jsxs(e.Fragment,{children:[e.jsx(nt,{}),e.jsx(et,{schema:a.revision,values:d,onValuesChange:f,fieldControls:x,orgContext:c,renderControl:r})]}),z&&e.jsxs("div",{className:"grid gap-2",children:[e.jsx(H,{htmlFor:"sidebar-correction-note",children:"Correction note (optional)"}),e.jsx(We,{id:"sidebar-correction-note",value:j,onChange:v=>y(v.target.value),placeholder:"Why are you changing these fields? Helps Automations respect the correction.",rows:2})]}),w&&e.jsx("div",{className:"rounded-md bg-destructive/10 px-3 py-2 text-sm text-destructive",children:w}),e.jsx(ve,{outcome:O,schema:n}),b?e.jsxs("div",{className:"space-y-3 rounded-lg border border-destructive/40 bg-destructive/5 p-3",children:[e.jsxs("div",{className:"flex items-start gap-2.5 text-sm",children:[e.jsx(qe,{className:"h-4 w-4 shrink-0 text-destructive mt-0.5"}),e.jsxs("div",{className:"space-y-1",children:[e.jsxs("p",{className:"font-medium text-foreground",children:['Delete "',s.name,'"?']}),L&&e.jsxs("p",{className:"text-muted-foreground",children:["Removes ",L,". This cannot be easily undone."]})]})]}),P&&e.jsx("div",{className:"rounded-md bg-destructive/10 px-2.5 py-1.5 text-sm text-destructive",children:P}),e.jsxs("div",{className:"flex justify-end gap-2",children:[e.jsx(S,{type:"button",variant:"ghost",size:"sm",onClick:()=>{C(!1),V(null)},children:"Cancel"}),e.jsx(S,{type:"button",variant:"destructive",size:"sm",onClick:M,disabled:p.isPending,children:p.isPending?"Deleting...":`Delete ${i||"entity"}`})]})]}):e.jsx("div",{className:"pt-2",children:e.jsx(S,{type:"button",variant:"ghost",size:"sm",className:"text-destructive hover:text-destructive",onClick:()=>C(!0),children:"Delete"})})]})}function je(t,s){const i=new Set(t.measure_columns??[]),n=s?.properties??{};return Object.keys(t.metadata??{}).filter(a=>a!=="id"&&a!=="slug"&&a!=="name"&&!$e(n[a])&&n[a]?.const===void 0).map(a=>({key:a,prop:n[a]??{},label:n[a]?.["x-table-label"]??(i.has(a)?a:Oe(a.replace(/_/g," "))),numeric:i.has(a)}))}function Dt({entity:t,schema:s,ownerSlug:i,fieldLimit:n}){const a=je(t,s);return e.jsxs("div",{children:[e.jsx("p",{className:"mb-3 text-xs text-muted-foreground",children:"Managed by the source"}),e.jsx(xe,{fields:a,fieldLimit:n,values:t.metadata??{},context:{ownerSlug:i}})]})}const Ct=720,me="owletto:record-details-expanded";function Lt(){const[t,s]=F.useState(()=>{try{return window.localStorage.getItem(me)==="1"}catch{return!1}});return[t,n=>{s(n);try{window.localStorage.setItem(me,n?"1":"0")}catch{}}]}function Bt({schema:t,metadata:s}){const i=Y(t).filter(({key:n,prop:a})=>a["x-table-column"]===!0&&!a["x-image"]&&s[n]!==void 0&&s[n]!==null&&s[n]!=="");return i.length===0?null:e.jsx("p",{"data-testid":"record-summary",className:"-mt-2 truncate text-sm text-muted-foreground tabular-nums",children:i.map(({key:n,prop:a},c)=>e.jsxs("span",{children:[c>0?" · ":null,e.jsx(tt,{value:s[n],prop:a})]},n))})}function Pt({namespace:t,entity:s,recordUrl:i,viewKey:n,title:a,onDeleted:c}){const r=Fe({strict:!1}),o=pe(),u=F.useRef(null),g=Ee(u,Ct),[p,x]=Lt(),[l,m]=B(R(s),!1),d={slug:t.slug,organizationId:t.id},{isMember:h,isLoading:N}=De(t.slug),f=Ce({...d,organizationId:h?t.id:null}),{data:j,isLoading:y}=G(s.entity_type,d),w=j?.metadata_schema,{isAdmin:D,isLoading:O}=Le(h?d.organizationId:void 0),E=h&&D&&!O&&!s.is_derived,b=gt({entity:s,schema:w,orgContext:d}),[C,P]=B(R(s),null),V=`record-form-${s.id}`,z=l&&E,U=h?f.data??[]:[],M=Be(U,{type:s.entity_type,id:R(s)}),L=Pe(M,n),v=!n&&r.tab==="relationships",_=k=>void o({to:".",search:k,replace:!0}),J={type:s.entity_type,entity:s.is_derived?s.slug:s.id??s.slug},T=g&&!p&&!l&&!v,Z=s.is_derived?oe(je(s,w),s.metadata??{}).length:oe(Y(b.revision),b.values.metadata).length,ee=T?ue:void 0,te=e.jsxs("div",{className:"space-y-6",children:[s.is_derived?e.jsxs(e.Fragment,{children:[e.jsx(Dt,{entity:s,schema:w,ownerSlug:t.slug,fieldLimit:ee}),e.jsx(bt,{record:{type:s.entity_type,key:s.slug},ownerSlug:t.slug,orgContext:d,focus:v})]}):e.jsxs(e.Fragment,{children:[e.jsx(Ft,{entity:s,ownerSlug:t.slug,orgContext:d,recordUrl:i,schema:w,entityTypeName:j?.name,isTypeLoading:y,record:b,canEdit:E,editing:l,onEditingChange:m,outcome:C,onSaved:P,formId:V,fieldLimit:ee,onDeleted:c}),e.jsx(yt,{entityId:typeof s.id=="number"?s.id:void 0,entityName:s.name,ownerSlug:t.slug,orgContext:d,focus:v,collapsed:T})]}),g&&!l&&!v?e.jsx(S,{type:"button",variant:"ghost",size:"sm",className:"h-8 px-2 text-primary hover:text-primary","aria-expanded":!T,onClick:()=>x(T),children:T?Z>ue?`Show all ${Z} fields`:"Show all details":"Show fewer"}):null]}),ye=k=>e.jsx("div",{ref:u,className:"min-w-0 space-y-4",children:g?e.jsxs(e.Fragment,{children:[e.jsx(Bt,{schema:w,metadata:s.metadata??{}}),e.jsx("section",{"aria-label":"Details","data-testid":"record-details",children:te}),k]}):e.jsxs("div",{className:"grid grid-cols-[18rem_minmax(0,1fr)] gap-6",children:[e.jsx("aside",{className:"sticky top-12 max-h-[calc(100dvh-7rem)] min-w-0 self-start overflow-y-auto overscroll-contain pr-2 pb-16",children:te}),k]})}),be=z?e.jsxs("div",{className:"flex shrink-0 items-center gap-2",children:[e.jsx(S,{type:"button",variant:"ghost",size:"sm",onClick:()=>{b.reset(),P(null),m(!1)},children:"Cancel"}),e.jsx(S,{type:"submit",form:V,size:"sm",disabled:!b.canSubmit||!b.isDirty||b.saving||!b.values.name.trim(),children:b.saving?"Saving...":"Save"})]}):E&&!y?e.jsxs(S,{type:"button",variant:"ghost",size:"sm",className:"h-8 shrink-0 gap-1.5 px-2 text-muted-foreground hover:text-foreground",onClick:()=>{P(null),m(!0)},children:[e.jsx(Ve,{className:"h-3.5 w-3.5"}),"Edit"]}):null,I=k=>e.jsxs(e.Fragment,{children:[e.jsxs("div",{"data-testid":"record-header",className:"sticky top-0 z-30 -mx-4 flex h-12 items-center justify-between gap-3 bg-background px-4 lg:-mx-6 lg:px-6",children:[e.jsx("div",{className:"flex min-w-0 items-center gap-2",children:a}),be]}),k]});if(n&&!h)return I(N?null:e.jsx(at,{}));if(n&&f.data===void 0)return I(f.isError?e.jsx(le,{onRetry:()=>void f.refetch()}):null);if(L.kind==="missing")return I(e.jsx(rt,{viewKey:L.key,backTo:i,backLabel:`Back to ${s.name}`}));if(L.kind==="view"){const{view:k}=L;return I(e.jsxs("div",{className:"min-w-0 space-y-3",children:[e.jsx(ot,{decls:k.params,params:ne(r),onParamsChange:_e=>void o({to:".",search:_e})}),e.jsx(fe,{orgSlug:t.slug,viewKey:k.key,scope:J,params:ne(r),onParamsChange:_,contentHash:k.content_hash,title:k.name,minHeight:320})]}))}return I(ye(e.jsxs("div",{className:"min-w-0 space-y-4",children:[h&&f.isError&&e.jsx(le,{onRetry:()=>void f.refetch()}),M.map(k=>e.jsx(wt,{view:k,orgSlug:t.slug,recordUrl:i,scope:J},k.key)),e.jsxs("section",{"aria-labelledby":"record-activity-heading",className:"min-w-0",children:[e.jsx("h2",{id:"record-activity-heading",className:"mb-2 text-sm font-medium text-muted-foreground",children:"Activity"}),e.jsx(Qe,{entity:s,organizationId:t.id,ownerSlug:t.slug})]})]})))}function Vt(t){return t?.trim()?t:void 0}function is({namespace:t,path:s,entity:i,viewKey:n}){const a=pe(),{data:c}=G(i.entity_type,{slug:t.slug}),r=s[0]?.entity_type??i.entity_type,{data:o}=G(r,{slug:t.slug}),u=Vt(c?.icon),g=s.map(l=>({entity_type:l.entity_type,slug:l.slug})),p=`/${t.slug}/${re(i.entity_type)}`,x=K(t.slug,g);return e.jsxs("div",{className:"mx-auto flex min-h-0 w-full max-w-7xl flex-1 flex-col gap-4 px-4 pt-2.5 pb-8 lg:px-6",children:[e.jsx(Ge,{crumbs:[...r==="$member"?[]:[e.jsx(W,{to:"/$owner/data",params:{owner:t.slug},className:q,children:"Memory"},"memory")],e.jsx(W,{to:`/${t.slug}/${re(r)}`,className:q,children:r==="$member"?"Team":o?.name??r},"type"),...s.slice(0,-1).map((l,m)=>e.jsx(W,{to:K(t.slug,g.slice(0,m+1)),className:q,children:l.name},l.id))],current:i.name}),e.jsx(Pt,{namespace:t,entity:i,recordUrl:x,viewKey:n,title:e.jsxs(e.Fragment,{children:[e.jsx(it,{metadata:i.metadata,metadataSchema:c?.metadata_schema,name:i.name,typeIcon:u,className:"h-6 w-6 shrink-0"}),e.jsx("h2",{className:"truncate text-lg font-semibold leading-tight",children:i.name})]}),onDeleted:()=>{const l=s.slice(0,-1);l.length>0?a({to:K(t.slug,l)}):a({to:p})}})]})}export{is as EntityPage};
|
|
2
|
+
//# sourceMappingURL=entity-page-CY7PF3X9.js.map
|
|
@@ -0,0 +1,2 @@
|
|
|
1
|
+
import{j as e,o as $,e$ as me,fK as xe,f2 as K,bx as ae,r as x,f0 as he,f1 as pe,dC as ge,dE as fe,B as f,d3 as V,dD as je,E as C,bn as q,bo as P,bp as M,bq as L,br as R,I as O,a3 as ve,fa as Ne,fL as ye,Q,dT as be,X as W,cF as ne,C as re,U as we,b0 as le,fM as ie,fN as Se,b7 as oe,fO as Ce,fD as ke,bO as Ee,bP as Y,bS as _e,fP as Re,by as Oe,fQ as Te,fR as De,T as G,L as Ae}from"./index-JmEl29py.js";import{C as Fe,J as U}from"./json-diff-4sMmayDd.js";import{C as ce}from"./code-editor-C8FJbT2P.js";function ze({entry:s}){return e.jsxs("div",{className:"relative pl-6 pb-6 last:pb-0",children:[e.jsx("div",{className:"absolute left-0 top-1.5 h-3 w-3 rounded-full border-2 border-border bg-background"}),e.jsx("div",{className:"absolute left-[5px] top-5 bottom-0 w-px bg-border last:hidden"}),e.jsxs("div",{className:"space-y-1",children:[e.jsx(Fe,{operation:s.action,actor:s.actor,createdAt:s.created_at}),s.action==="update"&&e.jsx(U,{before:s.before_payload,after:s.after_payload}),s.action==="create"&&s.after_payload&&e.jsx(U,{before:null,after:s.after_payload}),s.action==="delete"&&s.before_payload&&e.jsx(U,{before:s.before_payload,after:null})]})]})}function qe({entityType:s}){const{orgContext:a}=$(),{data:c,isLoading:n}=me(a),{data:r}=xe(a),t=(c||[]).filter(m=>m.status==="active"),i=t.filter(m=>!m.organization_slug||m.organization_slug===a?.slug),o=i.filter(m=>m.purpose!==K),d=i.filter(m=>m.purpose===K),h=t.filter(m=>m.organization_slug&&m.organization_slug!==a?.slug);return e.jsx("div",{className:"space-y-4 py-4",children:n?e.jsx(ae,{label:"relationships",variant:"rows",rows:4}):e.jsxs(e.Fragment,{children:[e.jsx(B,{entityTypeSlug:s.slug,relationshipTypes:o,allEntityTypes:r||[]}),d.length>0&&e.jsxs("div",{className:"space-y-2 pt-2",children:[e.jsx("h4",{className:"text-xs font-medium text-muted-foreground uppercase tracking-wide",children:"Managed by access control"}),e.jsx(B,{entityTypeSlug:s.slug,relationshipTypes:d,allEntityTypes:r||[],readOnly:!0})]}),h.length>0&&e.jsxs("div",{className:"space-y-2 pt-2",children:[e.jsx("h4",{className:"text-xs font-medium text-muted-foreground uppercase tracking-wide",children:"From public catalogs"}),e.jsx(B,{entityTypeSlug:s.slug,relationshipTypes:h,allEntityTypes:r||[],readOnly:!0})]}),e.jsx(Le,{entityTypeSlug:s.slug,relationshipTypes:o,allEntityTypes:r||[]})]})})}function B({entityTypeSlug:s,relationshipTypes:a,allEntityTypes:c,readOnly:n=!1}){return e.jsx("div",{className:"space-y-2",children:a.map(r=>e.jsx(Pe,{relationshipType:r,entityTypeSlug:s,allEntityTypes:c,readOnly:n},r.id))})}function Pe({relationshipType:s,entityTypeSlug:a,allEntityTypes:c,readOnly:n=!1}){const{orgContext:r}=$(),{data:t}=Ne(s.slug,r),i=ye(),o=(t||[]).filter(h=>h.source_entity_type_slug===a||h.target_entity_type_slug===a);if(o.length===0)return null;const d=new Map(c.map(h=>[h.slug,h.name]));return e.jsxs("div",{className:"space-y-1.5",children:[e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx("span",{className:"text-sm font-medium",children:s.name}),e.jsx("code",{className:"text-[11px] bg-muted px-1.5 py-0.5 rounded text-muted-foreground",children:s.slug}),s.is_symmetric&&e.jsx(Q,{variant:"secondary",className:"text-[10px] px-1.5 py-0",children:"symmetric"}),n&&e.jsx(Q,{variant:"outline",className:"text-[10px] px-1.5 py-0",children:"read-only"})]}),o.map(h=>e.jsx(Me,{rule:h,entityTypeSlug:a,entityTypeNameMap:d,onRemove:()=>i.mutate(h.id),isRemoving:i.isPending,readOnly:n},h.id))]})}function Me({rule:s,entityTypeSlug:a,entityTypeNameMap:c,onRemove:n,isRemoving:r,readOnly:t=!1}){const[i,o]=x.useState(!1),d=s.source_entity_type_slug===a,h=d?s.target_entity_type_slug:s.source_entity_type_slug,m=c.get(h)||h;return e.jsxs("div",{className:"flex items-center gap-2 py-1.5 px-3 rounded-md border border-border bg-muted/30 text-sm",children:[e.jsx("span",{className:"text-muted-foreground",children:d?"this":m}),e.jsx(be,{className:"h-3 w-3 text-muted-foreground shrink-0"}),e.jsx("span",{className:"text-muted-foreground",children:d?m:"this"}),t?null:i?e.jsxs("div",{className:"flex items-center gap-1 ml-auto",children:[e.jsx(f,{variant:"destructive",size:"sm",className:"h-6 px-2 text-xs",onClick:n,disabled:r,children:r?"Removing...":"Remove"}),e.jsx(f,{variant:"ghost",size:"sm",className:"h-6 px-2 text-xs",onClick:()=>o(!1),disabled:r,children:"Cancel"})]}):e.jsx("div",{className:"ml-auto",children:e.jsx(f,{variant:"ghost",size:"sm",className:"h-6 w-6 p-0 text-muted-foreground hover:text-destructive",onClick:()=>o(!0),disabled:r,children:e.jsx(W,{className:"h-3 w-3"})})})]})}function Le({entityTypeSlug:s,relationshipTypes:a,allEntityTypes:c}){const{orgContext:n}=$(),r=c.filter(l=>!l.organization_slug||l.organization_slug===n?.slug),[t,i]=x.useState(!1),[o,d]=x.useState("existing"),[h,m]=x.useState(""),[S,N]=x.useState(""),[y,b]=x.useState("source"),[g,j]=x.useState(""),[k,E]=x.useState(""),[D,w]=x.useState(!1),[A,_]=x.useState(null),u=he(),p=pe(),v=()=>{d("existing"),m(""),N(""),b("source"),j(""),E(""),w(!1),_(null)},T=l=>{i(l),l||v()},F=l=>l.toLowerCase().replace(/[^a-z0-9]+/g,"_").replace(/^_+|_+$/g,""),J=async()=>{_(null);try{let l=h;if(o==="new"){if(!g.trim()){_("Name is required");return}const H=k.trim()||F(g);if(!H){_("Slug is required");return}l=(await u.mutateAsync({slug:H,name:g.trim(),is_symmetric:D})).relationship_type.slug}if(!l){_("Select a relationship type");return}if(!S){_("Select a target entity type");return}const I=y==="source"?s:S,ue=y==="source"?S:s;await p.mutateAsync({slug:l,source_entity_type_slug:I,target_entity_type_slug:ue}),T(!1)}catch(l){_(l instanceof Error?l.message:"An error occurred")}},z=u.isPending||p.isPending;return e.jsxs(ge,{open:t,onOpenChange:T,children:[e.jsx(fe,{asChild:!0,children:e.jsxs(f,{variant:"outline",size:"sm",className:"w-full",children:[e.jsx(V,{className:"h-3.5 w-3.5 mr-1.5"}),"Add Relationship Rule"]})}),e.jsx(je,{className:"w-80 p-4",align:"start",children:e.jsxs("div",{className:"space-y-3",children:[e.jsxs("div",{className:"space-y-1.5",children:[e.jsx(C,{className:"text-xs",children:"Relationship Type"}),e.jsxs("div",{className:"flex gap-1.5",children:[e.jsx(f,{variant:o==="existing"?"default":"outline",size:"sm",className:"h-7 text-xs flex-1",onClick:()=>d("existing"),children:"Existing"}),e.jsx(f,{variant:o==="new"?"default":"outline",size:"sm",className:"h-7 text-xs flex-1",onClick:()=>d("new"),children:"Create New"})]})]}),o==="existing"?e.jsxs(q,{value:h,onValueChange:m,children:[e.jsx(P,{className:"h-8 text-sm",children:e.jsx(M,{placeholder:"Select relationship type..."})}),e.jsxs(L,{children:[a.map(l=>e.jsx(R,{value:l.slug,children:l.name},l.slug)),a.length===0&&e.jsx("div",{className:"px-2 py-1.5 text-xs text-muted-foreground",children:"No relationship types yet. Create one."})]})]}):e.jsxs("div",{className:"space-y-2",children:[e.jsx(O,{placeholder:"Name (e.g. Integrates With)",className:"h-8 text-sm",value:g,onChange:l=>{j(l.target.value),k||E("")}}),e.jsx(O,{placeholder:g?F(g)||"slug":"Slug (auto-generated)",className:"h-8 text-sm",value:k,onChange:l=>E(l.target.value)}),e.jsxs("label",{className:"flex items-center gap-2 text-xs cursor-pointer",children:[e.jsx("input",{type:"checkbox",checked:D,onChange:l=>w(l.target.checked),className:"rounded"}),"Symmetric (A↔B = B↔A)"]})]}),e.jsxs("div",{className:"space-y-1.5",children:[e.jsx(C,{className:"text-xs",children:"Direction"}),e.jsxs(q,{value:y,onValueChange:l=>b(l),children:[e.jsx(P,{className:"h-8 text-sm",children:e.jsx(M,{})}),e.jsxs(L,{children:[e.jsx(R,{value:"source",children:"This type → other"}),e.jsx(R,{value:"target",children:"Other → this type"})]})]})]}),e.jsxs("div",{className:"space-y-1.5",children:[e.jsxs(C,{className:"text-xs",children:[y==="source"?"Target":"Source"," Entity Type"]}),e.jsxs(q,{value:S,onValueChange:N,children:[e.jsx(P,{className:"h-8 text-sm",children:e.jsx(M,{placeholder:"Select entity type..."})}),e.jsx(L,{children:r.map(l=>e.jsxs(R,{value:l.slug,children:[l.icon?`${l.icon} `:"",l.name]},l.slug))})]})]}),A&&e.jsx("p",{className:"text-xs text-destructive",children:A}),e.jsx(f,{size:"sm",className:"w-full",onClick:J,disabled:z,children:z?e.jsxs(e.Fragment,{children:[e.jsx(ve,{className:"mr-1.5"}),"Saving..."]}):"Add Rule"})]})})]})}function Ie({options:s,onChange:a}){const[c,n]=x.useState(""),r=()=>{const i=c.trim();i&&!s.includes(i)&&(a([...s,i]),n(""))},t=i=>{a(s.filter((o,d)=>d!==i))};return e.jsxs("div",{className:"space-y-2 pl-4 border-l-2 border-muted",children:[e.jsx("div",{className:"flex flex-wrap gap-1.5",children:s.map((i,o)=>e.jsxs("span",{className:"inline-flex items-center gap-1 bg-muted text-sm px-2 py-0.5 rounded",children:[i,e.jsx("button",{type:"button",onClick:()=>t(o),className:"text-muted-foreground hover:text-foreground",children:e.jsx(W,{className:"h-3 w-3"})})]},i))}),e.jsxs("div",{className:"flex gap-1.5",children:[e.jsx(O,{value:c,onChange:i=>n(i.target.value),onKeyDown:i=>{i.key==="Enter"&&(i.preventDefault(),r())},placeholder:"Add option...",className:"h-7 text-sm"}),e.jsx(f,{type:"button",variant:"outline",size:"sm",className:"h-7 px-2",onClick:r,children:e.jsx(V,{className:"h-3 w-3"})})]})]})}const Ve=[{value:"string",label:"Text"},{value:"number",label:"Number"},{value:"integer",label:"Whole number"},{value:"boolean",label:"Yes/No"},{value:"enum",label:"Choice"}];function Je({examples:s,onChange:a}){const[c,n]=x.useState(""),r=()=>{const t=c.trim();t&&!s.includes(t)&&(a([...s,t]),n(""))};return e.jsxs("div",{className:"space-y-1.5",children:[e.jsx("div",{className:"flex flex-wrap gap-1.5",children:s.map((t,i)=>e.jsxs("span",{className:"inline-flex items-center gap-1 bg-muted text-xs px-2 py-0.5 rounded",children:[t,e.jsx("button",{type:"button",onClick:()=>a(s.filter((o,d)=>d!==i)),className:"text-muted-foreground hover:text-foreground",children:e.jsx(W,{className:"h-3 w-3"})})]},t))}),e.jsxs("div",{className:"flex gap-1.5",children:[e.jsx(O,{value:c,onChange:t=>n(t.target.value),onKeyDown:t=>{t.key==="Enter"&&(t.preventDefault(),r())},placeholder:"Add example...",className:"h-7 text-xs"}),e.jsx(f,{type:"button",variant:"outline",size:"sm",className:"h-7 px-2",onClick:r,children:e.jsx(V,{className:"h-3 w-3"})})]})]})}function Ue({field:s,onChange:a,onDelete:c}){const[n,r]=x.useState(!!(s.description||s.default||s.role||s.examples&&s.examples.length>0));return e.jsxs("div",{className:"rounded-md border border-border p-2.5 space-y-2",children:[e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx("button",{type:"button",onClick:()=>r(!n),className:"text-muted-foreground hover:text-foreground shrink-0",children:n?e.jsx(ne,{className:"h-3.5 w-3.5"}):e.jsx(re,{className:"h-3.5 w-3.5"})}),e.jsx(O,{value:s.name,onChange:t=>a({...s,name:t.target.value}),placeholder:"Field name",className:"h-8 flex-1"}),e.jsxs(q,{value:s.type,onValueChange:t=>a({...s,type:t,enumOptions:t==="enum"?s.enumOptions||[]:void 0,role:t==="enum"||s.role!=="workflowState"?s.role:void 0}),children:[e.jsx(P,{className:"h-8 w-32",children:e.jsx(M,{})}),e.jsx(L,{children:Ve.map(t=>e.jsx(R,{value:t.value,children:t.label},t.value))})]}),e.jsxs("div",{className:"flex items-center gap-1.5 text-sm text-muted-foreground whitespace-nowrap",children:[e.jsx(we,{checked:s.required,onCheckedChange:t=>a({...s,required:t===!0})}),e.jsx("span",{children:"Required"})]}),e.jsx(f,{type:"button",variant:"ghost",size:"sm",className:"h-8 w-8 p-0 text-muted-foreground hover:text-destructive",onClick:c,children:e.jsx(le,{className:"h-3.5 w-3.5"})})]}),s.type==="enum"&&e.jsx("div",{className:"pl-6",children:e.jsx(Ie,{options:s.enumOptions||[],onChange:t=>a({...s,enumOptions:t})})}),n&&e.jsxs("div",{className:"pl-6 space-y-2 pt-1",children:[e.jsxs("div",{className:"grid grid-cols-3 gap-2",children:[e.jsxs("div",{children:[e.jsx("span",{className:"text-[11px] text-muted-foreground font-medium",children:"Description"}),e.jsx(O,{value:s.description||"",onChange:t=>a({...s,description:t.target.value||void 0}),placeholder:"Field description",className:"h-7 text-xs mt-0.5"})]}),e.jsxs("div",{children:[e.jsx("span",{className:"text-[11px] text-muted-foreground font-medium",children:"Default"}),e.jsx(O,{value:s.default||"",onChange:t=>a({...s,default:t.target.value||void 0}),placeholder:s.type==="boolean"?"true / false":"Default value",className:"h-7 text-xs mt-0.5"})]}),e.jsxs("div",{children:[e.jsx("span",{className:"text-[11px] text-muted-foreground font-medium",children:"View role"}),e.jsxs(q,{value:s.role||"none",onValueChange:t=>a({...s,role:t==="workflowState"||t==="sortRank"?t:void 0}),children:[e.jsx(P,{className:"h-7 text-xs mt-0.5",children:e.jsx(M,{})}),e.jsxs(L,{children:[e.jsx(R,{value:"none",children:"None"}),e.jsx(R,{value:"workflowState",disabled:s.type!=="enum",children:"Workflow state (board)"}),e.jsx(R,{value:"sortRank",children:"Sort rank"})]})]})]})]}),e.jsxs("div",{children:[e.jsx("span",{className:"text-[11px] text-muted-foreground font-medium",children:"Examples"}),e.jsx("div",{className:"mt-0.5",children:e.jsx(Je,{examples:s.examples||[],onChange:t=>a({...s,examples:t.length>0?t:void 0})})})]})]})]})}function X({value:s,onChange:a,readonly:c,error:n}){return e.jsxs("div",{className:"space-y-2",children:[e.jsx(ce,{value:s,onChange:a,readonly:c,placeholder:'{ "type": "object", "properties": {} }',minHeight:"200px"}),n&&e.jsx("p",{className:"text-sm text-destructive",children:n})]})}function Z(s){if(s.type!=="object")return!1;const a=s.properties;if(!a||typeof a!="object")return Object.keys(s).length<=1;for(const c of Object.values(a)){if(!c||typeof c!="object")return!1;const n=c,r=n.type;if(!n.enum&&(!r||!["string","number","integer","boolean"].includes(r)||n.properties||n.items||n.allOf||n.oneOf||n.anyOf))return!1}return!0}function de(){return typeof crypto<"u"&&typeof crypto.randomUUID=="function"?crypto.randomUUID():`field-${Date.now()}-${Math.random().toString(36).slice(2,10)}`}function ee(s){const a=s.properties||{},c=s.required||[];return Object.entries(a).map(([n,r])=>{const t=r["x-lobu"]?.role||r["x-lobu-role"],i=t==="workflowState"?"workflowState":t==="sortRank"?"sortRank":void 0,o={id:de(),name:n,required:c.includes(n),description:r.description||void 0,default:r.default!==void 0?String(r.default):void 0,examples:Array.isArray(r.examples)?r.examples.map(String):void 0,role:i};return r.enum?{...o,type:"enum",enumOptions:r.enum||[]}:{...o,type:r.type||"string"}})}function se(s,a){if(a==="number"||a==="integer"){const c=Number(s);return Number.isNaN(c)?s:c}return a==="boolean"?s==="true"?!0:s==="false"?!1:s:s}function Be(s,a="auto"){const c={},n=[];for(const t of s){if(!t.name.trim())continue;const i={};t.type==="enum"?i.enum=t.enumOptions||[]:i.type=t.type,t.description?.trim()&&(i.description=t.description.trim()),t.default!==void 0&&t.default!==""&&(i.default=se(t.default,t.type)),t.examples&&t.examples.length>0&&(i.examples=t.examples.map(o=>se(o,t.type))),t.role&&(i["x-lobu"]={role:t.role,...t.role==="workflowState"&&t.type==="enum"?{states:(t.enumOptions||[]).map(o=>({value:o,label:o.replace(/[_-]+/g," ").replace(/\b\w/g,d=>d.toUpperCase()),terminal:["done","complete","completed","closed","archived"].includes(o.toLowerCase())}))}:{}}),c[t.name]=i,t.required&&n.push(t.name)}const r={type:"object",properties:c};return n.length>0&&(r.required=n),a&&a!=="auto"&&(r["x-lobu"]={defaultView:a}),r}function te(s){const a=s["x-lobu"]?.defaultView;return a==="table"||a==="board"?a:"auto"}function $e({value:s,onChange:a,readonly:c=!1}){const[n,r]=x.useState("visual"),[t,i]=x.useState([]),[o,d]=x.useState("auto"),[h,m]=x.useState(""),[S,N]=x.useState(null),[y,b]=x.useState(!1),g=x.useRef(!1);x.useEffect(()=>{if(g.current){g.current=!1;return}if(!s||Object.keys(s).length===0){i([]),d("auto"),m(""),b(!1);return}const u=JSON.stringify(s,null,2);m(u),d(te(s)),Z(s)?(i(ee(s)),b(!1)):(b(!0),r("json"))},[s]);const j=x.useCallback((u,p)=>{g.current=!0;const v=Be(u,p),T=u.some(F=>F.name.trim());m(T?JSON.stringify(v,null,2):""),a(T?v:void 0)},[a]),k=x.useCallback(u=>{i(u),j(u,o)},[j,o]),E=x.useCallback(u=>{d(u),j(t,u)},[j,t]),D=x.useCallback(u=>{if(g.current=!0,m(u),!u.trim()){N(null),i([]),d("auto"),a(void 0);return}try{const p=JSON.parse(u);N(null),d(te(p)),Z(p)?(i(ee(p)),b(!1)):b(!0),a(p)}catch(p){N(p instanceof Error?p.message:"Invalid JSON")}},[a]),w=()=>{k([...t,{id:de(),name:"",type:"string",required:!1}])},A=(u,p)=>{const v=[...t];v[u]=p,k(v)},_=u=>{k(t.filter((p,v)=>v!==u))};return c?e.jsx(X,{value:h,onChange:()=>{},readonly:!0}):e.jsxs("div",{className:"space-y-3",children:[e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsxs(f,{type:"button",variant:n==="visual"?"default":"outline",size:"sm",onClick:()=>!y&&r("visual"),disabled:y,className:"h-7 text-xs",children:[e.jsx(ie,{className:"h-3 w-3 mr-1"}),"Visual"]}),e.jsxs(f,{type:"button",variant:n==="json"?"default":"outline",size:"sm",onClick:()=>r("json"),className:"h-7 text-xs",children:[e.jsx(Se,{className:"h-3 w-3 mr-1"}),"JSON"]})]}),y&&e.jsxs("div",{className:"flex items-start gap-2 p-2 rounded-md bg-amber-500/10 text-amber-600 text-xs",children:[e.jsx(oe,{className:"h-3.5 w-3.5 mt-0.5 shrink-0"}),e.jsx("span",{children:"This schema uses advanced features (nested objects, allOf, etc.) that can only be edited in JSON mode."})]}),n==="visual"?e.jsxs("div",{className:"space-y-3",children:[t.map((u,p)=>e.jsx(Ue,{field:u,onChange:v=>A(p,v),onDelete:()=>_(p)},u.id)),e.jsxs(f,{type:"button",variant:"outline",size:"sm",onClick:w,className:"w-full",children:[e.jsx(V,{className:"h-3.5 w-3.5 mr-1"}),"Add Field"]}),t.some(u=>u.name.trim())&&e.jsxs("div",{className:"flex items-center gap-3 rounded-md border border-border p-2.5",children:[e.jsxs("div",{className:"flex-1",children:[e.jsx("span",{className:"text-[11px] text-muted-foreground font-medium",children:"Default view"}),e.jsx("p",{className:"text-[11px] text-muted-foreground/70",children:"Which view this type opens in. Auto picks from your fields (a workflow field → board, otherwise table)."})]}),e.jsxs(q,{value:o,onValueChange:u=>E(u),children:[e.jsx(P,{className:"h-8 w-32 text-xs",children:e.jsx(M,{})}),e.jsxs(L,{children:[e.jsx(R,{value:"auto",children:"Auto"}),e.jsx(R,{value:"table",children:"Table"}),e.jsx(R,{value:"board",children:"Board"})]})]})]})]}):e.jsx(X,{value:h,onChange:D,error:S})]})}function We(s){return s.toLowerCase().replace(/[^a-z0-9]+/g,"-").replace(/^-+|-+$/g,"")}function He({entityType:s,onCancel:a,onSaved:c}){const n=!!s,r=Ce(),t=ke(),i=s?.slug??"new",o=Ee(i,{name:s?.name??"",slug:s?.slug??"",description:s?.description??"",icon:s?.icon??"",color:s?.color??"",metadataSchema:s?.metadata_schema??void 0,backingSql:s?.backing_sql??""}),[d,h]=o.field("name"),[m,S]=o.field("slug"),[N,y]=o.field("description"),[b,g]=o.field("icon"),[j,k]=o.field("color"),[E,D]=o.field("metadataSchema"),[w,A]=o.field("backingSql"),[_,u]=Y(i,n),[p,v]=Y(i,null),T=w.trim().length>0,F=l=>{h(l),!n&&!_&&S(We(l))},J=async()=>{if(!o.canSubmit)return;if(v(null),!d.trim()){v("Name is required");return}if(!n&&!m.trim()){v("Slug is required");return}const l=T?{sql:w.trim()}:null;try{n?await t.mutateAsync({slug:s.slug,name:d.trim(),description:N.trim()||void 0,icon:b.trim()||void 0,color:j.trim()||void 0,metadata_schema:T?void 0:E,backing:l}):await r.mutateAsync({slug:m.trim(),name:d.trim(),description:N.trim()||void 0,icon:b.trim()||void 0,color:j.trim()||void 0,metadata_schema:T?void 0:E,backing:l}),c()}catch(I){v(I instanceof Error?I.message:"An error occurred")}},z=r.isPending||t.isPending;return e.jsxs("div",{className:"space-y-5",children:[e.jsx(_e,{visible:o.hasConflict,onReload:o.reset}),e.jsxs("div",{className:"space-y-1.5",children:[e.jsx(C,{htmlFor:"et-name",children:"Name"}),e.jsx(O,{id:"et-name",value:d,onChange:l=>F(l.target.value),placeholder:"e.g. Product"})]}),e.jsxs("div",{className:"space-y-1.5",children:[e.jsx(C,{htmlFor:"et-slug",children:"Slug"}),e.jsx(O,{id:"et-slug",value:m,onChange:l=>{u(!0),S(l.target.value)},placeholder:"e.g. topic",disabled:n}),n&&e.jsx("p",{className:"text-xs text-muted-foreground",children:"Slug cannot be changed after creation."})]}),e.jsxs("div",{className:"space-y-1.5",children:[e.jsx(C,{htmlFor:"et-desc",children:"Description"}),e.jsx(Re,{id:"et-desc",value:N,onChange:l=>y(l.target.value),placeholder:"Optional description...",rows:2})]}),e.jsxs("div",{className:"grid grid-cols-2 gap-3",children:[e.jsxs("div",{className:"space-y-1.5",children:[e.jsx(C,{htmlFor:"et-icon",children:"Icon (emoji)"}),e.jsx(O,{id:"et-icon",value:b,onChange:l=>g(l.target.value),placeholder:"e.g. 📦"})]}),e.jsxs("div",{className:"space-y-1.5",children:[e.jsx(C,{htmlFor:"et-color",children:"Color"}),e.jsxs("div",{className:"flex gap-2",children:[e.jsx(O,{id:"et-color",value:j,onChange:l=>k(l.target.value),placeholder:"e.g. #6366f1",className:"flex-1"}),j&&e.jsx("div",{className:"h-9 w-9 rounded-md border border-border shrink-0",style:{backgroundColor:j}})]})]})]}),e.jsxs("div",{className:"space-y-1.5",children:[e.jsx(C,{children:"Backing query (SQL)"}),e.jsx("p",{className:"text-xs text-muted-foreground",children:"Optional. A read-only SELECT turns this into a derived (view) type — rows are computed from the query, not stored. Leave empty for a normal stored type. Table references are auto-scoped to your organization."}),e.jsx(ce,{value:w,onChange:A,minHeight:"120px",placeholder:"SELECT (metadata->>'vendor') AS vendor, SUM((metadata->>'amount')::numeric) AS total FROM events GROUP BY 1"})]}),T?e.jsxs("div",{className:"space-y-1.5",children:[e.jsxs("div",{className:"flex items-start gap-2 rounded-lg bg-muted px-3 py-2 text-sm text-muted-foreground",children:[e.jsx(ie,{className:"mt-0.5 h-4 w-4 shrink-0"}),e.jsx("span",{children:"Derived view — columns are computed from the query, so there's no stored-row schema to define."})]}),s?.measure_columns&&s.measure_columns.length>0&&e.jsxs("div",{className:"space-y-1 pt-1",children:[e.jsx(C,{children:"Measure columns"}),e.jsx("div",{className:"flex flex-wrap gap-1.5",children:s.measure_columns.map(l=>e.jsx("span",{className:"rounded-md border border-border bg-muted px-2 py-0.5 font-mono text-xs text-muted-foreground",children:l},l))})]})]}):e.jsxs("div",{className:"space-y-1.5",children:[e.jsx(C,{children:"Metadata Schema"}),e.jsx("p",{className:"text-xs text-muted-foreground",children:"Define the structure of metadata fields for entities of this type."}),e.jsx($e,{value:E,onChange:D})]}),n&&e.jsxs("div",{className:"space-y-1.5",children:[e.jsx(C,{children:"Relationships"}),e.jsx("p",{className:"text-xs text-muted-foreground",children:"Define how this entity type relates to others."}),e.jsx(qe,{entityType:s})]}),p&&e.jsx("div",{className:"p-3 rounded-md bg-destructive/10 text-destructive text-sm",children:p}),e.jsx(Oe,{onCancel:a,cancelDisabled:z,className:"pt-2",children:e.jsx(f,{onClick:J,disabled:z,children:z?"Saving...":n?"Update":"Create"})})]})}function Xe({entityType:s,onClose:a,orgContext:c,hideDelete:n=!1,compact:r=!1}){const t=!!s,[i,o]=x.useState(!1),[d,h]=x.useState(!1),[m,S]=x.useState(null),N=Te(),{data:y,isLoading:b}=De(i&&s?s.slug:null,c),g=s?.entity_count??0,j=g>0,k=async()=>{if(s){S(null);try{await N.mutateAsync(s.slug),a()}catch(w){S(w instanceof Error?w.message:"Failed to delete")}}},E=t?`${s?.icon||"📄"} ${s?.name}`:"Create Entity Type",D=t?"Edit entity type configuration.":"Define a new entity type for your workspace.";return e.jsxs(e.Fragment,{children:[e.jsxs("div",{className:G("space-y-1.5",!t&&!r&&"text-center"),children:[e.jsx("h1",{className:G("font-semibold leading-tight",r?"text-lg":"text-2xl"),children:E}),e.jsx("p",{className:"text-sm text-muted-foreground",children:D})]}),e.jsx("div",{className:"py-4",children:e.jsx(He,{entityType:s,onCancel:a,onSaved:a})}),t&&e.jsxs(e.Fragment,{children:[e.jsxs("div",{className:"border-t border-border pt-4 space-y-3",children:[c.slug&&s?e.jsx(Ae,{to:"/$owner/events",params:{owner:c.slug},search:{semantic_types:"change",event_category:"config",resource_kind:"entity-type",resource_id:s.slug},className:"text-sm text-primary underline underline-offset-4",children:"View configuration history in Events"}):null,e.jsxs("button",{type:"button",onClick:()=>o(!i),className:"flex items-center gap-2 text-sm font-medium text-muted-foreground hover:text-foreground transition-colors w-full",children:[i?e.jsx(ne,{className:"h-4 w-4"}):e.jsx(re,{className:"h-4 w-4"}),"Schema audit records"]}),i&&e.jsx("div",{className:"mt-3",children:b?e.jsx(ae,{label:"history",variant:"rows",rows:4}):y&&y.length>0?e.jsx("div",{className:"relative ml-1.5",children:y.map(w=>e.jsx(ze,{entry:w},w.id))}):e.jsx("p",{className:"text-sm text-muted-foreground py-4 text-center",children:"No audit history found."})})]}),!n&&e.jsx("div",{className:"border-t border-border pt-4 mt-4",children:d?e.jsxs("div",{className:"space-y-3",children:[j?e.jsxs("div",{className:"flex items-start gap-3 p-3 rounded-md bg-amber-500/10 text-amber-600",children:[e.jsx(oe,{className:"h-5 w-5 shrink-0 mt-0.5"}),e.jsxs("div",{className:"text-sm",children:[e.jsx("p",{className:"font-medium",children:"Cannot delete this entity type"}),e.jsxs("p",{className:"mt-1 text-amber-600/80",children:["There ",g===1?"is":"are"," ",g," entit",g===1?"y":"ies",' of type "',s.name,'". Migrate or delete them first.']})]})]}):e.jsxs("p",{className:"text-sm text-muted-foreground",children:['Are you sure you want to delete "',s.name,'"? This action will soft-delete the entity type. It can be restored by a database administrator.']}),m&&e.jsx("div",{className:"p-3 rounded-md bg-destructive/10 text-destructive text-sm",children:m}),e.jsxs("div",{className:"flex gap-2",children:[e.jsx(f,{variant:"outline",size:"sm",onClick:()=>{h(!1),S(null)},children:"Cancel"}),e.jsx(f,{variant:"destructive",size:"sm",onClick:k,disabled:j||N.isPending,children:N.isPending?"Deleting...":"Delete"})]})]}):e.jsxs(f,{variant:"outline",size:"sm",className:"text-destructive hover:text-destructive",onClick:()=>h(!0),children:[e.jsx(le,{className:"h-3.5 w-3.5 mr-1.5"}),"Delete entity type"]})})]})]})}export{Xe as E};
|
|
2
|
+
//# sourceMappingURL=entity-type-page-BzMZttzh.js.map
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import{
|
|
2
|
-
//# sourceMappingURL=event-detail-
|
|
1
|
+
import{k as q,V as I,r as D,gb as J,fU as Q,j as s,b_ as M,L as W}from"./index-JmEl29py.js";import{u as X,E as Y}from"./events-feed-C4VrjIc1.js";import{b as Z,a as z,V as K,M as ee}from"./view-param-filters-FuOZyjMg.js";const se={},te="calc(100dvh - 120px)";function ie({owner:n,organizationId:o,eventId:c,viewKey:r,params:g,onParamsChange:d,onSelectView:p,dense:h=!1,fullBleed:k=!1}){const{isAuthenticated:y,isReady:E}=q(),{data:U,isLoading:w}=I(),O=U?.some(t=>t.id===o&&t.is_member),i=n!=="me"&&o!==null&&E&&y&&!w&&O,a=X(i?{slug:n,organizationId:o}:null,c),[b,j]=D.useState(se),[P,L]=D.useState(null),m=J(a.views,r),e=i&&!a.isLoading&&!a.isError&&m.kind==="view"?m.view:null,v=e?`${Q(n,e.key)}/${e.content_hash}/${e.eventId}`:null,x=e!==null&&P===v,V=M(n,c),F=n!=="me"&&(!E||y&&(w||a.isLoading)),H=e!==null&&!x&&!F,u=k&&H,T=(k||h)&&H,N=F?s.jsx("div",{role:"status",className:"py-8 text-sm text-muted-foreground",children:"Loading event view…"}):e&&!x?s.jsxs(s.Fragment,{children:[s.jsx(Z,{decls:e.params,params:g??b,onParamsChange:t=>d?d(e.key,t,{replace:!1}):j(t)}),s.jsx(z,{orgSlug:n,viewKey:e.key,scope:{event:e.eventId},params:g??b,onParamsChange:t=>d?d(e.key,t):j(t),onLoadError:()=>L(v),contentHash:e.content_hash,title:e.name,minHeight:h?240:320,fixedHeight:T?te:void 0},v)]}):void 0;return s.jsxs("div",{className:u?"w-full space-y-3":"mx-auto w-full max-w-3xl space-y-3",...u?{"data-testid":"event-view-fullbleed"}:{},children:[i&&a.isError&&s.jsx(K,{onRetry:a.refetch}),(i||n==="me"&&r)&&!a.isLoading&&!a.isError&&m.kind==="missing"&&s.jsx(ee,{viewKey:m.key,backTo:V,backLabel:"Back to the event"}),x&&s.jsxs("div",{role:"alert",className:"rounded-md border p-3 text-sm",children:[s.jsx("p",{children:"The custom view couldn’t load. The event content is shown below."}),s.jsx("button",{type:"button",className:"mt-2 underline",onClick:()=>L(null),children:"Retry custom view"})]}),s.jsx(Y,{presentation:"detail",organizationId:o,ownerSlug:n,filters:{contentIds:[c],...n==="me"?{sortBy:"date",sortOrder:"desc"}:{}},hideDetails:h,renderDetail:t=>{const f=N!=null&&(t==null||!!r),_=(i?a.views:[]).filter(l=>!f||l.key!==e?.key).map(l=>({key:l.key,name:l.name,href:M(n,c,l.key)})),A=l=>l.length?s.jsx("nav",{"aria-label":"Event views",className:"flex flex-wrap gap-3 text-sm",children:l.map(({key:$,name:C,href:B})=>s.jsx(W,{to:B,className:"underline",onClick:p?G=>{G.preventDefault(),p(B)}:void 0,children:C},$))}):null,R=[..._],S=[..._];return i&&r&&t!=null&&S.unshift({key:":event",name:"Event details",href:V}),{content:f?N:t,nativeHeading:!f&&t!=null,headingAside:u?A(R):void 0,links:u?null:A(S)}}})]})}export{ie as E};
|
|
2
|
+
//# sourceMappingURL=event-detail-C25TvOb_.js.map
|
|
@@ -0,0 +1,2 @@
|
|
|
1
|
+
import{j as e,L as ie,C as Vt,dQ as ht,cN as qt,bw as Kt,g as ft,r as _,dR as gt,dS as Jt,Y as Qt,K as Wt,dP as Gt,u as yt,T as Se,dT as rt,dU as Qe,dV as jt,dW as Yt,dX as vt,b6 as Nt,dY as Xt,dZ as Zt,c_ as en,d_ as _t,d$ as tn,cj as nn,e0 as $e,e1 as sn,B as $,e2 as ve,cF as Ne,Q as xe,cH as bt,e3 as Ze,e4 as wt,dC as rn,dE as an,dD as on,e5 as ln,e6 as dn,cO as kt,e7 as cn,e8 as un,q as mn,o as Ct,bH as at,b_ as it,a0 as pn,e9 as xn,ea as hn,cl as fn,cK as gn,eb as yn,ec as jn,a3 as Pe,ed as vn,ee as Nn,bO as _n,ef as bn,bS as wn,eg as kn,dK as Cn,eh as Sn,X as An,bi as St,ei as Be,ej as ze,ek as Ue,df as Le,S as Re,aR as In,dv as Rn,k as En,an as Tn,cf as $n,dj as Pn,dn as Dn,dp as Fn,el as On,em as Ln,en as Mn,eo as Bn,ep as zn,bK as Un,eq as Hn,cI as Ve,bc as ot,cD as Vn}from"./index-JmEl29py.js";import{u as qn}from"./client-activity-scopes-CmK3DkSP.js";import{u as Kn,a as Jn}from"./client-rows-fFuxzFtE.js";import{b as At}from"./use-automations-DS3uz3pb.js";import{C as Qn,J as qe}from"./json-diff-4sMmayDd.js";import{C as lt}from"./copy-button-kcjg8Giw.js";import{J as Wn,l as Gn,s as Yn,S as Xn}from"./linked-record-peek-B0_B4PnF.js";import{u as Zn}from"./use-scroll-sentinel-BpQ70c28.js";function It(t,n){if(!t||typeof t!="object"||Array.isArray(t))return null;const s=t.title;if(typeof s!="string")return null;const r=s.trim();return r&&r!==n?r:null}function es(t,n){const s=n.parentEntityType&&n.parentEntitySlug?[{entity_type:n.parentEntityType,slug:n.parentEntitySlug},{entity_type:n.entityType,slug:n.entitySlug}]:[{entity_type:n.entityType,slug:n.entitySlug}];return ht(t,s)}function ts({ownerSlug:t,entity:n,className:s}){const r=es(t,n);return e.jsxs(ie,{to:r,className:`flex items-center gap-1 text-primary hover:underline group ${s??""}`,children:[e.jsx("span",{className:"font-medium",children:n.entityName}),e.jsx(Vt,{className:"h-3 w-3 opacity-0 group-hover:opacity-100 transition-opacity"})]})}function Rt(t){const n=Array.isArray(t?.records)?t.records:Array.isArray(t?.current)?t.current:[];return[t?.from_entity_id??t?.entity_id,t?.to_entity_id].map(s=>{const a=n.find(o=>o&&typeof o=="object"&&"id"in o&&o.id===s);return{id:String(s??"unknown"),name:typeof a?.name=="string"?a.name:`Record ${String(s??"unknown")}`}})}function Et(t,n){return n==="rejected"?"The proposed relationship change was rejected. Both records remain available.":n==="failed"?"The relationship change failed. Both records remain available.":n==="completed"?t==="link"?"The records were linked. Both records remain available.":"The relationship was removed. Both records remain available.":n==="approved"||n==="confirmed"?"The relationship change was approved. Both records remain available.":t==="link"?"If approved, these records will be linked. Both records remain available.":"If approved, this relationship will be removed. Both records remain available."}function cr(t){const n=Rt(t.proposal);return{title:t.action==="link"?"Link records":"Unlink records",icon:"entity",impact:{level:"normal"},tone:"default",blocks:[...n.map((s,r)=>({type:"text",label:r===0?"From":"To",value:s.name})),{type:"text",label:"Relationship",value:String(t.proposal?.relationship_type??t.proposal?.relationship_type_slug??"Relationship")},{type:"text",value:Et(t.action,typeof t.status=="string"?t.status:void 0),muted:!0},...typeof t.reason=="string"&&t.reason?[{type:"text",label:"Why this needs approval",value:t.reason}]:[]],actions:[{id:"approve",label:"Approve",variant:"primary",icon:"check",confirm:t.action==="unlink",confirmPrompt:"Remove this relationship? Both records will remain available.",tool:"manage_operations",args:{action:"approve"},resolvedLabel:"Approval submitted."},{id:"reject",label:"Reject",variant:"outline",icon:"x",confirm:!0,confirmPrompt:"Reject this relationship change?",tool:"manage_operations",args:{action:"reject"},resolvedLabel:"Relationship change rejected."}]}}function Tt(t,n,s){return{queryKey:["event-view-match",t,n.key,n.content_hash,s],queryFn:async()=>{try{const a=(await qt("open_view",{key:n.key,scope:{event:s}},{slug:t})).scope?.event;if(!Number.isSafeInteger(a)||(a??0)<1)throw new Error("The view did not resolve its event subject");return a}catch(r){if(r instanceof Kt&&(r.status===400||r.status===404))return null;throw r}},staleTime:6e4}}function ur(t,n){const s=ft(t??{slug:null,organizationId:null}),r=t?.slug??null,a=_.useMemo(()=>r?gt(s.data??[]):[],[r,s.data]),o=Jt({queries:a.map(l=>Tt(r,l,n))});return r?{views:a.flatMap((l,p)=>{const i=o[p]?.data;return i?[{...l,eventId:i}]:[]}),isLoading:s.data===void 0?!s.isError:o.some(l=>l.isPending),isError:s.isError||o.some(l=>l.isError),refetch:()=>{s.refetch();for(const l of o)l.isError&&l.refetch()}}:{views:[],isLoading:!1,isError:!1,refetch:()=>{}}}async function ns(t,n,s,r){const a=await Promise.all(s.map(o=>t.fetchQuery(Tt(n,o,r))));return s.find((o,l)=>a[l])??null}async function ss(t,n,s,r){const a=await Qt(`${Wt}/api/${encodeURIComponent(t)}/events/${n}/actions/${encodeURIComponent(s.action)}`,{method:"POST",timeoutMs:9e4,credentials:"include",headers:{"Content-Type":"application/json"},body:JSON.stringify({value:s.value,interaction_id:r})});return await Gt(a,"Could not record interaction"),a.json()}function z(t){if(typeof t!="string")return;const n=t.trim();return n.length>0?n:void 0}function Ke(t){return typeof t=="boolean"?t:void 0}function rs(t,n,s){const r=(s??"").toLowerCase();return!!(r==="prepare_comment"||r==="verify_staged_comment"||r.includes("prepare_")||r.includes("verify_staged")||n?.prepared===!0||typeof n?.verified=="boolean"||z(n?.reason_preview)&&z(n?.message)||z(t?.body)&&(z(t?.post_url)||z(t?.activity_id)))}function as(t,n,s){if(!rs(t,n,s))return null;const r=(s??"").toLowerCase(),a=z(n?.body)??z(t?.body),o=z(n?.reason_preview)??z(t?.reason),l=z(n?.post_url)??z(t?.post_url)??(z(t?.activity_id)?`https://www.linkedin.com/feed/update/urn:li:activity:${z(t?.activity_id)}`:void 0),p=Ke(n?.prepared),i=Ke(n?.verified),c=Ke(n?.banner_shown),v=z(n?.message),m=n?.match&&typeof n.match=="object"?n.match:null,h=z(m?.text_preview),N=z(m?.author);let A="generic";r==="verify_staged_comment"||r.includes("verify")||typeof i=="boolean"?A="verify":(r==="prepare_comment"||r.includes("prepare")||p===!0||a&&l)&&(A="prepare");const b=[];return p===!0&&b.push("Staged — not posted"),p===!1&&b.push("Not staged"),i===!0&&b.push("Verified posted"),i===!1&&b.push("Not verified as posted"),c===!0&&b.push("In-page banner"),c===!1&&b.push("No banner"),{kind:A,message:v,reason:o,body:a,postUrl:l,prepared:p,bannerShown:c,verified:i,matchPreview:h,matchAuthor:N,chips:b}}function is(t){return t.semantic_type==="change"&&(t.metadata?.category==="config"||t.metadata?.category==="deployment")}function ye(t){return t!==null&&typeof t=="object"&&!Array.isArray(t)?t:null}function os({content:t,detail:n=!1}){const s=t.metadata??{},r=t.payload_data??{},a=s.category==="deployment",o=typeof s.apply_id=="string"?s.apply_id:null,l=ye(r.manifest),p=o&&/^apl_[A-Za-z0-9-]{1,48}$/.test(o)&&t.origin_type==="deployment"&&t.origin_id===`deployment_${o}`&&(s.status==="succeeded"||s.status==="partial_failure")&&ye(l?.state);return e.jsxs("div",{className:"space-y-3","data-testid":"config-change-event",children:[e.jsx(Qn,{showAttribution:n,operation:a?String(s.status??"Apply"):typeof s.op=="string"?s.op:null,actor:t.author_name??(typeof s.actor_source=="string"?s.actor_source:null),createdAt:t.occurred_at??t.created_at,resource:a?"Configuration apply":`${s.resource_kind??"Configuration"} · ${s.resource_id??""}`,changedFields:Array.isArray(s.changed_fields)?s.changed_fields.filter(i=>typeof i=="string"):void 0}),o?e.jsxs("div",{className:"flex min-w-0 items-center gap-2 text-xs text-muted-foreground",children:[e.jsxs("span",{className:"break-all",children:["Apply ",o]}),e.jsx(lt,{text:o,label:"Copy apply ID"})]}):null,n?a?e.jsxs(e.Fragment,{children:[typeof s.rollback_of=="string"?e.jsxs("p",{className:"break-all text-xs text-muted-foreground",children:["Restores apply ",s.rollback_of]}):null,ye(s.counts)?e.jsx("dl",{className:"flex flex-wrap gap-4 text-xs",children:Object.entries(ye(s.counts)??{}).map(([i,c])=>e.jsxs("div",{children:[e.jsx("dt",{className:"text-muted-foreground",children:i}),e.jsx("dd",{children:String(c)})]},i))}):null,typeof r.error=="string"?e.jsx("p",{className:"text-sm text-destructive",children:r.error}):null,p?e.jsxs("div",{className:"space-y-2 rounded-md border p-3",children:[e.jsx("p",{className:"text-sm font-medium",children:"Restore this deployment"}),e.jsx("p",{className:"text-xs text-muted-foreground",children:"Preview restoring this saved configuration with the CLI. Secret values stay unchanged."}),e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsxs("code",{className:"break-all text-xs",children:["lobu rollback ",o]}),e.jsx(lt,{text:`lobu rollback ${o}`,label:"restore command",iconOnly:!0})]})]}):null,e.jsx(qe,{before:null,after:l})]}):Object.hasOwn(r,"before")?e.jsx(qe,{before:ye(r.before),after:ye(r.state)}):e.jsxs(e.Fragment,{children:[e.jsx("p",{className:"text-xs text-muted-foreground",children:"The earlier state was not recorded for this change."}),e.jsx(qe,{before:null,after:ye(r.state)})]}):null]})}function Ee(t){return t!==null&&typeof t=="object"&&!Array.isArray(t)}function ls({template:t,data:n,onAction:s}){const[r,a]=_.useState(null),[o,l]=_.useState(!1),[p,i]=_.useState(null),[c,v]=_.useState(!1),m=_.useRef(!1),h=_.useRef(!0);_.useEffect(()=>(h.current=!0,()=>{h.current=!1}),[]);const N=async A=>{if(!(!s||m.current)){m.current=!0,l(!0),i(null),v(!1);try{const b=await s(A);if(!h.current)return;if(Ee(b)&&b.kind==="sdk"){const f=b.result;if(!Ee(f)||f.success!==!0){const w=Ee(f)&&Ee(f.error)?f.error.message:null;throw new Error(typeof w=="string"?w:"Could not update this event.")}if(f.return_truncated||!Ee(f.return_value))throw new Error("The update did not return a complete data object.");a(f.return_value),v(!0)}}catch(b){h.current&&i(b instanceof Error?b.message:"Could not update this event.")}finally{m.current=!1,h.current&&l(!1)}}};return e.jsxs("div",{className:"space-y-2",children:[o?e.jsx("p",{role:"status",className:"text-sm text-muted-foreground",children:"Updating…"}):null,c?e.jsx("p",{role:"status",className:"sr-only",children:"Updated"}):null,p?e.jsxs("p",{role:"alert",className:"text-sm text-destructive",children:[p," Previous data is still shown."]}):null,e.jsx("fieldset",{disabled:!s||o,"aria-busy":o,className:"min-w-0",children:e.jsx(Wn,{template:{root:t.root},data:r??n,onAction:s?N:void 0,interactions:t.interactions})})]})}const dt="inline-flex max-w-full items-center truncate rounded-md border border-border px-1.5 py-0.5 text-xs";function We({peer:t,ownerSlug:n,orgContext:s}){const r=yt();if(t.self||!t.type||!r)return e.jsx("span",{className:Se(dt,"text-muted-foreground"),children:t.name});const a=r.item?.recordPeer?.entityId===t.id;return e.jsx("button",{type:"button","aria-pressed":a,title:t.type,className:Se(dt,"hover:bg-muted",a&&"ring-1 ring-primary"),onClick:o=>{o.stopPropagation(),r.open(Gn({...typeof t.id=="number"?{entityId:t.id}:{record:{type:t.type,key:t.id}},ownerSlug:n,orgContext:s,name:t.name}))},children:e.jsx("span",{className:"truncate",children:t.name})})}function mr(t,n=t.relationship_type_name){const s=t.from_entity_name??`Record #${t.from_entity_id}`,r=t.to_entity_name??`Record #${t.to_entity_id}`;return t.is_symmetric?`${s} ${n} ${r}`:`${s} → ${n} → ${r}`}function pr({row:t,entityId:n,entityType:s,ownerSlug:r,orgContext:a,label:o=t.relationship_type_name}){const l=(p,i,c)=>e.jsx(We,{peer:{id:p,name:i??`Record #${p}`,type:c,self:p===n&&(typeof p=="number"||c===s)},ownerSlug:r,orgContext:a});return e.jsxs("div",{className:"flex min-w-0 flex-wrap items-center gap-1 text-xs",children:[l(t.from_entity_id,t.from_entity_name,t.from_entity_type),!t.is_symmetric&&e.jsx(rt,{"aria-hidden":"true",className:"size-3 shrink-0 text-muted-foreground"}),e.jsx("span",{className:"text-muted-foreground",children:o}),!t.is_symmetric&&e.jsx(rt,{"aria-hidden":"true",className:"size-3 shrink-0 text-muted-foreground"}),l(t.to_entity_id,t.to_entity_name,t.to_entity_type)]})}function xr({count:t,onRetry:n}){return t?e.jsxs("p",{role:"status",className:"text-xs text-muted-foreground",children:["Some linked records could not be read."," ",e.jsx("button",{type:"button",className:"underline",onClick:n,children:"Retry"})]}):null}const $t={name:"Name",slug:"URL slug",parent_id:"Parent",content:"Content changed"};function je(t){return typeof t=="object"&&t!==null&&!Array.isArray(t)}function Fe(t){return t==null||t===""}function ds(t,n){return Qe(t??null)===Qe(n??null)}function cs(t){return!!(t?.type==="array"&&(t.items?.type==="object"||t.items?.properties))}function us(t){return!!(t&&(t.type==="object"||t.properties)&&t.type!=="array")}function et(t,n){return Yn({key:t,prop:n??{}})}function ms(t,n){return t?.properties?.[n]}function Ge(t,n,s,r,a){if(ds(n,s))return;const o=i=>Array.isArray(i)?i:[];if((Array.isArray(n)||Fe(n))&&(Array.isArray(s)||Fe(s))&&(Array.isArray(n)||Array.isArray(s)||r?.type==="array")){const i=o(n),c=o(s);if(cs(r)||[...i,...c].some(f=>je(f))){const f=Math.min(i.length,c.length);for(let P=0;P<f;P++)Ge([...t,`item ${P+1}`],i[P],c[P],r?.items,a);const w=Math.max(0,c.length-i.length),q=Math.max(0,i.length-c.length);(w||q)&&a.push({kind:"items",path:t,added:w,removed:q});return}const m=f=>Qe(f),h=new Set(i.map(m)),N=new Set(c.map(m)),A=c.filter(f=>!h.has(m(f))),b=i.filter(f=>!N.has(m(f)));a.push(A.length||b.length?{kind:"values",path:t,added:A,removed:b,prop:r?.items}:{kind:"reordered",path:t});return}if((je(n)||Fe(n))&&(je(s)||Fe(s))&&(je(n)||je(s)||us(r))){const i=je(n)?n:{},c=je(s)?s:{},v=[...new Set([...Object.keys(r?.properties??{}),...Object.keys(i),...Object.keys(c)])];for(const m of v){const h=ms(r,m);Ge([...t,et(m,h)],i[m],c[m],h,a)}return}a.push({kind:"set",path:t,old:n,new:s,prop:r})}function ps(t,n){const s=$t[t.field];if(s)return t.field==="content"?[{kind:"note",path:[s]}]:t.field==="parent_id"?[{kind:"parent",path:[s],old:t.old,new:t.new}]:[{kind:"set",path:[s],old:t.old,new:t.new}];const r=n?.properties?.[t.field],a=[];return Ge([et(t.field,r)],t.old,t.new,r,a),a}function xs(t,n){const s=n?.properties;return t.map(r=>r.field==="content"?"Content":$t[r.field]??et(r.field,s?.[r.field]))}const hs="entity.updated",fs=new Set(["link","unlink","update_link"]);function ct(t){const n=typeof t=="string"||typeof t=="number"?Number(t):Number.NaN;return Number.isSafeInteger(n)&&n>0?n:null}function gs(t){const n=t.split("_").join(" ").trim();return n?`${n.charAt(0).toUpperCase()}${n.slice(1)}`:t}function ys(t){const n=t.metadata;if(t.semantic_type!=="change"||!n||n._lobu_relationship_change!==!0||typeof n.op!="string"||!fs.has(n.op))return null;const s=ct(n.fromEntityId),r=ct(n.toEntityId);if(s==null||r==null)return null;const a=typeof n.relationshipTypeSlug=="string"?n.relationshipTypeSlug:null,o=Array.isArray(n.changes)?n.changes:[];return{op:n.op,fromId:s,toId:r,typeLabel:a?gs(a):"relationship",changedFields:o.flatMap(l=>l&&typeof l=="object"&&typeof l.field=="string"?[l.field]:[])}}function Me({id:t,recordId:n,ownerSlug:s}){const r=t===n,a={slug:s},{data:o,isLoading:l,isError:p}=jt(r?void 0:t,a);return r?e.jsx(We,{peer:{id:t,name:"this record",type:null,self:!0},ownerSlug:s,orgContext:a}):l?e.jsxs("span",{className:"text-xs text-muted-foreground",children:["Record #",t]}):p||!o?e.jsx("span",{className:"text-xs text-muted-foreground",title:"Deleted, or you do not have access to it",children:"Unavailable record"}):e.jsx(We,{peer:{id:t,name:o.name,type:o.entity_type},ownerSlug:s,orgContext:a})}function js({change:t,recordId:n,ownerSlug:s}){const r=t.op==="link"?`Linked as ${t.typeLabel}`:t.op==="unlink"?`Unlinked ${t.typeLabel}`:`Updated ${t.typeLabel} link`,a=n===t.toId&&n!==t.fromId,o=n===t.fromId;return e.jsxs("span",{"data-testid":"relationship-change",className:"inline-flex flex-wrap items-center gap-1.5",children:[!o&&!a?e.jsx(Me,{id:t.fromId,ownerSlug:s}):null,e.jsx("span",{children:a?`${r} from`:r}),a?e.jsx(Me,{id:t.fromId,recordId:n,ownerSlug:s}):e.jsxs(e.Fragment,{children:[e.jsx("span",{"aria-hidden":"true",children:"→"}),e.jsx(Me,{id:t.toId,recordId:n,ownerSlug:s})]}),t.op==="update_link"&&t.changedFields.length>0?e.jsxs("span",{className:"text-xs text-muted-foreground",children:["· ",t.changedFields.join(", ")]}):null]})}function vs(t){if(!Array.isArray(t)||t.length===0)return null;const n=[];for(const s of t){if(!s||typeof s!="object"||typeof s.field!="string")return null;const{field:r,old:a,new:o}=s;n.push({field:r,old:a??null,new:o??null})}return n}function Ns(t){const n=ys(t);if(n)return{kind:"relationship",change:n};const s=t.metadata;if(t.semantic_type!=="change"||!s)return null;const r=s._lobu_event_type;if(r!==hs&&(r!==void 0||s.category))return null;const a=vs(s.changes);if(!a)return null;const o=t.entity_ids?.[0];return{kind:"fields",entityId:typeof o=="number"?o:null,changes:a}}function Pt(t,n){const s={slug:n},{data:r}=jt(t.entityType?void 0:t.entityId??void 0,s),{data:a}=Yt(t.entityType??r?.entity_type??"",s);return a?.metadata_schema}const _s=4;function Oe({value:t,prop:n}){return e.jsx("span",{className:"inline-block max-w-[18rem] truncate align-bottom",title:typeof t=="string"?t:void 0,children:e.jsx(Xn,{value:t,prop:n,empty:e.jsx("span",{className:"italic",children:"empty"})})})}function ut({id:t,ownerSlug:n}){const s=typeof t=="number"||typeof t=="string"?Number(t):Number.NaN;return Number.isSafeInteger(s)&&s>0?e.jsx(Me,{id:s,ownerSlug:n}):e.jsx("span",{className:"italic text-muted-foreground",children:"empty"})}function Ye(t,n){return`${t} ${n}${t===1?"":"s"}`}function bs({line:t,ownerSlug:n}){const s=e.jsx("span",{className:"text-muted-foreground",children:t.path.join(" · ")});switch(t.kind){case"note":return s;case"set":return e.jsxs(e.Fragment,{children:[s,": ",e.jsx(Oe,{value:t.old,prop:t.prop})," ",e.jsx("span",{"aria-hidden":"true",children:"→"})," ",e.jsx(Oe,{value:t.new,prop:t.prop})]});case"parent":return e.jsxs(e.Fragment,{children:[s,": ",e.jsx(ut,{id:t.old,ownerSlug:n})," ",e.jsx("span",{"aria-hidden":"true",children:"→"})," ",e.jsx(ut,{id:t.new,ownerSlug:n})]});case"items":return e.jsxs(e.Fragment,{children:[s,":"," ",[t.added?`${Ye(t.added,"item")} added`:null,t.removed?`${Ye(t.removed,"item")} removed`:null].filter(Boolean).join(", ")]});case"values":return e.jsxs(e.Fragment,{children:[s,":",t.added.map((r,a)=>e.jsxs("span",{className:"ml-1.5",children:["+",e.jsx(Oe,{value:r,prop:t.prop})]},`+${a}`)),t.removed.map((r,a)=>e.jsxs("span",{className:"ml-1.5 text-muted-foreground",children:["−",e.jsx(Oe,{value:r,prop:t.prop})]},`-${a}`))]});case"reordered":return e.jsxs(e.Fragment,{children:[s,": reordered"]})}}function ws({change:t,ownerSlug:n}){const s=Pt(t,n);return e.jsxs(e.Fragment,{children:["Updated ",xs(t.changes,s).join(", ")]})}function tt({changes:t,entityId:n,entityType:s,ownerSlug:r,showAll:a=!1}){const o=Pt({entityId:n,entityType:s},r),[l,p]=_.useState(a),i=t.flatMap(m=>ps(m,o)),c=l?i:i.slice(0,_s),v=i.length-c.length;return e.jsxs("ul",{"data-testid":"field-changes",className:"space-y-0.5 text-sm",children:[c.map((m,h)=>e.jsx("li",{className:"min-w-0 truncate",children:e.jsx(bs,{line:m,ownerSlug:r})},h)),v>0?e.jsx("li",{children:e.jsxs("button",{type:"button",className:"text-xs text-primary hover:underline",onClick:m=>{m.stopPropagation(),p(!0)},children:["+",Ye(v,"more change")]})}):null]})}function ks({event:t,recordId:n,ownerSlug:s}){return t.kind==="relationship"?e.jsx(js,{change:t.change,recordId:n,ownerSlug:s}):e.jsx(ws,{change:t,ownerSlug:s})}function Cs({event:t,ownerSlug:n}){return t.kind==="fields"?e.jsx(tt,{changes:t.changes,entityId:t.entityId,ownerSlug:n}):null}function Dt(t){return{audit:t.semantic_type==="audit"&&t.origin_type==="tool_invocation",operation:t.interaction_type==="approval"||t.semantic_type==="operation",changeSet:t.semantic_type==="change_set"}}const Ss={};function he(t){return t.replace(/_/g," ").replace(/\s+/g," ").trim().replace(/^./,n=>n.toUpperCase())}const As={notification:"Notification",tool_invocation:"Action",deployment:"Deployment",config_change:"Config change",message:"Message",msg:"Note",summary:"Summary"};function Is(t){return t.author_name?t.author_name:t.platform?he(t.platform):t.origin_type?As[t.origin_type]??he(t.origin_type):null}function Rs(t){return t==null?"":typeof t=="string"?t:typeof t=="number"||typeof t=="boolean"||typeof t=="bigint"?String(t):Array.isArray(t)?t.length===0?"":t.every(n=>typeof n!="object")?t.map(n=>String(n)).join(", "):e.jsx("pre",{className:"overflow-x-auto rounded bg-muted/40 p-2 text-[11px] leading-relaxed whitespace-pre-wrap",children:JSON.stringify(t,null,2)}):e.jsx("pre",{className:"overflow-x-auto rounded bg-muted/40 p-2 text-[11px] leading-relaxed whitespace-pre-wrap",children:JSON.stringify(t,null,2)})}const Je=1e5;function mt({value:t}){const n=JSON.stringify(t,null,2)??"null",s=n.length>Je;return e.jsxs(e.Fragment,{children:[e.jsx("pre",{className:"max-h-80 overflow-auto whitespace-pre-wrap break-words rounded-md border bg-muted/40 p-3 font-mono text-xs",children:s?n.slice(0,Je):n}),s&&e.jsxs("p",{className:"text-xs text-muted-foreground",children:["Showing the first ",Je.toLocaleString()," of"," ",n.length.toLocaleString()," characters."]})]})}function Es(t){return Object.entries(t).filter(([,n])=>n==null?!1:typeof n=="string"?n.trim().length>0:Array.isArray(n)?n.length>0:typeof n=="object"?Object.keys(n).length>0:!0).sort(([n],[s])=>n.localeCompare(s))}function Ts({breakdown:t}){if(!t)return null;const n=[{label:"Engagement",value:t.engagement,max:100},{label:"Criticality",value:t.criticality,max:100},{label:"Depth",value:t.depth,max:100},{label:"Authority",value:t.authority,max:100},{label:"Recency",value:t.recency,max:100},{label:"Quality",value:t.quality,max:100}];return e.jsx("div",{className:"space-y-2 text-sm",children:n.map(s=>e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx("span",{className:"w-20 text-muted-foreground",children:s.label}),e.jsx("div",{className:"flex-1 h-2 bg-muted rounded-full overflow-hidden",children:e.jsx("div",{className:"h-full bg-primary",style:{width:`${s.value/s.max*100}%`}})}),e.jsx("span",{className:"w-8 text-right",children:s.value})]},s.label))})}function $s({slug:t,value:n,isManual:s}){return e.jsxs(xe,{variant:"secondary",className:"text-xs",children:[t,": ",n,s&&e.jsx(_t,{className:"ml-1 h-2.5 w-2.5 fill-current"})]})}function Ps(t){if(t&&typeof t=="object"){const n=t;if(Array.isArray(n.values))return{values:n.values.map(s=>String(s)).filter(s=>s.length>0),isManual:n.is_manual===!0};if(n.value!==void 0&&n.value!==null)return{values:[String(n.value)],isManual:n.is_manual===!0};if(typeof n.values=="string"&&n.values.length>0)return{values:[n.values],isManual:n.is_manual===!0}}return typeof t=="string"||typeof t=="number"||typeof t=="boolean"||typeof t=="bigint"?{values:[String(t)],isManual:!1}:{values:[],isManual:!1}}function Ft(t,n){if(t)switch(t){case"pending":return"pending_approval";case"approved":return"confirmed";case"rejected":return"rejected";case"completed":return"completed";case"failed":return"failed";default:return t}return n||"pending_approval"}function Xe(t){return!t||typeof t!="object"||Array.isArray(t)?null:t}function Ds(t){return t.replace(/\s+[—-]\s+pending approval$/i,"")}function He(t){return t.replace(/^\$/,"").replace(/[_-]/g," ").replace(/\s+/g," ").trim().replace(/^./,n=>n.toUpperCase())}function Ot(t,n,s){return t?.kind==="agent_session"&&t.agent_id?t.client_id?`${t.agent_id} via ${t.client_id}`:t.agent_id:t?.kind==="user"?"a person":n==="agent"?"an agent":s?`Automation ${s}`:"an Automation"}function Fs({ownerSlug:t,initiator:n,clientName:s,fallback:r}){const a=n?.client_id??s,{allOrgs:o,isAuthenticated:l}=Ct(),p=l&&o?.some(N=>N.slug===t),c=Kn(void 0,{ownerSlug:t,enabled:!!(a&&p)}).data?.find(N=>N.id===a)?.title,v=n&&n.kind!=="user"?Ot(n,void 0,n.automation_id===void 0?void 0:String(n.automation_id)):r,m="font-medium text-foreground",h=`${m} underline-offset-4 hover:underline`;return n?.kind==="automation"&&n.automation_id?e.jsx(ie,{to:"/$owner/automations/$automationId",params:{owner:t,automationId:String(n.automation_id)},search:{view:"definition",run_id:void 0},className:h,children:v}):n?.kind==="agent_session"&&n.agent_id?e.jsx(ie,{to:"/$owner/agents/$agentId",params:{owner:t,agentId:String(n.agent_id)},className:h,children:v}):a?e.jsxs(ie,{to:"/$owner/agents/connected/$clientId",params:{owner:t,clientId:a},className:`${h} inline-flex items-center gap-1 align-middle`,children:[e.jsx(St,{name:c??s??a}),c??v]}):e.jsx("span",{className:m,children:v})}function Os(t){const n=Object.keys(t.fields),s=n.map(He).join(", ")||"field",r=n.length===1?"field":"fields";return`Update ${t.entityType?He(t.entityType).toLowerCase():"entity"} ${r}: ${s}`}function Ls(t,n){const s=Xe(n.fields);if(!s||Object.keys(s).length===0||n.action_key!=="entity_field_change"&&n.tool!=="entity_field_change")return null;const r=Xe(n.current)??{},a=t;return{fields:s,current:r,reason:typeof n.reason=="string"?n.reason:void 0,automationId:n.automation_id!=null?String(n.automation_id):void 0,automationName:typeof n.automation_name=="string"?n.automation_name:void 0,automationAgentId:typeof n.automation_agent_id=="string"?n.automation_agent_id:void 0,entityType:typeof n.entity_type=="string"?n.entity_type:void 0,entityName:(typeof n.entity_name=="string"?n.entity_name:void 0)??a.entity_name??void 0,entitySlug:typeof n.entity_slug=="string"?n.entity_slug:void 0,parentSlug:typeof n.parent_slug=="string"?n.parent_slug:void 0,parentEntityType:typeof n.parent_entity_type=="string"?n.parent_entity_type:void 0,attribution:typeof n.attribution=="string"?n.attribution:void 0,initiator:n.initiator&&typeof n.initiator=="object"?n.initiator:void 0}}function Ms(t){const n=t.entityType?He(t.entityType).toLowerCase():"entity";return`${He(t.operation)} ${n}`}function Bs(t,n){if(n.action_key!=="entity_change"&&n.tool!=="entity_change")return null;const s=n.action;if(s!=="create"&&s!=="delete"&&s!=="link"&&s!=="unlink")return null;const r=t;return{operation:s,proposal:Xe(n.proposal),reason:typeof n.reason=="string"?n.reason:void 0,automationId:n.automation_id!=null?String(n.automation_id):void 0,automationName:typeof n.automation_name=="string"?n.automation_name:void 0,automationAgentId:typeof n.automation_agent_id=="string"?n.automation_agent_id:void 0,entityType:typeof n.entity_type=="string"?n.entity_type:void 0,entityName:(typeof n.entity_name=="string"?n.entity_name:void 0)??r.entity_name??void 0,entitySlug:typeof n.entity_slug=="string"?n.entity_slug:void 0,parentSlug:typeof n.parent_slug=="string"?n.parent_slug:void 0,parentEntityType:typeof n.parent_entity_type=="string"?n.parent_entity_type:void 0,attribution:typeof n.attribution=="string"?n.attribution:void 0,proposerRationale:typeof n.proposer_rationale=="string"?n.proposer_rationale:void 0,initiator:n.initiator&&typeof n.initiator=="object"?n.initiator:void 0}}function zs(t,n){return!n.entityType||!n.entitySlug?null:ht(t,n.parentEntityType&&n.parentSlug?[{entity_type:n.parentEntityType,slug:n.parentSlug},{entity_type:n.entityType,slug:n.entitySlug}]:[{entity_type:n.entityType,slug:n.entitySlug}])}function Lt({ownerSlug:t,runId:n,details:s}){const a=At(s.automationId,void 0,void 0,{ownerSlug:t,includeVersions:!1}).data?.automation,o=Ot(s.initiator,s.attribution,s.automationId),l=a?.automation_name??s.automationName??o;return e.jsxs("div",{className:"text-sm text-muted-foreground",children:["Requested by"," ",s.automationId?e.jsx(ie,{to:"/$owner/automations/$automationId",params:{owner:t,automationId:s.automationId},search:{view:"definition",run_id:void 0},className:"font-medium text-foreground underline-offset-4 hover:underline",children:l}):e.jsx("span",{className:"font-medium text-foreground",children:l}),n&&e.jsxs(e.Fragment,{children:[e.jsx("span",{children:" · "}),e.jsxs(ie,{to:"/$owner/events",params:{owner:t},search:{run_ids:String(n)},className:"font-medium text-foreground underline-offset-4 hover:underline",children:["Run #",n]})]})]})}function Mt({ownerSlug:t,details:n}){const s=zs(t,n);return n.entityName?e.jsxs("div",{className:"rounded-md bg-muted/40 px-3 py-2",children:[e.jsx("div",{className:"text-[11px] font-medium uppercase tracking-wide text-muted-foreground",children:"Entity"}),e.jsx("div",{className:"mt-1 text-sm font-medium",children:s?e.jsx(ie,{to:s,className:"underline-offset-4 hover:underline",children:n.entityName}):n.entityName})]}):null}function Us({ownerSlug:t,runId:n,details:s}){return e.jsxs("div",{className:"space-y-3",children:[e.jsx(Lt,{ownerSlug:t,runId:n,details:s}),e.jsx(Mt,{ownerSlug:t,details:s}),e.jsx("div",{className:"rounded-md border border-border/70 px-3 py-2",children:e.jsx(tt,{changes:Object.entries(s.fields).map(([r,a])=>({field:r,old:s.current[r]??null,new:a??null})),entityType:s.entityType,ownerSlug:t,showAll:!0})}),s.reason&&e.jsxs("div",{className:"rounded-md bg-muted/40 px-3 py-2",children:[e.jsx("div",{className:"text-[11px] font-medium uppercase tracking-wide text-muted-foreground",children:"Reasoning"}),e.jsx("div",{className:"mt-1 text-sm leading-relaxed",children:s.reason})]})]})}function Hs({ownerSlug:t,runId:n,details:s,status:r}){const{operation:a}=s,o=a==="link"||a==="unlink";return e.jsxs("div",{className:"space-y-3",children:[e.jsx(Lt,{ownerSlug:t,runId:n,details:s}),!o&&e.jsx(Mt,{ownerSlug:t,details:s}),e.jsxs("div",{className:"rounded-lg bg-muted/40 px-3 py-2",children:[e.jsx("div",{className:"text-xs font-medium text-muted-foreground",children:"Change"}),e.jsx("div",{className:"mt-1 text-sm leading-relaxed",children:o?Et(a,r):a==="create"?"Create a new entity after approval.":"Delete this entity after approval."}),o&&e.jsxs("div",{className:"mt-2 space-y-1 text-sm",children:[Rt(s.proposal).map((l,p)=>e.jsxs("div",{children:[e.jsx("span",{className:"text-muted-foreground",children:p===0?"From: ":"To: "}),l.name]},l.id)),e.jsxs("div",{className:"text-muted-foreground",children:["Relationship:"," ",String(s.proposal?.relationship_type??s.proposal?.relationship_type_slug??"Relationship")]})]})]}),!o&&s.proposal&&e.jsxs("div",{className:"rounded-lg border border-border/70 p-3",children:[e.jsx("div",{className:"mb-1 text-xs font-medium text-muted-foreground",children:"Proposal"}),e.jsx("pre",{className:"overflow-x-auto whitespace-pre-wrap break-words text-xs leading-relaxed",children:JSON.stringify(s.proposal,null,2)})]}),s.proposerRationale&&e.jsxs("div",{className:"rounded-lg bg-muted/40 px-3 py-2",children:[e.jsx("div",{className:"text-xs font-medium text-muted-foreground",children:s.attribution==="agent"?"The agent's reasoning":"The Automation's reasoning"}),e.jsx("div",{className:"mt-1 text-sm leading-relaxed",children:s.proposerRationale})]}),s.reason&&e.jsxs("div",{className:"rounded-lg bg-muted/40 px-3 py-2",children:[e.jsx("div",{className:"text-xs font-medium text-muted-foreground",children:"Why this needs approval"}),e.jsx("div",{className:"mt-1 text-sm leading-relaxed",children:s.reason})]})]})}function Vs({summary:t}){return e.jsxs("div",{className:"space-y-2 rounded-md border border-border/70 bg-muted/30 p-3 text-sm",children:[t.chips.length>0&&e.jsx("div",{className:"flex flex-wrap gap-1.5",children:t.chips.map(n=>e.jsx(xe,{variant:"outline",className:"text-[10px] font-normal",children:n},n))}),t.message&&e.jsx("p",{className:"leading-relaxed text-foreground",children:t.message}),t.reason&&e.jsxs("div",{className:"rounded-md bg-background/80 px-2.5 py-2",children:[e.jsx("div",{className:"text-[11px] font-medium uppercase tracking-wide text-muted-foreground",children:"Why"}),e.jsx("div",{className:"mt-0.5 leading-relaxed",children:t.reason})]}),t.body&&e.jsxs("div",{className:"rounded-md bg-background/80 px-2.5 py-2",children:[e.jsx("div",{className:"text-[11px] font-medium uppercase tracking-wide text-muted-foreground",children:t.kind==="verify"?"Expected comment":"Draft"}),e.jsx("div",{className:"mt-0.5 whitespace-pre-wrap leading-relaxed",children:t.body})]}),t.matchPreview&&e.jsxs("div",{className:"rounded-md bg-background/80 px-2.5 py-2",children:[e.jsxs("div",{className:"text-[11px] font-medium uppercase tracking-wide text-muted-foreground",children:["Matched comment",t.matchAuthor?` · ${t.matchAuthor}`:""]}),e.jsx("div",{className:"mt-0.5 whitespace-pre-wrap leading-relaxed text-muted-foreground",children:t.matchPreview})]}),t.postUrl&&e.jsxs("a",{href:t.postUrl,target:"_blank",rel:"noreferrer",className:"inline-flex items-center gap-1 text-xs text-primary hover:underline",children:["Open post",e.jsx(kt,{className:"h-3 w-3"})]})]})}function qs({ownerSlug:t,content:n,batchReview:s}){const r=n.metadata||{},a=n.run_id??void 0,o=Ls(n,r),l=Bs(n,r),p=(o?Os(o):l?Ms(l):void 0)||r.operation_name||r.action_name||(n.title?Ds(n.title):void 0)||"Action",i=r.connection_name,c=r.operation_key||r.action_key||null,v=n.interaction_input_schema||r.input_schema||null,m=_.useMemo(()=>n.interaction_input||r.action_input||r.operation_input||Ss,[n.interaction_input,r.action_input,r.operation_input]),h=n.interaction_output||r.action_output||void 0,N=as(m,h??null,c),A=n.interaction_error||r.error_message||void 0,b=Ft(n.interaction_status,r.status),f=r.reviewed_by_name||r.reviewed_by_id||void 0,w=r.reject_reason||void 0,q=r.initiator,P=vn({slug:t}),D=Nn({slug:t}),E=_n(n.id,bn(v,m),v),{values:g,setValues:B}=E,[k,L]=_.useState(null),[x,Y]=_.useState(!1),[R,F]=_.useState(""),O=b==="pending_approval"&&k?k:b,I=O==="pending_approval",U=typeof r.source_run_id=="number";return e.jsxs("div",{className:"space-y-3",children:[e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(Nt,{className:"h-4 w-4 text-yellow-500"}),e.jsx("span",{className:"font-medium",children:p}),i&&e.jsxs("span",{className:"text-xs text-muted-foreground",children:["on ",i]}),O==="confirmed"&&e.jsx(xe,{variant:"outline",className:"text-blue-700 border-blue-300 bg-blue-50 dark:bg-blue-950/30 text-[10px]",children:"Approved"}),O==="completed"&&e.jsx(xe,{variant:"outline",className:"text-green-700 border-green-300 bg-green-50 dark:bg-green-950/30 text-[10px]",children:"Completed"}),O==="failed"&&e.jsx(xe,{variant:"outline",className:"text-red-700 border-red-300 bg-red-50 dark:bg-red-950/30 text-[10px]",children:"Failed"}),O==="rejected"&&e.jsx(xe,{variant:"outline",className:"text-muted-foreground text-[10px]",children:"Rejected"})]}),!o&&!l&&(n.author_name||f)&&e.jsxs("div",{className:"flex flex-wrap items-center gap-x-1.5 gap-y-0.5 text-xs text-muted-foreground",children:[n.author_name&&e.jsxs("span",{children:["Requested by"," ",e.jsx(Fs,{ownerSlug:t,initiator:q,clientName:n.author_name,fallback:n.author_name})]}),n.author_name&&f&&e.jsx("span",{children:"·"}),f&&e.jsxs("span",{children:[O==="rejected"?"Rejected":"Approved"," by"," ",e.jsx("span",{className:"font-medium text-foreground",children:f})]})]}),o&&e.jsx(Us,{ownerSlug:t,runId:a,details:o}),!o&&l&&e.jsx(Hs,{ownerSlug:t,runId:a,details:l,status:O}),O==="rejected"&&w&&e.jsxs("div",{className:"rounded-md bg-muted/50 p-2 text-xs text-muted-foreground",children:[e.jsx("span",{className:"font-medium text-foreground",children:"Reason:"})," ",w]}),N&&e.jsx(Vs,{summary:N}),(I?E.revision:v)&&(I||Object.keys(m).length>0)&&e.jsxs("div",{children:[e.jsx("p",{className:"text-xs text-muted-foreground mb-1",children:N?"Full input":"Input"}),I?e.jsxs(e.Fragment,{children:[e.jsx(wn,{visible:E.hasConflict,onReload:E.reset}),e.jsx(kn,{schema:E.revision,values:g,onValuesChange:B,fieldIdPrefix:`action-${n.id}-`},`action-${n.id}`)]}):N?e.jsxs("details",{className:"text-xs",children:[e.jsx("summary",{className:"cursor-pointer text-muted-foreground hover:text-foreground",children:"Raw input"}),e.jsx("pre",{className:"mt-1 bg-muted/50 rounded p-2 font-mono overflow-auto max-h-32",children:JSON.stringify(m,null,2)})]}):e.jsx("pre",{className:"text-xs bg-muted/50 rounded p-2 font-mono overflow-auto max-h-32",children:JSON.stringify(m,null,2)})]}),O==="completed"&&h&&Object.keys(h).length>0&&!N&&e.jsxs("div",{className:"rounded-md bg-green-50 dark:bg-green-950/30 p-3 text-sm space-y-1",children:[e.jsxs("div",{className:"flex items-center gap-1.5 text-green-700 dark:text-green-400 font-medium",children:[e.jsx(Ze,{className:"h-3.5 w-3.5"}),"Output"]}),e.jsx("pre",{className:"text-xs text-green-800 dark:text-green-300 font-mono whitespace-pre-wrap",children:JSON.stringify(h,null,2)})]}),O==="completed"&&h&&Object.keys(h).length>0&&N&&e.jsxs("details",{className:"text-xs",children:[e.jsx("summary",{className:"cursor-pointer text-muted-foreground hover:text-foreground",children:"Raw output"}),e.jsx("pre",{className:"mt-1 rounded bg-green-50 p-2 font-mono dark:bg-green-950/30 overflow-auto max-h-32",children:JSON.stringify(h,null,2)})]}),O==="failed"&&A&&e.jsxs("div",{className:"rounded-md bg-red-50 dark:bg-red-950/30 p-3 text-sm",children:[e.jsxs("div",{className:"flex items-center gap-1.5 text-red-700 dark:text-red-400 font-medium",children:[e.jsx(bt,{className:"h-3.5 w-3.5"}),"Error"]}),e.jsx("p",{className:"text-xs text-red-800 dark:text-red-300 font-mono mt-1",children:A})]}),I&&!k&&U&&e.jsxs("div",{className:"pt-1 text-xs text-muted-foreground",children:["Review this proposal with the other changes in its Automation run.",s]}),I&&a&&!k&&!U&&e.jsx("div",{className:"flex items-center gap-2 pt-1",children:x?e.jsxs("div",{className:"flex items-center gap-2 w-full",children:[e.jsx("input",{type:"text",placeholder:"Reason (optional)",value:R,onChange:ne=>F(ne.target.value),className:"h-7 text-xs border rounded px-2 flex-1 bg-background"}),e.jsxs($,{size:"sm",variant:"destructive",className:"h-7 text-xs",onClick:()=>D.mutate({run_id:a,reason:R||void 0},{onSuccess:()=>{L("rejected")}}),disabled:D.isPending,children:[D.isPending&&e.jsx(Pe,{size:"sm",className:"mr-1"}),"Confirm Reject"]}),e.jsx($,{size:"sm",variant:"ghost",className:"h-7 text-xs px-2",onClick:()=>{Y(!1),F("")},children:"Cancel"})]}):e.jsxs(e.Fragment,{children:[e.jsxs($,{size:"sm",className:"h-7 text-xs",onClick:()=>P.mutate({run_id:a,input:Sn(g)},{onSuccess:()=>{L("confirmed")}}),disabled:!E.canSubmit||P.isPending||D.isPending,children:[P.isPending?e.jsx(Pe,{size:"sm",className:"mr-1"}):e.jsx(Cn,{className:"h-3 w-3 mr-1"}),"Confirm"]}),e.jsxs($,{size:"sm",variant:"outline",className:"h-7 text-xs",onClick:()=>Y(!0),disabled:P.isPending||D.isPending,children:[e.jsx(An,{className:"h-3 w-3 mr-1"}),"Reject"]})]})})]})}function Ks({content:t,ownerSlug:n}){const s=t.metadata||{},r=s.kind,a=t.run_id??null,o=typeof s.automation_id=="number"?s.automation_id:null,i=At(o!=null?String(o):void 0,void 0,void 0,{includeVersions:!1,ownerSlug:n}).data?.automation?.automation_name??(o!=null?`Automation ${o}`:"An Automation"),c=yn({slug:n}),v=jn({slug:n}),[m,h]=_.useState(!1),[N,A]=_.useState(""),[b,f]=_.useState(null);if(r==="automation_batch_reject"){const x=s.reason||void 0;return e.jsxs("div",{className:"rounded-md border border-destructive/40 bg-destructive/5 p-3",children:[e.jsx("div",{className:"text-sm font-medium",children:"Proposals rejected"}),x&&e.jsx("div",{className:"mt-1 text-sm text-muted-foreground",children:x}),e.jsx("div",{className:"mt-1 text-xs text-muted-foreground",children:"Ask the agent to revise its proposals with this feedback."})]})}const w=Array.isArray(s.changes)?s.changes:[],q=typeof s.created_count=="number"?s.created_count:w.filter(x=>x.kind==="created").length,P=typeof s.updated_count=="number"?s.updated_count:w.filter(x=>x.kind==="updated").length,D=typeof s.denied_count=="number"?s.denied_count:w.filter(x=>x.kind==="denied").length,E=w.filter(x=>x.kind==="denied"),g=w.filter(x=>x.kind==="updated"&&Object.keys(x.applied||{}).length>0),B=typeof s.pending_proposal_count=="number"?s.pending_proposal_count:null,k=B==null||B>0,L=k?"proposed":"applied";return e.jsxs("div",{className:"rounded-md border p-3",children:[e.jsxs("div",{className:"flex flex-wrap items-center justify-between gap-x-3 gap-y-1",children:[e.jsxs("div",{className:"text-sm font-medium",children:[L==="proposed"?"Proposed":"Applied"," ",q," ","new + ",P," updated",D>0&&e.jsxs(e.Fragment,{children:[" + ",D," denied"]})]}),e.jsxs("div",{className:"text-xs text-muted-foreground",children:[o!=null?e.jsx(ie,{to:"/$owner/automations/$automationId",params:{owner:n,automationId:String(o)},search:{view:"definition",run_id:void 0},className:"font-medium text-foreground underline-offset-4 hover:underline",children:i}):e.jsx("span",{className:"font-medium text-foreground",children:i}),a!=null&&e.jsxs("span",{children:[" · run #",a]}),B!=null&&B>0&&e.jsxs("span",{children:[" · ",B," pending"]})]})]}),g.length>0&&e.jsx("div",{className:"mt-3 space-y-2",children:g.map(x=>e.jsxs("div",{className:"space-y-1.5",children:[e.jsx("div",{className:"text-xs font-medium text-muted-foreground",children:x.name}),e.jsx(tt,{changes:Object.entries(x.applied).map(([Y,R])=>({field:Y,old:R.old??null,new:R.new??null})),entityId:x.entityId,ownerSlug:n,showAll:!0})]},x.entityId))}),E.length>0&&e.jsx("div",{className:"mt-3 space-y-1.5",children:E.map(x=>e.jsxs("div",{className:"rounded-md border border-destructive/40 bg-destructive/5 px-2.5 py-2",children:[e.jsxs("div",{className:"text-xs font-medium",children:[x.name," — not written"]}),x.denied&&e.jsxs("div",{className:"mt-0.5 text-xs text-muted-foreground",children:[x.denied.reason,e.jsxs("span",{className:"ml-1 opacity-70",children:["(refused by"," ",x.denied.source==="rule"?"a write rule":"org policy",")"]})]})]},`denied-${x.entityId}-${x.name}`))}),a!=null&&b==null&&k&&e.jsx("div",{className:"mt-3 border-t border-border/70 pt-3",children:m?e.jsxs("div",{className:"flex items-center gap-2 w-full",children:[e.jsx("input",{type:"text",placeholder:"What should the agent change?",value:N,onChange:x=>A(x.target.value),className:"h-7 text-xs border rounded px-2 flex-1 bg-background"}),e.jsxs($,{size:"sm",variant:"destructive",className:"h-7 text-xs",onClick:()=>v.mutate({run_id:a,reason:N||void 0},{onSuccess:()=>f("rejected")}),disabled:v.isPending,children:[v.isPending&&e.jsx(Pe,{size:"sm",className:"mr-1"}),"Reject all"]}),e.jsx($,{size:"sm",variant:"ghost",className:"h-7 text-xs px-2",onClick:()=>{h(!1),A("")},children:"Cancel"})]}):e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsxs($,{size:"sm",className:"h-7 text-xs",onClick:()=>c.mutate({run_id:a},{onSuccess:()=>f("approved")}),disabled:c.isPending||v.isPending,children:[c.isPending&&e.jsx(Pe,{size:"sm",className:"mr-1"}),"Approve all proposals"]}),e.jsx($,{size:"sm",variant:"outline",className:"h-7 text-xs",onClick:()=>h(!0),disabled:c.isPending||v.isPending,children:"Reject with feedback"})]})}),b==="approved"&&e.jsx("div",{className:"mt-3 text-xs text-muted-foreground",children:"All proposals approved."}),b==="rejected"&&e.jsx("div",{className:"mt-3 text-xs text-muted-foreground",children:"Proposals rejected — ask the agent to revise them."}),a!=null&&b==null&&!k&&e.jsx("div",{className:"mt-3 text-xs text-muted-foreground",children:"All proposals reviewed."})]})}function Te({presentation:t="summary",renderDetail:n,onFiltersChange:s,ownerSlug:r,content:a,isReply:o,showParentContext:l,connectorDefinitions:p,hideOriginator:i=!1,hideRunAction:c=!1,hideAttribution:v=!1,hideDetails:m=!1,recordId:h}){const[N,A]=_.useState(null),b=mn(),f=t==="detail",w=yt(),{currentOwner:q,allOrgs:P,isAuthenticated:D}=Ct(),E=r??q,g=E==="me"?null:E,B=_.useCallback(async y=>{if(!g){at.error("Open this event inside a workspace to interact with it.");return}const T=await ss(g,Number(a.id),y,crypto.randomUUID());return"event_id"in T&&at.success("Recorded"),T},[a.id,g]),k=a.payload_data??{},{audit:L,operation:x,changeSet:Y}=Dt(a),R=L&&(k.request!==void 0||k.request_status==="too_large"),F=L&&Array.isArray(k.sdk_call_trace)&&k.sdk_call_trace.length>0,O=E?it(E,Number(a.id)):null,I=!f&&D?(P??[]).find(y=>y.slug===g):void 0,U=I?{slug:I.slug,organizationId:I.id}:null,ne=ft(U??{slug:null,organizationId:null}),se=U?.slug??null,fe=_.useMemo(()=>se&&!L?gt(ne.data??[],a.semantic_type):[],[se,L,ne.data,a.semantic_type]),_e=pn(),re=is(a),oe=!!(!(x||Y||re)&&U&&fe.length>0),Q=!f&&!!O,le=xn(w?.item?.href.split(/[?#]/)[0]??""),ae=le?.owner===E&&le?.eventId===Number(a.id),X=(y,T,u)=>{w?w.open({href:y,title:T,...u==null?{}:{runId:u}}):b({to:y})},de=(y,T)=>{if(!g)return null;const u=`/${g}/events?run_ids=${y}`;return w?.item?.href===u?null:e.jsxs($,{variant:"ghost",size:"sm",className:"h-7 px-2 text-xs",onClick:()=>s?s({runIds:[y]}):X(u,"Run activity",y),title:s?"Filter by this run":"Open run activity",children:[e.jsx(gn,{className:"h-3.5 w-3.5"}),T]})},ce=a.run_id!=null&&(s||!(w&&g&&a.automation_id!=null))?de(a.run_id,s?"Run":"Open run"):null,H=hn(a),ue=a.automation_id,we=w&&g&&H!=null&&ue!=null?()=>w.open({href:`/${g}/automations/${ue}?run_id=${H}`,title:`${a.automation_name??`Automation ${ue}`} · Run #${H}`,runId:H}):void 0,ge=()=>{if(oe&&U&&g){const y=Number(a.id);ns(_e,U.slug,fe,y).catch(()=>null).then(T=>X(it(g,y,T?.key),a.title??"Event"));return}O&&X(O,a.title??"Event")},Z=y=>{const T=y.target;if(!(T instanceof Element))return!1;const u=T.closest('a,button,input,select,textarea,[role="button"],[role="radio"]');return u!==null&&u!==y.currentTarget},ee=y=>{Z(y)||ge()},ke=y=>{y.key!=="Enter"&&y.key!==" "||Z(y)||(y.preventDefault(),ge())},W=a.metadata?.source_run_id,me=Ns(a),pe=re?e.jsx(os,{content:a,detail:f}):f&&g?Y?e.jsx(Ks,{content:a,ownerSlug:g}):x?e.jsx(qs,{ownerSlug:g,content:a,batchReview:typeof W=="number"?de(W,"Review run"):null}):void 0:void 0,K=f&&n?n(pe):{content:pe,nativeHeading:pe!=null};return e.jsx("div",{className:Se(o?"border-l-2 border-l-muted pl-4":"",Q&&"cursor-pointer rounded-lg p-3 transition-colors hover:bg-accent/40",Q&&ae&&"bg-accent ring-1 ring-inset ring-primary/20"),...Q?{role:"button","aria-current":ae?"true":void 0,tabIndex:0,onClick:ee,onKeyDown:ke}:{},children:e.jsx(Ws,{primaryContent:K.content,nativeHeading:K.nativeHeading,heading:me&&g?e.jsx(ks,{event:me,recordId:h,ownerSlug:g}):void 0,body:me&&g?e.jsx(Cs,{event:me,ownerSlug:g}):void 0,detailLinks:K.links,headingAside:K.headingAside,hideDetails:m,onFiltersChange:s,presentation:t,content:a,ownerSlug:E??void 0,showParentContext:l,connectorDefinitions:p,onRenderedAction:g?B:void 0,runAction:c?null:ce,hideOriginator:i,hideAttribution:v,runId:H??a.run_id??null,onRunSelect:we,auditDetails:f&&(R||F)&&e.jsxs("div",{className:"space-y-3",children:[e.jsx("div",{className:"flex flex-wrap gap-2",children:[{key:"request",label:"Request",available:R},{key:"calls",label:"SDK calls",available:F}].map(y=>y.available?e.jsxs($,{variant:"outline",size:"sm","aria-expanded":N===y.key,onClick:()=>A(T=>T===y.key?null:y.key),children:[N===y.key?e.jsx(ve,{className:"h-3.5 w-3.5"}):e.jsx(Ne,{className:"h-3.5 w-3.5"}),y.label]},y.key):null)}),N==="request"&&(k.request_status==="too_large"?e.jsxs("p",{className:"text-sm text-muted-foreground",children:["The request was too large to retain",typeof k.request_bytes=="number"?` (${k.request_bytes.toLocaleString()} bytes).`:"."]}):e.jsx(mt,{value:k.request})),N==="calls"&&e.jsx(mt,{value:k.sdk_call_trace})]})})})}function Js(t,n){const s=t.payload_data??{},r=t.metadata??{};if(n.audit&&typeof s.success=="boolean")return s.success?"completed":"failed";if(n.changeSet)return r.kind==="automation_batch_reject"?"rejected":typeof r.pending_proposal_count!="number"?void 0:r.pending_proposal_count>0?"pending_approval":"completed";if(n.operation)return Ft(t.interaction_status,typeof r.status=="string"?r.status:void 0)}function Qs(t){return t==="pending_approval"?"Needs approval":t==="confirmed"?"Approved":t?he(t):null}function Ws({presentation:t,primaryContent:n,nativeHeading:s=!1,heading:r,body:a,detailLinks:o,headingAside:l,onFiltersChange:p,content:i,ownerSlug:c,showParentContext:v,connectorDefinitions:m,onRenderedAction:h,runAction:N,auditDetails:A,hideOriginator:b=!1,hideAttribution:f=!1,runId:w,onRunSelect:q,hideDetails:P=!1}){const[D,E]=_.useState(!1),g=i.metadata??{},B=typeof i.score=="number"&&Number.isFinite(i.score)?Math.round(i.score):"-",k=i.payload_type||"text",L=i.text_content||"",x=t==="summary",Y=t==null&&(k==="text"||k==="markdown")&&L.length>500,R=Y&&!D?`${L.slice(0,500)}...`:L,F=i.payload_data??{},O=Dt(i),{audit:I,operation:U,changeSet:ne}=O,se=Js(i,O),fe=Qs(se),_e=(I?It(F,F.tool_name):null)??(x&&I&&typeof F.tool_name=="string"?he(F.tool_name):i.title),re=I&&F.error&&typeof F.error=="object"?F.error.message:void 0,be=(typeof re=="string"?re:void 0)??i.interaction_error??(typeof g.error_message=="string"?g.error_message:void 0),oe=be||(I?"":L),[Q,le]=_.useState(t!=="summary"&&I&&n==null&&o==null),ae=I?F.duration_ms:g.duration_ms,X=typeof ae=="number"&&Number.isFinite(ae)&&ae>=0?ae:null,de=I&&typeof F.sdk_call_count=="number"&&Number.isSafeInteger(F.sdk_call_count)&&F.sdk_call_count>=0?F.sdk_call_count:null,ce=g.thumbnail_url||g.thumbnail,H=g.media_url,ue=x?[]:Es(g),we=Object.entries(i.classifications||{}).flatMap(([d,j])=>{const S=Ps(j);return S.values.map(J=>({slug:d,value:J,isManual:S.isManual}))}),ge=(()=>{const d=i.platform||(typeof g.platform=="string"?g.platform:null),j=i.connection_id!=null?i.connection_id:g.source_connection_id!=null?Number(g.source_connection_id):null;return{...i,platform:d,connection_id:j!=null&&Number.isFinite(j)?j:null}})(),Z=(()=>{const d=i.source_url??g.browser_url;if(typeof d!="string"||!URL.canParse(d))return null;const j=new URL(d);return j.protocol==="https:"||j.protocol==="http:"?j:null})(),ee=i.occurred_at?new Date(i.occurred_at):null,ke=I?vt:U?Nt:ne?Xt:i.semantic_type==="notification"?Zt:en,W=I?"SDK call":he(i.semantic_type||i.origin_type||"Event"),me=e.jsx(fn,{source:ge,connectorDefinitions:m,sourceUrl:Z,label:W,fallback:e.jsx(ke,{className:"h-4 w-4"})}),pe=ue.length>0?e.jsx("dl",{className:"grid gap-x-3 gap-y-2 text-sm sm:grid-cols-[minmax(140px,180px)_1fr]",children:ue.map(([d,j])=>e.jsxs("div",{className:"contents",children:[e.jsx("dt",{className:"text-muted-foreground",children:he(d)}),e.jsx("dd",{className:"min-w-0 break-words font-mono text-xs sm:text-sm",children:Rs(j)})]},d))}):null,K=a?e.jsx("div",{className:"mt-1",children:a}):x?oe?e.jsx("p",{className:Se("line-clamp-2 text-sm whitespace-pre-wrap",be&&"text-destructive"),children:oe.slice(0,320)}):null:e.jsxs(e.Fragment,{children:[i.rating&&e.jsx("div",{className:"flex items-center gap-1 mb-2",children:[1,2,3,4,5].map(d=>e.jsx(_t,{className:`h-4 w-4 ${d<=Number(i.rating)?"fill-yellow-400 text-yellow-400":"text-muted-foreground"}`},d))}),ce&&e.jsx("a",{href:H||i.source_url||"#",target:"_blank",rel:"noopener noreferrer",className:"block mb-2",children:e.jsx("img",{src:ce,alt:"",className:`rounded-md object-cover ${k==="media"?"max-h-96 w-full":"max-h-48"}`,loading:"lazy"})}),(()=>{switch(k){case"markdown":if(R)return e.jsx("div",{className:"max-w-none text-sm space-y-2",children:e.jsx(tn,{text:R})});break;case"json_template":{const d=i.payload_template;if(d?.root)return e.jsx(ls,{template:d,data:i.payload_data||{},onAction:n?void 0:h},`${c}:${i.id}`);if(R)return e.jsx("div",{className:"text-sm whitespace-pre-wrap",children:R});break}case"media":return e.jsxs("div",{className:"space-y-3",children:[!ce&&H&&e.jsx("a",{href:H,target:"_blank",rel:"noopener noreferrer",className:"text-sm text-primary hover:underline truncate block",children:H}),R&&e.jsx("div",{className:"text-sm whitespace-pre-wrap text-muted-foreground",children:R})]});case"empty":return e.jsxs("div",{className:"space-y-3",children:[A,pe??(A?null:e.jsx("p",{className:"text-sm text-muted-foreground italic",children:"No content"}))]});default:if(R)return e.jsx("div",{className:"text-sm whitespace-pre-wrap",children:R});break}return e.jsxs("div",{className:"space-y-3",children:[H&&!ce&&e.jsx("a",{href:H,target:"_blank",rel:"noopener noreferrer",className:"text-sm text-muted-foreground hover:text-foreground truncate block",children:H}),pe]})})()]}),y=n!=null||t==="detail"&&I,T=l!==void 0,u=y||o!=null;return _.useEffect(()=>{if(!T||!Q)return;const d=j=>{j.key==="Escape"&&(j.preventDefault(),le(!1))};return window.addEventListener("keydown",d),()=>window.removeEventListener("keydown",d)},[T,Q]),e.jsxs(e.Fragment,{children:[v&&i.parent_context&&e.jsxs("div",{className:"mb-3 p-2 bg-muted/50 rounded-md text-sm",children:[e.jsx("div",{className:"text-xs text-muted-foreground mb-1",children:"Replying to:"}),e.jsx("div",{className:"font-medium",children:i.parent_context.author_name}),e.jsx("div",{className:"text-muted-foreground line-clamp-2",children:i.parent_context.text_content})]}),e.jsxs("div",{className:Se("flex gap-3",t==="detail"&&"mb-5",T&&"relative"),children:[e.jsx(nn,{children:me}),e.jsxs("div",{className:"min-w-0 flex-1",children:[t==="detail"&&(()=>{const d={semanticTypes:[i.semantic_type],...typeof i.automation_id=="number"?{producedByAutomationId:i.automation_id}:{},...typeof i.run_id=="number"?{runIds:[i.run_id]}:{}},j={semantic_types:i.semantic_type,...typeof i.automation_id=="number"?{produced_by:String(i.automation_id)}:{},...typeof i.run_id=="number"?{run_ids:String(i.run_id)}:{}};return e.jsxs("div",{className:"mb-2 flex flex-wrap items-center gap-2 text-xs text-muted-foreground",children:[i.semantic_type?p?e.jsx("button",{type:"button",className:"hover:underline",title:`Show all ${W} events`,onClick:()=>p(d),children:W}):c?e.jsx(ie,{to:"/$owner/events",params:{owner:c},search:j,className:"hover:underline",title:`Show all ${W} events`,children:W}):e.jsx("span",{children:W}):e.jsx("span",{children:W}),ee&&e.jsx("time",{dateTime:ee.toISOString(),children:$e(ee)})]})})(),e.jsxs("div",{className:"flex items-start justify-between gap-3",children:[(r??_e)&&!s&&e.jsx("h4",{className:Se("min-w-0 font-medium",t==="detail"?"text-xl leading-snug":"line-clamp-2 text-sm"),children:r??_e}),t!=="detail"&&ee&&e.jsx(sn,{at:ee}),T&&e.jsxs("div",{className:"flex shrink-0 items-center gap-1 pt-0.5",children:[l,u&&e.jsxs($,{type:"button",variant:"ghost",size:"sm",className:"h-7 gap-1 px-2 text-muted-foreground hover:text-foreground","aria-expanded":Q,onClick:()=>le(d=>!d),children:["Details",Q?e.jsx(ve,{className:"h-3.5 w-3.5"}):e.jsx(Ne,{className:"h-3.5 w-3.5"})]})]})]}),x&&e.jsx("div",{className:"mt-1 text-muted-foreground",children:K}),e.jsxs("div",{className:"mt-2 flex flex-wrap items-center gap-x-3 gap-y-1 text-xs text-muted-foreground",children:[fe&&!s&&e.jsxs(xe,{variant:se==="failed"?"destructive":"secondary",className:"gap-1 text-xs",children:[se==="failed"?e.jsx(bt,{className:"h-3 w-3"}):se==="completed"?e.jsx(Ze,{className:"h-3 w-3"}):null,fe]}),de!=null&&e.jsxs("span",{children:[de," SDK ",de===1?"call":"calls"]}),X!=null&&e.jsxs("span",{className:"inline-flex items-center gap-1",children:[e.jsx(wt,{className:"h-3 w-3"}),X<1e3?`${Math.round(X)}ms`:`${Number((X/1e3).toFixed(2))}s`]}),N,B==="-"||x&&(I||U||ne)?null:i.score_breakdown?e.jsxs(rn,{children:[e.jsx(an,{asChild:!0,children:e.jsx($,{variant:"ghost",size:"sm",className:"h-7 px-2",children:e.jsx("span",{className:"font-medium",children:B})})}),e.jsx(on,{className:"w-64",align:"end",children:e.jsxs("div",{className:"space-y-2",children:[e.jsx("h4",{className:"font-medium",children:"Score Breakdown"}),e.jsx(Ts,{breakdown:i.score_breakdown})]})})]}):null,Z&&e.jsxs(ln,{children:[e.jsx(dn,{asChild:!0,children:e.jsx($,{variant:"ghost",size:"sm",className:"h-7 gap-1 px-1",asChild:!0,children:e.jsxs("a",{href:Z.href,target:"_blank",rel:"noopener noreferrer",children:[e.jsx(kt,{className:"h-3.5 w-3.5"}),e.jsx("span",{className:x?"sr-only":void 0,children:"View original"})]})})}),e.jsx(cn,{children:"View original"})]})]}),c&&!f&&e.jsx(un,{owner:c,source:ge,connectorDefinitions:m,onFiltersChange:p,variant:"chips",className:"mt-2 text-xs",hideOriginator:b,runId:w,onRunSelect:q}),(i.author_name||!c)&&!(t==="detail"&&U)&&e.jsx("div",{className:"mt-2 text-xs text-muted-foreground",children:i.author_name||Is(i)})]}),T&&Q&&u&&e.jsxs("div",{className:"absolute inset-x-0 top-full z-20 mt-2 max-h-[65vh] space-y-3 overflow-y-auto rounded-lg border bg-background p-3 shadow-lg",children:[o,y&&K]})]}),!x&&typeof re=="string"&&e.jsx("p",{className:"mb-2 text-sm whitespace-pre-wrap text-destructive",children:re}),n,!x&&!y&&K,(y||o!=null)&&l===void 0&&!(P&&n!=null)&&e.jsxs("details",{className:"mt-5 border-t pt-3",open:Q,onToggle:d=>le(d.currentTarget.open),children:[e.jsx("summary",{className:"cursor-pointer text-sm text-muted-foreground",children:"Details"}),Q&&e.jsxs("div",{className:"mt-3 space-y-3",children:[o,y&&K]})]}),Y&&e.jsx($,{variant:"link",size:"sm",className:"px-0 h-6 mt-1",onClick:()=>E(!D),children:D?e.jsxs(e.Fragment,{children:[e.jsx(ve,{className:"h-3 w-3 mr-1"})," Show less"]}):e.jsxs(e.Fragment,{children:[e.jsx(Ne,{className:"h-3 w-3 mr-1"})," Show more"]})}),we.length>0&&e.jsx("div",{className:"flex flex-wrap gap-1.5 mt-3",children:we.map(d=>e.jsx($s,{slug:d.slug,value:d.value||"",isManual:d.isManual},d.slug))})]})}function Gs({toolName:t,count:n,titles:s=[],totalDurationMs:r,totalSdkCalls:a,newestAt:o,oldestAt:l,expanded:p,onToggle:i,children:c}){return e.jsx("div",{children:e.jsxs(Be,{open:p,children:[e.jsx("div",{className:"rounded-lg p-3",children:e.jsxs("div",{className:"flex gap-3",children:[e.jsx("div",{"aria-hidden":!0,className:"mt-0.5 flex h-8 w-8 shrink-0 items-center justify-center rounded-lg bg-muted text-muted-foreground",children:e.jsx(vt,{className:"h-4 w-4"})}),e.jsxs("div",{className:"min-w-0 flex-1",children:[e.jsxs("div",{className:"flex items-start justify-between gap-3",children:[e.jsx(ze,{asChild:!0,children:e.jsxs($,{variant:"ghost",size:"sm",className:"h-5 min-w-0 gap-1.5 px-0 text-sm text-muted-foreground",onClick:i,children:[e.jsxs("span",{className:"min-w-0 truncate font-medium text-foreground",children:[he(t)," × ",n]}),p?e.jsx(ve,{className:"h-3.5 w-3.5 shrink-0"}):e.jsx(Ne,{className:"h-3.5 w-3.5 shrink-0"})]})}),e.jsx(Bt,{newestAt:o,oldestAt:l})]}),s.length>0&&e.jsx("p",{className:"mt-0.5 truncate text-sm text-muted-foreground",children:s.join(" · ")}),e.jsxs("div",{className:"mt-2 flex flex-wrap items-center gap-x-3 gap-y-1 text-xs text-muted-foreground",children:[e.jsxs(xe,{variant:"secondary",className:"gap-1 text-xs",children:[e.jsx(Ze,{className:"h-3 w-3"}),"Completed"]}),a!=null&&e.jsxs("span",{children:[a," SDK ",a===1?"call":"calls"]}),r!=null&&e.jsxs("span",{className:"inline-flex items-center gap-1",children:[e.jsx(wt,{className:"h-3 w-3"}),Ys(r)]})]})]})]})}),e.jsx(Ue,{className:"mt-2 space-y-3 border-l-2 border-l-muted pl-4",children:c})]})})}function Ys(t){return t<1e3?`${Math.round(t)}ms`:`${Number((t/1e3).toFixed(2))}s`}function Bt({newestAt:t,oldestAt:n}){const s=pt(t),r=pt(n);return s!=null&&r!=null&&s.getTime()-r.getTime()>Xs&&r?e.jsxs("time",{dateTime:s.toISOString(),title:`${$e(r)} – ${$e(s)}`,className:"shrink-0 pt-0.5 text-xs text-muted-foreground",children:[Le(r,"HH:mm"),"–",Le(s,"HH:mm")]}):s?e.jsx("time",{dateTime:s.toISOString(),title:$e(s),className:"shrink-0 pt-0.5 text-xs text-muted-foreground",children:Le(s,"HH:mm")}):null}const Xs=300*1e3;function pt(t){if(t==null||t==="")return null;const n=new Date(t);return Number.isNaN(n.getTime())?null:n}function Zs({organizationId:t,clientId:n,activityId:s,activityKind:r,callCount:a,newestAt:o,oldestAt:l,expanded:p,onToggle:i,children:c}){const{data:v=[]}=qn({limit:100,organizationId:t??null}),m=v.find(A=>A.activityId===s&&(n==null||A.clientId===n))??null,h=m?Jn(m):r==="session"?"MCP session":"Conversation",N=m?.clientName??null;return e.jsx("div",{children:e.jsxs(Be,{open:p,children:[e.jsx("div",{className:"rounded-lg border bg-muted/40 p-3",children:e.jsxs("div",{className:"flex gap-3",children:[e.jsx("span",{className:"flex h-7 w-7 shrink-0 items-center justify-center rounded-md border bg-background",children:e.jsx(St,{name:N})}),e.jsxs("div",{className:"min-w-0 flex-1",children:[e.jsxs("div",{className:"flex items-start justify-between gap-3",children:[e.jsx(ze,{asChild:!0,children:e.jsxs($,{variant:"ghost",size:"sm",className:"h-5 min-w-0 gap-1.5 px-0 text-sm text-muted-foreground",onClick:i,children:[e.jsx("span",{className:"min-w-0 truncate font-medium text-foreground",children:h}),p?e.jsx(ve,{className:"h-3.5 w-3.5 shrink-0"}):e.jsx(Ne,{className:"h-3.5 w-3.5 shrink-0"})]})}),e.jsx(Bt,{newestAt:o,oldestAt:l})]}),e.jsxs("div",{className:"mt-1 text-xs text-muted-foreground",children:[`${a} ${a===1?"call":"calls"}`,N?` · ${N}`:null]})]})]})}),e.jsx(Ue,{className:"mt-2 space-y-3 border-l-2 border-l-muted pl-4",children:c})]})})}function er({groupByDate:t=!0}){return e.jsx("div",{role:"status","aria-label":"Loading activity","aria-busy":"true",children:e.jsxs("div",{"aria-hidden":"true",children:[t?e.jsx("div",{className:"px-3 pb-2",children:e.jsx(Re,{className:"h-4 w-28 rounded-none"})}):null,["first","second","third","fourth","fifth"].map(n=>e.jsxs("div",{className:"flex items-start gap-3 px-3 py-3",children:[e.jsx(Re,{className:"h-8 w-8 shrink-0 rounded-none"}),e.jsxs("div",{className:"min-w-0 flex-1 space-y-2",children:[e.jsx(Re,{className:"h-4 w-3/5 max-w-sm rounded-none"}),e.jsxs("div",{className:"flex gap-3",children:[e.jsx(Re,{className:"h-3 w-20 rounded-none"}),e.jsx(Re,{className:"h-3 w-12 rounded-none"})]})]})]},n))]})})}function xt(t){if(t==null||t==="")return null;const n=new Date(t);return Number.isNaN(n.getTime())?null:Le(n,"d MMMM yyyy")}function tr({items:t,isLoading:n,emptyState:s,hasNextPage:r,isFetching:a,isFetchingNextPage:o,onLoadMore:l,autoLoadMore:p=!0,groupByDate:i=!0}){const c=Zn({onIntersect:l,enabled:p&&r&&!a});return n&&t.length===0?e.jsx(er,{groupByDate:i}):e.jsxs("div",{children:[t.length===0?s!==void 0?s:e.jsx(In,{icon:Rn,title:"Nothing here yet",description:"No events match this view."}):t.map((v,m)=>{const h=xt(v.occurredAt),N=m>0?xt(t[m-1].occurredAt):null;return e.jsxs(_.Fragment,{children:[i&&h&&h!==N&&e.jsx("p",{className:"px-3 pb-2 pt-4 text-xs text-muted-foreground first:pt-0",children:h}),e.jsx("div",{className:"mb-1",children:v.content})]},v.key)}),e.jsx("div",{ref:c,className:"h-1"}),o?e.jsx("div",{className:"flex justify-center py-4",children:e.jsx(Pe,{size:"xl",className:"text-muted-foreground"})}):r&&e.jsx($,{size:"sm",variant:"outline",disabled:a,onClick:l,children:"Load more"})]})}function hr({presentation:t="summary",renderDetail:n,onFiltersChange:s,hideDetails:r=!1,organizationId:a,ownerSlug:o,entityId:l,filters:p,showEntityLinks:i=!1,hideOriginator:c=!1,emptyState:v,foldConsecutiveCalls:m=!1,groupByConversation:h=!1,groupByRun:N=!1,onRunSelect:A,runs:b,hideRunAction:f=!1,hideAttribution:w=!1,hiddenApprovalRunIds:q}){const{isAuthenticated:P,isReady:D}=En(),{isMember:E,isLoading:g}=Tn(),B=o==="me",k=!B&&D&&P&&E,L=!B&&D&&(!P||!g&&!E),{data:x=[]}=$n(D&&k?a:null),{data:Y=[]}=Pn(L?o:null),R=k?x:Y,F=Dn(D&&k?a:null,l,p,o),O=Fn(L?o:null,l,p),I=L?O:F,{data:U,isLoading:ne,error:se,fetchNextPage:fe,hasNextPage:_e,isFetchingNextPage:re}=I,be=_.useMemo(()=>U?.pages.flatMap(u=>u.content)??[],[U]),oe=_.useMemo(()=>{const u=On(be,{foldRunSatellites:!N}),d=u.map(V=>V.head),j=new Map(u.map(V=>[V.head.id,V])),S=Ln(d,{groupByRun:N}),J=Array.from(S.entries()).map(([V,M])=>{const G=M.root||M.replies[0],Ae=G?j.get(G.id):void 0;return{rootId:V,group:M,history:Ae?.history??[],runId:Ae?.runId??null}});return q?Mn(J,q):J},[be,N,q]),[Q,le]=_.useState(new Set),[ae,X]=_.useState(new Set),[de,ce]=_.useState(new Set),[H,ue]=_.useState(new Set),[we,ge]=_.useState(new Set),Z=(u,d)=>u(j=>{const S=new Set(j);return S.has(d)?S.delete(d):S.add(d),S}),ee=(u,d)=>d.some(j=>u.has(j)),ke=(u,d)=>u(j=>{const S=new Set(j),J=d.some(V=>S.has(V));for(const V of d)J?S.delete(V):S.add(V);return S}),W=m?Bn(oe):oe.map(u=>({kind:"single",node:u})),me=h?zn(W):W,pe=!B&&(!D||P&&g||k&&I.isPending);if(se)return e.jsx(Un,{label:"events"});const K=u=>{if(u.kind==="fold"){const{fold:C}=u,nt=C.nodes.map(Ie=>Ie.rootId),Ht=ee(ae,nt);return[{key:C.key,occurredAt:C.newestAt,content:e.jsx(Gs,{toolName:C.toolName,count:C.nodes.length,titles:[...new Set(C.nodes.flatMap(Ie=>{const Ce=Ie.group.root?.payload_data,st=It(Ce,Ce?.tool_name);return st?[st]:[]}))],totalDurationMs:C.totalDurationMs,totalSdkCalls:C.totalSdkCalls,newestAt:C.newestAt,oldestAt:C.oldestAt,expanded:Ht,onToggle:()=>ke(X,nt),children:C.nodes.map(Ie=>{const Ce=Ie.group.root;return Ce?e.jsx(Te,{presentation:t,recordId:l,onFiltersChange:s,ownerSlug:o,content:Ce,renderDetail:n,connectorDefinitions:R,hideOriginator:c,hideRunAction:f,hideAttribution:w,hideDetails:r},Ce.id):null})})}]}const{rootId:d,group:j,history:S,runId:J}=u.node,V=j.replies.length>0,M=Q.has(d),G=we.has(d),Ae=H.has(d),zt=j.replies.filter(C=>C.depth<=3),De=j.replies.filter(C=>C.depth>3),Ut=!j.root&&j.replies.length>0,te=j.root||j.replies[0];return te?[{key:d,occurredAt:te.occurred_at,content:e.jsxs(e.Fragment,{children:[i&&o&&te.entity_name&&te.entity_type&&te.entity_slug&&e.jsx("div",{className:"mb-2",children:e.jsx(ts,{ownerSlug:o,entity:{entityName:te.entity_name,entityType:te.entity_type,entitySlug:te.entity_slug}})}),e.jsx(Te,{presentation:t,recordId:l,onFiltersChange:s,ownerSlug:o,content:te,renderDetail:n,showParentContext:Ut&&!!te.parent_context,connectorDefinitions:R,hideOriginator:c,hideRunAction:f,hideAttribution:w,hideDetails:r}),S.length>0&&e.jsxs(Be,{open:Ae,children:[e.jsx(ze,{asChild:!0,children:e.jsxs($,{variant:"ghost",size:"sm",className:"mt-1 h-7 gap-1 text-xs text-muted-foreground",onClick:()=>Z(ue,d),children:[e.jsx(Vn,{className:"h-3.5 w-3.5"}),Ae?e.jsxs(e.Fragment,{children:[e.jsx(ve,{className:"h-3.5 w-3.5"}),"Hide ",J!=null?`run #${J} `:"","history"]}):e.jsxs(e.Fragment,{children:[e.jsx(Ne,{className:"h-3.5 w-3.5"}),J!=null?`Run #${J} · ${S.length===1?"1 earlier step":`${S.length} earlier steps`}`:S.length===1?"1 earlier state":`${S.length} earlier states`]})]})}),e.jsx(Ue,{className:"mt-2 space-y-3 border-l-2 border-l-muted pl-4",children:S.map(C=>e.jsxs("div",{children:[e.jsx("time",{dateTime:new Date(C.occurred_at).toISOString(),title:$e(C.occurred_at),className:"mb-1 block text-xs text-muted-foreground",children:ot(C.occurred_at)}),e.jsx(Te,{presentation:t,recordId:l,onFiltersChange:s,ownerSlug:o,content:C,connectorDefinitions:R,hideOriginator:c,hideRunAction:f,hideAttribution:w})]},C.id))})]}),V&&e.jsxs(Be,{open:M,children:[e.jsx(ze,{asChild:!0,children:e.jsxs($,{variant:"ghost",size:"sm",className:"mt-2 ml-6 gap-1",onClick:()=>Z(le,d),children:[e.jsx(Ve,{className:"h-3.5 w-3.5"}),M?e.jsxs(e.Fragment,{children:[e.jsx(ve,{className:"h-3.5 w-3.5"}),"Hide ",j.replies.length," replies"]}):e.jsxs(e.Fragment,{children:[e.jsx(Ne,{className:"h-3.5 w-3.5"}),"Show ",j.replies.length," replies"]})]})}),e.jsxs(Ue,{className:"space-y-2 mt-2",children:[zt.map(C=>e.jsx(Te,{presentation:t,recordId:l,onFiltersChange:s,ownerSlug:o,content:C,isReply:!0,connectorDefinitions:R,hideOriginator:c,hideRunAction:f,hideAttribution:w},C.id)),De.length>0&&e.jsxs(e.Fragment,{children:[e.jsx($,{variant:"ghost",size:"sm",className:"ml-12",onClick:()=>Z(ge,d),children:G?e.jsxs(e.Fragment,{children:["Hide ",De.length," nested replies"]}):e.jsxs(e.Fragment,{children:["Show ",De.length," nested replies"]})}),G&&De.map(C=>e.jsx(Te,{presentation:t,recordId:l,onFiltersChange:s,ownerSlug:o,content:C,isReply:!0,connectorDefinitions:R,hideOriginator:c,hideRunAction:f,hideAttribution:w},C.id))]})]})]})]})}]:[]},y=u=>{const d=u.nodes.length;return{key:u.key,occurredAt:u.newestAt,content:e.jsxs("div",{children:[e.jsxs("div",{className:"flex flex-wrap items-center gap-x-2 gap-y-1",children:[A?e.jsxs($,{variant:"ghost",size:"sm",className:"h-7 gap-1 px-1 text-xs font-medium",onClick:()=>A(u.runId),title:`Open run #${u.runId} conversation`,children:[e.jsx(Ve,{className:"h-3.5 w-3.5"}),"Run #",u.runId]}):e.jsxs("span",{className:"inline-flex h-7 items-center gap-1 px-1 text-xs font-medium",children:[e.jsx(Ve,{className:"h-3.5 w-3.5"}),"Run #",u.runId]}),e.jsxs("span",{className:"text-xs text-muted-foreground",children:[u.status!=null?`· ${he(u.status)} · `:"· ",d===1?"1 event":`${d} events`,u.newestAt!=null?` · ${ot(u.newestAt)}`:""]})]}),e.jsx("div",{className:"mt-2 space-y-2 border-l-2 border-l-muted pl-4",children:u.nodes.flatMap(j=>K({kind:"single",node:j}).map(S=>e.jsx(_.Fragment,{children:S.content},S.key)))})]})}},T=u=>{const{block:d}=u,j=d.entries.flatMap(M=>M.kind==="fold"?M.fold.nodes.map(G=>G.rootId):[M.node.rootId]),S=ee(de,j),J=d.entries.flatMap(M=>K(M).map(G=>({key:G.key,content:G.content})));if(J.length===0)return[];const V=d.entries.reduce((M,G)=>M+(G.kind==="fold"?G.fold.nodes.length:1),0);return[{key:d.key,occurredAt:d.newestAt,content:e.jsx(Zs,{organizationId:a,clientId:d.clientId,activityId:d.activityId,activityKind:d.activityKind,callCount:V,newestAt:d.newestAt,oldestAt:d.oldestAt,expanded:S,onToggle:()=>ke(ce,j),children:J.map(M=>e.jsx(_.Fragment,{children:M.content},M.key))})}]};return e.jsx(tr,{groupByDate:t==="summary",isLoading:ne||pe,emptyState:v,hasNextPage:!!_e,isFetching:I.isFetching,isFetchingNextPage:re,onLoadMore:()=>void fe(),items:N?Hn(oe,b).map(u=>"nodes"in u?y(u):K({kind:"single",node:u})[0]).filter(u=>u!=null):me.flatMap(u=>u.kind==="context"?T(u):K(u))})}export{hr as E,xr as R,er as a,tr as b,Ws as c,pr as d,cr as e,mr as r,It as t,ur as u};
|
|
2
|
+
//# sourceMappingURL=events-feed-C4VrjIc1.js.map
|
|
@@ -0,0 +1,2 @@
|
|
|
1
|
+
import{dB as O,j as e,B as h,T as g,r as m,dC as C,X as P,dD as k,dE as S,dF as z,h as B,dG as D,dH as F,dI as E,dJ as L,cR as $,cS as R,U as I,df as j,dK as _,dL as H,dM as N,dN as b,I as y,dO as Q}from"./index-JmEl29py.js";function w(s,t,n){return O(s,-t,n)}const M="w-72";function T({editor:s,close:t,header:n,footer:o}){const[r,a]=m.useState("");return e.jsxs(e.Fragment,{children:[n,s.kind==="list"?e.jsxs(D,{shouldFilter:!s.onQueryChange,children:[e.jsx(F,{autoFocus:!0,placeholder:s.searchPlaceholder,value:r,onValueChange:d=>{a(d),s.onQueryChange?.(d)}}),e.jsxs(E,{children:[e.jsx(L,{children:s.emptyText}),e.jsx($,{children:s.items(t,r)})]})]}):s.render(t),o]})}function U({chip:s,editor:t}){const[n,o]=m.useState(!1),r=s.onRemove!=null,a=[s.label,s.op,s.value].filter(Boolean).join(" "),d=e.jsxs(e.Fragment,{children:[e.jsx("span",{className:"text-muted-foreground",children:s.label}),s.op?e.jsx("span",{className:"text-muted-foreground",children:s.op}):null,e.jsx("span",{className:"min-w-0 truncate font-medium",children:s.value})]}),l=t?e.jsx(S,{asChild:!0,children:e.jsx("button",{type:"button","aria-label":`Edit filter: ${a}`,className:"flex min-w-0 items-center gap-1.5 pl-2.5 pr-1 focus-visible:outline-none",children:d})}):e.jsx("span",{className:"flex min-w-0 items-center gap-1.5 pl-2.5 pr-1",children:d});return e.jsxs(C,{open:n,onOpenChange:o,children:[e.jsxs("div",{"data-filter-chip":s.id,title:s.title,className:g("inline-flex h-8 max-w-full items-stretch rounded-md border text-sm",s.tone==="warning"?"border-amber-500/60 bg-amber-500/10":r?"bg-muted":"border-dashed bg-transparent",n&&"ring-1 ring-ring",!r&&"pr-1.5"),children:[l,r?e.jsx("button",{type:"button","aria-label":`Remove filter: ${a}`,onClick:s.onRemove,className:"flex w-7 shrink-0 items-center justify-center text-muted-foreground transition-colors hover:text-foreground",children:e.jsx(P,{className:"h-3.5 w-3.5"})}):null]}),t?e.jsx(k,{align:"start",className:g("p-0",M,t.className),children:e.jsx(T,{editor:t,close:()=>o(!1),footer:r?e.jsx("div",{className:"border-t p-1",children:e.jsx(h,{variant:"ghost",size:"sm",className:"w-full justify-start text-destructive hover:text-destructive",onClick:()=>{o(!1),s.onRemove?.()},children:"Remove filter"})}):null})}):null]})}function A({fields:s}){const[t,n]=m.useState(!1),[o,r]=m.useState(),a=s.find(i=>i.key===o),d=[...new Set(s.map(i=>i.group??""))],l=()=>{n(!1),r(void 0)};return e.jsxs(C,{open:t,onOpenChange:i=>{n(i),i||r(void 0)},children:[e.jsx(S,{asChild:!0,children:e.jsxs(h,{variant:"outline",size:"sm",className:"h-8 gap-1.5 font-normal text-muted-foreground",children:[e.jsx(z,{className:"h-3.5 w-3.5"}),"Filter"]})}),e.jsx(k,{align:"start",className:g("p-0",M,a?.editor.className),children:a?e.jsx(T,{editor:a.editor,close:l,header:e.jsxs("div",{className:"flex items-center gap-1 border-b px-1 py-1 text-sm font-medium",children:[e.jsx(h,{variant:"ghost",size:"icon",className:"h-7 w-7","aria-label":"Back to filters",onClick:()=>r(void 0),children:e.jsx(B,{className:"h-4 w-4"})}),a.label]})},a.key):e.jsxs(D,{children:[e.jsx(F,{autoFocus:!0,placeholder:"Filter by…"}),e.jsxs(E,{children:[e.jsx(L,{children:"No matching filter"}),d.map(i=>e.jsx($,{heading:i||void 0,children:s.filter(c=>(c.group??"")===i).map(c=>e.jsxs(R,{value:`${c.label} ${c.key}`,onSelect:()=>r(c.key),className:"gap-2",children:[c.icon?e.jsx("span",{className:"flex h-4 w-4 shrink-0 items-center justify-center text-muted-foreground",children:c.icon}):null,c.label]},c.key))},i))]})]})})]})}function X({fields:s,chips:t,meta:n,actions:o,trailing:r,onClearAll:a,hasClearableState:d=!1,className:l,label:i="Filters"}){const c=s.filter(u=>u.inMenu!==!1),f=t.filter(u=>u.onRemove).length;return e.jsxs("div",{role:"search","aria-label":i,className:g("flex min-w-0 flex-wrap items-center gap-2",l),children:[t.map(u=>e.jsx(U,{chip:u,editor:u.editor??s.find(x=>x.key===(u.field??u.id))?.editor},u.id)),c.length>0?e.jsx(A,{fields:c}):null,o,e.jsxs("div",{className:"ml-auto flex flex-wrap items-center gap-2",children:[n?e.jsx("span",{className:"text-sm text-muted-foreground",children:n}):null,a&&(f>0||d)?e.jsx(h,{variant:"ghost",size:"sm",className:"h-8 text-muted-foreground",onClick:a,children:"Clear all"}):null,r]})]})}function G({selected:s}){return e.jsx(_,{className:g("h-4 w-4 shrink-0",s?"opacity-100":"opacity-0")})}function Y({searchPlaceholder:s,emptyText:t="No options",options:n,selected:o,multiple:r=!1,onSelect:a}){return{kind:"list",searchPlaceholder:s,emptyText:t,items:d=>n.map(l=>{const i=o.includes(l.value);return e.jsxs(R,{value:`${l.label} ${l.keywords??l.value}`,onSelect:()=>{a(l.value),r||d()},className:"gap-2",children:[r?e.jsx(I,{checked:i,className:"mr-1"}):e.jsx(G,{selected:i}),l.icon,e.jsx("span",{className:"min-w-0 flex-1 truncate",children:l.label}),l.count!=null?e.jsx("span",{className:"shrink-0 text-xs tabular-nums text-muted-foreground",children:l.count.toLocaleString()}):null]},l.value)})}}function Z([s,t],n,o){return s<=n?`≤ ${t}`:t>=o?`≥ ${s}`:`${s}–${t}`}function V({value:s,min:t,max:n,onApply:o,close:r}){const[a,d]=m.useState(String(s?.[0]??t)),[l,i]=m.useState(String(s?.[1]??n)),[c,f]=m.useState(),u=x=>{x.preventDefault();const p=Number(a),v=Number(l);if(!Number.isFinite(p)||!Number.isFinite(v)){f("Enter a number.");return}if(p<t||v>n){f(`Use values between ${t} and ${n}.`);return}if(p>v){f("The lower bound must not exceed the upper bound.");return}o([p,v]),r()};return e.jsxs("form",{className:"space-y-3 p-3",onSubmit:u,children:[e.jsxs("div",{className:"grid grid-cols-[1fr_auto_1fr] items-center gap-2",children:[e.jsx(y,{"aria-label":"From",type:"number",min:t,max:n,value:a,onChange:x=>d(x.target.value)}),e.jsx("span",{className:"text-sm text-muted-foreground",children:"to"}),e.jsx(y,{"aria-label":"To",type:"number",min:t,max:n,value:l,onChange:x=>i(x.target.value)})]}),c?e.jsx("p",{role:"alert",className:"text-xs text-destructive",children:c}):null,e.jsx(h,{type:"submit",size:"sm",className:"w-full",children:"Apply"})]})}function ee(s){return{kind:"custom",render:t=>e.jsx(V,{...s,close:t})}}const q=[{label:"Today",range:()=>[N(new Date),b(new Date)]},{label:"Last 7 days",range:()=>[N(w(new Date,6)),b(new Date)]},{label:"Last 30 days",range:()=>[N(w(new Date,29)),b(new Date)]},{label:"This month",range:()=>[Q(new Date),b(new Date)]}];function se([s,t]){return j(s,"yyyy-MM-dd")===j(t,"yyyy-MM-dd")?j(s,"LLL d, y"):`${j(s,"LLL d")} – ${j(t,"LLL d, y")}`}function J({value:s,onApply:t,close:n}){const[o,r]=m.useState(s?{from:s[0],to:s[1]}:void 0);return e.jsxs("div",{className:"flex flex-col sm:flex-row",children:[e.jsx("div",{className:"flex flex-col gap-0.5 border-b p-2 sm:w-36 sm:border-b-0 sm:border-r",children:q.map(a=>e.jsx(h,{variant:"ghost",size:"sm",className:"justify-start font-normal",onClick:()=>{t(a.range()),n()},children:a.label},a.label))}),e.jsx(H,{mode:"range",defaultMonth:o?.from,selected:o,onSelect:a=>{r(a),a?.from&&a.to&&a.from!==a.to&&(t([N(a.from),b(a.to)]),n())},numberOfMonths:1})]})}function te(s){return{kind:"custom",className:"w-auto",render:t=>e.jsx(J,{...s,close:t})}}function K({type:s,label:t,value:n,onApply:o,close:r}){const[a,d]=m.useState(n==null?"":String(n)),[l,i]=m.useState(),c=f=>{if(f.preventDefault(),s==="number"){const u=Number(a);if(a.trim()===""||!Number.isFinite(u)){i("Enter a number.");return}o(u)}else o(a);r()};return e.jsxs("form",{className:"space-y-3 p-3",onSubmit:c,children:[e.jsx(y,{autoFocus:!0,"aria-label":t,type:s,step:s==="number"?"any":void 0,value:a,onChange:f=>d(f.target.value),placeholder:"Enter a value…"}),l?e.jsx("p",{role:"alert",className:"text-xs text-destructive",children:l}):null,e.jsx(h,{type:"submit",size:"sm",className:"w-full",children:"Apply"})]})}function ae(s){return{kind:"custom",render:t=>e.jsx(K,{...s,close:t})}}export{X as F,G as S,Z as a,te as d,se as f,Y as o,ee as r,ae as v};
|
|
2
|
+
//# sourceMappingURL=filter-editors-oNjBX9a2.js.map
|
package/dist/owletto/dist/assets/{full-page-spinner-BVbcpW3R.js → full-page-spinner-DtmqQmgl.js}
RENAMED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import{r,j as t,
|
|
2
|
-
//# sourceMappingURL=full-page-spinner-
|
|
1
|
+
import{r,j as t,T as u}from"./index-JmEl29py.js";function l({className:i,delayMs:e=500}){const[s,n]=r.useState(e<=0);return r.useEffect(()=>{if(e<=0)return;const a=setTimeout(()=>n(!0),e);return()=>clearTimeout(a)},[e]),s?t.jsx("div",{className:u("flex min-h-[50vh] items-center justify-center",i),role:"status","aria-label":"Loading",children:t.jsx("div",{className:"h-8 w-8 animate-spin rounded-full border-4 border-primary border-t-transparent"})}):null}export{l as F};
|
|
2
|
+
//# sourceMappingURL=full-page-spinner-DtmqQmgl.js.map
|
|
@@ -0,0 +1,2 @@
|
|
|
1
|
+
import{iX as t,j as n}from"./index-JmEl29py.js";import{a as i}from"./agents-workbench-D1YL3VAB.js";import"./agent-editor-form-C24p9LLg.js";import"./model-selector-BeFuFH7p.js";import"./proposal-review-shell-CmLy1MZf.js";import"./runs-B0zVYb-w.js";function d(){const{owner:o,agentId:r}=t.useParams(),e=t.useSearch();return n.jsx(i,{owner:o,agentId:r,tab:"identity",runId:e.run_id})}export{d as component};
|
|
2
|
+
//# sourceMappingURL=identity-BkK8ggdp.js.map
|
|
@@ -0,0 +1,2 @@
|
|
|
1
|
+
import{am as l,an as c,j as e,S as t,L as m,C as d,ao as x}from"./index-JmEl29py.js";function u({owner:a}){const{destinations:r}=l(),{isMember:i,isLoading:o,org:n}=c(a);return e.jsxs("div",{className:"mx-auto flex w-full max-w-xl flex-col gap-6 px-4 pt-4 pb-8",children:[e.jsxs("div",{className:"space-y-1",children:[e.jsx("h1",{className:"text-3xl font-semibold leading-tight",children:"Settings"}),n?e.jsx("p",{className:"text-sm text-muted-foreground",children:n.name}):null]}),o?e.jsx("div",{role:"status","aria-label":"Loading settings","aria-busy":"true",children:e.jsx("div",{"aria-hidden":"true",children:r.map(s=>e.jsx("div",{className:s.separator?"mt-3 border-t border-border pt-3":void 0,children:e.jsxs("div",{className:"flex min-h-12 items-center gap-3 px-3",children:[e.jsx(t,{className:"h-4 w-4 shrink-0 rounded-none"}),e.jsx(t,{className:"h-4 w-24 rounded-none"})]})},s.key))})}):i?e.jsx("nav",{"aria-label":"Settings sections",children:e.jsx("ul",{children:r.map(s=>e.jsx("li",{className:s.separator?"mt-3 border-t border-border pt-3":void 0,children:e.jsxs(m,{to:s.to,params:s.params,search:s.search,className:"flex min-h-12 items-center gap-3 rounded-md px-3 text-sm font-medium transition-colors hover:bg-sidebar-accent focus-visible:outline-none focus-visible:ring-1 focus-visible:ring-ring",children:[e.jsx(s.icon,{className:"h-4 w-4 shrink-0 text-muted-foreground"}),e.jsx("span",{className:"min-w-0 flex-1 truncate",children:s.label}),e.jsx(d,{className:"h-4 w-4 shrink-0 text-muted-foreground"})]})},s.key))})}):e.jsx("p",{className:"text-sm text-muted-foreground",children:"Workspace settings are available to members."})]})}function p(){const{owner:a}=x.useParams();return e.jsx(u,{owner:a})}export{p as component};
|
|
2
|
+
//# sourceMappingURL=index-BhBYXtEN.js.map
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import{
|
|
2
|
-
//# sourceMappingURL=index-
|
|
1
|
+
import{o as y,q as C,s as U,r as R,t as S,v as L,j as I}from"./index-JmEl29py.js";import{F as P}from"./full-page-spinner-DtmqQmgl.js";function f(t){return t?.trim().toLowerCase()||null}function _(t){return t?.methods??[]}function k(t,s){const e=f(s);if(!e)return null;for(const i of t){const o=_(i.auth_schema);if(!o.some(n=>n.type==="oauth"&&f(n.provider)===e&&Array.isArray(n.loginScopes)&&n.loginScopes.length>0))continue;const r=o.find(n=>n.type==="app_installation"&&f(n.provider)===e);if(r)return{connectorKey:i.key,provider:e,installShape:r.installShape??null}}return null}function q(){const{isAuthenticated:t,authReady:s,currentOwner:e,orgsReady:i}=y(),o=C(),p=U(),r=R.useRef(!1),n=new URLSearchParams(window.location.search).get("onboard_provider"),d=new URLSearchParams(window.location.search).get("connector"),l=d&&/^[a-z0-9][a-z0-9._-]{0,127}$/.test(d)&&!["create","deployments"].includes(d)?d:null;return R.useEffect(()=>{if(s&&p.pathname==="/"){if(t&&e){const a=new URLSearchParams(window.location.hash.replace(/^#/,"")),m=a.get("agent")?.trim(),h=a.get("thread")?.trim(),$=a.get("message")?.trim()||a.get("message_id")?.trim(),c=a.get("run")?.trim(),g=a.get("worker")?.trim();if(!!m&&!!h||!!c&&/^\d+$/.test(c)||!!g){if(r.current)return;if(r.current=!0,window.history.replaceState(null,"",`${window.location.pathname}${window.location.search}`),m&&h){const u=$?`?message_id=${encodeURIComponent($)}`:"";window.location.replace(`/${encodeURIComponent(e)}/chat/${encodeURIComponent(m)}/c/${encodeURIComponent(h)}${u}`);return}if(c&&/^\d+$/.test(c)){const u=new URLSearchParams({run_ids:c,peek:"1",peek_run_id:c});window.location.replace(`/${encodeURIComponent(e)}/events?${u.toString()}`);return}if(g){window.location.replace(`/${encodeURIComponent(e)}/connectors/device/${encodeURIComponent(g)}`);return}}if(r.current)return;if(r.current=!0,l){o({to:"/$owner/connectors/$connectorKey",params:{owner:e,connectorKey:l},replace:!0});return}const w=()=>void o({to:"/$owner",params:{owner:e},replace:!0});if(n){S(e).then(u=>{const v=k(u,n);if(v){window.location.assign(`/${encodeURIComponent(e)}/connectors/${encodeURIComponent(v.connectorKey)}`);return}w()}).catch(w);return}w();return}if(t){i&&o({to:"/account/settings",replace:!0});return}o({to:"/auth/login",search:L({callbackUrl:l?`/?connector=${encodeURIComponent(l)}`:void 0}),replace:!0})}},[s,e,t,i,o,p.pathname,n,l]),I.jsx("div",{"data-public-loading":"true",children:I.jsx(P,{delayMs:0,className:"min-h-0 py-16"})})}export{q as component};
|
|
2
|
+
//# sourceMappingURL=index-Bhop_otG.js.map
|
|
@@ -0,0 +1,2 @@
|
|
|
1
|
+
import{w as t,j as i}from"./index-JmEl29py.js";import{A as m}from"./activity-route-view-_G_lDz5K.js";import"./record-activity-Doeu5kPO.js";import"./filter-editors-oNjBX9a2.js";import"./connection-label-BobuYiAG.js";import"./runs-B0zVYb-w.js";import"./source-record-panels-BeAZeMLy.js";import"./events-feed-C4VrjIc1.js";import"./client-activity-scopes-CmK3DkSP.js";import"./client-rows-fFuxzFtE.js";import"./use-automations-DS3uz3pb.js";import"./json-diff-4sMmayDd.js";import"./index-wHFQv1aT.js";import"./copy-button-kcjg8Giw.js";import"./linked-record-peek-B0_B4PnF.js";import"./card-Cspo-4M6.js";import"./use-scroll-sentinel-BpQ70c28.js";import"./agent-loading-shells-jkf9DjdO.js";import"./member-scope-gate-Dit3MXBQ.js";import"./public-shell-ready-_awBxu2Y.js";function S(){const{owner:o}=t.useParams(),r=t.useSearch();return i.jsx(m,{owner:o,search:r,home:!0})}export{S as component};
|
|
2
|
+
//# sourceMappingURL=index-Bw5iV_J7.js.map
|
|
@@ -0,0 +1,2 @@
|
|
|
1
|
+
import{im as n,j as o,at as r}from"./index-JmEl29py.js";import{A as a}from"./agent-connect-pages-BryZas7Z.js";import"./agent-client-setup-list-BgyLhJCo.js";import"./copy-button-kcjg8Giw.js";import"./client-rows-fFuxzFtE.js";function g(){const{owner:t}=n.useParams();return o.jsx(r,{owner:t,children:({ownerSlug:e})=>o.jsx(a,{owner:e})})}export{g as component};
|
|
2
|
+
//# sourceMappingURL=index-C3dpyynY.js.map
|
|
@@ -0,0 +1,2 @@
|
|
|
1
|
+
import{i_ as r,j as e}from"./index-JmEl29py.js";import{A as i}from"./agent-skills-route-BMZ3r1bP.js";import"./agent-skill-context-B9giw2u2.js";import"./core.esm-CoJ5Splc.js";import"./skill-editor-D_W3QlRz.js";import"./agent-subpage-shell-D49f-bzP.js";import"./agent-loading-shells-jkf9DjdO.js";import"./agent-card-controls-ColL5rdd.js";function l(){const{owner:t,agentId:o}=r.useParams();return e.jsx(i,{owner:t,agentId:o})}export{l as component};
|
|
2
|
+
//# sourceMappingURL=index-C3zAbslo.js.map
|
|
@@ -0,0 +1,2 @@
|
|
|
1
|
+
import{bk as t,j as p,bl as m}from"./index-JmEl29py.js";import{M as i}from"./memory-browse-page-DTlM_9MY.js";import"./public-shell-ready-_awBxu2Y.js";import"./schema-type-editor-panel-DcJqbCrU.js";import"./entity-type-page-BzMZttzh.js";import"./json-diff-4sMmayDd.js";import"./index-wHFQv1aT.js";import"./code-editor-C8FJbT2P.js";import"./linked-record-peek-B0_B4PnF.js";import"./card-Cspo-4M6.js";import"./entity-avatar-BZIa-7i5.js";import"./filter-editors-oNjBX9a2.js";import"./core.esm-CoJ5Splc.js";import"./view-param-filters-FuOZyjMg.js";import"./app-bridge-BCm4muqj.js";import"./member-scope-gate-Dit3MXBQ.js";function b(){const{owner:o,entityType:r}=t.useParams(),{create:e}=t.useSearch();return p.jsx(i,{ownerSlug:o,typeScope:m(r),create:e??!1})}export{b as component};
|
|
2
|
+
//# sourceMappingURL=index-CGKN_WN_.js.map
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import{
|
|
2
|
-
//# sourceMappingURL=index-
|
|
1
|
+
import{as as z,j as n,at as Y,au as Q,av as V,aw as H,ax as J,ay as Z,az as ee,aA as ne,r as D,aB as se,aC as G,B as W,q as oe,aD as ae,aE as te,aF as re,aG as ie,aH as ce,aI as de,aJ as le,aK as ue,aL as pe,aM as me,aN as U,aO as he,aP as fe,S as T,aQ as xe,L,aR as X,aS as q,aT as ve,aU as ge,aV as ye,aW as _e,aX as Ne,aY as je,Q as be,aZ as ke}from"./index-JmEl29py.js";function Le(){const{owner:a}=z.useParams(),{filter:c}=z.useSearch();return n.jsx(Y,{owner:a,children:r=>n.jsx(Ce,{ownerSlug:r.ownerSlug,organizationId:r.organizationId,isWorkspaceLoading:r.isWorkspaceLoading,requestedFilter:c})})}function Ce({ownerSlug:a,organizationId:c,isWorkspaceLoading:r,requestedFilter:m}){const{data:h=[],isLoading:d,isError:E,refetch:j}=Q(c??""),{data:y=[],isLoading:S,isError:K,refetch:R}=V(c??""),{data:b=[]}=H(c,{}),{data:k=[],isLoading:f,isError:C,refetch:O}=J(),{data:I=[]}=Z(),{data:P,isLoading:M,isError:s,refetch:t}=ee(),{data:x=[],isLoading:p,isError:w,refetch:v}=ne(),e=r||d||S||f||M||p,o=P?.sandboxes??[],i=D.useMemo(()=>x.filter(l=>se(l,a)),[x,a]);return E||K||C||s||w?n.jsx(G,{children:n.jsxs("div",{role:"alert",className:"space-y-2",children:[n.jsx("p",{children:"Could not load the connector inventory."}),n.jsx(W,{variant:"outline",size:"sm",onClick:()=>{Promise.all([j(),R(),O(),t(),v()])},children:"Retry"})]})}):n.jsx(G,{className:"flex flex-1 flex-col gap-6",children:n.jsx(Ie,{ownerSlug:a,isContentLoading:e,groups:h,installedDefs:y,authProfiles:b,inferenceProviders:k,inferenceCatalog:I,sandboxes:o,devices:i,requestedFilter:m})})}function Ie({ownerSlug:a,isContentLoading:c,groups:r,installedDefs:m,authProfiles:h,inferenceProviders:d,inferenceCatalog:E,sandboxes:j,devices:y,requestedFilter:S}){const K=oe(),R=S??"all",b=D.useMemo(()=>{const s=new Map(r.map(e=>[e.connector_key,e])),t=new Map;for(const e of m)t.set(e.key,e);for(const e of r)t.has(e.connector_key)||t.set(e.connector_key,{key:e.connector_key,name:e.connector_name??e.connector_key,description:null,version:"",auth_schema:null,feeds_schema:null,actions_schema:null,options_schema:null,status:"active",login_enabled:!1,favicon_domain:e.favicon_domain,facets:e.facets});const x=ae(d).filter((e,o,i)=>i.findIndex(l=>l.provider.kind===e.provider.kind)===o).map(e=>({connector:{...e.connector,key:`${te}${e.provider.kind}`,name:E.find(o=>o.slug===e.provider.kind)?.displayName??e.provider.kind},group:void 0,profileCounts:{env:0,oauth_app:0,oauth_account:0,browser_session:0},facets:e.facets,needsSetup:!1,provider:e.provider,sandbox:void 0,device:void 0,deviceFamily:void 0})),p=re(j).filter((e,o,i)=>i.findIndex(l=>l.sandbox.providerKind===e.sandbox.providerKind)===o).map(e=>({connector:{...e.connector,key:`${ie}${e.sandbox.providerKind}`,name:ce(e.sandbox.providerKind)},group:void 0,profileCounts:{env:0,oauth_app:0,oauth_account:0,browser_session:0},facets:e.facets,needsSetup:j.some(o=>o.providerKind===e.sandbox.providerKind&&!o.connected),provider:void 0,sandbox:e.sandbox,device:void 0,deviceFamily:void 0})),w=de(y,r,a).map(e=>({connector:e.connector,group:void 0,profileCounts:{env:0,oauth_app:0,oauth_account:0,browser_session:0},facets:e.facets,needsSetup:!1,isDevice:!0,provider:void 0,sandbox:void 0,device:e.device,deviceFamily:e}));return[...Array.from(t.values()).filter(e=>e.installed||(s.get(e.key)?.connection_count??0)>0).filter(e=>!le(e)).map(e=>{const o=s.get(e.key),i=ue(e.auth_schema),l=h.reduce((g,N)=>(N.connector_key!==e.key||(g[N.profile_kind]+=1),g),{env:0,oauth_app:0,oauth_account:0,browser_session:0}),A=pe(e,o),_=y.some(g=>g.connectors.some(N=>N.organization_slug===a&&N.connector_key===e.key)),$=we(e,o,i,l);return{connector:e,group:o,profileCounts:l,facets:A,needsSetup:$,isDevice:_,provider:void 0,sandbox:void 0,device:void 0,deviceFamily:void 0}}),...x,...p,...w].sort((e,o)=>e.needsSetup&&!o.needsSetup?-1:!e.needsSetup&&o.needsSetup?1:e.connector.name.localeCompare(o.connector.name))},[a,h,y,r,m,d,E,j]),k=D.useMemo(()=>{const s=me.filter(t=>t!=="all"&&b.some(x=>U(x,t)));return s.length>1?["all",...s]:[]},[b]),f=k.includes(R)?R:"all",C=D.useMemo(()=>b.filter(s=>U(s,f)),[b,f]),O=C.length,I=D.useMemo(()=>f==="all"?he(a,y,fe()):[],[f,a,y]),P=n.jsx(W,{asChild:!0,size:"sm",className:"h-8 shrink-0 text-xs",children:n.jsxs(L,{to:"/$owner/connectors/create",params:{owner:a},children:[n.jsx(ke,{className:"mr-1.5 h-3.5 w-3.5"}),"Add connector"]})});if(c)return n.jsxs("div",{className:"space-y-4",children:[n.jsx("div",{className:"flex justify-end",children:P}),n.jsx("div",{className:"overflow-hidden rounded-lg border",role:"status","aria-label":"Loading connectors",children:Array.from({length:6}).map((s,t)=>n.jsxs("div",{className:`flex items-center gap-3 px-3 py-2.5 ${t===5?"":"border-b"}`,children:[n.jsx(T,{className:"h-7 w-7 shrink-0 rounded-md"}),n.jsxs("div",{className:"min-w-0 flex-1 space-y-1.5",children:[n.jsx(T,{className:"h-4 w-40"}),n.jsx(T,{className:"h-3 w-24"})]})]},t))})]});const M=s=>{K({to:"/$owner/connectors",params:{owner:a},search:t=>({...t,filter:s==="all"?void 0:s}),replace:!0})};return n.jsxs("div",{className:"space-y-4",children:[n.jsx("p",{className:"text-sm text-muted-foreground",children:"What your agents can reach — data, tools, models, and runtimes."}),n.jsxs("div",{className:"flex flex-wrap items-center gap-x-3 gap-y-2",children:[n.jsxs("div",{className:"flex min-w-0 flex-1 flex-wrap items-center gap-1.5",children:[k.map(s=>n.jsx(W,{type:"button",variant:f===s?"secondary":"ghost","aria-pressed":f===s,size:"sm",className:"h-7 px-2 text-xs",onClick:()=>M(s),children:xe[s]},s)),k.length===0&&C.length===0&&I.length>0?n.jsx("p",{className:"text-sm text-muted-foreground",children:"Nothing connected yet — set up one of the apps below."}):null]}),n.jsx("div",{className:"ml-auto shrink-0",children:P})]}),I.length>0?n.jsx("div",{className:"grid grid-cols-2 gap-px overflow-hidden rounded-lg border border-dashed bg-border sm:grid-cols-[repeat(auto-fit,minmax(10rem,1fr))]",children:I.map(s=>n.jsxs(L,{to:"/$owner/connectors/app/$appId",params:{owner:a,appId:s.id},title:s.tagline,className:"flex min-w-0 items-center gap-2 bg-background px-3 py-2.5 text-muted-foreground transition-colors last:odd:col-span-2 hover:bg-accent/50 hover:text-foreground sm:last:odd:col-span-1",children:[n.jsx("span",{className:"flex h-7 w-7 shrink-0 items-center justify-center text-muted-foreground",children:s.icon}),n.jsx("span",{className:"truncate text-sm font-medium",children:s.name})]},s.id))}):null,C.length===0?k.length>0?n.jsx(X,{icon:q.connectors.icon,title:"No connectors match this filter",description:"Try another capability.",secondaryActionLabel:"Show all",secondaryOnAction:()=>M("all")}):I.length>0?null:n.jsx(X,{icon:q.connectors.icon,title:"No connectors yet",description:"Connect your first connector to this workspace."}):n.jsx("div",{className:"overflow-hidden rounded-lg border",children:C.map(({connector:s,group:t,facets:x,profileCounts:p,needsSetup:w,provider:v,sandbox:e,device:o,deviceFamily:i},l)=>{const A=new Map(m.map(u=>[u.key,u])),_=ve(s.key,A,{name:s.name,iconUrl:v?E.find(u=>u.slug===v.kind)?.iconUrl:void 0,faviconDomain:s.favicon_domain??t?.favicon_domain??(e?ge(e.providerKind):void 0)}),$=p.oauth_account+p.browser_session,g=t?.connection_count??0,N=o?`${i?.devices.length??1} ${o.platform==="chrome-extension"?i?.devices.length===1?"profile":"profiles":i?.devices.length===1?"device":"devices"} · ${i?.devices.filter(u=>u.online).length??0} online`:v?`${d.filter(u=>u.kind===v.kind).length} configured accounts`:e?`${j.filter(u=>u.providerKind===e.providerKind).length} instances`:[`${g} ${g===1?"connection":"connections"}`,$>0?`${$} ${$===1?"saved authorization":"saved authorizations"}`:null,p.oauth_app>0?`${p.oauth_app} OAuth app${p.oauth_app===1?"":"s"}`:null].filter(Boolean).join(" · "),F=Ee(l,O),B=n.jsxs(n.Fragment,{children:[o?n.jsx("span",{className:"flex h-7 w-7 shrink-0 items-center justify-center rounded-md border",children:n.jsx(ye,{platform:_e(o)})}):n.jsx(Ne,{icon:_.icon,iconUrl:_.iconUrl,name:_.name,faviconDomain:_.faviconDomain,className:"h-7 w-7 shrink-0 rounded-md text-[10px]"}),n.jsxs("div",{className:"min-w-0 flex-1",children:[n.jsxs("div",{className:"flex flex-wrap items-center gap-2",children:[n.jsx("span",{className:"truncate text-sm font-medium",children:_.name}),n.jsx(je,{facets:x})]}),n.jsx("p",{className:"truncate text-xs text-muted-foreground",children:N})]}),w?n.jsx(be,{variant:"secondary",className:"shrink-0 text-[10px]",children:"Needs setup"}):null]});return i?.appId?n.jsx(L,{to:"/$owner/connectors/app/$appId",params:{owner:a,appId:i.appId},className:F,children:B},s.key):o?n.jsx(L,{to:"/$owner/connectors/device/$deviceId",params:{owner:a,deviceId:o.id},className:F,children:B},s.key):n.jsx(L,{to:"/$owner/connectors/$connectorKey",params:{owner:a,connectorKey:s.key},search:v||e?{instances:!0}:{},className:F,children:B},s.key)})})]})}function Ee(a,c){return`flex items-center gap-3 px-3 py-2.5 text-left text-muted-foreground transition-colors hover:bg-accent/50 hover:text-foreground ${a===c-1?"":"border-b"}`}function we(a,c,r,m){if((c?.connection_count??0)>0)return!1;const h=r.some(d=>d.type==="none");return!!(!h&&r.some(d=>d.type==="oauth")&&m.oauth_app===0||!h&&r.some(d=>d.type==="env_keys")&&m.env===0||!h&&r.some(d=>d.type==="app_installation")&&!c||a.required_capability&&!c)}export{Le as component};
|
|
2
|
+
//# sourceMappingURL=index-CgRaCOzW.js.map
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import{
|
|
2
|
-
//# sourceMappingURL=index-
|
|
1
|
+
import{hz as n,j as s,hA as r}from"./index-JmEl29py.js";function c(){const{owner:e}=n.useParams(),{connector:o,install:t}=n.useSearch();return s.jsx(r,{owner:e,initialConnectorKey:o||t})}export{c as component};
|
|
2
|
+
//# sourceMappingURL=index-DRbaESbJ.js.map
|
|
@@ -0,0 +1,2 @@
|
|
|
1
|
+
import{ar as r,j as e}from"./index-JmEl29py.js";import{M as m}from"./memory-browse-page-DTlM_9MY.js";import"./public-shell-ready-_awBxu2Y.js";import"./schema-type-editor-panel-DcJqbCrU.js";import"./entity-type-page-BzMZttzh.js";import"./json-diff-4sMmayDd.js";import"./index-wHFQv1aT.js";import"./code-editor-C8FJbT2P.js";import"./linked-record-peek-B0_B4PnF.js";import"./card-Cspo-4M6.js";import"./entity-avatar-BZIa-7i5.js";import"./filter-editors-oNjBX9a2.js";import"./core.esm-CoJ5Splc.js";import"./view-param-filters-FuOZyjMg.js";import"./app-bridge-BCm4muqj.js";import"./member-scope-gate-Dit3MXBQ.js";function M(){const{owner:t}=r.useParams(),o=r.useSearch();return e.jsx(m,{ownerSlug:t,create:!1,createType:o.create_type==="true"})}export{M as component};
|
|
2
|
+
//# sourceMappingURL=index-DfIoxD5Q.js.map
|
|
@@ -0,0 +1,2 @@
|
|
|
1
|
+
import{r as x,j as n,B as p,b0 as T,b1 as C,a$ as S,aA as L,av as E,aR as N,b2 as R,aS as M,aT as I,L as j,b3 as D,b4 as P,b5 as B,b6 as O,aX as W,Q as v,b7 as z,b8 as U,b9 as F,ba as K,bb as H,bc as A,bd as G,be as Q,bf as X,at as Z}from"./index-JmEl29py.js";import{L as q}from"./list-skeleton-BafzvpOM.js";import{u as J,a as V}from"./use-automations-DS3uz3pb.js";import{c as Y}from"./cronstrue-CeUS_78Q.js";const ee=[{value:"all",label:"All"},{value:"event",label:"Event"},{value:"schedule",label:"Schedule"},{value:"manual",label:"Manual"}];function te({pending:e,onConfirm:t}){const[s,o]=x.useState(!1);return s?n.jsxs("div",{className:"flex items-center gap-1",children:[n.jsx(p,{type:"button",variant:"destructive",size:"sm",disabled:e,onClick:t,children:"Delete"}),n.jsx(p,{type:"button",variant:"ghost",size:"sm",onClick:()=>o(!1),children:"Cancel"})]}):n.jsx(p,{type:"button",variant:"ghost",size:"icon",className:"text-muted-foreground hover:text-destructive","aria-label":"Delete",onClick:()=>o(!0),children:n.jsx(T,{className:"h-4 w-4"})})}function ne(e){try{return Y.toString(e.trim(),{throwExceptionOnParseError:!0})}catch{return`On schedule ${e.trim()}`}}function se(e){return e.toLowerCase()==="github"?"GitHub":C(e)}function ae(e){return C(e.replace(/^\$/,""))}function oe(e){if(!e||typeof e!="object"||Array.isArray(e))return"";const t=e;return typeof t.repository=="string"?` in ${t.repository}`:typeof t.channel_id=="string"?` in #${t.channel_id}`:typeof t.resource_ref=="string"?` for ${t.resource_ref}`:""}function re(e){return Array.isArray(e.triggers)?e.triggers.filter(t=>!!t&&typeof t=="object"):[]}function ie(e){if(e.kind==="schedule"&&typeof e.cron=="string")return ne(e.cron);if(e.kind==="event"&&e.source!=="workspace"&&typeof e.connector_key=="string"){const t=Array.isArray(e.event_types)?e.event_types.filter(o=>typeof o=="string"):[],s=t.length>0?t.join(" or "):"an event";return`${se(e.connector_key)} sends ${s}${oe(e.match)}`}if(e.kind==="event"&&e.source==="workspace"){const t=Array.isArray(e.event_types)?e.event_types.filter(l=>typeof l=="string"):[],s=t.length>0?t.join(" or "):"an event",o=typeof e.entity_type=="string"?` on ${ae(e.entity_type)}`:"";return`another Automation writes ${s}${o}`}return null}function le(e){return e.health==="degraded"?"error":"enabled"}function ce(e){const t=re(e),s=e.name?.trim()||"Untitled automation",o=t.some(r=>r.kind==="event"),l=t.some(r=>r.kind==="schedule"),m=o?"event":l?"schedule":"manual",u=t.map(ie).filter(r=>!!r);let d="When started manually";u.length===1?d=`When ${u[0]}`:u.length>1&&(d=`When ${u[0]}${u.slice(1).map(r=>`, or when ${r}`).join("")}`);const i=t.some(r=>r.kind==="event"&&r.output==="reply_to_source")?"source":"silent";return{key:`automation:${e.automation_id}`,kind:m,when:d,does:s,output:{destination:i},state:le(e),sortTime:e.next_run_at?Date.parse(e.next_run_at):null,automation:e}}const y={event:0,schedule:1,manual:2};function ue(e){return e.map(ce).sort((t,s)=>t.state!==s.state?t.state==="enabled"?-1:1:y[t.kind]!==y[s.kind]?y[t.kind]-y[s.kind]:t.sortTime!==s.sortTime?t.sortTime===null?1:s.sortTime===null?-1:t.sortTime-s.sortTime:t.when.localeCompare(s.when)||t.key.localeCompare(s.key))}const de={kind:"all",output:"any",state:"any"};function me(e,t){return e.filter(s=>(t.kind==="all"||s.kind===t.kind)&&(t.output==="any"||(t.output==="reply"?s.output.destination==="source":s.output.destination==="silent"))&&(t.state==="any"||(t.state==="active"?s.state==="enabled":s.state==="error")))}const w="bg-muted text-muted-foreground",fe={event:{label:"Event",icon:O},schedule:{label:"Schedule",icon:B},manual:{label:"Manual",icon:P}};function he({agentName:e,deviceLabel:t}){const s=t?{label:t,icon:F}:e?{label:e,icon:K}:{label:"Manual · any client",icon:H},{label:o,icon:l}=s;return n.jsxs(v,{variant:"secondary",className:w,children:[n.jsx(l,{className:"h-3 w-3"}),o]})}function xe({lastRunAt:e,nextRunAt:t}){const s=e?`Ran ${A(e)}`:t?`Next run ${A(t)}`:"Never run";return n.jsxs(v,{variant:"secondary",className:w,children:[n.jsx(G,{className:"h-3 w-3"}),s]})}function pe({count:e}){return e<=0?null:n.jsxs(v,{variant:"secondary",className:w,children:[n.jsx(Q,{className:"h-3 w-3"}),e," ",e===1?"client":"clients"]})}function ye(e){const t=Array.isArray(e.triggers)?e.triggers:[];for(const s of t)if(s&&typeof s=="object"&&s.kind==="event"&&s.source!=="workspace"&&typeof s.connector_key=="string")return s.connector_key;return null}function ve(e,t){return`flex items-center gap-3 px-3 py-2.5 text-left transition-colors hover:bg-accent/50 ${e===t-1?"":"border-b"}`}function ge({automation:e,agentName:t,deviceLabel:s,connectorDisplay:o,owner:l,onRemove:m,removing:u,rowClass:d}){const i=e.automation,r=i.automation_id,g=fe[e.kind],b=i.entity_name&&i.entity_type?`${i.entity_name} · ${i.entity_type}`:null,f=[e.when,b].filter(Boolean).join(" — "),h=i.health==="degraded"?i.health_reasons?.[0]||"Needs attention":null;return n.jsxs("div",{className:d,children:[n.jsxs(j,{to:"/$owner/automations/$automationId",params:{owner:l,automationId:r},search:{view:"activity",run_id:void 0},className:"flex min-w-0 flex-1 items-center gap-3",children:[o?n.jsx(W,{icon:o.icon,iconUrl:o.iconUrl,name:o.name,faviconDomain:o.faviconDomain,className:"h-7 w-7 shrink-0 rounded-md text-[10px]"}):n.jsx("span",{className:"flex h-7 w-7 shrink-0 items-center justify-center rounded-md border",children:n.jsx(g.icon,{className:"h-3.5 w-3.5 text-muted-foreground"})}),n.jsxs("div",{className:"min-w-0 flex-1",children:[n.jsxs("div",{className:"flex flex-wrap items-center gap-2",children:[n.jsx("span",{className:"truncate text-sm font-medium",children:e.does}),n.jsx(he,{agentName:t,deviceLabel:s}),n.jsx(xe,{lastRunAt:i.last_run_completed_at??i.last_fired_at??null,nextRunAt:i.next_run_at??null}),n.jsx(pe,{count:i.processing_client_count??0}),h?n.jsxs(v,{variant:"secondary",className:"max-w-full whitespace-normal bg-amber-500/10 text-left text-amber-700 dark:text-amber-400",children:[n.jsx(z,{className:"h-3 w-3 shrink-0"}),h]}):null]}),f?n.jsx("p",{className:"truncate text-xs text-muted-foreground",children:f}):null]})]}),n.jsx(j,{to:"/$owner/automations/$automationId",params:{owner:l,automationId:r},search:{view:"definition",run_id:void 0},className:"inline-flex h-8 w-8 shrink-0 items-center justify-center rounded-md text-muted-foreground transition-colors hover:bg-accent/50 hover:text-foreground","aria-label":"Edit",children:n.jsx(U,{className:"h-3.5 w-3.5"})}),n.jsx(te,{pending:u,onConfirm:m})]})}function be({owner:e,organizationId:t,isWorkspaceLoading:s}){const[o,l]=x.useState(de),m=J(t??void 0),{data:u=[]}=S({enabled:!!t}),{data:d=[]}=L(),{data:i=[]}=E(t),r=V(),g=x.useMemo(()=>{const a=new Map;for(const c of u)a.set(c.agentId,c.name);return a},[u]),b=x.useMemo(()=>{const a=new Map;for(const c of d)a.set(c.id,c.label||c.platform||c.id);return a},[d]),f=x.useMemo(()=>ue(m.data??[]),[m.data]),h=x.useMemo(()=>me(f,o),[f,o]),$=s||m.isLoading,k=n.jsx(p,{asChild:!0,size:"sm",className:"h-8 shrink-0 text-xs",children:n.jsxs(j,{to:"/$owner/automations/new",params:{owner:e},children:[n.jsx(D,{className:"mr-1.5 h-3.5 w-3.5"}),"New automation"]})});return $?n.jsxs("div",{className:"space-y-4",children:[n.jsx("div",{className:"flex justify-end",children:k}),n.jsx(q,{label:"Loading automations",actions:!0})]}):n.jsxs("div",{className:"space-y-4",children:[n.jsx("p",{className:"text-sm text-muted-foreground",children:"What runs on its own — on a schedule, on an event, or when you ask."}),n.jsxs("div",{className:"flex flex-wrap items-center gap-x-3 gap-y-2",children:[n.jsx("div",{className:"flex min-w-0 flex-1 flex-wrap items-center gap-1.5",children:ee.map(a=>n.jsx(p,{type:"button",variant:o.kind===a.value?"secondary":"ghost","aria-pressed":o.kind===a.value,size:"sm",className:"h-7 px-2 text-xs",onClick:()=>l(c=>({...c,kind:a.value})),children:a.label},a.value))}),n.jsx("div",{className:"ml-auto shrink-0",children:k})]}),f.length===0?n.jsx(N,{icon:R,title:"No automations yet",description:"Automations act on their own — reply to a message, run a nightly summary, react to a ticket. Use New automation to create one."}):h.length===0?n.jsx(N,{icon:M.automations.icon,title:"No automations match this filter",description:"Try another trigger type.",secondaryActionLabel:"Show all",secondaryOnAction:()=>l(a=>({...a,kind:"all"}))}):n.jsx("div",{className:"overflow-hidden rounded-lg border",children:h.map((a,c)=>n.jsx(ge,{automation:a,agentName:a.automation.managed_agent_id?g.get(a.automation.managed_agent_id)??a.automation.managed_agent_id:null,deviceLabel:a.automation.device_worker_id?b.get(a.automation.device_worker_id)??a.automation.device_worker_id:null,connectorDisplay:(()=>{const _=ye(a.automation);return _?I(_,i):null})(),owner:e,rowClass:ve(c,h.length),removing:r.isPending,onRemove:()=>r.mutate(a.automation.automation_id)},a.key))})]})}function Ne(){const{owner:e}=X.useParams();return n.jsx("div",{className:"flex min-h-0 flex-1 flex-col gap-3 px-4 pt-2.5 pb-8 lg:px-6",children:n.jsx("div",{className:"flex min-h-0 min-w-0 flex-1 flex-col",children:n.jsx(Z,{owner:e,children:t=>n.jsx("div",{className:"mx-auto flex min-h-0 w-full min-w-0 max-w-3xl flex-1 flex-col",children:n.jsx(be,{owner:t.ownerSlug,organizationId:t.organizationId,isWorkspaceLoading:t.isWorkspaceLoading})})})})})}export{Ne as component};
|
|
2
|
+
//# sourceMappingURL=index-DijuudSs.js.map
|