@lobu/runtime-server 24.9.0 → 24.10.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/catalogs/automations.json +2 -2
- package/dist/catalogs/connectors.json +16 -4
- package/dist/catalogs/skills.json +1 -1
- package/dist/component.json +1 -1
- package/dist/connectors/postgres.ts +39 -24
- package/dist/connectors/whatsapp-web-adapter.js +41 -10
- package/dist/connectors/whatsapp-web-helpers.ts +12 -2
- package/dist/connectors/whatsapp_web.ts +18 -2
- package/dist/db/migrations/20261112210000_instance_identity.sql +18 -0
- package/dist/dependencies.bun.lock +62 -60
- package/dist/embeddings-server.mjs +38 -5
- package/dist/owletto/dist/assets/_-CYvj1y65.js +3 -0
- package/dist/owletto/dist/assets/_-CeLTSYYY.js +2 -0
- package/dist/owletto/dist/assets/_agentId-BB5E-L6T.js +2 -0
- package/dist/owletto/dist/assets/{_agentId-bna2tPsW.js → _agentId-DN0EwMAC.js} +2 -2
- package/dist/owletto/dist/assets/_automationId-DvUl9CSd.js +2 -0
- package/dist/owletto/dist/assets/_connectorKey._connectionId-CVKfL9AG.js +2 -0
- package/dist/owletto/dist/assets/_connectorKey.index-Cv6FzK1v.js +2 -0
- package/dist/owletto/dist/assets/{_conversationId-zcs-S3dY.js → _conversationId-CPpNySjO.js} +2 -2
- package/dist/owletto/dist/assets/_eventId-DZKicuq6.js +2 -0
- package/dist/owletto/dist/assets/_owner-Dauk3YuD.js +3 -0
- package/dist/owletto/dist/assets/_shape-cKrEID3T.js +2 -0
- package/dist/owletto/dist/assets/_slug-DJx_8fsV.js +2 -0
- package/dist/owletto/dist/assets/_viewKey-CPVzVKEf.js +2 -0
- package/dist/owletto/dist/assets/_viewKey-CW8gexOQ.js +2 -0
- package/dist/owletto/dist/assets/accept-invitation-Dwq1GAnG.js +2 -0
- package/dist/owletto/dist/assets/activity-route-location-C1jcXC7v.js +2 -0
- package/dist/owletto/dist/assets/activity-route-view-D78Wj0RH.js +2 -0
- package/dist/owletto/dist/assets/agent-connect-pages-DoI9UR0a.js +4 -0
- package/dist/owletto/dist/assets/{agent-editor-form-Bnc_q5WD.js → agent-editor-form-DlavYg2q.js} +2 -2
- package/dist/owletto/dist/assets/{agent-loading-shells-xteN-pyK.js → agent-loading-shells-DYqQphN7.js} +2 -2
- package/dist/owletto/dist/assets/agent-permissions-matrix-C1L8IcYR.js +2 -0
- package/dist/owletto/dist/assets/{agent-skill-context-r0O0BVOu.js → agent-skill-context-D1nMrVod.js} +2 -2
- package/dist/owletto/dist/assets/{agent-subpage-shell-C2KpYdu3.js → agent-subpage-shell-2w7vTeXw.js} +2 -2
- package/dist/owletto/dist/assets/{agent-thread-Bv_chdPy.js → agent-thread-BopD-2k1.js} +3 -3
- package/dist/owletto/dist/assets/{app._appId-BUcNaSMS.js → app._appId-BXeFXW1w.js} +2 -2
- package/dist/owletto/dist/assets/{assist-composer-B1LykXpD.js → assist-composer-CL5x8pNt.js} +2 -2
- package/dist/owletto/dist/assets/automation-run-now-MtxUTfzd.js +2 -0
- package/dist/owletto/dist/assets/{callback-kSLa4n5s.js → callback-BgfwP1Eo.js} +2 -2
- package/dist/owletto/dist/assets/{card-C01y1O-W.js → card-DtLIFq7D.js} +2 -2
- package/dist/owletto/dist/assets/{claim-Dnux9Lqf.js → claim-CT3hYVMF.js} +2 -2
- package/dist/owletto/dist/assets/{client-activity-scopes-BBIq16tG.js → client-activity-scopes-BPbRX-Pe.js} +2 -2
- package/dist/owletto/dist/assets/{client-rows-DGh1O-Fu.js → client-rows-vrNA6FLs.js} +2 -2
- package/dist/owletto/dist/assets/clients-xnzZeEdZ.js +2 -0
- package/dist/owletto/dist/assets/{code-editor-BdRMYojw.js → code-editor-mrKkAfcE.js} +2 -2
- package/dist/owletto/dist/assets/connect-NUCSay8X.js +2 -0
- package/dist/owletto/dist/assets/{connect-menu-D4w-JhJW.js → connect-menu-C6iVtuSo.js} +2 -2
- package/dist/owletto/dist/assets/connect._clientId-Cp-d9Q5b.js +2 -0
- package/dist/owletto/dist/assets/{connected._clientId-BsDzltNz.js → connected._clientId-ROfVgp9h.js} +2 -2
- package/dist/owletto/dist/assets/connection-BMz740Wi.js +2 -0
- package/dist/owletto/dist/assets/{connection-feed-detail-CJju0qiw.js → connection-feed-detail-0VAJiZTP.js} +2 -2
- package/dist/owletto/dist/assets/connector-page-shell-BFv21yuv.js +2 -0
- package/dist/owletto/dist/assets/{connector-provenance-B2C2cjBg.js → connector-provenance-b59RfBtk.js} +2 -2
- package/dist/owletto/dist/assets/connectors-nYS31lO2.js +2 -0
- package/dist/owletto/dist/assets/consent-cPRF9JQv.js +2 -0
- package/dist/owletto/dist/assets/{copy-button-BhXeXLIm.js → copy-button-C3wMMv63.js} +2 -2
- package/dist/owletto/dist/assets/{core.esm-CJUp2aNZ.js → core.esm-C9QlSrgK.js} +3 -3
- package/dist/owletto/dist/assets/{create-DUlRsFNn.js → create-ASRN3Obq.js} +2 -2
- package/dist/owletto/dist/assets/create-CBcodaSO.js +2 -0
- package/dist/owletto/dist/assets/create-CGOWfMk4.js +2 -0
- package/dist/owletto/dist/assets/{create-automation-form-D141prEG.js → create-automation-form-CLicoPH5.js} +3 -3
- package/dist/owletto/dist/assets/create._connectorKey-s4xkktTC.js +2 -0
- package/dist/owletto/dist/assets/{custom-guardrail-edits-DuQ28xv3.js → custom-guardrail-edits-BUL7nmuO.js} +2 -2
- package/dist/owletto/dist/assets/{definition-comparison-BUDNuAN_.js → definition-comparison-4UYMI6BK.js} +2 -2
- package/dist/owletto/dist/assets/{detail-page-skeleton-BRHaq5Sj.js → detail-page-skeleton-C8v3rJXK.js} +2 -2
- package/dist/owletto/dist/assets/device-BBwsOi7q.js +2 -0
- package/dist/owletto/dist/assets/{device-pin-tombstone-BIM-ziCH.js → device-pin-tombstone-Bcpe7nAA.js} +2 -2
- package/dist/owletto/dist/assets/{device._deviceId-BnPqTgK1.js → device._deviceId-DLT4jh0Z.js} +2 -2
- package/dist/owletto/dist/assets/{dynamic-schema-form-OkIZImgp.js → dynamic-schema-form-BDT8x0Vg.js} +2 -2
- package/dist/owletto/dist/assets/{entity-options-CpeX7iiX.js → entity-options-B9hm9V87.js} +2 -2
- package/dist/owletto/dist/assets/entity-page-DZjzQ2V4.js +2 -0
- package/dist/owletto/dist/assets/entity-pages-BWBpttz3.js +2 -0
- package/dist/owletto/dist/assets/entity-schema-graph-lMMx3HhR.js +2 -0
- package/dist/owletto/dist/assets/{entity-type-page-MgZ7_0oh.js → entity-type-page-CkQm0yEu.js} +2 -2
- package/dist/owletto/dist/assets/{event-detail-D6AH6a2C.js → event-detail-CkzfakTK.js} +2 -2
- package/dist/owletto/dist/assets/events-feed-DmRzikZW.js +2 -0
- package/dist/owletto/dist/assets/{filter-editors-DDTwyYt0.js → filter-editors-CQoSj-20.js} +3 -3
- package/dist/owletto/dist/assets/{full-page-spinner-DWo519BU.js → full-page-spinner-CYyCnKve.js} +2 -2
- package/dist/owletto/dist/assets/index-BE7eb2kE.js +2 -0
- package/dist/owletto/dist/assets/index-BFR0uiKY.js +2 -0
- package/dist/owletto/dist/assets/{index-Cd8jMsz8.js → index-BS5Ty3tf.js} +2 -2
- package/dist/owletto/dist/assets/index-C38OzBpB.js +2 -0
- package/dist/owletto/dist/assets/{index-D1UCJQl1.js → index-C3hz9tzx.js} +2 -2
- package/dist/owletto/dist/assets/index-CDyFQ32o.js +2 -0
- package/dist/owletto/dist/assets/{index-BW7IFKXC.js → index-CUndAH6o.js} +2 -2
- package/dist/owletto/dist/assets/index-CiKysEhV.js +2 -0
- package/dist/owletto/dist/assets/{index-CdDNNAx2.js → index-DByaMzsG.js} +274 -274
- package/dist/owletto/dist/assets/index-DfdinB7B.js +2 -0
- package/dist/owletto/dist/assets/index-DgMM4Zt5.css +1 -0
- package/dist/owletto/dist/assets/index-Xk711gVC.js +2 -0
- package/dist/owletto/dist/assets/{index-DmqnKGqW.js → index-ittfA0k8.js} +2 -2
- package/dist/owletto/dist/assets/{json-diff-C-WQqyIf.js → json-diff-mcDgyct_.js} +2 -2
- package/dist/owletto/dist/assets/{list-skeleton-0B1bTrAK.js → list-skeleton-DsYGUHxi.js} +2 -2
- package/dist/owletto/dist/assets/login-EoLq136v.js +2 -0
- package/dist/owletto/dist/assets/{logout-D474YsYQ.js → logout-gLgEQOiX.js} +2 -2
- package/dist/owletto/dist/assets/{member-scope-gate-CH_0jHiM.js → member-scope-gate-vvkgSAb2.js} +2 -2
- package/dist/owletto/dist/assets/memory-browse-page-DvDtwrEI.js +74 -0
- package/dist/owletto/dist/assets/{model-selector-XYmk7Iru.js → model-selector-D3vSMLO2.js} +2 -2
- package/dist/owletto/dist/assets/{needs-you-list-Bd4iiiqm.js → needs-you-list-B5Bgd05M.js} +2 -2
- package/dist/owletto/dist/assets/{new-CJ6TF3Vc.js → new-BPW3V0Y1.js} +2 -2
- package/dist/owletto/dist/assets/new-Bk_flKQO.js +2 -0
- package/dist/owletto/dist/assets/new-C5HtQdM_.js +2 -0
- package/dist/owletto/dist/assets/new-dLXsCHBd.js +2 -0
- package/dist/owletto/dist/assets/organization-DBfgBkzq.js +2 -0
- package/dist/owletto/dist/assets/{peek-pane-content-Cc8YX1oy.js → peek-pane-content-c2PG3TEX.js} +2 -2
- package/dist/owletto/dist/assets/{pending-seed-D7-ld7as.js → pending-seed-CBhx2Ql-.js} +2 -2
- package/dist/owletto/dist/assets/{proposal-review-shell-BWRJidwb.js → proposal-review-shell-B-jYcKfB.js} +2 -2
- package/dist/owletto/dist/assets/public-shell-ready-D8TijlRY.js +2 -0
- package/dist/owletto/dist/assets/record-activity-DnRVOrG2.js +2 -0
- package/dist/owletto/dist/assets/{record-session-ClKBr1_C.js → record-session-CAmGHMyM.js} +2 -2
- package/dist/owletto/dist/assets/{renderer-DZ0w2k2r.js → renderer-olRv_HMI.js} +3 -3
- package/dist/owletto/dist/assets/reset-password-B9_xi8Pq.js +2 -0
- package/dist/owletto/dist/assets/{run-initiator-B8IRlRd-.js → run-initiator-DhE5v4z0.js} +2 -2
- package/dist/owletto/dist/assets/runs-C8sZQr4o.js +2 -0
- package/dist/owletto/dist/assets/{runs-list-8gUPWjP4.js → runs-list-CwtH-wmk.js} +2 -2
- package/dist/owletto/dist/assets/{schema-value-k19Ata7u.js → schema-value-zTJGE4eh.js} +3 -3
- package/dist/owletto/dist/assets/{scoped-feed-bar-L7h-Ca4u.js → scoped-feed-bar-BKyJSa3_.js} +2 -2
- package/dist/owletto/dist/assets/{settings-BZqntV3E.js → settings-z02cvVS3.js} +2 -2
- package/dist/owletto/dist/assets/source-record-panels-CGmKIJdN.js +2 -0
- package/dist/owletto/dist/assets/{status-variants-BR_iGWN5.js → status-variants-DyRCXBzM.js} +2 -2
- package/dist/owletto/dist/assets/subDays-D8nHthaS.js +2 -0
- package/dist/owletto/dist/assets/{table-C3DMoL4K.js → table-C637cQxG.js} +2 -2
- package/dist/owletto/dist/assets/use-automations-CgWNoYio.js +2 -0
- package/dist/owletto/dist/assets/use-login-redirect-tDdhXTpt.js +2 -0
- package/dist/owletto/dist/assets/{use-mention-search-CtbixPEE.js → use-mention-search-D-kIKchD.js} +2 -2
- package/dist/owletto/dist/assets/view-param-filters-CUCj9Df-.js +2 -0
- package/dist/owletto/dist/assets/{views-access-required-CvIIxdS_.js → views-access-required-C35Dyt91.js} +2 -2
- package/dist/owletto/dist/index.html +2 -2
- package/dist/server-main.bundle.mjs +2733 -1795
- package/npm-shrinkwrap.json +238 -221
- package/package.json +1 -1
- package/vendor/connector-sdk/dist/connector-types.d.ts +6 -0
- package/vendor/connector-sdk/dist/index.d.ts +1 -0
- package/vendor/connector-sdk/dist/index.js +1 -0
- package/vendor/connector-sdk/dist/ip-reachability.d.ts +1 -1
- package/vendor/connector-sdk/dist/ip-reachability.js +1 -1
- package/vendor/connector-sdk/dist/logger.d.ts +1 -1
- package/vendor/connector-sdk/dist/logger.js +1 -1
- package/vendor/connector-sdk/dist/reaction-client-types.d.ts +3 -1
- package/vendor/connector-sdk/dist/retry.d.ts +1 -1
- package/vendor/connector-sdk/dist/retry.js +1 -1
- package/vendor/connector-sdk/dist/source-withheld-error.d.ts +16 -0
- package/vendor/connector-sdk/dist/source-withheld-error.js +19 -0
- package/vendor/connector-sdk/package.json +1 -1
- package/vendor/core/dist/classify-error.d.ts +1 -1
- package/vendor/core/dist/classify-error.js +2 -2
- package/vendor/core/dist/contracts/tools/manage-automations.d.ts +28 -3
- package/vendor/core/dist/contracts/tools/manage-automations.js +27 -8
- package/vendor/core/dist/contracts/tools/manage-entity.d.ts +8 -0
- package/vendor/core/dist/contracts/tools/manage-entity.js +11 -3
- package/vendor/core/dist/contracts/tools/save-memory.d.ts +11 -1
- package/vendor/core/dist/contracts/tools/save-memory.js +25 -3
- package/vendor/core/dist/contracts/tools/search-memory.js +1 -1
- package/vendor/core/dist/credentials.d.ts +12 -0
- package/vendor/core/dist/credentials.js +1 -0
- package/vendor/core/dist/errors.js +2 -2
- package/vendor/core/dist/worker/auth.d.ts +5 -0
- package/vendor/core/dist/worker/auth.js +15 -4
- package/vendor/core/package.json +1 -1
- package/vendor/postgres/cf/src/connection.js +7 -2
- package/vendor/postgres/cjs/src/connection.js +7 -2
- package/vendor/postgres/src/connection.js +7 -2
- package/vendor/views/dist/native.d.ts +33 -1
- package/vendor/views/dist/native.js +3 -0
- package/vendor/views/package.json +1 -1
- package/dist/owletto/dist/assets/_-B2C9B2RM.js +0 -2
- package/dist/owletto/dist/assets/_-CjyiGzwB.js +0 -3
- package/dist/owletto/dist/assets/_agentId-DKHXGvS2.js +0 -2
- package/dist/owletto/dist/assets/_automationId-CowRFD4E.js +0 -2
- package/dist/owletto/dist/assets/_connectorKey._connectionId-dE6im18z.js +0 -2
- package/dist/owletto/dist/assets/_connectorKey.index-DqwSv8Zs.js +0 -2
- package/dist/owletto/dist/assets/_eventId-BVOVizs4.js +0 -2
- package/dist/owletto/dist/assets/_owner-DsvIC94q.js +0 -3
- package/dist/owletto/dist/assets/_shape-CWjpzcvv.js +0 -2
- package/dist/owletto/dist/assets/_slug-DuCxYsJk.js +0 -2
- package/dist/owletto/dist/assets/_viewKey-BqVeHB6Z.js +0 -2
- package/dist/owletto/dist/assets/_viewKey-DzyOCG5U.js +0 -2
- package/dist/owletto/dist/assets/accept-invitation-k1u3zBcn.js +0 -2
- package/dist/owletto/dist/assets/activity-route-view-jTBMW7a9.js +0 -2
- package/dist/owletto/dist/assets/agent-connect-pages-D3mVM_q4.js +0 -4
- package/dist/owletto/dist/assets/agent-permissions-matrix-C_ayr0pd.js +0 -2
- package/dist/owletto/dist/assets/automation-run-now-CjkJIkaZ.js +0 -2
- package/dist/owletto/dist/assets/clients-BCvjAJDT.js +0 -2
- package/dist/owletto/dist/assets/connect-DZeFSGIH.js +0 -2
- package/dist/owletto/dist/assets/connect._clientId-IZEMQJ64.js +0 -2
- package/dist/owletto/dist/assets/connection-C7glVpPE.js +0 -2
- package/dist/owletto/dist/assets/connector-page-shell-BeuyjiB2.js +0 -2
- package/dist/owletto/dist/assets/connectors-DSQ5AWPf.js +0 -2
- package/dist/owletto/dist/assets/consent-B6Aw_89N.js +0 -2
- package/dist/owletto/dist/assets/create-CWcza8NT.js +0 -2
- package/dist/owletto/dist/assets/create-bGOYifof.js +0 -2
- package/dist/owletto/dist/assets/create._connectorKey-Ds4tpwHP.js +0 -2
- package/dist/owletto/dist/assets/device-D3fzoIrM.js +0 -2
- package/dist/owletto/dist/assets/entity-page-Cjc8oXA2.js +0 -2
- package/dist/owletto/dist/assets/entity-pages-18xSANrS.js +0 -2
- package/dist/owletto/dist/assets/entity-schema-graph-uwZ-P0t8.js +0 -2
- package/dist/owletto/dist/assets/events-feed-BI7wNRUY.js +0 -2
- package/dist/owletto/dist/assets/index-9tTjJo_J.css +0 -1
- package/dist/owletto/dist/assets/index-BYcFrinP.js +0 -2
- package/dist/owletto/dist/assets/index-BhJsTy-C.js +0 -2
- package/dist/owletto/dist/assets/index-CEcsgXDj.js +0 -2
- package/dist/owletto/dist/assets/index-CPscKk2u.js +0 -2
- package/dist/owletto/dist/assets/index-CfJ2-EpK.js +0 -2
- package/dist/owletto/dist/assets/index-D5DM4g2w.js +0 -2
- package/dist/owletto/dist/assets/index-DznAbTOF.js +0 -2
- package/dist/owletto/dist/assets/login-CH7P2AyR.js +0 -2
- package/dist/owletto/dist/assets/memory-browse-page-Ba4aYavw.js +0 -74
- package/dist/owletto/dist/assets/new-BOsrRqp8.js +0 -2
- package/dist/owletto/dist/assets/new-DGPOjak2.js +0 -2
- package/dist/owletto/dist/assets/new-Q0XqiZq2.js +0 -2
- package/dist/owletto/dist/assets/organization-hD_Z6TSd.js +0 -2
- package/dist/owletto/dist/assets/public-shell-ready-CRyAZATw.js +0 -2
- package/dist/owletto/dist/assets/record-activity-9ux6SfCd.js +0 -2
- package/dist/owletto/dist/assets/reset-password-D2RfrEVZ.js +0 -2
- package/dist/owletto/dist/assets/runs-CuC7WMtd.js +0 -2
- package/dist/owletto/dist/assets/source-record-panels-C4UItfdk.js +0 -2
- package/dist/owletto/dist/assets/subDays-hOwerOLo.js +0 -2
- package/dist/owletto/dist/assets/use-automations-CdtiVLCv.js +0 -2
- package/dist/owletto/dist/assets/use-login-redirect-CYlVkAhE.js +0 -2
- package/dist/owletto/dist/assets/view-param-filters-BdN8OU35.js +0 -2
- /package/vendor/postgres/{.bun-tag-c81dacd34e959a7a → .bun-tag-652f2580b8090d71} +0 -0
|
@@ -1,2 +0,0 @@
|
|
|
1
|
-
import{G as k,j as e,L as P,en as $,r as p,ai as R,B as F,fy as C,ex as K,eY as q,ax as B,z as O,n as L,dA as I,m as Y,cq as H,hY as J,cs as z,f3 as Q,dM as W,bR as G,eP as V,hZ as U,h_ as X,ad as Z,i as ee,u as te}from"./index-CdDNNAx2.js";import{E as se}from"./event-detail-D6AH6a2C.js";import{a as ne,M as ie}from"./needs-you-list-Bd4iiiqm.js";import{S as re}from"./scoped-feed-bar-L7h-Ca4u.js";import{C as ae,A as oe}from"./create-automation-form-D141prEG.js";import{P as ue}from"./proposal-review-shell-BWRJidwb.js";import{u as A,a as ce,i as le}from"./runs-CuC7WMtd.js";import{E as de}from"./events-feed-BI7wNRUY.js";import{D as me,a as fe}from"./definition-comparison-BUDNuAN_.js";import{R as xe}from"./runs-list-8gUPWjP4.js";import{a as D,h as ge}from"./use-automations-CdtiVLCv.js";function w({automationId:t}){const{currentOwner:s}=k();return s?e.jsx(P,{to:"/$owner/events",params:{owner:s},search:$({semanticTypes:["change"],eventCategory:"config",resourceKind:"automation",resourceId:t}),className:"text-sm text-primary underline underline-offset-4",children:"View definition history in Events"}):null}const pe={workspace:!0},he=6,je=["name","title"],S=10;function j(t){return t==null?!1:typeof t=="string"?t.trim().length>0:Array.isArray(t)?t.some(j):typeof t=="object"?Object.values(t).some(j):!0}function ye(t){const s=t.split("_").join(" ").trim();return s.charAt(0).toUpperCase()+s.slice(1)}function _({value:t,depth:s=0}){if(!j(t))return null;if(typeof t!="object"||t==null)return e.jsx("span",{className:"break-words",children:String(t)});if(s>=he)return e.jsx("span",{className:"break-words text-muted-foreground",children:JSON.stringify(t).slice(0,200)});if(Array.isArray(t))return e.jsx("ul",{className:"space-y-1.5",children:t.filter(j).map((a,u)=>e.jsx("li",{className:"border-l-2 border-border pl-2",children:e.jsx(_,{value:a,depth:s+1})},u))});const n=t,r=je.find(a=>typeof n[a]=="string"&&j(n[a])),i=Object.entries(n).filter(([a,u])=>a!==r&&j(u));return e.jsxs("div",{className:"space-y-1",children:[r?e.jsx("p",{className:"font-medium text-foreground",children:String(n[r])}):null,i.length>0?e.jsx("dl",{className:"space-y-1",children:i.map(([a,u])=>e.jsxs("div",{children:[e.jsxs("dt",{className:"inline text-muted-foreground",children:[ye(a),":"," "]}),e.jsx("dd",{className:"inline",children:typeof u=="object"?e.jsx("div",{className:"mt-1",children:e.jsx(_,{value:u,depth:s+1})}):e.jsx(_,{value:u,depth:s+1})})]},a))}):null]})}function E({run:t}){const s=t.completed_at??t.created_at;return e.jsx("time",{dateTime:new Date(s).toISOString(),title:q(s),className:"text-xs text-muted-foreground",children:K(s)})}function b({rows:t}){return t.length===0?null:e.jsx("ul",{className:"divide-y overflow-hidden rounded-lg border",children:t.map(s=>e.jsx("li",{children:s.content},s.key))})}function Ne({owner:t,automationId:s,failedRows:n}){const r=p.useId(),i=A(pe,{runTypes:["automation"],automationIds:[s],status:"completed"},t),a=i.data?.pages.flatMap(d=>d.runs)??[],u=a.filter(d=>j(d.output)),c=a.length-u.length,[o,...m]=u,f=i.data?.pages.length??0,{hasNextPage:x,isFetching:l,fetchNextPage:h}=i;p.useEffect(()=>{!o&&x&&!l&&f<S&&h()},[o,x,l,f,h]);const y=i.hasNextPage?e.jsx("div",{className:"flex justify-center",children:i.isFetchingNextPage?e.jsx(R,{role:"status","aria-label":"Loading earlier runs",className:"text-muted-foreground"}):e.jsx(F,{variant:"link",size:"sm",className:"h-auto p-0 text-xs font-normal text-muted-foreground",disabled:i.isFetching,onClick:()=>void i.fetchNextPage(),children:"Show earlier runs"})}):null,N=o?[...m.map(d=>({key:String(d.id),occurredAt:d.completed_at??d.created_at,content:e.jsxs("div",{className:"space-y-1 px-3 py-2 text-xs",children:[e.jsx(E,{run:d}),e.jsx(_,{value:d.output})]})})),...n].sort((d,g)=>(C(g.occurredAt)??0)-(C(d.occurredAt)??0)):[];return i.isError?e.jsxs("div",{className:"space-y-6 py-6",children:[e.jsx("p",{role:"alert",className:"text-sm text-muted-foreground",children:"Couldn't load this Automation's runs."}),e.jsx(b,{rows:n})]}):i.isLoading||!o&&x&&f<S?null:o?e.jsxs("div",{className:"space-y-6",children:[e.jsxs("section",{"aria-label":"Latest result",className:"space-y-2",children:[e.jsxs("div",{className:"flex items-baseline gap-2",children:[e.jsx("h2",{className:"text-xs font-medium uppercase tracking-wide text-muted-foreground",children:"Latest result"}),e.jsx(E,{run:o})]}),e.jsx("div",{className:"text-sm",children:e.jsx(_,{value:o.output})})]}),N.length>0?e.jsxs("section",{"aria-labelledby":r,className:"space-y-2",children:[e.jsx("h2",{id:r,className:"text-xs font-medium uppercase tracking-wide text-muted-foreground",children:"Earlier results"}),e.jsx(b,{rows:N})]}):null,c>0?e.jsxs("p",{className:"text-xs text-muted-foreground",children:[c," other ",c===1?"run":"runs"," found nothing new."]}):null,y]}):e.jsxs("div",{className:"space-y-6 py-6",children:[e.jsx("p",{className:"text-sm text-muted-foreground",children:a.length===0?"This Automation hasn't run yet. Its results appear here, newest first.":`It ran ${a.length}${i.hasNextPage?"+":""} times without returning a result.`}),e.jsx(b,{rows:n}),y]})}function T(t){const{orgContext:s,hasOrgContext:n}=k(),{data:r,isLoading:i}=B(`/${t}`,s),{isAuthenticated:a}=O(),{isMember:u,isLoading:c}=L(),o=a&&u,m=r?.workspace,f=o?!n||i||c:i||c;return{organizationId:m?.id??"",isLoading:f}}function Be(t){return T(t)}const _e={workspace:!0};function M(t,s,n=!0){const r=n?_e:null,i=A(r,{runTypes:["automation"],automationIds:[s],status:"failed"},t),a=A(r,{runTypes:["automation"],automationIds:[s],status:"timeout"},t);return p.useMemo(()=>[...i.data?.pages[0]?.runs??[],...a.data?.pages[0]?.runs??[]].sort((u,c)=>Date.parse(c.created_at)-Date.parse(u.created_at)||c.id-u.id),[i.data,a.data])}function ve(t,s){const n=H(t),{decisions:r,notices:i}=p.useMemo(()=>{const c=n.attentionCards.filter(o=>o.automation_id===s);return{decisions:z(c),notices:c.filter(o=>!J(o)&&o.unread&&o.notification_id!=null)}},[n.attentionCards,s]);return{attention:n,decisions:r,notices:i,markRead:c=>{c.length>0&&n.markManyRead.mutateAsync(c)},unreadFor:c=>i.flatMap(o=>o.run_id!=null&&o.run_id===c.run_id||Q(o.href?.split(/[?#]/)[0]??"")?.eventId===Number(c.id)?[o.notification_id]:[])}}function be({owner:t,automationId:s,organizationId:n}){const r=Number(s),i=p.useMemo(()=>({producedByAutomationId:r}),[r]),{attention:a,decisions:u,notices:c,markRead:o,unreadFor:m}=ve(t,r),f=M(t,r);if(!Number.isFinite(r))return null;const x=f.map(l=>({key:`run:${l.id}`,occurredAt:l.completed_at??l.created_at,content:e.jsx(xe,{run:l,ownerSlug:t})}));return e.jsxs(e.Fragment,{children:[a.isError?e.jsx("p",{role:"alert",className:"mb-6 text-sm text-destructive",children:"Could not load notifications. Refresh to try again."}):u.length>0?e.jsxs("section",{"aria-label":"Needs you",className:"mb-6 space-y-2",children:[e.jsx("h2",{className:"px-1 text-sm font-semibold",children:"Needs you"}),e.jsx(ne,{owner:t,entries:u})]}):null,e.jsxs("div",{className:"mb-3 flex items-center gap-2",children:[e.jsx(re,{owner:t,organizationId:n||null,activitySearch:{produced_by:String(r)}}),e.jsx(ie,{entries:c.map(l=>({unreadIds:[l.notification_id]})),disabled:a.markManyRead.isPending,onMarkRead:o})]}),e.jsx(de,{organizationId:n,ownerSlug:t,filters:i,foldRunSatellites:!1,unreadNotices:m,onMarkRead:o,extraRows:x,renderLead:(l,{hasEarlier:h})=>e.jsxs("div",{className:"mb-4 space-y-6",children:[e.jsxs("section",{"aria-label":"Latest result",className:"space-y-2",children:[e.jsx("h2",{className:"text-xs font-medium uppercase tracking-wide text-muted-foreground",children:"Latest result"}),e.jsx(se,{owner:t,organizationId:n,eventId:l.id})]}),h?e.jsx("h2",{className:"text-xs font-medium uppercase tracking-wide text-muted-foreground",children:"Earlier results"}):null]}),emptyState:e.jsx(Ne,{owner:t,automationId:r,failedRows:x})})]})}function Ae({agentId:t,automationId:s,runId:n,organizationId:r,onDone:i}){const[a,u]=p.useState({ready:!1,triggers:[]}),c=p.useCallback(d=>{u(g=>JSON.stringify(g)===JSON.stringify(d)?g:d)},[]),o=D(s,void 0,r,{includeVersions:!0}),m=o.data?.automation,{currentOwner:f}=k(),x=I({queryKey:["automations-list",f,"editor",s,m?.status],enabled:!!f&&!!r&&!!m,queryFn:async()=>{const g=(await W("manage_automations",{action:"list",automation_id:s,status:m?.status,include_details:!0,limit:1},{slug:f})).automations.find(v=>v.automation_id===s);if(!g)throw new G("Automation not found",404);return g},staleTime:3e4}),l=x.data,h=p.useMemo(()=>m&&l?{automation_id:m.automation_id,name:l.name,slug:l.slug,description:l.description,prompt:l.prompt,sources:l.sources,reaction_script:m.reaction_script,managed_agent_id:l.managed_agent_id,device_worker_id:l.device_worker_id,agent_kind:l.agent_kind,delivery_target:l.delivery_target??void 0,execution_config:l.execution_config??void 0,model_config:l.model_config,tags:l.tags,keying_config:m.keying_config,reactions_guidance:l.reactions_guidance,triggers:l.triggers}:void 0,[m,l]),y=e.jsx("div",{className:"flex flex-col gap-4",children:[0,1,2].map(d=>e.jsx(Y,{className:"h-16 w-full rounded-lg"},d))}),N=x.isError?e.jsxs("div",{role:"alert",className:"space-y-2 text-sm",children:[e.jsx("p",{children:"Could not load the saved Automation definition."}),e.jsx("button",{type:"button",className:"text-primary underline underline-offset-4",onClick:()=>void x.refetch(),children:"Retry"})]}):o.isLoading||m&&x.isPending?y:h?e.jsx(ae,{organizationId:r,prefillAgentId:t??void 0,editingAutomation:h,createFields:{triggers:a.triggers},triggerFields:e.jsx(oe,{organizationId:r,initialTriggers:h.triggers??[],onChange:c},JSON.stringify(h.triggers??[])),hideHeader:!0,hideCancel:!0,submitDisabled:!a.ready,onClose:i}):e.jsx("p",{className:"text-sm text-muted-foreground",children:"Automation not found. It may have been removed."});return t?e.jsxs("div",{className:"space-y-6",children:[e.jsx(ue,{resource:{kind:"automation",agentId:t,automationId:s},runId:n,onDone:i,children:({reviewMode:d,proposal:g})=>d==="active"?e.jsx(me,{current:g?.current??null,proposed:{...g?.current??{},...g?.proposedAfter??{}},render:v=>e.jsx(fe,{value:v})}):d==="loading"?y:d==="error"?null:N}),e.jsx(w,{automationId:s})]}):e.jsxs("div",{className:"space-y-6",children:[N,e.jsx(w,{automationId:s})]})}function Ie({owner:t,agentId:s,automationId:n,view:r,runId:i,onDone:a}){const{organizationId:u}=T(t),c=D(n,void 0,u),o=s??c.data?.automation?.managed_agent_id??null;return i||r==="definition"?e.jsx(Ae,{agentId:o,automationId:n,runId:i,organizationId:u,onDone:a},`${t}/${n}`):e.jsx(be,{owner:t,automationId:n,organizationId:u})}function Ye(t,s,n,r=!0){const{isAuthenticated:i}=O(),{isMember:a}=L(),u=ge(),c=r&&i&&a&&n?.status==="active",o=c&&n?.schedule_auto_paused_at!=null,m=Number(s),[f]=M(t,m,o&&Number.isFinite(m));return{owner:t,automationId:s,canRun:c,paused:o,pending:u.isPending,run:()=>u.mutate(s),failures:n?.consecutive_scheduled_failures??0,scheduled:n?.triggers?.some(x=>x.kind==="schedule")??!1,external:["external","manual"].includes(V(n)),error:(f?.error_message??n?.last_scheduling_error)?.trim()||null,result:c?u.data:void 0}}function He({runNow:t}){return e.jsxs(e.Fragment,{children:[t.paused?e.jsx(Re,{failures:t.failures,error:t.error,scheduled:t.scheduled,external:t.external,action:e.jsx(ke,{variant:"default",pending:t.pending,onRun:t.run})}):null,t.result?e.jsx(Se,{owner:t.owner,automationId:t.automationId,result:t.result},t.result.run_id):null]})}function ke({pending:t,onRun:s,variant:n="ghost"}){return e.jsxs(F,{type:"button",variant:n,size:"sm",className:"h-8 gap-1.5",disabled:t,onClick:s,children:[t?e.jsx(R,{}):e.jsx(U,{className:"h-3.5 w-3.5","aria-hidden":!0}),t?"Starting...":"Run now"]})}function Re({failures:t,error:s,scheduled:n,external:r,action:i}){const a=r?`Run now resumes it right away${n?" and restarts its schedule":""}.`:"Run now retries it, and a successful run resumes it.";return e.jsxs("section",{"aria-label":"Automation paused",className:"flex flex-wrap items-start gap-3 rounded-lg bg-amber-500/10 px-3 py-2.5 text-sm",children:[e.jsx(X,{"aria-hidden":!0,className:"mt-0.5 h-4 w-4 shrink-0 text-amber-600 dark:text-amber-400"}),e.jsxs("div",{className:"min-w-0 flex-1 space-y-1",children:[e.jsxs("p",{className:"font-medium",children:["Automation paused after"," ",t===1?"a failed run":`${t} consecutive failed runs`]}),s?e.jsxs("p",{title:s,className:"line-clamp-3 whitespace-pre-wrap break-words text-muted-foreground",children:["Latest error: ",s]}):null,e.jsxs("p",{className:"text-muted-foreground",children:[a,n?" Changing its schedule also resumes it.":null]})]}),i]})}function Ce({owner:t,automationId:s,runId:n}){const r=te();return e.jsxs(P,{to:"/$owner/events",params:{owner:t},search:{run_ids:String(n)},className:"font-medium text-foreground underline-offset-4 hover:underline",onClick:i=>{!r||i.button!==0||i.metaKey||i.ctrlKey||i.shiftKey||i.altKey||(i.preventDefault(),r.open({href:`/${t}/automations/${s}?view=activity&run_id=${n}`,title:`Run #${n}`,runId:n}))},children:["Run #",n]})}function we(t,s){return t==="running"||t==="claimed"?"is running":t==="pending"?s==="external_client"?"is waiting for a connected client to pick it up":s==="device_worker"?"is waiting for its device":"is queued":t==="completed"?"completed":t==="timeout"?"timed out":t==="cancelled"?"was cancelled":t}function Se({owner:t,automationId:s,result:n}){const r=ce(t,n.run_id),i=r.data?.status??n.status,a=le(i),u=Z(),c=p.useRef(!1);p.useEffect(()=>{if(a){c.current=!0;return}if(c.current){c.current=!1;for(const f of["automation-detail","automations-list","runs-infinite"])u.invalidateQueries({queryKey:[f]})}},[a,u]);const o=a?null:r.data?.error_message?.trim(),m=i==="failed"||i==="timeout"||i==="cancelled";return e.jsxs("p",{role:"status",className:ee("flex items-center gap-1.5 text-sm",m?"text-destructive":"text-muted-foreground"),children:[a&&!r.isError?e.jsx(R,{className:"shrink-0"}):null,e.jsxs("span",{className:"min-w-0 break-words",children:[!n.created&&a?"Already in progress: ":null,e.jsx(Ce,{owner:t,automationId:s,runId:n.run_id})," ",we(i,n.execution.lane),o?`: ${o}`:"."]})]})}export{Ie as A,ke as R,He as a,Be as b,Ye as u};
|
|
2
|
-
//# sourceMappingURL=automation-run-now-CjkJIkaZ.js.map
|
|
@@ -1,2 +0,0 @@
|
|
|
1
|
-
import{dN as c,dA as u,ad as d,b$ as p,bz as r,aa as o,dO as i,$ as w}from"./index-CdDNNAx2.js";function l(t,s="",e){const a=`${w}/api/${t}/clients${s}`,n=e?.toString();return n?`${a}?${n}`:a}function h(t,s){const e=s?.ownerSlug??c().slug;return u({queryKey:["connected-clients",e,t??null],queryFn:async()=>{if(!e)throw new Error("Workspace required");const a=new URLSearchParams;t&&a.set("agentId",t);const n=await o(l(e,"",a),{credentials:"include"});return await i(n,"Failed to load connected clients"),(await n.json()).clients??[]},enabled:!!e&&(s?.enabled??!0),staleTime:15e3,refetchInterval:s?.refetchInterval})}function y(){const{slug:t}=c(),s=d();return p({mutationFn:async e=>{if(!t)throw new Error("Workspace required");const a=new URLSearchParams;e.scope==="all"&&a.set("scope","all");const n=await o(l(t,`/mcp/${encodeURIComponent(e.clientId)}`,a),{method:"DELETE",credentials:"include"});return await i(n,"Failed to revoke client"),await n.json()},onSuccess:()=>{s.invalidateQueries({queryKey:["connected-clients",t]}),r.success("App access revoked")},onError:e=>{r.error(e.message||"Failed to revoke app access")}})}export{y as a,h as u};
|
|
2
|
-
//# sourceMappingURL=clients-BCvjAJDT.js.map
|
|
@@ -1,2 +0,0 @@
|
|
|
1
|
-
import{jH as r,j as t,aT as a}from"./index-CdDNNAx2.js";import{a as s}from"./agent-connect-pages-D3mVM_q4.js";import"./connector-page-shell-BeuyjiB2.js";import"./copy-button-BhXeXLIm.js";import"./clients-BCvjAJDT.js";import"./client-rows-DGh1O-Fu.js";function x(){const{owner:e,clientId:o}=r.useParams();return t.jsx(a,{owner:e,children:({ownerSlug:n})=>t.jsx(s,{owner:n,clientId:o})})}export{x as component};
|
|
2
|
-
//# sourceMappingURL=connect._clientId-IZEMQJ64.js.map
|
|
@@ -1,2 +0,0 @@
|
|
|
1
|
-
import{bq as W,M as V,r as l,aa as z,$ as R,j as e,ai as N,B as f,br as q,bs as F,bt as M,bu as Y,bv as E,U as B,I as D,an as G,ac as K,ak as H,V as J}from"./index-CdDNNAx2.js";import{s as Q}from"./index-Cd8jMsz8.js";import{C as X,a as Z,b as ee,c as ne}from"./card-C01y1O-W.js";const C="__new_org__";function te(r){return r.trim().toLowerCase().replace(/[^a-z0-9]+/g,"-").replace(/^-+|-+$/g,"")}function w(r){return Q.find(i=>i.provider===r)?.name??r}function re(r,i){return`${window.location.origin}/connector/${encodeURIComponent(r)}/connection?${new URLSearchParams({ref:i})}`}function ie(r,i){return r==="account_already_linked_to_different_user"?`This ${i} account belongs to a different Lobu account than the one you are signed in to. Sign out, then continue with ${i} to finish setup as that account.`:`We couldn’t verify your ${i} account for this setup. Sign out, then continue with ${i} to try again.`}function oe(r,i){const[s,n]=l.useState({}),o=i?`${i}:${r}`:null;return l.useEffect(()=>{if(!o||!i||o in s)return;let c=!1;return D(i).then(h=>h.find(g=>g.key===r)?.name??null).catch(()=>null).then(h=>{c||n(g=>({...g,[o]:h}))}),()=>{c=!0}},[o,r,s,i]),o?s[o]??null:null}function I(r,i,s){if(!r)return"/";const n=`/${encodeURIComponent(r)}/`;if(s?.startsWith(n)){const o=new URL(s,window.location.origin);if(o.origin===window.location.origin&&o.pathname.startsWith(n))return o.pathname+o.search}return`${n}connectors/${encodeURIComponent(i)}?connected=1`}function se(r,i){return r==="not_admin"?`You must be an admin or owner to connect ${i} to Lobu.`:`You don't have permission to connect ${i} to Lobu.`}function T(r,i,s){switch(r){case"not_authorized":return se(i,s);case"no_pending":return`No Lobu install was found for ${s}. Add Lobu from the marketplace to get started.`;case"no_org":return`Your account has no Lobu organization to connect ${s} to.`;default:return`Something went wrong while connecting ${s}. Please try again.`}}function de(){const{name:r}=W({from:"/connector/$name/connection"}),{ref:i,error:s}=V({from:"/connector/$name/connection"}),[n,o]=l.useState({kind:"loading"}),[c,h]=l.useState(""),[g,O]=l.useState(""),[x,$]=l.useState(!1),[_,p]=l.useState(null),[j,k]=l.useState(null),u=oe(r,n.kind==="confirm"?n.orgs[0]?.slug??null:n.kind==="already_connected"?n.orgSlug:null),m=n.kind==="confirm"&&n.subjectKind||"connection",S=n.kind==="confirm"&&n.subjectName?n.subjectName:u?`this ${u} ${m}`:`this ${m}`,P=l.useCallback(async()=>{if(!i){o({kind:"error",message:"This connection link is missing its reference."});return}o({kind:"loading"});try{const t=await(await z(`${R}/api/connector/${encodeURIComponent(r)}/connection/claim-context?ref=${encodeURIComponent(i)}`,{credentials:"include"})).json();if("error"in t){if(t.error==="unauthenticated"){o({kind:"signin",signinProvider:t.signinProvider??r,linkAccount:!1});return}if(t.error==="signin_required"){o(s?{kind:"link_failed",signinProvider:t.signinProvider??r,error:s}:{kind:"signin",signinProvider:t.signinProvider??r,linkAccount:!0});return}o({kind:"error",message:T(t.error,t.code,"this connection")});return}if("alreadyConnected"in t){o({kind:"already_connected",orgSlug:t.orgSlug,nextUrl:t.nextUrl});return}h(t.orgs[0]?.slug??""),o({kind:"confirm",subjectKind:t.subjectKind,subjectName:t.subjectName,orgs:t.orgs})}catch{o({kind:"error",message:"We couldn’t load this connection link. Please try again."})}},[r,i,s]);l.useEffect(()=>{P()},[P]);const L=async d=>{if(!i)return;const t=re(r,i);if(n.kind==="signin"&&n.linkAccount){const y=await G.linkSocial({provider:d,callbackURL:t,errorCallbackURL:t});y.error&&o({kind:"error",message:y.error.message??"Couldn’t verify this account."});return}n.kind==="link_failed"&&await K(),await H.social({provider:d,callbackURL:t,errorCallbackURL:t})},U=async(d=!1)=>{if(!(!i||!c)){$(!0),p(null),k(null);try{let t=c;if(c===C){const b=g.trim();if(!b){p("Enter a name for the new organization.");return}const v=await J.create({name:b,slug:te(b)});if(v.error||!v.data){p(v.error?.message??"Couldn’t create the organization.");return}t=v.data.slug}const a=await(await z(`${R}/api/connector/${encodeURIComponent(r)}/connection/claim`,{method:"POST",headers:{"Content-Type":"application/json"},credentials:"include",body:JSON.stringify({ref:i,org:t,confirmMove:d})})).json();if("error"in a){if(a.error==="signin_required"||a.error==="unauthenticated"){o({kind:"signin",signinProvider:a.signinProvider??r,linkAccount:a.error==="signin_required"});return}if((a.error==="already_connected_elsewhere"||a.error==="enterprise_scope_overlap")&&a.existing){k({kind:a.error,existing:a.existing});return}p(T(a.error,a.code,S));return}window.location.href=I(a.orgSlug,r,a.nextUrl)}catch{p(`Something went wrong while connecting this ${m}. Please try again.`)}finally{$(!1)}}},A=n.kind==="signin"?"Sign in to continue":n.kind==="link_failed"?"Use a different account":n.kind==="error"?`Can’t connect this ${m}`:n.kind==="already_connected"?"Already connected":u?`Connect ${u} to Lobu`:"Connect to Lobu";return e.jsx("div",{className:"min-h-[calc(100vh-3.5rem)] flex items-center justify-center",children:e.jsx("div",{className:"w-full max-w-md p-8",children:e.jsxs(X,{children:[e.jsx(Z,{children:e.jsx(ee,{asChild:!0,children:e.jsx("h1",{children:A})})}),e.jsxs(ne,{children:[n.kind==="loading"&&e.jsxs("div",{className:"flex items-center justify-center gap-2 py-6 text-sm text-muted-foreground",children:[e.jsx(N,{size:"lg"}),e.jsx("span",{children:"Checking this connection link…"})]}),n.kind==="error"&&e.jsx("div",{className:"rounded-lg bg-destructive/10 px-3 py-2 text-sm text-destructive",children:n.message}),n.kind==="already_connected"&&e.jsxs("div",{className:"space-y-4",children:[e.jsxs("p",{className:"text-sm text-muted-foreground",children:["This ",u?`${u} `:"",m," is already connected to Lobu."]}),e.jsx(f,{className:"w-full",asChild:!0,children:e.jsx("a",{href:I(n.orgSlug,r,n.nextUrl),children:n.nextUrl?"Choose an agent":"Open Lobu"})})]}),n.kind==="signin"&&e.jsxs("div",{className:"space-y-4",children:[e.jsxs("p",{className:"text-sm text-muted-foreground",children:["Sign in with ",w(n.signinProvider)," to verify you can connect this ",m,"."]}),e.jsxs(f,{className:"w-full",onClick:()=>L(n.signinProvider),children:["Sign in with ",w(n.signinProvider)]})]}),n.kind==="link_failed"&&e.jsxs("div",{className:"space-y-4",children:[e.jsx("div",{role:"alert",className:"rounded-lg bg-destructive/10 px-3 py-2 text-sm text-destructive",children:ie(n.error,w(n.signinProvider))}),e.jsxs(f,{className:"w-full",onClick:()=>L(n.signinProvider),children:["Sign out and continue with"," ",w(n.signinProvider)]})]}),n.kind==="confirm"&&(()=>{const d=n.subjectName||S;return e.jsxs("div",{className:"space-y-4",children:[e.jsxs("p",{className:"text-sm text-muted-foreground",children:["Connecting"," ",e.jsx("strong",{className:"font-medium text-foreground",children:d}),". Choose the organization to connect it to:"]}),e.jsxs(q,{value:c,onValueChange:t=>{k(null),h(t)},children:[e.jsx(F,{children:e.jsx(M,{placeholder:"Select an organization"})}),e.jsxs(Y,{children:[n.orgs.map(t=>e.jsxs(E,{value:t.slug,children:[t.name,t.isPersonal&&e.jsx("span",{className:"ml-1 text-muted-foreground",children:"(personal)"})]},t.id)),e.jsx(E,{value:C,children:"+ New organization"})]})]}),c===C&&e.jsx(B,{autoFocus:!0,value:g,onChange:t=>O(t.target.value),placeholder:"New organization name","aria-label":"New organization name"}),_&&e.jsx("div",{className:"rounded-lg bg-destructive/10 px-3 py-2 text-sm text-destructive",children:_}),j&&(()=>{const t=j.existing.orgName??j.existing.orgSlug??"another organization";return j.kind==="already_connected_elsewhere"?e.jsxs("div",{className:"space-y-3 rounded-lg border border-border bg-muted/40 px-3 py-3",children:[e.jsxs("p",{className:"text-sm text-foreground",children:[d," is already connected in"," ",e.jsx("strong",{className:"font-medium",children:t}),". Move it here?"]}),e.jsxs("div",{className:"flex gap-2",children:[e.jsx(f,{className:"flex-1",onClick:()=>U(!0),disabled:x,children:x?e.jsxs(e.Fragment,{children:[e.jsx(N,{size:"lg"}),e.jsx("span",{className:"ml-2",children:"Moving…"})]}):"Move it here"}),e.jsx(f,{className:"flex-1",variant:"outline",onClick:()=>k(null),disabled:x,children:"Cancel"})]})]}):e.jsxs("div",{className:"rounded-lg bg-destructive/10 px-3 py-2 text-sm text-destructive",children:["This ",u?`${u} `:"","Enterprise Grid is already connected in"," ",e.jsx("strong",{className:"font-medium",children:t}),"; ","connecting this ",m," here may change how its messages route. Contact support to move it."]})})(),e.jsx(f,{className:"w-full",onClick:()=>U(),disabled:x||j!==null||!c||c===C&&!g.trim(),children:x?e.jsxs(e.Fragment,{children:[e.jsx(N,{size:"lg"}),e.jsx("span",{className:"ml-2",children:"Connecting…"})]}):`Connect ${d}`})]})})()]})]})})})}export{de as component};
|
|
2
|
-
//# sourceMappingURL=connection-C7glVpPE.js.map
|
|
@@ -1,2 +0,0 @@
|
|
|
1
|
-
import{j as s,as as l}from"./index-CdDNNAx2.js";function c({header:e,children:a}){return s.jsxs(l,{className:"flex min-h-0 min-w-0 flex-1 flex-col",children:[s.jsx("div",{className:"sticky top-0 z-10 space-y-4 bg-background pb-1",children:e}),s.jsx("div",{className:"mt-4 min-w-0 flex-1 space-y-7",children:a})]})}export{c as C};
|
|
2
|
-
//# sourceMappingURL=connector-page-shell-BeuyjiB2.js.map
|
|
@@ -1,2 +0,0 @@
|
|
|
1
|
-
import{j as e,ar as s,O as a}from"./index-CdDNNAx2.js";function t(){return e.jsx(s,{className:"gap-3 pt-2.5 pb-8",children:e.jsx("div",{className:"flex min-h-0 min-w-0 flex-1 flex-col",children:e.jsx(a,{})})})}export{t as component};
|
|
2
|
-
//# sourceMappingURL=connectors-DSQ5AWPf.js.map
|
|
@@ -1,2 +0,0 @@
|
|
|
1
|
-
import{a0 as U,z as W,r as i,j as t,$ as D,a1 as F}from"./index-CdDNNAx2.js";import{a as I,u as T,C as G,b as B,c as J,R as Q,W as H,A as K,r as V,o as X}from"./use-login-redirect-CYlVkAhE.js";import{F as Y}from"./full-page-spinner-DWo519BU.js";import"./card-C01y1O-W.js";const Z=["client_id","redirect_uri","scope","code_challenge","code_challenge_method"];function re(){const e=U.useSearch(),d=e.workspace_grants==="1",{session:g,isReady:k}=W(),m=!k,[r,_]=i.useState(null),[v,l]=i.useState(null);I(!!g,m);const p=i.useMemo(()=>Z.filter(s=>!e[s]||e[s]?.length===0),[e]),c=p.length===0,C=e.client_name?.trim()||null,f=i.useMemo(()=>Array.from(new Set((e.scope||"").split(" ").map(s=>s.trim()).filter(Boolean))),[e.scope]),{accessLevel:w,setAccessLevel:O,selectedScopes:A,resourceOrg:S,hasMcpScopes:E,requiresWorkspaceAccess:n,orgList:h,workspaceAccess:L,setWorkspaceAccess:M,selectedOrgIds:o,toggleSelectedOrgId:P,orgsLoading:q,orgsError:b,retryOrgs:N,workspaceSelectionReady:y}=T({requestedScopes:f,resource:e.resource,allowMultiple:d}),u=i.useMemo(()=>h.filter(s=>o.includes(s.id)).map(s=>s.name),[h,o]),$=n?u.length===0?"Nothing will be granted access.":`${u.length<=2?u.join(", "):`${u.length} workspaces`} will be granted access.`:null,z=n&&d&&o.length>0?`Approve ${o.length} ${o.length===1?"workspace":"workspaces"}`:"Approve",R=async s=>{if(!c){l(`Missing required query params: ${p.join(", ")}`);return}if(s&&n&&!y){l(b?"Workspaces could not be loaded. Retry before approving.":"Choose at least one workspace before approving.");return}_(s?"approve":"deny"),l(null);try{const a=await fetch(`${D}/oauth/authorize/consent`,{method:"POST",headers:{"Content-Type":"application/json"},credentials:"include",body:JSON.stringify({client_id:e.client_id,redirect_uri:e.redirect_uri,scope:s?A.join(" "):e.scope,state:e.state??"",code_challenge:e.code_challenge,code_challenge_method:e.code_challenge_method,client_name:e.client_name,resource:e.resource,authorization_intent:e.authorization_intent,approved:s,...s&&n?{workspace_access:L,organization_ids:o}:{}})}),x=await a.json().catch(()=>null);if(a.status===401){V();return}if(!a.ok)throw new Error(X(x,`Failed to ${s?"approve":"deny"} OAuth consent`));const j=F(x?.redirect_url);if(!j)throw new Error("Consent response did not include a valid redirect URL");window.location.href=j}catch(a){_(null),l(a instanceof Error?a.message:"Unexpected error while submitting consent")}};return m||!g?t.jsx(Y,{className:"min-h-[calc(100vh-3.5rem)]"}):t.jsx(G,{title:"Authorize application",busy:r!==null,error:v,review:t.jsx(K,{idPrefix:"oauth-consent",clientName:C,requestedScopes:f,accessLevel:w,onAccessLevelChange:O,disabled:r!==null,resource:e.resource,logoUri:e.logo_uri,clientUri:e.client_uri}),aside:n?t.jsx(H,{idPrefix:"oauth-consent",allowMultiple:d,orgList:h,selectedOrgIds:o,onWorkspaceAccessChange:M,onSelectedOrgChange:P,orgsLoading:q,orgsError:b,onRetry:N,disabled:r!==null||!c}):void 0,below:E&&S?t.jsx(Q,{resourceOrg:S,accessLevel:w}):null,notice:c?null:t.jsxs("p",{role:"alert",className:"text-sm text-destructive",children:["Missing required query params: ",p.join(", ")]}),footer:t.jsx(B,{summary:$,children:t.jsx(J,{busy:r,approveLabel:z,approveDisabled:r!==null||!c||A.length===0||n&&!y,denyDisabled:r!==null||!c,onApprove:()=>R(!0),onDeny:()=>R(!1)})})})}export{re as component};
|
|
2
|
-
//# sourceMappingURL=consent-B6Aw_89N.js.map
|
|
@@ -1,2 +0,0 @@
|
|
|
1
|
-
import{c as x,hh as G,j1 as L,j2 as b,ia as y,j as t,dy as v,bz as r,jL as w}from"./index-CdDNNAx2.js";import{A as S,v as N,a as P}from"./custom-guardrail-edits-DuQ28xv3.js";import{A as $,a as F}from"./agent-subpage-shell-C2KpYdu3.js";import"./model-selector-XYmk7Iru.js";function R({owner:e,agentId:a}){const i=x(),{data:n,isLoading:c}=G(a),{data:m,isLoading:p}=L(a),{data:o=null,isLoading:f}=b(a),C=c||p||f,u=y(a),g=n?.guardrailsInline??[],j=(m??[]).map(s=>s.name),A=async s=>{if(!n){r.error("Still loading agent settings — try again in a moment");return}const d=N(s,g,j,o);if(d){r.error(d);return}try{await u.mutateAsync({guardrailsInline:P(g,s)}),r.success("Guardrail created"),i({to:"/$owner/agents/$agentId",params:{owner:e,agentId:a},hash:"guardrails"})}catch(l){r.error(l instanceof Error?l.message:"Failed to create guardrail")}},h=()=>void i({to:"/$owner/agents/$agentId",params:{owner:e,agentId:a},hash:"guardrails"});return t.jsxs("div",{className:"space-y-6",children:[t.jsx($,{title:"New custom guardrail",description:"A custom guardrail judges text at one stage against a policy you write."}),C?t.jsx(v,{rows:4}):t.jsx(S,{judgeModelDefault:o,submitLabel:"Create guardrail",submitting:u.isPending,onSubmit:A,onCancel:h})]})}function D({owner:e,agentId:a}){return t.jsx(F,{children:t.jsx(R,{owner:e,agentId:a})})}function H(){const{owner:e,agentId:a}=w.useParams();return t.jsx(D,{owner:e,agentId:a})}export{H as component};
|
|
2
|
-
//# sourceMappingURL=create-CWcza8NT.js.map
|
|
@@ -1,2 +0,0 @@
|
|
|
1
|
-
import{j as n,aT as t,O as c,cO as r,as as i,dt as d,du as l,be as m,dv as x,L as u,dw as j,dx as C,dy as h}from"./index-CdDNNAx2.js";function b({owner:e,initialConnectorKey:a}){return n.jsx(t,{owner:e,children:o=>n.jsx(p,{ownerSlug:o.ownerSlug,organizationId:o.organizationId,initialConnectorKey:a})})}function p({ownerSlug:e,organizationId:a,initialConnectorKey:o}){const{data:s=[]}=r(a??"");return n.jsxs(i,{className:"flex flex-1 flex-col gap-6",children:[n.jsx(d,{breadcrumb:n.jsx(x,{crumbs:[n.jsx(u,{to:"/$owner/connectors",params:{owner:e},search:{},className:j,children:"Connectors"},"connectors")]}),icon:n.jsx(m.connectors.icon,{className:"h-6 w-6"}),title:"Add a connection",caption:"Pick a connector from the catalog or drop in an MCP URL — Lobu handles auth and brings the data into memory.",meta:n.jsx(l,{owner:e})}),a?n.jsx(C,{ownerSlug:e,organizationId:a,connections:s,initialConnectorKey:o},o??"catalog"):n.jsx("div",{className:"max-w-3xl",children:n.jsx(h,{rows:4})})]})}const f=()=>n.jsx(c,{});export{b as ConnectionsCreateRouteContent,f as component};
|
|
2
|
-
//# sourceMappingURL=create-bGOYifof.js.map
|
|
@@ -1,2 +0,0 @@
|
|
|
1
|
-
import{Y as Ce,z as je,r as h,Z as Ne,j as e,U as Se,B as ce,$ as ie}from"./index-CdDNNAx2.js";import{u as Ae,r as te,o as F,g as _e,a as De,C as ne,A as Ee,W as Re,b as re,c as Te,R as Pe}from"./use-login-redirect-CYlVkAhE.js";import{F as Le}from"./full-page-spinner-DWo519BU.js";import{w as A}from"./workspace-label-o_QfBuCM.js";import"./card-C01y1O-W.js";const Ie=[];function M(t){return t.trim().toUpperCase()}const Oe=15e3;async function ze(t){const i=new AbortController,p=window.setTimeout(()=>i.abort(),Oe);try{const n=await fetch(`${ie}/oauth/device/info?user_code=${encodeURIComponent(t)}`,{credentials:"include",signal:i.signal}),u=await n.json().catch(()=>null);return{response:n,data:u}}catch(n){throw i.signal.aborted?new Error("Verification timed out. Check your connection and try again."):n}finally{window.clearTimeout(p)}}function Ue({isVerified:t,requiresDeviceHome:i,requiresWorkspaceAccess:p,homeLabel:n,workspaceCount:u}){if(!t||p&&u===0)return null;const b=`${u} workspace${u===1?"":"s"}`;return i?n?p?`Pairs this device in ${n} and grants MCP access to ${b}.`:`Pairs this device in ${n} with no workspace data access.`:null:p?`Grants MCP access to ${b}.`:null}function qe(){const t=Ce.useSearch(),{session:i,isReady:p}=je(),n=!p,[u,b]=h.useState(t.user_code||""),[r,g]=h.useState(null),[w,s]=h.useState(null),[a,ae]=h.useState(null),[$,P]=h.useState(null),[le,V]=h.useState(null),k=h.useRef(0),j=Ne(t.return_to),q=j?"app":"terminal",de=!!t.user_code,_=M(u),m=$?.code===_?$:null,v=m!==null,D=m?.scopes??Ie,E=D.includes("device_worker:run"),ue=D.includes("connections:token"),L=m?.multiWorkspaceGrantsEnabled===!0,{accessLevel:G,setAccessLevel:I,selectedScopes:me,resourceOrg:O,hasMcpScopes:he,requiresWorkspaceAccess:N,orgList:C,workspaceAccess:pe,setWorkspaceAccess:ve,selectedOrgIds:z,toggleSelectedOrgId:fe,resetWorkspaceSelection:ge,deviceHomeOrgId:R,orgsLoading:U,orgsError:T,retryOrgs:B,workspaceSelectionReady:xe}=Ae({requestedScopes:D,resource:m?.resource??null,allowMultiple:L,requireDeviceHome:E,deviceHomeOrgId:le}),l=v&&E&&!O,d=C.find(o=>o.id===R)??null,Y=U||T!==null||C.length>1,J=C.length===1?C[0]:void 0,we=J!==void 0&&!J.isPersonal,Z=l&&(Y||R===null||we),K=N&&Y&&(L||!l),Q=!N&&!l||xe,W=h.useCallback(async o=>{const x=++k.current;g("verify"),s(null);try{const{response:y,data:c}=await ze(o);if(x!==k.current)return;if(y.status===401){te();return}if(!y.ok||!c)throw new Error(F(c,"Failed to verify device authorization code"));const f=Array.isArray(c.scopes)?c.scopes:[];P({code:o,clientName:c.client_name??null,logoUri:typeof c.logo_uri=="string"?c.logo_uri:null,clientUri:typeof c.client_uri=="string"?c.client_uri:null,scopes:f,resource:typeof c.resource=="string"?c.resource:null,multiWorkspaceGrantsEnabled:c.multi_workspace_grants_enabled===!0}),I(_e(f))}catch(y){if(x!==k.current)return;P(null),s(y instanceof Error?y.message:"Unexpected error")}finally{x===k.current&&g(null)}},[I]);De(!!i,n),h.useEffect(()=>{if(!(n||!i||!t.user_code))return W(M(t.user_code)),()=>{k.current+=1}},[i,n,t.user_code,W]);const X=async o=>{const x=_;if(!x){s(`Please enter the code shown in your ${q}.`);return}if(!v){s("Verify the device code before approving or denying access.");return}if(o&&!Q){s(T?"Workspaces could not be loaded. Retry before approving.":l&&!d?"Choose a workspace for this device before approving.":"Choose at least one workspace before approving.");return}const y=m?.clientName??null,c=l&&d?A(d):null;g(o?"approve":"deny"),s(null);try{const f=await fetch(`${ie}/oauth/device/approve`,{method:"POST",headers:{"Content-Type":"application/json"},credentials:"include",body:JSON.stringify({user_code:x,approved:o,...o?{scope:me.join(" ")}:{},...o&&N?{workspace_access:pe,organization_ids:z}:{},...o&&l&&d?{organization_id:d.id}:{}})}),S=await f.json().catch(()=>null);if(f.status===401){te();return}if(!f.ok)throw new Error(F(S,"Failed to process device authorization"));const oe=o?"approved":"denied";if(S?.status!==oe)throw new Error(F(S,o?"The server did not confirm this approval. The device is still waiting — try again.":"The server did not confirm this denial. Try again."));const se=typeof S.user_code=="string"?M(S.user_code):null;if(se!==null&&se!==x)throw new Error("The server confirmed a different device code. Re-check the code shown on your device.");g(null),ae({outcome:oe,code:x,clientName:y,deviceHomeLabel:c})}catch(f){g(null),s(f instanceof Error?f.message:"Unexpected error")}};if(h.useEffect(()=>{if(a?.outcome!=="approved"||!j)return;const o=window.setTimeout(()=>{window.location.href=j},600);return()=>window.clearTimeout(o)},[a,j]),n||!i)return e.jsx(Le,{className:"min-h-[calc(100vh-3.5rem)]"});if(a)return e.jsx(ne,{live:!0,title:a.outcome==="approved"?de?"Access Authorized":"Device Authorized":"Authorization Denied",description:a.outcome==="approved"?j?"You can close this tab and return to the Lobu app.":"You can close this tab and return to your terminal.":"The device was not authorized. You can close this tab.",review:e.jsxs("div",{className:"space-y-4 text-sm",children:[a.outcome==="approved"&&a.deviceHomeLabel?e.jsxs("p",{className:"text-muted-foreground",children:["This device now lives in ",a.deviceHomeLabel,". Change its workspace or share its connections from the device page under Connectors."]}):null,e.jsxs("dl",{className:"space-y-1",children:[e.jsx("dt",{className:"text-muted-foreground",children:a.outcome==="approved"?"Approved code":"Denied code"}),e.jsx("dd",{className:"font-mono text-base tracking-widest text-foreground",children:a.code}),a.clientName?e.jsxs(e.Fragment,{children:[e.jsx("dt",{className:"text-muted-foreground",children:"Requested by"}),e.jsx("dd",{className:"text-foreground",children:a.clientName})]}):null]})]})});const ye=Ue({isVerified:v,requiresDeviceHome:l,requiresWorkspaceAccess:N,homeLabel:d?A(d):null,workspaceCount:z.length}),ee=e.jsxs("div",{className:"space-y-2",children:[e.jsx("label",{htmlFor:"user-code",className:"text-sm font-medium",children:"Device code"}),e.jsx(Se,{id:"user-code",value:u,disabled:r==="approve"||r==="deny",onChange:o=>{k.current+=1,b(o.target.value.toUpperCase()),P(null),ge(),V(null),g(null),s(null)},placeholder:"ABCD-1234",className:"font-mono text-center text-lg tracking-widest",maxLength:9,autoFocus:!t.user_code})]}),H=Z?e.jsx(We,{deviceName:m?.clientName??null,orgList:C,deviceHomeOrgId:R,onChange:V,orgsLoading:U,orgsError:T,onRetry:B,disabled:r!==null}):null,be=v?e.jsxs("div",{className:"space-y-5",children:[ee,e.jsx(Ee,{idPrefix:"oauth-device",clientName:m?.clientName??null,clientNote:E?"This device can run commands and control apps.":void 0,requestedScopes:D,accessLevel:G,onAccessLevelChange:I,allowNoAccess:E,disabled:r!==null,resource:m?.resource??null,logoUri:m?.logoUri??null,clientUri:m?.clientUri??null}),ue?e.jsx("p",{className:"text-sm text-muted-foreground",children:"Can fetch tokens for your connected services."}):null,v&&l&&!Z&&d?e.jsxs("p",{className:"text-sm text-muted-foreground",children:["This device will live in ",A(d),".",N?" MCP access follows the device home.":""]}):null,H&&!K?H:null]}):ee,ke=K?e.jsxs("div",{className:"space-y-4",children:[H,l&&d?e.jsxs("p",{className:"text-xs text-muted-foreground",children:[A(d)," is always included as the device home. Additional workspaces grant MCP access only."]}):null,e.jsx(Re,{idPrefix:"oauth-device",heading:l?"Additional workspaces":void 0,allowMultiple:L,includedOrgId:l?R:null,orgList:C,selectedOrgIds:z,onWorkspaceAccessChange:ve,onSelectedOrgChange:fe,orgsLoading:U,orgsError:T,onRetry:B,disabled:r!==null})]}):void 0;return e.jsx(ne,{title:v?"Authorize application":"Connect a device",description:v?void 0:`Enter the code shown in your ${q}.`,busy:r!==null,error:w,review:be,aside:ke,below:v&&he&&O?e.jsx(Pe,{resourceOrg:O,accessLevel:G}):null,footer:v?e.jsx(re,{summary:ye,children:e.jsx(Te,{busy:r==="approve"||r==="deny"?r:null,approveDisabled:r!==null||!Q,denyDisabled:r!==null,onApprove:()=>X(!0),onDeny:()=>X(!1)})}):e.jsx(re,{children:e.jsx(ce,{type:"button",onClick:()=>W(_),disabled:r!==null||!_,children:r==="verify"?"Verifying...":"Continue"})})})}function We({deviceName:t,orgList:i,deviceHomeOrgId:p,onChange:n,orgsLoading:u,orgsError:b,onRetry:r,disabled:g}){const w=i.find(s=>s.id===p)??null;return e.jsxs("section",{className:"space-y-2 rounded-md border bg-card p-3 text-sm",children:[e.jsx("label",{htmlFor:"oauth-device-home",className:"block font-medium text-foreground",children:"Device home"}),u?e.jsx("p",{role:"status","aria-live":"polite",className:"text-muted-foreground",children:"Loading your workspaces..."}):b?e.jsxs("div",{role:"alert",className:"space-y-2 text-destructive",children:[e.jsx("p",{children:"Workspaces could not be loaded. Approval is unavailable until they load."}),e.jsx(ce,{type:"button",variant:"outline",size:"sm",onClick:r,children:"Retry"})]}):e.jsxs(e.Fragment,{children:[e.jsxs("select",{id:"oauth-device-home",value:w?.id??"",disabled:g,onChange:s=>n(s.target.value),className:"flex h-9 w-full rounded-md border border-input bg-background px-3 text-sm focus:outline-none focus:ring-1 focus:ring-ring disabled:cursor-not-allowed disabled:opacity-50",children:[w?null:e.jsx("option",{value:"",disabled:!0,children:"Choose a workspace"}),i.map(s=>e.jsx("option",{value:s.id,children:A(s)},s.id))]}),w&&!w.isPersonal?e.jsxs("p",{role:"note",className:"rounded-md bg-amber-500/10 px-3 py-2 text-amber-700 dark:text-amber-400",children:[t??"This device"," will be added to ",w.name,". Its Shell and Browser connections will be private to you — teammates can't use them unless you share them from the device page."]}):null,e.jsx("p",{className:"text-xs text-muted-foreground",children:"Where this device is registered. Its connectors and Automations run here. A device that is already paired keeps its workspace; change it from the Devices page."})]})]})}export{qe as component};
|
|
2
|
-
//# sourceMappingURL=device-D3fzoIrM.js.map
|
|
@@ -1,2 +0,0 @@
|
|
|
1
|
-
import{ea as Re,r as E,c6 as Ee,kc as w,gj as Fe,eG as se,j as e,B as N,u as Z,k5 as De,m as ae,gs as pe,kd as Ce,M as Le,c as fe,b as Be,c7 as B,n as Pe,w as Te,eI as X,cN as Ve,gG as $e,ke as Ie,dI as Me,cj as ne,cl as ie,fZ as Oe,go as Ae,dy as ze,hP as Ue,hQ as He,hR as Ke,hS as Ge,hT as We,kf as qe,cb as Qe,T as G,U as oe,f5 as Xe,a3 as Ye,gh as re,fg as W,dv as Ze,L as q,dw as Q}from"./index-CdDNNAx2.js";import{N as Je,d as et,f as tt,g as st,S as at,h as nt}from"./entity-pages-18xSANrS.js";import{R as it}from"./record-activity-9ux6SfCd.js";import{D as ot}from"./dynamic-schema-form-OkIZImgp.js";import{r as rt,V as lt}from"./views-access-required-CvIIxdS_.js";import{a as xe,V as le,M as ct,b as dt}from"./view-param-filters-BdN8OU35.js";import{m as ut,j as Y,d as mt,o as ce,c as ge,R as ve,q as ht,r as pt}from"./renderer-DZ0w2k2r.js";import"./table-C3DMoL4K.js";import{a as ft}from"./source-record-panels-C4UItfdk.js";import{r as xt,R as de,b as gt}from"./events-feed-BI7wNRUY.js";import{a as vt}from"./record-session-ClKBr1_C.js";import"./schema-value-k19Ata7u.js";import"./filter-editors-DDTwyYt0.js";import"./subDays-hOwerOLo.js";import"./runs-CuC7WMtd.js";import"./event-kind-options-fHAIXu24.js";import"./clients-BCvjAJDT.js";import"./client-activity-scopes-BBIq16tG.js";import"./client-rows-DGh1O-Fu.js";import"./run-initiator-B8IRlRd-.js";import"./list-skeleton-0B1bTrAK.js";import"./use-automations-CdtiVLCv.js";import"./agent-loading-shells-xteN-pyK.js";import"./member-scope-gate-CH_0jHiM.js";import"./app-bridge-C4nPtae3.js";import"./card-C01y1O-W.js";import"./definition-comparison-BUDNuAN_.js";import"./json-diff-C-WQqyIf.js";import"./code-editor-BdRMYojw.js";import"./index-Vcq4gwWv.js";import"./copy-button-BhXeXLIm.js";import"./device-automation-Dp3faMvp.js";function yt(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 jt(t,s){const{shouldBlockFn:i,enableBeforeUnload:n=!0,disabled:a=!1,withResolver:d=!1}=yt(t),o=Re(),{history:r}=o,[c,h]=E.useState({status:"idle",current:void 0,next:void 0,action:void 0,proceed:void 0,reset:void 0});return E.useEffect(()=>{const p=async x=>{function l(y){const b=o.parseLocation(y),v=o.getMatchedRoutes(b.pathname);return v.foundRoute===void 0?{routeId:"__notFound__",fullPath:b.pathname,pathname:b.pathname,params:v.routeParams,search:o.options.parseSearch(y.search)}:{routeId:v.foundRoute.id,fullPath:v.foundRoute.fullPath,pathname:b.pathname,params:v.routeParams,search:o.options.parseSearch(y.search)}}const m=l(x.currentLocation),u=l(x.nextLocation);if(m.routeId==="__notFound__"&&u.routeId!=="__notFound__")return!1;const f=await i({action:x.action,current:m,next:u});if(!d)return f;if(!f)return!1;const _=await new Promise(y=>{h({status:"blocked",current:m,next:u,action:x.action,proceed:()=>y(!1),reset:()=>y(!0)})});return h({status:"idle",current:void 0,next:void 0,action:void 0,proceed:void 0,reset:void 0}),_};return a?void 0:r.block({blockerFn:p,enableBeforeUnload:n})},[i,n,a,d,r,o]),c}function U(t,s){return se(Y(t))===se(Y(s))}function bt(t,s){const i={};for(const n of new Set([...Object.keys(t),...Object.keys(s)]))U(t[n],s[n])||(i[n]=Y(t[n])??null);return Object.keys(i).length>0?i:void 0}function kt(t,s){return[...new Set([...Object.keys(t),...Object.keys(s)])].filter(i=>{try{return!U(t[i],s[i])}catch{return!0}})}function ue(t,s){return{name:t.name,slug:t.slug,metadata:ut(t.metadata??{},s)}}function _t(t,s,i){const n=new Set(i),a={},d={},o=new Set([...Object.keys(t.values.metadata),...Object.keys(t.baseline.metadata),...Object.keys(s.metadata)]);for(const r of o){const c=n.has(r),h=c?t.values.metadata[r]:t.baseline.metadata[r],p=U(h,s.metadata[r])?h:s.metadata[r];p!==void 0&&(a[r]=p);let x=!1;if(!c)try{x=!U(t.values.metadata[r],t.baseline.metadata[r])}catch{x=!0}const l=x?t.values.metadata[r]:p;l!==void 0&&(d[r]=l)}return{baseline:{name:s.name,slug:s.slug,metadata:a},values:{name:s.name,slug:s.slug,metadata:d}}}function Nt({entity:t,schema:s,orgContext:i}){const n=E.useMemo(()=>ue(t,s),[t,s]),a=Ee(w(t),n,s),d=Fe(i),{values:o,baseline:r,commit:c}=a,h=E.useMemo(()=>kt(o.metadata,r.metadata),[o.metadata,r.metadata]),p=o.name!==r.name||o.slug!==r.slug,x=E.useCallback((m,u)=>a.setValues(f=>({...f,metadata:{...f.metadata,[m]:u}})),[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 u=bt(o.metadata,r.metadata),f=o.name.trim()!==r.name.trim();if(!u&&!p)return null;const _=await d.mutateAsync({entityId:t.id,name:f?o.name.trim():void 0,slug:o.slug,metadata:u,field_note:u&&m?.trim()||void 0}),y=ue(_.entity,s);return c(b=>_t(b,y,Object.keys(u??{})),y),{held:_.blocked_fields??[],approvalUrl:_.approval_url}};return{values:o,baseline:r,revision:a.revision,setValues:a.setValues,setMetadataField:x,reset:a.reset,save:l,saving:d.isPending,dirtyKeys:h,identityDirty:p,isDirty:p||h.length>0,canSubmit:a.canSubmit,hasConflict:a.hasConflict,hasInvalidInput:a.hasInvalidInput}}const St=3,wt=50;function ye(t){const s=E.useRef(null);return E.useEffect(()=>{t&&(s.current?.scrollIntoView?.({block:"start"}),s.current?.focus())},[t]),s}function T({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 Rt({entityId:t,entityName:s,ownerSlug:i,orgContext:n,focus:a,collapsed:d=!1}){const o=Z(),r=ye(a),{data:c,isLoading:h,isError:p,refetch:x}=De(t,n,{limit:wt});if(t===void 0)return null;if(h)return e.jsxs("section",{className:"space-y-2","aria-busy":"true",children:[e.jsx(T,{headingRef:r,children:"Linked"}),e.jsx(ae,{className:"h-4 w-24"}),e.jsx(ae,{className:"h-6 w-full rounded-md"})]});if(p||!c)return e.jsxs("section",{className:"space-y-2",children:[e.jsx(T,{headingRef:r,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(c.countsByType.length===0&&!c.hasMore&&!c.failures?.length)return a?e.jsxs("section",{className:"space-y-2",children:[e.jsx(T,{headingRef:r,children:"Linked"}),e.jsx("p",{className:"text-xs text-muted-foreground",children:"No links to other records yet."})]}):null;if(d){const l=c.countsByType.flatMap(m=>{const u=m.count===1?c.rows.find(f=>f.relationship_type_slug===m.relationship_type_slug):void 0;return u?[xt(u,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(T,{headingRef:r,children:"Linked"}),e.jsx(de,{count:c.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(T,{headingRef:r,children:"Linked"}),e.jsx(de,{count:c.failures?.length??0,onRetry:()=>void x()}),c.hasMore&&o?e.jsx(N,{type:"button",variant:"ghost",size:"sm",onClick:()=>o.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,c.countsByType.map(l=>{const m=c.rows.filter(f=>f.relationship_type_slug===l.relationship_type_slug).slice(0,St),u=l.count>m.length;return e.jsxs("div",{className:"space-y-1 text-sm",children:[u||m.length===0?e.jsxs("p",{className:"text-muted-foreground",children:[l.relationship_type_name,u?e.jsxs("span",{className:"tabular-nums text-muted-foreground/70",children:[" ","· ",l.count,c.countsScope==="page"?" shown":""]}):null]}):null,e.jsxs("div",{className:"flex min-w-0 flex-col items-start gap-1",children:[m.map(f=>e.jsx(gt,{row:f,label:l.relationship_type_name,entityId:t,ownerSlug:i,orgContext:n},f.id)),u&&o?e.jsxs(N,{type:"button",variant:"ghost",size:"sm",className:"h-8 px-2 text-primary hover:text-primary",onClick:()=>o.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 Et({record:t,ownerSlug:s,orgContext:i,focus:n}){const[a,d]=E.useState(n),o=ye(n);return e.jsxs("section",{className:"space-y-2",children:[e.jsx(T,{headingRef:o,children:"Linked"}),a?e.jsx(ft,{record:t,ownerSlug:s,orgContext:i}):e.jsx(N,{type:"button",variant:"outline",size:"sm",className:"h-7",onClick:()=>d(!0),children:"Find linked records"})]})}const Ft="$name";function je({outcome:t,schema:s}){if(!t||t.held.length===0)return null;const i=s?.properties??{},n=t.held.map(a=>a===Ft?"Name":mt(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 Dt=320,Ct={},Lt=()=>{};function Bt({view:t,orgSlug:s,recordUrl:i,scope:n}){const a=Z(),d=`${i}${pe(t.key)}`,o=a?()=>a.open({href:d,title:t.name}):void 0,r=!t.untitled,c=r||!!t.description,h=c||!!o;return e.jsxs("section",{className:"min-w-0 rounded-lg border","data-testid":"view-card","data-view":t.key,"aria-label":r?void 0:t.name,children:[h?e.jsxs("header",{className:c?"flex items-start justify-between gap-3 px-4 pt-3 pb-2":"flex justify-end px-2 pt-1.5",children:[c?e.jsxs("div",{className:"min-w-0",children:[r?e.jsx("h3",{className:"truncate text-sm font-medium",children:t.name}):null,t.description?e.jsx("p",{className:"truncate text-xs text-muted-foreground",children:t.description}):null]}):null,o?e.jsxs(N,{type:"button",variant:"ghost",size:"sm",className:"h-7 shrink-0 gap-1.5 px-2 text-muted-foreground hover:text-foreground",onClick:o,"aria-label":`Open ${t.name}`,children:[e.jsx(Ce,{className:"h-3.5 w-3.5"}),"Open"]}):null]}):null,e.jsx("div",{className:h?"px-4 pb-3":"px-4 py-3",children:e.jsx(xe,{orgSlug:s,viewKey:t.key,scope:n,params:Ct,onParamsChange:Lt,contentHash:t.content_hash,title:t.name,minHeight:64,displayMode:"inline",maxHeight:Dt,onRequestDisplayMode:o?p=>{p==="fullscreen"&&o()}:void 0})})]})}function Pt({recordUrl:t,dirty:s,onDiscard:i}){const n=jt({disabled:!s,enableBeforeUnload:s,withResolver:!0,shouldBlockFn:({next:d})=>d.pathname!==t&&!d.pathname.startsWith(`${t}${pe("")}`)}),a=n.status==="blocked";return e.jsx(Ue,{open:a,onOpenChange:d=>{!d&&a&&n.reset()},children:e.jsxs(He,{className:"max-w-sm",children:[e.jsxs(Ke,{children:[e.jsx(Ge,{children:"Discard unsaved changes?"}),e.jsx(We,{children:"This record has edits that are not saved. Leaving discards them."})]}),e.jsxs("div",{className:"flex justify-end gap-2",children:[e.jsx(N,{type:"button",variant:"ghost",onClick:()=>a&&n.reset(),children:"Keep editing"}),e.jsx(N,{type:"button",variant:"destructive",onClick:()=>{a&&(i(),n.proceed())},children:"Discard"})]})]})})}const me=6;function Tt({entity:t,ownerSlug:s,orgContext:i,recordUrl:n,schema:a,entityTypeName:d,isTypeLoading:o,record:r,canEdit:c,editing:h,onEditingChange:p,outcome:x,onSaved:l,formId:m,fieldLimit:u,onDeleted:f}){const _=h&&c,y=Z(),b={entity:{id:w(t),name:t.name,entity_type:t.entity_type},ownerSlug:s,orgContext:i,schema:a,record:r,editing:_};vt(b);const v=y?.item?.recordField,D={ownerSlug:s,orgContext:i,controls:t.field_controls,dirtyKeys:r.dirtyKeys,openField:y?L=>y.open(rt(b,L.key)):void 0,openFieldKey:v?.entityId===w(t)?v.field:void 0},C=e.jsx(Pt,{recordUrl:n,dirty:_&&r.isDirty,onDiscard:()=>{r.reset(),p(!1)}});if(o)return e.jsx(ze,{rows:6});if(_)return e.jsxs(e.Fragment,{children:[C,e.jsx(Vt,{formId:m,entity:t,entityTypeName:d,schema:a,record:r,orgContext:i,renderControl:(L,P,F)=>ht(P)?e.jsx(pt,{field:{key:L,prop:P},value:F,context:D}):void 0,onSaved:l,onDeleted:f,onDone:()=>p(!1)})]});const R=ge(r.revision);return e.jsxs("div",{className:"space-y-3",children:[e.jsx(je,{outcome:x,schema:a}),e.jsx(ve,{fields:R,fieldLimit:u,values:r.values.metadata,context:D})]})}function Vt({formId:t,entity:s,entityTypeName:i,schema:n,record:a,orgContext:d,renderControl:o,onSaved:r,onDeleted:c,onDone:h}){const p=qe(),x=s.field_controls,{name:l,slug:m,metadata:u}=a.values,f=g=>a.setValues(j=>({...j,name:g})),_=g=>a.setValues(j=>({...j,slug:g})),y=g=>a.setValues(j=>({...j,metadata:g})),[b,v]=B(w(s),""),[D,C]=B(w(s),null),[R,L]=B(w(s),null),[P,F]=B(w(s),!1),[S,V]=B(w(s),null),$=a.dirtyKeys.length>0,O=async g=>{if(g.preventDefault(),!!a.canSubmit){if(C(null),!l.trim()){C("Name is required");return}try{const j=await a.save({note:b});L(j),r(j),v(""),j?.held.length||h()}catch(j){C(j instanceof Error?j.message:"Failed to update entity")}}},H=async()=>{V(null);try{if(typeof s.id!="number")throw new Error("Source records are read-only");await p.mutateAsync({entityId:s.id}),F(!1),c?.()}catch(g){V(g instanceof Error?g.message:"Failed to delete entity")}},A=[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:O,className:"space-y-4",children:[e.jsx(Qe,{visible:a.hasConflict,onReload:a.reset}),e.jsxs("div",{className:"grid gap-2",children:[e.jsxs(G,{htmlFor:"sidebar-name",children:["Name ",e.jsx("span",{className:"text-destructive",children:"*"})]}),e.jsx(oe,{id:"sidebar-name",value:l,onChange:g=>f(g.target.value)})]}),e.jsxs("div",{className:"grid gap-2",children:[e.jsx(G,{htmlFor:"sidebar-slug",children:"URL Slug"}),e.jsx(oe,{id:"sidebar-slug",value:m,onChange:g=>_(g.target.value.toLowerCase().replace(/[^a-z0-9-]/g,""))})]}),a.revision&&Object.keys(a.revision).length>0&&e.jsxs(e.Fragment,{children:[e.jsx(at,{}),e.jsx(ot,{schema:a.revision,values:u,onValuesChange:y,fieldControls:x,orgContext:d,renderControl:o})]}),$&&e.jsxs("div",{className:"grid gap-2",children:[e.jsx(G,{htmlFor:"sidebar-correction-note",children:"Correction note (optional)"}),e.jsx(Xe,{id:"sidebar-correction-note",value:b,onChange:g=>v(g.target.value),placeholder:"Why are you changing these fields? Helps Automations respect the correction.",rows:2})]}),D&&e.jsx("div",{className:"rounded-md bg-destructive/10 px-3 py-2 text-sm text-destructive",children:D}),e.jsx(je,{outcome:R,schema:n}),P?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(Ye,{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,'"?']}),A&&e.jsxs("p",{className:"text-muted-foreground",children:["Removes ",A,". This cannot be easily undone."]})]})]}),S&&e.jsx("div",{className:"rounded-md bg-destructive/10 px-2.5 py-1.5 text-sm text-destructive",children:S}),e.jsxs("div",{className:"flex justify-end gap-2",children:[e.jsx(N,{type:"button",variant:"ghost",size:"sm",onClick:()=>{F(!1),V(null)},children:"Cancel"}),e.jsx(N,{type:"button",variant:"destructive",size:"sm",onClick:H,disabled:p.isPending,children:p.isPending?"Deleting...":`Delete ${i||"entity"}`})]})]}):e.jsx("div",{className:"pt-2",children:e.jsx(N,{type:"button",variant:"ghost",size:"sm",className:"text-destructive hover:text-destructive",onClick:()=>F(!0),children:"Delete"})})]})}function be(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"&&!Oe(n[a])&&n[a]?.const===void 0).map(a=>({key:a,prop:n[a]??{},label:n[a]?.["x-table-label"]??(i.has(a)?a:Ae(a.replace(/_/g," "))),numeric:i.has(a)}))}function $t({entity:t,schema:s,ownerSlug:i,fieldLimit:n}){const a=be(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(ve,{fields:a,fieldLimit:n,values:t.metadata??{},context:{ownerSlug:i}})]})}const he="owletto:record-details-expanded";function It(){const[t,s]=E.useState(()=>{try{return window.localStorage.getItem(he)==="1"}catch{return!1}});return[t,n=>{s(n);try{window.localStorage.setItem(he,n?"1":"0")}catch{}}]}function Mt({namespace:t,entity:s,recordUrl:i,viewKey:n,title:a,onDeleted:d}){const o=Le({strict:!1}),r=fe(),c=E.useRef(null),h=Be(c,Je),[p,x]=It(),[l,m]=B(w(s),!1),u={slug:t.slug,organizationId:t.id},{isMember:f,isPublic:_,isLoading:y}=Pe(t.slug),b=f||_,v=Te({...u,organizationId:f?t.id:null}),{data:D,isLoading:C}=X(s.entity_type,u),R=D?.metadata_schema,{isAdmin:L,isLoading:P}=Ve(f?u.organizationId:void 0),F=f&&L&&!P&&!s.is_derived,S=Nt({entity:s,schema:R,orgContext:u}),[V,$]=B(w(s),null),O=`record-form-${s.id}`,H=l&&F,A=b?v.data??[]:[],g=$e(A,{type:s.entity_type,id:w(s)}),j=Ie(g,n),z=!n&&o.tab==="relationships",ke=k=>void r({to:".",search:K=>ne(K,k),replace:!0}),J={type:s.entity_type,entity:s.is_derived?s.slug:s.id??s.slug},I=h&&!p&&!l&&!z,ee=s.is_derived?ce(be(s,R),s.metadata??{}).length:ce(ge(S.revision),S.values.metadata).length,te=I?me:void 0,_e=e.jsxs("div",{className:"space-y-6",children:[s.is_derived?e.jsxs(e.Fragment,{children:[e.jsx($t,{entity:s,schema:R,ownerSlug:t.slug,fieldLimit:te}),e.jsx(Et,{record:{type:s.entity_type,key:s.slug},ownerSlug:t.slug,orgContext:u,focus:z})]}):e.jsxs(e.Fragment,{children:[e.jsx(Tt,{entity:s,ownerSlug:t.slug,orgContext:u,recordUrl:i,schema:R,entityTypeName:D?.name,isTypeLoading:C,record:S,canEdit:F,editing:l,onEditingChange:m,outcome:V,onSaved:$,formId:O,fieldLimit:te,onDeleted:d}),e.jsx(Rt,{entityId:typeof s.id=="number"?s.id:void 0,entityName:s.name,ownerSlug:t.slug,orgContext:u,focus:z,collapsed:I})]}),h&&!l&&!z?e.jsx(N,{type:"button",variant:"ghost",size:"sm",className:"h-8 px-2 text-primary hover:text-primary","aria-expanded":!I,onClick:()=>x(I),children:I?ee>me?`Show all ${ee} fields`:"Show all details":"Show fewer"}):null]}),Ne=k=>e.jsx(tt,{rootRef:c,narrow:h,details:_e,summary:e.jsx(st,{entity:s,schema:R}),children:k}),Se=H?e.jsxs("div",{className:"flex shrink-0 items-center gap-2",children:[e.jsx(N,{type:"button",variant:"ghost",size:"sm",onClick:()=>{S.reset(),$(null),m(!1)},children:"Cancel"}),e.jsx(N,{type:"submit",form:O,size:"sm",disabled:!S.canSubmit||!S.isDirty||S.saving||!S.values.name.trim(),children:S.saving?"Saving...":"Save"})]}):F&&!C?e.jsxs(N,{type:"button",variant:"ghost",size:"sm",className:"h-8 shrink-0 gap-1.5 px-2 text-muted-foreground hover:text-foreground",onClick:()=>{$(null),m(!0)},children:[e.jsx(Me,{className:"h-3.5 w-3.5"}),"Edit"]}):null,M=k=>e.jsx(et,{entity:s,owner:t.slug,schema:R,title:a??null,actions:Se,layout:"content",children:k});if(n&&!b)return M(y?null:e.jsx(lt,{}));if(n&&v.data===void 0)return M(v.isError?e.jsx(le,{onRetry:()=>void v.refetch()}):null);if(j.kind==="missing")return M(e.jsx(ct,{viewKey:j.key,backTo:i,backLabel:`Back to ${s.name}`}));if(j.kind==="view"){const{view:k}=j;return M(e.jsxs("div",{className:"min-w-0 space-y-3",children:[e.jsx(dt,{decls:k.params,params:ie(o),onParamsChange:K=>void r({to:".",search:we=>ne(we,K)})}),e.jsx(xe,{orgSlug:t.slug,viewKey:k.key,scope:J,params:ie(o),onParamsChange:ke,paramDecls:k.params,contentHash:k.content_hash,title:k.name,minHeight:320})]}))}return M(Ne(e.jsxs("div",{className:"min-w-0 space-y-4",children:[b&&v.isError&&e.jsx(le,{onRetry:()=>void v.refetch()}),g.map(k=>e.jsx(Bt,{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(it,{entity:s,organizationId:t.id,ownerSlug:t.slug})]})]})))}function Ot(t){return t?.trim()?t:void 0}function ys({namespace:t,path:s,entity:i,viewKey:n}){const a=fe(),{data:d}=X(i.entity_type,{slug:t.slug}),o=s[0]?.entity_type??i.entity_type,{data:r}=X(o,{slug:t.slug}),c=Ot(d?.icon),h=s.map(l=>({entity_type:l.entity_type,slug:l.slug})),p=`/${t.slug}/${re(i.entity_type)}`,x=W(t.slug,h);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(Ze,{crumbs:[...o==="$member"?[]:[e.jsx(q,{to:"/$owner",params:{owner:t.slug},search:{section:"entity-type"},className:Q,children:"Entity types"},"home")],e.jsx(q,{to:`/${t.slug}/${re(o)}`,className:Q,children:o==="$member"?"Team":r?.name??o},"type"),...s.slice(0,-1).map((l,m)=>e.jsx(q,{to:W(t.slug,h.slice(0,m+1)),className:Q,children:l.name},l.id))],current:i.name}),e.jsx(Mt,{namespace:t,entity:i,recordUrl:x,viewKey:n,title:e.jsx(nt,{entity:i,schema:d?.metadata_schema,icon:c}),onDeleted:()=>{const l=s.slice(0,-1);l.length>0?a({to:W(t.slug,l)}):a({to:p})}})]})}export{ys as EntityPage};
|
|
2
|
-
//# sourceMappingURL=entity-page-Cjc8oXA2.js.map
|
|
@@ -1,2 +0,0 @@
|
|
|
1
|
-
import{r as x,j as e,bA as ue,i as H,aF as me,aG as xe,B as T,gq as he,aI as pe,cT as ge,fI as ne,go as F,fZ as fe,dP as P,a2 as X,L as A,fg as je,b as ve,m as E}from"./index-CdDNNAx2.js";import{p as S,n as be,e as re,b as ye,g as Ne,f as J,R as we,c as _e}from"./renderer-DZ0w2k2r.js";import{S as U}from"./schema-value-k19Ata7u.js";import{T as Se,a as ke,b as B,c as Y,d as Ce,e as K}from"./table-C3DMoL4K.js";var Ee="Separator",ee="horizontal",Re=["horizontal","vertical"],ae=x.forwardRef((t,s)=>{const{decorative:n,orientation:a=ee,...i}=t,o=Le(a)?a:ee,h=n?{role:"none"}:{"aria-orientation":o==="vertical"?o:void 0,role:"separator"};return e.jsx(ue.div,{"data-orientation":o,...h,...i,ref:s})});ae.displayName=Ee;function Le(t){return Re.includes(t)}var oe=ae;const Me=x.forwardRef(({className:t,orientation:s="horizontal",decorative:n=!0,...a},i)=>e.jsx(oe,{ref:i,decorative:n,orientation:s,className:H("shrink-0 bg-border",s==="horizontal"?"h-[1px] w-full":"h-full w-[1px]",t),...a}));Me.displayName=oe.displayName;function Ae({choices:t,visible:s,onChange:n}){return e.jsxs(me,{children:[e.jsx(xe,{asChild:!0,children:e.jsx(T,{variant:"ghost",size:"icon",className:"size-7 text-muted-foreground hover:text-foreground","aria-label":"Choose columns",title:"Choose columns",children:e.jsx(he,{className:"h-4 w-4"})})}),e.jsxs(pe,{align:"end",className:"max-h-80 overflow-y-auto p-3",children:[e.jsx("p",{className:"mb-2 text-sm font-medium",children:"Visible columns"}),t.map(a=>e.jsxs("label",{className:"flex cursor-pointer items-center gap-2 py-1.5 text-sm",children:[e.jsx("input",{type:"checkbox",checked:!s||s.includes(a.field),onChange:i=>{const o=s??t.map(c=>c.field);n(i.target.checked?[...o,a.field]:o.filter(c=>c!==a.field))}}),a.label]},a.field))]})]})}function Pe({direction:t}){return t?e.jsxs("svg",{className:"h-4 w-4",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:[e.jsx("title",{children:t==="asc"?"Sort ascending":"Sort descending"}),t==="asc"?e.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M5 15l7-7 7 7"}):e.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M19 9l-7 7-7-7"})]}):e.jsxs("svg",{className:"h-4 w-4 text-muted-foreground/50",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:[e.jsx("title",{children:"Sort"}),e.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M7 16V4m0 0L3 8m4-4l4 4m6 0v12m0 0l4-4m-4 4l-4-4"})]})}function te(t,s){const n=t?.properties;if(n)return Object.entries(n).find(([,a])=>a[s])?.[0]}function Te(t){const s=t.trim(),n=s.split(/[\s._@/-]+/).filter(Boolean),a=n.length>=2?`${n[0][0]}${n[1][0]}`:(n[0]??s).slice(0,2);let i=0;for(let o=0;o<s.length;o++)i=i*31+s.charCodeAt(o)>>>0;return{initials:a.toUpperCase()||"?",hue:i%360}}function Fe(t){const[s,n]=x.useState();return x.useEffect(()=>{if(!t||!globalThis.crypto?.subtle){n(void 0);return}let a=!1;const i=t.trim().toLowerCase();return crypto.subtle.digest("SHA-256",new TextEncoder().encode(i)).then(o=>{a||n(Array.from(new Uint8Array(o)).map(c=>c.toString(16).padStart(2,"0")).join(""))}),()=>{a=!0}},[t]),s?`https://www.gravatar.com/avatar/${s}?d=identicon&s=80`:void 0}function ie({metadata:t,metadataSchema:s,name:n,typeIcon:a,className:i="h-6 w-6",iconClassName:o="h-5 w-5",initialsFallback:c=!1}){const h=te(s,"x-image"),j=te(s,"x-email"),y=h&&t?.[h]||void 0,v=j&&t?.[j]||void 0,N=Fe(y?void 0:v),w=y||N,[k,R]=x.useState(!1);if(x.useEffect(()=>{R(!1)},[w]),w&&!k)return e.jsx("img",{src:w,alt:n,referrerPolicy:"no-referrer",onError:()=>R(!0),className:H("rounded-full object-cover border border-border",i)});if(c){const L=n.trim()||v||Oe(t,s)||n,{initials:O,hue:I}=Te(L);return e.jsx("span",{role:"img","aria-label":n,className:H("inline-grid place-items-center rounded-full border border-border font-semibold text-white select-none",i),style:{background:`oklch(0.55 0.13 ${I})`,fontSize:"0.85em"},children:O})}return e.jsx(ge,{icon:a,className:o})}function Oe(t,s){if(!t)return;const n=s?.properties,a=["email","handle","username","login","github","x_handle","slug"],i=Object.keys(n||t);for(const o of i)if(a.includes(o.toLowerCase())){const c=t[o];if(typeof c=="string"&&c.trim())return c}}function _({column:t,children:s,alignRight:n=!1}){return e.jsxs("button",{type:"button",className:`flex items-center gap-1.5 whitespace-nowrap text-left transition-colors hover:text-foreground [&>svg]:shrink-0${n?" ml-auto":""}`,onClick:()=>t.toggleSorting(t.getIsSorted()==="asc"),children:[s,e.jsx(Pe,{direction:t.getIsSorted()})]})}function se(t,s,n){const a=ne(t?.properties).filter(([o,c])=>(!s||o!=="name")&&!c["x-image"]&&c["x-table-column"]===!0);if(a.length)return a.map(([o,c])=>({field:o,label:c["x-table-label"]??F(o.replaceAll("_"," "))}));if(!s)return[];const i=n.find(o=>Object.keys(S(o.metadata)).length>0);return Object.keys(S(i?.metadata)).filter(o=>o!=="id"&&o!=="slug"&&o!=="name"&&!fe(t?.properties?.[o])).map(o=>({field:o,label:F(o.replaceAll("_"," "))}))}function Ie(t){return t.some(s=>Object.hasOwn(S(s.metadata),"name"))}function ze(t,s){return P(t,re(s))}function $e(t){return`${t.entityType}:${t.lookupField}`}const Be=new Set(["stage","category","round_type","investor_type"]);function Ke(t,s){const n=t.toLowerCase();return n==="mrr"||n==="arr"||n==="revenue"||n==="valuation"||n==="funding_raised"||n==="fund_size"||n.endsWith("_usd")||s.description?.toLowerCase().includes("usd")===!0}function He(t,s){if(Ke(t,s))return"currency";if(Be.has(t)||t.endsWith("_slug"))return"enum"}function Ue({entities:t,owner:s,schema:n,entityTypeIcon:a,isDerived:i,measureColumns:o,linkedEntityLookups:c,hasAnyParents:h,sorting:j,onSortingChange:y,visibleColumns:v,columnChoices:N,onVisibleColumnsChange:w,page:k,pageSize:R,totalCount:L,hasMore:O,pageTitle:I,onPrevPage:le,onNextPage:ce}){const M=N?.length&&w?e.jsx(Ae,{choices:N,visible:v,onChange:w}):null,f=n?.properties,V=!i||Ie(t),W=x.useMemo(()=>f?Object.fromEntries(Object.entries(f).flatMap(([l,r])=>r["x-link-entity-type"]?[[l,{entityType:r["x-link-entity-type"],lookupField:r["x-link-lookup-field"]||"slug"}]]:[])):{},[f]),C=x.useMemo(()=>f?se({properties:f},i,[]).map(({field:r})=>[r,f[r]]).map(([r,u])=>{const m=W[r],d=m?c[$e(m)]:void 0;return{id:i?r:`meta_${r}`,accessorFn:p=>{const g=S(p.metadata);return be(g[r],u.enum)},header:({column:p})=>{const g=u["x-table-label"]||u.title||u.description||F(r.replace(/_/g," "));return i?e.jsx(_,{column:p,children:g}):g},cell:({getValue:p})=>e.jsx(U,{value:p(),prop:u,format:He(r,u),className:"text-muted-foreground",resolveLink:d?g=>{const b=d[g];return b?{label:b.name,to:P(s,[{entity_type:b.entity_type,slug:b.slug}])}:void 0}:void 0})}}):[],[i,W,c,s,f]),D=x.useMemo(()=>new Set(o),[o]),z=x.useMemo(()=>!i||C.length>0?[]:se({properties:f},!0,t).map(({field:r})=>r).map(r=>{const u=D.has(r);return{id:r,accessorFn:m=>S(m.metadata)[r],header:({column:m})=>e.jsxs(_,{column:m,children:[u?r:F(r.replace(/_/g," ")),u&&e.jsx(X,{variant:"secondary",className:"font-normal lowercase",children:"measure"})]}),cell:({getValue:m})=>e.jsx(U,{value:m(),prop:f?.[r],className:u?"tabular-nums":"text-muted-foreground"}),meta:u?{align:"right"}:void 0}}),[i,C,t,D,f]),G=x.useMemo(()=>{const l=n?.["x-table-relationships"];return!l||l.length===0?[]:l.map(r=>({id:`rel_${r.relationship_type}`,accessorFn:u=>u.relationships?.[r.relationship_type]??[],header:r.label,cell:({getValue:u})=>{const m=u();return!m||m.length===0?e.jsx("span",{className:"text-muted-foreground",children:"-"}):e.jsx("div",{className:"flex flex-wrap gap-1",children:m.map((d,p)=>{const g=P(s,[{entity_type:d.entity_type,slug:d.slug}]);return e.jsxs("span",{children:[e.jsx(A,{to:g,className:"text-primary hover:underline",onClick:b=>b.stopPropagation(),children:d.name}),p<m.length-1&&","]},d.id)})})}}))},[s,n]),Z=x.useMemo(()=>h||t.some(r=>r.parent_name&&r.parent_slug&&r.parent_entity_type)?[{id:"parent",accessorFn:r=>r.parent_name,header:"Parent",cell:({row:r})=>{if(!r.original.parent_name||!r.original.parent_slug||!r.original.parent_entity_type)return e.jsx("span",{className:"text-muted-foreground",children:"-"});const u=P(s,[{entity_type:r.original.parent_entity_type,slug:r.original.parent_slug}]);return e.jsx(A,{to:u,className:"text-primary hover:underline",children:r.original.parent_name})}}]:[],[t,h,s]),q=x.useMemo(()=>{const l=[],r=t.some(d=>(d.total_content??0)>0),u=t.some(d=>(d.active_connections??0)>0),m=t.some(d=>(d.automations_count??0)>0);return r&&l.push({accessorKey:"total_content",header:({column:d})=>e.jsx(_,{column:d,alignRight:!0,children:"Activity"}),cell:({row:d,getValue:p})=>{const g=p()??0;if(g===0)return e.jsx("span",{className:"tabular-nums",children:"0"});const b=re(d.original);return e.jsx(A,{to:je(s,b),className:"tabular-nums hover:underline",children:g})},meta:{align:"right"}}),u&&l.push({accessorKey:"active_connections",header:"Connectors",cell:({getValue:d})=>{const p=d();return p&&p>0?e.jsxs(X,{variant:"outline",className:"text-green-600 dark:text-green-400",children:[p," active"]}):e.jsx("span",{className:"text-muted-foreground",children:"-"})},meta:{align:"right"}}),m&&l.push({accessorKey:"automations_count",header:({column:d})=>e.jsx(_,{column:d,alignRight:!0,children:"Automations"}),cell:({getValue:d})=>e.jsx("span",{className:"tabular-nums",children:d()??0}),meta:{align:"right"}}),l},[t,s]),Q=x.useMemo(()=>[{accessorKey:"name",header:({column:l})=>V?e.jsx(_,{column:l,children:"Name"}):"Name",cell:({row:l})=>{const r=S(l.original.metadata);return e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(ie,{metadata:r,metadataSchema:n,name:l.original.name,typeIcon:a,className:"h-6 w-6 shrink-0"}),e.jsx("div",{className:"min-w-0",children:(()=>{const u=ze(s,l.original);return e.jsx(A,{to:u,className:"block max-w-56 truncate font-medium hover:underline",title:l.original.name,children:l.original.name})})()})]})}},...Z,...C,...z,...G,...q,...i?[]:[{accessorKey:"created_at",header:({column:l})=>e.jsx(_,{column:l,children:"Created"}),cell:({getValue:l})=>e.jsx("span",{className:"whitespace-nowrap text-muted-foreground",children:new Date(l()).toLocaleDateString("en-US",{month:"short",day:"numeric",year:"numeric"})})}]],[s,Z,C,z,G,q,n,a,i,V]),$=ye({data:t,columns:Q,state:{sorting:j,columnVisibility:Object.fromEntries([...C,...z].flatMap(l=>l.id?[[l.id,!v||v.includes(i?l.id:l.id.replace(/^meta_/,""))]]:[]))},onSortingChange:y,getCoreRowModel:Ne(),manualSorting:!0,enableSortingRemoval:!1}),de=t.length>0||k>0;return e.jsxs("div",{className:"space-y-4",children:[e.jsx("div",{className:"rounded-lg border",children:e.jsxs(Se,{className:"min-w-[48rem]",children:[e.jsx(ke,{children:$.getHeaderGroups().map(l=>e.jsxs(B,{children:[l.headers.map(r=>e.jsx(Y,{"aria-sort":r.column.getIsSorted()==="asc"?"ascending":r.column.getIsSorted()==="desc"?"descending":void 0,className:r.column.columnDef.meta?.align==="right"?"text-right":"",children:r.isPlaceholder?null:J(r.column.columnDef.header,r.getContext())},r.id)),M?e.jsx(Y,{className:"w-10 pr-2 text-right",children:M}):null]},l.id))}),e.jsx(Ce,{children:$.getRowModel().rows.length?$.getRowModel().rows.map(l=>e.jsxs(B,{children:[l.getVisibleCells().map(r=>e.jsx(K,{className:r.column.columnDef.meta?.align==="right"?"whitespace-nowrap text-right":"",children:J(r.column.columnDef.cell,r.getContext())},r.id)),M?e.jsx(K,{}):null]},l.id)):e.jsx(B,{children:e.jsx(K,{colSpan:Q.length+(M?1:0),className:"h-24 text-center",children:"No results found."})})})]})}),de&&e.jsxs("div",{className:"mt-4 flex flex-col gap-2 text-sm text-muted-foreground sm:flex-row sm:items-center sm:justify-between",children:[e.jsxs("div",{children:["Showing ",t.length," of ",L," ",I.toLowerCase()]}),e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsxs("span",{children:["Page ",k+1," of ",Math.max(1,Math.ceil(L/R))]}),e.jsx(T,{variant:"outline",size:"sm",onClick:le,disabled:k===0,children:"Previous"}),e.jsx(T,{variant:"outline",size:"sm",onClick:ce,disabled:!O,children:"Next"})]})]})]})}const Ve=720;function We(){return e.jsxs("div",{className:"space-y-4","aria-label":"Loading entities",role:"status",children:[e.jsxs("div",{className:"flex items-center justify-between gap-3",children:[e.jsx(E,{className:"h-9 max-w-sm flex-1"}),e.jsx(E,{className:"h-9 w-28"})]}),e.jsxs("div",{className:"overflow-hidden rounded-lg border",children:[e.jsx("div",{className:"border-b px-4 py-3",children:e.jsx(E,{className:"h-3 w-1/3"})}),e.jsx("div",{className:"divide-y",children:Array.from({length:5},(t,s)=>e.jsxs("div",{className:"flex items-center gap-3 px-4 py-3",children:[e.jsx(E,{className:"h-3 flex-1"}),e.jsx(E,{className:"h-3 w-16 shrink-0"})]},s))})]})]})}function et({title:t,actions:s,controls:n,table:a,children:i,loading:o=!1,error:c=null,onRetry:h,empty:j=e.jsx("p",{className:"py-12 text-center text-sm text-muted-foreground",children:"No records."})}){return e.jsxs("div",{className:"@container space-y-4",children:[e.jsxs("div",{className:"flex min-w-0 items-center gap-2",children:[typeof t=="string"?e.jsx("h2",{className:"text-lg font-semibold",children:t}):t,s]}),e.jsxs("div",{children:[n,o?e.jsx(We,{}):c!==null?e.jsxs("div",{role:"alert",className:"rounded-lg border border-destructive/30 bg-destructive/5 px-4 py-6 text-sm text-destructive",children:[c,h?e.jsx(T,{className:"ml-3",variant:"outline",size:"sm",onClick:h,children:"Retry"}):null]}):i!==void 0?i:a?e.jsx(Ue,{...a}):j]})]})}function De(t,s){return s?.properties?ne(s.properties).map(([n,a])=>({key:n,prop:a})):Object.keys(t.metadata??{}).map(n=>({key:n,prop:{}}))}function Ge({entity:t,schema:s,icon:n}){return e.jsxs(e.Fragment,{children:[e.jsx(ie,{metadata:t.metadata,metadataSchema:s?{...s}:void 0,name:t.name,typeIcon:n,className:"h-6 w-6 shrink-0"}),e.jsx("h2",{className:"truncate text-lg font-semibold leading-tight",children:t.name})]})}function Ze({entity:t,schema:s}){const n=_e(s?{...s}:void 0).filter(({key:a,prop:i})=>i["x-table-column"]===!0&&!i["x-image"]&&t.metadata?.[a]!==void 0&&t.metadata[a]!==null&&t.metadata[a]!=="");return n.length?e.jsx("p",{"data-testid":"record-summary",className:"-mt-2 truncate text-sm text-muted-foreground tabular-nums",children:n.map(({key:a,prop:i},o)=>e.jsxs("span",{children:[o>0?" · ":null,e.jsx(U,{value:t.metadata?.[a],prop:i})]},a))}):null}function qe({details:t,summary:s,children:n,rootRef:a,narrow:i}){return e.jsx("div",{ref:a,className:"min-w-0 space-y-4",children:i?e.jsxs(e.Fragment,{children:[s,e.jsx("section",{"aria-label":"Details","data-testid":"record-details",children:t}),n]}):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:t}),n]})})}function tt({entity:t,owner:s,schema:n,title:a,actions:i,details:o,summary:c,children:h,layout:j="record"}){const y=x.useRef(null),v=ve(y,Ve),N=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===void 0?e.jsx(Ge,{entity:t,schema:n}):a}),i]}),j==="content"?h:e.jsx(qe,{rootRef:y,narrow:v,details:o===void 0?e.jsx(we,{fields:De(t,n),values:t.metadata??{},context:{ownerSlug:s}}):o,summary:c===void 0?e.jsx(Ze,{entity:t,schema:n}):c,children:h})]});return j==="content"?N:e.jsx("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:N})}export{ie as E,Ve as N,Me as S,Ue as a,et as b,We as c,tt as d,se as e,qe as f,Ze as g,Ge as h};
|
|
2
|
-
//# sourceMappingURL=entity-pages-18xSANrS.js.map
|
|
@@ -1,2 +0,0 @@
|
|
|
1
|
-
import{r as _,j as N,B as xe,cU as lt,fF as ut,fG as dt,c4 as ft,i as ve,cT as yt,m as ye,by as ht,ds as mt}from"./index-CdDNNAx2.js";function Ge(t){let n=Number.POSITIVE_INFINITY,r=Number.POSITIVE_INFINITY,i=Number.NEGATIVE_INFINITY,l=Number.NEGATIVE_INFINITY;for(const c of t)n=Math.min(n,c.x-c.w/2),i=Math.max(i,c.x+c.w/2),r=Math.min(r,c.y-c.h/2),l=Math.max(l,c.y+c.h/2);return Number.isFinite(n)?{x0:n,y0:r,x1:i,y1:l}:null}const be=(t,n,r)=>t<n?n:t>r?r:t;function pt(t,n,r,{padding:i=.12,minZoom:l=.2,maxZoom:c=1.2}={}){const x=Math.max(1,t.x1-t.x0),w=Math.max(1,t.y1-t.y0),E=be(Math.min(n/(x*(1+i)),r/(w*(1+i))),l,c);return{z:E,x:n/2-(t.x0+t.x1)/2*E,y:r/2-(t.y0+t.y1)/2*E}}function xt(t,n,r=0){if(t===n){const h=t.x+t.w/2,p=t.y-t.h/2;return[{x:h-30,y:p},{x:h-30,y:p-26},{x:h+22,y:p-26},{x:h+22,y:t.y-6},{x:h,y:t.y-6}]}const i=r*8,l=t.x+t.w/2,c=t.y+be(i,-t.h/2+6,t.h/2-6),x=n.x-n.w/2,w=n.y+be(i,-n.h/2+6,n.h/2-6);if(x-l>=40){const h=(l+x)/2+i;return[{x:l,y:c},{x:h,y:c},{x:h,y:w},{x,y:w}]}const E=Math.max(t.y+t.h/2,n.y+n.h/2)+24+Math.abs(i),k=Math.min(t.y-t.h/2,n.y-n.h/2)-24-Math.abs(i),g=(c+w)/2,u=Math.abs(E-g)<=Math.abs(k-g)?E:k,f=l+24+Math.abs(i),y=x-24-Math.abs(i);return[{x:l,y:c},{x:f,y:c},{x:f,y:u},{x:y,y:u},{x:y,y:w},{x,y:w}]}function gt(t,n,r){const i=r.x-n.x,l=r.y-n.y,c=i*i+l*l,x=c?be(((t.x-n.x)*i+(t.y-n.y)*l)/c,0,1):0;return Math.hypot(t.x-(n.x+x*i),t.y-(n.y+x*l))}function wt(t,n){let r=Number.POSITIVE_INFINITY;for(let i=0;i<n.length-1;i++)r=Math.min(r,gt(t,n[i],n[i+1]));return r}function vt(t,n){return Math.abs(n.x-t.x)<=t.w/2&&Math.abs(n.y-t.y)<=t.h/2}class ie{cells=new Set;static CELL_W=12;static CELL_H=16;keys(n){const r=[],i=Math.floor(n.x0/ie.CELL_W),l=Math.floor(n.x1/ie.CELL_W),c=Math.floor(n.y0/ie.CELL_H),x=Math.floor(n.y1/ie.CELL_H);for(let w=i;w<=l;w++)for(let E=c;E<=x;E++)r.push(w*1e5+E);return r}isFree(n){return this.keys(n).every(r=>!this.cells.has(r))}reserve(n){for(const r of this.keys(n))this.cells.add(r)}}function bt(t,n,r,i,l){const c=t.slice(0,-1).map((u,f)=>({i:f,length:Math.hypot(t[f+1].x-u.x,t[f+1].y-u.y)})).sort((u,f)=>f.length-u.length);if(c.length===0)return null;const x=u=>({x0:u.x-n/2,x1:u.x+n/2,y0:u.y-r/2,y1:u.y+r/2}),w=u=>({x:(t[u].x+t[u+1].x)/2,y:(t[u].y+t[u+1].y)/2});for(const{i:u,length:f}of c){if(!l&&f<n*.7)break;const y=w(u);if(i.isFree(x(y)))return i.reserve(x(y)),y}if(!l)return null;const E=w(c[0].i),g=[-1,1,-1.6,1.6].map(u=>({x:E.x,y:E.y+u*(r+12)})).find(u=>i.isFree(x(u)))??E;return i.reserve(x(g)),g}const kt=t=>N.jsx(yt,{icon:t||null,className:"h-4 w-4"}),Mt='600 14px "DM Sans", system-ui, sans-serif',Et='400 11px "DM Sans", system-ui, sans-serif',St='500 9px "DM Sans", system-ui, sans-serif',Tt='500 11px "DM Sans", system-ui, sans-serif',he=18,Be=8;function qe(t){const n=getComputedStyle(t),r=(i,l)=>n.getPropertyValue(i).trim()||l;return{foreground:r("--foreground","#141414"),muted:r("--muted-foreground","#545454"),card:r("--card","#ffffff"),background:r("--background","#fcfcfb"),border:r("--border","#e7e4dc"),primary:r("--primary","#2f63e8"),mutedSurface:r("--muted","#f3f1ea")}}function ge(t,n,r){if(t.measureText(n).width<=r)return n;let i=0,l=n.length;for(;i<l;){const c=Math.ceil((i+l)/2);t.measureText(`${n.slice(0,c)}…`).width<=r?i=c:l=c-1}return`${n.slice(0,i)}…`}function _t(t,n,r,i){const l=Math.hypot(r.x-n.x,r.y-n.y);if(l<1)return;const c=(r.x-n.x)/l,x=(r.y-n.y)/l;t.moveTo(r.x-c*i-x*i*.55,r.y-x*i+c*i*.55),t.lineTo(r.x,r.y),t.lineTo(r.x-c*i+x*i*.55,r.y-x*i-c*i*.55)}function tn({boxes:t,edges:n,label:r,onOpenBox:i,openLabel:l,onConnect:c,renderIcon:x=kt,className:w}){const E=_.useRef(null),k=_.useRef(null),g=_.useRef(null),u=_.useRef({z:1,x:0,y:0}),f=_.useRef({w:0,h:0,dpr:1}),y=_.useRef(!0),h=_.useRef(new Map),p=_.useRef(null),L=_.useRef(null),O=_.useRef(new Map),C=_.useRef(null),A=_.useRef(""),q=_.useRef(!1),[a,I]=_.useState(()=>new Map),[S,$]=_.useState(null),[Y,R]=_.useState(null),[j,Q]=_.useState(null),[B,Oe]=_.useState(null),[Je,Ze]=_.useState(0),{placed:U,movedIds:me}=_.useMemo(()=>{const o=new Map,e=new Set;for(const s of t){const d=a.get(s.id);d&&d.from.x===s.x&&d.from.y===s.y?(o.set(s.id,{...s,x:d.at.x,y:d.at.y}),e.add(s.id)):o.set(s.id,s)}return{placed:o,movedIds:e}},[t,a]),re=_.useMemo(()=>{const o=new Map;for(const s of n){const d=[s.source,s.target].sort().join("|");o.set(d,[...o.get(d)??[],s])}const e=new Map;for(const s of n){const d=U.get(s.source),v=U.get(s.target);if(!d||!v)continue;if(s.route&&!me.has(d.id)&&!me.has(v.id)){e.set(s.id,s.route);continue}const b=o.get([s.source,s.target].sort().join("|"))??[s];e.set(s.id,xt(d,v,b.indexOf(s)-(b.length-1)/2))}return e},[n,U,me]),W=_.useCallback(()=>{y.current=!0},[]),ce=_.useCallback(()=>{const o=Ge([...U.values()]),{w:e,h:s}=f.current;!o||!e||!s||(u.current=pt(o,e,s),q.current=!0,W())},[U,W]),ae=o=>{u.current=o,q.current=!1,W()},Ce=o=>{const e=Ge(o),{w:s,h:d}=f.current;if(!e||!s||!d)return;const v=u.current,b=24;e.x0*v.z+v.x>=b&&e.y0*v.z+v.y>=b&&e.x1*v.z+v.x<=s-b&&e.y1*v.z+v.y<=d-b||ae({...v,x:s/2-(e.x0+e.x1)/2*v.z,y:d/2-(e.y0+e.y1)/2*v.z})},Qe=o=>{Oe(o);const e=U.get(o);e&&Ce([e])},se=t.map(o=>`${o.id}@${Math.round(o.x)},${Math.round(o.y)}`).join(";");_.useEffect(()=>{!se||A.current===se||f.current.w&&(A.current=se,ce())},[se,ce]);const Ae=_.useRef(ce);Ae.current=ce;const Pe=_.useRef(se);Pe.current=se,_.useEffect(()=>{const o=E.current,e=k.current;if(!o||!e||typeof ResizeObserver>"u")return;const s=()=>{const v=window.devicePixelRatio||1,b=o.clientWidth,H=o.clientHeight;f.current={w:b,h:H,dpr:v},e.width=Math.round(b*v),e.height=Math.round(H*v);const F=Pe.current;F&&b&&H&&(A.current!==F||q.current)&&(A.current=F,Ae.current()),W()};s();const d=new ResizeObserver(s);return d.observe(o),()=>d.disconnect()},[W]);const[et,tt]=_.useState(0);_.useEffect(()=>{const o=g.current,e=k.current;if(!o||!e)return;const s=qe(e).muted;for(const d of o.querySelectorAll("[data-icon-key]")){const v=d.dataset.iconKey??"";if(h.current.has(v))continue;const b=d.querySelector("svg"),H=b?null:d.querySelector("img")?.src;if(!b&&!H){h.current.set(v,d.textContent??"");continue}const F=new Image;if(F.onload=W,F.onerror=()=>{h.current.delete(v),tt(T=>T+1)},b){const T=b.cloneNode(!0);T.getAttribute("width")||T.setAttribute("width","24"),T.getAttribute("height")||T.setAttribute("height","24");const M=new XMLSerializer().serializeToString(T).replaceAll("currentColor",s);F.src=`data:image/svg+xml;charset=utf-8,${encodeURIComponent(M)}`}else H&&(F.src=H);h.current.set(v,F)}},[t,Je,et,W]);const le=(o,e)=>{const s=u.current;return{x:(o-s.x)/s.z,y:(e-s.y)/s.z}},ke=(o,e)=>{const s=u.current,d=le(o,e),v=S&&S.kind!=="edge"?U.get(S.box.id):void 0;if(v&&c){const T=Ke(v);if(Math.hypot(T.x*s.z+s.x-o,T.y*s.z+s.y-e)<=Be+3)return{kind:"handle",box:v}}const b=[...U.values()];for(let T=b.length-1;T>=0;T--)if(vt(b[T],d))return{kind:"box",box:b[T]};let H=null,F=7/s.z;for(const T of n){const M=re.get(T.id);if(!M)continue;const V=wt(d,M);V<F&&(F=V,H=T)}return H?{kind:"edge",edge:H}:null},ee=_.useMemo(()=>{const o=new Set;for(const s of[Y,j])s&&o.add(s);S?.kind==="edge"&&o.add(S.edge.id);const e=S&&S.kind!=="edge"?S.box.id:B;if(e)for(const s of n)(s.source===e||s.target===e)&&o.add(s.id);for(const s of n)s.dimmed&&o.delete(s.id);return o},[n,S,Y,j,B]);_.useEffect(W,[U,re,ee,S,B,W]);const ze=_.useCallback(()=>{const o=k.current,e=o?.getContext("2d");if(!o||!e)return;const{w:s,h:d,dpr:v}=f.current,b=qe(o),H=getComputedStyle(o),F=new Map,T=m=>{let P=F.get(m);return P===void 0&&(P=H.getPropertyValue(m).trim(),F.set(m,P)),P},{z:M,x:V,y:X}=u.current,ue=m=>({x:m.x*M+V,y:m.y*M+X});e.setTransform(v,0,0,v,0,0),e.clearRect(0,0,s,d);const Se=S&&S.kind!=="edge"?S.box.id:null;e.lineJoin="round";for(const m of n){const P=re.get(m.id);if(!P)continue;const z=P.map(ue),D=ee.has(m.id);e.globalAlpha=m.dimmed?.15:D?.95:.55,e.strokeStyle=D?b.foreground:b.muted,e.lineWidth=D?1.75:1.25,e.beginPath(),e.moveTo(z[0].x,z[0].y);for(const G of z.slice(1))e.lineTo(G.x,G.y);m.directed&&_t(e,z[z.length-2],z[z.length-1],8),e.stroke()}const $e=new ie;for(const m of U.values()){const P=ue(m),z=m.w*M,D=m.h*M,G=P.x-z/2,K=P.y-D/2;if($e.reserve({x0:G,y0:K,x1:G+z,y1:K+D}),G>s||K>d||G+z<0||K+D<0)continue;const de=Se===m.id||C.current?.over?.id===m.id;e.globalAlpha=m.dimmed?.25:1,e.beginPath(),e.roundRect(G,K,z,D,8*M),e.fillStyle=m.muted?b.mutedSurface:b.card,e.fill(),e.lineWidth=de||B===m.id?1.5:1,e.strokeStyle=de||B===m.id?b.primary:b.border,e.stroke();const fe=m.accent&&T(m.accent);if(fe&&(e.save(),e.clip(),e.fillStyle=fe,e.fillRect(G,K,3*M,D),e.restore()),14*M<5)continue;const te=12*M,J=16*M,ne=m.meta?K+D/2-8*M:K+D/2,oe=h.current.get(m.icon??"");oe instanceof HTMLImageElement&&oe.complete&&oe.naturalWidth>0?e.drawImage(oe,G+te,ne-J/2,J,J):typeof oe=="string"&&oe&&(e.font=`${14*M}px system-ui, sans-serif`,e.textBaseline="middle",e.textAlign="left",e.fillText(oe,G+te,ne));const pe=G+te+J+8*M,Fe=12*M;e.textBaseline="middle",e.textAlign="left";let Ie=G+z-Fe-pe;if(m.badge){e.font=St.replace("9px",`${9*M}px`);const We=ge(e,m.badge.toUpperCase(),Ie*.35),Ne=e.measureText(We).width+8*M,He=G+z-Fe-Ne;e.strokeStyle=b.border,e.lineWidth=1,e.beginPath(),e.roundRect(He,ne-7*M,Ne,14*M,3*M),e.stroke(),e.fillStyle=b.muted,e.fillText(We,He+4*M,ne+.5),Ie-=Ne+6*M}e.font=Mt.replace("14px",`${14*M}px`),e.fillStyle=b.foreground,e.fillText(ge(e,m.title,Ie),pe,ne+.5),m.meta&&(e.font=Et.replace("11px",`${11*M}px`),e.fillStyle=b.muted,e.fillText(ge(e,m.meta,G+z-te-pe),pe,K+D/2+10*M))}const Te=C.current,_e=Te?.from??(Se?U.get(Se):void 0);if(c&&_e&&_e.w*M>=60){const m=ue(Ke(_e));if(e.globalAlpha=1,Te){const P=ue(Te.to);e.strokeStyle=b.primary,e.lineWidth=2,e.setLineDash([6,4]),e.beginPath(),e.moveTo(m.x,m.y),e.lineTo(P.x,P.y),e.stroke(),e.setLineDash([])}e.fillStyle=b.card,e.strokeStyle=b.primary,e.lineWidth=1.5,e.beginPath(),e.arc(m.x,m.y,Be,0,Math.PI*2),e.fill(),e.stroke(),e.beginPath(),e.moveTo(m.x-4,m.y),e.lineTo(m.x+4,m.y),e.moveTo(m.x,m.y-4),e.lineTo(m.x,m.y+4),e.stroke()}e.font=Tt,e.textAlign="center",e.textBaseline="middle";const ct=(m,P,z,D)=>{e.globalAlpha=1,e.fillStyle=b.background,e.strokeStyle=z?b.foreground:b.border,e.lineWidth=1,e.beginPath(),e.roundRect(m.x-D/2,m.y-he/2,D,he,5),e.fill(),e.stroke(),e.fillStyle=z?b.foreground:b.muted,e.fillText(P,m.x,m.y+.5)},at=[...n].sort((m,P)=>Number(ee.has(P.id))-Number(ee.has(m.id)));for(const m of at){const P=re.get(m.id);if(!P||m.dimmed&&!ee.has(m.id))continue;const z=P.map(ue),D=ee.has(m.id),K=(D?m.details:[m.summary]).map(J=>ge(e,J,200)),de=Math.max(...K.map(J=>e.measureText(J).width))+14,fe=K.length*(he+2);if(!D&&M<.45)continue;const te=bt(z,de,fe,$e,D);te&&K.forEach((J,ne)=>{ct({x:te.x,y:te.y-fe/2+(he+2)*ne+he/2},J,D,de)})}e.globalAlpha=1},[n,re,U,ee,S,B,c]);_.useEffect(()=>{let o=0;const e=()=>{o=requestAnimationFrame(e),y.current&&(y.current=!1,ze())};return o=requestAnimationFrame(e),document.addEventListener("visibilitychange",W),()=>{cancelAnimationFrame(o),document.removeEventListener("visibilitychange",W)}},[ze,W]),_.useEffect(()=>{const o=new MutationObserver(()=>{h.current.clear(),Ze(e=>e+1),W()});return o.observe(document.documentElement,{attributes:!0,attributeFilter:["class","data-theme","style"]}),()=>o.disconnect()},[W]);const Me=(o,e,s)=>{const d=u.current,v=Math.min(3,Math.max(.15,d.z*o));ae({z:v,x:e-(e-d.x)*(v/d.z),y:s-(s-d.y)*(v/d.z)})},Ee=o=>{const e=k.current?.getBoundingClientRect();return{x:o.clientX-(e?.left??0),y:o.clientY-(e?.top??0)}},nt=o=>{if(o.button!==0&&o.pointerType==="mouse")return;o.currentTarget.setPointerCapture(o.pointerId);const e=Ee(o);if(o.pointerType==="touch"&&(O.current.set(o.pointerId,e),O.current.size===2)){const[v,b]=[...O.current.values()];p.current=null,C.current=null,L.current={d:Math.hypot(v.x-b.x,v.y-b.y)||1,mid:{x:(v.x+b.x)/2,y:(v.y+b.y)/2}};return}const s=ke(e.x,e.y),d={start:e,last:e,hit:s,moved:!1};if(s?.kind==="handle")C.current={from:s.box,to:le(e.x,e.y),over:null};else if(s?.kind==="box"){const v=le(e.x,e.y);d.grab={x:s.box.x-v.x,y:s.box.y-v.y}}p.current=d},ot=o=>{const e=Ee(o);O.current.has(o.pointerId)&&O.current.set(o.pointerId,e);const s=L.current;if(s&&O.current.size===2){const[T,M]=[...O.current.values()],V=Math.hypot(T.x-M.x,T.y-M.y)||1,X={x:(T.x+M.x)/2,y:(T.y+M.y)/2};ae({...u.current,x:u.current.x+X.x-s.mid.x,y:u.current.y+X.y-s.mid.y}),Me(V/s.d,X.x,X.y),L.current={d:V,mid:X};return}const d=p.current;if(!d){const T=ke(e.x,e.y);$(V=>It(V,T)?V:T);const M=k.current;M&&(M.style.cursor=T?.kind==="handle"?"crosshair":T?"pointer":"grab");return}const v=e.x-d.last.x,b=e.y-d.last.y;if(d.last=e,!d.moved&&Math.hypot(e.x-d.start.x,e.y-d.start.y)>4&&(d.moved=!0),!d.moved)return;const H=C.current;if(H){H.to=le(e.x,e.y);const T=ke(e.x,e.y);H.over=T?.kind==="box"?T.box:null,W();return}const F=d.hit;if(F?.kind==="box"&&d.grab){const T=le(e.x,e.y),M=t.find(X=>X.id===F.box.id);if(!M)return;const V={x:T.x+d.grab.x,y:T.y+d.grab.y};I(X=>new Map(X).set(M.id,{at:V,from:{x:M.x,y:M.y}}));return}ae({...u.current,x:u.current.x+v,y:u.current.y+b}),k.current&&(k.current.style.cursor="grabbing")},rt=o=>{if(O.current.delete(o.pointerId),L.current){O.current.size<2&&(L.current=null),p.current=null;return}const e=p.current;p.current=null;const s=C.current;if(C.current=null,!e)return;if(k.current&&(k.current.style.cursor="grab"),s){W(),s.over&&c&&c(s.from.id,s.over.id);return}if(e.moved)return;const d=e.hit;d?.kind==="box"?i(d.box.id):d?.kind==="edge"?R(v=>v===d.edge.id?null:d.edge.id):R(null)},st=o=>{O.current.delete(o.pointerId),L.current=null,p.current=null,C.current=null,W()};_.useEffect(()=>{const o=k.current;if(!o)return;const e=s=>{s.preventDefault();const d=Ee(s);s.ctrlKey||s.metaKey?Me(Math.exp(-s.deltaY*(s.ctrlKey?.01:.002)),d.x,d.y):ae({...u.current,x:u.current.x-s.deltaX,y:u.current.y-s.deltaY})};return o.addEventListener("wheel",e,{passive:!1}),()=>o.removeEventListener("wheel",e)});const De=o=>Me(o,f.current.w/2,f.current.h/2),it=[...new Set(t.map(o=>o.icon??""))];return N.jsxs("div",{ref:E,className:ve("relative h-full w-full overflow-hidden",w),children:[N.jsx("canvas",{ref:k,"aria-hidden":"true",className:"block h-full w-full cursor-grab touch-none",onPointerDown:nt,onPointerMove:ot,onPointerUp:rt,onPointerCancel:st,onPointerLeave:()=>{p.current||$(null)}}),N.jsxs("ul",{ref:g,"aria-label":r,className:"sr-only",children:[it.map(o=>N.jsx("li",{"aria-hidden":"true","data-icon-key":o,children:x(o)},`icon:${o}`)),t.map(o=>N.jsx("li",{children:N.jsx("button",{type:"button",onClick:()=>i(o.id),onFocus:()=>Qe(o.id),onBlur:()=>Oe(null),children:l(o)})},o.id)),n.map(o=>N.jsx("li",{"data-revealed":ee.has(o.id)||void 0,children:N.jsx("button",{type:"button","aria-pressed":Y===o.id,onClick:()=>R(e=>e===o.id?null:o.id),onFocus:()=>{Q(o.id);const e=re.get(o.id);e&&Ce(e.map(s=>({...s,w:0,h:0})))},onBlur:()=>Q(null),children:o.ariaLabel})},o.id))]}),N.jsxs("div",{className:"absolute bottom-3 left-3 flex flex-col gap-1",children:[N.jsx(xe,{type:"button",variant:"outline",size:"icon",className:"h-7 w-7","aria-label":"Zoom in",onClick:()=>De(1.25),children:N.jsx(lt,{className:"h-3.5 w-3.5"})}),N.jsx(xe,{type:"button",variant:"outline",size:"icon",className:"h-7 w-7","aria-label":"Zoom out",onClick:()=>De(.8),children:N.jsx(ut,{className:"h-3.5 w-3.5"})}),N.jsx(xe,{type:"button",variant:"outline",size:"icon",className:"h-7 w-7","aria-label":"Fit to view",onClick:ce,children:N.jsx(dt,{className:"h-3.5 w-3.5"})}),me.size>0?N.jsx(xe,{type:"button",variant:"outline",size:"icon",className:"h-7 w-7","aria-label":"Reset layout",onClick:()=>I(new Map),children:N.jsx(ft,{className:"h-3.5 w-3.5"})}):null]})]})}const Ke=t=>({x:t.x+t.w/2,y:t.y});function It(t,n){return!t||!n?t===n:t.kind==="edge"||n.kind==="edge"?t.kind==="edge"&&n.kind==="edge"&&t.edge.id===n.edge.id:t.kind===n.kind&&t.box.id===n.box.id}function nn({label:t,fill:n=!1}){return N.jsxs("div",{role:"status","aria-label":t,"aria-busy":"true",className:ve("flex min-w-0 flex-col gap-3",n&&"min-h-0 flex-1"),children:[N.jsx("div",{className:"flex min-w-0 items-center gap-3",children:N.jsx("div",{"aria-hidden":"true",className:"min-w-0 flex-1",children:N.jsx(ye,{className:"h-5 w-3/4 max-w-xl rounded-none"})})}),N.jsx("div",{className:ve("relative flex min-h-0 flex-col",n&&"flex-1"),"aria-hidden":"true",children:N.jsxs("div",{className:ve("relative min-h-[420px]",n?"flex-1":"h-[70vh]"),children:[N.jsxs("div",{className:"absolute top-1/2 left-1/2 flex h-16 w-52 -translate-x-1/2 -translate-y-1/2 items-center gap-3 rounded-xl border border-border bg-card px-4",children:[N.jsx(ye,{className:"h-4 w-4 shrink-0 rounded-none"}),N.jsxs("div",{className:"flex flex-1 flex-col gap-2",children:[N.jsx(ye,{className:"h-3.5 w-24 rounded-none"}),N.jsx(ye,{className:"h-2.5 w-32 rounded-none"})]})]}),N.jsx("div",{className:"absolute bottom-3 left-3 flex flex-col gap-1",children:["in","out","fit"].map(r=>N.jsx("div",{className:"flex h-7 w-7 items-center justify-center border border-input bg-background",children:N.jsx(ye,{className:"h-3 w-3 rounded-none"})},r))})]})})]})}function we(t){throw new Error('Could not dynamically require "'+t+'". Please configure the dynamicRequireTargets or/and ignoreDynamicRequires option of @rollup/plugin-commonjs appropriately for this require call to work.')}var Re={exports:{}},Ye;function Nt(){return Ye||(Ye=1,(function(t,n){(function(r){t.exports=r()})(function(){return(function(){function r(i,l,c){function x(k,g){if(!l[k]){if(!i[k]){var u=typeof we=="function"&&we;if(!g&&u)return u(k,!0);if(w)return w(k,!0);var f=new Error("Cannot find module '"+k+"'");throw f.code="MODULE_NOT_FOUND",f}var y=l[k]={exports:{}};i[k][0].call(y.exports,function(h){var p=i[k][1][h];return x(p||h)},y,y.exports,r,i,l,c)}return l[k].exports}for(var w=typeof we=="function"&&we,E=0;E<c.length;E++)x(c[E]);return x}return r})()({1:[function(r,i,l){Object.defineProperty(l,"__esModule",{value:!0}),l.default=void 0;function c(f){"@babel/helpers - typeof";return c=typeof Symbol=="function"&&typeof Symbol.iterator=="symbol"?function(y){return typeof y}:function(y){return y&&typeof Symbol=="function"&&y.constructor===Symbol&&y!==Symbol.prototype?"symbol":typeof y},c(f)}function x(f,y){if(!(f instanceof y))throw new TypeError("Cannot call a class as a function")}function w(f,y){for(var h=0;h<y.length;h++){var p=y[h];p.enumerable=p.enumerable||!1,p.configurable=!0,"value"in p&&(p.writable=!0),Object.defineProperty(f,k(p.key),p)}}function E(f,y,h){return y&&w(f.prototype,y),Object.defineProperty(f,"prototype",{writable:!1}),f}function k(f){var y=g(f,"string");return c(y)=="symbol"?y:y+""}function g(f,y){if(c(f)!="object"||!f)return f;var h=f[Symbol.toPrimitive];if(h!==void 0){var p=h.call(f,y);if(c(p)!="object")return p;throw new TypeError("@@toPrimitive must return a primitive value.")}return String(f)}l.default=(function(){function f(){var y=this,h=arguments.length>0&&arguments[0]!==void 0?arguments[0]:{},p=h.defaultLayoutOptions,L=p===void 0?{}:p,O=h.algorithms,C=O===void 0?["layered","stress","mrtree","radial","force","disco","sporeOverlap","sporeCompaction","rectpacking"]:O,A=h.workerFactory,q=h.workerUrl;if(x(this,f),this.defaultLayoutOptions=L,this.initialized=!1,typeof q>"u"&&typeof A>"u")throw new Error("Cannot construct an ELK without both 'workerUrl' and 'workerFactory'.");var a=A;typeof q<"u"&&typeof A>"u"&&(a=function($){return new Worker($)});var I=a(q);if(typeof I.postMessage!="function")throw new TypeError("Created worker does not provide the required 'postMessage' function.");this.worker=new u(I),this.worker.postMessage({cmd:"register",algorithms:C}).then(function(S){return y.initialized=!0}).catch(console.err)}return E(f,[{key:"layout",value:function(h){var p=arguments.length>1&&arguments[1]!==void 0?arguments[1]:{},L=p.layoutOptions,O=L===void 0?this.defaultLayoutOptions:L,C=p.logging,A=C===void 0?!1:C,q=p.measureExecutionTime,a=q===void 0?!1:q;return h?this.worker.postMessage({cmd:"layout",graph:h,layoutOptions:O,options:{logging:A,measureExecutionTime:a}}):Promise.reject(new Error("Missing mandatory parameter 'graph'."))}},{key:"knownLayoutAlgorithms",value:function(){return this.worker.postMessage({cmd:"algorithms"})}},{key:"knownLayoutOptions",value:function(){return this.worker.postMessage({cmd:"options"})}},{key:"knownLayoutCategories",value:function(){return this.worker.postMessage({cmd:"categories"})}},{key:"terminateWorker",value:function(){this.worker&&this.worker.terminate()}}])})();var u=(function(){function f(y){var h=this;if(x(this,f),y===void 0)throw new Error("Missing mandatory parameter 'worker'.");this.resolvers={},this.worker=y,this.worker.onmessage=function(p){setTimeout(function(){h.receive(h,p)},0)}}return E(f,[{key:"postMessage",value:function(h){var p=this.id||0;this.id=p+1,h.id=p;var L=this;return new Promise(function(O,C){L.resolvers[p]=function(A,q){A?(L.convertGwtStyleError(A),C(A)):O(q)},L.worker.postMessage(h)})}},{key:"receive",value:function(h,p){var L=p.data,O=h.resolvers[L.id];O&&(delete h.resolvers[L.id],L.error?O(L.error):O(null,L.data))}},{key:"terminate",value:function(){this.worker&&this.worker.terminate()}},{key:"convertGwtStyleError",value:function(h){if(h){var p=h.__java$exception;p&&(p.cause&&p.cause.backingJsObject&&(h.cause=p.cause.backingJsObject,this.convertGwtStyleError(h.cause)),delete h.__java$exception)}}}])})()},{}],2:[function(r,i,l){var c=r("./elk-api.js").default;Object.defineProperty(i.exports,"__esModule",{value:!0}),i.exports=c,c.default=c},{"./elk-api.js":1}]},{},[2])(2)})})(Re)),Re.exports}var Rt=Nt();const jt=ht(Rt);function Lt(t){return new Worker("/assets/elk-worker.min-BENGc9gn.js",{name:t?.name})}const Ot=200,Ct=320,Xe=56,At=7.4,Pt=5.9,zt=84,Dt=48;function $t(t,n){return Math.round(Math.min(Ct,Math.max(Ot,zt+t.length*At,Dt+n.length*Pt)))}function Ft(t,n){const r=[];return t>0&&r.push(`${t} ${t===1?"field":"fields"}`),typeof n=="number"&&r.push(`${n.toLocaleString()} ${n===1?"record":"records"}`),r.join(" · ")}function Ue(t,n){return t.slug<n.slug?-1:t.slug>n.slug?1:0}function Wt(t,n){const r=new Set;return t.filter(i=>i.status!=="active"||i.organization_slug&&i.organization_slug!==n||r.has(i.slug)?!1:(r.add(i.slug),!0))}function Ht(t){const n=t.metadata_schema;if(!n||typeof n!="object")return 0;const r=n.properties;return!r||typeof r!="object"?0:Object.keys(r).length}function Gt(t){const{entityTypes:n,relationshipTypes:r,rulesBySlug:i}=t,l=t.ownerSlug??"",c=[...n].sort(Ue),x=Wt(r,l).sort(Ue),w=a=>!a.organization_slug||a.organization_slug===l,E=a=>a.organization_slug||l,k=new Map;for(const a of c)k.set(a.slug,[...k.get(a.slug)??[],a]);const g=a=>(k.get(a.slug)?.length??0)>1?`${E(a)}:${a.slug}`:a.slug,u=new Set(c.filter(w).map(g)),f=a=>{const I=k.get(a)??[];return I.find(w)??(I.length===1?I[0]:void 0)},y=new Set(u),h=x.flatMap(a=>[...i[a.slug]??[]].sort((I,S)=>I.id-S.id).flatMap(I=>{const S=f(I.source_entity_type_slug),$=f(I.target_entity_type_slug);if(!S||!$)return[];const Y=g(S),R=g($);return!u.has(Y)&&!u.has(R)?[]:(y.add(Y),y.add(R),[{rt:a,source:Y,target:R}])})),p=c.filter(a=>y.has(g(a))),L=[],O=new Map,C=new Map;for(const{rt:a,source:I,target:S}of h){const $=`${a.slug}|${I}|${S}`,Y=C.get($);if(Y){Y.ruleCount+=1;continue}const R={slug:a.slug,label:a.name||a.slug,ruleCount:1};C.set($,R);const j=`${I}|${S}`,Q=O.get(j);if(Q){Q.data.relationships.push(R),Q.data.isSymmetric=Q.data.isSymmetric&&a.is_symmetric;continue}const B={id:`pair:${I}|${S}`,source:I,target:S,data:{relationships:[R],isSymmetric:a.is_symmetric}};O.set(j,B),L.push(B)}const A=new Map;for(const{rt:a,source:I,target:S}of h){const $=A.get(a.slug)??new Set;$.add(`${I}|${S}`),A.set(a.slug,$)}for(const{rt:a}of h)if(A.get(a.slug)?.size===1&&typeof a.relationship_count=="number")for(const I of C.values())I.slug===a.slug&&(I.linkCount=a.relationship_count);return{nodes:p.map(a=>{const I=a.name||a.slug,S=Ht(a),$=Ft(S,a.entity_count);return{id:g(a),width:$t(I,$),height:Xe,data:{slug:a.slug,label:I,icon:a.icon,isSystem:mt(a),organizationSlug:w(a)?void 0:E(a),metaLabel:$}}}),edges:L}}const Z=24,Bt=72,qt=16,Kt=48,Yt=64,je=16,Ut=720;function Vt(t,n){const r=new Map(t.map(c=>[c.id,c.id])),i=c=>{const x=r.get(c)??c;if(x===c)return c;const w=i(x);return r.set(c,w),w};for(const c of n)r.set(i(c.source),i(c.target));const l=new Map;for(const c of t){const x=i(c.id);l.set(x,[...l.get(x)??[],c])}return[...l.values()].sort((c,x)=>x.length-c.length)}function Xt(t,n,r,i){const l=new Map(t.flatMap((g,u)=>g.map(f=>[f.id,u]))),c=t.map(()=>({top:1/0,bottom:-1/0})),x=(g,u,f)=>{const y=c[l.get(g)??0];y.top=Math.min(y.top,u),y.bottom=Math.max(y.bottom,f)};for(const g of n)x(g.id,g.position.y,g.position.y+g.height);for(const g of r)for(const u of i.get(g.id)??[])x(g.source,u.y,u.y);let w=Z;const E=c.map(({top:g,bottom:u})=>{const f=w-g;return w=u+f+Kt,f}),k=g=>E[l.get(g)??0];for(const g of r){const u=i.get(g.id);u&&i.set(g.id,u.map(f=>({x:f.x,y:f.y+k(g.source)})))}return n.map(g=>({...g,position:{x:g.position.x,y:g.position.y+k(g.id)}}))}function Jt(t,n){const r=Z,i=Math.max(r+Ut,...n.map(w=>w.position.x+w.width));let l=n.length>0?Math.max(...n.map(w=>w.position.y+w.height))+Yt:Z;const c=[...new Set(t.map(w=>w.lane??0))].sort((w,E)=>w-E),x=[];for(const w of c){let E=r,k=0;for(const g of t.filter(u=>(u.lane??0)===w))E>r&&E+g.width>i&&(E=r,l+=k+je,k=0),x.push({...g,position:{x:E,y:l}}),E+=g.width+je,k=Math.max(k,g.height);l+=k+je*2}return x}let Ve=null;function Zt(){return Ve??=new jt({workerFactory:()=>new Lt}),Ve}const Le={"elk.algorithm":"layered","elk.direction":"RIGHT","elk.edgeRouting":"ORTHOGONAL","elk.layered.spacing.edgeEdgeBetweenLayers":"12","elk.layered.spacing.edgeNodeBetweenLayers":"24","elk.layered.spacing.nodeNodeBetweenLayers":"80","elk.spacing.nodeNode":"48","elk.spacing.edgeEdge":"14","elk.spacing.edgeNode":"24","elk.layered.considerModelOrder.strategy":"NODES_AND_EDGES","elk.layered.crossingMinimization.semiInteractive":"true"};async function Qt(t,{elk:n=Zt(),targetAspect:r}={}){const i=new Set;for(const a of t.edges)i.add(a.source),i.add(a.target);const l=t.nodes.some(a=>a.lane!==void 0),c=t.nodes.filter(a=>i.has(a.id)),x=l?Vt(c,t.edges):[c],w=x.flat(),E=t.nodes.filter(a=>!i.has(a.id)),k=l?[]:E,g=l?E:[],u=k.reduce((a,I)=>Math.max(a,I.width),0),f=k.length>0?Z+u+Bt:0,y=a=>({x:a.x+Z+f,y:a.y+Z});let h=[];const p=new Map;if(w.length>0){const a=t.edges.filter(R=>R.source!==R.target),I=R=>n.layout({id:"root",layoutOptions:l?{...R,"elk.partitioning.activate":"true","elk.separateConnectedComponents":"false"}:R,children:w.map(j=>({id:j.id,width:j.width,height:j.height,...l?{layoutOptions:{"elk.partitioning.partition":String(j.lane??1)}}:{}})),edges:a.map(j=>({id:j.id,sources:[j.layoutReversed?j.target:j.source],targets:[j.layoutReversed?j.source:j.target]}))});let S=await I(Le);const $=r&&S.width&&S.height?r*S.width/S.height:1;if($>1.08){const R=Number(Le["elk.spacing.nodeNode"]),j=Math.min($,2.2);S=await I({...Le,"elk.spacing.nodeNode":String(Math.round(Math.min(180,R*j+Xe*(j-1))))})}const Y=new Map((S.children??[]).map(R=>[R.id,R]));h=w.map(R=>{const j=Y.get(R.id);return{...R,position:y({x:j?.x??0,y:j?.y??0})}});for(const R of S.edges??[]){const j=(R.sections??[]).flatMap(B=>[B.startPoint,...B.bendPoints??[],B.endPoint]);if(j.length<2)continue;const Q=t.edges.find(B=>B.id===R.id)?.layoutReversed;p.set(R.id,(Q?[...j].reverse():j).map(y))}}let L=Z;const O=k.map(a=>{const I={x:Z,y:L};return L+=a.height+qt,{...a,position:I}});l&&(h=Xt(x,h,t.edges,p));const C=Jt(g,h),A=new Map([...h,...O,...C].map(a=>[a.id,a]));return{nodes:t.nodes.map(a=>A.get(a.id)??{...a,position:{x:Z,y:Z}}),edges:t.edges.map(a=>({...a,route:p.get(a.id)??null}))}}function on(t,n){return Qt(Gt(t),n)}export{nn as G,Xe as H,on as a,Gt as b,tn as c,Qt as l,$t as n,Wt as s};
|
|
2
|
-
//# sourceMappingURL=entity-schema-graph-uwZ-P0t8.js.map
|
|
@@ -1,2 +0,0 @@
|
|
|
1
|
-
import{eE as xn,j as t,aa as hn,$ as gn,dO as yn,u as Pe,eF as jn,i as Y,d0 as $t,eG as ct,r as j,eH as Ot,eI as vn,ex as _n,a2 as H,eJ as Je,L as W,bg as Le,bh as Qe,eK as bn,cz as Nn,eL as wn,eM as kn,de as Pt,eN as Cn,eO as An,aQ as Rn,eP as Sn,cB as $n,q as In,eQ as Tn,bR as Re,z as et,eR as gt,dA as Ge,I as En,dM as Ae,eS as Bt,eT as Ut,eU as Ye,eV as zt,ck as Kt,eW as Mn,eX as Dn,eY as Fn,eZ as Ln,B as O,e_ as dt,dj as ut,e$ as qt,f0 as Vt,f1 as On,aF as Ht,aG as Wt,aI as Jt,dF as Pn,dG as Bn,a7 as Qt,dH as Un,f2 as zn,c as Kn,H as qn,G as Vn,bz as Ue,cN as Hn,ad as Wn,f3 as mt,f4 as Jn,U as Qn,f5 as Gn,bT as Yn,ai as Ne,f6 as Gt,df as yt,ez as Zn,f7 as Xn,f8 as es,f9 as ts,fa as ns,c6 as ss,fb as rs,cb as as,fc as is,a4 as os,fd as ls,X as cs,dI as ds,cc as us,fe as ms,ff as ps,fg as fs,d as xs,v as hs,fh as gs,fi as ys,e9 as Se,fj as Yt,fk as js,fl as vs,fm as _s,fn as bs,fo as Ns,fp as ws,fq as ks,n as Cs,cQ as As,ed as Rs,cO as Ss,s as $s,t as Is,eg as Ts,fr as Es,fs as Ms,ft as Ds,fu as It,fv as Fs,fw as Ls,fx as Os,c2 as Ps,fy as ze,fz as Bs,fA as Us,fB as zs}from"./index-CdDNNAx2.js";import{D as Ks,A as qs,a as Vs,T as Hs,b as Ws,c as Js,d as Qs}from"./definition-comparison-BUDNuAN_.js";import{R as Gs,p as Ys,a as Zs,i as Xs,b as er}from"./run-initiator-B8IRlRd-.js";import{a as Zt}from"./use-automations-CdtiVLCv.js";import{l as tr,s as nr,J as sr}from"./renderer-DZ0w2k2r.js";import{S as rr}from"./schema-value-k19Ata7u.js";import{J as We}from"./json-diff-C-WQqyIf.js";import{C as Tt}from"./copy-button-BhXeXLIm.js";import{A as Et}from"./device-automation-Dp3faMvp.js";function Xt(e){const n=Array.isArray(e?.records)?e.records:Array.isArray(e?.current)?e.current:[];return[e?.from_entity_id??e?.entity_id,e?.to_entity_id].map(s=>{const a=n.find(i=>i&&typeof i=="object"&&"id"in i&&i.id===s);return{id:String(s??"unknown"),name:typeof a?.name=="string"?a.name:`Record ${String(s??"unknown")}`}})}function en(e,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"?e==="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.":e==="link"?"If approved, these records will be linked. Both records remain available.":"If approved, this relationship will be removed. Both records remain available."}function Va(e){const n=Xt(e.proposal);return{title:e.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(e.proposal?.relationship_type??e.proposal?.relationship_type_slug??"Relationship")},{type:"text",value:en(e.action,typeof e.status=="string"?e.status:void 0),muted:!0},...typeof e.reason=="string"&&e.reason?[{type:"text",label:"Why this needs approval",value:e.reason}]:[]],actions:[{id:"approve",label:"Approve",variant:"primary",icon:"check",confirm:e.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 rt(e){return e&&typeof e=="object"&&!Array.isArray(e)?e:null}function ar(e){const n=rt(e.proposal);if(!n)return null;const s=rt(e.current);if(e.tool==="manage_agents"){if(!["create","update","delete"].includes(String(n.action)))return null;const r=xn({current:s,proposal:n});return{kind:"agent",current:n.action==="create"?null:r.current,proposed:n.action==="delete"?null:r.proposed}}if(e.tool==="manage_automations"){const r=rt(n.args);if(!r||!["create","update","create_version","set_reaction_script"].includes(String(r.action)))return null;const{action:a,automation_id:i,expected_version:c,...o}=r;return{kind:"automation",current:a==="create"?null:s,proposed:{...a==="create"?null:s,...o}}}return null}function ir({proposal:e}){return t.jsxs("div",{className:"space-y-3",children:[t.jsx("p",{className:"text-xs text-muted-foreground",children:"Recorded configuration and requested changes. Fields absent from the snapshot are not shown; creation uses the normal defaults."}),t.jsx(Ks,{current:e.current,proposed:e.proposed,render:n=>e.kind==="agent"?t.jsx(qs,{value:n}):t.jsx(Vs,{value:n})})]})}async function or(e,n,s,r){const a=await hn(`${gn}/api/${encodeURIComponent(e)}/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 yn(a,"Could not record interaction"),a.json()}function U(e){if(typeof e!="string")return;const n=e.trim();return n.length>0?n:void 0}function at(e){return typeof e=="boolean"?e:void 0}function lr(e,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"||U(n?.reason_preview)&&U(n?.message)||U(e?.body)&&(U(e?.post_url)||U(e?.activity_id)))}function cr(e,n,s){if(!lr(e,n,s))return null;const r=(s??"").toLowerCase(),a=U(n?.body)??U(e?.body),i=U(n?.reason_preview)??U(e?.reason),c=U(n?.post_url)??U(e?.post_url)??(U(e?.activity_id)?`https://www.linkedin.com/feed/update/urn:li:activity:${U(e?.activity_id)}`:void 0),o=at(n?.prepared),l=at(n?.verified),d=at(n?.banner_shown),p=U(n?.message),u=n?.match&&typeof n.match=="object"?n.match:null,m=U(u?.text_preview),b=U(u?.author);let w="generic";r==="verify_staged_comment"||r.includes("verify")||typeof l=="boolean"?w="verify":(r==="prepare_comment"||r.includes("prepare")||o===!0||a&&c)&&(w="prepare");const h=[];return o===!0&&h.push("Staged — not posted"),o===!1&&h.push("Not staged"),l===!0&&h.push("Verified posted"),l===!1&&h.push("Not verified as posted"),d===!0&&h.push("In-page banner"),d===!1&&h.push("No banner"),{kind:w,message:p,reason:i,body:a,postUrl:c,prepared:o,bannerShown:d,verified:l,matchPreview:m,matchAuthor:b,chips:h}}const Ke="inline-flex max-w-full items-center truncate rounded-md border border-border px-1.5 py-0.5 text-xs";function tn({peer:e,ownerSlug:n,orgContext:s}){const r=Pe();if(e.url&&!e.self&&e.type){const i=jn(e.url);return i?t.jsx("a",{href:i,target:"_blank",rel:"noopener noreferrer",className:Y(Ke,"hover:bg-muted"),title:e.type,onClick:c=>c.stopPropagation(),children:t.jsx("span",{className:"truncate",children:e.name})}):t.jsx("span",{className:Y(Ke,"text-muted-foreground"),children:e.name})}if(e.self||!e.type||!r)return t.jsx("span",{className:Y(Ke,"text-muted-foreground"),children:e.name});const a=r.item?.recordPeer?.entityId===e.id;return t.jsx("button",{type:"button","aria-pressed":a,title:e.type,className:Y(Ke,"hover:bg-muted",a&&"ring-1 ring-primary"),onClick:i=>{i.stopPropagation(),r.open(tr({...typeof e.id=="number"?{entityId:e.id}:{record:{type:e.type,key:e.id}},ownerSlug:n,orgContext:s,name:e.name}))},children:t.jsx("span",{className:"truncate",children:e.name})})}function Ha(e,n=e.relationship_type_name){const s=e.from_entity_name??`Record #${e.from_entity_id}`,r=e.to_entity_name??`Record #${e.to_entity_id}`;return e.is_symmetric?`${s} ${n} ${r}`:`${s} → ${n} → ${r}`}function Wa({row:e,entityId:n,entityType:s,ownerSlug:r,orgContext:a,label:i=e.relationship_type_name}){const c=(o,l,d,p)=>t.jsx(tn,{peer:{id:o,name:l??`Record #${o}`,type:d,url:p,self:!p&&o===n&&(typeof o=="number"||d===s)},ownerSlug:r,orgContext:a});return t.jsxs("div",{className:"flex min-w-0 flex-wrap items-center gap-1 text-xs",children:[c(e.from_entity_id,e.from_entity_name,e.from_entity_type,e.from_entity_url),!e.is_symmetric&&t.jsx($t,{"aria-hidden":"true",className:"size-3 shrink-0 text-muted-foreground"}),t.jsx("span",{className:"text-muted-foreground",children:i}),!e.is_symmetric&&t.jsx($t,{"aria-hidden":"true",className:"size-3 shrink-0 text-muted-foreground"}),c(e.to_entity_id,e.to_entity_name,e.to_entity_type,e.to_entity_url)]})}function Ja({count:e,onRetry:n}){return e?t.jsxs("p",{role:"status",className:"text-xs text-muted-foreground",children:["Some linked records could not be read."," ",t.jsx("button",{type:"button",className:"underline",onClick:n,children:"Retry"})]}):null}const nn={name:"Name",slug:"URL slug",parent_id:"Parent",content:"Content changed"};function _e(e){return typeof e=="object"&&e!==null&&!Array.isArray(e)}function qe(e){return e==null||e===""}function dr(e,n){return ct(e??null)===ct(n??null)}function ur(e){return!!(e?.type==="array"&&(e.items?.type==="object"||e.items?.properties))}function mr(e){return!!(e&&(e.type==="object"||e.properties)&&e.type!=="array")}function jt(e,n){return nr({key:e,prop:n??{}})}function pr(e,n){return e?.properties?.[n]}function pt(e,n,s,r,a){if(dr(n,s))return;const i=l=>Array.isArray(l)?l:[];if((Array.isArray(n)||qe(n))&&(Array.isArray(s)||qe(s))&&(Array.isArray(n)||Array.isArray(s)||r?.type==="array")){const l=i(n),d=i(s);if(ur(r)||[...l,...d].some(v=>_e(v))){const v=Math.min(l.length,d.length);for(let S=0;S<v;S++)pt([...e,`item ${S+1}`],l[S],d[S],r?.items,a);const N=Math.max(0,d.length-l.length),k=Math.max(0,l.length-d.length);(N||k)&&a.push({kind:"items",path:e,added:N,removed:k});return}const u=v=>ct(v),m=new Set(l.map(u)),b=new Set(d.map(u)),w=d.filter(v=>!m.has(u(v))),h=l.filter(v=>!b.has(u(v)));a.push(w.length||h.length?{kind:"values",path:e,added:w,removed:h,prop:r?.items}:{kind:"reordered",path:e});return}if((_e(n)||qe(n))&&(_e(s)||qe(s))&&(_e(n)||_e(s)||mr(r))){const l=_e(n)?n:{},d=_e(s)?s:{},p=[...new Set([...Object.keys(r?.properties??{}),...Object.keys(l),...Object.keys(d)])];for(const u of p){const m=pr(r,u);pt([...e,jt(u,m)],l[u],d[u],m,a)}return}a.push({kind:"set",path:e,old:n,new:s,prop:r})}function fr(e,n){const s=nn[e.field];if(s)return e.field==="content"?[{kind:"note",path:[s]}]:e.field==="parent_id"?[{kind:"parent",path:[s],old:e.old,new:e.new}]:[{kind:"set",path:[s],old:e.old,new:e.new}];const r=n?.properties?.[e.field],a=[];return pt([jt(e.field,r)],e.old,e.new,r,a),a}function xr(e,n){const s=n?.properties;return e.map(r=>r.field==="content"?"Content":nn[r.field]??jt(r.field,s?.[r.field]))}const hr="entity.updated",gr=new Set(["link","unlink","update_link"]);function Mt(e){const n=typeof e=="string"||typeof e=="number"?Number(e):Number.NaN;return Number.isSafeInteger(n)&&n>0?n:null}function yr(e){const n=e.split("_").join(" ").trim();return n?`${n.charAt(0).toUpperCase()}${n.slice(1)}`:e}function jr(e){const n=e.metadata;if(e.semantic_type!=="change"||!n||n._lobu_relationship_change!==!0||typeof n.op!="string"||!gr.has(n.op))return null;const s=Mt(n.fromEntityId),r=Mt(n.toEntityId);if(s==null||r==null)return null;const a=typeof n.relationshipTypeSlug=="string"?n.relationshipTypeSlug:null,i=Array.isArray(n.changes)?n.changes:[];return{op:n.op,fromId:s,toId:r,typeLabel:a?yr(a):"relationship",changedFields:i.flatMap(c=>c&&typeof c=="object"&&typeof c.field=="string"?[c.field]:[])}}function ft({id:e,ownerSlug:n}){const s={slug:n},{data:r,isLoading:a,isError:i}=Ot(e,s);return a?t.jsxs("span",{className:"text-xs text-muted-foreground",children:["Record #",e]}):i||!r?t.jsx("span",{className:"text-xs text-muted-foreground",title:"Deleted, or you do not have access to it",children:"Unavailable record"}):t.jsx(tn,{peer:{id:e,name:r.name,type:r.entity_type},ownerSlug:n,orgContext:s})}function vr({change:e,ownerSlug:n}){const s=e.op==="link"?`Linked as ${e.typeLabel}`:e.op==="unlink"?`Unlinked ${e.typeLabel}`:`Updated ${e.typeLabel} link`;return t.jsxs("span",{"data-testid":"relationship-change",className:"inline-flex flex-wrap items-center gap-1.5",children:[t.jsx(ft,{id:e.fromId,ownerSlug:n}),t.jsx("span",{children:s}),t.jsx("span",{"aria-hidden":"true",children:"→"}),t.jsx(ft,{id:e.toId,ownerSlug:n}),e.op==="update_link"&&e.changedFields.length>0?t.jsxs("span",{className:"text-xs text-muted-foreground",children:["· ",e.changedFields.join(", ")]}):null]})}function _r(e){if(!Array.isArray(e)||e.length===0)return null;const n=[];for(const s of e){if(!s||typeof s!="object"||typeof s.field!="string")return null;const{field:r,old:a,new:i}=s;n.push({field:r,old:a??null,new:i??null})}return n}function br(e){const n=jr(e);if(n)return{kind:"relationship",change:n};const s=e.metadata;if(e.semantic_type!=="change"||!s)return null;const r=s._lobu_event_type;if(r!==hr&&(r!==void 0||s.category))return null;const a=_r(s.changes);if(!a)return null;const i=e.entity_ids?.[0];return{kind:"fields",entityId:typeof i=="number"?i:null,changes:a}}function sn(e,n){const s={slug:n},{data:r}=Ot(e.entityType?void 0:e.entityId??void 0,s),{data:a}=vn(e.entityType??r?.entity_type??"",s);return a?.metadata_schema}const Nr=4;function Ve({value:e,prop:n}){return t.jsx("span",{className:"inline-block max-w-[18rem] truncate align-bottom",title:typeof e=="string"?e:void 0,children:t.jsx(rr,{value:e,prop:n,empty:t.jsx("span",{className:"italic",children:"empty"})})})}function Dt({id:e,ownerSlug:n}){const s=typeof e=="number"||typeof e=="string"?Number(e):Number.NaN;return Number.isSafeInteger(s)&&s>0?t.jsx(ft,{id:s,ownerSlug:n}):t.jsx("span",{className:"italic text-muted-foreground",children:"empty"})}function xt(e,n){return`${e} ${n}${e===1?"":"s"}`}function wr({line:e,ownerSlug:n}){const s=t.jsx("span",{className:"text-muted-foreground",children:e.path.join(" · ")});switch(e.kind){case"note":return s;case"set":return t.jsxs(t.Fragment,{children:[s,": ",t.jsx(Ve,{value:e.old,prop:e.prop})," ",t.jsx("span",{"aria-hidden":"true",children:"→"})," ",t.jsx(Ve,{value:e.new,prop:e.prop})]});case"parent":return t.jsxs(t.Fragment,{children:[s,": ",t.jsx(Dt,{id:e.old,ownerSlug:n})," ",t.jsx("span",{"aria-hidden":"true",children:"→"})," ",t.jsx(Dt,{id:e.new,ownerSlug:n})]});case"items":return t.jsxs(t.Fragment,{children:[s,":"," ",[e.added?`${xt(e.added,"item")} added`:null,e.removed?`${xt(e.removed,"item")} removed`:null].filter(Boolean).join(", ")]});case"values":return t.jsxs(t.Fragment,{children:[s,":",e.added.map((r,a)=>t.jsxs("span",{className:"ml-1.5",children:["+",t.jsx(Ve,{value:r,prop:e.prop})]},`+${a}`)),e.removed.map((r,a)=>t.jsxs("span",{className:"ml-1.5 text-muted-foreground",children:["−",t.jsx(Ve,{value:r,prop:e.prop})]},`-${a}`))]});case"reordered":return t.jsxs(t.Fragment,{children:[s,": reordered"]})}}function kr({change:e,ownerSlug:n}){const s=sn(e,n);return t.jsxs(t.Fragment,{children:["Updated ",xr(e.changes,s).join(", ")]})}function vt({changes:e,entityId:n,entityType:s,ownerSlug:r,showAll:a=!1}){const i=sn({entityId:n,entityType:s},r),[c,o]=j.useState(a),l=e.flatMap(u=>fr(u,i)),d=c?l:l.slice(0,Nr),p=l.length-d.length;return t.jsxs("ul",{"data-testid":"field-changes",className:"space-y-0.5 text-sm",children:[d.map((u,m)=>t.jsx("li",{className:"min-w-0 truncate",children:t.jsx(wr,{line:u,ownerSlug:r})},m)),p>0?t.jsx("li",{children:t.jsxs("button",{type:"button",className:"text-xs text-primary hover:underline",onClick:u=>{u.stopPropagation(),o(!0)},children:["+",xt(p,"more change")]})}):null]})}function Cr({event:e,ownerSlug:n}){return e.kind==="relationship"?t.jsx(vr,{change:e.change,ownerSlug:n}):t.jsx(kr,{change:e,ownerSlug:n})}function Ar({event:e,ownerSlug:n}){return e.kind==="fields"?t.jsx(vt,{changes:e.changes,entityId:e.entityId,ownerSlug:n}):null}function Rr({operation:e}){switch(e){case"create":case"created":return t.jsx(H,{variant:"default",children:"Created"});case"update":case"updated":return t.jsx(H,{variant:"secondary",children:"Updated"});case"delete":case"deleted":return t.jsx(H,{variant:"destructive",children:"Deleted"});default:return t.jsx(H,{variant:"outline",children:e||"Change"})}}function Sr({operation:e,actor:n,createdAt:s,resource:r,changedFields:a}){return t.jsxs("div",{className:"min-w-0 flex-1 space-y-1",children:[t.jsxs("div",{className:"flex flex-wrap items-center gap-2",children:[r?t.jsx("span",{className:"break-words text-sm font-medium",children:r}):null,t.jsx(Rr,{operation:e}),t.jsx("time",{dateTime:s,title:s,className:"ml-auto text-xs text-muted-foreground",children:_n(s)})]}),t.jsxs("p",{className:"break-words text-xs text-muted-foreground",children:["by ",n||"unknown"]}),a?.length?t.jsxs("p",{className:"break-words text-xs text-muted-foreground",children:["Changed: ",a.join(", ")]}):null]})}function $r(e){return e.semantic_type==="change"&&(e.metadata?.category==="config"||e.metadata?.category==="deployment")}function be(e){return e!==null&&typeof e=="object"&&!Array.isArray(e)?e:null}function Ir({content:e}){const n=e.metadata??{},s=e.payload_data??{},r=n.category==="deployment",a=typeof n.apply_id=="string"?n.apply_id:null,i=be(s.manifest),c=a&&/^apl_[A-Za-z0-9-]{1,48}$/.test(a)&&e.origin_type==="deployment"&&e.origin_id===`deployment_${a}`&&(n.status==="succeeded"||n.status==="partial_failure")&&be(i?.state);return t.jsxs("div",{className:"space-y-3","data-testid":"config-change-event",children:[t.jsx(Sr,{operation:r?String(n.status??"Apply"):typeof n.op=="string"?n.op:null,actor:e.author_name??(typeof n.actor_source=="string"?n.actor_source:null),createdAt:e.occurred_at??e.created_at,resource:r?"Configuration apply":`${n.resource_kind??"Configuration"} · ${n.resource_id??""}`,changedFields:Array.isArray(n.changed_fields)?n.changed_fields.filter(o=>typeof o=="string"):void 0}),a?t.jsxs("div",{className:"flex min-w-0 items-center gap-2 text-xs text-muted-foreground",children:[t.jsxs("span",{className:"break-all",children:["Apply ",a]}),t.jsx(Tt,{text:a,label:"Copy apply ID"})]}):null,r?t.jsxs(t.Fragment,{children:[typeof n.rollback_of=="string"?t.jsxs("p",{className:"break-all text-xs text-muted-foreground",children:["Restores apply ",n.rollback_of]}):null,be(n.counts)?t.jsx("dl",{className:"flex flex-wrap gap-4 text-xs",children:Object.entries(be(n.counts)??{}).map(([o,l])=>t.jsxs("div",{children:[t.jsx("dt",{className:"text-muted-foreground",children:o}),t.jsx("dd",{children:String(l)})]},o))}):null,typeof s.error=="string"?t.jsx("p",{className:"text-sm text-destructive",children:s.error}):null,c?t.jsxs("div",{className:"space-y-2 rounded-md border p-3",children:[t.jsx("p",{className:"text-sm font-medium",children:"Restore this deployment"}),t.jsx("p",{className:"text-xs text-muted-foreground",children:"Preview restoring this saved configuration with the CLI. Secret values stay unchanged."}),t.jsxs("div",{className:"flex items-center gap-2",children:[t.jsxs("code",{className:"break-all text-xs",children:["lobu rollback ",a]}),t.jsx(Tt,{text:`lobu rollback ${a}`,label:"restore command",iconOnly:!0})]})]}):null,t.jsx(We,{before:null,after:i})]}):Object.hasOwn(s,"before")?t.jsx(We,{before:be(s.before),after:be(s.state)}):t.jsxs(t.Fragment,{children:[t.jsx("p",{className:"text-xs text-muted-foreground",children:"The earlier state was not recorded for this change."}),t.jsx(We,{before:null,after:be(s.state)})]})]})}const Tr={slack:"Slack",telegram:"Telegram",whatsapp:"WhatsApp",discord:"Discord",gchat:"Google Chat",teams:"Microsoft Teams",web:"Web"};function Er(e){return Tr[e]??null}function Mr(e){return e?e.kind==="automation"?`Ran ${e.automationName}`:e.platform==="web"?"Chatted in Lobu":`Replied on ${Er(e.platform)??e.platform}`:"No activity yet"}function Dr({owner:e,item:n,last:s,appearance:r="row"}){const a=r==="inline",i=a?"inline-flex items-center gap-1.5 rounded-md bg-accent px-1.5 py-0.5 text-sm font-medium":Y(Je,!s&&"border-b");if(n.kind==="managed"){const l=n.agent,d=[l.lastActivity===void 0?null:Mr(l.lastActivity),l.connectionCount===void 0?null:`${l.connectionCount} ${l.connectionCount===1?"connection":"connections"}`,l.userCount===void 0?null:`${l.userCount} ${l.userCount===1?"user":"users"}`].filter(u=>!!u),p=t.jsx(Nn,{className:"h-4 w-4 text-muted-foreground"});return t.jsx(W,{to:"/$owner/agents/$agentId",params:{owner:e,agentId:l.agentId},className:i,children:a?t.jsxs(t.Fragment,{children:[p,l.name]}):t.jsx(Le,{mark:p,name:l.name,details:t.jsx(Qe,{parts:d.length>0?d:[l.description]}),at:l.lastActivity?Date.parse(l.lastActivity.at):void 0})})}const c=n.group,o=t.jsx(bn,{name:c.title});return t.jsx(W,{to:"/$owner/agents/connected/$clientId",params:{owner:e,clientId:c.clientId},className:i,children:a?t.jsxs(t.Fragment,{children:[o,c.title]}):t.jsx(Le,{mark:o,name:c.title,details:t.jsx(Qe,{parts:[c.connected?"Connected app":"Disconnected",c.linkedUser,c.drivenBy&&c.drivenBy!==c.title?`via ${c.drivenBy}`:null]}),at:c.lastSeenAt})})}const Fr={event:{label:"Event",icon:Pt},schedule:{label:"Schedule",icon:kn},manual:{label:"Manual",icon:wn}};function Lr(e,n,s){switch(Sn(e)){case"script":return["Script"];case"external":case"manual":return["Outside client"];case"device":{const r=e.agent_kind,a=r&&r in Et?Et[r]:r;return[n,s,a].filter(i=>!!i)}case"agent":return[n??"Agent","Hosted"]}}function Or({automation:e,agentName:n,deviceLabel:s,connectorDisplay:r,owner:a,actions:i,rowClass:c,appearance:o="row"}){const l=e.automation,d=l.automation_id,p=Fr[e.kind];if(o==="inline")return t.jsxs(W,{to:"/$owner/automations/$automationId",params:{owner:a,automationId:d},search:{view:"definition",run_id:void 0},className:"inline-flex items-center gap-1.5 rounded-md bg-accent px-1.5 py-0.5 text-sm font-medium",children:[t.jsx(p.icon,{className:"h-3.5 w-3.5 shrink-0"}),e.does,l.status==="archived"?t.jsx(H,{variant:"outline",children:"Archived"}):null]});const u=Cn(e,Date.now()),m=l.processing_client_count??0,b=l.entity_name&&l.entity_type?`${l.entity_name} · ${l.entity_type}`:null;return t.jsxs("div",{className:c,children:[t.jsx(W,{to:"/$owner/automations/$automationId",params:{owner:a,automationId:d},search:{view:"definition",run_id:void 0},className:"flex min-w-0 flex-1 items-center gap-3",children:t.jsx(Le,{mark:r?t.jsx(Rn,{icon:r.icon,iconUrl:r.iconUrl,name:r.name,faviconDomain:r.faviconDomain,className:"h-7 w-7 text-[10px]"}):t.jsx(p.icon,{className:"h-4 w-4 text-muted-foreground"}),name:e.does,badge:l.status==="archived"?t.jsx(H,{variant:"outline",children:"Archived"}):null,tone:u.problem?"destructive":null,details:t.jsx(Qe,{parts:[u.text,...Lr(l,n,s),m>0?`${m} ${m===1?"client":"clients"}`:null,An(e.when),b]}),at:u.at})}),i]})}function Pr({record:e,workspace:n,appearance:s}){return t.jsx(Or,{automation:In(e),owner:n,agentName:e.managed_agent_id??null,deviceLabel:e.device_worker_id?"Device-pinned":null,connectorDisplay:null,appearance:s,rowClass:"flex items-center gap-3 rounded-lg border px-3 py-2.5"})}function Br({agent:e,workspace:n,appearance:s}){return t.jsx(Dr,{owner:n,appearance:s,last:!0,item:{kind:"managed",key:e.id,agent:{agentId:e.id,name:e.name,description:e.description??void 0}}})}function Ur({connector:e,connection:n,workspace:s,appearance:r}){const a=e.key,i=t.jsx(Tn,{connector:e,showDescription:r!=="inline"});return t.jsx("div",{className:r==="inline"?"inline-flex items-center gap-2":"rounded-lg border p-3",children:n?t.jsxs(W,{to:"/$owner/connectors/$connectorKey/$connectionId",params:{owner:s,connectorKey:a,connectionId:String(n.id)},search:{},children:[i,t.jsx("span",{className:"text-xs text-muted-foreground",children:$n(n)})]}):t.jsx(W,{to:"/$owner/connectors/$connectorKey",params:{owner:s,connectorKey:a},children:i})})}function He(e,n){return typeof e=="string"&&e.trim().length>0&&e.length<=n}function _t(e,n){if(!n||typeof n!="object"||Array.isArray(n))return null;const s=n;if(s.mode!=="live"||!He(s.workspace,128)||!/^[a-zA-Z0-9][a-zA-Z0-9_.-]*$/.test(s.workspace)||s.appearance!==void 0&&s.appearance!=="inline"&&s.appearance!=="row")return null;const r={mode:"live",workspace:s.workspace,appearance:s.appearance??"row"};return e==="automation-ref"?!He(s.automationId,128)||!/^[1-9][0-9]*$/.test(s.automationId)||!Number.isSafeInteger(Number(s.automationId))?null:{...r,automationId:s.automationId}:e==="connector-ref"?!He(s.connectorKey,128)||s.connectionId!==void 0&&(typeof s.connectionId!="number"||!Number.isSafeInteger(s.connectionId)||s.connectionId<=0)?null:{...r,connectorKey:s.connectorKey,...s.connectionId!==void 0?{connectionId:s.connectionId}:{}}:He(s.agentId,128)?{...r,agentId:s.agentId}:null}const zr=4,Kr=128;let it=0;const De=[];async function qr(e,n){if(e.aborted)throw e.reason;await new Promise((s,r)=>{const a=()=>{const c=De.indexOf(i);c>=0&&De.splice(c,1),r(e.reason)},i=()=>{e.removeEventListener("abort",a),it++,s()};it<zr?i():De.length>=Kr?r(new Error("Reference read capacity exceeded")):(De.push(i),e.addEventListener("abort",a,{once:!0}))});try{if(e.aborted)throw e.reason;return await n()}finally{it--,De.shift()?.()}}const Ze={retry:!1,staleTime:0,refetchOnMount:"always",refetchOnWindowFocus:"always",refetchOnReconnect:"always"};function we({error:e}){const n=e instanceof Re&&(e.status===401||e.status===403)?"Access required to view this reference.":e instanceof Re&&e.status===404?"Reference not found.":"Reference unavailable.";return t.jsx("span",{role:"status",className:"text-sm text-muted-foreground",children:n})}function bt(){return t.jsx("span",{role:"status",className:"text-sm text-muted-foreground",children:"Loading reference…"})}function Vr({workspace:e,automationId:n,appearance:s}){const{session:r,isReady:a}=et(),i=gt(),c=Ge({...Ze,enabled:a&&!i,queryKey:["automations-list",e,"native-reference",r?.user.id??null,n],queryFn:({signal:l})=>qr(l,async()=>{let d;for(const u of["active","archived"])if(d=(await Ae("manage_automations",{action:"list",automation_id:n,status:u,include_details:!1,limit:1},{slug:e},{signal:l})).automations?.find(b=>b.automation_id===n),d)break;if(!d)throw new Re("Reference not found",404);const p=d.execution_config?.executor;return d={automation_id:d.automation_id,name:d.name,status:d.status,triggers:d.triggers,next_run_at:d.next_run_at,last_fired_at:d.last_fired_at,last_run_completed_at:d.last_run_completed_at,managed_agent_id:d.managed_agent_id,device_worker_id:d.device_worker_id,health:d.health,health_reasons:d.health_reasons,processing_client_count:d.processing_client_count,execution_config:p&&typeof p=="object"?{executor:{kind:p.kind}}:void 0},d})});if(i)return t.jsx("span",{role:"status",children:"Unavailable in visitor preview."});if(c.isPending||c.isFetching)return t.jsx(bt,{});if(c.error||!c.data)return t.jsx(we,{error:c.error});const o=c.data;return t.jsx(Pr,{record:o,workspace:e,appearance:s})}function Hr({workspace:e,connectorKey:n,connectionId:s,appearance:r}){const{session:a,isReady:i}=et(),c=gt(),o=Ge({...Ze,enabled:i&&!c,queryKey:["connector-definitions",e,"native-reference",a?.user.id??null],queryFn:async({signal:u})=>(await En({slug:e},{signal:u})).map(m=>({key:m.key,name:m.name,description:m.description,icon:m.icon}))}),l=Ge({...Ze,enabled:i&&!c&&s!==void 0,queryKey:["connections",e,"native-reference",a?.user.id??null,n,s??null],queryFn:async({signal:u})=>{const m=s===void 0?void 0:(await Ae("manage_connections",{action:"list",connection_ids:[s],connector_key:n,limit:1},{slug:e},{signal:u})).connections?.find(b=>b.id===s);if(s!==void 0&&(!m||m.id!==s||m.connector_key!==n))throw new Re("Reference not found",404);return{connection:m?{id:m.id,connector_key:m.connector_key,display_name:m.display_name,connector_name:m.connector_name,auth_profile_name:m.auth_profile_name,auth_profile_slug:m.auth_profile_slug}:void 0}}});if(c)return t.jsx("span",{role:"status",children:"Unavailable in visitor preview."});if(o.isPending||o.isFetching||s!==void 0&&(l.isPending||l.isFetching))return t.jsx(bt,{});if(o.error||s!==void 0&&(l.error||!l.data))return t.jsx(we,{error:o.error||l.error});const d=o.data?.find(u=>u.key===n);if(!d)return t.jsx(we,{error:new Re("Reference not found",404)});const p=l.data?.connection;return t.jsx(Ur,{connector:d,connection:p,workspace:e,appearance:r})}function Wr({workspace:e,agentId:n,appearance:s}){const{session:r,isReady:a}=et(),i=gt(),c=Ge({...Ze,enabled:a&&!i,queryKey:["agents",e,"native-reference",r?.user.id??null,n],queryFn:async({signal:l})=>{const d=await Ae("manage_agents",{action:"get",agent_id:n},{slug:e},{signal:l});if(d.agent?.id!==n)throw new Re("Reference not found",404);return{id:d.agent.id,name:d.agent.name,description:d.agent.description}}});if(i)return t.jsx("span",{role:"status",children:"Unavailable in visitor preview."});if(c.isPending||c.isFetching)return t.jsx(bt,{});if(c.error||!c.data)return t.jsx(we,{error:c.error});const o=c.data;return t.jsx(Br,{agent:o,workspace:e,appearance:s})}function Jr(e){const n=_t("automation-ref",e);return n?t.jsx(Vr,{...n}):t.jsx(we,{})}function Qr(e){const n=_t("connector-ref",e);return n?t.jsx(Hr,{...n}):t.jsx(we,{})}function Gr(e){const n=_t("agent-ref",e);return n?t.jsx(Wr,{...n}):t.jsx(we,{})}const ot=e=>typeof e=="string"&&e.trim().length>0&&e.length<=128,Yr={tabs:({defaultValue:e,children:n})=>ot(e)?t.jsx(Qs,{defaultValue:e,children:n}):null,"tabs-list":({label:e,children:n})=>t.jsx(Js,{label:typeof e=="string"&&e.length<=200?e:void 0,children:n}),"tabs-trigger":({value:e,children:n})=>ot(e)?t.jsx(Ws,{value:e,children:n}):null,"tabs-content":({value:e,children:n})=>ot(e)?t.jsx(Hs,{value:e,children:n}):null,"automation-ref":Jr,"connector-ref":Qr,"agent-ref":Gr,"json-diff":(({before:e,after:n})=>{const s=r=>r!==null&&typeof r=="object"&&!Array.isArray(r)?r:null;return t.jsx(We,{before:s(e),after:s(n)})})};function Fe(e){return e!==null&&typeof e=="object"&&!Array.isArray(e)}function Zr({template:e,data:n,onAction:s}){const[r,a]=j.useState(null),[i,c]=j.useState(!1),[o,l]=j.useState(null),[d,p]=j.useState(!1),u=j.useRef(!1),m=j.useRef(!0);j.useEffect(()=>(m.current=!0,()=>{m.current=!1}),[]);const b=async w=>{if(!(!s||u.current)){u.current=!0,c(!0),l(null),p(!1);try{const h=await s(w);if(!m.current)return;if(Fe(h)&&h.kind==="sdk"){const v=h.result;if(!Fe(v)||v.success!==!0){const N=Fe(v)&&Fe(v.error)?v.error.message:null;throw new Error(typeof N=="string"?N:"Could not update this event.")}if(v.return_truncated||!Fe(v.return_value))throw new Error("The update did not return a complete data object.");a(v.return_value),p(!0)}}catch(h){m.current&&l(h instanceof Error?h.message:"Could not update this event.")}finally{u.current=!1,m.current&&c(!1)}}};return t.jsxs("div",{className:"space-y-2",children:[i?t.jsx("p",{role:"status",className:"text-sm text-muted-foreground",children:"Updating…"}):null,d?t.jsx("p",{role:"status",className:"sr-only",children:"Updated"}):null,o?t.jsxs("p",{role:"alert",className:"text-sm text-destructive",children:[o," Previous data is still shown."]}):null,t.jsx("div",{"aria-busy":i,className:"min-w-0",children:t.jsx(sr,{template:{root:e.root},data:r??n,onAction:s?b:void 0,interactions:e.interactions,components:Yr,actionsDisabled:!s||i})})]})}function rn(e){return{audit:Gt(e),operation:e.interaction_type==="approval"||e.semantic_type==="operation",changeSet:e.semantic_type==="change_set"}}const Xr={},ea={notification:"Notification",tool_invocation:"Action",deployment:"Deployment",config_change:"Config change",message:"Message",msg:"Note",summary:"Summary"};function ta(e){return e.author_name?e.author_name:e.platform?Ye(e.platform):e.origin_type?ea[e.origin_type]??Ye(e.origin_type):null}function na(e){return e==null?"":typeof e=="string"?e:typeof e=="number"||typeof e=="boolean"||typeof e=="bigint"?String(e):Array.isArray(e)?e.length===0?"":e.every(n=>typeof n!="object")?e.map(n=>String(n)).join(", "):t.jsx("pre",{className:"overflow-x-auto rounded bg-muted/40 p-2 text-[11px] leading-relaxed whitespace-pre-wrap",children:JSON.stringify(e,null,2)}):t.jsx("pre",{className:"overflow-x-auto rounded bg-muted/40 p-2 text-[11px] leading-relaxed whitespace-pre-wrap",children:JSON.stringify(e,null,2)})}const lt=1e5;function Ft({value:e}){const n=JSON.stringify(e,null,2)??"null",s=n.length>lt;return t.jsxs(t.Fragment,{children:[t.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,lt):n}),s&&t.jsxs("p",{className:"text-xs text-muted-foreground",children:["Showing the first ",lt.toLocaleString()," of"," ",n.length.toLocaleString()," characters."]})]})}function sa(e){return Object.entries(e).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 ra({breakdown:e}){if(!e)return null;const n=[{label:"Engagement",value:e.engagement,max:100},{label:"Criticality",value:e.criticality,max:100},{label:"Depth",value:e.depth,max:100},{label:"Authority",value:e.authority,max:100},{label:"Recency",value:e.recency,max:100},{label:"Quality",value:e.quality,max:100}];return t.jsx("div",{className:"space-y-2 text-sm",children:n.map(s=>t.jsxs("div",{className:"flex items-center gap-2",children:[t.jsx("span",{className:"w-20 text-muted-foreground",children:s.label}),t.jsx("div",{className:"flex-1 h-2 bg-muted rounded-full overflow-hidden",children:t.jsx("div",{className:"h-full bg-primary",style:{width:`${s.value/s.max*100}%`}})}),t.jsx("span",{className:"w-8 text-right",children:s.value})]},s.label))})}function aa({slug:e,value:n,isManual:s}){return t.jsxs(H,{variant:"secondary",className:"text-xs",children:[e,": ",n,s&&t.jsx(zt,{className:"ml-1 h-2.5 w-2.5 fill-current"})]})}function ia(e){if(e&&typeof e=="object"){const n=e;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 e=="string"||typeof e=="number"||typeof e=="boolean"||typeof e=="bigint"?{values:[String(e)],isManual:!1}:{values:[],isManual:!1}}function an(e,n){if(e)switch(e){case"pending":return"pending_approval";case"approved":return"confirmed";case"rejected":return"rejected";case"completed":return"completed";case"failed":return"failed";default:return e}return n||"pending_approval"}function ht(e){return!e||typeof e!="object"||Array.isArray(e)?null:e}function oa(e){return e.replace(/\s+[—-]\s+pending approval$/i,"")}function Xe(e){return e.replace(/^\$/,"").replace(/[_-]/g," ").replace(/\s+/g," ").trim().replace(/^./,n=>n.toUpperCase())}function la(e){const n=Object.keys(e.fields),s=n.map(Xe).join(", ")||"field",r=n.length===1?"field":"fields";return`Update ${e.entityType?Xe(e.entityType).toLowerCase():"entity"} ${r}: ${s}`}function ca(e,n){const s=ht(n.fields);if(!s||Object.keys(s).length===0||n.action_key!=="entity_field_change"&&n.tool!=="entity_field_change")return null;const r=ht(n.current)??{},a=e;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 da(e){const n=e.entityType?Xe(e.entityType).toLowerCase():"entity";return`${Xe(e.operation)} ${n}`}function ua(e,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=e;return{operation:s,proposal:ht(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 ma(e,n){return!n.entityType||!n.entitySlug?null:fs(e,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 on({ownerSlug:e,runId:n,details:s}){const a=Zt(s.automationId,void 0,void 0,{ownerSlug:e,includeVersions:!1}).data?.automation,i=Pe(),c=Ys(s.initiator,s.attribution,s.automationId),o=a?.automation_name??s.automationName??c;return t.jsxs("div",{className:"text-sm text-muted-foreground",children:["Requested by"," ",s.automationId?t.jsx(W,{to:"/$owner/automations/$automationId",params:{owner:e,automationId:s.automationId},search:{view:"definition",run_id:void 0},className:"font-medium text-foreground underline-offset-4 hover:underline",children:o}):t.jsx("span",{className:"font-medium text-foreground",children:o}),n&&t.jsxs(t.Fragment,{children:[t.jsx("span",{children:" · "}),t.jsxs(W,{to:"/$owner/events",params:{owner:e},search:{run_ids:String(n)},className:"font-medium text-foreground underline-offset-4 hover:underline",onClick:l=>{!i||l.button!==0||l.metaKey||l.ctrlKey||l.shiftKey||l.altKey||(l.preventDefault(),i.open({href:`/${e}/events?run_ids=${n}`,title:`Run #${n}`,runId:n}))},children:["Run #",n]})]})]})}function ln({ownerSlug:e,details:n}){const s=ma(e,n);return n.entityName?t.jsxs("div",{className:"rounded-md bg-muted/40 px-3 py-2",children:[t.jsx("div",{className:"text-[11px] font-medium uppercase tracking-wide text-muted-foreground",children:"Entity"}),t.jsx("div",{className:"mt-1 text-sm font-medium",children:s?t.jsx(W,{to:s,className:"underline-offset-4 hover:underline",children:n.entityName}):n.entityName})]}):null}function pa({ownerSlug:e,runId:n,details:s}){return t.jsxs("div",{className:"space-y-3",children:[t.jsx(on,{ownerSlug:e,runId:n,details:s}),t.jsx(ln,{ownerSlug:e,details:s}),t.jsx("div",{className:"rounded-md border border-border/70 px-3 py-2",children:t.jsx(vt,{changes:Object.entries(s.fields).map(([r,a])=>({field:r,old:s.current[r]??null,new:a??null})),entityType:s.entityType,ownerSlug:e,showAll:!0})}),s.reason&&t.jsxs("div",{className:"rounded-md bg-muted/40 px-3 py-2",children:[t.jsx("div",{className:"text-[11px] font-medium uppercase tracking-wide text-muted-foreground",children:"Reasoning"}),t.jsx("div",{className:"mt-1 text-sm leading-relaxed",children:s.reason})]})]})}function fa({ownerSlug:e,runId:n,details:s,status:r}){const{operation:a}=s,i=a==="link"||a==="unlink";return t.jsxs("div",{className:"space-y-3",children:[t.jsx(on,{ownerSlug:e,runId:n,details:s}),!i&&t.jsx(ln,{ownerSlug:e,details:s}),t.jsxs("div",{className:"rounded-lg bg-muted/40 px-3 py-2",children:[t.jsx("div",{className:"text-xs font-medium text-muted-foreground",children:"Change"}),t.jsx("div",{className:"mt-1 text-sm leading-relaxed",children:i?en(a,r):a==="create"?"Create a new entity after approval.":"Delete this entity after approval."}),i&&t.jsxs("div",{className:"mt-2 space-y-1 text-sm",children:[Xt(s.proposal).map((c,o)=>t.jsxs("div",{children:[t.jsx("span",{className:"text-muted-foreground",children:o===0?"From: ":"To: "}),c.name]},c.id)),t.jsxs("div",{className:"text-muted-foreground",children:["Relationship:"," ",String(s.proposal?.relationship_type??s.proposal?.relationship_type_slug??"Relationship")]})]})]}),!i&&s.proposal&&t.jsxs("div",{className:"rounded-lg border border-border/70 p-3",children:[t.jsx("div",{className:"mb-1 text-xs font-medium text-muted-foreground",children:"Proposal"}),t.jsx("pre",{className:"overflow-x-auto whitespace-pre-wrap break-words text-xs leading-relaxed",children:JSON.stringify(s.proposal,null,2)})]}),s.proposerRationale&&t.jsxs("div",{className:"rounded-lg bg-muted/40 px-3 py-2",children:[t.jsx("div",{className:"text-xs font-medium text-muted-foreground",children:s.attribution==="agent"?"The agent's reasoning":"The Automation's reasoning"}),t.jsx("div",{className:"mt-1 text-sm leading-relaxed",children:s.proposerRationale})]}),s.reason&&t.jsxs("div",{className:"rounded-lg bg-muted/40 px-3 py-2",children:[t.jsx("div",{className:"text-xs font-medium text-muted-foreground",children:"Why this needs approval"}),t.jsx("div",{className:"mt-1 text-sm leading-relaxed",children:s.reason})]})]})}function xa({summary:e}){return t.jsxs("div",{className:"space-y-2 rounded-md border border-border/70 bg-muted/30 p-3 text-sm",children:[e.chips.length>0&&t.jsx("div",{className:"flex flex-wrap gap-1.5",children:e.chips.map(n=>t.jsx(H,{variant:"outline",className:"text-[10px] font-normal",children:n},n))}),e.message&&t.jsx("p",{className:"leading-relaxed text-foreground",children:e.message}),e.reason&&t.jsxs("div",{className:"rounded-md bg-background/80 px-2.5 py-2",children:[t.jsx("div",{className:"text-[11px] font-medium uppercase tracking-wide text-muted-foreground",children:"Why"}),t.jsx("div",{className:"mt-0.5 leading-relaxed",children:e.reason})]}),e.body&&t.jsxs("div",{className:"rounded-md bg-background/80 px-2.5 py-2",children:[t.jsx("div",{className:"text-[11px] font-medium uppercase tracking-wide text-muted-foreground",children:e.kind==="verify"?"Expected comment":"Draft"}),t.jsx("div",{className:"mt-0.5 whitespace-pre-wrap leading-relaxed",children:e.body})]}),e.matchPreview&&t.jsxs("div",{className:"rounded-md bg-background/80 px-2.5 py-2",children:[t.jsxs("div",{className:"text-[11px] font-medium uppercase tracking-wide text-muted-foreground",children:["Matched comment",e.matchAuthor?` · ${e.matchAuthor}`:""]}),t.jsx("div",{className:"mt-0.5 whitespace-pre-wrap leading-relaxed text-muted-foreground",children:e.matchPreview})]}),e.postUrl&&t.jsxs("a",{href:e.postUrl,target:"_blank",rel:"noreferrer",className:"inline-flex items-center gap-1 text-xs text-primary hover:underline",children:["Open post",t.jsx(Qt,{className:"h-3 w-3"})]})]})}function ha({ownerSlug:e,content:n,batchReview:s}){const r=n.metadata||{},a=n.run_id??void 0,i=ar(r),c=ca(n,r),o=ua(n,r),l=(c?la(c):o?da(o):void 0)||r.operation_name||r.action_name||(n.title?oa(n.title):void 0)||"Action",d=r.connection_name,p=r.operation_key||r.action_key||null,u=n.interaction_input_schema||r.input_schema||null,m=j.useMemo(()=>n.interaction_input||r.action_input||r.operation_input||Xr,[n.interaction_input,r.action_input,r.operation_input]),b=n.interaction_output||r.action_output||void 0,w=cr(m,b??null,p),h=n.interaction_error||r.error_message||void 0,v=an(n.interaction_status,r.status),N=r.reviewed_by_name||r.reviewed_by_id||void 0,k=r.reject_reason||void 0,S=r.initiator,R=ts({slug:e}),T=ns({slug:e}),E=ss(n.id,rs(u,m),u),{values:M,setValues:F}=E,[C,x]=j.useState(null),[B,V]=j.useState(!1),[P,y]=j.useState(""),L=v==="pending_approval"&&C?C:v,D=L==="pending_approval",Z=typeof r.source_run_id=="number";return t.jsxs("div",{className:"space-y-3",children:[t.jsxs("div",{className:"flex items-center gap-2",children:[t.jsx(Pt,{className:"h-4 w-4 text-yellow-500"}),t.jsx("span",{className:"font-medium",children:l}),d&&t.jsxs("span",{className:"text-xs text-muted-foreground",children:["on ",d]}),L==="confirmed"&&t.jsx(H,{variant:"outline",className:"text-blue-700 border-blue-300 bg-blue-50 dark:bg-blue-950/30 text-[10px]",children:"Approved"}),L==="completed"&&t.jsx(H,{variant:"outline",className:"text-green-700 border-green-300 bg-green-50 dark:bg-green-950/30 text-[10px]",children:"Completed"}),L==="failed"&&t.jsx(H,{variant:"outline",className:"text-red-700 border-red-300 bg-red-50 dark:bg-red-950/30 text-[10px]",children:"Failed"}),L==="rejected"&&t.jsx(H,{variant:"outline",className:"text-muted-foreground text-[10px]",children:"Rejected"})]}),!c&&!o&&(n.author_name||N)&&t.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&&t.jsxs("span",{children:["Requested by"," ",t.jsx(Gs,{ownerSlug:e,initiator:S,clientName:n.author_name,fallback:n.author_name})]}),n.author_name&&N&&t.jsx("span",{children:"·"}),N&&t.jsxs("span",{children:[L==="rejected"?"Rejected":"Approved"," by"," ",t.jsx("span",{className:"font-medium text-foreground",children:N})]})]}),c&&t.jsx(pa,{ownerSlug:e,runId:a,details:c}),!c&&o&&t.jsx(fa,{ownerSlug:e,runId:a,details:o,status:L}),L==="rejected"&&k&&t.jsxs("div",{className:"rounded-md bg-muted/50 p-2 text-xs text-muted-foreground",children:[t.jsx("span",{className:"font-medium text-foreground",children:"Reason:"})," ",k]}),w&&t.jsx(xa,{summary:w}),i&&t.jsx(ir,{proposal:i}),!i&&(D?E.revision:u)&&(D||Object.keys(m).length>0)&&t.jsxs("div",{children:[t.jsx("p",{className:"text-xs text-muted-foreground mb-1",children:w?"Full input":"Input"}),D?t.jsxs(t.Fragment,{children:[t.jsx(as,{visible:E.hasConflict,onReload:E.reset}),t.jsx(is,{schema:E.revision,values:M,onValuesChange:F,fieldIdPrefix:`action-${n.id}-`},`action-${n.id}`)]}):w?t.jsxs("details",{className:"text-xs",children:[t.jsx("summary",{className:"cursor-pointer text-muted-foreground hover:text-foreground",children:"Raw input"}),t.jsx("pre",{className:"mt-1 bg-muted/50 rounded p-2 font-mono overflow-auto max-h-32",children:JSON.stringify(m,null,2)})]}):t.jsx("pre",{className:"text-xs bg-muted/50 rounded p-2 font-mono overflow-auto max-h-32",children:JSON.stringify(m,null,2)})]}),L==="completed"&&b&&Object.keys(b).length>0&&!w&&t.jsxs("div",{className:"rounded-md bg-green-50 dark:bg-green-950/30 p-3 text-sm space-y-1",children:[t.jsxs("div",{className:"flex items-center gap-1.5 text-green-700 dark:text-green-400 font-medium",children:[t.jsx(Vt,{className:"h-3.5 w-3.5"}),"Output"]}),t.jsx("pre",{className:"text-xs text-green-800 dark:text-green-300 font-mono whitespace-pre-wrap",children:JSON.stringify(b,null,2)})]}),L==="completed"&&b&&Object.keys(b).length>0&&w&&t.jsxs("details",{className:"text-xs",children:[t.jsx("summary",{className:"cursor-pointer text-muted-foreground hover:text-foreground",children:"Raw output"}),t.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(b,null,2)})]}),L==="failed"&&h&&t.jsxs("div",{className:"rounded-md bg-red-50 dark:bg-red-950/30 p-3 text-sm",children:[t.jsxs("div",{className:"flex items-center gap-1.5 text-red-700 dark:text-red-400 font-medium",children:[t.jsx(qt,{className:"h-3.5 w-3.5"}),"Error"]}),t.jsx("p",{className:"text-xs text-red-800 dark:text-red-300 font-mono mt-1",children:h})]}),D&&!C&&Z&&t.jsxs("div",{className:"pt-1 text-xs text-muted-foreground",children:["Review this proposal with the other changes in its Automation run.",s]}),D&&a&&!C&&!Z&&t.jsx("div",{className:"flex items-center gap-2 pt-1",children:B?t.jsxs("div",{className:"flex items-center gap-2 w-full",children:[t.jsx("input",{type:"text",placeholder:"Reason (optional)",value:P,onChange:le=>y(le.target.value),className:"h-7 text-xs border rounded px-2 flex-1 bg-background"}),t.jsxs(O,{size:"sm",variant:"destructive",className:"h-7 text-xs",onClick:()=>T.mutate({run_id:a,reason:P||void 0},{onSuccess:()=>{x("rejected")}}),disabled:T.isPending,children:[T.isPending&&t.jsx(Ne,{size:"sm",className:"mr-1"}),"Confirm Reject"]}),t.jsx(O,{size:"sm",variant:"ghost",className:"h-7 text-xs px-2",onClick:()=>{V(!1),y("")},children:"Cancel"})]}):t.jsxs(t.Fragment,{children:[t.jsxs(O,{size:"sm",className:"h-7 text-xs",onClick:()=>R.mutate({run_id:a,...i?{}:{input:ls(M)}},{onSuccess:()=>{x("confirmed")}}),disabled:!i&&!E.canSubmit||R.isPending||T.isPending,children:[R.isPending?t.jsx(Ne,{size:"sm",className:"mr-1"}):t.jsx(os,{className:"h-3 w-3 mr-1"}),i?"Approve":"Confirm"]}),t.jsxs(O,{size:"sm",variant:"outline",className:"h-7 text-xs",onClick:()=>V(!0),disabled:R.isPending||T.isPending,children:[t.jsx(cs,{className:"h-3 w-3 mr-1"}),"Reject"]})]})})]})}function ga({content:e,ownerSlug:n}){const s=e.metadata||{},r=s.kind,a=e.run_id??null,i=typeof s.automation_id=="number"?s.automation_id:null,l=Zt(i!=null?String(i):void 0,void 0,void 0,{includeVersions:!1,ownerSlug:n}).data?.automation?.automation_name??(i!=null?`Automation ${i}`:"An Automation"),d=Xn({slug:n}),p=es({slug:n}),[u,m]=j.useState(!1),[b,w]=j.useState(""),[h,v]=j.useState(null);if(r==="automation_batch_reject"){const x=s.reason||void 0;return t.jsxs("div",{className:"rounded-md border border-destructive/40 bg-destructive/5 p-3",children:[t.jsx("div",{className:"text-sm font-medium",children:"Proposals rejected"}),x&&t.jsx("div",{className:"mt-1 text-sm text-muted-foreground",children:x}),t.jsx("div",{className:"mt-1 text-xs text-muted-foreground",children:"Ask the agent to revise its proposals with this feedback."})]})}const N=Array.isArray(s.changes)?s.changes:[],k=typeof s.created_count=="number"?s.created_count:N.filter(x=>x.kind==="created").length,S=typeof s.updated_count=="number"?s.updated_count:N.filter(x=>x.kind==="updated").length,R=typeof s.denied_count=="number"?s.denied_count:N.filter(x=>x.kind==="denied").length,T=N.filter(x=>x.kind==="denied"),E=N.filter(x=>x.kind==="updated"&&Object.keys(x.applied||{}).length>0),M=typeof s.pending_proposal_count=="number"?s.pending_proposal_count:null,F=M==null||M>0,C=F?"proposed":"applied";return t.jsxs("div",{className:"rounded-md border p-3",children:[t.jsxs("div",{className:"flex flex-wrap items-center justify-between gap-x-3 gap-y-1",children:[t.jsxs("div",{className:"text-sm font-medium",children:[C==="proposed"?"Proposed":"Applied"," ",k," ","new + ",S," updated",R>0&&t.jsxs(t.Fragment,{children:[" + ",R," denied"]})]}),t.jsxs("div",{className:"text-xs text-muted-foreground",children:[i!=null?t.jsx(W,{to:"/$owner/automations/$automationId",params:{owner:n,automationId:String(i)},search:{view:"definition",run_id:void 0},className:"font-medium text-foreground underline-offset-4 hover:underline",children:l}):t.jsx("span",{className:"font-medium text-foreground",children:l}),a!=null&&t.jsxs("span",{children:[" · run #",a]}),M!=null&&M>0&&t.jsxs("span",{children:[" · ",M," pending"]})]})]}),E.length>0&&t.jsx("div",{className:"mt-3 space-y-2",children:E.map(x=>t.jsxs("div",{className:"space-y-1.5",children:[t.jsx("div",{className:"text-xs font-medium text-muted-foreground",children:x.name}),t.jsx(vt,{changes:Object.entries(x.applied).map(([B,V])=>({field:B,old:V.old??null,new:V.new??null})),entityId:x.entityId,ownerSlug:n,showAll:!0})]},x.entityId))}),T.length>0&&t.jsx("div",{className:"mt-3 space-y-1.5",children:T.map(x=>t.jsxs("div",{className:"rounded-md border border-destructive/40 bg-destructive/5 px-2.5 py-2",children:[t.jsxs("div",{className:"text-xs font-medium",children:[x.name," — not written"]}),x.denied&&t.jsxs("div",{className:"mt-0.5 text-xs text-muted-foreground",children:[x.denied.reason,t.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&&h==null&&F&&t.jsx("div",{className:"mt-3 border-t border-border/70 pt-3",children:u?t.jsxs("div",{className:"flex items-center gap-2 w-full",children:[t.jsx("input",{type:"text",placeholder:"What should the agent change?",value:b,onChange:x=>w(x.target.value),className:"h-7 text-xs border rounded px-2 flex-1 bg-background"}),t.jsxs(O,{size:"sm",variant:"destructive",className:"h-7 text-xs",onClick:()=>p.mutate({run_id:a,reason:b||void 0},{onSuccess:()=>v("rejected")}),disabled:p.isPending,children:[p.isPending&&t.jsx(Ne,{size:"sm",className:"mr-1"}),"Reject all"]}),t.jsx(O,{size:"sm",variant:"ghost",className:"h-7 text-xs px-2",onClick:()=>{m(!1),w("")},children:"Cancel"})]}):t.jsxs("div",{className:"flex items-center gap-2",children:[t.jsxs(O,{size:"sm",className:"h-7 text-xs",onClick:()=>d.mutate({run_id:a},{onSuccess:()=>v("approved")}),disabled:d.isPending||p.isPending,children:[d.isPending&&t.jsx(Ne,{size:"sm",className:"mr-1"}),"Approve all proposals"]}),t.jsx(O,{size:"sm",variant:"outline",className:"h-7 text-xs",onClick:()=>m(!0),disabled:d.isPending||p.isPending,children:"Reject with feedback"})]})}),h==="approved"&&t.jsx("div",{className:"mt-3 text-xs text-muted-foreground",children:"All proposals approved."}),h==="rejected"&&t.jsx("div",{className:"mt-3 text-xs text-muted-foreground",children:"Proposals rejected — ask the agent to revise them."}),a!=null&&h==null&&!F&&t.jsx("div",{className:"mt-3 text-xs text-muted-foreground",children:"All proposals reviewed."})]})}function ya(e){if(!e)return;const n={};for(const[s,r]of Object.entries(e))s==="_lobu_idempotency_key"||s==="agent_id"||(n[s]=r);return Object.keys(n).length>0?n:void 0}function ja({renderDetail:e,ownerSlug:n,content:s,connectorDefinitions:r,hideDetails:a=!1}){const[i,c]=j.useState(null),[o,l]=j.useState(!1),[d,p]=j.useState(!1),[u,m]=j.useState(!1),[b,w]=j.useState(!1),[h,v]=j.useState(!1),[N,k]=j.useState(null),[S,R]=j.useState(s.title??""),[T,E]=j.useState(s.text_content??""),M=Kn(),F=qn(),C=Pe(),{currentOwner:x,allOrgs:B,isAuthenticated:V}=Vn(),P=n??x,y=P==="me"?null:P,L=j.useCallback(async g=>{if(!y){Ue.error("Open this event inside a workspace to interact with it.");return}const $=await or(y,Number(s.id),g,crypto.randomUUID());return"event_id"in $&&Ue.success("Recorded"),$},[s.id,y]),D=s.payload_data??{},{audit:Z,operation:le,changeSet:J}=rn(s),pe=Z&&(D.request!==void 0||D.request_status==="too_large"),Q=Z&&Array.isArray(D.sdk_call_trace)&&D.sdk_call_trace.length>0,X=V&&y?(B??[]).find(g=>g.slug===y):void 0,ce=s.semantic_type==="guidance",{isAdmin:fe,isLoading:ee}=Hn(ce?X?.id:void 0),ne=Wn(),je=$r(s),G=mt(C?.item?.href.split(/[?#]/)[0]??""),se=G?.owner===P&&G?.eventId===Number(s.id),re=(g,$,K)=>{C?C.open({href:g,title:$,...K==null?{}:{runId:K}}):M({to:g})},ae=(g,$)=>{if(!y)return null;const K=`/${y}/events?run_ids=${g}`;if(C?.item?.href===K)return null;const ge=()=>re(K,`Run #${g}`,g),Me="Show everything this run recorded";return $?t.jsxs(O,{variant:"ghost",size:"sm",className:"h-7 px-2 text-xs",onClick:ge,title:Me,children:[t.jsx(Zn,{className:"h-3.5 w-3.5"}),$]}):t.jsxs("button",{type:"button",className:"hover:text-foreground hover:underline",onClick:ge,title:Me,children:["Run #",g]})},ie=s.run_id!=null&&!(C&&y&&s.automation_id!=null)?ae(s.run_id):null,de=Jn(s),ue=s.automation_id,xe=C&&y&&de!=null&&ue!=null?()=>C.open({href:`/${y}/automations/${ue}?view=activity&run_id=${de}`,title:`${s.automation_name??`Automation ${ue}`} · Run #${de}`,runId:de}):void 0,te=s.metadata?.source_run_id,z=br(s),ve=(!s.platform||s.platform==="lobu")&&s.connection_id==null&&s.feed_id==null&&s.origin_type==null&&s.automation_id==null&&!Z&&!le&&!J&&!je&&z==null&&s.semantic_type!=="tombstone"&&s.semantic_type!=="notification"&&s.metadata?.tombstone!==!0&&s.interaction_type!=="approval"&&s.interaction_status==null&&!s.is_superseded&&s.superseded_by==null,ke=!!(y&&X&&ve&&(!ce||!ee&&fe)),_=ke&&s.payload_type!=="json_template"&&s.payload_type!=="media",I=()=>{ne.invalidateQueries({queryKey:[ms]}),ne.invalidateQueries({queryKey:[ps]}),ne.invalidateQueries({queryKey:["search-memory"]})},me=async()=>{if(!(!y||!_)){if(w(!1),k(null),s.payload_truncated){p(!0);try{const $=(await Ae("read_knowledge",{content_ids:[Number(s.id)]},{slug:y})).content?.find(K=>Number(K.id)===Number(s.id));R($?.title??s.title??""),E($?.text_content??$?.payload_text??s.text_content??""),l(!0)}catch(g){k(g instanceof Error?g.message:"Failed to load full memory.")}finally{p(!1)}return}R(s.title??""),E(s.text_content??""),l(!0)}},$e=async()=>{if(!y||u)return;if(!T.trim()){k("Memory content cannot be empty.");return}m(!0),k(null);try{const $=s.payload_type==="markdown"||s.payload_type==="text"?s.payload_type:"text",K=ya(s.metadata);await Ae("save_memory",{supersedes_event_id:Number(s.id),semantic_type:s.semantic_type||"note",payload_type:$,title:S.trim()||void 0,content:T,...Array.isArray(s.entity_ids)&&s.entity_ids.length>0?{entity_ids:s.entity_ids}:{},...s.source_url?{source_url:s.source_url}:{},...s.author_name?{author:s.author_name}:{},...s.occurred_at?{occurred_at:s.occurred_at}:{},...s.payload_data&&Object.keys(s.payload_data).length>0?{payload_data:s.payload_data}:{},...K?{metadata:K}:{}},{slug:y}),l(!1),I(),Ue.success("Memory updated")}catch($){k($ instanceof Error?$.message:"Failed to update memory.")}finally{m(!1)}},Ie=async()=>{if(!(!y||h)){v(!0),k(null);try{const g=Number(s.id),$=await Ae("run_sdk",{title:"Delete memory",script:`export default async (_ctx, client) => client.knowledge.delete(${JSON.stringify({content_id:g,reason:"Deleted from web UI"})});`},{slug:y});if($?.success===!1){const ge=typeof $.error=="string"?$.error:$.error?.message||"Failed to delete memory.";throw new Error(ge)}w(!1),se&&C?.close();const K=mt(F.pathname);K?.owner===y&&K.eventId===g&&M({to:"/$owner/events",params:{owner:y}}),I(),Ue.success("Memory deleted")}catch(g){k(g instanceof Error?g.message:"Failed to delete memory.")}finally{v(!1)}}},Te=ke&&!o?b?t.jsxs("span",{className:"inline-flex items-center gap-1.5",children:[t.jsxs(O,{type:"button",variant:"destructive",size:"sm",className:"h-7 px-2.5 text-xs",disabled:h,onClick:()=>void Ie(),children:[h&&t.jsx(Ne,{size:"xs",className:"mr-1.5"}),h?"Deleting...":"Delete"]}),t.jsx(O,{type:"button",variant:"ghost",size:"sm",className:"h-7 px-2 text-xs",disabled:h,onClick:()=>{w(!1),k(null)},children:"Cancel"})]}):t.jsxs(t.Fragment,{children:[_&&t.jsxs(O,{type:"button",variant:"ghost",size:"sm","aria-label":"Edit memory",className:"h-7 gap-1 px-2 text-xs text-muted-foreground hover:text-foreground",disabled:d||h,onClick:()=>void me(),children:[d?t.jsx(Ne,{size:"xs"}):t.jsx(ds,{className:"h-3.5 w-3.5"}),t.jsx("span",{children:d?"Loading...":"Edit"})]}),t.jsxs(O,{type:"button",variant:"ghost",size:"sm","aria-label":"Delete memory",className:"h-7 gap-1 px-2 text-xs text-muted-foreground hover:text-destructive",disabled:d,onClick:()=>{k(null),w(!0)},children:[t.jsx(us,{className:"h-3.5 w-3.5"}),t.jsx("span",{children:"Delete"})]})]}):null,tt=o?t.jsxs("form",{className:"mt-2 space-y-3 rounded-lg border bg-background p-3 text-foreground",onSubmit:g=>{g.preventDefault(),$e()},children:[t.jsxs("div",{className:"space-y-1.5",children:[t.jsx("label",{htmlFor:`memory-title-${s.id}`,className:"block text-xs font-medium text-muted-foreground",children:"Title"}),t.jsx(Qn,{id:`memory-title-${s.id}`,"aria-label":"Memory title",value:S,onChange:g=>R(g.target.value),placeholder:"Optional short summary",disabled:u})]}),t.jsxs("div",{className:"space-y-1.5",children:[t.jsxs("label",{htmlFor:`memory-content-${s.id}`,className:"block text-xs font-medium text-muted-foreground",children:["Content",t.jsx("span",{className:"ml-1 text-destructive",children:"*"})]}),t.jsx(Gn,{id:`memory-content-${s.id}`,"aria-label":"Memory content",value:T,onChange:g=>E(g.target.value),rows:5,disabled:u})]}),N&&t.jsx("div",{role:"alert",className:"rounded-md bg-destructive/10 px-3 py-2 text-sm text-destructive",children:N}),t.jsx(Yn,{onCancel:()=>{l(!1),k(null)},cancelDisabled:u,children:t.jsxs(O,{type:"submit",disabled:u||T.trim().length===0,children:[u&&t.jsx(Ne,{size:"xs",className:"mr-1.5"}),u?"Saving...":"Save"]})})]}):null,Be=!o&&N?t.jsx("div",{role:"alert",className:"mt-2 rounded-md bg-destructive/10 px-3 py-2 text-sm text-destructive",children:N}):null,Ee=je?t.jsx(Ir,{content:s}):y?J?t.jsx(ga,{content:s,ownerSlug:y}):le?t.jsx(ha,{ownerSlug:y,content:s,batchReview:typeof te=="number"?ae(te,"Review run"):null}):void 0:void 0,he=e?e(Ee):{content:Ee,nativeHeading:Ee!=null};return t.jsx(ba,{primaryContent:he.content,nativeHeading:he.nativeHeading,heading:z&&y?t.jsx(Cr,{event:z,ownerSlug:y}):void 0,body:tt??(z&&y?t.jsx(Ar,{event:z,ownerSlug:y}):void 0),detailLinks:he.links,headingAside:he.headingAside,hideDetails:a,presentation:"detail",content:s,ownerSlug:P??void 0,connectorDefinitions:r,onRenderedAction:y?L:void 0,runAction:ie,memoryActions:Te,memoryFeedback:Be,runId:de??s.run_id??null,onRunSelect:xe,auditDetails:(pe||Q)&&t.jsxs("div",{className:"space-y-3",children:[t.jsx("div",{className:"flex flex-wrap gap-2",children:[{key:"request",label:"Request",available:pe},{key:"calls",label:"SDK calls",available:Q}].map(g=>g.available?t.jsxs(O,{variant:"outline",size:"sm","aria-expanded":i===g.key,onClick:()=>c($=>$===g.key?null:g.key),children:[i===g.key?t.jsx(dt,{className:"h-3.5 w-3.5"}):t.jsx(ut,{className:"h-3.5 w-3.5"}),g.label]},g.key):null)}),i==="request"&&(D.request_status==="too_large"?t.jsxs("p",{className:"text-sm text-muted-foreground",children:["The request was too large to retain",typeof D.request_bytes=="number"?` (${D.request_bytes.toLocaleString()} bytes).`:"."]}):t.jsx(Ft,{value:D.request})),i==="calls"&&t.jsx(Ft,{value:D.sdk_call_trace})]})})}function va(e,n){const s=e.payload_data??{},r=e.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 an(e.interaction_status,typeof r.status=="string"?r.status:void 0)}function _a(e){return e==="pending_approval"?"Needs approval":e==="confirmed"?"Approved":e?Ye(e):null}function ba({presentation:e,primaryContent:n,nativeHeading:s=!1,heading:r,body:a,detailLinks:i,headingAside:c,content:o,ownerSlug:l,connectorDefinitions:d,onRenderedAction:p,runAction:u,memoryActions:m,memoryFeedback:b,auditDetails:w,runId:h,onRunSelect:v,hideDetails:N=!1}){const[k,S]=j.useState(!1),R=o.metadata??{},T=typeof o.score=="number"&&Number.isFinite(o.score)?Math.round(o.score):"-",E=o.payload_type||"text",M=E==="text"&&(o.semantic_type==="notification"||o.automation_id!=null)?"markdown":E,F=o.text_content||"",C=e==null&&(M==="text"||M==="markdown")&&F.length>500,x=C&&!k?`${F.slice(0,500)}...`:F,B=o.payload_data??{},V=rn(o),{audit:P,operation:y}=V,L=va(o,V),D=_a(L),Z=(P?Bt(o).title:null)??o.title,le=P&&B.error&&typeof B.error=="object"?B.error.message:void 0,[J,pe]=j.useState(P&&n==null&&i==null),Q=P?B.duration_ms:R.duration_ms,X=typeof Q=="number"&&Number.isFinite(Q)&&Q>=0?Q:null,ce=P&&typeof B.sdk_call_count=="number"&&Number.isSafeInteger(B.sdk_call_count)&&B.sdk_call_count>=0?B.sdk_call_count:null,fe=R.thumbnail_url||R.thumbnail,ee=R.media_url,ne=sa(R),je=Object.entries(o.classifications||{}).flatMap(([_,I])=>{const me=ia(I);return me.values.map($e=>({slug:_,value:$e,isManual:me.isManual}))}),G=(()=>{const _=o.platform||(typeof R.platform=="string"?R.platform:null),I=o.connection_id!=null?o.connection_id:R.source_connection_id!=null?Number(R.source_connection_id):null;return{...o,platform:_,connection_id:I!=null&&Number.isFinite(I)?I:null}})(),se=(()=>{const _=o.source_url??R.browser_url;if(typeof _!="string"||!URL.canParse(_))return null;const I=new URL(_);return I.protocol==="https:"||I.protocol==="http:"?I:null})(),re=o.occurred_at?new Date(o.occurred_at):null,{KindIcon:ae,kindLabel:ie}=Ut(o),de=t.jsx(yt,{source:G,connectorDefinitions:d,sourceUrl:se,label:ie,fallback:t.jsx(ae,{className:"h-4 w-4"})}),ue=ne.length>0?t.jsx("dl",{className:"grid gap-x-3 gap-y-2 text-sm sm:grid-cols-[minmax(140px,180px)_1fr]",children:ne.map(([_,I])=>t.jsxs("div",{className:"contents",children:[t.jsx("dt",{className:"text-muted-foreground",children:Ye(_)}),t.jsx("dd",{className:"min-w-0 break-words font-mono text-xs sm:text-sm",children:na(I)})]},_))}):null,xe=a?t.jsx("div",{className:"mt-1",children:a}):t.jsxs(t.Fragment,{children:[o.rating&&t.jsx("div",{className:"flex items-center gap-1 mb-2",children:[1,2,3,4,5].map(_=>t.jsx(zt,{className:`h-4 w-4 ${_<=Number(o.rating)?"fill-yellow-400 text-yellow-400":"text-muted-foreground"}`},_))}),fe&&t.jsx("a",{href:ee||o.source_url||"#",target:"_blank",rel:"noopener noreferrer",className:"block mb-2",children:t.jsx("img",{src:fe,alt:"",className:`rounded-md object-cover ${M==="media"?"max-h-96 w-full":"max-h-48"}`,loading:"lazy"})}),(()=>{switch(M){case"markdown":if(x)return t.jsx("div",{className:"max-w-none text-sm space-y-2",children:t.jsx(Mn,{text:x})});break;case"json_template":{const _=o.payload_data;if(_?._truncated===!0&&typeof _.bytes=="number")return t.jsxs("div",{className:"space-y-2 text-sm",children:[t.jsx("p",{role:"status",children:"This report is too large for the feed preview. Open the full event to view its complete data."}),l?t.jsx(W,{to:Kt(l,Number(o.id)),className:"underline underline-offset-4",children:"Open full report"}):null]});const I=o.payload_template;if(I?.root)return t.jsx(Zr,{template:I,data:o.payload_data||{},onAction:n?void 0:p},`${l}:${o.id}`);if(x)return t.jsx("div",{className:"text-sm whitespace-pre-wrap",children:x});break}case"media":return t.jsxs("div",{className:"space-y-3",children:[!fe&&ee&&t.jsx("a",{href:ee,target:"_blank",rel:"noopener noreferrer",className:"text-sm text-primary hover:underline truncate block",children:ee}),x&&t.jsx("div",{className:"text-sm whitespace-pre-wrap text-muted-foreground",children:x})]});case"empty":return t.jsxs("div",{className:"space-y-3",children:[w,ue??(w?null:t.jsx("p",{className:"text-sm text-muted-foreground italic",children:"No content"}))]});default:if(x)return t.jsx("div",{className:"text-sm whitespace-pre-wrap",children:x});break}return t.jsxs("div",{className:"space-y-3",children:[ee&&!fe&&t.jsx("a",{href:ee,target:"_blank",rel:"noopener noreferrer",className:"text-sm text-muted-foreground hover:text-foreground truncate block",children:ee}),ue]})})()]}),te=n!=null||e==="detail"&&P,z=c!==void 0,ve=te||i!=null,ke=!!(D&&!s||ce!=null||X!=null||!z&&m!=null||T!=="-"&&o.score_breakdown!=null||se!=null);return j.useEffect(()=>{if(!z||!J)return;const _=I=>{I.key==="Escape"&&(I.preventDefault(),pe(!1))};return window.addEventListener("keydown",_),()=>window.removeEventListener("keydown",_)},[z,J]),t.jsxs(t.Fragment,{children:[t.jsxs("div",{className:Y("flex gap-3",e==="detail"&&"mb-5",z&&"relative"),children:[t.jsx(Dn,{children:de}),t.jsxs("div",{className:"min-w-0 flex-1",children:[e==="detail"&&(()=>{const _={semantic_types:o.semantic_type,...typeof o.automation_id=="number"?{produced_by:String(o.automation_id)}:{},...typeof o.run_id=="number"?{run_ids:String(o.run_id)}:{}};return t.jsxs("div",{className:"mb-2 flex flex-wrap items-center gap-2 text-xs text-muted-foreground",children:[o.semantic_type?l?t.jsx(W,{to:"/$owner/events",params:{owner:l},search:_,className:"hover:underline",title:`Show all ${ie} events`,children:ie}):t.jsx("span",{children:ie}):t.jsx("span",{children:ie}),re&&t.jsx("time",{dateTime:re.toISOString(),children:Fn(re)}),u]})})(),t.jsxs("div",{className:"flex items-start justify-between gap-3",children:[(r??Z)&&!s&&t.jsx("h4",{className:Y("min-w-0 font-medium",e==="detail"?"text-xl leading-snug":"line-clamp-2 text-sm"),children:r??Z}),e!=="detail"&&re&&t.jsx(Ln,{at:re}),z&&t.jsxs("div",{className:"flex shrink-0 flex-wrap items-center justify-end gap-1 pt-0.5",children:[c,m,ve&&t.jsxs(O,{type:"button",variant:"ghost",size:"sm",className:"h-7 gap-1 px-2 text-muted-foreground hover:text-foreground","aria-expanded":J,onClick:()=>pe(_=>!_),children:["Details",J?t.jsx(dt,{className:"h-3.5 w-3.5"}):t.jsx(ut,{className:"h-3.5 w-3.5"})]})]})]}),ke&&t.jsxs("div",{className:"mt-2 flex flex-wrap items-center gap-x-3 gap-y-1 text-xs text-muted-foreground",children:[D&&!s&&t.jsxs(H,{variant:L==="failed"?"destructive":"secondary",className:"gap-1 text-xs",children:[L==="failed"?t.jsx(qt,{className:"h-3 w-3"}):L==="completed"?t.jsx(Vt,{className:"h-3 w-3"}):null,D]}),ce!=null&&t.jsxs("span",{children:[ce," SDK ",ce===1?"call":"calls"]}),X!=null&&t.jsxs("span",{className:"inline-flex items-center gap-1",children:[t.jsx(On,{className:"h-3 w-3"}),X<1e3?`${Math.round(X)}ms`:`${Number((X/1e3).toFixed(2))}s`]}),T==="-"?null:o.score_breakdown?t.jsxs(Ht,{children:[t.jsx(Wt,{asChild:!0,children:t.jsx(O,{variant:"ghost",size:"sm",className:"h-7 px-2",children:t.jsx("span",{className:"font-medium",children:T})})}),t.jsx(Jt,{className:"w-64",align:"end",children:t.jsxs("div",{className:"space-y-2",children:[t.jsx("h4",{className:"font-medium",children:"Score Breakdown"}),t.jsx(ra,{breakdown:o.score_breakdown})]})})]}):null,se&&t.jsxs(Pn,{children:[t.jsx(Bn,{asChild:!0,children:t.jsx(O,{variant:"ghost",size:"sm",className:"h-7 gap-1 px-1",asChild:!0,children:t.jsxs("a",{href:se.href,target:"_blank",rel:"noopener noreferrer",children:[t.jsx(Qt,{className:"h-3.5 w-3.5"}),t.jsx("span",{children:"View original"})]})})}),t.jsx(Un,{children:"View original"})]}),!z&&m]}),b,l&&!(e==="detail"&&y)&&t.jsx(zn,{owner:l,source:G,connectorDefinitions:d,variant:"chips",className:"mt-2 text-xs",runId:h,onRunSelect:v}),(o.author_name||!l)&&!(e==="detail"&&y)&&t.jsx("div",{className:"mt-2 text-xs text-muted-foreground",children:o.author_name||ta(o)})]}),z&&J&&ve&&t.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:[i,te&&xe]})]}),typeof le=="string"&&t.jsx("p",{className:"mb-2 text-sm whitespace-pre-wrap text-destructive",children:le}),n,!te&&xe,(te||i!=null)&&c===void 0&&!(N&&n!=null)&&t.jsxs("details",{className:"mt-5 border-t pt-3",open:J,onToggle:_=>pe(_.currentTarget.open),children:[t.jsx("summary",{className:"cursor-pointer text-sm text-muted-foreground",children:"Details"}),J&&t.jsxs("div",{className:"mt-3 space-y-3",children:[i,te&&xe]})]}),C&&t.jsx(O,{variant:"link",size:"sm",className:"px-0 h-6 mt-1",onClick:()=>S(!k),children:k?t.jsxs(t.Fragment,{children:[t.jsx(dt,{className:"h-3 w-3 mr-1"})," Show less"]}):t.jsxs(t.Fragment,{children:[t.jsx(ut,{className:"h-3 w-3 mr-1"})," Show more"]})}),je.length>0&&t.jsx("div",{className:"flex flex-wrap gap-1.5 mt-3",children:je.map(_=>t.jsx(aa,{slug:_.slug,value:_.value||"",isManual:_.isManual},_.slug))})]})}function Na(e,n){const s=e.metadata??{},r=Gt(e)?Bt(e,n):null,{KindIcon:a,kindLabel:i}=Ut(e),c=hs(e,n),o=e.interaction_error??(typeof s.error_message=="string"?s.error_message:r?.failed?"Failed":null),l=e.platform||(typeof s.platform=="string"?s.platform:null);return{title:c,kindLabel:i,error:o,KindIcon:a,platform:l}}function wa(e,n){const s=Number(e.metadata?.resource_id);return n!=="me"&&e.semantic_type==="notification"&&e.metadata?.resource_type==="automation"&&Number.isSafeInteger(s)&&s>0?gs(n,String(s)):Kt(n,Number(e.id))}function ka(e,n){const s=ys(e);return s&&n?n(s):null}function Ca({content:e,ownerSlug:n,connectorDefinitions:s,hideOriginator:r=!1,showEntity:a=!1,connectionName:i,callerName:c,extra:o,unread:l=!1,onOpen:d}){const p=Pe(),{title:u,kindLabel:m,error:b,KindIcon:w,platform:h}=Na(e,i),v=e.interaction_status==="pending",N=!!b||e.interaction_status==="failed",k=n?wa(e,n):null,S=mt(p?.item?.href.split(/[?#]/)[0]??""),R=S!=null&&S.owner===n&&S.eventId===Number(e.id),T=[m,a?e.entity_name:null,e.automation_name,r?null:e.connection_name??e.feed_name,e.agent_name??e.client_name??e.device_label??ka(e,c),o],E=t.jsx(Le,{mark:t.jsx(yt,{source:{...e,platform:h},connectorDefinitions:s,label:m,fallback:t.jsx(w,{className:"h-4 w-4 text-muted-foreground"})}),name:u,badge:l&&!N?t.jsx("span",{className:"sr-only",children:"Unread"}):null,tone:v||l&&!N?"amber":N?"destructive":null,details:t.jsx(Qe,{parts:T}),at:e.occurred_at?new Date(e.occurred_at).getTime():null});if(!k)return t.jsx("div",{className:Y(Je,"cursor-default"),children:E});const M=C=>{d?.(),!(!p||C.metaKey||C.ctrlKey||C.shiftKey||C.altKey||C.button!==0)&&(C.preventDefault(),p.open({href:k,title:u}))},F=xs(k);return t.jsx(W,{to:F.pathname,search:F.search,"aria-current":R?"true":void 0,className:Y(Je,R&&"bg-accent"),onClick:M,children:E})}function Oe(e,n,s=`${n}s`){return`${e} ${e===1?n:s}`}function Nt(e){const n=[...new Set(e.apps.map(r=>r.name))];if(n.length>1)return Oe(e.apps.length,"app");const s=n[0]??"Unknown app";return e.apps.length>1?`${s} (${e.apps.length})`:s}function Lt(e){const{oldestAt:n,newestAt:s}=e;if(n==null||s==null)return null;const r=ks(n,s),a=Se(n,r?"p":"d MMM p"),i=Se(s,r?"p":"d MMM p");return a===i?a:`${a}–${i}`}function cn(e){const n=new Map;for(const s of e.calls)n.set(s.call.title,(n.get(s.call.title)??0)+1);return[...n].map(([s,r])=>({title:s,count:r})).sort((s,r)=>r.count-s.count)}function dn(e){const n=cn(e)[0]?.title??"Ran background checks";return`${Nt(e)} ${n.charAt(0).toLowerCase()}${n.slice(1)}`}function un(e){return cn(e).slice(1).map(n=>`${n.title.charAt(0).toLowerCase()}${n.title.slice(1)} ${n.count}×`)}function Aa(e,n){if(e.source)return e.source.name;if(e.kind==="background")return dn(e);if(n.idle)return"Looked around, changed nothing";const{topAction:s}=n;return n.changed[0]??(s?`${s.title}${s.count>1?` · ${s.count}×`:""}`:null)??n.explicitTitles[0]??Nt(e)}function Ra(e){return[e.reads>0?Oe(e.reads,"read"):null,e.actions>0?Oe(e.actions,"action"):null].filter(Boolean).join(" · ")}function Sa({summary:e,headline:n}){const s=Ra(e),r=e.changed[0]===n?e.changed.slice(1):e.changed;if(r.length===0){const c=e.idle?e.explicitTitles.slice(0,2):[];return t.jsx("span",{className:"block truncate",children:[...c,s].filter(Boolean).join(" · ")})}const a=r.slice(0,2),i=r.length-a.length;return t.jsxs("span",{className:"block truncate text-foreground/80",children:["Changed: ",a.join(" · "),i>0?` · ${i} more`:"",s?t.jsxs("span",{className:"text-muted-foreground",children:[" — ",s]}):null]})}function $a({stretch:e,ownerSlug:n,connectorDefinitions:s,connectionName:r,sourceConnection:a,showEntity:i=!1},c){const o=Pe();return!o||!n?{open:null,selected:!1}:{selected:o.item?.key===e.key,open:()=>o.open({href:"",key:e.key,title:c,workStretch:{stretch:e,ownerSlug:n,connectorDefinitions:s,connectionName:r,sourceConnection:a,showEntity:i}})}}function Ia(e){if(e.length<2)return null;const n=Math.max(...e)-Math.min(...e),s=Math.round(n/(e.length-1)/1e3);return s<1?null:s<90?`every ${s}s`:`every ${Math.round(s/60)} min`}function Ta(e){const n=new Map;for(const s of e.calls){const r=ws(s.content),a=n.get(r.key)??{name:r.name,titles:new Map,ats:[]};a.titles.set(s.call.title,(a.titles.get(s.call.title)??0)+1),s.at!=null&&a.ats.push(s.at),n.set(r.key,a)}return[...n].map(([s,{name:r,titles:a,ats:i}])=>({key:s,name:r,checks:[...a].sort((c,o)=>o[1]-c[1]).map(([c,o])=>`${c} · ${o}×`),every:Ia(i),lastAt:i.length>0?Math.max(...i):null}))}function Ea({stretch:e}){const n=dn(e),s=un(e),r=[`${n} · ${e.calls.length}×`,e.oldestAt!=null?`since ${Se(e.oldestAt,"p")}`:null,...s].filter(Boolean).join(" · ");return t.jsxs(Ht,{children:[t.jsx(Wt,{asChild:!0,children:t.jsxs("button",{type:"button",className:"flex w-full min-w-0 items-center gap-2 rounded-md px-2 py-1 text-left text-xs text-muted-foreground hover:bg-accent/50 data-[state=open]:bg-accent data-[state=open]:text-foreground",children:[t.jsx(Yt,{"aria-hidden":"true",className:"h-3 w-3 shrink-0"}),t.jsx("span",{className:"truncate",children:r})]})}),t.jsxs(Jt,{align:"start",className:"w-80 p-0",children:[t.jsx("p",{className:"border-b border-border px-3 py-2 text-xs text-muted-foreground",children:"Apps checking in today. Background, not work they did."}),t.jsx("ul",{className:"divide-y divide-border",children:Ta(e).map(a=>t.jsxs("li",{className:"px-3 py-2",children:[t.jsx("div",{className:"text-sm font-medium",children:a.name}),t.jsx("div",{className:"text-xs text-muted-foreground",children:[...a.checks,a.every,a.lastAt!=null?`last checked ${js(a.lastAt,{addSuffix:!0})}`:null].filter(Boolean).join(" · ")})]},a.key))})]})]})}function Ma({hideOriginator:e=!1,...n}){const{stretch:s,connectorDefinitions:r,sourceConnection:a}=n,i=j.useMemo(()=>vs(s),[s]),c=Aa(s,i),{open:o,selected:l}=$a(n,c),d=s.kind==="background",{source:p}=s,u=i.failedCalls.length+i.failedOperations.length+s.flagged.length,m=!u&&!p&&(d||i.idle),b=d?Yt:i.idle&&!p?_s:bs,w=p?[Lt(s),Oe(s.items.length,"item"),u>0?`${u} failed`:null]:d?[s.oldestAt!=null?`since ${Se(s.oldestAt,"p")}`:null,...un(s)]:[e?null:Nt(s),Oe(s.calls.length,"call"),Lt(s),u>0?`${u} failed`:null],h=t.jsx(Le,{mark:p?t.jsx(yt,{source:{platform:a?.(p.connectionId)?.connectorKey??s.items[0]?.group.root?.platform??null},connectorDefinitions:r,label:p.name,fallback:t.jsx(b,{className:"h-4 w-4 text-muted-foreground"})}):t.jsx(b,{className:"h-4 w-4 text-muted-foreground"}),name:c,badge:d?t.jsxs("span",{className:"shrink-0 text-xs tabular-nums text-muted-foreground",children:[s.calls.length,"×"]}):null,tone:u>0?"destructive":null,details:t.jsxs(t.Fragment,{children:[p?t.jsx("span",{className:"block truncate text-foreground/80",children:Ns(s).map(N=>N.label).join(" · ")}):d?null:t.jsx(Sa,{summary:i,headline:c}),t.jsx("span",{className:"block truncate",children:w.filter(Boolean).join(" · ")})]}),at:s.newestAt}),v=Y(Je,m&&"opacity-60");return o?t.jsx("button",{type:"button","aria-current":l?"true":void 0,className:Y(v,l&&"bg-accent opacity-100"),onClick:o,children:h}):t.jsx("div",{className:Y(v,"cursor-default"),children:h})}function Qa({presentation:e="summary",renderDetail:n,hideDetails:s=!1,organizationId:r,ownerSlug:a,entityId:i,filters:c,showEntityLinks:o=!1,hideOriginator:l=!1,emptyState:d,groupStretches:p=!1,foldRunSatellites:u=!0,renderLead:m,hiddenPinned:b,unreadNotices:w,onMarkRead:h,extraRows:v,onGoToLatest:N}){const{isAuthenticated:k,isReady:S,session:R}=et(),{isMember:T,isLoading:E}=Cs(),M=a==="me",F=!M&&S&&k&&T,C=!M&&S&&(!k||!E&&!T),{data:x=[]}=As(S&&F?r:null),{data:B=[]}=Rs(C?a:null),V=F?x:B,{data:P}=Ss(p&&S&&F?r:null),y=j.useMemo(()=>{const f=new Map((P??[]).map(A=>[A.id,A.display_name??A.connector_name]));return A=>f.get(A)??null},[P]),{data:L}=$s({enabled:S&&F}),D=R?.user?.id??null,Z=j.useCallback(f=>f.kind==="user"?f.userId===D?"You":null:L?.find(A=>A.agentId===f.agentId)?.name??f.agentId,[L,D]),le=j.useMemo(()=>{const f=new Map((P??[]).map(A=>[A.id,A.connector_key]));return A=>{const q=f.get(A);return q&&r?{connectorKey:q,organizationId:r}:null}},[P,r]),J=Is(S&&F?r:null,i,c,a),pe=Ts(C?a:null,i,c),Q=C?pe:J,{data:X,isLoading:ce,error:fe,fetchNextPage:ee,hasNextPage:ne,isFetchingNextPage:je}=Q,G=j.useMemo(()=>X?.pages.flatMap(f=>f.content)??[],[X]),se=j.useMemo(()=>{const f=Es(G,{foldRunSatellites:u}),A=f.map(oe=>oe.head),q=new Map(f.map(oe=>[oe.head.id,oe])),ye=Ms(A),Ce=Array.from(ye.entries()).map(([oe,st])=>{const Rt=st.root||st.replies[0],St=Rt?q.get(Rt.id):void 0;return{rootId:oe,group:st,history:St?.history??[],runId:St?.runId??null}});return b?Ds(Ce,b):Ce},[G,u,b]),re=m?se[0]:void 0,ae=re?It(re)??void 0:void 0,ie=ae?se.slice(1):se,de=f=>w?.(f)??[],ue=p&&Fs(c),xe=`${r}:${i}:${JSON.stringify(Ls(c))}:${c.beforeOccurredAt}:${c.beforeId}`,[te,z]=j.useState(null),ve=()=>{let f=Number.NEGATIVE_INFINITY;for(const A of G){const q=Date.parse(A.occurred_at);q>f&&(f=q)}z({scope:xe,ids:new Set(G.map(A=>A.id)),newestAt:f})},ke=ue&&G.length>0&&!Q.isFetching,_=te?.scope!==xe;j.useEffect(()=>{ke&&_&&ve()});const I=j.useRef(null),me=ue?Os(ie,_?null:te,f=>Bs(f,{connectionName:y,groupSources:!Us(c,i)})):{entries:ie.map(f=>({kind:"single",node:f})),pending:[]},$e=new Date().toDateString(),Ie=f=>f.kind==="stretch"&&f.stretch.kind==="background"&&f.stretch.newestAt!=null&&new Date(f.stretch.newestAt).toDateString()===$e,Te=[...me.entries,...me.pending].find(Ie),tt=me.entries.filter(f=>!Ie(f)),Be=me.pending.filter(f=>!Ie(f)).length,Ee=!M&&(!S||k&&E||F&&Q.isPending);if(fe)return t.jsx(Ps,{label:"events"});const he=e==="detail",g=(f,A,q={})=>{const ye=de(f);return{key:A,occurredAt:f.occurred_at,content:t.jsx(Ca,{content:f,ownerSlug:a,connectorDefinitions:V,connectionName:y,callerName:Z,hideOriginator:l,showEntity:o,extra:q.extra,unread:ye.length>0,onOpen:ye.length>0&&h?()=>h(ye):void 0})}},$=f=>{if(f.kind==="stretch"){const{stretch:oe}=f;return[{key:oe.key,occurredAt:oe.newestAt,content:t.jsx(Ma,{stretch:oe,ownerSlug:a,connectorDefinitions:V,connectionName:y,sourceConnection:le,hideOriginator:l,showEntity:o})}]}const{rootId:A,group:q}=f.node,ye=q.root||q.replies[0];if(!ye)return[];const Ce=q.root?q.replies.length:q.replies.length-1;return[g(ye,A,{extra:Ce>0?`${Ce} ${Ce===1?"reply":"replies"}`:null})]},K=f=>{if(f.kind!=="single")return[];const A=It(f.node);return A?[{key:f.node.rootId,occurredAt:A.occurred_at,content:t.jsx(ja,{ownerSlug:a,content:A,renderDetail:n,connectorDefinitions:V,hideDetails:s})}]:[]},ge=tt.flatMap(he?K:$),Me=G.at(-1)?.occurred_at,wt=(v??[]).filter(f=>!ne||Me==null||(ze(f.occurredAt)??0)>=(ze(Me)??0)),kt=wt.length>0&&(ge.length>0||ae)?[...ge,...wt].sort((f,A)=>(ze(A.occurredAt)??0)-(ze(f.occurredAt)??0)):ge,mn=t.jsx(Zs,{rows:!he,groupByDate:!he,isLoading:ce||Ee,emptyState:ae||Te?.kind==="stretch"?null:d,hasNextPage:!!ne,isFetching:Q.isFetching,isFetchingNextPage:je,onLoadMore:()=>void ee(),items:kt}),pn=Be>0?t.jsx("div",{className:"pointer-events-none sticky top-2 z-10 flex h-0 justify-center overflow-visible",children:t.jsxs(O,{size:"sm",className:"pointer-events-auto h-7 rounded-full px-3 text-xs shadow-md",onClick:()=>{ve(),I.current?.scrollIntoView?.({block:"start",behavior:"smooth"})},children:[Be," new"]})}):null,Ct=Te?.kind==="stretch"?t.jsx(Ea,{stretch:Te.stretch}):null,nt=c.beforeOccurredAt?Da(c.beforeOccurredAt):null,fn=Ct||nt||N?t.jsxs("div",{className:"flex min-w-0 items-center gap-2",children:[t.jsx("div",{className:"min-w-0 flex-1",children:Ct}),nt?t.jsxs("span",{className:"shrink-0 text-xs text-muted-foreground",children:["From ",nt]}):null,N&&t.jsxs(O,{variant:"ghost",size:"sm",className:"h-7 shrink-0 gap-1.5 px-2 text-xs font-normal text-muted-foreground",onClick:N,children:[t.jsx(zs,{"aria-hidden":"true",className:"h-3.5 w-3.5"}),"Back to latest"]})]}):null,At=t.jsxs(t.Fragment,{children:[t.jsx("div",{ref:I,className:"scroll-mt-4"}),pn,fn,mn]});return!ae||!m?At:t.jsxs(t.Fragment,{children:[m(ae,{hasEarlier:kt.length>0||!!ne}),At]})}function Da(e){const n=new Date(e);return Number.isNaN(n.getTime())?null:Xs(n)?Se(n,"p"):Se(n,er(n)?"d MMM, p":"d MMM yyyy, p")}export{Qa as E,Ja as R,ba as a,Wa as b,Va as c,Er as d,Nt as e,Ca as f,Oe as p,Ha as r,Lt as s};
|
|
2
|
-
//# sourceMappingURL=events-feed-BI7wNRUY.js.map
|