@lobu/runtime-server 22.0.0 → 23.0.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/catalogs/connectors.json +1353 -181
- package/dist/catalogs/skills.json +1 -1
- package/dist/component.json +1 -1
- package/dist/connectors/README.md +14 -1
- package/dist/connectors/google_gmail.ts +1 -0
- package/dist/connectors/jira-helpers.ts +313 -0
- package/dist/connectors/jira.ts +29 -221
- package/dist/connectors/linkedin-browser-script.ts +13 -0
- package/dist/connectors/linkedin-draft-page.js +104 -0
- package/dist/connectors/linkedin-drafts.ts +73 -0
- package/dist/connectors/linkedin-identity.ts +32 -0
- package/dist/connectors/linkedin-inbox-adapter.js +1185 -0
- package/dist/connectors/linkedin-inbox.ts +156 -0
- package/dist/connectors/linkedin-like.ts +114 -0
- package/dist/connectors/linkedin-takeout.ts +577 -0
- package/dist/connectors/linkedin.ts +3998 -0
- package/dist/connectors/takeout-utils.ts +240 -0
- package/dist/connectors/tiktok-inbox-page.js +9 -9
- package/dist/connectors/tiktok-web-page.js +21 -15
- package/dist/connectors/tiktok_web.ts +63 -30
- package/dist/connectors/whatsapp-web-adapter.js +64 -564
- package/dist/connectors/whatsapp-web-helpers.ts +30 -444
- package/dist/connectors/whatsapp-web-identity.ts +20 -6
- package/dist/connectors/whatsapp_web.ts +45 -645
- package/dist/connectors/x-dm-adapter.js +556 -0
- package/dist/connectors/x-identity.ts +31 -2
- package/dist/connectors/x.ts +266 -120
- package/dist/db/migrations/20261017120000_drop_feeds_kind_virtual.sql +26 -0
- package/dist/db/migrations/20261017130000_drop_retired_dead_code_columns.sql +46 -0
- package/dist/dependencies.bun.lock +41 -41
- package/dist/guest.bundle.js +288 -148
- package/dist/owletto/dist/assets/_-3J-IrxWk.js +2 -0
- package/dist/owletto/dist/assets/{_-CEPl6gU4.js → _-DYUE3ix4.js} +3 -3
- package/dist/owletto/dist/assets/_agentId-Bn2IAjIy.js +2 -0
- package/dist/owletto/dist/assets/{_agentId-CBC_SadO.js → _agentId-Cam7Z0N7.js} +2 -2
- package/dist/owletto/dist/assets/{_automationId-YTTNksw6.js → _automationId-CXEiKVZJ.js} +2 -2
- package/dist/owletto/dist/assets/{_connectorKey._connectionId-fK0h7RAp.js → _connectorKey._connectionId-CS85l61t.js} +2 -2
- package/dist/owletto/dist/assets/{_connectorKey.index-C7TPS598.js → _connectorKey.index-clVDIyW0.js} +2 -2
- package/dist/owletto/dist/assets/{_conversationId-CEhxlTIo.js → _conversationId-Ci2k-BuN.js} +2 -2
- package/dist/owletto/dist/assets/{_deploymentId-BQfYN1U2.js → _deploymentId-BuUzGtVL.js} +2 -2
- package/dist/owletto/dist/assets/{_eventId-Cl8GSdjg.js → _eventId-B0662F8h.js} +2 -2
- package/dist/owletto/dist/assets/_name-CwWePlOl.js +2 -0
- package/dist/owletto/dist/assets/{_owner-cUtGHqSw.js → _owner-dTWkrKsK.js} +3 -3
- package/dist/owletto/dist/assets/_shape-BtS3y4M9.js +2 -0
- package/dist/owletto/dist/assets/_skillKey-Dc9m-nlR.js +2 -0
- package/dist/owletto/dist/assets/{_slug-CU1PuHB9.js → _slug-DQHutM41.js} +2 -2
- package/dist/owletto/dist/assets/_viewKey-B30ik8ma.js +2 -0
- package/dist/owletto/dist/assets/_viewKey-CUHypQnF.js +2 -0
- package/dist/owletto/dist/assets/{accept-invitation-D3OgJG4i.js → accept-invitation-w17IFTtf.js} +2 -2
- package/dist/owletto/dist/assets/{activity-route-view-DQglkhXU.js → activity-route-view-CMqYiiKM.js} +2 -2
- package/dist/owletto/dist/assets/{agent-card-controls-DzRs4Ix9.js → agent-card-controls-mnTN2AZt.js} +2 -2
- package/dist/owletto/dist/assets/{agent-client-setup-list-B2SvH7xD.js → agent-client-setup-list-Bg3hBfUV.js} +2 -2
- package/dist/owletto/dist/assets/{agent-connect-pages-B6uKvT_X.js → agent-connect-pages-B_vrqLVc.js} +2 -2
- package/dist/owletto/dist/assets/{agent-editor-form-oUnIYHd7.js → agent-editor-form-hTs7eO_U.js} +2 -2
- package/dist/owletto/dist/assets/{agent-guardrails-route-BaV1VpDh.js → agent-guardrails-route-BOrCXcAl.js} +2 -2
- package/dist/owletto/dist/assets/{agent-loading-shells-CtZJM2Gc.js → agent-loading-shells-Dqcvky-k.js} +2 -2
- package/dist/owletto/dist/assets/{agent-permissions-matrix-Ds48KFK9.js → agent-permissions-matrix-BOo_4r_4.js} +2 -2
- package/dist/owletto/dist/assets/{agent-skill-context-DPk5r08w.js → agent-skill-context-CCdvtlmH.js} +2 -2
- package/dist/owletto/dist/assets/{agent-skills-route-DYpB5H1J.js → agent-skills-route-BUxIswuq.js} +2 -2
- package/dist/owletto/dist/assets/{agent-subpage-shell-B3K_jPYR.js → agent-subpage-shell-D92imvSt.js} +2 -2
- package/dist/owletto/dist/assets/agent-thread-BJOijbT0.js +6 -0
- package/dist/owletto/dist/assets/agents-9XjpDj_S.js +2 -0
- package/dist/owletto/dist/assets/{agents-workbench-CMyk4PI7.js → agents-workbench-Bt5QCYQ7.js} +2 -2
- package/dist/owletto/dist/assets/{app._appId-DH1Qutz6.js → app._appId-CKv7_squ.js} +2 -2
- package/dist/owletto/dist/assets/{automation-detail-content-CEDNboId.js → automation-detail-content-vUwVumXf.js} +2 -2
- package/dist/owletto/dist/assets/automations-9XjpDj_S.js +2 -0
- package/dist/owletto/dist/assets/{callback-CU-hb8JB.js → callback-BRgcL8gz.js} +2 -2
- package/dist/owletto/dist/assets/{card-DIF8SF9b.js → card-Djgp00r_.js} +2 -2
- package/dist/owletto/dist/assets/{claim-DELEa-gH.js → claim-BYUZnyMp.js} +2 -2
- package/dist/owletto/dist/assets/{clients-CpG676mg.js → clients-D3Zbjxin.js} +2 -2
- package/dist/owletto/dist/assets/{code-editor-V27Z4o3P.js → code-editor-DHeyRGZI.js} +2 -2
- package/dist/owletto/dist/assets/connect-CfsFsy9P.js +2 -0
- package/dist/owletto/dist/assets/connect._clientId-DkiC8xos.js +2 -0
- package/dist/owletto/dist/assets/connected._clientId-CIXrGOsT.js +2 -0
- package/dist/owletto/dist/assets/{connected._clientId.activity-DQWcUqKM.js → connected._clientId.activity-Ckdz6I0y.js} +2 -2
- package/dist/owletto/dist/assets/{connected._clientId.index-BC3R303A.js → connected._clientId.index-CNxafNeo.js} +2 -2
- package/dist/owletto/dist/assets/{connection-DySpRE9x.js → connection-C3XXFEqh.js} +2 -2
- package/dist/owletto/dist/assets/{connection-feed-detail-C_D68j6d.js → connection-feed-detail-CIJJLDP8.js} +2 -2
- package/dist/owletto/dist/assets/{connections-browser-Cnv2iBbZ.js → connections-browser-CKZjzRz6.js} +2 -2
- package/dist/owletto/dist/assets/{connector-provenance-CNXtzYg5.js → connector-provenance-8-d8hl10.js} +2 -2
- package/dist/owletto/dist/assets/{connector-scope-lists-BKDetNDc.js → connector-scope-lists-CadPVsI3.js} +2 -2
- package/dist/owletto/dist/assets/{connectors-BJnk1z_2.js → connectors-lvLJ30lo.js} +2 -2
- package/dist/owletto/dist/assets/{consent-BVzxrAO9.js → consent-CdSvVCgx.js} +2 -2
- package/dist/owletto/dist/assets/{conversations-table-DfZGICl7.js → conversations-table-BdXoZAfc.js} +2 -2
- package/dist/owletto/dist/assets/{core.esm-DiTpULFl.js → core.esm-CYvgWCuv.js} +2 -2
- package/dist/owletto/dist/assets/create-0xW9eXxG.js +2 -0
- package/dist/owletto/dist/assets/{create-JRFM8mMf.js → create-B0qhrrX4.js} +2 -2
- package/dist/owletto/dist/assets/create-CAfF-yI1.js +2 -0
- package/dist/owletto/dist/assets/create-automation-form-CtSSeYj3.js +3 -0
- package/dist/owletto/dist/assets/create._connectorKey-i6xxkWKV.js +2 -0
- package/dist/owletto/dist/assets/{cronstrue-DPXl0qA2.js → cronstrue-n4qGUraE.js} +2 -2
- package/dist/owletto/dist/assets/deployments-4Itm35Xc.js +2 -0
- package/dist/owletto/dist/assets/{deployments-DCQdFdwG.js → deployments-RvUdVkj3.js} +2 -2
- package/dist/owletto/dist/assets/{deployments-body-D6TAWs_6.js → deployments-body-BMp7UsMo.js} +2 -2
- package/dist/owletto/dist/assets/{device-CntqYW65.js → device-CPU6CjkJ.js} +2 -2
- package/dist/owletto/dist/assets/{device-pin-tombstone-Bz4JHHMK.js → device-pin-tombstone-CrjG7gPo.js} +2 -2
- package/dist/owletto/dist/assets/{device._deviceId-D4plO3GM.js → device._deviceId-Cs3ZmXWo.js} +2 -2
- package/dist/owletto/dist/assets/{entity-options-UJs64GdQ.js → entity-options-uXjgT7y9.js} +2 -2
- package/dist/owletto/dist/assets/{entity-page-Djz6T50J.js → entity-page-Dc0LGr5U.js} +2 -2
- package/dist/owletto/dist/assets/{entity-type-page-OznRag6A.js → entity-type-page-CwZxa0BR.js} +2 -2
- package/dist/owletto/dist/assets/{event-detail-04qOUGIP.js → event-detail-ve2d6Gbb.js} +2 -2
- package/dist/owletto/dist/assets/{events-feed-fucGZSJR.js → events-feed-BtvhZF1f.js} +2 -2
- package/dist/owletto/dist/assets/{filter-editors-DCQgGLyR.js → filter-editors-Cj-v6NtH.js} +2 -2
- package/dist/owletto/dist/assets/{full-page-spinner-KpV2FS2u.js → full-page-spinner-DqpH99np.js} +2 -2
- package/dist/owletto/dist/assets/guardrails-HFo2Ut8B.js +2 -0
- package/dist/owletto/dist/assets/identity-BigVSBCl.js +2 -0
- package/dist/owletto/dist/assets/{index-BEvyBdOU.js → index-B9uPN6FC.js} +2 -2
- package/dist/owletto/dist/assets/{index-BNh2cidi.js → index-BQVliQW1.js} +2 -2
- package/dist/owletto/dist/assets/index-BfedB4Rc.js +2 -0
- package/dist/owletto/dist/assets/index-CUw3aKBI.js +2 -0
- package/dist/owletto/dist/assets/index-CXhxUkv3.js +2 -0
- package/dist/owletto/dist/assets/{index-_oPeVpL_.js → index-Cr5hwh-C.js} +66 -66
- package/dist/owletto/dist/assets/index-CzkTV4ZQ.js +2 -0
- package/dist/owletto/dist/assets/index-DKSx8JN_.js +2 -0
- package/dist/owletto/dist/assets/{index-D3s8rhG9.js → index-DVk7Ug0d.js} +2 -2
- package/dist/owletto/dist/assets/index-DmZuKGf8.js +2 -0
- package/dist/owletto/dist/assets/{index-DCdkwg9H.js → index-Hio-HRfo.js} +2 -2
- package/dist/owletto/dist/assets/{index-BJXkc60S.js → index-ICgKp3YK.js} +2 -2
- package/dist/owletto/dist/assets/index-cPcroOH0.js +2 -0
- package/dist/owletto/dist/assets/{index-BOzuAbvi.js → index-n7sTbNv4.js} +2 -2
- package/dist/owletto/dist/assets/index-xiFpcWKv.js +2 -0
- package/dist/owletto/dist/assets/{json-diff-D_Ym3Uku.js → json-diff-DBoag_OS.js} +2 -2
- package/dist/owletto/dist/assets/{list-skeleton-Bl0OS39L.js → list-skeleton-C_GuoxAH.js} +2 -2
- package/dist/owletto/dist/assets/{login-QHdxqX-4.js → login-Ci6ixHuL.js} +2 -2
- package/dist/owletto/dist/assets/{logout-DUccApuZ.js → logout-CLGgeZB7.js} +2 -2
- package/dist/owletto/dist/assets/{member-scope-gate-CFbrq1by.js → member-scope-gate-B44INDPY.js} +2 -2
- package/dist/owletto/dist/assets/{memory-browse-page-IrIXuZTF.js → memory-browse-page-DyQiRvzl.js} +2 -2
- package/dist/owletto/dist/assets/{model-selector-CB1BDvlW.js → model-selector-dAbDgJvx.js} +2 -2
- package/dist/owletto/dist/assets/models-DpVP7ZwX.js +2 -0
- package/dist/owletto/dist/assets/{new-BWo8_Pms.js → new-BUb7AnEW.js} +2 -2
- package/dist/owletto/dist/assets/{new-B5UsLiy6.js → new-BkdULx2r.js} +2 -2
- package/dist/owletto/dist/assets/{new-DpmDXmFI.js → new-CHOr-EcI.js} +2 -2
- package/dist/owletto/dist/assets/{oauth-workspace-access-PGyTnW2K.js → oauth-workspace-access-BxsjwgdH.js} +2 -2
- package/dist/owletto/dist/assets/{organization-BH8PYlVu.js → organization-gxGeDjIV.js} +2 -2
- package/dist/owletto/dist/assets/{peek-pane-content-B2AFNTzP.js → peek-pane-content-CHoQHe2H.js} +2 -2
- package/dist/owletto/dist/assets/{permissions-CwN_YP3u.js → permissions-aPHaKLec.js} +2 -2
- package/dist/owletto/dist/assets/{proposal-review-shell-DKKGu4Ww.js → proposal-review-shell-UcZr87_Q.js} +2 -2
- package/dist/owletto/dist/assets/public-shell-ready-DcnlADmj.js +2 -0
- package/dist/owletto/dist/assets/{recent-DqdZE_TI.js → recent-D-65Pgu-.js} +2 -2
- package/dist/owletto/dist/assets/{record-activity-CvgZyCmw.js → record-activity-CBXH6v1d.js} +2 -2
- package/dist/owletto/dist/assets/{renderer-BL6VcwQH.js → renderer-mEDnVW0O.js} +2 -2
- package/dist/owletto/dist/assets/{reset-password-DAvBYkiI.js → reset-password-uX_V6bip.js} +2 -2
- package/dist/owletto/dist/assets/{runs-BWtc5rmc.js → runs-C0rCgGwX.js} +2 -2
- package/dist/owletto/dist/assets/runs-panel-Du1JMjg5.js +2 -0
- package/dist/owletto/dist/assets/{runs-table-DxIiqrSk.js → runs-table-syPJ6r6T.js} +2 -2
- package/dist/owletto/dist/assets/{settings-Crxlwps-.js → settings-9NkNA1G1.js} +2 -2
- package/dist/owletto/dist/assets/settings-E-10sLQX.js +2 -0
- package/dist/owletto/dist/assets/skills-D2Ri9b4f.js +2 -0
- package/dist/owletto/dist/assets/{source-record-panels-CRIPMWfN.js → source-record-panels-CPyzlfD1.js} +2 -2
- package/dist/owletto/dist/assets/{status-dot-C5KDvvm9.js → status-dot-B-EWMgq6.js} +2 -2
- package/dist/owletto/dist/assets/{tabs-B4Er9hJj.js → tabs-DqIIkCX-.js} +2 -2
- package/dist/owletto/dist/assets/{use-mention-search-DqEykWl_.js → use-mention-search-By8RZyKW.js} +2 -2
- package/dist/owletto/dist/assets/{view-param-filters-Cylutoy1.js → view-param-filters-CqLZQrnO.js} +2 -2
- package/dist/owletto/dist/index.html +1 -1
- package/dist/server-main.bundle.mjs +11447 -10762
- package/npm-shrinkwrap.json +160 -160
- package/package.json +1 -1
- package/vendor/connector-sdk/dist/browser-handoff-banner.d.ts +39 -0
- package/vendor/connector-sdk/dist/browser-handoff-banner.js +175 -0
- package/vendor/connector-sdk/dist/browser-source-read.d.ts +52 -0
- package/vendor/connector-sdk/dist/browser-source-read.js +107 -0
- package/vendor/connector-sdk/dist/connector-types.d.ts +10 -0
- package/vendor/connector-sdk/dist/index.d.ts +3 -0
- package/vendor/connector-sdk/dist/index.js +2 -0
- package/vendor/connector-sdk/package.json +9 -1
- package/vendor/core/dist/capabilities.d.ts +1 -1
- package/vendor/core/dist/capabilities.js +0 -1
- package/vendor/core/dist/connector-query-errors.d.ts +32 -0
- package/vendor/core/dist/connector-query-errors.js +41 -1
- package/vendor/core/dist/contracts/tools/manage-conversations.js +2 -2
- package/vendor/core/dist/contracts/tools/manage-feeds.d.ts +14 -0
- package/vendor/core/dist/contracts/tools/manage-feeds.js +17 -0
- package/vendor/core/dist/contracts/worker/protocol.d.ts +8 -131
- package/vendor/core/dist/contracts/worker/protocol.js +9 -61
- package/vendor/core/dist/device-pin-tombstones.d.ts +44 -0
- package/vendor/core/dist/device-pin-tombstones.js +57 -0
- package/vendor/core/dist/index.d.ts +2 -1
- package/vendor/core/dist/index.js +1 -0
- package/vendor/core/dist/logger.js +10 -25
- package/vendor/core/dist/utils/diagnostic-scrubber.js +258 -21
- package/vendor/core/dist/worker/wire.d.ts +0 -10
- package/vendor/core/package.json +6 -6
- package/vendor/views/package.json +1 -1
- package/dist/owletto/dist/assets/_-C_zNZben.js +0 -2
- package/dist/owletto/dist/assets/_agentId-QQW91cHX.js +0 -2
- package/dist/owletto/dist/assets/_name-t3oBJ6Zf.js +0 -2
- package/dist/owletto/dist/assets/_shape-bo2lMVCu.js +0 -2
- package/dist/owletto/dist/assets/_skillKey-Dwm4Q4wI.js +0 -2
- package/dist/owletto/dist/assets/_viewKey-Bh6E_NxA.js +0 -2
- package/dist/owletto/dist/assets/_viewKey-D4jKl-Zf.js +0 -2
- package/dist/owletto/dist/assets/agent-thread-C8UaUTWc.js +0 -6
- package/dist/owletto/dist/assets/agents-F4mGI2oF.js +0 -2
- package/dist/owletto/dist/assets/automations-F4mGI2oF.js +0 -2
- package/dist/owletto/dist/assets/connect-B2YL6qIK.js +0 -2
- package/dist/owletto/dist/assets/connect._clientId-B6LDmDRV.js +0 -2
- package/dist/owletto/dist/assets/connected._clientId-D_HaKoI1.js +0 -2
- package/dist/owletto/dist/assets/create-CUqO6Kfk.js +0 -2
- package/dist/owletto/dist/assets/create-automation-form-_4vUkrls.js +0 -3
- package/dist/owletto/dist/assets/create-iHcxV0xd.js +0 -2
- package/dist/owletto/dist/assets/create._connectorKey-CCYLEicg.js +0 -2
- package/dist/owletto/dist/assets/deployments-ihkhK1zV.js +0 -2
- package/dist/owletto/dist/assets/guardrails-molekzAF.js +0 -2
- package/dist/owletto/dist/assets/identity-BJcaG66g.js +0 -2
- package/dist/owletto/dist/assets/index-B04ON9Jv.js +0 -2
- package/dist/owletto/dist/assets/index-BOsK-K-2.js +0 -2
- package/dist/owletto/dist/assets/index-Bk1x7A67.js +0 -2
- package/dist/owletto/dist/assets/index-CFnx5huL.js +0 -2
- package/dist/owletto/dist/assets/index-Dbd1jusf.js +0 -2
- package/dist/owletto/dist/assets/index-DqZuqC08.js +0 -2
- package/dist/owletto/dist/assets/index-Dr-Xg_xO.js +0 -2
- package/dist/owletto/dist/assets/index-KPOvMVa-.js +0 -2
- package/dist/owletto/dist/assets/models-DnMb3n-Z.js +0 -2
- package/dist/owletto/dist/assets/public-shell-ready-7KYnww6e.js +0 -2
- package/dist/owletto/dist/assets/runs-panel-BO3h5RkS.js +0 -2
- package/dist/owletto/dist/assets/settings-4Ev-0iNL.js +0 -2
- package/dist/owletto/dist/assets/skills-D0X430X8.js +0 -2
- package/vendor/core/dist/contracts/worker/device-chat.d.ts +0 -4
- package/vendor/core/dist/contracts/worker/device-chat.js +0 -26
|
@@ -0,0 +1,3 @@
|
|
|
1
|
+
import{r as i,j as e,bn as ie,bo as re,bp as ce,bq as le,br as P,I as oe,B as Q,X as Xt,cN as gs,cL as ps,cg as Zt,gl as fs,gm as vs,S as Ct,y as k,P as R,ae as Ie,dM as Et,dO as ys,dP as js,ft as _s,dv as es,dQ as Ns,ei as ks,a$ as Ft,gn as bs,fe as st,ck as Ke,dd as tt,fg as yt,a_ as ts,cy as Je,cc as Ss,V as ws,H as Cs,cu as Es,go as Fs,gp as As,gq as Os,gr as Ms,gs as Ds,M as Ps,L as Ts,k as ss,gi as Ls,aZ as Rs,az as $s,ew as At,fV as Is,gt as qs,bY as Ks,f3 as Bs,by as pt,a1 as Ws,gu as Vs,gv as zs,gw as Us,gx as Qs,gy as Gs,gz as Js,gA as Hs,gB as Ys,gC as Xs,b0 as Zs,bx as en}from"./index-Cr5hwh-C.js";import{c as tn}from"./cronstrue-n4qGUraE.js";import{C as sn,f as nn}from"./entity-options-uXjgT7y9.js";import{M as an}from"./model-selector-dAbDgJvx.js";import{b as on}from"./skill-editor-D_W3QlRz.js";import{C as ft}from"./code-editor-DHeyRGZI.js";import{u as rn,b as Ot,c as Mt,s as cn,o as ln,M as dn,d as un,e as mn,f as hn,v as xn,r as gn}from"./use-mention-search-By8RZyKW.js";const Ze=[{value:"*/15 * * * *",label:"Every 15 minutes"},{value:"0 * * * *",label:"Every hour"},{value:"0 */6 * * *",label:"Every 6 hours"},{value:"0 9 * * *",label:"Daily at 9:00 AM"},{value:"0 18 * * *",label:"Daily at 6:00 PM"},{value:"0 9 * * 1-5",label:"Weekdays at 9:00 AM"},{value:"0 9 * * 1",label:"Weekly · Monday 9:00 AM"},{value:"0 9 1 * *",label:"Monthly · 1st at 9:00 AM"},{value:"custom",label:"Custom cron…"}];function pn(n){const t=n.trim();if(!t)return null;try{return tn.toString(t,{throwExceptionOnParseError:!0})}catch{return null}}function fn({value:n,onChange:t,placeholder:s="No schedule",className:r}){const d=n??"",u=Ze.some(f=>f.value===d),[c,a]=i.useState(!u&&d!==""),x=f=>{f==="custom"?a(!0):(a(!1),t(f))},m=d?pn(d):null,S=d?e.jsx("p",{className:m?"text-xs text-muted-foreground":"text-xs text-destructive",children:m??"Not a valid cron expression."}):null;return!d&&!c?e.jsxs(ie,{onValueChange:x,children:[e.jsx(re,{className:r??"w-full",children:e.jsx(ce,{placeholder:s})}),e.jsx(le,{children:Ze.map(f=>e.jsxs(P,{value:f.value,children:[f.label,f.value!=="custom"&&e.jsx("span",{className:"ml-2 text-xs text-muted-foreground font-mono",children:f.value})]},f.value))})]}):e.jsxs("div",{className:"space-y-2",children:[e.jsxs("div",{className:"flex items-center gap-2",children:[c?e.jsx(oe,{placeholder:"0 */6 * * *",value:d,onChange:f=>t(f.target.value),className:"font-mono text-sm flex-1"}):e.jsxs(ie,{value:d,onValueChange:x,children:[e.jsx(re,{className:r??"w-full flex-1",children:e.jsx(ce,{children:Ze.find(f=>f.value===d)?.label??d})}),e.jsx(le,{children:Ze.map(f=>e.jsxs(P,{value:f.value,children:[f.label,f.value!=="custom"&&e.jsx("span",{className:"ml-2 text-xs text-muted-foreground font-mono",children:f.value})]},f.value))})]}),e.jsx(Q,{type:"button",variant:"ghost",size:"icon",className:"h-9 w-9 shrink-0",onClick:()=>{a(!1),t("")},children:e.jsx(Xt,{className:"h-4 w-4"})})]}),S]})}const dt="__all_workspace_event_types__",vn=[],yn={};function Dt(n,t,s){const r=new Map;if(!t)for(const[u,c]of Object.entries(s??{}))r.set(u,{key:u,label:Ft(u),description:c.description});const d=[...n].filter(u=>!t||u.slug===t).sort((u,c)=>u.slug.localeCompare(c.slug));for(const u of d)for(const[c,a]of Object.entries(u.event_kinds??{})){const x=r.get(c);if(x){!x.description&&a.description&&(x.description=a.description),JSON.stringify(x.metadataSchema??null)!==JSON.stringify(a.metadataSchema??null)&&(x.metadataSchema=void 0);continue}r.set(c,{key:c,label:Ft(c),description:a.description,metadataSchema:a.metadataSchema})}return[...r.values()].sort((u,c)=>u.label.localeCompare(c.label))}function Pt(n){const t=n[0];if(!t)return;const s=d=>JSON.stringify(Object.keys(d?.properties??{}).sort()),r=s(t);return n.every(d=>s(d)===r)?t:void 0}function Tt(n,t,s){const r=new Set(Object.keys(t.properties??{}));return{...Object.fromEntries(Object.entries(n).filter(([d])=>!r.has(d))),...s}}function $e(n,t,s){return s==="steer"&&(n==="window"||t!=="reply_to_source")?"coalesce":s}function Qe(n,t){return n==="window"?"silent":t}function Lt(n){return Object.fromEntries(Object.entries(n).filter(([t])=>t==="resource_ref"||t==="resource_type"))}function Rt(n,t,s){const r=new Set(Object.keys(t?.properties??{})),d=new Set(s.flatMap(u=>Object.keys(u.filterSchema?.properties??{})));return Object.fromEntries(Object.entries(bs(n)).filter(([u])=>u==="resource_ref"||u==="resource_type"||!d.has(u)||r.has(u)))}function jn({value:n,options:t,onChange:s}){return e.jsx("div",{className:"inline-flex rounded-md border bg-muted/30 p-0.5 text-sm",children:t.map(r=>e.jsx("button",{type:"button","aria-pressed":n===r.value,onClick:()=>s(r.value),className:R("rounded px-3 py-1 transition-colors",n===r.value?"bg-background text-foreground ":"text-muted-foreground hover:text-foreground"),children:r.label},r.value))})}function $t({events:n,selectedKeys:t,onToggle:s,ariaLabel:r="Events"}){const d=i.useId(),u=n.filter(a=>t.includes(a.key)).map(a=>a.label),c=u.length===0?"Choose events":u.length===1?u[0]:`${u.length} events selected`;return e.jsx(st,{contentClassName:"w-[var(--radix-popover-trigger-width)] min-w-[280px]",searchPlaceholder:"Filter events...",emptyText:"No events found.",trigger:a=>e.jsxs(Q,{type:"button",variant:"outline",role:"combobox","aria-label":r,"aria-expanded":a,className:"w-full justify-between font-normal",children:[e.jsx("span",{className:R(u.length===0&&"text-muted-foreground"),children:c}),e.jsx(yt,{className:"ml-2 h-4 w-4 shrink-0 opacity-50"})]}),children:()=>n.map((a,x)=>{const m=t.includes(a.key),S=`${d}-${x}-state`;return e.jsxs(Ke,{value:`${a.label} ${a.key}`,onSelect:()=>s(a.key),"aria-label":a.label,"aria-describedby":S,className:"cursor-pointer",children:[e.jsx(tt,{className:R("mr-2 h-4 w-4",m?"opacity-100":"opacity-0")}),a.label,e.jsx("span",{id:S,className:"sr-only",children:m?"Selected":"Not selected"})]},a.key)})})}function _n({organizationId:n,initialTrigger:t,onChange:s,allowedKinds:r,showSectionHeader:d=!0,fieldIdPrefix:u="automation-trigger-"}){const c=gs(n,{status:"active",limit:500}),a=ps(n),x=Zt({organizationId:n}),m=fs({organizationId:n}),S=c.data??[],f=a.data??[],I=x.data??vn,h=m.data??yn,j=i.useMemo(()=>I.filter(l=>l.organization_id===n),[I,n]),y=t?.kind==="event"&&t?.source==="workspace",w=y||t===void 0,T=r?.length?[...r]:["event","time","manual"],_=T.join("|"),q=(()=>{const l=t===null?"manual":t?.kind==="schedule"?"time":"event";return T.includes(l)?l:T[0]??"event"})(),[N,K]=i.useState(q),[Y,te]=i.useState(y?"workspace":typeof t?.connection_id=="number"?String(t.connection_id):t?.kind==="event"&&t.connector_key?"":"workspace"),b=Y==="workspace",C=b?"":Y,[g,G]=i.useState(typeof t?.entity_type=="string"?t.entity_type:""),se=i.useMemo(()=>Array.isArray(t?.event_types)?t.event_types:[],[t]),[$,z]=i.useState(()=>se.filter(l=>typeof l=="string")),[X,he]=i.useState(t?.match&&typeof t.match=="object"&&!Array.isArray(t.match)?t.match:{}),[xe,ke]=i.useState(typeof t?.cron=="string"?t.cron:"0 9 * * 1-5"),be=typeof t?.timezone=="string"?t.timezone:void 0,[D,ge]=i.useState(t?.kind==="schedule"||w&&t?.execution!=="turn"||t?.execution==="window"?"window":"turn"),[ne,Z]=i.useState(Qe(D,t?.output==="reply_to_source"?"reply_to_source":"silent")),[J,ae]=i.useState(t?.kind==="schedule"||w&&t?.active_run!=="queue"?"coalesce":$e(D,ne,t?.active_run==="coalesce"||t?.active_run==="steer"?t.active_run:"queue")),[Se,Fe]=i.useState(t?.skip_if_unchanged!==!1),[we,p]=i.useState(!1);i.useEffect(()=>{const l=_.split("|");if(!l.includes(N)){const v=l[0]??"event";K(v),ge(v==="time"||v==="event"&&b?"window":"turn"),ae(v==="time"||v==="event"&&b?"coalesce":"queue"),Z("silent")}},[_,N,b]);const B=S.find(l=>String(l.id)===C),H=c.isLoading||a.isLoading,pe=x.isLoading,E=typeof t?.connector_key=="string"?t.connector_key:void 0,Ae=N==="event"&&!b&&t?.kind==="event"&&t?.source!=="workspace"&&typeof t.connection_id=="number"&&String(t.connection_id)===C&&!B,ve=N==="event"&&!b&&t?.kind==="event"&&t?.source!=="workspace"&&t.connection_id==null&&E!==void 0&&C==="",Oe=f.find(l=>l.key===(B?.connector_key??(ve?E:void 0))),de=Oe?.automation_events??[],W=de.filter(l=>$.includes(l.key)),ye=W[0],De=j.find(l=>l.slug===g),Me=[...j.filter(l=>Object.keys(l.event_kinds??{}).length>0||l.slug===g),...g&&!De?[{slug:g,name:g}]:[]],ue=i.useMemo(()=>Dt(j,g||void 0,h),[j,g,h]),Pe=ue.filter(l=>$.includes(l.key)),Be=Pe[0],fe=Pt(W.map(l=>l.filterSchema)),me=Pt(Pe.map(l=>l.metadataSchema)),We=!!(b&&g&&!De),Te=Ae||ve,Ce=(N==="event"?b?$.length>0&&!We:!!($.length>0&&(C&&B||Te)):N==="time"?!!xe.trim():!0)&&(N!=="event"||!vs(X));i.useEffect(()=>{let l;if(Ce&&N==="event"&&!b){const v=Rt(X,fe,Oe?.automation_events??[]);B||ve?l={kind:"event",source:"connector",connector_key:B?.connector_key??E,...B?{connection_id:Number(C)}:{},event_types:$,...Object.keys(v).length>0?{match:v}:{},execution:D,active_run:$e(D,ne,J),output:Qe(D,ne),skip_if_unchanged:Se}:Ae&&(l=t?{...t,source:"connector"}:void 0)}else if(Ce&&N==="event"&&b){const v=Rt(X,me,ue.map(F=>({filterSchema:F.metadataSchema})));l={kind:"event",source:"workspace",...g?{entity_type:g}:{},event_types:$,...Object.keys(v).length>0?{match:v}:{},execution:D,active_run:J==="queue"?"queue":"coalesce"}}else Ce&&N==="time"&&(l={kind:"schedule",cron:xe.trim(),...be?{timezone:be}:{},execution:"window",active_run:"coalesce",skip_if_unchanged:Se});s({ready:Ce,kind:N,trigger:l})},[J,C,B,xe,Oe,$,D,X,N,E,be,t,b,s,ne,Ce,fe,me,Se,g,ue,ve,Ae]);const at=l=>{const v=S.find(A=>String(A.id)===l),F=f.find(A=>A.key===v?.connector_key),ee=$.filter(A=>F?.automation_events?.some(Re=>Re.key===A)),M=F?.automation_events?.find(A=>A.key===ee[0]),je=v?.connector_key!==(B?.connector_key??E);if(te(l),z(ee),!M)he(Lt);else if(je){const A=M.defaults?.execution??"turn",Re=M.defaults?.activeRun??"queue",Ue=Qe(A,M.defaults?.output??"silent");he(Lt),ge(A),ae($e(A,Ue,Re)),Z(Ue)}},ot=l=>{if(l==="workspace"){te("workspace"),z(v=>v.filter(F=>ue.some(ee=>ee.key===F))),he({}),ge("window"),ae("coalesce"),Z("silent");return}at(l)},Ve=l=>{const v=$.includes(l)?$.filter(A=>A!==l):de.map(A=>A.key).filter(A=>A===l||$.includes(A));if(z(v),v[0]===$[0])return;const F=de.find(A=>A.key===v[0]),ee=F?.defaults?.execution??"turn",M=F?.defaults?.activeRun??"queue",je=Qe(ee,F?.defaults?.output??"silent");ge(ee),ae($e(ee,je,M)),Z(je)},Ye=l=>{const v=l===dt?"":l,F=j.find(M=>M.slug===v),ee=Dt(j,F?.slug,h);G(v),z(M=>M.filter(je=>ee.some(A=>A.key===je))),he({})},ze=l=>{z(v=>v.includes(l)?v.filter(F=>F!==l):ue.map(F=>F.key).filter(F=>F===l||v.includes(F)))},Le=[{value:"event",label:"Event"},{value:"time",label:"Schedule"},{value:"manual",label:"Manual"}].filter(l=>T.includes(l.value));return e.jsxs("div",{className:"space-y-4",children:[d?e.jsxs("div",{className:"space-y-1",children:[e.jsx("h2",{className:"text-sm font-medium",children:"When"}),e.jsx("p",{className:"text-xs text-muted-foreground",children:"Choose what starts this Automation. Its goal and context stay reusable."})]}):null,Le.length>1?e.jsx(jn,{value:N,options:Le,onChange:l=>{K(l),ge(l==="time"||l==="event"&&b?"window":"turn"),ae(l==="time"||l==="event"&&b?"coalesce":"queue"),Z("silent")}}):null,N==="event"?H||b&&pe?e.jsxs("div",{className:"space-y-2",children:[e.jsx(Ct,{className:"h-9 w-full"}),e.jsx(Ct,{className:"h-9 w-full"})]}):e.jsxs("div",{className:"space-y-3",children:[e.jsxs("div",{className:"space-y-2",children:[e.jsx(k,{children:"Source"}),e.jsx(sn,{connections:S,value:Y,onValueChange:ot,disabled:Te,includeWorkspaceEvents:!0,ariaLabel:"Source",placeholder:"Choose a source"}),Ae?e.jsx("p",{className:"text-xs text-muted-foreground",children:"This shared connection is managed outside this organization. Other Automation fields can still be edited."}):ve?e.jsxs("p",{className:"text-xs text-muted-foreground",children:["This Automation listens across all"," ",String(t?.connector_key)," connections. Other Automation fields can still be edited."]}):null]}),b?e.jsxs(e.Fragment,{children:[e.jsxs("div",{className:"space-y-2",children:[e.jsx(k,{children:ue.length>1?"Events":"Event"}),ue.length>0?e.jsx($t,{events:ue,selectedKeys:$,onToggle:ze}):e.jsx("div",{className:R(Ie,"px-3 py-2 text-sm text-muted-foreground"),children:g?"This entity type has no declared Automation events.":"This workspace has no declared Automation events."}),Be?.description?e.jsx("p",{className:"text-xs text-muted-foreground",children:Be.description}):null,We?e.jsxs("p",{className:"text-xs text-destructive",children:["This trigger filters on entity type “",g,"”, which no longer exists in this workspace. Clear the Entity type filter under Trigger options to save."]}):null,e.jsx("p",{className:"text-xs text-muted-foreground",children:"Only declared Automation outputs in the current workspace can trigger this Automation. Ordinary saved events remain data."})]}),me?e.jsx(Et,{schema:me,values:X,onValuesChange:l=>he(v=>Tt(v,me,l)),fieldIdPrefix:`${u}workspace-`},`${g||"workspace"}:${$.join(",")}`):null]}):B||ve?e.jsxs(e.Fragment,{children:[e.jsxs("div",{className:"space-y-2",children:[e.jsx(k,{children:de.length>1?"Events":"Event"}),de.length?e.jsx($t,{events:de,selectedKeys:$,onToggle:Ve}):e.jsx("div",{className:R(Ie,"px-3 py-2 text-sm text-muted-foreground"),children:"This connector has not published subscribable events."}),ye?.description?e.jsx("p",{className:"text-xs text-muted-foreground",children:ye.description}):null]}),typeof X.resource_ref=="string"||fe?e.jsxs("div",{className:"space-y-3",children:[typeof X.resource_ref=="string"?e.jsxs("div",{className:"space-y-2",children:[e.jsx(k,{children:"Resource"}),e.jsx("div",{className:R(Ie,"px-3 py-2 text-sm"),children:X.resource_ref})]}):null,fe?e.jsx(Et,{schema:fe,values:X,onValuesChange:l=>he(v=>Tt(v,fe,l)),fieldIdPrefix:u},$.join(",")):null]}):null]}):Y?null:e.jsx("p",{className:"text-xs text-muted-foreground",children:"Choose workspace events or a connected app as the source."})]}):N==="time"?e.jsx(fn,{value:xe,onChange:ke}):e.jsx("p",{className:"text-sm text-muted-foreground",children:"Run this Automation explicitly from Lobu, the API, CLI, or MCP."}),N!=="manual"&&!Te?e.jsxs(ys,{open:we,onOpenChange:p,children:[e.jsx(js,{asChild:!0,children:e.jsxs(Q,{type:"button",variant:"ghost",className:"h-auto w-full justify-between px-0 py-1 text-muted-foreground hover:bg-transparent hover:text-foreground",children:[e.jsxs("span",{className:"flex items-center gap-2 text-sm",children:[e.jsx(_s,{className:"h-4 w-4"}),"Trigger options",e.jsxs("span",{className:"font-normal text-muted-foreground",children:["· ",D==="turn"?"Each event":"Window"," ·"," ",N==="time"?"Combine":b?J==="queue"?"Queue":"Combine":J==="queue"?"Queue":J==="coalesce"?"Combine":"Update current run",N==="event"&&!b?` · ${D==="turn"&&ne==="reply_to_source"?"Reply":"Save in Lobu"}`:""]})]}),e.jsx(es,{className:R("h-4 w-4 transition-transform",we&&"rotate-180")})]})}),e.jsxs(Ns,{className:"space-y-4 pt-3",children:[N==="event"&&b?e.jsxs("div",{className:"space-y-2",children:[e.jsx(k,{children:"Entity type filter"}),e.jsxs(ie,{value:g||dt,onValueChange:Ye,children:[e.jsx(re,{"aria-label":"Entity type filter",children:e.jsx(ce,{})}),e.jsxs(le,{children:[e.jsx(P,{value:dt,children:"All event types"}),Me.map(l=>e.jsx(P,{value:l.slug,children:l.name},l.slug))]})]}),e.jsx("p",{className:"text-xs text-muted-foreground",children:"Optional. Limit selected events to outputs linked to this entity type."})]}):null,N==="event"?e.jsxs("div",{className:"grid gap-3 sm:grid-cols-2",children:[e.jsxs("div",{className:"space-y-2",children:[e.jsx(k,{children:"Run"}),e.jsxs(ie,{value:D,onValueChange:l=>{const v=l,F=Qe(v,ne);ge(v),Z(F),ae($e(v,F,J))},children:[e.jsx(re,{children:e.jsx(ce,{})}),e.jsxs(le,{children:[e.jsx(P,{value:"turn",children:"Start a run for each event"}),e.jsx(P,{value:"window",children:"Batch events into a window"})]})]})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(k,{children:"When busy"}),e.jsxs(ie,{value:J,onValueChange:l=>ae(l),children:[e.jsx(re,{children:e.jsx(ce,{})}),e.jsxs(le,{children:[e.jsx(P,{value:"queue",children:"Queue"}),e.jsx(P,{value:"coalesce",children:"Combine waiting events"}),!b&&D==="turn"&&ne==="reply_to_source"&&ye?.capabilities?.steering?e.jsx(P,{value:"steer",children:"Update the current run"}):null]})]})]})]}):null,D==="window"&&(N==="time"||!b)?e.jsxs("div",{className:"flex items-center justify-between gap-3",children:[e.jsxs("div",{children:[e.jsx("p",{className:"text-sm font-medium",children:"Skip unchanged windows"}),e.jsx("p",{className:"text-xs text-muted-foreground",children:"No source changes means no agent run or LLM call."})]}),e.jsx(ks,{"aria-label":"Skip unchanged windows",checked:Se,onCheckedChange:Fe})]}):null,N==="event"&&!b&&D==="turn"?e.jsxs("div",{className:"space-y-2",children:[e.jsx(k,{children:"Result"}),e.jsxs(ie,{value:ne,onValueChange:l=>{const v=l;Z(v),ae($e(D,v,J))},children:[e.jsx(re,{children:e.jsx(ce,{})}),e.jsxs(le,{children:[ye?.capabilities?.replyToSource?e.jsx(P,{value:"reply_to_source",children:"Reply where it happened"}):null,e.jsx(P,{value:"silent",children:"Save in Lobu"})]})]}),ye?.capabilities?.replyToSource?e.jsx("p",{className:"text-xs text-muted-foreground",children:"Messages matching this trigger run the Automation; anything else in the conversation stays with the connected agent."}):null]}):null]})]}):null]})}const Nn=16;function qe(){return crypto.randomUUID()}function kn(n){return n===void 0?[{key:qe(),initial:void 0}]:n.length===0?[{key:qe(),initial:null}]:n.map(t=>({key:qe(),initial:t}))}function ns(n){return n?n.kind==="time"||n.trigger?.kind==="schedule":!1}function bn(n,t){return n?n.ready===t.ready&&n.kind===t.kind&&JSON.stringify(n.trigger)===JSON.stringify(t.trigger):!1}function Sn(n,t){const s=n.map(a=>t[a.key]??{ready:!1,kind:"event"});if(!(n.length>1)&&s[0]?.kind==="manual")return{ready:s[0].ready,triggers:[]};const d=s.filter(ns).length;return{ready:!s.some(a=>a.kind==="manual")&&d<=1&&s.length>0&&s.every(a=>a.ready&&a.trigger),triggers:s.filter(a=>a.trigger).map(a=>a.trigger)}}function na({organizationId:n,initialTriggers:t,onChange:s}){const r=i.useId(),[d,u]=i.useState(()=>kn(t)),[c,a]=i.useState({}),x=i.useRef("");i.useEffect(()=>{const h=Sn(d,c),j=JSON.stringify(h);j!==x.current&&(x.current=j,s(h))},[d,c,s]);const m=d.find(h=>ns(c[h.key]))?.key??d.find(h=>h.initial&&typeof h.initial=="object"&&h.initial.kind==="schedule"&&!c[h.key])?.key??null,S=i.useCallback((h,j)=>{a(y=>bn(y[h],j)?y:{...y,[h]:j})},[]),f=()=>{const h=d[0],j=h?c[h.key]:void 0;if(d.length===1&&(j?.kind==="manual"||h?.initial===null)){const y=qe();a({}),u([{key:y,initial:void 0}]);return}u(y=>[...y,{key:qe(),initial:void 0}])},I=h=>{if(d.length<=1){const j=qe();a({}),u([{key:j,initial:null}]);return}a(j=>{const y={...j};return delete y[h],y}),u(j=>j.filter(y=>y.key!==h))};return e.jsxs("section",{className:"space-y-4","aria-labelledby":`${r}-heading`,children:[e.jsxs("div",{className:"space-y-1",children:[e.jsx("h2",{id:`${r}-heading`,className:"text-sm font-medium",children:"When"}),d.length>1?e.jsx("p",{className:"text-xs text-muted-foreground",children:"Each trigger can start this Automation independently (OR). At most one schedule. If several match the same event, the first listed wins for run options."}):null]}),e.jsx("div",{className:"space-y-3",children:d.map((h,j)=>{const y=d.length>1,w=y?m&&m!==h.key?["event"]:["event","time"]:["event","time","manual"],T=c[h.key],_=y||(T?T.kind!=="manual":h.initial!==null);return e.jsxs("div",{className:R("space-y-3 rounded-lg border bg-card/40 p-3",y&&"relative"),children:[e.jsxs("div",{className:"flex items-center justify-between gap-2",children:[e.jsx("p",{className:"text-xs font-medium text-muted-foreground",children:y?`Trigger ${j+1}`:"Trigger"}),_?e.jsx(Q,{type:"button",variant:"ghost",size:"icon",className:"h-7 w-7 text-muted-foreground hover:text-destructive","aria-label":y?`Remove trigger ${j+1}`:"Clear trigger",onClick:()=>I(h.key),children:e.jsx(ts,{className:"h-3.5 w-3.5"})}):null]}),e.jsx(wn,{slotKey:h.key,organizationId:n,initial:h.initial,kinds:w,fieldIdPrefix:`${r}-${h.key}-`,onChange:S})]},h.key)})}),e.jsxs(Q,{type:"button",variant:"outline",size:"sm",className:"w-full sm:w-auto",onClick:f,disabled:d.length>=Nn,children:[e.jsx(Je,{className:"mr-1.5 h-3.5 w-3.5"}),"Add another trigger"]})]})}function wn({slotKey:n,organizationId:t,initial:s,kinds:r,fieldIdPrefix:d,onChange:u}){const c=i.useCallback(a=>u(n,a),[u,n]);return e.jsx(_n,{organizationId:t,initialTrigger:s,allowedKinds:r,showSectionHeader:!1,fieldIdPrefix:d,onChange:c})}const Cn=["claude-code","codex","opencode","pi","agy"],En={"claude-code":"Claude Code",codex:"Codex",opencode:"OpenCode",pi:"Pi",agy:"Antigravity (agy)"},Fn=[{kind:"claude-code",binaryName:"claude",promptDelivery:{kind:"flag",flag:"-p"},mcpDelivery:{kind:"claude-config-file",flag:"--mcp-config",extraArgs:["--strict-mcp-config","--allowedTools","mcp__lobu__query_sdk,mcp__lobu__run_sdk"]},headlessArgs:[],modelFlag:"--model",effortFlag:"--effort",permissionModeFlag:"--permission-mode",budgetFlag:"--max-budget-usd",timeoutFlag:null,trailingArgs:[]},{kind:"agy",binaryName:"agy",promptDelivery:{kind:"flag",flag:"-p"},mcpDelivery:{kind:"none"},headlessArgs:["--dangerously-skip-permissions"],modelFlag:"--model",effortFlag:"--effort",permissionModeFlag:null,budgetFlag:null,timeoutFlag:{flag:"--print-timeout",suffix:"s"},trailingArgs:[]},{kind:"opencode",binaryName:"opencode",promptDelivery:{kind:"positional",subcommand:["run"]},mcpDelivery:{kind:"opencode-config-env",variable:"OPENCODE_CONFIG_CONTENT"},headlessArgs:["--auto","--print-logs","--log-level","ERROR"],modelFlag:"-m",effortFlag:"--variant",permissionModeFlag:null,budgetFlag:null,timeoutFlag:null,trailingArgs:[]},{kind:"codex",binaryName:"codex",promptDelivery:{kind:"positional",subcommand:["exec"]},mcpDelivery:{kind:"none"},headlessArgs:["--skip-git-repo-check","--sandbox","workspace-write","-c","sandbox_workspace_write.network_access=true"],modelFlag:"-m",effortFlag:"-c",effortConfigKey:"model_reasoning_effort",permissionModeFlag:null,budgetFlag:null,timeoutFlag:null,trailingArgs:[]},{kind:"pi",binaryName:"pi",promptDelivery:{kind:"positional",subcommand:[]},mcpDelivery:{kind:"none"},headlessArgs:["-p","--no-session","--tools","read,bash,edit,write"],modelFlag:"--model",effortFlag:"--thinking",permissionModeFlag:null,budgetFlag:null,timeoutFlag:null,trailingArgs:[]}];new Map(Fn.map(n=>[n.kind,n]));const It={agents:!0,lobuEmbedded:!1};function An(){const{data:n}=Ss({queryKey:["features"],queryFn:async()=>{const t=await ws(`${Cs}/api/features`);return t.ok?t.json():It},staleTime:3e4,refetchInterval:6e4});return n??It}const qt=["slack","imessage"],ut="__none__";function Ge(n){return`${n.connection_id}:${n.feed_key}`}function On(n){const t=n.indexOf(":");if(t<=0)return null;const s=Number(n.slice(0,t)),r=n.slice(t+1);return!Number.isSafeInteger(s)||s<=0||!r?null:{connection_id:s,channel_id:r}}function mt(n){return n?`${n.connection_id}:${n.channel_id}`:""}function et(n){return`${n.display_name||n.feed_key} (${n.feed_key})`}function Mn({organizationId:n,agentId:t,value:s,onChange:r,disabled:d=!1,automationName:u,onPendingChange:c}){const{data:a=[],isLoading:x}=Es(n),m=mt(s),[S,f]=i.useState(null),[I,h]=i.useState(!1),j=i.useRef(t),y=i.useMemo(()=>a.filter(g=>g.store==="channel_messages"&&g.target_agent_id===t&&qt.includes(g.connector_key)),[a,t]);i.useEffect(()=>{if(j.current===t||(j.current=t,f(null),h(!1),s==null))return;const g=mt(s);if(g==="")return;a.some(se=>se.store==="channel_messages"&&se.target_agent_id===t&&qt.includes(se.connector_key)&&Ge(se)===g)||r(null)},[t,a,s,r]);const w=S??m,T=w===""?ut:w,_=y.find(g=>Ge(g)===w),q=S!==null&&S!==""&&S!==m;i.useEffect(()=>{c?.(q)},[q,c]);const N=_??(S?void 0:y.find(g=>Ge(g)===m)),K=g=>{const G=g===ut?"":g;if(G===""){f(null),h(!1),r(null);return}if(G===m){f(null),h(!1);return}f(G),h(!1)},Y=g=>{if(h(g),g&&S){const G=On(S);G&&(f(null),r(G))}else!g&&S&&f(null)},b=(s&&mt(s)!==""?s:void 0)??(_?{connection_id:_.connection_id,channel_id:_.feed_key}:void 0),C=(u??"").trim()||"This automation";return e.jsxs("div",{className:"space-y-2",children:[e.jsxs(k,{htmlFor:"automation-delivery-target",children:["Digest destination"," ",e.jsx("span",{className:"text-xs font-normal text-muted-foreground",children:"(optional)"})]}),t?e.jsxs(ie,{value:T,onValueChange:K,disabled:d||x,children:[e.jsx(re,{id:"automation-delivery-target",className:"font-mono text-sm",children:e.jsx(ce,{placeholder:x?"Loading bound channels…":y.length===0?"No bound Slack or iMessage channels":"No digest — runs stay silent"})}),e.jsxs(le,{children:[e.jsx(P,{value:ut,children:"No digest — runs stay silent"}),y.map(g=>e.jsxs(P,{value:Ge(g),children:[et(g)," · ",g.connector_key]},Ge(g)))]})]}):e.jsx("p",{className:"text-xs text-muted-foreground",children:"Select a managed agent first — only channels bound to that agent can receive digests."}),t&&!x&&y.length===0?e.jsx("p",{className:"text-xs text-muted-foreground",children:"No Slack or iMessage channels are bound to this agent yet. Link a private channel first, then select it here."}):null,q&&_?e.jsxs("label",{className:"flex cursor-pointer items-start gap-2 text-xs",children:[e.jsx("input",{type:"checkbox",checked:I,onChange:g=>Y(g.target.checked),className:"mt-0.5","aria-label":`Confirm digest delivery to ${et(_)}`}),e.jsxs("span",{className:"text-muted-foreground",children:["I confirm posting material-change digests to"," ",e.jsx("span",{className:"font-medium text-foreground",children:et(_)}),". Destination changes are audited."]})]}):null,N||b?e.jsxs("div",{className:R(Ie,"space-y-1.5 px-3 py-2"),children:[e.jsxs("p",{className:"text-xs font-medium",children:["Digest preview →"," ",e.jsx("span",{className:"font-mono font-normal",children:N?`${N.connector_key} ${et(N)} · connection ${N.connection_id}`:`${b?.channel_id} · connection ${b?.connection_id}`})]}),e.jsxs("p",{className:"font-mono text-xs",children:[C," applied 2 new + 1 updated"]}),e.jsx("p",{className:"whitespace-pre-line font-mono text-xs text-muted-foreground",children:`+ Example task (#12)
|
|
2
|
+
~ Follow-up item (#34)`}),e.jsx("p",{className:"text-xs text-muted-foreground",children:"Sends only after a successful run with material changes. Runs with zero changes send nothing. Retries reuse the same notification and delivery receipts dedupe channel posts, but provider acceptance with a lost receipt can still duplicate."})]}):null]})}const Kt=4096;function Dn({open:n,onOpenChange:t,initial:s,onSubmit:r}){const[d,u]=i.useState(""),[c,a]=i.useState(""),[x,m]=i.useState(null);i.useEffect(()=>{n&&(u(s?.name??""),a(s?.query??""),m(null))},[n,s]);const S=()=>{const I=d.trim(),h=c.trim();if(!I){m("Give the SQL source a name.");return}if(!h){m("Enter a query.");return}if(h.length>Kt){m(`Query is too long (${h.length} chars, max ${Kt}).`);return}r({name:I,query:h}),t(!1)},f=!!s;return e.jsx(Fs,{open:n,onOpenChange:t,children:e.jsxs(As,{className:"max-w-2xl",children:[e.jsxs(Os,{children:[e.jsx(Ms,{children:f?"Edit SQL source":"SQL source"}),e.jsx(Ds,{children:"Write a query the automation runs each period. It becomes a reference in the prompt — the query travels with the chip."})]}),e.jsxs("div",{className:"space-y-4",children:[e.jsxs("div",{className:"space-y-2",children:[e.jsx(k,{htmlFor:"sql-source-name",children:"Name"}),e.jsx(oe,{id:"sql-source-name",value:d,onChange:I=>u(I.target.value),placeholder:"recent_cancellations",autoFocus:!f}),e.jsx("p",{className:"text-xs text-muted-foreground",children:"The output-field name this source fills."})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(k,{htmlFor:"sql-source-query",children:"Query"}),e.jsx(ft,{value:c,onChange:a,language:"sql",placeholder:"SELECT id, payload_text, occurred_at FROM events ORDER BY occurred_at DESC",minHeight:"160px"})]}),x?e.jsx("p",{className:"text-sm text-destructive",children:x}):null]}),e.jsxs("div",{className:"flex justify-end gap-2",children:[e.jsx(Q,{variant:"outline",onClick:()=>t(!1),children:"Cancel"}),e.jsx(Q,{onClick:S,children:f?"Save":"Add source"})]})]})})}const Pn=["skill","feed","connection","connector","metric","entity_type"];function Tn({value:n,onChange:t,library:s,pinned:r,required:d,error:u,owner:c,agentId:a,sources:x,onAddSources:m}){const S=rn(Pn,Ot,{skills:s,skillAgentId:a||null}),f=i.useRef(null),[I,h]=i.useState(null),j=i.useMemo(()=>{if(!x)return[];const _=new Set(x.map(q=>q.query.trim()));return Mt(n).filter(q=>!_.has(q.query.trim()))},[n,x]),y=cn(n),w=ln(r.filter(_=>y.includes(_.name)),s),T=s.length>0;return e.jsxs("div",{className:"space-y-2",children:[e.jsxs("div",{className:"flex items-center justify-between gap-3",children:[e.jsxs(k,{htmlFor:"automation-prompt",children:["Instructions"," ",d?e.jsx("span",{className:"text-destructive",children:"*"}):e.jsx("span",{className:"text-xs font-normal text-muted-foreground",children:"(optional)"})]}),y.length>0?e.jsxs("span",{className:"text-xs text-muted-foreground",children:[y.length,"/",Ot," skills"]}):null]}),e.jsx("div",{className:"rounded-lg border bg-background focus-within:ring-1 focus-within:ring-ring",children:e.jsx(dn,{value:n,onChange:t,onSubmit:()=>{},submitOnEnter:!1,searchRefs:S,handleRef:f,onSqlRequest:()=>h({}),onSqlEdit:(_,q)=>h({initial:_,pos:q}),placeholder:T?"What should this Automation do? Type @ to pull in a skill or a data source.":"What should this Automation do? Type @ to pull in a data source.",className:"[&_.ProseMirror]:min-h-[7rem] [&_.ProseMirror]:max-h-72 [&_.ProseMirror]:overflow-y-auto"})}),e.jsx(Dn,{open:I!==null,onOpenChange:_=>{_||h(null)},initial:I?.initial,onSubmit:_=>{f.current?.insertSql(_,I?.pos),h(null)}}),j.length>0&&m?e.jsxs("div",{className:"flex flex-wrap items-center justify-between gap-2 rounded-lg border border-dashed p-3",children:[e.jsxs("p",{className:"text-xs text-muted-foreground",children:[j.length===1?`"${j[0]?.name}" is referenced in the instructions but is not a source on this Automation.`:`${j.length} references in the instructions are not sources on this Automation.`," ","Editing an Automation does not add them automatically."]}),e.jsx(Q,{type:"button",variant:"outline",size:"sm",onClick:()=>m(Mt(n,x)),children:j.length===1?"Add as a source":"Add as sources"})]}):null,y.length>0?e.jsx("div",{className:"flex flex-wrap items-center gap-1.5",children:y.map(_=>{const q=w.includes(_),N=!s.some(K=>K.name===_);return e.jsxs(Ps,{variant:N?"destructive":"secondary",className:"font-normal",children:[_,N?" · unavailable":q?" · newer text":null]},_)})}):null,w.length>0?e.jsxs("p",{className:"rounded-lg border border-dashed p-3 text-xs text-muted-foreground",children:[w.length===1?`"${w[0]}" has been edited since this Automation pinned it.`:`${w.length} skills have been edited since this Automation pinned them.`," ","This Automation keeps running the pinned text until you save it again."]}):null,u?e.jsx("p",{className:"text-xs text-destructive",children:u}):null,!T&&a?e.jsxs("p",{className:"text-xs text-muted-foreground",children:["This agent has no skills yet."," ",e.jsx(Ts,{to:"/$owner/agents/$agentId/skills",params:{owner:c,agentId:a},className:"font-medium text-foreground underline underline-offset-2",children:"Add one"})," ","to reuse instructions across Automations."]}):u?null:e.jsx("p",{className:"text-xs text-muted-foreground",children:T?"Type @ to pull in a skill, a feed, connection, connector, metric, entity type, or a SQL query. Skill text is saved with this version, so later edits to the skill do not change this Automation until you update it.":"Type @ to pull in a feed, connection, connector, metric, entity type, or a SQL query this Automation should read."})]})}const Ln=["connection","connector","feed","metric","entity_type"];function Rn({sources:n,onChange:t,disabled:s}){const{currentOwner:r,resolvedOrganizationId:d}=ss(),[u,c]=i.useState(""),{refs:a}=un({owner:r,organizationId:d,kinds:Ln,query:u,limitPerKind:10});return e.jsxs("div",{className:"space-y-2",children:[e.jsx(k,{children:"Sources"}),n.length>0?e.jsx("ul",{className:"space-y-2",children:n.map(x=>e.jsxs("li",{className:"flex items-start gap-2 rounded-lg border bg-background p-2",children:[e.jsxs("div",{className:"min-w-0 flex-1",children:[e.jsx("div",{className:"truncate font-mono text-xs font-medium",children:x.name}),e.jsx("div",{className:"truncate text-xs text-muted-foreground",children:x.query})]}),e.jsx(Q,{type:"button",variant:"ghost",size:"icon",className:"h-7 w-7 shrink-0","aria-label":`Remove source ${x.name}`,disabled:s,onClick:()=>t(n.filter(m=>m.query!==x.query)),children:e.jsx(Xt,{className:"h-3.5 w-3.5"})})]},x.query))}):null,e.jsx("div",{className:"flex gap-2",children:e.jsx(st,{searchPlaceholder:"Search feeds, connections, metrics…",emptyText:"No matching reference.",onQueryChange:c,trigger:()=>e.jsxs(Q,{type:"button",variant:"outline",size:"sm",disabled:s,children:[e.jsx(Je,{className:"mr-2 h-3.5 w-3.5"}),"Add source"]}),children:x=>a.map(m=>e.jsxs(Ke,{value:`${m.label} ${m.kind}`,onSelect:()=>{t(mn(m,n)),x()},children:[e.jsx("span",{className:"truncate text-sm",children:m.label}),e.jsx("span",{className:"ml-2 shrink-0 text-xs text-muted-foreground",children:m.kind})]},`${m.kind}:${m.id}`))})}),e.jsx("p",{className:"text-xs text-muted-foreground",children:"Data handed to the agent alongside its instructions, and what change detection is measured against. Editing an Automation does not re-read the instructions for these — this list is what runs. To add a SQL source, write it with @ in the instructions above. Automation-owned; skills never add or remove sources."})]})}function $n({organizationId:n,value:t,onChange:s,className:r}){const{data:d=[]}=Ls(n),u=nn(d),c=u.find(a=>a.id===t);return e.jsx(st,{contentClassName:"w-[300px]",searchPlaceholder:"Search entities...",emptyText:"No entities found.",trigger:a=>e.jsxs(Q,{variant:"outline",role:"combobox","aria-expanded":a,className:R("w-full justify-between",r),children:[c?`${c.name} (${c.entityType})`:"All workspace",e.jsx(yt,{className:"ml-2 h-4 w-4 shrink-0 opacity-50"})]}),children:a=>e.jsxs(e.Fragment,{children:[e.jsxs(Ke,{value:"all workspace",onSelect:()=>{s(void 0),a()},className:"cursor-pointer",children:[e.jsx(tt,{className:R("mr-2 h-4 w-4",t===void 0?"opacity-100":"opacity-0")}),e.jsx("span",{children:"All workspace"})]}),u.map(x=>e.jsxs(Ke,{value:`${x.name} ${x.entityType}`,onSelect:()=>{s(x.id),a()},className:"cursor-pointer",children:[e.jsx(tt,{className:R("mr-2 h-4 w-4",t===x.id?"opacity-100":"opacity-0")}),e.jsxs("span",{children:[x.name," ",e.jsxs("span",{className:"text-muted-foreground text-xs",children:["(",x.entityType,")"]})]})]},x.id))]})})}function vt(n){if(Array.isArray(n))return n;if(typeof n=="string"&&n.startsWith("{")&&n.endsWith("}")){const t=n.slice(1,-1);return t?t.split(",").map(s=>s.trim()):[]}return[]}const In=Cn.map(n=>({value:n,label:En[n]})),Bt=[{value:"agent",label:"Agent",hint:"An agent reads the window and follows your instructions."},{value:"code",label:"Code",hint:"A deterministic script processes each completed window."},{value:"both",label:"Agent + code",hint:"An agent extracts per your instructions, then the script runs."}];function Wt(n){const t=!!(n?.prompt?.trim()||n?.skills?.some(r=>r.content.trim())),s=!!n?.reaction_script?.trim();return t&&s?"both":s?"code":"agent"}const qn=["text","number","date","boolean","json"],Kn=[{value:"key",label:"Key"},{value:"plain",label:"Plain"}],ht=[{value:"plan",label:"Plan first"},{value:"auto",label:"Auto"},{value:"acceptEdits",label:"Accept edits"},{value:"dontAsk",label:"Don't ask"},{value:"bypassPermissions",label:"Bypass permissions"}];let Vt=0;function Bn(){return Vt+=1,`field-${Vt}`}function as(n={}){return{id:Bn(),name:n.name??"",type:n.type??"text",role:n.role??"plain"}}function He(n){return n.trim().toLowerCase().replace(/[^a-z0-9_]+/g,"_").replace(/^_+|_+$/g,"")}function Wn(n){return n?Object.keys(n).every(t=>["entity_type","entity_path","key_fields","key_output_field"].includes(t)):!0}function zt(n){return n?Wn(n.keying_config)?"fields":"json":"fields"}function Ut(n){const t=n?.keying_config?.entity_type;return typeof t=="string"?t:""}function Qt(n){const t=n?.keying_config?.entity_path;return typeof t=="string"&&t.trim()?t:"$"}function Gt(n){const t=new Map,s=Array.isArray(n?.keying_config?.key_fields)?n?.keying_config?.key_fields:[];for(const r of s){if(typeof r!="string")continue;const d=He(r);d&&t.set(d,as({name:d,role:"key"}))}return Array.from(t.values())}function _e(n,t){const s=n?.execution_config?.[t];return typeof s=="number"||typeof s=="string"?String(s):""}function Jt(n,t,s){const r=n?.execution_config?.[t];return typeof r=="string"&&s.includes(r)?r:""}function xt(n,t){const s=n.trim();if(!s)return{};const r=Number(s);return Number.isFinite(r)?{value:r}:{error:`${t} must be a number.`}}function Ht({entityType:n,entityPath:t,fields:s}){const d=s.map(a=>({...a,name:He(a.name)})).filter(a=>a.name).filter(a=>a.role==="key").map(a=>a.name),u=He(n),c=t.trim()||"$";return d.length>0&&!u?{error:"Key fields need an output entity type."}:(d.length>0,{keyingConfig:d.length>0?{entity_type:u,entity_path:c,key_fields:d,key_output_field:`${u}_key`}:void 0})}function Vn(n,t){return e.jsxs("div",{className:"space-y-1",children:[e.jsx("h2",{className:"text-sm font-medium",children:n}),e.jsx("p",{className:"text-xs text-muted-foreground",children:t})]})}function Yt(n){return!!(n?.keying_config||n?.reactions_guidance||n?.model_config||n?.execution_config||n?.sources?.length||vt(n?.tags).length)}function zn({organizationId:n,entityId:t,prefill:s,onSubmit:r,isSubmitting:d,error:u,isEditing:c,onCancel:a,triggerFields:x,submitLabel:m="Create Automation",submitDisabled:S=!1,triggers:f}){const{lobuEmbedded:I}=An(),{currentOwner:h}=ss(),{data:j=[]}=Rs(),{data:y=[]}=$s(),[w,T]=i.useState(s?.managed_agent_id??""),_=!!s?.managed_agent_id&&!c,[q,N]=i.useState(s?.delivery_target??null),[K,Y]=i.useState(!1),[te,b]=i.useState(s?.device_worker_id??""),[C,g]=i.useState(s?.device_worker_id?"device":"agent"),[G,se]=i.useState(s?.agent_kind??""),{data:$=[]}=Zt({organizationId:n}),[z,X]=i.useState(s?.name??""),[he,xe]=i.useState(s?.slug??""),[ke,be]=i.useState(!!s?.slug),[D,ge]=i.useState(s?.description??""),[ne,Z]=i.useState(s?.prompt??""),[J,ae]=i.useState(!1),Se=s?.skills??[],[Fe,we]=i.useState(s?.sources??[]),[p,B]=i.useState(s?.entity_id??t),[H,pe]=i.useState(s?.reaction_script??""),[E,Ae]=i.useState(()=>Wt(s)),[ve,Oe]=i.useState(s?.keying_config?JSON.stringify(s.keying_config,null,2):""),[de,W]=i.useState(null),[ye,De]=i.useState(()=>zt(s)),[Me,ue]=i.useState(()=>Ut(s)),[Pe,Be]=i.useState(()=>Qt(s)),[fe,me]=i.useState(()=>Gt(s)),[We,Te]=i.useState(s?.reactions_guidance??""),[nt,Ce]=i.useState(()=>_e(s,"timeout_seconds")),[at,ot]=i.useState(()=>_e(s,"max_budget_usd")),[Ve,Ye]=i.useState(()=>_e(s,"model")),[ze,it]=i.useState(()=>Jt(s,"permission_mode",ht.map(o=>o.value))),[Le,l]=i.useState(()=>_e(s,"effort")),[v,F]=i.useState(()=>_e(s,"finalize_nudges")),[ee,M]=i.useState(null),[je,A]=i.useState(vt(s?.tags).join(", ")),[Re,Ue]=i.useState(""),[rt,jt]=i.useState(!!(c||Yt(s)));i.useEffect(()=>{s&&(X(s.name??""),xe(s.slug??""),be(!!s.slug),ge(s.description??""),Z(s.prompt??""),ae(!1),we(s.sources??[]),B(s.entity_id??t),b(s.device_worker_id??""),g(s.device_worker_id?"device":"agent"),se(s.agent_kind??""),pe(s.reaction_script??""),Ae(Wt(s)),Oe(s.keying_config?JSON.stringify(s.keying_config,null,2):""),W(null),De(zt(s)),ue(Ut(s)),Be(Qt(s)),me(Gt(s)),Te(s.reactions_guidance??""),Ce(_e(s,"timeout_seconds")),ot(_e(s,"max_budget_usd")),Ye(_e(s,"model")),it(Jt(s,"permission_mode",ht.map(o=>o.value))),l(_e(s,"effort")),F(_e(s,"finalize_nudges")),M(null),A(vt(s.tags).join(", ")),Ue(""),T(s.managed_agent_id??""),N(s.delivery_target??null),jt(!!(c||Yt(s))))},[s,t,c]);const os=ke?he:At(z),{data:is}=Is(w||null),{data:rs}=qs(w||null,{enabled:!!w}),ct=on(is??null,rs?.catalog??[]),cs=hn(f),lt=H.trim().length>0,Xe=!c&&E==="code"?"":ne,ls=!c&&E==="agent"?void 0:H.trim()||void 0,_t=(c||E==="code")&<,Nt=xn(Xe,ct,f,_t),ds=J||Xe.trim()!==""?Nt:null,kt=gn(Xe,ct),bt=!c&&E!=="agent",us=C==="device"&&!w.trim(),St=!!z.trim()&&!us&&!Nt&&(!bt||lt)&&!K,ms=cs&&!_t&&kt.length===0,hs=()=>{if(!St)return;let o;if(ye==="fields"){const Ne=Ht({entityType:Me,entityPath:Pe,fields:fe});if(Ne.error){W(Ne.error);return}o=Ne.keyingConfig,W(null)}else{if(ve.trim())try{const Ne=JSON.parse(ve);if(typeof Ne!="object"||Array.isArray(Ne)){W("Keying config must be a JSON object.");return}o=Ne}catch{W("Invalid JSON. Please check the syntax.");return}W(null)}const O=xt(nt,"Timeout");if(O.error){M(O.error);return}if(O.value!==void 0&&(!Number.isInteger(O.value)||O.value<1)){M("Timeout must be a whole number greater than 0.");return}const V=xt(at,"Budget");if(V.error){M(V.error);return}if(V.value!==void 0&&V.value<0){M("Budget cannot be negative.");return}const L=xt(v,"Finalize nudges");if(L.error){M(L.error);return}if(L.value!==void 0&&(!Number.isInteger(L.value)||L.value<0||L.value>5)){M("Finalize nudges must be a whole number from 0 to 5.");return}const Ee={...O.value!==void 0?{timeout_seconds:O.value}:{},...V.value!==void 0?{max_budget_usd:V.value}:{},...Ve.trim()?{model:Ve.trim()}:{},...ze?{permission_mode:ze}:{},...Le.trim()?{effort:Le.trim()}:{},...L.value!==void 0?{finalize_nudges:L.value}:{}},U=Object.keys(Ee).length>0||c?Ee:void 0;M(null);const xs=je.trim()?je.split(",").map(Ne=>Ne.trim()).filter(Boolean):void 0;r({slug:os,name:z.trim(),description:D.trim()||void 0,prompt:Xe,skills:kt,entity_id:p,sources:Fe,reaction_script:ls,keying_config:o,reactions_guidance:We.trim()||void 0,execution_config:U,tags:xs,outputs:s?.outputs,change_notes:Re.trim()||void 0,managed_agent_id:C==="manual"?null:w.trim()||null,device_worker_id:C==="device"&&te.trim()||null,agent_kind:C==="device"&&G.trim()||null,delivery_target:q})},wt=e.jsxs("div",{className:"space-y-2",children:[e.jsxs(k,{htmlFor:"scratch-reaction",children:["Reaction Script"," ",bt?e.jsx("span",{className:"text-destructive",children:"*"}):e.jsx("span",{className:"text-xs font-normal text-muted-foreground",children:"(optional)"})]}),e.jsx(ft,{value:H,onChange:pe,language:"typescript",placeholder:"export default async function reaction(ctx) { ... }",minHeight:"120px"}),c?null:e.jsxs("p",{className:"text-xs text-muted-foreground",children:["Runs deterministically on every completed window, after agent extraction. Declare an ",e.jsx("code",{children:"input"})," export to set the window's extraction contract."]})]});return e.jsxs("div",{className:"space-y-4",children:[e.jsx("div",{className:"space-y-4",children:e.jsxs("div",{className:"space-y-2",children:[e.jsxs("div",{className:"flex items-center justify-between gap-3",children:[e.jsxs(k,{htmlFor:"scratch-name",children:["Name ",e.jsx("span",{className:"text-destructive",children:"*"})]}),!c&&e.jsx("button",{type:"button",onClick:()=>be(!ke),className:"text-xs text-muted-foreground hover:text-foreground",children:ke?"Use automatic slug":"Customize slug"})]}),e.jsx(oe,{id:"scratch-name",value:z,onChange:o=>X(o.target.value),placeholder:"e.g., Escalation signals"}),!c&&ke?e.jsxs("div",{className:"space-y-2",children:[e.jsx(k,{htmlFor:"scratch-slug",children:"Slug"}),e.jsx(oe,{id:"scratch-slug",value:he,onChange:o=>xe(o.target.value.toLowerCase().replace(/[^a-z0-9-]/g,"")),placeholder:At(z)||"custom-slug"})]}):null]})}),c?null:e.jsxs("fieldset",{className:"space-y-2",children:[e.jsx("legend",{className:"text-sm font-medium leading-none peer-disabled:cursor-not-allowed peer-disabled:opacity-70",children:"How does this run?"}),e.jsx("div",{className:"flex flex-wrap gap-1.5",children:Bt.map(o=>e.jsx("button",{type:"button","aria-pressed":E===o.value,onClick:()=>Ae(o.value),className:R("rounded-md px-2.5 py-1.5 text-xs font-medium transition-colors",E===o.value?"bg-secondary text-secondary-foreground":"text-muted-foreground hover:bg-accent/50 hover:text-foreground"),children:o.label},o.value))}),e.jsx("p",{className:"text-xs text-muted-foreground",children:Bt.find(o=>o.value===E)?.hint})]}),c||E!=="code"?e.jsx(Tn,{value:ne,onChange:o=>{ae(!0),Z(o)},library:ct,pinned:Se,required:ms,error:ds,owner:h??"",agentId:w,sources:c?Fe:void 0,onAddSources:c?we:void 0}):null,!c&&E!=="agent"?wt:null,c?e.jsx(Rn,{sources:Fe,onChange:we,disabled:d}):null,e.jsx("div",{className:"space-y-4",children:x}),e.jsx(Mn,{organizationId:n,agentId:C==="agent"?w.trim():"",value:q,onChange:N,disabled:d,automationName:z,onPendingChange:Y}),K?e.jsx("p",{className:"text-xs text-destructive",children:"Confirm the digest destination above before saving — an unconfirmed destination is not sent."}):null,e.jsxs(Q,{type:"button",variant:"ghost",className:"w-full justify-between px-0 text-muted-foreground hover:bg-transparent hover:text-foreground","aria-expanded":rt,"aria-controls":"automation-advanced-settings",onClick:()=>jt(o=>!o),children:[e.jsxs("span",{className:"flex items-center gap-2",children:[e.jsx(Ks,{className:"h-4 w-4"}),"Advanced settings"]}),e.jsx(es,{className:R("h-4 w-4 transition-transform",rt&&"rotate-180")})]}),e.jsxs("div",{id:"automation-advanced-settings",className:R("space-y-4",!rt&&"hidden"),children:[e.jsxs("div",{className:"space-y-2",children:[e.jsx(k,{htmlFor:"scratch-description",children:"Description"}),e.jsx(oe,{id:"scratch-description",value:D,onChange:o=>ge(o.target.value),placeholder:"What this automation does"})]}),!t&&e.jsxs("div",{className:"space-y-2",children:[e.jsx(k,{children:"Entity scope"}),e.jsx($n,{organizationId:n,value:p,onChange:B}),e.jsx("p",{className:"text-xs text-muted-foreground",children:"Limit this automation to one workspace entity."})]}),c?wt:null,e.jsxs("div",{className:"space-y-3",children:[e.jsxs("div",{className:"flex items-center justify-between gap-3",children:[e.jsxs("div",{children:[e.jsx(k,{children:"Output fields"}),e.jsx("p",{className:"mt-1 text-xs text-muted-foreground",children:"Key fields become stable entity keys."})]}),e.jsx(Q,{type:"button",variant:"outline",size:"sm",onClick:()=>{if(ye==="fields"){const o=Ht({entityType:Me,entityPath:Pe,fields:fe});if(o.error){W(o.error);return}Oe(o.keyingConfig?JSON.stringify(o.keyingConfig,null,2):""),De("json")}else De("fields");W(null)},children:ye==="fields"?"Edit JSON":"Use fields"})]}),ye==="fields"?e.jsxs("div",{className:"space-y-3",children:[e.jsxs("div",{className:"grid gap-3 sm:grid-cols-2",children:[e.jsxs("div",{className:"space-y-2",children:[e.jsx(k,{htmlFor:"scratch-output-entity-type",children:"Output entity type"}),e.jsx(st,{contentClassName:"w-[320px]",searchPlaceholder:"Search or type a new type…",emptyText:"Type a name to create a new entity type.",trigger:o=>e.jsxs(Q,{type:"button",variant:"outline",role:"combobox","aria-expanded":o,id:"scratch-output-entity-type",className:"w-full justify-between font-mono text-sm font-normal",children:[e.jsx("span",{className:R("truncate",!Me&&"text-muted-foreground"),children:Me||"Select entity type"}),e.jsx(yt,{className:"ml-2 h-4 w-4 shrink-0 opacity-50"})]}),children:(o,O)=>{const V=He(O),L=$.filter(U=>!U.backing_sql),Ee=L.some(U=>U.slug===V);return e.jsxs(e.Fragment,{children:[L.map(U=>e.jsxs(Ke,{value:`${U.name??U.slug} ${U.slug}`,onSelect:()=>{ue(U.slug),W(null),o()},className:"cursor-pointer",children:[e.jsx(tt,{className:R("mr-2 h-4 w-4",Me===U.slug?"opacity-100":"opacity-0")}),e.jsxs("div",{className:"min-w-0",children:[e.jsx("div",{className:"font-mono text-sm",children:U.slug}),U.name&&U.name!==U.slug&&e.jsx("div",{className:"truncate text-xs text-muted-foreground",children:U.name})]})]},U.slug)),V&&!Ee&&e.jsxs(Ke,{value:O,onSelect:()=>{ue(V),W(null),o()},className:"cursor-pointer",children:[e.jsx(Je,{className:"mr-2 h-4 w-4"}),e.jsxs("span",{className:"text-sm",children:["Create"," ",e.jsx("span",{className:"font-mono",children:V})]})]})]})}})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(k,{htmlFor:"scratch-output-path",children:"Output path"}),e.jsx(oe,{id:"scratch-output-path",value:Pe,onChange:o=>{Be(o.target.value),W(null)},placeholder:"$.items[*]",className:"font-mono text-sm"})]})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsxs("div",{className:"flex items-center justify-between gap-3",children:[e.jsx(k,{children:"Fields"}),e.jsxs(Q,{type:"button",variant:"outline",size:"sm",onClick:()=>{me(o=>[...o,as()]),W(null)},children:[e.jsx(Je,{className:"mr-2 h-4 w-4"}),"Add field"]})]}),fe.length===0?e.jsx("div",{className:R(Ie,"px-3 py-2 text-sm text-muted-foreground"),children:"No output fields configured."}):e.jsx("div",{className:"space-y-2",children:fe.map(o=>e.jsxs("div",{className:R(Ie,"grid gap-2 p-3 sm:grid-cols-[minmax(0,1fr)_128px_minmax(0,240px)_auto]"),children:[e.jsx(oe,{value:o.name,onChange:O=>{const V=He(O.target.value);me(L=>L.map(Ee=>Ee.id===o.id?{...Ee,name:V}:Ee)),W(null)},placeholder:"severity","aria-label":"Output field name",className:"font-mono text-sm"}),e.jsxs(ie,{value:o.type,onValueChange:O=>{me(V=>V.map(L=>L.id===o.id?{...L,type:O}:L))},children:[e.jsx(re,{"aria-label":"Output field type",children:e.jsx(ce,{})}),e.jsx(le,{children:qn.map(O=>e.jsx(P,{value:O,children:O},O))})]}),e.jsx("div",{className:"grid grid-cols-2 rounded-md border border-input bg-background p-1",children:Kn.map(O=>e.jsx("button",{type:"button",onClick:()=>{me(V=>V.map(L=>L.id===o.id?{...L,role:O.value}:L)),W(null)},className:R("rounded-sm px-2 py-1 text-xs transition-colors",o.role===O.value?"bg-muted/70 text-foreground":"text-muted-foreground hover:text-foreground"),children:O.label},O.value))}),e.jsx(Q,{type:"button",variant:"ghost",size:"icon",onClick:()=>{me(O=>O.filter(V=>V.id!==o.id)),W(null)},"aria-label":"Remove output field",children:e.jsx(ts,{className:"h-4 w-4"})})]},o.id))})]}),de&&e.jsx("p",{className:"text-xs text-destructive",children:de})]}):e.jsx("div",{className:"space-y-3",children:e.jsxs("div",{className:"space-y-2",children:[e.jsx(k,{htmlFor:"scratch-keying-config",children:"Keying Config (JSON)"}),e.jsx(ft,{value:ve,onChange:o=>{Oe(o),W(null)},language:"json",placeholder:'{ "entity_type": "topic", "entity_path": "$.items[*]", "key_fields": ["name"], "key_output_field": "entity_key" }',minHeight:"60px"}),de&&e.jsx("p",{className:"text-xs text-destructive",children:de})]})})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(k,{htmlFor:"scratch-reactions-guidance",children:"Reactions Guidance"}),e.jsx(Bs,{id:"scratch-reactions-guidance",value:We,onChange:o=>Te(o.target.value),placeholder:"Guidance text for the reaction system (e.g., when to alert, severity thresholds)...",className:"font-mono text-xs min-h-[80px]"})]}),e.jsxs("div",{className:"space-y-4",children:[Vn("Run settings","Choose where the automation runs and the budget it can use."),!_&&e.jsxs("div",{className:"space-y-2",children:[e.jsx(k,{htmlFor:"scratch-runs-on",children:"Runs on"}),e.jsxs(ie,{value:C,onValueChange:o=>g(o),children:[e.jsx(re,{id:"scratch-runs-on",className:"text-sm",children:e.jsx(ce,{})}),e.jsxs(le,{children:[e.jsx(P,{value:"agent",children:"Managed agent"}),e.jsx(P,{value:"device",children:"On a device"}),e.jsx(P,{value:"manual",children:"Manual-only"})]})]}),e.jsx("p",{className:"text-xs text-muted-foreground",children:C==="agent"?"Automated runs dispatch to a managed Lobu agent.":C==="device"?"Automated runs are claimed and executed locally by a device worker (Mac app, remote worker).":"No executor — this automation runs only when started manually by a connected client."})]}),!_&&C!=="manual"&&e.jsxs("div",{className:"space-y-2",children:[e.jsxs(k,{htmlFor:"scratch-agent-id",children:["Agent",C==="device"&&e.jsx("span",{className:"text-destructive",children:" *"})]}),I?e.jsxs(ie,{value:w||"__unselected__",onValueChange:o=>{T(o==="__unselected__"?"":o)},children:[e.jsx(re,{id:"scratch-agent-id",className:"font-mono text-sm",children:e.jsx(ce,{placeholder:"Select a Lobu agent"})}),e.jsx(le,{children:j.map(o=>e.jsxs(P,{value:o.agentId,children:[o.name," (",o.agentId,")"]},o.agentId))})]}):e.jsx(oe,{id:"scratch-agent-id",value:w,onChange:o=>{T(o.target.value)},placeholder:"e.g., agent-123",className:"font-mono text-sm"}),C==="device"&&e.jsx("p",{className:"text-xs text-muted-foreground",children:"The device run uses this agent's memory and tools, acting as the agent's owner."})]}),!_&&C==="device"&&e.jsxs("div",{className:"space-y-2",children:[e.jsx(k,{htmlFor:"scratch-device-id",children:"Device"}),e.jsxs(ie,{value:te||"__unselected__",onValueChange:o=>b(o==="__unselected__"?"":o),children:[e.jsx(re,{id:"scratch-device-id",className:"font-mono text-sm",children:e.jsx(ce,{placeholder:"Select a device worker"})}),e.jsx(le,{children:y.map(o=>e.jsx(P,{value:o.id,children:o.label||o.platform||o.id},o.id))})]})]}),!_&&C==="device"&&e.jsxs("div",{className:"space-y-2",children:[e.jsx(k,{htmlFor:"scratch-device-agent-kind",children:"Runs as"}),e.jsxs(ie,{value:G||"__default__",onValueChange:o=>se(o==="__default__"?"":o),children:[e.jsx(re,{id:"scratch-device-agent-kind",className:"text-sm",children:e.jsx(ce,{placeholder:"Device default"})}),e.jsxs(le,{children:[e.jsx(P,{value:"__default__",children:"Device default"}),In.map(o=>e.jsx(P,{value:o.value,children:o.label},o.value))]})]}),e.jsx("p",{className:"text-xs text-muted-foreground",children:"Device default uses that device's preferred local agent. Availability is checked again when a run is claimed, so a run stays queued if its selected runtime is no longer available."})]}),e.jsx("div",{className:"grid gap-3 sm:grid-cols-2",children:e.jsxs("div",{className:"space-y-2",children:[e.jsx(k,{children:"Model"}),e.jsx(an,{value:Ve,onChange:o=>{Ye(o),M(null)},placeholder:"Use agent default"})]})}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(k,{htmlFor:"scratch-timeout",children:"Timeout seconds"}),e.jsx(oe,{id:"scratch-timeout",type:"number",min:1,max:86400,value:nt,onChange:o=>{Ce(o.target.value),M(null)},placeholder:"600"})]}),e.jsxs("div",{className:"grid gap-3 sm:grid-cols-3",children:[e.jsxs("div",{className:"space-y-2",children:[e.jsx(k,{htmlFor:"scratch-permission-mode",children:"Permission mode"}),e.jsxs(ie,{value:ze||"__default__",onValueChange:o=>{it(o==="__default__"?"":o),M(null)},children:[e.jsx(re,{id:"scratch-permission-mode",children:e.jsx(ce,{placeholder:"Default"})}),e.jsxs(le,{children:[e.jsx(P,{value:"__default__",children:"Default"}),ht.map(o=>e.jsx(P,{value:o.value,children:o.label},o.value))]})]})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(k,{htmlFor:"scratch-effort",children:"Effort"}),e.jsx(oe,{id:"scratch-effort",value:Le,onChange:o=>{l(o.target.value),M(null)},placeholder:"Default","aria-describedby":"scratch-effort-help"}),e.jsx("p",{id:"scratch-effort-help",className:"text-xs text-muted-foreground",children:"For device runs, use a value supported by the selected CLI and model. Leave empty for its default."})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(k,{htmlFor:"scratch-finalize-nudges",children:"Finalize nudges"}),e.jsx(oe,{id:"scratch-finalize-nudges",type:"number",min:0,max:5,value:v,onChange:o=>{F(o.target.value),M(null)},placeholder:"Default"})]})]}),ee&&e.jsx("p",{className:"text-xs text-destructive",children:ee})]}),e.jsxs("div",{className:"space-y-4",children:[e.jsxs("div",{className:"space-y-2",children:[e.jsx(k,{htmlFor:"scratch-tags",children:"Tags"}),e.jsx(oe,{id:"scratch-tags",value:je,onChange:o=>A(o.target.value),placeholder:"ops, support, risk"})]}),c&&e.jsxs("div",{className:"space-y-2",children:[e.jsx(k,{htmlFor:"scratch-change-notes",children:"Change notes"}),e.jsx(oe,{id:"scratch-change-notes",value:Re,onChange:o=>Ue(o.target.value),placeholder:"What changed in this version?"})]})]})]}),u&&!de&&!ee&&e.jsx("div",{className:"rounded-md bg-destructive/10 px-3 py-2 text-sm text-destructive",children:u}),e.jsx(pt,{onCancel:a,children:e.jsx(Q,{onClick:hs,disabled:!St||d||S,children:d?e.jsxs(e.Fragment,{children:[e.jsx(Ws,{size:"lg",className:"mr-2"}),c?"Saving...":"Creating..."]}):c?"Save Automation":m})})]})}function Un(n,t){const s=n??null,r=t??null;return s===null||r===null?s===r:s.connection_id===r.connection_id&&s.channel_id===r.channel_id}function Qn(n){const t=n.detail??{};return{name:n.name,slug:t.slug,description:t.description??n.description??void 0,prompt:t.prompt,triggers:t.triggers,sources:t.sources,keying_config:t.keying_config,reactions_guidance:t.reactions_guidance,reaction_script:t.reaction_script,model_config:t.model_config,execution_config:t.execution_config,tags:t.tags,outputs:t.outputs}}function aa({startFromScratch:n=!1,onClose:t,hideCancel:s=!1,hideHeader:r=!1,organizationId:d,entityId:u,entityName:c,prefillAgentId:a,onSuccess:x,editingAutomation:m,catalogPrefill:S,onDraft:f,triggerFields:I,submitLabel:h,submitDisabled:j,createFields:y,onPrefillTriggers:w}){const T=Vs(),_=zs(),q=Us(),N=Qs(),K=!!m,[Y,te]=i.useState(n?"scratch":"template"),[b,C]=i.useState(void 0),[g,G]=i.useState(void 0),{data:se=[],isLoading:$}=Gs(),[z,X]=i.useState(""),he=i.useMemo(()=>a?{managed_agent_id:a}:void 0,[a]),xe=i.useMemo(()=>se.map(p=>({key:p.id,name:p.name,description:p.description??"",badges:p.detail?.tags??[]})),[se]),ke=i.useMemo(()=>xe.filter(p=>p.name.toLowerCase().includes(z.toLowerCase())||p.description.toLowerCase().includes(z.toLowerCase())),[xe,z]),be=p=>{const B=se.find(pe=>pe.id===p.key);if(!B)return;const H=Qn(B);G(a?{...H,managed_agent_id:a}:H),w?.(H.triggers??[]),te("scratch")},D=()=>{T.reset(),_.reset(),te("template"),C(void 0),G(void 0),t()},ge=K?y?.triggers??m.triggers??[]:y?.triggers??g?.triggers??S?.triggers??[],ne=async p=>{try{if(f){await f(p);return}if(K){const B=y?.triggers??m.triggers??[],H=m.reaction_script??"",pe=p.reaction_script??"";pe&&pe!==H&&await q.mutateAsync({automation_id:m.automation_id,reaction_script:pe}),await _.mutateAsync({automation_id:m.automation_id,name:p.name,description:p.description,prompt:p.prompt,sources:p.sources,set_as_current:!0,triggers:B,keying_config:p.keying_config,reactions_guidance:p.reactions_guidance,change_notes:p.change_notes}),!pe&&H&&await q.mutateAsync({automation_id:m.automation_id,reaction_script:""});const E={};p.model_config!==void 0&&(E.model_config=p.model_config),p.execution_config!==void 0&&(E.execution_config=p.execution_config),p.tags!==void 0&&(E.tags=p.tags),p.delivery_target!==void 0&&!Un(p.delivery_target,m.delivery_target)&&(E.delivery_target=p.delivery_target),p.managed_agent_id!==void 0&&(E.managed_agent_id=p.managed_agent_id||null),p.agent_kind!==void 0&&(E.agent_kind=p.agent_kind||null),p.device_worker_id!==void 0&&(E.device_worker_id=p.device_worker_id||null),Object.keys(E).length>0&&await N.mutateAsync({automation_id:m.automation_id,...E}),D(),x?.(m.automation_id)}else{const B=y?.triggers??g?.triggers??S?.triggers??[],H=await T.mutateAsync({...p,managed_agent_id:p.managed_agent_id??void 0,device_worker_id:p.device_worker_id??void 0,agent_kind:p.agent_kind??void 0,delivery_target:p.delivery_target??void 0,triggers:B});D(),H.automation_id&&x?.(H.automation_id)}}catch{}},Z=K?_:T;let J="Add an automation";K?J="Edit automation configuration (saves as a new version)":c&&(J=`Add an automation for ${c}`);const ae=m?{entity_id:m.entity_id,name:m.name,slug:m.slug,description:m.description,prompt:m.prompt,sources:m.sources,reaction_script:m.reaction_script,device_worker_id:m.device_worker_id??void 0,agent_kind:m.agent_kind??void 0,keying_config:m.keying_config,reactions_guidance:m.reactions_guidance,model_config:m.model_config,execution_config:m.execution_config,tags:m.tags,managed_agent_id:m.managed_agent_id??void 0,delivery_target:m.delivery_target??void 0}:void 0,Se=K?"Edit Automation":"Create Automation",Fe=e.jsxs("div",{className:"space-y-1.5",children:[e.jsx("h1",{className:"text-2xl font-semibold leading-tight",children:Se}),e.jsx("p",{className:"text-sm text-muted-foreground",children:J})]}),we=e.jsxs("div",{className:"py-6 space-y-6",children:[!K&&e.jsxs("div",{className:"flex flex-wrap justify-start gap-2",children:[e.jsx(gt,{active:Y==="template",onClick:()=>te("template"),icon:e.jsx(Js,{className:"h-4 w-4"}),label:"From templates"}),e.jsx(gt,{active:Y==="scratch",onClick:()=>{te("scratch"),C(void 0),G(void 0)},icon:e.jsx(Je,{className:"h-4 w-4"}),label:"From scratch"}),e.jsx(gt,{active:Y==="clone",onClick:()=>te("clone"),icon:e.jsx(Hs,{className:"h-4 w-4"}),label:"Clone existing"})]}),!K&&Y==="template"?e.jsxs(e.Fragment,{children:[$?e.jsx(Ys,{}):e.jsx(Xs,{items:ke,searchQuery:z,onSearchChange:X,onSelect:be,searchPlaceholder:"Search templates...",searchAriaLabel:"Search automation templates",emptyMessage:xe.length===0?"No automation templates available.":void 0}),r&&!s?e.jsx(pt,{onCancel:D}):null]}):!K&&Y==="clone"&&!b?e.jsxs(e.Fragment,{children:[e.jsx(Gn,{organizationId:d,onSelect:p=>{C(p),w?.(p.triggers??[]),te("scratch")}}),r&&!s?e.jsx(pt,{onCancel:D}):null]}):e.jsx(zn,{organizationId:d,entityId:u,prefill:ae??b??g??S??he,onSubmit:ne,isSubmitting:Z.isPending,error:Z.error?Z.error.message:null,isEditing:K,onCancel:s?void 0:D,triggerFields:I,submitLabel:h,submitDisabled:j,triggers:ge})]});return e.jsxs("div",{className:"flex flex-col",children:[r?null:Fe,we]})}function gt({active:n,onClick:t,icon:s,label:r}){return e.jsxs("button",{type:"button",onClick:t,className:R("flex items-center gap-2 rounded-md border px-3 py-2 text-sm transition-colors",n?"border-primary bg-primary/5 text-primary":"border-border text-muted-foreground hover:border-muted-foreground/30 hover:text-foreground"),children:[s,r]})}function Gn({organizationId:n,onSelect:t}){const{data:s,isLoading:r}=Zs(n),[d,u]=i.useState(""),c=(s||[]).filter(a=>a.name?.toLowerCase().includes(d.toLowerCase()));return r?e.jsx(en,{label:"automations",variant:"list-picker",rows:4}):!s||s.length===0?e.jsx("p",{className:"text-sm text-muted-foreground py-4",children:"No existing automations to clone."}):e.jsxs("div",{className:"space-y-3",children:[e.jsx("input",{type:"text",value:d,onChange:a=>u(a.target.value),placeholder:"Search automations...",className:"w-full rounded-md border px-3 py-2 text-sm bg-background"}),e.jsxs("div",{className:"space-y-2 max-h-[400px] overflow-y-auto",children:[c.map(a=>e.jsxs("button",{type:"button",onClick:()=>t({name:`${a.name} (copy)`,slug:`${a.slug||a.automation_id}-copy`,prompt:a.prompt,keying_config:a.keying_config,triggers:a.triggers,sources:a.sources,outputs:a.outputs}),className:"w-full text-left rounded-md border p-3 hover:border-primary/50 hover:bg-primary/5 transition-colors",children:[e.jsx("p",{className:"text-sm font-medium",children:a.name}),e.jsxs("p",{className:"text-xs text-muted-foreground mt-1",children:[a.entity_name||"Space-level"," · v",a.version??"?"]})]},a.automation_id)),c.length===0&&e.jsx("p",{className:"text-sm text-muted-foreground text-center py-4",children:"No automations match your search."})]})]})}export{na as A,aa as C};
|
|
3
|
+
//# sourceMappingURL=create-automation-form-CtSSeYj3.js.map
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import{eo as U}from"./index-_oPeVpL_.js";var M={exports:{}},A;function H(){return A||(A=1,(function(L,C){(function(w,_){L.exports=_()})(globalThis,()=>(()=>{var D={949(g,p,v){Object.defineProperty(p,"__esModule",{value:!0}),p.CronParser=void 0;var i=v(515),y=(function(){function l(e,t,r){t===void 0&&(t=!0),r===void 0&&(r=!1),this.expression=e,this.dayOfWeekStartIndexZero=t,this.monthStartIndexZero=r}return l.prototype.parse=function(){var e,t,r=(e=this.expression)!==null&&e!==void 0?e:"";if(r==="@reboot")return t=["@reboot","","","","","",""],t;if(r.startsWith("@")){var n=this.parseSpecial(this.expression);t=this.extractParts(n)}else t=this.extractParts(this.expression);return this.normalize(t),this.validate(t),t},l.prototype.parseSpecial=function(e){var t={"@yearly":"0 0 1 1 *","@annually":"0 0 1 1 *","@monthly":"0 0 1 * *","@weekly":"0 0 * * 0","@daily":"0 0 * * *","@midnight":"0 0 * * *","@hourly":"0 * * * *","@reboot":"@reboot"},r=t[e];if(!r)throw new Error("Unknown special expression.");return r},l.prototype.extractParts=function(e){if(!this.expression)throw new Error("cron expression is empty");for(var t=e.trim().split(/[ ]+/),r=0;r<t.length;r++)if(t[r].includes(",")){var n=t[r].split(",").map(function(a){return a.trim()}).filter(function(a){return a!==""}).map(function(a){return isNaN(Number(a))?a:Number(a)}).filter(function(a){return a!==null&&a!==""});n.length===0&&n.push("*"),n.sort(function(a,u){return a!==null&&u!==null?a-u:0}),t[r]=n.map(function(a){return a!==null?a.toString():""}).join(",")}if(t.length<5)throw new Error("Expression has only ".concat(t.length," part").concat(t.length==1?"":"s",". At least 5 parts are required."));if(t.length==5)t.unshift(""),t.push("");else if(t.length==6){var o=/\d{4}$/.test(t[5])||t[4]=="?"||t[2]=="?";o?t.unshift(""):t.push("")}else if(t.length>7)throw new Error("Expression has ".concat(t.length," parts; too many!"));return t},l.prototype.normalize=function(e){var t=this;if(e[3]=e[3].replace("?","*"),e[5]=e[5].replace("?","*"),e[2]=e[2].replace("?","*"),e[0].indexOf("0/")==0&&(e[0]=e[0].replace("0/","*/")),e[1].indexOf("0/")==0&&(e[1]=e[1].replace("0/","*/")),e[2].indexOf("0/")==0&&(e[2]=e[2].replace("0/","*/")),e[3].indexOf("1/")==0&&(e[3]=e[3].replace("1/","*/")),e[4].indexOf("1/")==0&&(e[4]=e[4].replace("1/","*/")),e[6].indexOf("1/")==0&&(e[6]=e[6].replace("1/","*/")),e[5]=e[5].replace(/(^\d)|([^#/\s]\d)/g,function(c){var d=c.replace(/\D/,""),f=d;return t.dayOfWeekStartIndexZero?d=="7"&&(f="0"):f=(parseInt(d)-1).toString(),c.replace(d,f)}),e[5]=="L"&&(e[5]="6"),e[3]=="?"&&(e[3]="*"),e[3].indexOf("W")>-1&&(e[3].indexOf(",")>-1||e[3].indexOf("-")>-1))throw new Error("The 'W' character can be specified only when the day-of-month is a single day, not a range or list of days.");var r={SUN:0,MON:1,TUE:2,WED:3,THU:4,FRI:5,SAT:6};for(var n in r)e[5]=e[5].replace(new RegExp(n,"gi"),r[n].toString());e[4]=e[4].replace(/(^\d{1,2})|([^#/\s]\d{1,2})/g,function(c){var d=c.replace(/\D/,""),f=d;return t.monthStartIndexZero&&(f=(parseInt(d)+1).toString()),c.replace(d,f)});var o={JAN:1,FEB:2,MAR:3,APR:4,MAY:5,JUN:6,JUL:7,AUG:8,SEP:9,OCT:10,NOV:11,DEC:12};for(var a in o)e[4]=e[4].replace(new RegExp(a,"gi"),o[a].toString());e[0]=="0"&&(e[0]=""),!/\*|\-|\,|\//.test(e[2])&&(/\*|\//.test(e[1])||/\*|\//.test(e[0]))&&(e[2]+="-".concat(e[2]));for(var u=0;u<e.length;u++)if(e[u].indexOf(",")!=-1&&(e[u]=e[u].split(",").filter(function(c){return c!==""}).join(",")||"*"),e[u]=="*/1"&&(e[u]="*"),e[u].indexOf("/")>-1&&!/^\*|\-|\,/.test(e[u])){var s=null;switch(u){case 4:s="12";break;case 5:s="6";break;case 6:s="9999";break;default:s=null;break}if(s!==null){var h=e[u].split("/");e[u]="".concat(h[0],"-").concat(s,"/").concat(h[1])}}},l.prototype.validate=function(e){var t="0-9,\\-*/";this.validateOnlyExpectedCharactersFound(e[0],t),this.validateOnlyExpectedCharactersFound(e[1],t),this.validateOnlyExpectedCharactersFound(e[2],t),this.validateOnlyExpectedCharactersFound(e[3],"0-9,\\-*/LW"),this.validateOnlyExpectedCharactersFound(e[4],t),this.validateOnlyExpectedCharactersFound(e[5],"0-9,\\-*/L#"),this.validateOnlyExpectedCharactersFound(e[6],t),this.validateAnyRanges(e)},l.prototype.validateAnyRanges=function(e){i.default.secondRange(e[0]),i.default.minuteRange(e[1]),i.default.hourRange(e[2]),i.default.dayOfMonthRange(e[3]),i.default.monthRange(e[4],this.monthStartIndexZero),i.default.dayOfWeekRange(e[5],this.dayOfWeekStartIndexZero)},l.prototype.validateOnlyExpectedCharactersFound=function(e,t){var r=e.match(new RegExp("[^".concat(t,"]+"),"gi"));if(r&&r.length)throw new Error("Expression contains invalid values: '".concat(r.toString(),"'"))},l})();p.CronParser=y},333(g,p,v){Object.defineProperty(p,"__esModule",{value:!0}),p.ExpressionDescriptor=void 0;var i=v(823),y=v(949),l=(function(){function e(t,r){if(this.expression=t,this.options=r,this.expressionParts=new Array(5),!this.options.locale&&e.defaultLocale&&(this.options.locale=e.defaultLocale),!e.locales[this.options.locale]){var n=Object.keys(e.locales)[0];console.warn("Locale '".concat(this.options.locale,"' could not be found; falling back to '").concat(n,"'.")),this.options.locale=n}this.i18n=e.locales[this.options.locale],r.use24HourTimeFormat===void 0&&(r.use24HourTimeFormat=this.i18n.use24HourTimeFormatByDefault())}return e.toString=function(t,r){var n=r===void 0?{}:r,o=n.throwExceptionOnParseError,a=o===void 0?!0:o,u=n.verbose,s=u===void 0?!1:u,h=n.dayOfWeekStartIndexZero,c=h===void 0?!0:h,d=n.monthStartIndexZero,f=d===void 0?!1:d,O=n.use24HourTimeFormat,T=n.trimHoursLeadingZero,m=T===void 0?!1:T,b=n.locale,E=b===void 0?null:b,X=n.logicalAndDayFields,x=X===void 0?!1:X,S={throwExceptionOnParseError:a,verbose:s,dayOfWeekStartIndexZero:c,monthStartIndexZero:f,use24HourTimeFormat:O,trimHoursLeadingZero:m,locale:E,logicalAndDayFields:x};S.tzOffset&&console.warn("'tzOffset' option has been deprecated and is no longer supported.");var I=new e(t,S);return I.getFullDescription()},e.initialize=function(t,r){r===void 0&&(r="en"),e.specialCharacters=["/","-",",","*"],e.defaultLocale=r,t.load(e.locales)},e.prototype.getFullDescription=function(){var t,r,n="";try{var o=new y.CronParser(this.expression,this.options.dayOfWeekStartIndexZero,this.options.monthStartIndexZero);if(this.expressionParts=o.parse(),this.expressionParts[0]==="@reboot")return((r=(t=this.i18n).atReboot)===null||r===void 0?void 0:r.call(t))||"Run once, at startup";var a=this.getTimeOfDayDescription(),u=this.getDayOfMonthDescription(),s=this.getMonthDescription(),h=this.getDayOfWeekDescription(),c=this.getYearDescription();n+=a+u+h+s+c,n=this.transformVerbosity(n,!!this.options.verbose),n=n.charAt(0).toLocaleUpperCase()+n.substr(1)}catch(d){if(!this.options.throwExceptionOnParseError)n=this.i18n.anErrorOccuredWhenGeneratingTheExpressionD();else throw"".concat(d)}return n},e.prototype.getTimeOfDayDescription=function(){var t=this.expressionParts[0],r=this.expressionParts[1],n=this.expressionParts[2],o="";if(!i.StringUtilities.containsAny(r,e.specialCharacters)&&!i.StringUtilities.containsAny(n,e.specialCharacters)&&!i.StringUtilities.containsAny(t,e.specialCharacters))o+=this.i18n.atSpace()+this.formatTime(n,r,t);else if(!t&&r.indexOf("-")>-1&&!(r.indexOf(",")>-1)&&!(r.indexOf("/")>-1)&&!i.StringUtilities.containsAny(n,e.specialCharacters)){var a=r.split("-");o+=i.StringUtilities.format(this.i18n.everyMinuteBetweenX0AndX1(),this.formatTime(n,a[0],""),this.formatTime(n,a[1],""))}else if(!t&&n.indexOf(",")>-1&&n.indexOf("-")==-1&&n.indexOf("/")==-1&&!i.StringUtilities.containsAny(r,e.specialCharacters)){var u=n.split(",");o+=this.i18n.at();for(var s=0;s<u.length;s++)o&&(o+=" "),o+=this.formatTime(u[s],r,""),s<u.length-2&&(o+=","),s==u.length-2&&(o+=this.i18n.spaceAnd())}else{var h=this.getSecondsDescription(),c=this.getMinutesDescription(),d=this.getHoursDescription();if(o+=h,o&&c&&(o+=", "),o+=c,c===d)return o;o&&d&&(o+=", "),o+=d}return o},e.prototype.getSecondsDescription=function(){var t=this,r=this.getSegmentDescription(this.expressionParts[0],this.i18n.everySecond(),function(n){return n},function(n){return i.StringUtilities.format(t.i18n.everyX0Seconds(n),n)},function(n){return t.i18n.secondsX0ThroughX1PastTheMinute()},function(n){return n=="0"?"":parseInt(n)<20?t.i18n.atX0SecondsPastTheMinute(n):t.i18n.atX0SecondsPastTheMinuteGt20()||t.i18n.atX0SecondsPastTheMinute(n)});return r},e.prototype.getMinutesDescription=function(){var t=this,r=this.expressionParts[0],n=this.expressionParts[2],o=this.getSegmentDescription(this.expressionParts[1],this.i18n.everyMinute(),function(a){return a},function(a){return i.StringUtilities.format(t.i18n.everyX0Minutes(a),a)},function(a){return t.i18n.minutesX0ThroughX1PastTheHour()},function(a){var u,s;try{return a=="0"&&n.indexOf("/")==-1&&r==""?t.i18n.everyHour():a=="0"?((s=(u=t.i18n).onTheHour)===null||s===void 0?void 0:s.call(u))||t.i18n.atX0MinutesPastTheHour(a):parseInt(a)<20?t.i18n.atX0MinutesPastTheHour(a):t.i18n.atX0MinutesPastTheHourGt20()||t.i18n.atX0MinutesPastTheHour(a)}catch{return t.i18n.atX0MinutesPastTheHour(a)}});return o},e.prototype.getHoursDescription=function(){var t=this,r=this.expressionParts[2],n=0,o=[];r.split("/")[0].split(",").forEach(function(s){var h=s.split("-");h.length===2&&o.push({value:h[1],index:n+1}),n+=h.length});var a=0,u=this.getSegmentDescription(r,this.i18n.everyHour(),function(s){var h=o.find(function(d){return d.value===s&&d.index===a}),c=h&&t.expressionParts[1]!=="0";return a++,c?t.formatTime(s,"59",""):t.formatTime(s,"0","")},function(s){return i.StringUtilities.format(t.i18n.everyX0Hours(s),s)},function(s){return t.i18n.betweenX0AndX1()},function(s){return t.i18n.atX0()});return u},e.prototype.getDayOfWeekDescription=function(){var t=this,r=this.i18n.daysOfTheWeek(),n=null;return this.expressionParts[5]=="*"?n="":n=this.getSegmentDescription(this.expressionParts[5],this.i18n.commaEveryDay(),function(o,a){var u=o;o.indexOf("#")>-1?u=o.substring(0,o.indexOf("#")):o.indexOf("L")>-1&&(u=u.replace("L",""));var s=parseInt(u),h=t.i18n.daysOfTheWeekInCase?t.i18n.daysOfTheWeekInCase(a)[s]:r[s];if(o.indexOf("#")>-1){var c=null,d=o.substring(o.indexOf("#")+1),f=o.substring(0,o.indexOf("#"));switch(d){case"1":c=t.i18n.first(f);break;case"2":c=t.i18n.second(f);break;case"3":c=t.i18n.third(f);break;case"4":c=t.i18n.fourth(f);break;case"5":c=t.i18n.fifth(f);break}h=c+" "+h}return h},function(o){return parseInt(o)==1?"":i.StringUtilities.format(t.i18n.commaEveryX0DaysOfTheWeek(o),o)},function(o){var a=o.substring(0,o.indexOf("-")),u=t.expressionParts[3]!="*";return u?t.i18n.commaAndX0ThroughX1(a):t.i18n.commaX0ThroughX1(a)},function(o){var a=null;if(o.indexOf("#")>-1){var u=o.substring(o.indexOf("#")+1),s=o.substring(0,o.indexOf("#"));a=t.i18n.commaOnThe(u,s).trim()+t.i18n.spaceX0OfTheMonth()}else if(o.indexOf("L")>-1)a=t.i18n.commaOnTheLastX0OfTheMonth(o.replace("L",""));else{var h=t.expressionParts[3]!="*";h?t.options.logicalAndDayFields?a=t.i18n.commaOnlyOnX0(o):a=t.i18n.commaAndOnX0():a=t.i18n.commaOnlyOnX0(o)}return a}),n},e.prototype.getMonthDescription=function(){var t=this,r=this.i18n.monthsOfTheYear(),n=this.getSegmentDescription(this.expressionParts[4],"",function(o,a){return a&&t.i18n.monthsOfTheYearInCase?t.i18n.monthsOfTheYearInCase(a)[parseInt(o)-1]:r[parseInt(o)-1]},function(o){return parseInt(o)==1?"":i.StringUtilities.format(t.i18n.commaEveryX0Months(o),o)},function(o){return t.i18n.commaMonthX0ThroughMonthX1()||t.i18n.commaX0ThroughX1()},function(o){return t.i18n.commaOnlyInMonthX0?t.i18n.commaOnlyInMonthX0():t.i18n.commaOnlyInX0()});return n},e.prototype.getDayOfMonthDescription=function(){var t=this,r=null,n=this.expressionParts[3];switch(n){case"L":r=this.i18n.commaOnTheLastDayOfTheMonth();break;case"WL":case"LW":r=this.i18n.commaOnTheLastWeekdayOfTheMonth();break;default:var o=n.match(/(\d{1,2}W)|(W\d{1,2})/);if(o){var a=parseInt(o[0].replace("W","")),u=a==1?this.i18n.firstWeekday():i.StringUtilities.format(this.i18n.weekdayNearestDayX0(),a.toString());r=i.StringUtilities.format(this.i18n.commaOnTheX0OfTheMonth(),u);break}else{var s=n.match(/L-(\d{1,2})/);if(s){var h=s[1];r=i.StringUtilities.format(this.i18n.commaDaysBeforeTheLastDayOfTheMonth(h),h);break}else{if(n=="*"&&this.expressionParts[5]!="*")return"";r=this.getSegmentDescription(n,this.i18n.commaEveryDay(),function(c){return c=="L"?t.i18n.lastDay():t.i18n.dayX0?i.StringUtilities.format(t.i18n.dayX0(),c):c},function(c){return c=="1"?t.i18n.commaEveryDay():t.i18n.commaEveryX0Days(c)},function(c){return t.i18n.commaBetweenDayX0AndX1OfTheMonth(c)},function(c){return t.i18n.commaOnDayX0OfTheMonth(c)})}break}}return r},e.prototype.getYearDescription=function(){var t=this,r=this.getSegmentDescription(this.expressionParts[6],"",function(n){return/^\d+$/.test(n)?new Date(parseInt(n),1).getFullYear().toString():n},function(n){return i.StringUtilities.format(t.i18n.commaEveryX0Years(n),n)},function(n){return t.i18n.commaYearX0ThroughYearX1()||t.i18n.commaX0ThroughX1()},function(n){return t.i18n.commaOnlyInYearX0?t.i18n.commaOnlyInYearX0():t.i18n.commaOnlyInX0()});return r},e.prototype.getSegmentDescription=function(t,r,n,o,a,u){var s=null,h=t.indexOf("/")>-1,c=t.indexOf("-")>-1,d=t.indexOf(",")>-1;if(!t)s="";else if(t==="*")s=r;else if(!h&&!c&&!d)s=i.StringUtilities.format(u(t),n(t));else if(d){for(var f=t.split(","),O="",T=this.i18n.spaceAnd(),m=0;m<f.length;m++)if(m>0&&f.length>2&&(O+=",",m<f.length-1&&(O+=" ")),m>0&&f.length>1&&(m==f.length-1||f.length==2)&&(O+=T==","&&f.length>2?" ":"".concat(T," ")),f[m].indexOf("/")>-1||f[m].indexOf("-")>-1){var b=f[m].indexOf("-")>-1&&f[m].indexOf("/")==-1,E=this.getSegmentDescription(f[m],r,n,o,b?this.i18n.commaX0ThroughX1:a,u);b&&(E=E.replace(", ","")),O+=E}else if(!h)O+=n(f[m]);else{var X=this.getSegmentDescription(f[m],r,n,o,a,u);X&&X.startsWith(", ")&&(X=X.substring(2)),O+=X}h?s=O:s=i.StringUtilities.format(u(t),O)}else if(h){var f=t.split("/");if(s=i.StringUtilities.format(o(f[1]),f[1]),f[0].indexOf("-")>-1){var x=this.generateRangeSegmentDescription(f[0],a,n);x.indexOf(", ")!=0&&(s+=", "),s+=x}else if(f[0].indexOf("*")==-1){var S=i.StringUtilities.format(u(f[0]),n(f[0]));S=S.replace(", ",""),s+=i.StringUtilities.format(this.i18n.commaStartingX0(),S)}}else c&&(s=this.generateRangeSegmentDescription(t,a,n));return s},e.prototype.generateRangeSegmentDescription=function(t,r,n){var o="",a=t.split("-"),u=n(a[0],1),s=n(a[1],2),h=r(t);return o+=i.StringUtilities.format(h,u,s),o},e.prototype.formatTime=function(t,r,n){var o=0,a=0,u=parseInt(t)+o,s=parseInt(r)+a;s>=60?(s-=60,u+=1):s<0&&(s+=60,u-=1),u>=24?u=u-24:u<0&&(u=24+u);var h="",c=!1;this.options.use24HourTimeFormat||(c=!!(this.i18n.setPeriodBeforeTime&&this.i18n.setPeriodBeforeTime()),h=c?"".concat(this.getPeriod(u)," "):" ".concat(this.getPeriod(u)),u>12&&(u-=12),u===0&&(u=12));var d="";n&&(d=":".concat(("00"+n).substring(n.length)));var f=u.toString(),O=("00"+f).substring(f.length),T=s.toString(),m=("00"+T).substring(T.length),b=this.options.trimHoursLeadingZero?f:O;return"".concat(c?h:"").concat(b,":").concat(m).concat(d).concat(c?"":h)},e.prototype.transformVerbosity=function(t,r){if(!r&&(t=t.replace(new RegExp(", ".concat(this.i18n.everyMinute()),"g"),""),t=t.replace(new RegExp(", ".concat(this.i18n.everyHour()),"g"),""),t=t.replace(new RegExp(this.i18n.commaEveryDay(),"g"),""),t=t.replace(/\, ?$/,""),this.i18n.conciseVerbosityReplacements))for(var n=0,o=Object.entries(this.i18n.conciseVerbosityReplacements());n<o.length;n++){var a=o[n],u=a[0],s=a[1];t=t.replace(new RegExp(u,"g"),s)}return t},e.prototype.getPeriod=function(t){return t>=12?this.i18n.pm&&this.i18n.pm()||"PM":this.i18n.am&&this.i18n.am()||"AM"},e.locales={},e})();p.ExpressionDescriptor=l},747(g,p,v){Object.defineProperty(p,"__esModule",{value:!0}),p.enLocaleLoader=void 0;var i=v(486),y=(function(){function l(){}return l.prototype.load=function(e){e.en=new i.en},l})();p.enLocaleLoader=y},486(g,p){Object.defineProperty(p,"__esModule",{value:!0}),p.en=void 0;var v=(function(){function i(){}return i.prototype.atX0SecondsPastTheMinuteGt20=function(){return null},i.prototype.atX0MinutesPastTheHourGt20=function(){return null},i.prototype.commaMonthX0ThroughMonthX1=function(){return null},i.prototype.commaYearX0ThroughYearX1=function(){return null},i.prototype.use24HourTimeFormatByDefault=function(){return!1},i.prototype.anErrorOccuredWhenGeneratingTheExpressionD=function(){return"An error occurred when generating the expression description. Check the cron expression syntax."},i.prototype.everyMinute=function(){return"every minute"},i.prototype.everyHour=function(){return"every hour"},i.prototype.atSpace=function(){return"At "},i.prototype.everyMinuteBetweenX0AndX1=function(){return"Every minute between %s and %s"},i.prototype.at=function(){return"At"},i.prototype.spaceAnd=function(){return" and"},i.prototype.everySecond=function(){return"every second"},i.prototype.everyX0Seconds=function(){return"every %s seconds"},i.prototype.secondsX0ThroughX1PastTheMinute=function(){return"seconds %s through %s past the minute"},i.prototype.atX0SecondsPastTheMinute=function(){return"at %s seconds past the minute"},i.prototype.everyX0Minutes=function(){return"every %s minutes"},i.prototype.minutesX0ThroughX1PastTheHour=function(){return"minutes %s through %s past the hour"},i.prototype.atX0MinutesPastTheHour=function(){return"at %s minutes past the hour"},i.prototype.everyX0Hours=function(){return"every %s hours"},i.prototype.betweenX0AndX1=function(){return"between %s and %s"},i.prototype.atX0=function(){return"at %s"},i.prototype.commaEveryDay=function(){return", every day"},i.prototype.commaEveryX0DaysOfTheWeek=function(){return", every %s days of the week"},i.prototype.commaX0ThroughX1=function(){return", %s through %s"},i.prototype.commaAndX0ThroughX1=function(){return", %s through %s"},i.prototype.first=function(){return"first"},i.prototype.second=function(){return"second"},i.prototype.third=function(){return"third"},i.prototype.fourth=function(){return"fourth"},i.prototype.fifth=function(){return"fifth"},i.prototype.commaOnThe=function(){return", on the "},i.prototype.spaceX0OfTheMonth=function(){return" %s of the month"},i.prototype.lastDay=function(){return"the last day"},i.prototype.commaOnTheLastX0OfTheMonth=function(){return", on the last %s of the month"},i.prototype.commaOnlyOnX0=function(){return", only on %s"},i.prototype.commaAndOnX0=function(){return", and on %s"},i.prototype.commaEveryX0Months=function(){return", every %s months"},i.prototype.commaOnlyInX0=function(){return", only in %s"},i.prototype.commaOnTheLastDayOfTheMonth=function(){return", on the last day of the month"},i.prototype.commaOnTheLastWeekdayOfTheMonth=function(){return", on the last weekday of the month"},i.prototype.commaDaysBeforeTheLastDayOfTheMonth=function(){return", %s days before the last day of the month"},i.prototype.firstWeekday=function(){return"first weekday"},i.prototype.weekdayNearestDayX0=function(){return"weekday nearest day %s"},i.prototype.commaOnTheX0OfTheMonth=function(){return", on the %s of the month"},i.prototype.commaEveryX0Days=function(){return", every %s days in a month"},i.prototype.commaBetweenDayX0AndX1OfTheMonth=function(){return", between day %s and %s of the month"},i.prototype.commaOnDayX0OfTheMonth=function(){return", on day %s of the month"},i.prototype.commaEveryHour=function(){return", every hour"},i.prototype.commaEveryX0Years=function(){return", every %s years"},i.prototype.commaStartingX0=function(){return", starting %s"},i.prototype.daysOfTheWeek=function(){return["Sunday","Monday","Tuesday","Wednesday","Thursday","Friday","Saturday"]},i.prototype.monthsOfTheYear=function(){return["January","February","March","April","May","June","July","August","September","October","November","December"]},i.prototype.atReboot=function(){return"Run once, at startup"},i.prototype.onTheHour=function(){return"on the hour"},i})();p.en=v},515(g,p){Object.defineProperty(p,"__esModule",{value:!0});function v(y,l){if(!y)throw new Error(l)}var i=(function(){function y(){}return y.secondRange=function(l){for(var e=l.split(","),t=0;t<e.length;t++)if(!isNaN(parseInt(e[t],10))){var r=parseInt(e[t],10);v(r>=0&&r<=59,"seconds part must be >= 0 and <= 59")}},y.minuteRange=function(l){for(var e=l.split(","),t=0;t<e.length;t++)if(!isNaN(parseInt(e[t],10))){var r=parseInt(e[t],10);v(r>=0&&r<=59,"minutes part must be >= 0 and <= 59")}},y.hourRange=function(l){for(var e=l.split(","),t=0;t<e.length;t++)if(!isNaN(parseInt(e[t],10))){var r=parseInt(e[t],10);v(r>=0&&r<=23,"hours part must be >= 0 and <= 23")}},y.dayOfMonthRange=function(l){for(var e=l.split(","),t=0;t<e.length;t++)if(!isNaN(parseInt(e[t],10))){var r=parseInt(e[t],10);v(r>=1&&r<=31,"DOM part must be >= 1 and <= 31")}},y.monthRange=function(l,e){for(var t=l.split(","),r=0;r<t.length;r++)if(!isNaN(parseInt(t[r],10))){var n=parseInt(t[r],10);v(n>=1&&n<=12,e?"month part must be >= 0 and <= 11":"month part must be >= 1 and <= 12")}},y.dayOfWeekRange=function(l,e){for(var t=l.split(","),r=0;r<t.length;r++)if(!isNaN(parseInt(t[r],10))){var n=parseInt(t[r],10);v(n>=0&&n<=6,e?"DOW part must be >= 0 and <= 6":"DOW part must be >= 1 and <= 7")}},y})();p.default=i},823(g,p){Object.defineProperty(p,"__esModule",{value:!0}),p.StringUtilities=void 0;var v=(function(){function i(){}return i.format=function(y){for(var l=[],e=1;e<arguments.length;e++)l[e-1]=arguments[e];return y.replace(/%s/g,function(t){return l.shift()})},i.containsAny=function(y,l){return l.some(function(e){return y.indexOf(e)>-1})},i})();p.StringUtilities=v}},w={};function _(g){var p=w[g];if(p!==void 0)return p.exports;var v=w[g]={exports:{}};return D[g](v,v.exports,_),v.exports}var k={};return(()=>{var g=k;Object.defineProperty(g,"__esModule",{value:!0}),g.toString=void 0;var p=_(333),v=_(747);p.ExpressionDescriptor.initialize(new v.enLocaleLoader),g.default=p.ExpressionDescriptor;var i=p.ExpressionDescriptor.toString;g.toString=i})(),k})())})(M)),M.exports}var R=H();const F=U(R);export{F as c};
|
|
2
|
-
//# sourceMappingURL=cronstrue-
|
|
1
|
+
import{eo as U}from"./index-Cr5hwh-C.js";var M={exports:{}},A;function H(){return A||(A=1,(function(L,C){(function(w,_){L.exports=_()})(globalThis,()=>(()=>{var D={949(g,p,v){Object.defineProperty(p,"__esModule",{value:!0}),p.CronParser=void 0;var i=v(515),y=(function(){function l(e,t,r){t===void 0&&(t=!0),r===void 0&&(r=!1),this.expression=e,this.dayOfWeekStartIndexZero=t,this.monthStartIndexZero=r}return l.prototype.parse=function(){var e,t,r=(e=this.expression)!==null&&e!==void 0?e:"";if(r==="@reboot")return t=["@reboot","","","","","",""],t;if(r.startsWith("@")){var n=this.parseSpecial(this.expression);t=this.extractParts(n)}else t=this.extractParts(this.expression);return this.normalize(t),this.validate(t),t},l.prototype.parseSpecial=function(e){var t={"@yearly":"0 0 1 1 *","@annually":"0 0 1 1 *","@monthly":"0 0 1 * *","@weekly":"0 0 * * 0","@daily":"0 0 * * *","@midnight":"0 0 * * *","@hourly":"0 * * * *","@reboot":"@reboot"},r=t[e];if(!r)throw new Error("Unknown special expression.");return r},l.prototype.extractParts=function(e){if(!this.expression)throw new Error("cron expression is empty");for(var t=e.trim().split(/[ ]+/),r=0;r<t.length;r++)if(t[r].includes(",")){var n=t[r].split(",").map(function(a){return a.trim()}).filter(function(a){return a!==""}).map(function(a){return isNaN(Number(a))?a:Number(a)}).filter(function(a){return a!==null&&a!==""});n.length===0&&n.push("*"),n.sort(function(a,u){return a!==null&&u!==null?a-u:0}),t[r]=n.map(function(a){return a!==null?a.toString():""}).join(",")}if(t.length<5)throw new Error("Expression has only ".concat(t.length," part").concat(t.length==1?"":"s",". At least 5 parts are required."));if(t.length==5)t.unshift(""),t.push("");else if(t.length==6){var o=/\d{4}$/.test(t[5])||t[4]=="?"||t[2]=="?";o?t.unshift(""):t.push("")}else if(t.length>7)throw new Error("Expression has ".concat(t.length," parts; too many!"));return t},l.prototype.normalize=function(e){var t=this;if(e[3]=e[3].replace("?","*"),e[5]=e[5].replace("?","*"),e[2]=e[2].replace("?","*"),e[0].indexOf("0/")==0&&(e[0]=e[0].replace("0/","*/")),e[1].indexOf("0/")==0&&(e[1]=e[1].replace("0/","*/")),e[2].indexOf("0/")==0&&(e[2]=e[2].replace("0/","*/")),e[3].indexOf("1/")==0&&(e[3]=e[3].replace("1/","*/")),e[4].indexOf("1/")==0&&(e[4]=e[4].replace("1/","*/")),e[6].indexOf("1/")==0&&(e[6]=e[6].replace("1/","*/")),e[5]=e[5].replace(/(^\d)|([^#/\s]\d)/g,function(c){var d=c.replace(/\D/,""),f=d;return t.dayOfWeekStartIndexZero?d=="7"&&(f="0"):f=(parseInt(d)-1).toString(),c.replace(d,f)}),e[5]=="L"&&(e[5]="6"),e[3]=="?"&&(e[3]="*"),e[3].indexOf("W")>-1&&(e[3].indexOf(",")>-1||e[3].indexOf("-")>-1))throw new Error("The 'W' character can be specified only when the day-of-month is a single day, not a range or list of days.");var r={SUN:0,MON:1,TUE:2,WED:3,THU:4,FRI:5,SAT:6};for(var n in r)e[5]=e[5].replace(new RegExp(n,"gi"),r[n].toString());e[4]=e[4].replace(/(^\d{1,2})|([^#/\s]\d{1,2})/g,function(c){var d=c.replace(/\D/,""),f=d;return t.monthStartIndexZero&&(f=(parseInt(d)+1).toString()),c.replace(d,f)});var o={JAN:1,FEB:2,MAR:3,APR:4,MAY:5,JUN:6,JUL:7,AUG:8,SEP:9,OCT:10,NOV:11,DEC:12};for(var a in o)e[4]=e[4].replace(new RegExp(a,"gi"),o[a].toString());e[0]=="0"&&(e[0]=""),!/\*|\-|\,|\//.test(e[2])&&(/\*|\//.test(e[1])||/\*|\//.test(e[0]))&&(e[2]+="-".concat(e[2]));for(var u=0;u<e.length;u++)if(e[u].indexOf(",")!=-1&&(e[u]=e[u].split(",").filter(function(c){return c!==""}).join(",")||"*"),e[u]=="*/1"&&(e[u]="*"),e[u].indexOf("/")>-1&&!/^\*|\-|\,/.test(e[u])){var s=null;switch(u){case 4:s="12";break;case 5:s="6";break;case 6:s="9999";break;default:s=null;break}if(s!==null){var h=e[u].split("/");e[u]="".concat(h[0],"-").concat(s,"/").concat(h[1])}}},l.prototype.validate=function(e){var t="0-9,\\-*/";this.validateOnlyExpectedCharactersFound(e[0],t),this.validateOnlyExpectedCharactersFound(e[1],t),this.validateOnlyExpectedCharactersFound(e[2],t),this.validateOnlyExpectedCharactersFound(e[3],"0-9,\\-*/LW"),this.validateOnlyExpectedCharactersFound(e[4],t),this.validateOnlyExpectedCharactersFound(e[5],"0-9,\\-*/L#"),this.validateOnlyExpectedCharactersFound(e[6],t),this.validateAnyRanges(e)},l.prototype.validateAnyRanges=function(e){i.default.secondRange(e[0]),i.default.minuteRange(e[1]),i.default.hourRange(e[2]),i.default.dayOfMonthRange(e[3]),i.default.monthRange(e[4],this.monthStartIndexZero),i.default.dayOfWeekRange(e[5],this.dayOfWeekStartIndexZero)},l.prototype.validateOnlyExpectedCharactersFound=function(e,t){var r=e.match(new RegExp("[^".concat(t,"]+"),"gi"));if(r&&r.length)throw new Error("Expression contains invalid values: '".concat(r.toString(),"'"))},l})();p.CronParser=y},333(g,p,v){Object.defineProperty(p,"__esModule",{value:!0}),p.ExpressionDescriptor=void 0;var i=v(823),y=v(949),l=(function(){function e(t,r){if(this.expression=t,this.options=r,this.expressionParts=new Array(5),!this.options.locale&&e.defaultLocale&&(this.options.locale=e.defaultLocale),!e.locales[this.options.locale]){var n=Object.keys(e.locales)[0];console.warn("Locale '".concat(this.options.locale,"' could not be found; falling back to '").concat(n,"'.")),this.options.locale=n}this.i18n=e.locales[this.options.locale],r.use24HourTimeFormat===void 0&&(r.use24HourTimeFormat=this.i18n.use24HourTimeFormatByDefault())}return e.toString=function(t,r){var n=r===void 0?{}:r,o=n.throwExceptionOnParseError,a=o===void 0?!0:o,u=n.verbose,s=u===void 0?!1:u,h=n.dayOfWeekStartIndexZero,c=h===void 0?!0:h,d=n.monthStartIndexZero,f=d===void 0?!1:d,O=n.use24HourTimeFormat,T=n.trimHoursLeadingZero,m=T===void 0?!1:T,b=n.locale,E=b===void 0?null:b,X=n.logicalAndDayFields,x=X===void 0?!1:X,S={throwExceptionOnParseError:a,verbose:s,dayOfWeekStartIndexZero:c,monthStartIndexZero:f,use24HourTimeFormat:O,trimHoursLeadingZero:m,locale:E,logicalAndDayFields:x};S.tzOffset&&console.warn("'tzOffset' option has been deprecated and is no longer supported.");var I=new e(t,S);return I.getFullDescription()},e.initialize=function(t,r){r===void 0&&(r="en"),e.specialCharacters=["/","-",",","*"],e.defaultLocale=r,t.load(e.locales)},e.prototype.getFullDescription=function(){var t,r,n="";try{var o=new y.CronParser(this.expression,this.options.dayOfWeekStartIndexZero,this.options.monthStartIndexZero);if(this.expressionParts=o.parse(),this.expressionParts[0]==="@reboot")return((r=(t=this.i18n).atReboot)===null||r===void 0?void 0:r.call(t))||"Run once, at startup";var a=this.getTimeOfDayDescription(),u=this.getDayOfMonthDescription(),s=this.getMonthDescription(),h=this.getDayOfWeekDescription(),c=this.getYearDescription();n+=a+u+h+s+c,n=this.transformVerbosity(n,!!this.options.verbose),n=n.charAt(0).toLocaleUpperCase()+n.substr(1)}catch(d){if(!this.options.throwExceptionOnParseError)n=this.i18n.anErrorOccuredWhenGeneratingTheExpressionD();else throw"".concat(d)}return n},e.prototype.getTimeOfDayDescription=function(){var t=this.expressionParts[0],r=this.expressionParts[1],n=this.expressionParts[2],o="";if(!i.StringUtilities.containsAny(r,e.specialCharacters)&&!i.StringUtilities.containsAny(n,e.specialCharacters)&&!i.StringUtilities.containsAny(t,e.specialCharacters))o+=this.i18n.atSpace()+this.formatTime(n,r,t);else if(!t&&r.indexOf("-")>-1&&!(r.indexOf(",")>-1)&&!(r.indexOf("/")>-1)&&!i.StringUtilities.containsAny(n,e.specialCharacters)){var a=r.split("-");o+=i.StringUtilities.format(this.i18n.everyMinuteBetweenX0AndX1(),this.formatTime(n,a[0],""),this.formatTime(n,a[1],""))}else if(!t&&n.indexOf(",")>-1&&n.indexOf("-")==-1&&n.indexOf("/")==-1&&!i.StringUtilities.containsAny(r,e.specialCharacters)){var u=n.split(",");o+=this.i18n.at();for(var s=0;s<u.length;s++)o&&(o+=" "),o+=this.formatTime(u[s],r,""),s<u.length-2&&(o+=","),s==u.length-2&&(o+=this.i18n.spaceAnd())}else{var h=this.getSecondsDescription(),c=this.getMinutesDescription(),d=this.getHoursDescription();if(o+=h,o&&c&&(o+=", "),o+=c,c===d)return o;o&&d&&(o+=", "),o+=d}return o},e.prototype.getSecondsDescription=function(){var t=this,r=this.getSegmentDescription(this.expressionParts[0],this.i18n.everySecond(),function(n){return n},function(n){return i.StringUtilities.format(t.i18n.everyX0Seconds(n),n)},function(n){return t.i18n.secondsX0ThroughX1PastTheMinute()},function(n){return n=="0"?"":parseInt(n)<20?t.i18n.atX0SecondsPastTheMinute(n):t.i18n.atX0SecondsPastTheMinuteGt20()||t.i18n.atX0SecondsPastTheMinute(n)});return r},e.prototype.getMinutesDescription=function(){var t=this,r=this.expressionParts[0],n=this.expressionParts[2],o=this.getSegmentDescription(this.expressionParts[1],this.i18n.everyMinute(),function(a){return a},function(a){return i.StringUtilities.format(t.i18n.everyX0Minutes(a),a)},function(a){return t.i18n.minutesX0ThroughX1PastTheHour()},function(a){var u,s;try{return a=="0"&&n.indexOf("/")==-1&&r==""?t.i18n.everyHour():a=="0"?((s=(u=t.i18n).onTheHour)===null||s===void 0?void 0:s.call(u))||t.i18n.atX0MinutesPastTheHour(a):parseInt(a)<20?t.i18n.atX0MinutesPastTheHour(a):t.i18n.atX0MinutesPastTheHourGt20()||t.i18n.atX0MinutesPastTheHour(a)}catch{return t.i18n.atX0MinutesPastTheHour(a)}});return o},e.prototype.getHoursDescription=function(){var t=this,r=this.expressionParts[2],n=0,o=[];r.split("/")[0].split(",").forEach(function(s){var h=s.split("-");h.length===2&&o.push({value:h[1],index:n+1}),n+=h.length});var a=0,u=this.getSegmentDescription(r,this.i18n.everyHour(),function(s){var h=o.find(function(d){return d.value===s&&d.index===a}),c=h&&t.expressionParts[1]!=="0";return a++,c?t.formatTime(s,"59",""):t.formatTime(s,"0","")},function(s){return i.StringUtilities.format(t.i18n.everyX0Hours(s),s)},function(s){return t.i18n.betweenX0AndX1()},function(s){return t.i18n.atX0()});return u},e.prototype.getDayOfWeekDescription=function(){var t=this,r=this.i18n.daysOfTheWeek(),n=null;return this.expressionParts[5]=="*"?n="":n=this.getSegmentDescription(this.expressionParts[5],this.i18n.commaEveryDay(),function(o,a){var u=o;o.indexOf("#")>-1?u=o.substring(0,o.indexOf("#")):o.indexOf("L")>-1&&(u=u.replace("L",""));var s=parseInt(u),h=t.i18n.daysOfTheWeekInCase?t.i18n.daysOfTheWeekInCase(a)[s]:r[s];if(o.indexOf("#")>-1){var c=null,d=o.substring(o.indexOf("#")+1),f=o.substring(0,o.indexOf("#"));switch(d){case"1":c=t.i18n.first(f);break;case"2":c=t.i18n.second(f);break;case"3":c=t.i18n.third(f);break;case"4":c=t.i18n.fourth(f);break;case"5":c=t.i18n.fifth(f);break}h=c+" "+h}return h},function(o){return parseInt(o)==1?"":i.StringUtilities.format(t.i18n.commaEveryX0DaysOfTheWeek(o),o)},function(o){var a=o.substring(0,o.indexOf("-")),u=t.expressionParts[3]!="*";return u?t.i18n.commaAndX0ThroughX1(a):t.i18n.commaX0ThroughX1(a)},function(o){var a=null;if(o.indexOf("#")>-1){var u=o.substring(o.indexOf("#")+1),s=o.substring(0,o.indexOf("#"));a=t.i18n.commaOnThe(u,s).trim()+t.i18n.spaceX0OfTheMonth()}else if(o.indexOf("L")>-1)a=t.i18n.commaOnTheLastX0OfTheMonth(o.replace("L",""));else{var h=t.expressionParts[3]!="*";h?t.options.logicalAndDayFields?a=t.i18n.commaOnlyOnX0(o):a=t.i18n.commaAndOnX0():a=t.i18n.commaOnlyOnX0(o)}return a}),n},e.prototype.getMonthDescription=function(){var t=this,r=this.i18n.monthsOfTheYear(),n=this.getSegmentDescription(this.expressionParts[4],"",function(o,a){return a&&t.i18n.monthsOfTheYearInCase?t.i18n.monthsOfTheYearInCase(a)[parseInt(o)-1]:r[parseInt(o)-1]},function(o){return parseInt(o)==1?"":i.StringUtilities.format(t.i18n.commaEveryX0Months(o),o)},function(o){return t.i18n.commaMonthX0ThroughMonthX1()||t.i18n.commaX0ThroughX1()},function(o){return t.i18n.commaOnlyInMonthX0?t.i18n.commaOnlyInMonthX0():t.i18n.commaOnlyInX0()});return n},e.prototype.getDayOfMonthDescription=function(){var t=this,r=null,n=this.expressionParts[3];switch(n){case"L":r=this.i18n.commaOnTheLastDayOfTheMonth();break;case"WL":case"LW":r=this.i18n.commaOnTheLastWeekdayOfTheMonth();break;default:var o=n.match(/(\d{1,2}W)|(W\d{1,2})/);if(o){var a=parseInt(o[0].replace("W","")),u=a==1?this.i18n.firstWeekday():i.StringUtilities.format(this.i18n.weekdayNearestDayX0(),a.toString());r=i.StringUtilities.format(this.i18n.commaOnTheX0OfTheMonth(),u);break}else{var s=n.match(/L-(\d{1,2})/);if(s){var h=s[1];r=i.StringUtilities.format(this.i18n.commaDaysBeforeTheLastDayOfTheMonth(h),h);break}else{if(n=="*"&&this.expressionParts[5]!="*")return"";r=this.getSegmentDescription(n,this.i18n.commaEveryDay(),function(c){return c=="L"?t.i18n.lastDay():t.i18n.dayX0?i.StringUtilities.format(t.i18n.dayX0(),c):c},function(c){return c=="1"?t.i18n.commaEveryDay():t.i18n.commaEveryX0Days(c)},function(c){return t.i18n.commaBetweenDayX0AndX1OfTheMonth(c)},function(c){return t.i18n.commaOnDayX0OfTheMonth(c)})}break}}return r},e.prototype.getYearDescription=function(){var t=this,r=this.getSegmentDescription(this.expressionParts[6],"",function(n){return/^\d+$/.test(n)?new Date(parseInt(n),1).getFullYear().toString():n},function(n){return i.StringUtilities.format(t.i18n.commaEveryX0Years(n),n)},function(n){return t.i18n.commaYearX0ThroughYearX1()||t.i18n.commaX0ThroughX1()},function(n){return t.i18n.commaOnlyInYearX0?t.i18n.commaOnlyInYearX0():t.i18n.commaOnlyInX0()});return r},e.prototype.getSegmentDescription=function(t,r,n,o,a,u){var s=null,h=t.indexOf("/")>-1,c=t.indexOf("-")>-1,d=t.indexOf(",")>-1;if(!t)s="";else if(t==="*")s=r;else if(!h&&!c&&!d)s=i.StringUtilities.format(u(t),n(t));else if(d){for(var f=t.split(","),O="",T=this.i18n.spaceAnd(),m=0;m<f.length;m++)if(m>0&&f.length>2&&(O+=",",m<f.length-1&&(O+=" ")),m>0&&f.length>1&&(m==f.length-1||f.length==2)&&(O+=T==","&&f.length>2?" ":"".concat(T," ")),f[m].indexOf("/")>-1||f[m].indexOf("-")>-1){var b=f[m].indexOf("-")>-1&&f[m].indexOf("/")==-1,E=this.getSegmentDescription(f[m],r,n,o,b?this.i18n.commaX0ThroughX1:a,u);b&&(E=E.replace(", ","")),O+=E}else if(!h)O+=n(f[m]);else{var X=this.getSegmentDescription(f[m],r,n,o,a,u);X&&X.startsWith(", ")&&(X=X.substring(2)),O+=X}h?s=O:s=i.StringUtilities.format(u(t),O)}else if(h){var f=t.split("/");if(s=i.StringUtilities.format(o(f[1]),f[1]),f[0].indexOf("-")>-1){var x=this.generateRangeSegmentDescription(f[0],a,n);x.indexOf(", ")!=0&&(s+=", "),s+=x}else if(f[0].indexOf("*")==-1){var S=i.StringUtilities.format(u(f[0]),n(f[0]));S=S.replace(", ",""),s+=i.StringUtilities.format(this.i18n.commaStartingX0(),S)}}else c&&(s=this.generateRangeSegmentDescription(t,a,n));return s},e.prototype.generateRangeSegmentDescription=function(t,r,n){var o="",a=t.split("-"),u=n(a[0],1),s=n(a[1],2),h=r(t);return o+=i.StringUtilities.format(h,u,s),o},e.prototype.formatTime=function(t,r,n){var o=0,a=0,u=parseInt(t)+o,s=parseInt(r)+a;s>=60?(s-=60,u+=1):s<0&&(s+=60,u-=1),u>=24?u=u-24:u<0&&(u=24+u);var h="",c=!1;this.options.use24HourTimeFormat||(c=!!(this.i18n.setPeriodBeforeTime&&this.i18n.setPeriodBeforeTime()),h=c?"".concat(this.getPeriod(u)," "):" ".concat(this.getPeriod(u)),u>12&&(u-=12),u===0&&(u=12));var d="";n&&(d=":".concat(("00"+n).substring(n.length)));var f=u.toString(),O=("00"+f).substring(f.length),T=s.toString(),m=("00"+T).substring(T.length),b=this.options.trimHoursLeadingZero?f:O;return"".concat(c?h:"").concat(b,":").concat(m).concat(d).concat(c?"":h)},e.prototype.transformVerbosity=function(t,r){if(!r&&(t=t.replace(new RegExp(", ".concat(this.i18n.everyMinute()),"g"),""),t=t.replace(new RegExp(", ".concat(this.i18n.everyHour()),"g"),""),t=t.replace(new RegExp(this.i18n.commaEveryDay(),"g"),""),t=t.replace(/\, ?$/,""),this.i18n.conciseVerbosityReplacements))for(var n=0,o=Object.entries(this.i18n.conciseVerbosityReplacements());n<o.length;n++){var a=o[n],u=a[0],s=a[1];t=t.replace(new RegExp(u,"g"),s)}return t},e.prototype.getPeriod=function(t){return t>=12?this.i18n.pm&&this.i18n.pm()||"PM":this.i18n.am&&this.i18n.am()||"AM"},e.locales={},e})();p.ExpressionDescriptor=l},747(g,p,v){Object.defineProperty(p,"__esModule",{value:!0}),p.enLocaleLoader=void 0;var i=v(486),y=(function(){function l(){}return l.prototype.load=function(e){e.en=new i.en},l})();p.enLocaleLoader=y},486(g,p){Object.defineProperty(p,"__esModule",{value:!0}),p.en=void 0;var v=(function(){function i(){}return i.prototype.atX0SecondsPastTheMinuteGt20=function(){return null},i.prototype.atX0MinutesPastTheHourGt20=function(){return null},i.prototype.commaMonthX0ThroughMonthX1=function(){return null},i.prototype.commaYearX0ThroughYearX1=function(){return null},i.prototype.use24HourTimeFormatByDefault=function(){return!1},i.prototype.anErrorOccuredWhenGeneratingTheExpressionD=function(){return"An error occurred when generating the expression description. Check the cron expression syntax."},i.prototype.everyMinute=function(){return"every minute"},i.prototype.everyHour=function(){return"every hour"},i.prototype.atSpace=function(){return"At "},i.prototype.everyMinuteBetweenX0AndX1=function(){return"Every minute between %s and %s"},i.prototype.at=function(){return"At"},i.prototype.spaceAnd=function(){return" and"},i.prototype.everySecond=function(){return"every second"},i.prototype.everyX0Seconds=function(){return"every %s seconds"},i.prototype.secondsX0ThroughX1PastTheMinute=function(){return"seconds %s through %s past the minute"},i.prototype.atX0SecondsPastTheMinute=function(){return"at %s seconds past the minute"},i.prototype.everyX0Minutes=function(){return"every %s minutes"},i.prototype.minutesX0ThroughX1PastTheHour=function(){return"minutes %s through %s past the hour"},i.prototype.atX0MinutesPastTheHour=function(){return"at %s minutes past the hour"},i.prototype.everyX0Hours=function(){return"every %s hours"},i.prototype.betweenX0AndX1=function(){return"between %s and %s"},i.prototype.atX0=function(){return"at %s"},i.prototype.commaEveryDay=function(){return", every day"},i.prototype.commaEveryX0DaysOfTheWeek=function(){return", every %s days of the week"},i.prototype.commaX0ThroughX1=function(){return", %s through %s"},i.prototype.commaAndX0ThroughX1=function(){return", %s through %s"},i.prototype.first=function(){return"first"},i.prototype.second=function(){return"second"},i.prototype.third=function(){return"third"},i.prototype.fourth=function(){return"fourth"},i.prototype.fifth=function(){return"fifth"},i.prototype.commaOnThe=function(){return", on the "},i.prototype.spaceX0OfTheMonth=function(){return" %s of the month"},i.prototype.lastDay=function(){return"the last day"},i.prototype.commaOnTheLastX0OfTheMonth=function(){return", on the last %s of the month"},i.prototype.commaOnlyOnX0=function(){return", only on %s"},i.prototype.commaAndOnX0=function(){return", and on %s"},i.prototype.commaEveryX0Months=function(){return", every %s months"},i.prototype.commaOnlyInX0=function(){return", only in %s"},i.prototype.commaOnTheLastDayOfTheMonth=function(){return", on the last day of the month"},i.prototype.commaOnTheLastWeekdayOfTheMonth=function(){return", on the last weekday of the month"},i.prototype.commaDaysBeforeTheLastDayOfTheMonth=function(){return", %s days before the last day of the month"},i.prototype.firstWeekday=function(){return"first weekday"},i.prototype.weekdayNearestDayX0=function(){return"weekday nearest day %s"},i.prototype.commaOnTheX0OfTheMonth=function(){return", on the %s of the month"},i.prototype.commaEveryX0Days=function(){return", every %s days in a month"},i.prototype.commaBetweenDayX0AndX1OfTheMonth=function(){return", between day %s and %s of the month"},i.prototype.commaOnDayX0OfTheMonth=function(){return", on day %s of the month"},i.prototype.commaEveryHour=function(){return", every hour"},i.prototype.commaEveryX0Years=function(){return", every %s years"},i.prototype.commaStartingX0=function(){return", starting %s"},i.prototype.daysOfTheWeek=function(){return["Sunday","Monday","Tuesday","Wednesday","Thursday","Friday","Saturday"]},i.prototype.monthsOfTheYear=function(){return["January","February","March","April","May","June","July","August","September","October","November","December"]},i.prototype.atReboot=function(){return"Run once, at startup"},i.prototype.onTheHour=function(){return"on the hour"},i})();p.en=v},515(g,p){Object.defineProperty(p,"__esModule",{value:!0});function v(y,l){if(!y)throw new Error(l)}var i=(function(){function y(){}return y.secondRange=function(l){for(var e=l.split(","),t=0;t<e.length;t++)if(!isNaN(parseInt(e[t],10))){var r=parseInt(e[t],10);v(r>=0&&r<=59,"seconds part must be >= 0 and <= 59")}},y.minuteRange=function(l){for(var e=l.split(","),t=0;t<e.length;t++)if(!isNaN(parseInt(e[t],10))){var r=parseInt(e[t],10);v(r>=0&&r<=59,"minutes part must be >= 0 and <= 59")}},y.hourRange=function(l){for(var e=l.split(","),t=0;t<e.length;t++)if(!isNaN(parseInt(e[t],10))){var r=parseInt(e[t],10);v(r>=0&&r<=23,"hours part must be >= 0 and <= 23")}},y.dayOfMonthRange=function(l){for(var e=l.split(","),t=0;t<e.length;t++)if(!isNaN(parseInt(e[t],10))){var r=parseInt(e[t],10);v(r>=1&&r<=31,"DOM part must be >= 1 and <= 31")}},y.monthRange=function(l,e){for(var t=l.split(","),r=0;r<t.length;r++)if(!isNaN(parseInt(t[r],10))){var n=parseInt(t[r],10);v(n>=1&&n<=12,e?"month part must be >= 0 and <= 11":"month part must be >= 1 and <= 12")}},y.dayOfWeekRange=function(l,e){for(var t=l.split(","),r=0;r<t.length;r++)if(!isNaN(parseInt(t[r],10))){var n=parseInt(t[r],10);v(n>=0&&n<=6,e?"DOW part must be >= 0 and <= 6":"DOW part must be >= 1 and <= 7")}},y})();p.default=i},823(g,p){Object.defineProperty(p,"__esModule",{value:!0}),p.StringUtilities=void 0;var v=(function(){function i(){}return i.format=function(y){for(var l=[],e=1;e<arguments.length;e++)l[e-1]=arguments[e];return y.replace(/%s/g,function(t){return l.shift()})},i.containsAny=function(y,l){return l.some(function(e){return y.indexOf(e)>-1})},i})();p.StringUtilities=v}},w={};function _(g){var p=w[g];if(p!==void 0)return p.exports;var v=w[g]={exports:{}};return D[g](v,v.exports,_),v.exports}var k={};return(()=>{var g=k;Object.defineProperty(g,"__esModule",{value:!0}),g.toString=void 0;var p=_(333),v=_(747);p.ExpressionDescriptor.initialize(new v.enLocaleLoader),g.default=p.ExpressionDescriptor;var i=p.ExpressionDescriptor.toString;g.toString=i})(),k})())})(M)),M.exports}var R=H();const F=U(R);export{F as c};
|
|
2
|
+
//# sourceMappingURL=cronstrue-n4qGUraE.js.map
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import{cb as r,e8 as l,V as i,di as u,cc as c,H as d}from"./index-
|
|
2
|
-
//# sourceMappingURL=deployments-
|
|
1
|
+
import{cb as r,e8 as l,V as i,di as u,cc as c,H as d}from"./index-Cr5hwh-C.js";function o(e,n=""){return`${d}/api/${e}/deployments${n}`}const y=50;function f(e){const{slug:n}=r();return l({queryKey:["deployments-feed",n,e?.resourceKind,e?.resourceId],queryFn:async({pageParam:t})=>{const a=new URLSearchParams({limit:String(y)});t!==null&&a.set("before_id",String(t)),e&&(a.set("resource_kind",e.resourceKind),a.set("resource_id",e.resourceId));const s=await i(o(n,`?${a.toString()}`),{credentials:"include"});return s.status===404?{items:[],has_more:!1}:(await u(s,"Failed to fetch deployments"),await s.json())},initialPageParam:null,getNextPageParam:t=>t.has_more?t.items[t.items.length-1]?.id:void 0,enabled:!!n,staleTime:15e3,retry:!1})}function h(e){const{slug:n}=r();return c({queryKey:["deployment-detail",n,e],queryFn:async()=>{const t=await i(o(n,`/${e}`),{credentials:"include"});return t.status===404?null:(await u(t,"Failed to fetch deployment"),await t.json())},enabled:!!n&&!!e,staleTime:15e3,retry:!1})}function g(e){const{slug:n}=r();return c({queryKey:["deployment-change-detail",n,e],queryFn:async()=>{const t=await i(o(n,`/changes/${e}`),{credentials:"include"});return t.status===404?null:(await u(t,"Failed to fetch change"),(await t.json()).change)},enabled:!!n&&!!e,staleTime:15e3,retry:!1})}export{g as a,h as b,f as u};
|
|
2
|
+
//# sourceMappingURL=deployments-RvUdVkj3.js.map
|
package/dist/owletto/dist/assets/{deployments-body-D6TAWs_6.js → deployments-body-BMp7UsMo.js}
RENAMED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import{j as a,bx as x,bK as p,aQ as m,
|
|
2
|
-
//# sourceMappingURL=deployments-body-
|
|
1
|
+
import{j as a,bx as x,bK as p,aQ as m,gW as c,B as f,bc as o,L as i,gX as h,M as r}from"./index-Cr5hwh-C.js";import{u as g}from"./deployments-RvUdVkj3.js";function y(e){return e==="partial_failure"?a.jsx(r,{variant:"destructive",children:"Partial failure"}):e==="succeeded"?a.jsx(r,{variant:"secondary",children:"Succeeded"}):null}function j(e){switch(e){case"created":return a.jsx(r,{variant:"default",children:"Created"});case"updated":return a.jsx(r,{variant:"secondary",children:"Updated"});case"deleted":return a.jsx(r,{variant:"destructive",children:"Deleted"});default:return null}}function N(e){if(!e)return null;const t=[e.create?`${e.create} created`:null,e.update?`${e.update} updated`:null,e.delete?`${e.delete} deleted`:null].filter(n=>n!==null);return t.length>0?t.join(" · "):"no changes"}const u="flex items-start gap-3 px-3 py-2.5 transition-colors hover:bg-accent/50";function B({owner:e}){const t=g(),n=t.data?.pages.flatMap(s=>s.items)??[];return t.isLoading?a.jsx("div",{className:"max-w-3xl",children:a.jsx(x,{label:"deployments"})}):t.isError?a.jsx(p,{label:"deployments"}):n.length===0?a.jsx(m,{icon:c,title:"No deployments yet",description:"lobu apply runs and settings edits will appear here as an audit trail."}):a.jsxs("div",{className:"max-w-3xl space-y-3",children:[a.jsx("div",{className:"overflow-hidden rounded-lg border",children:n.map((s,l)=>{const d=l===n.length-1;return s.type==="deployment"?a.jsx(b,{item:s,owner:e,isLast:d},s.id):a.jsx(v,{item:s,owner:e,isLast:d},s.id)})}),t.hasNextPage?a.jsx(f,{variant:"outline",size:"sm",className:"h-8 text-xs",disabled:t.isFetchingNextPage,onClick:()=>t.fetchNextPage(),children:t.isFetchingNextPage?"Loading...":"Load more"}):null]})}function b({item:e,owner:t,isLast:n}){const l=[N(e.counts),e.createdBy?`by ${e.createdBy}`:null,o(e.createdAt)].filter(Boolean).join(" · ");return a.jsxs(i,{to:"/$owner/connectors/deployments/$deploymentId",params:{owner:t,deploymentId:e.applyId??String(e.id)},className:`${u} ${n?"":"border-b"}`,children:[a.jsx(c,{className:"mt-0.5 h-4 w-4 shrink-0 text-muted-foreground"}),a.jsxs("div",{className:"min-w-0 flex-1",children:[a.jsxs("div",{className:"flex flex-wrap items-center gap-2",children:[a.jsx("span",{className:"truncate text-sm font-medium",children:"Deployment"}),y(e.status),e.gitSha?a.jsx("span",{className:"font-mono text-xs text-muted-foreground",children:e.gitSha.slice(0,7)}):null]}),a.jsx("p",{className:"truncate text-[11px] text-muted-foreground",children:l})]})]})}function v({item:e,owner:t,isLast:n}){const s=[e.actorSource?`via ${e.actorSource}`:null,e.createdBy?`by ${e.createdBy}`:null,o(e.createdAt)].filter(Boolean).join(" · ");return a.jsxs(i,{to:"/$owner/connectors/deployments/$deploymentId",params:{owner:t,deploymentId:`change-${e.id}`},className:`${u} ${n?"":"border-b"}`,children:[a.jsx(h,{className:"mt-0.5 h-4 w-4 shrink-0 text-muted-foreground"}),a.jsxs("div",{className:"min-w-0 flex-1",children:[a.jsxs("div",{className:"flex flex-wrap items-center gap-2",children:[a.jsxs("span",{className:"truncate text-sm font-medium",children:[e.resourceKind??"config",e.resourceId?a.jsxs("span",{className:"text-muted-foreground",children:[" ",e.resourceId]}):null]}),j(e.op)]}),a.jsx("p",{className:"truncate text-[11px] text-muted-foreground",children:s})]})]})}export{B as D,j as c,y as d};
|
|
2
|
+
//# sourceMappingURL=deployments-body-BMp7UsMo.js.map
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import{F as we,g as ye,r as c,G as be,j as e,I as je,B as R,H as ie}from"./index-_oPeVpL_.js";import{s as ke,g as Ce,u as Ne,a as Se,b as Ae,A as Re,W as _e}from"./oauth-workspace-access-PGyTnW2K.js";import{C as oe,a as re,b as ne,d as ce,c as P}from"./card-DIF8SF9b.js";import{w as ae}from"./workspace-label-o_QfBuCM.js";function q(t){return t.trim().toUpperCase()}const Le=15e3;async function Te(t){const n=new AbortController,j=window.setTimeout(()=>n.abort(),Le);try{const a=await fetch(`${ie}/oauth/device/info?user_code=${encodeURIComponent(t)}`,{credentials:"include",signal:n.signal}),x=await a.json().catch(()=>null);return{response:a,data:x}}catch(a){throw n.signal.aborted?new Error("Verification timed out. Check your connection and try again."):a}finally{window.clearTimeout(j)}}function F(t,n){return typeof t?.error_description=="string"&&t.error_description||typeof t?.error=="string"&&t.error||n}function ze(){const t=we.useSearch(),{session:n,isReady:j}=ye(),a=!j,[x,_]=c.useState(t.user_code||""),[r,m]=c.useState(null),[h,o]=c.useState(null),[i,le]=c.useState(null),[M,L]=c.useState(null),[T,D]=c.useState(null),[E,I]=c.useState(!1),[de,V]=c.useState(null),w=c.useRef(0),k=be(t.return_to),B=k?"app":"terminal",ue=!!t.user_code,N=q(x),d=M?.code===N?M:null,g=d!==null,C=d?.scopes??[],me=c.useMemo(()=>ke(C,T),[T,C]),$=C.some(s=>s.startsWith("mcp:")),G=C.includes("device_worker:run"),he=C.includes("connections:token"),Y=G||he,S=Ce(d?.resource),U=g&&$&&!S,J=d?.multiWorkspaceGrantsEnabled===!0,y=g&&G&&!S,{orgList:W,workspaceAccess:pe,setWorkspaceAccess:fe,selectedOrgIds:K,toggleSelectedOrgId:ge,resetWorkspaceSelection:ve,deviceHomeOrgId:z,orgsLoading:H,orgsError:A,retryOrgs:Q,workspaceSelectionReady:xe}=Ne({requireDeviceHome:y,deviceHomeOrgId:de,allowMultiple:J}),b=W.find(s=>s.id===z)??null,X=U?xe:!y||!H&&!A&&b!==null,O=c.useCallback(async s=>{const p=++w.current;m("verify"),o(null),I(!1);try{const{response:v,data:l}=await Te(s);if(p!==w.current)return;if(v.status===401){const f=new URL("/auth/login",window.location.origin);f.searchParams.set("callbackUrl",window.location.href),window.location.href=f.toString();return}if(!v.ok||!l)throw new Error(F(l,"Failed to verify device authorization code"));const u=Array.isArray(l.scopes)?l.scopes:[];L({code:s,clientName:l.client_name??null,scopes:u,resource:typeof l.resource=="string"?l.resource:null,multiWorkspaceGrantsEnabled:l.multi_workspace_grants_enabled===!0}),D(Se(u))}catch(v){if(p!==w.current)return;L(null),o(v instanceof Error?v.message:"Unexpected error")}finally{p===w.current&&m(null)}},[]);Ae(!!n,a),c.useEffect(()=>{if(!(a||!n||!t.user_code))return O(q(t.user_code)),()=>{w.current+=1}},[n,a,t.user_code,O]);const Z=async s=>{const p=N;if(!p){o(`Please enter the code shown in your ${B}.`);return}if(!g){o("Verify the device code before approving or denying access.");return}if(s&&Y&&!E){o("Confirm that you initiated this request and that the device code matches.");return}if(s&&!X){o(A?"Workspaces could not be loaded. Retry before approving.":y&&!b?"Choose a workspace for this device before approving.":"Choose at least one workspace before approving.");return}const v=d?.clientName??null,l=y&&b?ae(b):null;m(s?"approve":"deny"),o(null);try{const u=await fetch(`${ie}/oauth/device/approve`,{method:"POST",headers:{"Content-Type":"application/json"},credentials:"include",body:JSON.stringify({user_code:p,approved:s,...s?{scope:me.join(" ")}:{},...s&&U?{workspace_access:pe,organization_ids:K}:{},...s&&y&&b?{organization_id:b.id}:{}})}),f=await u.json().catch(()=>null);if(u.status===401){const te=new URL("/auth/login",window.location.origin);te.searchParams.set("callbackUrl",window.location.href),window.location.href=te.toString();return}if(!u.ok)throw new Error(F(f,"Failed to process device authorization"));const ee=s?"approved":"denied";if(f?.status!==ee)throw new Error(F(f,s?"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 f.user_code=="string"?q(f.user_code):null;if(se!==null&&se!==p)throw new Error("The server confirmed a different device code. Re-check the code shown on your device.");m(null),le({outcome:ee,code:p,clientName:v,deviceHomeLabel:l})}catch(u){m(null),o(u instanceof Error?u.message:"Unexpected error")}};return c.useEffect(()=>{if(i?.outcome!=="approved"||!k)return;const s=window.setTimeout(()=>{window.location.href=k},600);return()=>window.clearTimeout(s)},[i,k]),a||!n?e.jsx("main",{className:"min-h-[calc(100vh-3.5rem)] flex items-center justify-center p-4",children:e.jsx("p",{className:"text-sm text-muted-foreground",children:"Checking authentication..."})}):i?e.jsx("main",{className:"min-h-[calc(100vh-3.5rem)] flex items-center justify-center p-4",children:e.jsxs(oe,{className:"w-full max-w-lg",role:"status","aria-live":"polite",children:[e.jsxs(re,{children:[e.jsx(ne,{children:i.outcome==="approved"?ue?"Access Authorized":"Device Authorized":"Authorization Denied"}),e.jsx(ce,{children:i.outcome==="approved"?k?"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."})]}),i.outcome==="approved"&&i.deviceHomeLabel?e.jsxs(P,{className:"text-sm text-muted-foreground",children:["This device now lives in ",i.deviceHomeLabel,". Change its workspace or share its connections from the device page under Connectors."]}):null,e.jsx(P,{className:"text-sm",children:e.jsxs("dl",{className:"space-y-1",children:[e.jsx("dt",{className:"text-muted-foreground",children:i.outcome==="approved"?"Approved code":"Denied code"}),e.jsx("dd",{className:"font-mono text-base tracking-widest text-foreground",children:i.code}),i.clientName?e.jsxs(e.Fragment,{children:[e.jsx("dt",{className:"text-muted-foreground",children:"Requested by"}),e.jsx("dd",{className:"text-foreground",children:i.clientName})]}):null]})})]})}):e.jsx("main",{className:"min-h-[calc(100vh-3.5rem)] flex items-center justify-center p-4",children:e.jsxs(oe,{className:"w-full max-w-lg",children:[e.jsxs(re,{children:[e.jsx(ne,{asChild:!0,children:e.jsx("h1",{children:g?"Authorize application":"Connect a device"})}),e.jsx(ce,{children:g?"Review the application, access level, and workspaces.":`Enter the code shown in your ${B}.`})]}),e.jsxs(P,{className:"space-y-5","aria-busy":r!==null,children:[e.jsxs("div",{className:"space-y-2",children:[e.jsx("label",{htmlFor:"user-code",className:"text-sm font-medium",children:"Device code"}),e.jsx(je,{id:"user-code",value:x,disabled:r==="approve"||r==="deny",onChange:s=>{w.current+=1,_(s.target.value.toUpperCase()),L(null),D(null),ve(),V(null),I(!1),m(null),o(null)},placeholder:"ABCD-1234",className:"font-mono text-center text-lg tracking-widest",maxLength:9,autoFocus:!t.user_code})]}),y&&e.jsx(De,{deviceName:d?.clientName??null,orgList:W,deviceHomeOrgId:z,onChange:V,orgsLoading:H,orgsError:A,onRetry:Q,disabled:r!==null}),d&&e.jsx(Re,{idPrefix:"oauth-device",clientName:d.clientName,requestedScopes:d.scopes,accessLevel:T,onAccessLevelChange:D,sensitiveScopesAcknowledged:E,onSensitiveScopesAcknowledgedChange:I,disabled:r!==null}),U&&e.jsx(_e,{idPrefix:"oauth-device",allowMultiple:J,orgList:W,selectedOrgIds:K,onWorkspaceAccessChange:fe,onSelectedOrgChange:ge,orgsLoading:H,orgsError:A,onRetry:Q,disabled:r!==null,deviceHomeOrgId:z}),g&&$&&S&&e.jsxs("section",{className:"rounded-md border border-primary/20 bg-primary/5 p-3 text-sm space-y-1",children:[e.jsxs("p",{className:"font-medium text-foreground",children:["Workspace access: only ",S]}),e.jsx("p",{className:"text-muted-foreground",children:"This request is fixed to the workspace in the MCP resource URL."})]}),h&&e.jsx("p",{role:"alert",className:"rounded-md bg-destructive/10 px-3 py-2 text-sm text-destructive",children:h}),e.jsx("div",{className:"flex items-center justify-end gap-3",children:g?e.jsxs(e.Fragment,{children:[e.jsx(R,{type:"button",variant:"outline",onClick:()=>Z(!1),disabled:r!==null,children:r==="deny"?"Denying...":"Deny"}),e.jsx(R,{type:"button",onClick:()=>Z(!0),disabled:r!==null||!X||Y&&!E,children:r==="approve"?"Approving...":"Approve"})]}):e.jsx(R,{type:"button",onClick:()=>O(N),disabled:r!==null||!N,children:r==="verify"?"Verifying...":"Continue"})})]})]})})}function De({deviceName:t,orgList:n,deviceHomeOrgId:j,onChange:a,orgsLoading:x,orgsError:_,onRetry:r,disabled:m}){const h=n.find(o=>o.id===j)??null;return e.jsxs("section",{className:"space-y-2 rounded-md border border-primary/20 bg-primary/5 p-3 text-sm",children:[e.jsx("label",{htmlFor:"oauth-device-home",className:"block font-medium text-foreground",children:"Device workspace"}),x?e.jsx("p",{role:"status","aria-live":"polite",className:"text-muted-foreground",children:"Loading your workspaces..."}):_?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(R,{type:"button",variant:"outline",size:"sm",onClick:r,children:"Retry"})]}):e.jsxs(e.Fragment,{children:[e.jsxs("select",{id:"oauth-device-home",value:h?.id??"",disabled:m,onChange:o=>a(o.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:[h?null:e.jsx("option",{value:"",disabled:!0,children:"Choose a workspace"}),n.map(o=>e.jsx("option",{value:o.id,children:ae(o)},o.id))]}),h&&!h.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 ",h.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:"This applies to a newly paired device. A device that is already paired keeps its workspace; change it from the Devices page."})]})]})}export{ze as component};
|
|
2
|
-
//# sourceMappingURL=device-
|
|
1
|
+
import{F as we,g as ye,r as c,G as be,j as e,I as je,B as R,H as ie}from"./index-Cr5hwh-C.js";import{s as ke,g as Ce,u as Ne,a as Se,b as Ae,A as Re,W as _e}from"./oauth-workspace-access-BxsjwgdH.js";import{C as oe,a as re,b as ne,d as ce,c as P}from"./card-Djgp00r_.js";import{w as ae}from"./workspace-label-o_QfBuCM.js";function q(t){return t.trim().toUpperCase()}const Le=15e3;async function Te(t){const n=new AbortController,j=window.setTimeout(()=>n.abort(),Le);try{const a=await fetch(`${ie}/oauth/device/info?user_code=${encodeURIComponent(t)}`,{credentials:"include",signal:n.signal}),x=await a.json().catch(()=>null);return{response:a,data:x}}catch(a){throw n.signal.aborted?new Error("Verification timed out. Check your connection and try again."):a}finally{window.clearTimeout(j)}}function F(t,n){return typeof t?.error_description=="string"&&t.error_description||typeof t?.error=="string"&&t.error||n}function ze(){const t=we.useSearch(),{session:n,isReady:j}=ye(),a=!j,[x,_]=c.useState(t.user_code||""),[r,m]=c.useState(null),[h,o]=c.useState(null),[i,le]=c.useState(null),[M,L]=c.useState(null),[T,D]=c.useState(null),[E,I]=c.useState(!1),[de,V]=c.useState(null),w=c.useRef(0),k=be(t.return_to),B=k?"app":"terminal",ue=!!t.user_code,N=q(x),d=M?.code===N?M:null,g=d!==null,C=d?.scopes??[],me=c.useMemo(()=>ke(C,T),[T,C]),$=C.some(s=>s.startsWith("mcp:")),G=C.includes("device_worker:run"),he=C.includes("connections:token"),Y=G||he,S=Ce(d?.resource),U=g&&$&&!S,J=d?.multiWorkspaceGrantsEnabled===!0,y=g&&G&&!S,{orgList:W,workspaceAccess:pe,setWorkspaceAccess:fe,selectedOrgIds:K,toggleSelectedOrgId:ge,resetWorkspaceSelection:ve,deviceHomeOrgId:z,orgsLoading:H,orgsError:A,retryOrgs:Q,workspaceSelectionReady:xe}=Ne({requireDeviceHome:y,deviceHomeOrgId:de,allowMultiple:J}),b=W.find(s=>s.id===z)??null,X=U?xe:!y||!H&&!A&&b!==null,O=c.useCallback(async s=>{const p=++w.current;m("verify"),o(null),I(!1);try{const{response:v,data:l}=await Te(s);if(p!==w.current)return;if(v.status===401){const f=new URL("/auth/login",window.location.origin);f.searchParams.set("callbackUrl",window.location.href),window.location.href=f.toString();return}if(!v.ok||!l)throw new Error(F(l,"Failed to verify device authorization code"));const u=Array.isArray(l.scopes)?l.scopes:[];L({code:s,clientName:l.client_name??null,scopes:u,resource:typeof l.resource=="string"?l.resource:null,multiWorkspaceGrantsEnabled:l.multi_workspace_grants_enabled===!0}),D(Se(u))}catch(v){if(p!==w.current)return;L(null),o(v instanceof Error?v.message:"Unexpected error")}finally{p===w.current&&m(null)}},[]);Ae(!!n,a),c.useEffect(()=>{if(!(a||!n||!t.user_code))return O(q(t.user_code)),()=>{w.current+=1}},[n,a,t.user_code,O]);const Z=async s=>{const p=N;if(!p){o(`Please enter the code shown in your ${B}.`);return}if(!g){o("Verify the device code before approving or denying access.");return}if(s&&Y&&!E){o("Confirm that you initiated this request and that the device code matches.");return}if(s&&!X){o(A?"Workspaces could not be loaded. Retry before approving.":y&&!b?"Choose a workspace for this device before approving.":"Choose at least one workspace before approving.");return}const v=d?.clientName??null,l=y&&b?ae(b):null;m(s?"approve":"deny"),o(null);try{const u=await fetch(`${ie}/oauth/device/approve`,{method:"POST",headers:{"Content-Type":"application/json"},credentials:"include",body:JSON.stringify({user_code:p,approved:s,...s?{scope:me.join(" ")}:{},...s&&U?{workspace_access:pe,organization_ids:K}:{},...s&&y&&b?{organization_id:b.id}:{}})}),f=await u.json().catch(()=>null);if(u.status===401){const te=new URL("/auth/login",window.location.origin);te.searchParams.set("callbackUrl",window.location.href),window.location.href=te.toString();return}if(!u.ok)throw new Error(F(f,"Failed to process device authorization"));const ee=s?"approved":"denied";if(f?.status!==ee)throw new Error(F(f,s?"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 f.user_code=="string"?q(f.user_code):null;if(se!==null&&se!==p)throw new Error("The server confirmed a different device code. Re-check the code shown on your device.");m(null),le({outcome:ee,code:p,clientName:v,deviceHomeLabel:l})}catch(u){m(null),o(u instanceof Error?u.message:"Unexpected error")}};return c.useEffect(()=>{if(i?.outcome!=="approved"||!k)return;const s=window.setTimeout(()=>{window.location.href=k},600);return()=>window.clearTimeout(s)},[i,k]),a||!n?e.jsx("main",{className:"min-h-[calc(100vh-3.5rem)] flex items-center justify-center p-4",children:e.jsx("p",{className:"text-sm text-muted-foreground",children:"Checking authentication..."})}):i?e.jsx("main",{className:"min-h-[calc(100vh-3.5rem)] flex items-center justify-center p-4",children:e.jsxs(oe,{className:"w-full max-w-lg",role:"status","aria-live":"polite",children:[e.jsxs(re,{children:[e.jsx(ne,{children:i.outcome==="approved"?ue?"Access Authorized":"Device Authorized":"Authorization Denied"}),e.jsx(ce,{children:i.outcome==="approved"?k?"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."})]}),i.outcome==="approved"&&i.deviceHomeLabel?e.jsxs(P,{className:"text-sm text-muted-foreground",children:["This device now lives in ",i.deviceHomeLabel,". Change its workspace or share its connections from the device page under Connectors."]}):null,e.jsx(P,{className:"text-sm",children:e.jsxs("dl",{className:"space-y-1",children:[e.jsx("dt",{className:"text-muted-foreground",children:i.outcome==="approved"?"Approved code":"Denied code"}),e.jsx("dd",{className:"font-mono text-base tracking-widest text-foreground",children:i.code}),i.clientName?e.jsxs(e.Fragment,{children:[e.jsx("dt",{className:"text-muted-foreground",children:"Requested by"}),e.jsx("dd",{className:"text-foreground",children:i.clientName})]}):null]})})]})}):e.jsx("main",{className:"min-h-[calc(100vh-3.5rem)] flex items-center justify-center p-4",children:e.jsxs(oe,{className:"w-full max-w-lg",children:[e.jsxs(re,{children:[e.jsx(ne,{asChild:!0,children:e.jsx("h1",{children:g?"Authorize application":"Connect a device"})}),e.jsx(ce,{children:g?"Review the application, access level, and workspaces.":`Enter the code shown in your ${B}.`})]}),e.jsxs(P,{className:"space-y-5","aria-busy":r!==null,children:[e.jsxs("div",{className:"space-y-2",children:[e.jsx("label",{htmlFor:"user-code",className:"text-sm font-medium",children:"Device code"}),e.jsx(je,{id:"user-code",value:x,disabled:r==="approve"||r==="deny",onChange:s=>{w.current+=1,_(s.target.value.toUpperCase()),L(null),D(null),ve(),V(null),I(!1),m(null),o(null)},placeholder:"ABCD-1234",className:"font-mono text-center text-lg tracking-widest",maxLength:9,autoFocus:!t.user_code})]}),y&&e.jsx(De,{deviceName:d?.clientName??null,orgList:W,deviceHomeOrgId:z,onChange:V,orgsLoading:H,orgsError:A,onRetry:Q,disabled:r!==null}),d&&e.jsx(Re,{idPrefix:"oauth-device",clientName:d.clientName,requestedScopes:d.scopes,accessLevel:T,onAccessLevelChange:D,sensitiveScopesAcknowledged:E,onSensitiveScopesAcknowledgedChange:I,disabled:r!==null}),U&&e.jsx(_e,{idPrefix:"oauth-device",allowMultiple:J,orgList:W,selectedOrgIds:K,onWorkspaceAccessChange:fe,onSelectedOrgChange:ge,orgsLoading:H,orgsError:A,onRetry:Q,disabled:r!==null,deviceHomeOrgId:z}),g&&$&&S&&e.jsxs("section",{className:"rounded-md border border-primary/20 bg-primary/5 p-3 text-sm space-y-1",children:[e.jsxs("p",{className:"font-medium text-foreground",children:["Workspace access: only ",S]}),e.jsx("p",{className:"text-muted-foreground",children:"This request is fixed to the workspace in the MCP resource URL."})]}),h&&e.jsx("p",{role:"alert",className:"rounded-md bg-destructive/10 px-3 py-2 text-sm text-destructive",children:h}),e.jsx("div",{className:"flex items-center justify-end gap-3",children:g?e.jsxs(e.Fragment,{children:[e.jsx(R,{type:"button",variant:"outline",onClick:()=>Z(!1),disabled:r!==null,children:r==="deny"?"Denying...":"Deny"}),e.jsx(R,{type:"button",onClick:()=>Z(!0),disabled:r!==null||!X||Y&&!E,children:r==="approve"?"Approving...":"Approve"})]}):e.jsx(R,{type:"button",onClick:()=>O(N),disabled:r!==null||!N,children:r==="verify"?"Verifying...":"Continue"})})]})]})})}function De({deviceName:t,orgList:n,deviceHomeOrgId:j,onChange:a,orgsLoading:x,orgsError:_,onRetry:r,disabled:m}){const h=n.find(o=>o.id===j)??null;return e.jsxs("section",{className:"space-y-2 rounded-md border border-primary/20 bg-primary/5 p-3 text-sm",children:[e.jsx("label",{htmlFor:"oauth-device-home",className:"block font-medium text-foreground",children:"Device workspace"}),x?e.jsx("p",{role:"status","aria-live":"polite",className:"text-muted-foreground",children:"Loading your workspaces..."}):_?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(R,{type:"button",variant:"outline",size:"sm",onClick:r,children:"Retry"})]}):e.jsxs(e.Fragment,{children:[e.jsxs("select",{id:"oauth-device-home",value:h?.id??"",disabled:m,onChange:o=>a(o.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:[h?null:e.jsx("option",{value:"",disabled:!0,children:"Choose a workspace"}),n.map(o=>e.jsx("option",{value:o.id,children:ae(o)},o.id))]}),h&&!h.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 ",h.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:"This applies to a newly paired device. A device that is already paired keeps its workspace; change it from the Devices page."})]})]})}export{ze as component};
|
|
2
|
+
//# sourceMappingURL=device-CPU6CjkJ.js.map
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import{j as e,ex as f,r as y,
|
|
2
|
-
//# sourceMappingURL=device-pin-tombstone-
|
|
1
|
+
import{j as e,ex as f,r as y,hZ as C,h_ as k,hi as g,B as A,L as w,cy as E,h$ as I,i0 as L,i1 as N,u as P,i2 as F,hw as O}from"./index-Cr5hwh-C.js";import{a as R,R as S}from"./runs-panel-Du1JMjg5.js";import{c as v,C as $,a as b}from"./connector-scope-lists-CadPVsI3.js";function M({formRows:s=5}){return e.jsxs("div",{className:"grid gap-6 xl:grid-cols-[minmax(0,1fr)_360px]",children:[e.jsx(R,{}),e.jsx(f,{rows:s})]})}function V({connection:s,connectorDef:t,ownerSlug:a,openSettings:n=!1,authResult:o,showActivity:r=!0,embedded:i=!1,showShare:c=!0}){const[l,d]=y.useState(n);y.useEffect(()=>{n&&d(!0)},[n]);const m=s.id,h=s.connector_key,u=s.facets?.chat??!1,p=u?"Channels":"Feeds",x=s.has_operations===!0,_=s.feed_count>0||v(t),j=e.jsx(N,{connection:s,connectorDef:t,ownerSlug:a,showShare:c});return e.jsxs("div",{className:"space-y-6",children:[o&&e.jsx(C,{result:o}),s.auth_profile_kind==="oauth_account"&&e.jsx(k,{connection:s,connectorDef:t,onReview:()=>{d(!0),requestAnimationFrame(()=>document.getElementById("connection-auth")?.scrollIntoView({block:"nearest"}))}}),(_||x)&&e.jsxs("div",{className:i?"space-y-6":"grid grid-cols-1 items-start gap-3 sm:grid-cols-2",children:[_&&(i?e.jsx(g,{title:p,count:s.feed_count===1?"1 source":`${s.feed_count} sources`,action:v(t)?e.jsx(A,{asChild:!0,size:"sm",variant:"outline",children:e.jsxs(w,{to:"/$owner/connectors/$connectorKey/$connectionId",params:{owner:a,connectorKey:h,connectionId:String(m)},search:{addFeed:!0},children:[e.jsx(E,{className:"h-3.5 w-3.5"}),u?"Add channel":"Add source"]})}):null,children:e.jsx($,{connection:s,ownerSlug:a,connectorKey:h,connectorDef:t})}):e.jsx(b,{connection:s,ownerSlug:a,title:p})),x&&(i?e.jsx(I,{connection:s,ownerSlug:a}):e.jsx(B,{connection:s,ownerSlug:a}))]}),i?e.jsx(L,{title:"Connection settings",summary:"name, visibility, credentials, remove",open:l,onOpenChange:d,children:j}):j,r&&!u&&e.jsx(g,{title:"Recent activity",children:e.jsx(S,{scope:{connectionId:m},ownerSlug:a})})]})}function B({connection:s,ownerSlug:t}){const a=P(),{data:n=[],isLoading:o,isError:r}=F(s.id),i=n.filter(l=>l.readiness==="scope_upgrade_required").length,c=o?"Loading actions…":r?"Could not load actions — open to retry":`${n.length} actions${i?` · ${i} need additional provider access`:" · permissions and approval policy"}`;return e.jsx(O,{title:"Actions",summary:c,onOpen:()=>a?.open({href:"",title:"Actions",connectorPanel:{section:"actions",connectionId:s.id,connectorKey:s.connector_key,organizationId:s.organization_id,ownerSlug:t}})})}const T=new Set(["Device was removed","Device was moved to another workspace"]);function H(s){const t=s.error_message??null;return!t||!T.has(t)?t:!!s.device_worker_id&&(s.device_last_seen_at!=null||s.device_worker_handle!=null||s.device_label!=null)?null:t}export{V as C,M as R,H as c};
|
|
2
|
+
//# sourceMappingURL=device-pin-tombstone-CrjG7gPo.js.map
|
package/dist/owletto/dist/assets/{device._deviceId-D4plO3GM.js → device._deviceId-Cs3ZmXWo.js}
RENAMED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import{aI as U,hO as ne,hP as V,r as v,j as e,hQ as L,B as b,a1 as z,hR as C,cN as Y,au as te,hl as I,S as R,aU as T,dO as ae,dP as ce,dj as ie,dQ as oe,hS as re,T as le,m as de,az as me,hT as ue,hU as xe,hV as he,aA as pe,av as fe,aB as P,aT as O,L as E,hW as ge,hX as je,aO as ve,hY as ye,hZ as be,h3 as Ne,b7 as _e,fL as ke,h_ as q,I as we,a_ as Ce,b8 as Se,fM as $e,fN as K,bc as De,h$ as W,ah as Pe}from"./index-_oPeVpL_.js";import{c as Q,C as Le,R as ze}from"./device-pin-tombstone-Bz4JHHMK.js";import{R as Ie}from"./runs-panel-BO3h5RkS.js";import{S as Re,g as Ae}from"./runs-table-DxIiqrSk.js";import{c as Ee}from"./connection-label-BobuYiAG.js";import{w as M}from"./workspace-label-o_QfBuCM.js";import"./connector-scope-lists-BKDetNDc.js";import"./status-dot-C5KDvvm9.js";import"./runs-BWtc5rmc.js";import"./filter-editors-DCQgGLyR.js";function Me(s,n,o){const h=new Set(s.capabilities??[]),m=new Set(s.connectors.filter(t=>t.organization_slug===o).map(t=>t.connector_key)),r=new Set(G(s,o).map(t=>t.connector_key));return n.filter(t=>U(t)&&!!t.required_capability&&h.has(t.required_capability)&&!m.has(t.key)&&!r.has(t.key))}function G(s,n){return s.organization_slug===n?s.update_required:[]}function Te(s,n,o){const h=s.organization_slug;if(!h||h===o)return[];const m=new Set(n.map(t=>t.key)),r=new Set(s.connectors.filter(t=>t.organization_slug===o).map(t=>t.connector_key));return s.connectors.filter(t=>t.organization_slug!==h||m.has(t.connector_key)||r.has(t.connector_key)?!1:(r.add(t.connector_key),!0))}function Be({device:s,organizationId:n,ownerSlug:o,connectable:h,unavailable:m}){const r=ne(),t=V(),[u,p]=v.useState(null),[g,a]=v.useState(null),[f,N]=v.useState(null),[j,d]=v.useState([]),x=s.organization_id===n,y=async c=>{p(null),N(null),a(c.key);try{x||await t.mutateAsync({deviceWorkerId:s.id,organizationId:n});const w=await r.mutateAsync({connector_key:c.key,device_worker_id:s.id}),S=w.connection_id??w.connection?.id;if(S===void 0)throw new Error(w.instructions??"The connection was not created.");d($=>[...$.filter(D=>D.connectorKey!==c.key),{connectorKey:c.key,name:c.name,connectionId:S,instructions:w.status==="setup_required"?w.instructions:void 0}])}catch(w){N({key:c.key,message:w instanceof Error?w.message:"Could not connect."})}finally{a(null)}},_=new Set(j.map(c=>c.connectorKey)),l=G(s,o),i=h.filter(c=>!_.has(c.key));return e.jsxs("div",{className:"mt-4 space-y-3",children:[j.map(c=>e.jsx(Oe,{outcome:c,device:s,organizationId:n},c.connectorKey)),i.length>0?e.jsxs("div",{children:[e.jsx("p",{className:"text-xs font-medium",children:"Supported by this device"}),e.jsxs("p",{className:"mb-2 text-xs text-muted-foreground",children:["Not connected in this workspace yet.",x?null:" Connecting one moves the device here; you will be asked to confirm first."]}),e.jsx("div",{className:"divide-y border-y",children:i.map(c=>e.jsxs("div",{className:"space-y-2 py-3",children:[e.jsxs("div",{className:"flex items-center gap-3",children:[e.jsxs("span",{className:"min-w-0 flex-1 text-sm font-medium",children:[c.name,c.required_capability&&L[c.required_capability]&&L[c.required_capability]!==c.name?e.jsx("span",{className:"ml-2 text-xs font-normal text-muted-foreground",children:L[c.required_capability]}):null]}),e.jsxs(b,{size:"sm",variant:"outline","aria-label":`Connect ${c.name}`,disabled:g!==null,onClick:()=>x?void y(c):p(c.key),children:[g===c.key?e.jsx(z,{className:"mr-1.5"}):null,"Connect"]})]}),u===c.key?e.jsx(X,{device:s,ownerSlug:o,title:"Move device to this workspace",intro:`${C(s)} lives in ${s.organization_name??"another workspace"}. A device serves one workspace at a time, so it has to move here before it can be connected.`,confirmLabel:"Move here and connect",onConfirm:()=>void y(c),onCancel:()=>p(null)}):null,f?.key===c.key?e.jsx("p",{role:"alert",className:"text-sm text-destructive",children:f.message}):null]},c.key))})]}):null,l.length>0?e.jsxs("div",{role:"status",children:[e.jsx("p",{className:"text-xs font-medium",children:"Update Lobu on this device"}),e.jsx("ul",{className:"mt-1 space-y-1 text-xs text-muted-foreground",children:l.map(c=>e.jsx("li",{children:`${c.display_name} — this device has ${c.device_version}, this workspace uses ${c.workspace_version}`},c.connector_key))})]}):null,m.length>0?e.jsx("ul",{className:"space-y-1 text-xs text-muted-foreground",children:m.map(c=>e.jsx("li",{children:`${c.display_name} — set up on this device in ${s.organization_name??"its home workspace"}, not available in this workspace yet`},c.connector_key))}):null]})}function X({device:s,ownerSlug:n,title:o,intro:h,aftermath:m,confirmLabel:r,pending:t=!1,onConfirm:u,onCancel:p}){const g=s.connector_count,a=s.connectors.filter(f=>f.organization_slug===n).length;return e.jsxs("div",{role:"alertdialog","aria-label":o,className:"space-y-2 rounded-lg bg-amber-500/10 px-3 py-2 text-xs",children:[e.jsx("p",{children:h}),e.jsxs("p",{className:"text-muted-foreground",children:[g>0?`Moving pauses and unpins all ${g} connection${g===1?"":"s"} pinned to it${a>0?`, including ${a} in this workspace`:""}. They stay paused until you reconnect them.`:"It has no pinned connections, so nothing is paused.",m?` ${m}`:null]}),e.jsxs("div",{className:"flex gap-2",children:[e.jsxs(b,{size:"sm",disabled:t,onClick:u,children:[t?e.jsx(z,{className:"mr-1.5"}):null,r]}),e.jsx(b,{size:"sm",variant:"ghost",disabled:t,onClick:p,children:"Cancel"})]})]})}function Oe({outcome:s,device:n,organizationId:o}){const{data:h=[],isLoading:m}=Y(o,{connectionIds:[s.connectionId]}),r=h.find(p=>p.id===s.connectionId),t=C(n);if(m)return e.jsxs("p",{role:"status",className:"text-sm text-muted-foreground",children:["Checking ",s.name,"…"]});const u=[];if(!r)u.push(`${s.name} was created but could not be loaded yet.`);else if(r.status!=="active"){const p=Q(r);u.push(`${s.name} is ${r.status}${p?`: ${p}`:"."}`)}return s.instructions&&u.push(s.instructions),n.online||u.push(`${t} is offline. ${s.name} runs once it reconnects.`),e.jsx("div",{role:"status",className:"rounded-lg border px-3 py-2 text-sm",children:u.length===0?e.jsxs("p",{children:[s.name," is ready on ",t,"."]}):e.jsxs(e.Fragment,{children:[e.jsxs("p",{className:"font-medium",children:[s.name," connected, not ready yet"]}),e.jsx("ul",{className:"mt-1 list-disc pl-4 text-xs text-muted-foreground",children:u.map(p=>e.jsx("li",{children:p},p))})]})})}function H({device:s,organizationId:n,ownerSlug:o,selectedConnection:h,openSettings:m}){const{data:r=[],isLoading:t,isError:u,refetch:p}=te(n),g=new Map(r.map(d=>[d.key,d])),a=new Map,f=[];for(const d of s.connectors){if(d.organization_slug!==o)continue;const x=g.get(d.connector_key);if(!x||!U(x)){f.push(d);continue}const y=x.required_capability??`connector:${x.key}`,_=a.get(y)??{key:y,name:x.name,connections:[]};_.name=L[y]??x.name,_.connections.push(d),a.set(y,_)}const N=Me(s,r,o),j=Te(s,r,o);return e.jsxs(e.Fragment,{children:[e.jsxs(I,{title:"Capabilities",children:[e.jsx("p",{className:"mb-3 text-xs text-muted-foreground",children:"Manage the native connections available to this workspace."}),s.online?null:e.jsx("p",{className:"mb-3 text-sm text-muted-foreground",children:"This device is offline. You can edit its settings; actions and sync need it to reconnect."}),!n||t?e.jsx(R,{className:"h-24 w-full"}):u?e.jsxs("div",{role:"alert",className:"space-y-2 text-sm",children:[e.jsx("p",{children:"Could not load capability settings."}),e.jsx(b,{variant:"outline",size:"sm",onClick:()=>void p(),children:"Retry"})]}):a.size===0?e.jsx("p",{className:"text-sm text-muted-foreground",children:"No native connections on this device in this workspace."}):e.jsx("div",{className:"divide-y border-y",children:[...a.values()].map(d=>e.jsx(F,{group:d,deviceId:s.id,organizationId:n,ownerSlug:o,definitionsByKey:g,selectedConnection:h,openSettings:m},d.key))}),n&&!t&&!u?e.jsx(Be,{device:s,organizationId:n,ownerSlug:o,connectable:N,unavailable:j}):null,T(s)==="macos"?e.jsx("p",{className:"mt-3 text-xs text-muted-foreground",children:"Manage macOS permissions in the Lobu app on this device."}):null]}),n&&f.length>0&&!t&&!u?e.jsxs(I,{title:"Apps and sources",count:String(f.length),children:[e.jsx("p",{className:"mb-3 text-xs text-muted-foreground",children:"Apps and sources that use this device."}),e.jsx("div",{className:"divide-y border-y",children:[...new Set(f.map(d=>d.connector_key))].map(d=>e.jsx(F,{group:{key:d,name:g.get(d)?.name??d,connections:f.filter(x=>x.connector_key===d)},deviceId:s.id,organizationId:n,ownerSlug:o,definitionsByKey:g,selectedConnection:h,openSettings:m},d))})]}):null]})}function F({group:s,deviceId:n,organizationId:o,ownerSlug:h,definitionsByKey:m,selectedConnection:r,openSettings:t}){const u=s.connections.some(a=>a.connection_id===r),[p,g]=v.useState(u);return v.useEffect(()=>{u&&r!==void 0&&g(!0)},[u,r]),e.jsxs(ae,{open:p,onOpenChange:g,children:[e.jsxs(ce,{className:"group flex w-full items-center gap-3 py-3 text-left",children:[e.jsx(ie,{className:"size-3.5 shrink-0 text-muted-foreground transition-transform group-data-[state=open]:rotate-90"}),e.jsx("span",{className:"min-w-0 flex-1 text-sm font-medium",children:s.name}),e.jsx("span",{className:"text-right text-xs text-muted-foreground",children:s.connections.some(a=>a.status==="error"||a.status==="revoked")?"Needs attention":s.connections.length>1?`${s.connections.length} connections`:"Configured"})]}),e.jsx(oe,{className:"pb-4 pl-6",children:e.jsx("div",{className:"space-y-5",children:s.connections.map(a=>e.jsx(qe,{summary:a,deviceId:n,organizationId:o,ownerSlug:h,connectorDef:m.get(a.connector_key),openSettings:a.connection_id===r&&t},a.connection_id))})})]})}function qe({summary:s,deviceId:n,organizationId:o,ownerSlug:h,connectorDef:m,openSettings:r}){const{data:t=[],isLoading:u,isError:p,refetch:g}=Y(o,{connectionIds:[s.connection_id]}),a=t.find(j=>j.id===s.connection_id&&j.device_worker_id===n),f=m?.name??s.connector_key,N=a?Q(a):null;return e.jsxs("section",{id:`connection-${s.connection_id}`,"aria-label":f,className:"scroll-mt-24",children:[a?e.jsxs("div",{className:"mb-3 flex items-baseline justify-between gap-3 text-xs text-muted-foreground",children:[e.jsx("span",{children:Ee(a)}),e.jsx("span",{children:a.status})]}):null,u||!o?e.jsx(R,{className:"h-24 w-full"}):p?e.jsxs("div",{role:"alert",className:"space-y-2 text-sm",children:[e.jsx("p",{children:"Could not load this connection."}),e.jsx(b,{variant:"outline",size:"sm",onClick:()=>void g(),children:"Retry"})]}):a?e.jsxs(e.Fragment,{children:[N?e.jsx("p",{role:"alert",className:"mb-4 text-sm text-destructive",children:N}):null,e.jsx("div",{className:"mb-4",children:e.jsx(re,{connection:a})}),e.jsx(Le,{connection:a,connectorDef:m,ownerSlug:h,openSettings:r,showActivity:!1,showShare:!1,embedded:!0})]}):e.jsx("p",{className:"text-sm text-muted-foreground",children:"This connection is no longer available on this device."})]})}function Ke({device:s,ownerSlug:n}){const o=v.useId(),{data:h=[]}=le(),m=V(),[r,t]=v.useState(!1),[u,p]=v.useState(null),[g,a]=v.useState(null),f=h.filter(l=>l.is_member).map(l=>({id:l.id,name:l.name,isPersonal:l.is_personal===!0})),N=f.find(l=>l.id===s.organization_id),j=N?M(N):s.organization_name??"No workspace",d=f.filter(l=>l.id!==s.organization_id),x=d.find(l=>l.id===u)??null,y=()=>{t(!1),p(null)},_=async l=>{a(null);try{await m.mutateAsync({deviceWorkerId:s.id,organizationId:l}),y()}catch(i){a(i instanceof Error?i.message:"Could not move the device.")}};return e.jsxs("div",{className:"space-y-2 text-sm",children:[e.jsxs("div",{className:"flex flex-wrap items-center gap-3",children:[e.jsxs("p",{children:[e.jsx("span",{className:"text-muted-foreground",children:"Workspace: "}),j]}),!r&&d.length>0?e.jsx(b,{size:"sm",variant:"outline",onClick:()=>{a(null),t(!0)},children:"Change workspace"}):null]}),r?e.jsxs("div",{className:"flex flex-wrap items-center gap-2",children:[e.jsx("label",{htmlFor:o,className:"text-xs text-muted-foreground",children:"Move to"}),e.jsxs("select",{id:o,value:u??"",disabled:m.isPending,onChange:l=>p(l.target.value||null),className:"h-8 rounded-md border border-input bg-background px-2 text-sm",children:[e.jsx("option",{value:"",children:"Choose a workspace"}),d.map(l=>e.jsx("option",{value:l.id,children:M(l)},l.id))]}),x?null:e.jsx(b,{size:"sm",variant:"ghost",onClick:y,children:"Cancel"})]}):null,x?e.jsx(X,{device:s,ownerSlug:n,title:`Move device to ${x.name}`,intro:`Move ${C(s)} from ${j} to ${M(x)}?`,aftermath:`It is set up fresh in ${x.name}, with its connections there private to you until you share them.`,confirmLabel:"Move device",pending:m.isPending,onConfirm:()=>void _(x.id),onCancel:y}):null,g?e.jsx("p",{role:"alert",className:"text-sm text-destructive",children:g}):null]})}function We({ownerSlug:s,deviceId:n,organizationId:o,selectedConnection:h,openSettings:m}){const r=de(),{data:t=[],isLoading:u,isError:p,refetch:g}=me(),a=ue(),f=xe(),[N,j]=v.useState(!1),[d,x]=v.useState(!1),[y,_]=v.useState(""),l=he(t,n),i=l&&pe(l,s)?l:void 0,c=i?.id??n,{data:w=[]}=fe(o,{profileKind:"browser_session"}),S=v.useMemo(()=>w.filter(k=>k.device_worker_id===c&&k.status!=="revoked"),[w,c]),$=i?.label?.trim()??"";if(v.useEffect(()=>{d||_($)},[$,d]),u)return e.jsxs(P,{className:"space-y-4",children:[e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(R,{className:"h-6 w-6 rounded"}),e.jsx(R,{className:"h-5 w-40"})]}),e.jsx(ze,{})]});if(p)return e.jsx(P,{children:e.jsxs("div",{role:"alert",className:"space-y-2",children:[e.jsx("p",{children:"Could not load this device."}),e.jsx(b,{variant:"outline",size:"sm",onClick:()=>void g(),children:"Retry"})]})});if(!i&&l&&o)return e.jsxs(P,{className:"space-y-4",children:[e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(O,{platform:T(l),className:"h-5 w-5"}),e.jsx("h1",{className:"text-base font-semibold",children:C(l)})]}),e.jsxs("p",{className:"text-sm text-muted-foreground",children:["This device lives in"," ",l.organization_name??"another workspace",", not this workspace."]}),e.jsx(H,{device:l,organizationId:o,ownerSlug:s})]});if(!i)return e.jsxs(P,{className:"space-y-3",children:[e.jsx("p",{className:"text-sm text-muted-foreground",children:"This device isn't in this workspace, so its details aren't available."}),e.jsx(E,{to:"/$owner/connectors",params:{owner:s},search:{},className:"text-sm text-primary hover:underline",children:"Back to connectors"})]});const D=ge(i),A=D?je(s,D,ve()):void 0,Z=T(i),J=ye(i.app_version),ee=be(i,J),B=()=>{const k=y.trim(),se=i.label?.trim()??"";if(k===se){x(!1);return}f.mutate({deviceWorkerId:i.id,label:k.length===0?null:k},{onSuccess:()=>x(!1)})};return e.jsx("div",{className:"flex flex-1 flex-col",children:e.jsxs(Ne,{header:e.jsx(ke,{breadcrumb:e.jsx($e,{crumbs:[e.jsx(E,{to:"/$owner/connectors",params:{owner:s},search:{},className:K,children:"Connectors"},"connectors"),...A?[e.jsx(E,{to:"/$owner/connectors/app/$appId",params:{owner:s,appId:A.id},className:K,children:A.name},"app")]:[]]}),icon:e.jsx(O,{platform:Z,className:"h-5 w-5"}),title:d?e.jsxs("div",{className:"flex flex-wrap items-center gap-2",children:[e.jsx(we,{"aria-label":"Device name",value:y,onChange:k=>_(k.target.value),placeholder:C({...i,label:null}),maxLength:80,className:"h-9 max-w-sm text-base font-semibold",autoFocus:!0,onKeyDown:k=>{k.key==="Enter"?(k.preventDefault(),N||B()):k.key==="Escape"&&(j(!1),_(i.label?.trim()??""),x(!1))}}),N?e.jsxs("div",{className:"flex flex-wrap items-center gap-2 rounded-lg bg-destructive/10 px-3 py-2",children:[e.jsxs("span",{className:"text-xs text-muted-foreground",children:["Forgets this device"," ",i.connector_count>0?`and un-pins ${i.connector_count} connector${i.connector_count===1?"":"s"} across every workspace, not just this one.`:"with no pinned connections."]}),e.jsxs(b,{variant:"destructive",size:"sm",disabled:a.isPending,onClick:()=>a.mutate(i.id,{onSuccess:()=>{j(!1),r({to:"/$owner/connectors",params:{owner:s},search:{}})}}),children:[a.isPending?e.jsx(z,{className:"mr-1.5"}):null,a.isPending?"Removing...":"Confirm remove"]}),e.jsx(b,{size:"sm",variant:"ghost",disabled:a.isPending,onClick:()=>j(!1),children:"Cancel"})]}):e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsxs(b,{size:"sm",onClick:B,disabled:f.isPending,children:[f.isPending?e.jsx(z,{className:"mr-1.5"}):null,f.isPending?"Saving...":"Save"]}),e.jsx(b,{size:"sm",variant:"ghost",disabled:f.isPending,onClick:()=>{_(i.label?.trim()??""),x(!1)},children:"Cancel"}),e.jsxs(b,{size:"sm",variant:"ghost",className:"text-destructive hover:text-destructive",disabled:f.isPending||a.isPending,onClick:()=>j(!0),children:[e.jsx(Ce,{className:"mr-1.5 h-3.5 w-3.5"}),"Remove device"]})]})]}):e.jsxs("span",{className:"flex items-center gap-1.5",children:[C(i),e.jsx(b,{variant:"ghost",size:"sm",className:"h-7 w-7 p-0 text-muted-foreground","aria-label":"Edit device",onClick:()=>{j(!1),_(i.label?.trim()??""),x(!0)},children:e.jsx(Se,{className:"h-3.5 w-3.5"})})]}),badge:e.jsxs("span",{className:"inline-flex items-center gap-1.5 text-xs text-muted-foreground",children:[e.jsx("span",{className:`size-1.5 rounded-full ${i.online?"bg-emerald-500":"bg-muted-foreground/50"}`}),i.online?i.connector_error_count>0?"Needs attention":"Online":"Offline"]}),meta:ee||void 0,caption:`Last seen ${q(new Date(i.last_seen_at),{addSuffix:!0})}${i.last_sync_at?` · Last sync ${q(new Date(i.last_sync_at),{addSuffix:!0})}`:""}`}),children:[e.jsx(Ke,{device:i,ownerSlug:s}),i.connector_error_count>0?e.jsxs("div",{className:"flex items-center gap-2 rounded-lg bg-amber-500/10 px-3 py-2 text-xs text-amber-600",children:[e.jsx(_e,{className:"h-3.5 w-3.5 shrink-0"}),i.connector_error_count," connector",i.connector_error_count===1?"":"s"," pinned to this device ",i.connector_error_count===1?"is":"are"," erroring."]}):null,e.jsx(H,{device:i,organizationId:o,ownerSlug:s,selectedConnection:h,openSettings:m}),S.length>0?e.jsx(I,{title:"Browser auth profiles",children:e.jsx(He,{profiles:S})}):null,e.jsx(I,{title:"Runs",children:e.jsx(Ie,{scope:{deviceId:c},ownerSlug:s})})]})})}function He({profiles:s}){return s.length===0?null:e.jsx("div",{className:"rounded-lg border",children:e.jsx("ul",{className:"divide-y",children:s.map(n=>e.jsxs("li",{className:"space-y-2 px-3 py-2.5 text-sm",children:[e.jsxs("div",{className:"flex items-center justify-between gap-3",children:[e.jsxs("div",{className:"min-w-0 flex-1",children:[e.jsx("div",{className:"truncate font-medium",children:n.display_name}),e.jsxs("div",{className:"mt-0.5 flex flex-wrap items-center gap-1.5 text-xs text-muted-foreground",children:[e.jsx("span",{children:n.connector_key??"Any connector"}),n.browser_kind?e.jsxs("span",{children:["· ",n.browser_kind]}):null,n.captured_at?e.jsxs("span",{title:n.captured_at,children:["· captured ",De(n.captured_at)]}):null,typeof n.cookie_count=="number"?e.jsxs("span",{children:["· ",n.cookie_count," cookie",n.cookie_count===1?"":"s"]}):null]})]}),e.jsx(Re,{status:n.is_expired?"error":Ae(n.status),showDot:!0,children:n.is_expired?"expired":n.status})]}),e.jsx("p",{className:"text-xs text-muted-foreground",children:"Refresh the session using the connector’s authorization instructions."})]},n.id))})})}function ss(){const{owner:s,deviceId:n}=W.useParams(),{connection:o,settings:h}=W.useSearch();return e.jsx(Pe,{owner:s,children:({ownerSlug:m,organizationId:r})=>e.jsx(We,{ownerSlug:m,deviceId:n,organizationId:r,selectedConnection:o,openSettings:h})})}export{ss as component};
|
|
2
|
-
//# sourceMappingURL=device._deviceId-
|
|
1
|
+
import{aI as U,hL as ne,hM as V,r as v,j as e,hN as L,B as b,a1 as z,hO as C,cN as Y,au as te,hi as I,S as R,aU as T,dO as ae,dP as ce,dj as ie,dQ as oe,hP as re,T as le,m as de,az as me,hQ as ue,hR as xe,hS as he,aA as pe,av as fe,aB as P,aT as O,L as E,hT as ge,hU as je,aO as ve,hV as ye,hW as be,h0 as Ne,b7 as _e,fL as ke,hX as q,I as we,a_ as Ce,b8 as Se,fM as $e,fN as K,bc as De,hY as W,ah as Pe}from"./index-Cr5hwh-C.js";import{c as Q,C as Le,R as ze}from"./device-pin-tombstone-CrjG7gPo.js";import{R as Ie}from"./runs-panel-Du1JMjg5.js";import{S as Re,g as Ae}from"./runs-table-syPJ6r6T.js";import{c as Ee}from"./connection-label-BobuYiAG.js";import{w as M}from"./workspace-label-o_QfBuCM.js";import"./connector-scope-lists-CadPVsI3.js";import"./status-dot-B-EWMgq6.js";import"./runs-C0rCgGwX.js";import"./filter-editors-Cj-v6NtH.js";function Me(s,n,o){const h=new Set(s.capabilities??[]),m=new Set(s.connectors.filter(t=>t.organization_slug===o).map(t=>t.connector_key)),r=new Set(G(s,o).map(t=>t.connector_key));return n.filter(t=>U(t)&&!!t.required_capability&&h.has(t.required_capability)&&!m.has(t.key)&&!r.has(t.key))}function G(s,n){return s.organization_slug===n?s.update_required:[]}function Te(s,n,o){const h=s.organization_slug;if(!h||h===o)return[];const m=new Set(n.map(t=>t.key)),r=new Set(s.connectors.filter(t=>t.organization_slug===o).map(t=>t.connector_key));return s.connectors.filter(t=>t.organization_slug!==h||m.has(t.connector_key)||r.has(t.connector_key)?!1:(r.add(t.connector_key),!0))}function Be({device:s,organizationId:n,ownerSlug:o,connectable:h,unavailable:m}){const r=ne(),t=V(),[u,p]=v.useState(null),[g,a]=v.useState(null),[f,N]=v.useState(null),[j,d]=v.useState([]),x=s.organization_id===n,y=async c=>{p(null),N(null),a(c.key);try{x||await t.mutateAsync({deviceWorkerId:s.id,organizationId:n});const w=await r.mutateAsync({connector_key:c.key,device_worker_id:s.id}),S=w.connection_id??w.connection?.id;if(S===void 0)throw new Error(w.instructions??"The connection was not created.");d($=>[...$.filter(D=>D.connectorKey!==c.key),{connectorKey:c.key,name:c.name,connectionId:S,instructions:w.status==="setup_required"?w.instructions:void 0}])}catch(w){N({key:c.key,message:w instanceof Error?w.message:"Could not connect."})}finally{a(null)}},_=new Set(j.map(c=>c.connectorKey)),l=G(s,o),i=h.filter(c=>!_.has(c.key));return e.jsxs("div",{className:"mt-4 space-y-3",children:[j.map(c=>e.jsx(Oe,{outcome:c,device:s,organizationId:n},c.connectorKey)),i.length>0?e.jsxs("div",{children:[e.jsx("p",{className:"text-xs font-medium",children:"Supported by this device"}),e.jsxs("p",{className:"mb-2 text-xs text-muted-foreground",children:["Not connected in this workspace yet.",x?null:" Connecting one moves the device here; you will be asked to confirm first."]}),e.jsx("div",{className:"divide-y border-y",children:i.map(c=>e.jsxs("div",{className:"space-y-2 py-3",children:[e.jsxs("div",{className:"flex items-center gap-3",children:[e.jsxs("span",{className:"min-w-0 flex-1 text-sm font-medium",children:[c.name,c.required_capability&&L[c.required_capability]&&L[c.required_capability]!==c.name?e.jsx("span",{className:"ml-2 text-xs font-normal text-muted-foreground",children:L[c.required_capability]}):null]}),e.jsxs(b,{size:"sm",variant:"outline","aria-label":`Connect ${c.name}`,disabled:g!==null,onClick:()=>x?void y(c):p(c.key),children:[g===c.key?e.jsx(z,{className:"mr-1.5"}):null,"Connect"]})]}),u===c.key?e.jsx(X,{device:s,ownerSlug:o,title:"Move device to this workspace",intro:`${C(s)} lives in ${s.organization_name??"another workspace"}. A device serves one workspace at a time, so it has to move here before it can be connected.`,confirmLabel:"Move here and connect",onConfirm:()=>void y(c),onCancel:()=>p(null)}):null,f?.key===c.key?e.jsx("p",{role:"alert",className:"text-sm text-destructive",children:f.message}):null]},c.key))})]}):null,l.length>0?e.jsxs("div",{role:"status",children:[e.jsx("p",{className:"text-xs font-medium",children:"Update Lobu on this device"}),e.jsx("ul",{className:"mt-1 space-y-1 text-xs text-muted-foreground",children:l.map(c=>e.jsx("li",{children:`${c.display_name} — this device has ${c.device_version}, this workspace uses ${c.workspace_version}`},c.connector_key))})]}):null,m.length>0?e.jsx("ul",{className:"space-y-1 text-xs text-muted-foreground",children:m.map(c=>e.jsx("li",{children:`${c.display_name} — set up on this device in ${s.organization_name??"its home workspace"}, not available in this workspace yet`},c.connector_key))}):null]})}function X({device:s,ownerSlug:n,title:o,intro:h,aftermath:m,confirmLabel:r,pending:t=!1,onConfirm:u,onCancel:p}){const g=s.connector_count,a=s.connectors.filter(f=>f.organization_slug===n).length;return e.jsxs("div",{role:"alertdialog","aria-label":o,className:"space-y-2 rounded-lg bg-amber-500/10 px-3 py-2 text-xs",children:[e.jsx("p",{children:h}),e.jsxs("p",{className:"text-muted-foreground",children:[g>0?`Moving pauses and unpins all ${g} connection${g===1?"":"s"} pinned to it${a>0?`, including ${a} in this workspace`:""}. They stay paused until you reconnect them.`:"It has no pinned connections, so nothing is paused.",m?` ${m}`:null]}),e.jsxs("div",{className:"flex gap-2",children:[e.jsxs(b,{size:"sm",disabled:t,onClick:u,children:[t?e.jsx(z,{className:"mr-1.5"}):null,r]}),e.jsx(b,{size:"sm",variant:"ghost",disabled:t,onClick:p,children:"Cancel"})]})]})}function Oe({outcome:s,device:n,organizationId:o}){const{data:h=[],isLoading:m}=Y(o,{connectionIds:[s.connectionId]}),r=h.find(p=>p.id===s.connectionId),t=C(n);if(m)return e.jsxs("p",{role:"status",className:"text-sm text-muted-foreground",children:["Checking ",s.name,"…"]});const u=[];if(!r)u.push(`${s.name} was created but could not be loaded yet.`);else if(r.status!=="active"){const p=Q(r);u.push(`${s.name} is ${r.status}${p?`: ${p}`:"."}`)}return s.instructions&&u.push(s.instructions),n.online||u.push(`${t} is offline. ${s.name} runs once it reconnects.`),e.jsx("div",{role:"status",className:"rounded-lg border px-3 py-2 text-sm",children:u.length===0?e.jsxs("p",{children:[s.name," is ready on ",t,"."]}):e.jsxs(e.Fragment,{children:[e.jsxs("p",{className:"font-medium",children:[s.name," connected, not ready yet"]}),e.jsx("ul",{className:"mt-1 list-disc pl-4 text-xs text-muted-foreground",children:u.map(p=>e.jsx("li",{children:p},p))})]})})}function H({device:s,organizationId:n,ownerSlug:o,selectedConnection:h,openSettings:m}){const{data:r=[],isLoading:t,isError:u,refetch:p}=te(n),g=new Map(r.map(d=>[d.key,d])),a=new Map,f=[];for(const d of s.connectors){if(d.organization_slug!==o)continue;const x=g.get(d.connector_key);if(!x||!U(x)){f.push(d);continue}const y=x.required_capability??`connector:${x.key}`,_=a.get(y)??{key:y,name:x.name,connections:[]};_.name=L[y]??x.name,_.connections.push(d),a.set(y,_)}const N=Me(s,r,o),j=Te(s,r,o);return e.jsxs(e.Fragment,{children:[e.jsxs(I,{title:"Capabilities",children:[e.jsx("p",{className:"mb-3 text-xs text-muted-foreground",children:"Manage the native connections available to this workspace."}),s.online?null:e.jsx("p",{className:"mb-3 text-sm text-muted-foreground",children:"This device is offline. You can edit its settings; actions and sync need it to reconnect."}),!n||t?e.jsx(R,{className:"h-24 w-full"}):u?e.jsxs("div",{role:"alert",className:"space-y-2 text-sm",children:[e.jsx("p",{children:"Could not load capability settings."}),e.jsx(b,{variant:"outline",size:"sm",onClick:()=>void p(),children:"Retry"})]}):a.size===0?e.jsx("p",{className:"text-sm text-muted-foreground",children:"No native connections on this device in this workspace."}):e.jsx("div",{className:"divide-y border-y",children:[...a.values()].map(d=>e.jsx(F,{group:d,deviceId:s.id,organizationId:n,ownerSlug:o,definitionsByKey:g,selectedConnection:h,openSettings:m},d.key))}),n&&!t&&!u?e.jsx(Be,{device:s,organizationId:n,ownerSlug:o,connectable:N,unavailable:j}):null,T(s)==="macos"?e.jsx("p",{className:"mt-3 text-xs text-muted-foreground",children:"Manage macOS permissions in the Lobu app on this device."}):null]}),n&&f.length>0&&!t&&!u?e.jsxs(I,{title:"Apps and sources",count:String(f.length),children:[e.jsx("p",{className:"mb-3 text-xs text-muted-foreground",children:"Apps and sources that use this device."}),e.jsx("div",{className:"divide-y border-y",children:[...new Set(f.map(d=>d.connector_key))].map(d=>e.jsx(F,{group:{key:d,name:g.get(d)?.name??d,connections:f.filter(x=>x.connector_key===d)},deviceId:s.id,organizationId:n,ownerSlug:o,definitionsByKey:g,selectedConnection:h,openSettings:m},d))})]}):null]})}function F({group:s,deviceId:n,organizationId:o,ownerSlug:h,definitionsByKey:m,selectedConnection:r,openSettings:t}){const u=s.connections.some(a=>a.connection_id===r),[p,g]=v.useState(u);return v.useEffect(()=>{u&&r!==void 0&&g(!0)},[u,r]),e.jsxs(ae,{open:p,onOpenChange:g,children:[e.jsxs(ce,{className:"group flex w-full items-center gap-3 py-3 text-left",children:[e.jsx(ie,{className:"size-3.5 shrink-0 text-muted-foreground transition-transform group-data-[state=open]:rotate-90"}),e.jsx("span",{className:"min-w-0 flex-1 text-sm font-medium",children:s.name}),e.jsx("span",{className:"text-right text-xs text-muted-foreground",children:s.connections.some(a=>a.status==="error"||a.status==="revoked")?"Needs attention":s.connections.length>1?`${s.connections.length} connections`:"Configured"})]}),e.jsx(oe,{className:"pb-4 pl-6",children:e.jsx("div",{className:"space-y-5",children:s.connections.map(a=>e.jsx(qe,{summary:a,deviceId:n,organizationId:o,ownerSlug:h,connectorDef:m.get(a.connector_key),openSettings:a.connection_id===r&&t},a.connection_id))})})]})}function qe({summary:s,deviceId:n,organizationId:o,ownerSlug:h,connectorDef:m,openSettings:r}){const{data:t=[],isLoading:u,isError:p,refetch:g}=Y(o,{connectionIds:[s.connection_id]}),a=t.find(j=>j.id===s.connection_id&&j.device_worker_id===n),f=m?.name??s.connector_key,N=a?Q(a):null;return e.jsxs("section",{id:`connection-${s.connection_id}`,"aria-label":f,className:"scroll-mt-24",children:[a?e.jsxs("div",{className:"mb-3 flex items-baseline justify-between gap-3 text-xs text-muted-foreground",children:[e.jsx("span",{children:Ee(a)}),e.jsx("span",{children:a.status})]}):null,u||!o?e.jsx(R,{className:"h-24 w-full"}):p?e.jsxs("div",{role:"alert",className:"space-y-2 text-sm",children:[e.jsx("p",{children:"Could not load this connection."}),e.jsx(b,{variant:"outline",size:"sm",onClick:()=>void g(),children:"Retry"})]}):a?e.jsxs(e.Fragment,{children:[N?e.jsx("p",{role:"alert",className:"mb-4 text-sm text-destructive",children:N}):null,e.jsx("div",{className:"mb-4",children:e.jsx(re,{connection:a})}),e.jsx(Le,{connection:a,connectorDef:m,ownerSlug:h,openSettings:r,showActivity:!1,showShare:!1,embedded:!0})]}):e.jsx("p",{className:"text-sm text-muted-foreground",children:"This connection is no longer available on this device."})]})}function Ke({device:s,ownerSlug:n}){const o=v.useId(),{data:h=[]}=le(),m=V(),[r,t]=v.useState(!1),[u,p]=v.useState(null),[g,a]=v.useState(null),f=h.filter(l=>l.is_member).map(l=>({id:l.id,name:l.name,isPersonal:l.is_personal===!0})),N=f.find(l=>l.id===s.organization_id),j=N?M(N):s.organization_name??"No workspace",d=f.filter(l=>l.id!==s.organization_id),x=d.find(l=>l.id===u)??null,y=()=>{t(!1),p(null)},_=async l=>{a(null);try{await m.mutateAsync({deviceWorkerId:s.id,organizationId:l}),y()}catch(i){a(i instanceof Error?i.message:"Could not move the device.")}};return e.jsxs("div",{className:"space-y-2 text-sm",children:[e.jsxs("div",{className:"flex flex-wrap items-center gap-3",children:[e.jsxs("p",{children:[e.jsx("span",{className:"text-muted-foreground",children:"Workspace: "}),j]}),!r&&d.length>0?e.jsx(b,{size:"sm",variant:"outline",onClick:()=>{a(null),t(!0)},children:"Change workspace"}):null]}),r?e.jsxs("div",{className:"flex flex-wrap items-center gap-2",children:[e.jsx("label",{htmlFor:o,className:"text-xs text-muted-foreground",children:"Move to"}),e.jsxs("select",{id:o,value:u??"",disabled:m.isPending,onChange:l=>p(l.target.value||null),className:"h-8 rounded-md border border-input bg-background px-2 text-sm",children:[e.jsx("option",{value:"",children:"Choose a workspace"}),d.map(l=>e.jsx("option",{value:l.id,children:M(l)},l.id))]}),x?null:e.jsx(b,{size:"sm",variant:"ghost",onClick:y,children:"Cancel"})]}):null,x?e.jsx(X,{device:s,ownerSlug:n,title:`Move device to ${x.name}`,intro:`Move ${C(s)} from ${j} to ${M(x)}?`,aftermath:`It is set up fresh in ${x.name}, with its connections there private to you until you share them.`,confirmLabel:"Move device",pending:m.isPending,onConfirm:()=>void _(x.id),onCancel:y}):null,g?e.jsx("p",{role:"alert",className:"text-sm text-destructive",children:g}):null]})}function We({ownerSlug:s,deviceId:n,organizationId:o,selectedConnection:h,openSettings:m}){const r=de(),{data:t=[],isLoading:u,isError:p,refetch:g}=me(),a=ue(),f=xe(),[N,j]=v.useState(!1),[d,x]=v.useState(!1),[y,_]=v.useState(""),l=he(t,n),i=l&&pe(l,s)?l:void 0,c=i?.id??n,{data:w=[]}=fe(o,{profileKind:"browser_session"}),S=v.useMemo(()=>w.filter(k=>k.device_worker_id===c&&k.status!=="revoked"),[w,c]),$=i?.label?.trim()??"";if(v.useEffect(()=>{d||_($)},[$,d]),u)return e.jsxs(P,{className:"space-y-4",children:[e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(R,{className:"h-6 w-6 rounded"}),e.jsx(R,{className:"h-5 w-40"})]}),e.jsx(ze,{})]});if(p)return e.jsx(P,{children:e.jsxs("div",{role:"alert",className:"space-y-2",children:[e.jsx("p",{children:"Could not load this device."}),e.jsx(b,{variant:"outline",size:"sm",onClick:()=>void g(),children:"Retry"})]})});if(!i&&l&&o)return e.jsxs(P,{className:"space-y-4",children:[e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(O,{platform:T(l),className:"h-5 w-5"}),e.jsx("h1",{className:"text-base font-semibold",children:C(l)})]}),e.jsxs("p",{className:"text-sm text-muted-foreground",children:["This device lives in"," ",l.organization_name??"another workspace",", not this workspace."]}),e.jsx(H,{device:l,organizationId:o,ownerSlug:s})]});if(!i)return e.jsxs(P,{className:"space-y-3",children:[e.jsx("p",{className:"text-sm text-muted-foreground",children:"This device isn't in this workspace, so its details aren't available."}),e.jsx(E,{to:"/$owner/connectors",params:{owner:s},search:{},className:"text-sm text-primary hover:underline",children:"Back to connectors"})]});const D=ge(i),A=D?je(s,D,ve()):void 0,J=T(i),Z=ye(i.app_version),ee=be(i,Z),B=()=>{const k=y.trim(),se=i.label?.trim()??"";if(k===se){x(!1);return}f.mutate({deviceWorkerId:i.id,label:k.length===0?null:k},{onSuccess:()=>x(!1)})};return e.jsx("div",{className:"flex flex-1 flex-col",children:e.jsxs(Ne,{header:e.jsx(ke,{breadcrumb:e.jsx($e,{crumbs:[e.jsx(E,{to:"/$owner/connectors",params:{owner:s},search:{},className:K,children:"Connectors"},"connectors"),...A?[e.jsx(E,{to:"/$owner/connectors/app/$appId",params:{owner:s,appId:A.id},className:K,children:A.name},"app")]:[]]}),icon:e.jsx(O,{platform:J,className:"h-5 w-5"}),title:d?e.jsxs("div",{className:"flex flex-wrap items-center gap-2",children:[e.jsx(we,{"aria-label":"Device name",value:y,onChange:k=>_(k.target.value),placeholder:C({...i,label:null}),maxLength:80,className:"h-9 max-w-sm text-base font-semibold",autoFocus:!0,onKeyDown:k=>{k.key==="Enter"?(k.preventDefault(),N||B()):k.key==="Escape"&&(j(!1),_(i.label?.trim()??""),x(!1))}}),N?e.jsxs("div",{className:"flex flex-wrap items-center gap-2 rounded-lg bg-destructive/10 px-3 py-2",children:[e.jsxs("span",{className:"text-xs text-muted-foreground",children:["Forgets this device"," ",i.connector_count>0?`and un-pins ${i.connector_count} connector${i.connector_count===1?"":"s"} across every workspace, not just this one.`:"with no pinned connections."]}),e.jsxs(b,{variant:"destructive",size:"sm",disabled:a.isPending,onClick:()=>a.mutate(i.id,{onSuccess:()=>{j(!1),r({to:"/$owner/connectors",params:{owner:s},search:{}})}}),children:[a.isPending?e.jsx(z,{className:"mr-1.5"}):null,a.isPending?"Removing...":"Confirm remove"]}),e.jsx(b,{size:"sm",variant:"ghost",disabled:a.isPending,onClick:()=>j(!1),children:"Cancel"})]}):e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsxs(b,{size:"sm",onClick:B,disabled:f.isPending,children:[f.isPending?e.jsx(z,{className:"mr-1.5"}):null,f.isPending?"Saving...":"Save"]}),e.jsx(b,{size:"sm",variant:"ghost",disabled:f.isPending,onClick:()=>{_(i.label?.trim()??""),x(!1)},children:"Cancel"}),e.jsxs(b,{size:"sm",variant:"ghost",className:"text-destructive hover:text-destructive",disabled:f.isPending||a.isPending,onClick:()=>j(!0),children:[e.jsx(Ce,{className:"mr-1.5 h-3.5 w-3.5"}),"Remove device"]})]})]}):e.jsxs("span",{className:"flex items-center gap-1.5",children:[C(i),e.jsx(b,{variant:"ghost",size:"sm",className:"h-7 w-7 p-0 text-muted-foreground","aria-label":"Edit device",onClick:()=>{j(!1),_(i.label?.trim()??""),x(!0)},children:e.jsx(Se,{className:"h-3.5 w-3.5"})})]}),badge:e.jsxs("span",{className:"inline-flex items-center gap-1.5 text-xs text-muted-foreground",children:[e.jsx("span",{className:`size-1.5 rounded-full ${i.online?"bg-emerald-500":"bg-muted-foreground/50"}`}),i.online?i.connector_error_count>0?"Needs attention":"Online":"Offline"]}),meta:ee||void 0,caption:`Last seen ${q(new Date(i.last_seen_at),{addSuffix:!0})}${i.last_sync_at?` · Last sync ${q(new Date(i.last_sync_at),{addSuffix:!0})}`:""}`}),children:[e.jsx(Ke,{device:i,ownerSlug:s}),i.connector_error_count>0?e.jsxs("div",{className:"flex items-center gap-2 rounded-lg bg-amber-500/10 px-3 py-2 text-xs text-amber-600",children:[e.jsx(_e,{className:"h-3.5 w-3.5 shrink-0"}),i.connector_error_count," connector",i.connector_error_count===1?"":"s"," pinned to this device ",i.connector_error_count===1?"is":"are"," erroring."]}):null,e.jsx(H,{device:i,organizationId:o,ownerSlug:s,selectedConnection:h,openSettings:m}),S.length>0?e.jsx(I,{title:"Browser auth profiles",children:e.jsx(He,{profiles:S})}):null,e.jsx(I,{title:"Runs",children:e.jsx(Ie,{scope:{deviceId:c},ownerSlug:s})})]})})}function He({profiles:s}){return s.length===0?null:e.jsx("div",{className:"rounded-lg border",children:e.jsx("ul",{className:"divide-y",children:s.map(n=>e.jsxs("li",{className:"space-y-2 px-3 py-2.5 text-sm",children:[e.jsxs("div",{className:"flex items-center justify-between gap-3",children:[e.jsxs("div",{className:"min-w-0 flex-1",children:[e.jsx("div",{className:"truncate font-medium",children:n.display_name}),e.jsxs("div",{className:"mt-0.5 flex flex-wrap items-center gap-1.5 text-xs text-muted-foreground",children:[e.jsx("span",{children:n.connector_key??"Any connector"}),n.browser_kind?e.jsxs("span",{children:["· ",n.browser_kind]}):null,n.captured_at?e.jsxs("span",{title:n.captured_at,children:["· captured ",De(n.captured_at)]}):null,typeof n.cookie_count=="number"?e.jsxs("span",{children:["· ",n.cookie_count," cookie",n.cookie_count===1?"":"s"]}):null]})]}),e.jsx(Re,{status:n.is_expired?"error":Ae(n.status),showDot:!0,children:n.is_expired?"expired":n.status})]}),e.jsx("p",{className:"text-xs text-muted-foreground",children:"Refresh the session using the connector’s authorization instructions."})]},n.id))})})}function ss(){const{owner:s,deviceId:n}=W.useParams(),{connection:o,settings:h}=W.useSearch();return e.jsx(Pe,{owner:s,children:({ownerSlug:m,organizationId:r})=>e.jsx(We,{ownerSlug:m,deviceId:n,organizationId:r,selectedConnection:o,openSettings:h})})}export{ss as component};
|
|
2
|
+
//# sourceMappingURL=device._deviceId-Cs3ZmXWo.js.map
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import{m as x,t as m,j as e,bn as C,bo as _,bp as S,bq as b,br as c,eh as u}from"./index-
|
|
2
|
-
//# sourceMappingURL=entity-options-
|
|
1
|
+
import{m as x,t as m,j as e,bn as C,bo as _,bp as S,bq as b,br as c,eh as u}from"./index-Cr5hwh-C.js";import{c as w}from"./connection-label-BobuYiAG.js";const h="__connection_picker_create_new__";function y({connections:s,value:r,onValueChange:n,connectorKey:a,disabled:p,placeholder:d="Choose a connection",includeWorkspaceEvents:i=!1,ariaLabel:g="Connection"}){const f=x(),l=m().org?.slug,o=a?s.filter(t=>t.connector_key===a):s,j=t=>{if(t===h){if(!l)return;f({to:"/$owner/connectors/create",params:{owner:l},search:a?{connector:a}:{}});return}n(t)};return e.jsxs(C,{value:r,onValueChange:j,disabled:p,children:[e.jsx(_,{"aria-label":g,children:e.jsx(S,{placeholder:d})}),e.jsxs(b,{children:[i?e.jsxs(e.Fragment,{children:[e.jsx(c,{value:"workspace",children:"Current workspace"}),o.length>0?e.jsx(u,{}):null]}):null,o.map(t=>e.jsx(c,{value:String(t.id),children:w(t)},t.id)),l?e.jsxs(e.Fragment,{children:[o.length>0||i?e.jsx(u,{}):null,e.jsx(c,{value:h,children:"Connect an app…"})]}):null]})]})}function v(s){const r=[];for(const n of s)r.push({id:n.id,name:n.name,entityType:n.entity_type}),n.children&&n.children.length>0&&r.push(...v(n.children));return r}export{y as C,v as f};
|
|
2
|
+
//# sourceMappingURL=entity-options-uXjgT7y9.js.map
|