prefect 3.6.14.dev3__py3-none-any.whl → 3.6.14.dev5__py3-none-any.whl
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.
- prefect/_build_info.py +3 -3
- prefect/events/clients.py +36 -3
- prefect/futures.py +17 -4
- prefect/runner/runner.py +113 -29
- prefect/server/api/events.py +3 -2
- prefect/server/ui-v2/assets/{artifact-card-CNabu-6j.js → artifact-card-DprxJzPy.js} +2 -2
- prefect/server/ui-v2/assets/{artifact-card-CNabu-6j.js.map → artifact-card-DprxJzPy.js.map} +1 -1
- prefect/server/ui-v2/assets/{artifact._id-Emkhr_0h.js → artifact._id-CXcnU7_U.js} +2 -2
- prefect/server/ui-v2/assets/{artifact._id-Emkhr_0h.js.map → artifact._id-CXcnU7_U.js.map} +1 -1
- prefect/server/ui-v2/assets/{automation-schema-CRKJHa4q.js → automation-schema-crrFcHTg.js} +2 -2
- prefect/server/ui-v2/assets/{automation-schema-CRKJHa4q.js.map → automation-schema-crrFcHTg.js.map} +1 -1
- prefect/server/ui-v2/assets/{automation-wizard-Cej8aik5.js → automation-wizard-DPKDA6ji.js} +2 -2
- prefect/server/ui-v2/assets/{automation-wizard-Cej8aik5.js.map → automation-wizard-DPKDA6ji.js.map} +1 -1
- prefect/server/ui-v2/assets/automation._id-BvFFkDrn.js +2 -0
- prefect/server/ui-v2/assets/{automation._id-Bm1T3_NO.js.map → automation._id-BvFFkDrn.js.map} +1 -1
- prefect/server/ui-v2/assets/{automation_._id.edit-C5NIVfxR.js → automation_._id.edit-vpFy8Znl.js} +2 -2
- prefect/server/ui-v2/assets/{automation_._id.edit-C5NIVfxR.js.map → automation_._id.edit-vpFy8Znl.js.map} +1 -1
- prefect/server/ui-v2/assets/{automations-header-CdJSlWw8.js → automations-header-eG-shDxp.js} +2 -2
- prefect/server/ui-v2/assets/{automations-header-CdJSlWw8.js.map → automations-header-eG-shDxp.js.map} +1 -1
- prefect/server/ui-v2/assets/{base-job-template-form-section-DX_X28oU.js → base-job-template-form-section-du3c8HMM.js} +2 -2
- prefect/server/ui-v2/assets/{base-job-template-form-section-DX_X28oU.js.map → base-job-template-form-section-du3c8HMM.js.map} +1 -1
- prefect/server/ui-v2/assets/{block-type-details-BcpcwaJS.js → block-type-details-CIGWaz9i.js} +2 -2
- prefect/server/ui-v2/assets/{block-type-details-BcpcwaJS.js.map → block-type-details-CIGWaz9i.js.map} +1 -1
- prefect/server/ui-v2/assets/block-type-logo-B3oMH8dS.js +2 -0
- prefect/server/ui-v2/assets/{block-type-logo-ox5VqJuy.js.map → block-type-logo-B3oMH8dS.js.map} +1 -1
- prefect/server/ui-v2/assets/{block._id-BD6wu3yC.js → block._id-Cay2vm3g.js} +2 -2
- prefect/server/ui-v2/assets/{block._id-BD6wu3yC.js.map → block._id-Cay2vm3g.js.map} +1 -1
- prefect/server/ui-v2/assets/{block_._id.edit-aneXPzUW.js → block_._id.edit-bNSemu_v.js} +2 -2
- prefect/server/ui-v2/assets/{block_._id.edit-aneXPzUW.js.map → block_._id.edit-bNSemu_v.js.map} +1 -1
- prefect/server/ui-v2/assets/{catalog-C7ttFKuv.js → catalog-B3SdxUVJ.js} +2 -2
- prefect/server/ui-v2/assets/{catalog-C7ttFKuv.js.map → catalog-B3SdxUVJ.js.map} +1 -1
- prefect/server/ui-v2/assets/{catalog_._slug-CrcphBbo.js → catalog_._slug-BfQw_9GK.js} +2 -2
- prefect/server/ui-v2/assets/{catalog_._slug-CrcphBbo.js.map → catalog_._slug-BfQw_9GK.js.map} +1 -1
- prefect/server/ui-v2/assets/{catalog_._slug_.create-Dd7ATIKq.js → catalog_._slug_.create-k_HRDFv7.js} +2 -2
- prefect/server/ui-v2/assets/{catalog_._slug_.create-Dd7ATIKq.js.map → catalog_._slug_.create-k_HRDFv7.js.map} +1 -1
- prefect/server/ui-v2/assets/{collapsible-D5U2XK4R.js → collapsible-CjJyAdbn.js} +2 -2
- prefect/server/ui-v2/assets/{collapsible-D5U2XK4R.js.map → collapsible-CjJyAdbn.js.map} +1 -1
- prefect/server/ui-v2/assets/{concurrency-limit._id-D-xV_tiF.js → concurrency-limit._id-B3Gnqcjc.js} +2 -2
- prefect/server/ui-v2/assets/{concurrency-limit._id-D-xV_tiF.js.map → concurrency-limit._id-B3Gnqcjc.js.map} +1 -1
- prefect/server/ui-v2/assets/create-AIgXW0ut.js +2 -0
- prefect/server/ui-v2/assets/{create-Da7OBOa5.js.map → create-AIgXW0ut.js.map} +1 -1
- prefect/server/ui-v2/assets/create-CWAzl36x.js +2 -0
- prefect/server/ui-v2/assets/{create-CiMo25er.js.map → create-CWAzl36x.js.map} +1 -1
- prefect/server/ui-v2/assets/cronstrue-IJcBJ9tZ.js +2 -0
- prefect/server/ui-v2/assets/cronstrue-IJcBJ9tZ.js.map +1 -0
- prefect/server/ui-v2/assets/{data-table-Bfa8_ZJd.js → data-table-B3EtpFhV.js} +2 -2
- prefect/server/ui-v2/assets/{data-table-Bfa8_ZJd.js.map → data-table-B3EtpFhV.js.map} +1 -1
- prefect/server/ui-v2/assets/{delete-confirmation-dialog-D18TITKv.js → delete-confirmation-dialog-DyUMWSB-.js} +2 -2
- prefect/server/ui-v2/assets/{delete-confirmation-dialog-D18TITKv.js.map → delete-confirmation-dialog-DyUMWSB-.js.map} +1 -1
- prefect/server/ui-v2/assets/deployment-action-header-BJ8WZ6O0.js +2 -0
- prefect/server/ui-v2/assets/{deployment-action-header-AamGn0qI.js.map → deployment-action-header-BJ8WZ6O0.js.map} +1 -1
- prefect/server/ui-v2/assets/{deployment-form-QIRH-pew.js → deployment-form-DXZUK11h.js} +3 -3
- prefect/server/ui-v2/assets/{deployment-form-QIRH-pew.js.map → deployment-form-DXZUK11h.js.map} +1 -1
- prefect/server/ui-v2/assets/{deployment-links-yTRvIDd3.js → deployment-links-bbtRf3OX.js} +2 -2
- prefect/server/ui-v2/assets/{deployment-links-yTRvIDd3.js.map → deployment-links-bbtRf3OX.js.map} +1 -1
- prefect/server/ui-v2/assets/{deployment._id-m4luvPWl.js → deployment._id-DFzzDIAz.js} +2 -2
- prefect/server/ui-v2/assets/{deployment._id-m4luvPWl.js.map → deployment._id-DFzzDIAz.js.map} +1 -1
- prefect/server/ui-v2/assets/{deployment._id-CCBPOCfw.js → deployment._id-GmnYU2jN.js} +2 -2
- prefect/server/ui-v2/assets/{deployment._id-CCBPOCfw.js.map → deployment._id-GmnYU2jN.js.map} +1 -1
- prefect/server/ui-v2/assets/deployment_._id.duplicate--_rm26pJ.js +2 -0
- prefect/server/ui-v2/assets/{deployment_._id.duplicate-DFjSeYn4.js.map → deployment_._id.duplicate--_rm26pJ.js.map} +1 -1
- prefect/server/ui-v2/assets/deployment_._id.edit-BS799pF4.js +2 -0
- prefect/server/ui-v2/assets/{deployment_._id.edit-5-mFOphJ.js.map → deployment_._id.edit-BS799pF4.js.map} +1 -1
- prefect/server/ui-v2/assets/{deployment_._id.run-CwVe5hPJ.js → deployment_._id.run-c02Fu6v1.js} +2 -2
- prefect/server/ui-v2/assets/{deployment_._id.run-CwVe5hPJ.js.map → deployment_._id.run-c02Fu6v1.js.map} +1 -1
- prefect/server/ui-v2/assets/{dropdown-menu-g64QiYKu.js → dropdown-menu-6cSdnzsr.js} +2 -2
- prefect/server/ui-v2/assets/{dropdown-menu-g64QiYKu.js.map → dropdown-menu-6cSdnzsr.js.map} +1 -1
- prefect/server/ui-v2/assets/{event-resource-display-BqqHFc0B.js → event-resource-display-DeFGeJR9.js} +2 -2
- prefect/server/ui-v2/assets/{event-resource-display-BqqHFc0B.js.map → event-resource-display-DeFGeJR9.js.map} +1 -1
- prefect/server/ui-v2/assets/{event._eventDate._eventId-BR0eukkm.js → event._eventDate._eventId-CKnfHNoF.js} +2 -2
- prefect/server/ui-v2/assets/{event._eventDate._eventId-BR0eukkm.js.map → event._eventDate._eventId-CKnfHNoF.js.map} +1 -1
- prefect/server/ui-v2/assets/{flow-run-graph-kZfaIevn.js → flow-run-graph-aynL8fbE.js} +2 -2
- prefect/server/ui-v2/assets/{flow-run-graph-kZfaIevn.js.map → flow-run-graph-aynL8fbE.js.map} +1 -1
- prefect/server/ui-v2/assets/flow-run._id-4lwBtUgU.js +2 -0
- prefect/server/ui-v2/assets/{flow-run._id-DiA0_X5m.js.map → flow-run._id-4lwBtUgU.js.map} +1 -1
- prefect/server/ui-v2/assets/flow-run._id-CT2imMDV.js +2 -0
- prefect/server/ui-v2/assets/{flow-run._id-Caq--9Lr.js.map → flow-run._id-CT2imMDV.js.map} +1 -1
- prefect/server/ui-v2/assets/{flow-run._id-BX0UeXTj.js → flow-run._id-s3t6dDIS.js} +4 -4
- prefect/server/ui-v2/assets/{flow-run._id-BX0UeXTj.js.map → flow-run._id-s3t6dDIS.js.map} +1 -1
- prefect/server/ui-v2/assets/{flow-runs-pagination-CoZZ-ed_.js → flow-runs-pagination-DvDLs5GM.js} +2 -2
- prefect/server/ui-v2/assets/{flow-runs-pagination-CoZZ-ed_.js.map → flow-runs-pagination-DvDLs5GM.js.map} +1 -1
- prefect/server/ui-v2/assets/{flow._id-nRzTWzLb.js → flow._id-U31aNcVQ.js} +2 -2
- prefect/server/ui-v2/assets/{flow._id-nRzTWzLb.js.map → flow._id-U31aNcVQ.js.map} +1 -1
- prefect/server/ui-v2/assets/{form-CdcF42XZ.js → form-DvAgEGjn.js} +2 -2
- prefect/server/ui-v2/assets/{form-CdcF42XZ.js.map → form-DvAgEGjn.js.map} +1 -1
- prefect/server/ui-v2/assets/{header-DkJo9Uge.js → header-Bq61DIIv.js} +2 -2
- prefect/server/ui-v2/assets/{header-DkJo9Uge.js.map → header-Bq61DIIv.js.map} +1 -1
- prefect/server/ui-v2/assets/{header-DijI5Lcu.js → header-QiKDPn2b.js} +2 -2
- prefect/server/ui-v2/assets/{header-DijI5Lcu.js.map → header-QiKDPn2b.js.map} +1 -1
- prefect/server/ui-v2/assets/{header-DV0gMQER.js → header-YbYlGgAg.js} +2 -2
- prefect/server/ui-v2/assets/{header-DV0gMQER.js.map → header-YbYlGgAg.js.map} +1 -1
- prefect/server/ui-v2/assets/{index-BZ9TDxSy.js → index--QEAQOap.js} +2 -2
- prefect/server/ui-v2/assets/{index-BZ9TDxSy.js.map → index--QEAQOap.js.map} +1 -1
- prefect/server/ui-v2/assets/{index-VUajxmNL.js → index-BJJn5VNO.js} +2 -2
- prefect/server/ui-v2/assets/{index-VUajxmNL.js.map → index-BJJn5VNO.js.map} +1 -1
- prefect/server/ui-v2/assets/{index-DYKO0qOd.js → index-BToZEh2M.js} +2 -2
- prefect/server/ui-v2/assets/{index-DYKO0qOd.js.map → index-BToZEh2M.js.map} +1 -1
- prefect/server/ui-v2/assets/{index-BmUvoLOK.js → index-BzE5jxe7.js} +2 -2
- prefect/server/ui-v2/assets/{index-BmUvoLOK.js.map → index-BzE5jxe7.js.map} +1 -1
- prefect/server/ui-v2/assets/index-C-uTnVrI.js +2 -0
- prefect/server/ui-v2/assets/{index-BCKNs_w7.js.map → index-C-uTnVrI.js.map} +1 -1
- prefect/server/ui-v2/assets/{index-yTjygRmH.js → index-C19BICb6.js} +2 -2
- prefect/server/ui-v2/assets/{index-yTjygRmH.js.map → index-C19BICb6.js.map} +1 -1
- prefect/server/ui-v2/assets/{index-Cuh3BwlA.js → index-C84_3iOG.js} +2 -2
- prefect/server/ui-v2/assets/{index-Cuh3BwlA.js.map → index-C84_3iOG.js.map} +1 -1
- prefect/server/ui-v2/assets/{index-Chtop8D8.js → index-CGt_907f.js} +2 -2
- prefect/server/ui-v2/assets/{index-Chtop8D8.js.map → index-CGt_907f.js.map} +1 -1
- prefect/server/ui-v2/assets/index-COtFm673.js +2 -0
- prefect/server/ui-v2/assets/{index-CqvGvZOq.js.map → index-COtFm673.js.map} +1 -1
- prefect/server/ui-v2/assets/{index-BZqccBpn.js → index-CQlQauOE.js} +6 -6
- prefect/server/ui-v2/assets/index-CQlQauOE.js.map +1 -0
- prefect/server/ui-v2/assets/{index-BGZtCgRR.js → index-CovPzmtX.js} +2 -2
- prefect/server/ui-v2/assets/{index-BGZtCgRR.js.map → index-CovPzmtX.js.map} +1 -1
- prefect/server/ui-v2/assets/{index-BV3WqCCv.js → index-CzZJA-g2.js} +2 -2
- prefect/server/ui-v2/assets/{index-BV3WqCCv.js.map → index-CzZJA-g2.js.map} +1 -1
- prefect/server/ui-v2/assets/{index-CUZXozY8.js → index-D9O_iUny.js} +2 -2
- prefect/server/ui-v2/assets/{index-CUZXozY8.js.map → index-D9O_iUny.js.map} +1 -1
- prefect/server/ui-v2/assets/{index-AXV1ellj.js → index-DBhG-F3c.js} +2 -2
- prefect/server/ui-v2/assets/{index-AXV1ellj.js.map → index-DBhG-F3c.js.map} +1 -1
- prefect/server/ui-v2/assets/{index-KlV75baW.js → index-DEijvsFf.js} +2 -2
- prefect/server/ui-v2/assets/{index-KlV75baW.js.map → index-DEijvsFf.js.map} +1 -1
- prefect/server/ui-v2/assets/{index-DO_c3_A_.js → index-DJx6_wL3.js} +2 -2
- prefect/server/ui-v2/assets/{index-DO_c3_A_.js.map → index-DJx6_wL3.js.map} +1 -1
- prefect/server/ui-v2/assets/{index-faXvGo5k.js → index-DzylsDQg.js} +2 -2
- prefect/server/ui-v2/assets/{index-faXvGo5k.js.map → index-DzylsDQg.js.map} +1 -1
- prefect/server/ui-v2/assets/index-MqrX6o60.js +2 -0
- prefect/server/ui-v2/assets/{index-BijfHkUE.js.map → index-MqrX6o60.js.map} +1 -1
- prefect/server/ui-v2/assets/index-Xbikq0U9.js +2 -0
- prefect/server/ui-v2/assets/{index-CUJoNEgb.js.map → index-Xbikq0U9.js.map} +1 -1
- prefect/server/ui-v2/assets/{index-BfuGBXBN.js → index-xd6ftCzl.js} +2 -2
- prefect/server/ui-v2/assets/{index-BfuGBXBN.js.map → index-xd6ftCzl.js.map} +1 -1
- prefect/server/ui-v2/assets/{json-input-DFgWdLGv.js → json-input-CUdR2ooF.js} +2 -2
- prefect/server/ui-v2/assets/{json-input-DFgWdLGv.js.map → json-input-CUdR2ooF.js.map} +1 -1
- prefect/server/ui-v2/assets/{key._key-CpeWM0mN.js → key._key-Dkjl-3EA.js} +2 -2
- prefect/server/ui-v2/assets/{key._key-CpeWM0mN.js.map → key._key-Dkjl-3EA.js.map} +1 -1
- prefect/server/ui-v2/assets/{lazy-markdown-Bzi0YUUV.js → lazy-markdown-B5J5jhCs.js} +3 -3
- prefect/server/ui-v2/assets/{lazy-markdown-Bzi0YUUV.js.map → lazy-markdown-B5J5jhCs.js.map} +1 -1
- prefect/server/ui-v2/assets/{login-CM0nuDdd.js → login-DzDO0DVR.js} +2 -2
- prefect/server/ui-v2/assets/{login-CM0nuDdd.js.map → login-DzDO0DVR.js.map} +1 -1
- prefect/server/ui-v2/assets/{markdown-input-CGOAnaWz.js → markdown-input-BYRT3e1M.js} +2 -2
- prefect/server/ui-v2/assets/{markdown-input-CGOAnaWz.js.map → markdown-input-BYRT3e1M.js.map} +1 -1
- prefect/server/ui-v2/assets/{python-example-snippet-CyJ28Tm-.js → python-example-snippet-BMLiEUYL.js} +3 -3
- prefect/server/ui-v2/assets/{python-example-snippet-CyJ28Tm-.js.map → python-example-snippet-BMLiEUYL.js.map} +1 -1
- prefect/server/ui-v2/assets/{python-input-D8_x22t4.js → python-input-xovZoSSG.js} +2 -2
- prefect/server/ui-v2/assets/{python-input-D8_x22t4.js.map → python-input-xovZoSSG.js.map} +1 -1
- prefect/server/ui-v2/assets/{radio-group-Dgu38qwz.js → radio-group-B4HH3BMW.js} +2 -2
- prefect/server/ui-v2/assets/{radio-group-Dgu38qwz.js.map → radio-group-B4HH3BMW.js.map} +1 -1
- prefect/server/ui-v2/assets/{route-error-state-CVHTggxQ.js → route-error-state-BI1VOaRa.js} +2 -2
- prefect/server/ui-v2/assets/{route-error-state-CVHTggxQ.js.map → route-error-state-BI1VOaRa.js.map} +1 -1
- prefect/server/ui-v2/assets/schema-form-DvPKoIJV.js +2 -0
- prefect/server/ui-v2/assets/schema-form-DvPKoIJV.js.map +1 -0
- prefect/server/ui-v2/assets/{schema-form-input-string-format-datetime-DuEmswz-.js → schema-form-input-string-format-datetime-FBLeet2k.js} +4 -4
- prefect/server/ui-v2/assets/{schema-form-input-string-format-datetime-DuEmswz-.js.map → schema-form-input-string-format-datetime-FBLeet2k.js.map} +1 -1
- prefect/server/ui-v2/assets/{settings-CtKmYnoo.js → settings-LiwgpMzF.js} +2 -2
- prefect/server/ui-v2/assets/{settings-CtKmYnoo.js.map → settings-LiwgpMzF.js.map} +1 -1
- prefect/server/ui-v2/assets/{sort-filter-BNQ6rjAG.js → sort-filter-BdZ0BjdE.js} +2 -2
- prefect/server/ui-v2/assets/{sort-filter-BNQ6rjAG.js.map → sort-filter-BdZ0BjdE.js.map} +1 -1
- prefect/server/ui-v2/assets/{table-CJS-5Aky.js → table--kjjs3jN.js} +2 -2
- prefect/server/ui-v2/assets/{table-CJS-5Aky.js.map → table--kjjs3jN.js.map} +1 -1
- prefect/server/ui-v2/assets/{tags-input-CDvuqe9B.js → tags-input-9pBchAz7.js} +2 -2
- prefect/server/ui-v2/assets/{tags-input-CDvuqe9B.js.map → tags-input-9pBchAz7.js.map} +1 -1
- prefect/server/ui-v2/assets/{task-run-concurrency-limits-reset-dialog-DMqNFEVn.js → task-run-concurrency-limits-reset-dialog-B3XhJqIQ.js} +2 -2
- prefect/server/ui-v2/assets/{task-run-concurrency-limits-reset-dialog-DMqNFEVn.js.map → task-run-concurrency-limits-reset-dialog-B3XhJqIQ.js.map} +1 -1
- prefect/server/ui-v2/assets/task-run._id-BdlPyINB.js +2 -0
- prefect/server/ui-v2/assets/{task-run._id-CiVsXKpy.js.map → task-run._id-BdlPyINB.js.map} +1 -1
- prefect/server/ui-v2/assets/{task-run._id-CV5t0LR0.js → task-run._id-BnZwcX9a.js} +3 -3
- prefect/server/ui-v2/assets/{task-run._id-CV5t0LR0.js.map → task-run._id-BnZwcX9a.js.map} +1 -1
- prefect/server/ui-v2/assets/task-runs-pagination-ClbepGWu.js +2 -0
- prefect/server/ui-v2/assets/{task-runs-pagination-DGjxL4DO.js.map → task-runs-pagination-ClbepGWu.js.map} +1 -1
- prefect/server/ui-v2/assets/{textarea-Mne2s-1n.js → textarea-CjmPCtZi.js} +2 -2
- prefect/server/ui-v2/assets/{textarea-Mne2s-1n.js.map → textarea-CjmPCtZi.js.map} +1 -1
- prefect/server/ui-v2/assets/{timezone-select-CPBtT8tA.js → timezone-select-5WxUFUXB.js} +2 -2
- prefect/server/ui-v2/assets/{timezone-select-CPBtT8tA.js.map → timezone-select-5WxUFUXB.js.map} +1 -1
- prefect/server/ui-v2/assets/{toggle-group-CvPe0UY1.js → toggle-group-DjbSsHsv.js} +2 -2
- prefect/server/ui-v2/assets/{toggle-group-CvPe0UY1.js.map → toggle-group-DjbSsHsv.js.map} +1 -1
- prefect/server/ui-v2/assets/{use-debounce-callback-Dcf0d0U7.js → use-debounce-callback-CVfZS_LP.js} +2 -2
- prefect/server/ui-v2/assets/{use-debounce-callback-Dcf0d0U7.js.map → use-debounce-callback-CVfZS_LP.js.map} +1 -1
- prefect/server/ui-v2/assets/{use-delete-automation-confirmation-dialog-DnRkM1Cj.js → use-delete-automation-confirmation-dialog-C7nas8eR.js} +2 -2
- prefect/server/ui-v2/assets/{use-delete-automation-confirmation-dialog-DnRkM1Cj.js.map → use-delete-automation-confirmation-dialog-C7nas8eR.js.map} +1 -1
- prefect/server/ui-v2/assets/{use-delete-block-document-confirmation-dialog-CMHtwDvb.js → use-delete-block-document-confirmation-dialog-Cz3znU4m.js} +2 -2
- prefect/server/ui-v2/assets/{use-delete-block-document-confirmation-dialog-CMHtwDvb.js.map → use-delete-block-document-confirmation-dialog-Cz3znU4m.js.map} +1 -1
- prefect/server/ui-v2/assets/{use-delete-confirmation-dialog-Bka9YDdO.js → use-delete-confirmation-dialog-C5d6hPL-.js} +2 -2
- prefect/server/ui-v2/assets/{use-delete-confirmation-dialog-Bka9YDdO.js.map → use-delete-confirmation-dialog-C5d6hPL-.js.map} +1 -1
- prefect/server/ui-v2/assets/{use-flow-runs-selected-rows-DB4pe2_m.js → use-flow-runs-selected-rows-B_7PiPKo.js} +2 -2
- prefect/server/ui-v2/assets/{use-flow-runs-selected-rows-DB4pe2_m.js.map → use-flow-runs-selected-rows-B_7PiPKo.js.map} +1 -1
- prefect/server/ui-v2/assets/{use-get-artifacts-flow-task-runs-DUPrB7V9.js → use-get-artifacts-flow-task-runs-BitcuQLc.js} +2 -2
- prefect/server/ui-v2/assets/{use-get-artifacts-flow-task-runs-DUPrB7V9.js.map → use-get-artifacts-flow-task-runs-BitcuQLc.js.map} +1 -1
- prefect/server/ui-v2/assets/{use-is-overflowing-Cc-Qm0vx.js → use-is-overflowing-CyVH32I2.js} +2 -2
- prefect/server/ui-v2/assets/{use-is-overflowing-Cc-Qm0vx.js.map → use-is-overflowing-CyVH32I2.js.map} +1 -1
- prefect/server/ui-v2/assets/{use-page-title-ELpQMkBC.js → use-page-title-CImKMV-D.js} +2 -2
- prefect/server/ui-v2/assets/{use-page-title-ELpQMkBC.js.map → use-page-title-CImKMV-D.js.map} +1 -1
- prefect/server/ui-v2/assets/use-quick-run-IfBGzpj9.js +2 -0
- prefect/server/ui-v2/assets/{use-quick-run-uAasMmAv.js.map → use-quick-run-IfBGzpj9.js.map} +1 -1
- prefect/server/ui-v2/assets/{use-state-favicon-CzOUYzQe.js → use-state-favicon-kNCf3RcS.js} +2 -2
- prefect/server/ui-v2/assets/{use-state-favicon-CzOUYzQe.js.map → use-state-favicon-kNCf3RcS.js.map} +1 -1
- prefect/server/ui-v2/assets/{use-stepper-DvHmfROo.js → use-stepper-DRdSNO1_.js} +2 -2
- prefect/server/ui-v2/assets/{use-stepper-DvHmfROo.js.map → use-stepper-DRdSNO1_.js.map} +1 -1
- prefect/server/ui-v2/assets/{utilities-XA-1-LhA.js → utilities-B74wofJY.js} +2 -2
- prefect/server/ui-v2/assets/{utilities-XA-1-LhA.js.map → utilities-B74wofJY.js.map} +1 -1
- prefect/server/ui-v2/assets/{vendor-codemirror-Dn73yRFx.js → vendor-codemirror-OTxfneaa.js} +2 -2
- prefect/server/ui-v2/assets/{vendor-codemirror-Dn73yRFx.js.map → vendor-codemirror-OTxfneaa.js.map} +1 -1
- prefect/server/ui-v2/assets/{vendor-date-Bxa7CHB1.js → vendor-date-CRz8gtWZ.js} +2 -2
- prefect/server/ui-v2/assets/{vendor-date-Bxa7CHB1.js.map → vendor-date-CRz8gtWZ.js.map} +1 -1
- prefect/server/ui-v2/assets/{vendor-forms-mroZAMaw.js → vendor-forms-D-iybWES.js} +2 -2
- prefect/server/ui-v2/assets/{vendor-forms-mroZAMaw.js.map → vendor-forms-D-iybWES.js.map} +1 -1
- prefect/server/ui-v2/assets/{vendor-markdown-BV905mMk.js → vendor-markdown-TdbL8FCd.js} +2 -2
- prefect/server/ui-v2/assets/{vendor-markdown-BV905mMk.js.map → vendor-markdown-TdbL8FCd.js.map} +1 -1
- prefect/server/ui-v2/assets/{vendor-radix-CP6hQtRc.js → vendor-radix-DRMjKWJW.js} +5 -5
- prefect/server/ui-v2/assets/{vendor-radix-CP6hQtRc.js.map → vendor-radix-DRMjKWJW.js.map} +1 -1
- prefect/server/ui-v2/assets/{vendor-recharts-BOcghvr2.js → vendor-recharts-BGjDGXVf.js} +2 -2
- prefect/server/ui-v2/assets/{vendor-recharts-BOcghvr2.js.map → vendor-recharts-BGjDGXVf.js.map} +1 -1
- prefect/server/ui-v2/assets/{vendor-tanstack-CLpbOGYv.js → vendor-tanstack-CWDKYA_B.js} +2 -2
- prefect/server/ui-v2/assets/{vendor-tanstack-CLpbOGYv.js.map → vendor-tanstack-CWDKYA_B.js.map} +1 -1
- prefect/server/ui-v2/assets/{work-pool-filter-D4DI4Hd5.js → work-pool-filter-BD0cywQF.js} +2 -2
- prefect/server/ui-v2/assets/{work-pool-filter-D4DI4Hd5.js.map → work-pool-filter-BD0cywQF.js.map} +1 -1
- prefect/server/ui-v2/assets/{work-pool-queue-toggle--tVsqhDi.js → work-pool-queue-toggle-Dd3mOecD.js} +2 -2
- prefect/server/ui-v2/assets/{work-pool-queue-toggle--tVsqhDi.js.map → work-pool-queue-toggle-Dd3mOecD.js.map} +1 -1
- prefect/server/ui-v2/assets/{work-pool._workPoolName-Ba0XSN4m.js → work-pool._workPoolName-Dxf0Y-lV.js} +2 -2
- prefect/server/ui-v2/assets/{work-pool._workPoolName-Ba0XSN4m.js.map → work-pool._workPoolName-Dxf0Y-lV.js.map} +1 -1
- prefect/server/ui-v2/assets/work-pool_._workPoolName.edit-B0Y9VwYX.js +2 -0
- prefect/server/ui-v2/assets/{work-pool_._workPoolName.edit-CeYLESXS.js.map → work-pool_._workPoolName.edit-B0Y9VwYX.js.map} +1 -1
- prefect/server/ui-v2/assets/{work-pool_._workPoolName.queue._workQueueName-CHvlnO-U.js → work-pool_._workPoolName.queue._workQueueName-ZHSn4vVg.js} +2 -2
- prefect/server/ui-v2/assets/{work-pool_._workPoolName.queue._workQueueName-CHvlnO-U.js.map → work-pool_._workPoolName.queue._workQueueName-ZHSn4vVg.js.map} +1 -1
- prefect/server/ui-v2/assets/{work-queue-icon-text-DnQAtUi_.js → work-queue-icon-text-GE7b8Ro1.js} +2 -2
- prefect/server/ui-v2/assets/{work-queue-icon-text-DnQAtUi_.js.map → work-queue-icon-text-GE7b8Ro1.js.map} +1 -1
- prefect/server/ui-v2/assets/{zod-cc-7bk3x.js → zod-CjGf5GIv.js} +2 -2
- prefect/server/ui-v2/assets/{zod-cc-7bk3x.js.map → zod-CjGf5GIv.js.map} +1 -1
- prefect/server/ui-v2/index.html +6 -6
- prefect/server/utilities/subscriptions.py +25 -8
- prefect/testing/fixtures.py +31 -1
- {prefect-3.6.14.dev3.dist-info → prefect-3.6.14.dev5.dist-info}/METADATA +2 -2
- {prefect-3.6.14.dev3.dist-info → prefect-3.6.14.dev5.dist-info}/RECORD +235 -235
- prefect/server/ui-v2/assets/automation._id-Bm1T3_NO.js +0 -2
- prefect/server/ui-v2/assets/block-type-logo-ox5VqJuy.js +0 -2
- prefect/server/ui-v2/assets/create-CiMo25er.js +0 -2
- prefect/server/ui-v2/assets/create-Da7OBOa5.js +0 -2
- prefect/server/ui-v2/assets/cronstrue-CeanGOEE.js +0 -2
- prefect/server/ui-v2/assets/cronstrue-CeanGOEE.js.map +0 -1
- prefect/server/ui-v2/assets/deployment-action-header-AamGn0qI.js +0 -2
- prefect/server/ui-v2/assets/deployment_._id.duplicate-DFjSeYn4.js +0 -2
- prefect/server/ui-v2/assets/deployment_._id.edit-5-mFOphJ.js +0 -2
- prefect/server/ui-v2/assets/flow-run._id-Caq--9Lr.js +0 -2
- prefect/server/ui-v2/assets/flow-run._id-DiA0_X5m.js +0 -2
- prefect/server/ui-v2/assets/index-BCKNs_w7.js +0 -2
- prefect/server/ui-v2/assets/index-BZqccBpn.js.map +0 -1
- prefect/server/ui-v2/assets/index-BijfHkUE.js +0 -2
- prefect/server/ui-v2/assets/index-CUJoNEgb.js +0 -2
- prefect/server/ui-v2/assets/index-CqvGvZOq.js +0 -2
- prefect/server/ui-v2/assets/schema-form-DqRLX--T.js +0 -2
- prefect/server/ui-v2/assets/schema-form-DqRLX--T.js.map +0 -1
- prefect/server/ui-v2/assets/task-run._id-CiVsXKpy.js +0 -2
- prefect/server/ui-v2/assets/task-runs-pagination-DGjxL4DO.js +0 -2
- prefect/server/ui-v2/assets/use-quick-run-uAasMmAv.js +0 -2
- prefect/server/ui-v2/assets/work-pool_._workPoolName.edit-CeYLESXS.js +0 -2
- {prefect-3.6.14.dev3.dist-info → prefect-3.6.14.dev5.dist-info}/WHEEL +0 -0
- {prefect-3.6.14.dev3.dist-info → prefect-3.6.14.dev5.dist-info}/entry_points.txt +0 -0
- {prefect-3.6.14.dev3.dist-info → prefect-3.6.14.dev5.dist-info}/licenses/LICENSE +0 -0
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import{j as e,r as m,s as L,L as Ue}from"./vendor-tanstack-CLpbOGYv.js";import{a as Be}from"./zod-cc-7bk3x.js";import{g as _,p as E,q as Qe,Z as Fe,c as ze}from"./vendor-forms-mroZAMaw.js";import{S as B,a as Q,b as z,c as J,d as De,dh as Je,e as G,p as X,al as re,b5 as Ge,br as He,ac as D,ad as R,ae as M,af as O,ah as W,ag as V,ai as F,aj as N,be as Ye,ab as ie,bN as Re,I as Z,M as me,d2 as Me,bm as Ke,bp as Xe,di as Ze,q as U,i as pe,aW as et,a_ as tt,ap as st,cP as xe,ak as ge,aq as je,aw as rt,ax as nt,ay as ve,az as Se,L as ot,C as at,o as lt,dj as ct}from"./index-BZqccBpn.js";import{b as w,c as S,d as b,e as y,a as k,F as it}from"./form-CdcF42XZ.js";import{u as ut,S as dt}from"./use-stepper-DvHmfROo.js";import{U as ee,T as Oe,A as ht}from"./automation-schema-CRKJHa4q.js";import{S as mt,R as pt,a as We,b as be,c as ft}from"./index-BfuGBXBN.js";import{T as Ve}from"./textarea-Mne2s-1n.js";import{R as xt,a as gt}from"./radio-group-Dgu38qwz.js";import{u as jt,C as vt,a as St,b as bt}from"./collapsible-D5U2XK4R.js";import{T as wt}from"./tags-input-CDvuqe9B.js";const we={"cancel-flow-run":"Cancel a flow run","suspend-flow-run":"Suspend a flow run","resume-flow-run":"Resume a flow run","change-flow-run-state":"Change flow run's state","run-deployment":"Run a deployment","pause-deployment":"Pause a deployment","resume-deployment":"Resume a deployment","pause-work-queue":"Pause a work queue","resume-work-queue":"Resume a work queue","pause-work-pool":"Pause a work pool","resume-work-pool":"Resume a work pool","pause-automation":"Pause an automation","resume-automation":"Resume an automation","send-notification":"Send a notification"},yt=({index:t})=>{const s=_();return e.jsx(w,{control:s.control,name:`actions.${t}.type`,render:({field:n})=>e.jsxs(S,{children:[e.jsx(b,{children:"Action Type"}),e.jsx(y,{children:e.jsxs(B,{...n,onValueChange:r=>{n.onChange(r);const l=Ct({index:t,type:r});l&&s.setValue(l,ee)},children:[e.jsx(Q,{"aria-label":"select action",className:"w-full",children:e.jsx(z,{placeholder:"Select action"})}),e.jsx(J,{children:e.jsxs(De,{children:[e.jsx(Je,{children:"Actions"}),Object.keys(we).map(r=>e.jsx(G,{value:r,children:we[r]},r))]})})]})})]})})};function Ct({index:t,type:s}){switch(s){case"run-deployment":case"pause-deployment":case"resume-deployment":return`actions.${t}.deployment_id`;case"pause-work-queue":case"resume-work-queue":return`actions.${t}.work_queue_id`;case"pause-work-pool":case"resume-work-pool":return`actions.${t}.work_pool_id`;case"pause-automation":case"resume-automation":return`actions.${t}.automation_id`;default:return null}}const Nt=({index:t})=>{const s=_(),n=s.watch(`actions.${t}.state`);return e.jsxs(e.Fragment,{children:[e.jsx(w,{control:s.control,name:`actions.${t}.state`,render:({field:r})=>e.jsxs(S,{children:[e.jsx(b,{children:"State"}),e.jsx(y,{children:e.jsx(mt,{value:r.value,onValueChange:r.onChange})}),e.jsx(k,{})]})}),e.jsx(w,{control:s.control,name:`actions.${t}.name`,render:({field:r})=>e.jsxs(S,{children:[e.jsx(b,{children:"Name"}),e.jsx(y,{children:e.jsx(X,{type:"text",...r,value:r.value??"",placeholder:n?pt[n]:void 0})}),e.jsx(k,{})]})}),e.jsx(w,{control:s.control,name:`actions.${t}.message`,render:({field:r})=>e.jsxs(S,{children:[e.jsx(b,{children:"Message"}),e.jsx(y,{children:e.jsx(Ve,{...r,placeholder:"State changed by Automation <id>"})}),e.jsx(k,{})]})})]})},ae=({action:t})=>{const s=t==="Resume"?"Resume a flow run inferred from the triggering event":`${t} flow run inferred from the triggering event`;return e.jsx(re,{variant:"bodySmall",className:"text-muted-foreground",children:s})},kt=4,te=({length:t=kt})=>Array.from({length:t},(s,n)=>e.jsx(Ge,{className:"mt-2 p-4 h-2 w-full"},n)),H={value:ee,name:"Infer Automation"},_t=(t,s)=>{if(s===H.value)return H.name;const n=t?.find(r=>r.id===s);if(n)return n.name},ye=({action:t,index:s})=>{const[n,r]=m.useState(""),l=_(),{data:o,isSuccess:a}=L(He()),h=m.useDeferredValue(n),p=m.useMemo(()=>o?o.filter(c=>c.name.toLowerCase().includes(h.toLowerCase())):[],[o,h]),u=H.name.toLowerCase().includes(h.toLowerCase());return e.jsx(w,{control:l.control,name:`actions.${s}.automation_id`,render:({field:c})=>{const f=_t(o,c.value);return e.jsxs(S,{className:"flex flex-col",children:[e.jsxs(b,{children:["Automation To ",t]}),e.jsxs(D,{children:[e.jsx(R,{selected:!!f,"aria-label":`Select Automation to ${t}`,children:f??"Select automation"}),e.jsxs(M,{children:[e.jsx(O,{value:n,onValueChange:r,placeholder:"Search for an automation..."}),e.jsx(W,{children:"No automation found"}),e.jsx(V,{children:e.jsxs(F,{children:[u&&e.jsx(N,{selected:c.value===H.value,onSelect:i=>{c.onChange(i),r("")},value:H.value,children:H.name}),a?p.map(i=>e.jsx(N,{selected:c.value===i.id,onSelect:d=>{c.onChange(d),r("")},value:i.id,children:i.name},i.id)):e.jsx(te,{})]})})]})]}),e.jsx(k,{})]})}})},Tt=(t={page:1,limit:100,sort:"NAME_ASC"})=>{const{data:s,status:n}=L(Ye(t)),r=new Set(s?.results.map(a=>a.flow_id)),{data:l,status:o}=L(ie({flows:{operator:"or_",id:{any_:Array.from(r)}},sort:"NAME_DESC",offset:0},{enabled:r.size>0}));return m.useMemo(()=>{if(l&&s){const a=new Map(l.map(d=>[d.id,d])),h=s.results.map(d=>({...d,flow:a.get(d.flow_id)})),{count:p,limit:u,pages:c,page:f}=s;return{data:{count:p,limit:u,pages:c,page:f,results:h},status:"success"}}return o==="error"||n==="error"?{data:void 0,status:"error"}:{data:void 0,status:"pending"}},[s,n,l,o])},q={value:ee,name:"Infer Deployment"},At=(t,s)=>{if(s===q.value)return q.name;const n=t?.find(r=>r.id===s);if(n)return e.jsx(Ie,{deploymentWithFlow:n})},le=({action:t,index:s})=>{const[n,r]=m.useState(""),l=_(),o=l.watch(`actions.${s}.type`),a=E({name:`actions.${s}.deployment_id`}),h=Re(n,500),{data:p}=Tt({page:1,sort:"NAME_ASC",deployments:{operator:"or_",flow_or_deployment_name:{like_:h}}}),u=q.name.toLowerCase().includes(n.toLowerCase()),c=p?.results;return e.jsxs(e.Fragment,{children:[e.jsx(w,{control:l.control,name:`actions.${s}.deployment_id`,render:({field:f})=>{const i=At(c,f.value);return e.jsxs(S,{className:"flex flex-col",children:[e.jsxs(b,{children:["Deployment To ",t]}),e.jsxs(D,{children:[e.jsx(R,{selected:!!i,"aria-label":`Select Deployment to ${t}`,children:i??"Select deployment"}),e.jsxs(M,{children:[e.jsx(O,{value:n,onValueChange:r,placeholder:"Search for an deployment..."}),e.jsx(W,{children:"No deployment found"}),e.jsx(V,{children:e.jsxs(F,{children:[u&&e.jsx(N,{selected:f.value===q.value,onSelect:f.onChange,value:q.value,children:q.name}),c?c.map(d=>e.jsx(N,{"aria-label":d.name,selected:f.value===d.id,onSelect:f.onChange,value:d.id,children:e.jsx(Ie,{deploymentWithFlow:d})},d.id)):e.jsx(te,{})]})})]})]}),e.jsx(k,{})]})}}),a!==q.value&&o==="run-deployment"&&e.jsx("div",{children:"TODO: Additional fields"})]})},Ie=({deploymentWithFlow:t})=>t.flow?e.jsxs("div",{className:"flex items-center gap-0.5",children:[e.jsx("div",{children:t.flow.name}),e.jsx(Z,{className:"size-4",id:"ChevronRight"}),e.jsx("div",{children:t.name})]}):t.name,Y={value:ee,name:"Infer Work Pool"},Et=(t,s)=>{if(s===Y.value)return Y.name;const n=t?.find(r=>r.id===s);if(n)return n.name},Ce=({action:t,index:s})=>{const[n,r]=m.useState(""),l=_(),{data:o,isSuccess:a}=L(me()),h=m.useDeferredValue(n),p=m.useMemo(()=>o?o.filter(c=>c.name.toLowerCase().includes(h.toLowerCase())):[],[o,h]),u=Y.name.toLowerCase().includes(h.toLowerCase());return e.jsx(w,{control:l.control,name:`actions.${s}.work_pool_id`,render:({field:c})=>{const f=Et(o,c.value);return e.jsxs(S,{className:"flex flex-col",children:[e.jsxs(b,{children:["Work Pool To ",t]}),e.jsxs(D,{children:[e.jsx(R,{selected:!!f,"aria-label":`Select Work Pool to ${t}`,children:f??"Select Work Pool"}),e.jsxs(M,{children:[e.jsx(O,{value:n,onValueChange:r,placeholder:"Search for a work pool..."}),e.jsx(W,{children:"No work pool found"}),e.jsx(V,{children:e.jsxs(F,{children:[u&&e.jsx(N,{selected:c.value===Y.value,onSelect:i=>{c.onChange(i),r("")},value:Y.value,children:Y.name}),a?p.map(i=>e.jsx(N,{selected:c.value===i.id,onSelect:d=>{c.onChange(d),r("")},value:i.id,children:i.name},i.id)):e.jsx(te,{})]})})]})]}),e.jsx(k,{})]})}})},K={value:ee,name:"Infer Work Queue"},Lt=(t,s)=>{if(s===K.value)return K.name;const n=t?.find(r=>r.id===s);if(n)return n.name},Ne=({action:t,index:s})=>{const[n,r]=m.useState(""),l=_(),{data:o}=L(Me()),a=m.useDeferredValue(n),h=m.useMemo(()=>{if(!o)return;const u=new Map,c=o.filter(f=>f.name.toLowerCase().includes(a.toLowerCase()));for(const f of c){const{work_pool_name:i}=f;if(!i)throw new Error("'work_pool_name expected");u.set(i,[...u.get(i)??[],f])}return u},[o,a]),p=K.name.toLowerCase().includes(a.toLowerCase());return e.jsx(w,{control:l.control,name:`actions.${s}.work_queue_id`,render:({field:u})=>{const c=Lt(o,u.value);return e.jsxs(S,{className:"flex flex-col",children:[e.jsxs(b,{children:["Work Queue To ",t]}),e.jsxs(D,{children:[e.jsx(R,{selected:!!c,"aria-label":`Select Work Queue to ${t}`,children:c??"Select Work Queue"}),e.jsxs(M,{children:[e.jsx(O,{value:n,onValueChange:r,placeholder:"Search for a work queue..."}),e.jsx(W,{children:"No work queue found"}),e.jsx(V,{children:e.jsxs(F,{children:[p&&e.jsx(N,{selected:u.value===K.value,onSelect:f=>{u.onChange(f),r("")},value:K.value,children:K.name}),h?Array.from(h).map(([f,i])=>e.jsxs("div",{className:"border-b",children:[e.jsx(N,{disabled:!0,children:f}),i.map(d=>e.jsx(N,{selected:u.value===d.id,onSelect:g=>{u.onChange(g),r("")},value:d.id,children:d.name},d.id))]},f)):e.jsx(te,{})]})})]})]}),e.jsx(k,{})]})}})},Ft=({index:t})=>{const s=_(),[n,r]=m.useState(""),{data:l,isLoading:o}=L(Ke({offset:0,block_schemas:{operator:"and_",block_capabilities:{all_:["notify"]}}})),a=m.useMemo(()=>l?.map(d=>d.slug)??[],[l]),{data:h,isLoading:p}=L(Xe({block_types:a.length>0?{slug:{any_:a}}:void 0,include_secrets:!1,sort:"BLOCK_TYPE_AND_NAME_ASC",offset:0},{enabled:a.length>0})),u=o||p,c=m.useMemo(()=>!l||!h?[]:l.map(d=>({blockType:d,documents:h.filter(g=>g.block_type_id===d.id)})).filter(d=>d.documents.length>0),[l,h]),f=m.useMemo(()=>{if(!n)return c;const d=n.toLowerCase();return c.map(g=>({...g,documents:g.documents.filter(v=>v.name?.toLowerCase().includes(d))})).filter(g=>g.documents.length>0)},[c,n]),i=m.useCallback(d=>{if(!(!d||!h))return h.find(g=>g.id===d)},[h]);return e.jsxs("div",{className:"space-y-4",children:[e.jsx(w,{control:s.control,name:`actions.${t}.block_document_id`,render:({field:d})=>{const g=i(d.value);return e.jsxs(S,{className:"flex flex-col",children:[e.jsx(b,{children:"Block"}),e.jsxs(D,{children:[e.jsx(R,{selected:!!g,"aria-label":"Select notification block",children:g?g.name:"Select a notification block"}),e.jsxs(M,{children:[e.jsx(O,{value:n,onValueChange:r,placeholder:"Search for a block..."}),e.jsx(W,{children:"No notification blocks found"}),e.jsx(V,{children:u?e.jsx(te,{}):f.map(v=>e.jsx(F,{heading:v.blockType.name,children:v.documents.map(I=>e.jsx(N,{value:I.id,selected:d.value===I.id,onSelect:d.onChange,children:I.name},I.id))},v.blockType.id))})]})]}),e.jsx(k,{})]})}}),e.jsx(ke,{index:t,name:"subject",label:"Subject",placeholder:"Enter notification subject..."}),e.jsx(ke,{index:t,name:"body",label:"Body",placeholder:"Enter notification body...",multiline:!0}),e.jsxs("div",{className:"flex items-start gap-2 rounded-md border border-blue-200 bg-blue-50 p-3 text-sm text-blue-800 dark:border-blue-800 dark:bg-blue-950 dark:text-blue-200",children:[e.jsx(Z,{id:"Info",className:"mt-0.5 size-4 shrink-0"}),e.jsxs("p",{children:["In addition to any fields present on the triggering event, the following objects can be used in notification templates:"," ",e.jsx("code",{className:"rounded bg-blue-100 px-1 py-0.5 font-mono text-xs dark:bg-blue-900",children:"flow"}),","," ",e.jsx("code",{className:"rounded bg-blue-100 px-1 py-0.5 font-mono text-xs dark:bg-blue-900",children:"deployment"}),","," ",e.jsx("code",{className:"rounded bg-blue-100 px-1 py-0.5 font-mono text-xs dark:bg-blue-900",children:"flow_run"}),","," ",e.jsx("code",{className:"rounded bg-blue-100 px-1 py-0.5 font-mono text-xs dark:bg-blue-900",children:"work_pool"}),","," ",e.jsx("code",{className:"rounded bg-blue-100 px-1 py-0.5 font-mono text-xs dark:bg-blue-900",children:"work_queue"}),", and"," ",e.jsx("code",{className:"rounded bg-blue-100 px-1 py-0.5 font-mono text-xs dark:bg-blue-900",children:"metric"}),"."]})]})]})},ke=({index:t,name:s,label:n,placeholder:r,multiline:l=!1})=>{const o=_(),{validateTemplate:a}=Ze(),[h,p]=m.useState(null),[u,c]=m.useState(!1),f=o.watch(`actions.${t}.${s}`),i=Re(f,1e3);m.useEffect(()=>{(async()=>{if(!i||i.trim()===""){p(null);return}c(!0);try{const v=await a(i);v.valid?p(null):p(v.error)}catch{p(null)}finally{c(!1)}})()},[i,a]);const d=l?Ve:X;return e.jsx(w,{control:o.control,name:`actions.${t}.${s}`,render:({field:g})=>e.jsxs(S,{children:[e.jsxs(b,{className:"flex items-center gap-2",children:[n,u&&e.jsx(Z,{id:"Loader2",className:"size-3 animate-spin"})]}),e.jsx(y,{children:e.jsx(d,{...g,value:g.value??"",placeholder:r,className:h?"border-destructive":""})}),h&&e.jsx("p",{className:"text-sm text-destructive",children:h}),e.jsx(k,{})]})})},Dt=({index:t,onRemove:s})=>e.jsxs("div",{className:"space-y-2",children:[e.jsxs("div",{className:"flex justify-between items-center",children:[e.jsxs(re,{variant:"body",className:"font-semibold",children:["Action ",t+1]}),e.jsx(U,{size:"icon","aria-label":`remove action ${t+1}`,onClick:s,variant:"outline",children:e.jsx(Z,{id:"Trash2",className:"size-4"})})]}),e.jsx(yt,{index:t}),e.jsx(Rt,{index:t}),e.jsx("hr",{className:"my-8"})]},t),Rt=({index:t})=>{switch(E({name:`actions.${t}.type`})){case"change-flow-run-state":return e.jsx(Nt,{index:t});case"run-deployment":return e.jsx(le,{action:"Run",index:t});case"pause-deployment":return e.jsx(le,{action:"Pause",index:t});case"resume-deployment":return e.jsx(le,{action:"Resume",index:t});case"pause-work-queue":return e.jsx(Ne,{action:"Pause",index:t});case"resume-work-queue":return e.jsx(Ne,{action:"Resume",index:t});case"pause-work-pool":return e.jsx(Ce,{action:"Pause",index:t});case"resume-work-pool":return e.jsx(Ce,{action:"Resume",index:t});case"pause-automation":return e.jsx(ye,{action:"Pause",index:t});case"resume-automation":return e.jsx(ye,{action:"Resume",index:t});case"send-notification":return e.jsx(Ft,{index:t});case"cancel-flow-run":return e.jsx(ae,{action:"Cancel"});case"suspend-flow-run":return e.jsx(ae,{action:"Suspend"});case"resume-flow-run":return e.jsx(ae,{action:"Resume"});default:return null}},Mt=()=>{const t=_(),{fields:s,append:n,remove:r}=Qe({control:t.control,name:"actions",shouldUnregister:!1,rules:{minLength:1}});return e.jsxs("div",{children:[s.map(({id:l},o)=>e.jsx(Dt,{index:o,onRemove:()=>r(o)},l)),e.jsxs(U,{type:"button",variant:"outline",onClick:()=>n({type:"cancel-flow-run"}),children:[e.jsx(Z,{id:"Plus",className:"mr-2 size-4"})," Add Action"]})]})},Ot=()=>{const t=_();return e.jsxs("div",{className:"flex flex-col gap-4",children:[e.jsx(w,{control:t.control,name:"name",render:({field:s})=>e.jsxs(S,{children:[e.jsx(b,{children:"Automation Name"}),e.jsx(y,{children:e.jsx(X,{type:"text",...s,value:s.value??""})}),e.jsx(k,{})]})}),e.jsx(w,{control:t.control,name:"description",render:({field:s})=>e.jsxs(S,{children:[e.jsx(b,{children:"Description (Optional)"}),e.jsx(y,{children:e.jsx(X,{type:"text",...s,value:s.value??""})}),e.jsx(k,{})]})})]})},Wt=[{value:"Reactive",label:"Observe"},{value:"Proactive",label:"Don't observe"}],Vt=30,It=()=>{const t=_(),s=n=>{const r=t.getValues("trigger.posture");if(t.setValue("trigger.posture",n),r==="Reactive"&&n==="Proactive"){const l=t.getValues("trigger.expect")??[];t.setValue("trigger.after",l),t.setValue("trigger.expect",[]),t.getValues("trigger.within")===0&&t.setValue("trigger.within",Vt)}else if(r==="Proactive"&&n==="Reactive"){const l=t.getValues("trigger.after")??[];t.setValue("trigger.expect",l),t.setValue("trigger.after",[])}};return e.jsx(w,{control:t.control,name:"trigger.posture",render:({field:n})=>e.jsxs(S,{children:[e.jsx(b,{children:"When I"}),e.jsx(y,{children:e.jsx(xt,{value:n.value,onValueChange:s,className:"flex gap-4",children:Wt.map(r=>e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(gt,{value:r.value,id:`custom-${r.value}`}),e.jsx(pe,{htmlFor:`custom-${r.value}`,children:r.label})]},r.value))})})]})})},ue=60,de=3600,he=86400,Pt=[{label:"Seconds",value:1},{label:"Minutes",value:ue},{label:"Hours",value:de},{label:"Days",value:he}];function $t(t){return t>0&&t%he===0?he:t>0&&t%de===0?de:t>0&&t%ue===0?ue:1}function se({value:t,onChange:s,min:n=0,max:r,className:l,disabled:o=!1}){const[a,h]=m.useState(()=>$t(t)),p=m.useMemo(()=>Pt.filter(i=>i.value>=n),[n]),u=m.useMemo(()=>t/a,[t,a]),c=m.useCallback(i=>{let d=i*a;r!==void 0&&d>r&&(d=r),s(d)},[s,a,r]),f=m.useCallback(i=>{const d=Number(i),g=a;h(d);let v=t/g*d;r!==void 0&&v>r&&(v=r),s(v)},[s,a,t,r]);return m.useEffect(()=>{if(!p.some(i=>i.value===a)){const i=p[0];i&&h(i.value)}},[p,a]),e.jsxs("div",{className:et("grid grid-cols-[1fr_7rem] gap-2 w-full",l),children:[e.jsx(X,{type:"number",min:0,value:u,onChange:i=>c(Number(i.target.value)),disabled:o,"aria-label":"Duration quantity"}),e.jsxs(B,{value:String(a),onValueChange:f,disabled:o,children:[e.jsx(Q,{"aria-label":"Duration unit",children:e.jsx(z,{})}),e.jsx(J,{children:p.map(i=>e.jsx(G,{value:String(i.value),children:i.label},i.value))})]})]})}const qt=2,Ut=40;function _e({selectedResourceIds:t,onToggleResource:s,emptyMessage:n="All resources"}){const[r,l]=m.useState(""),o=m.useDeferredValue(r),[a,h]=m.useState(0),p=m.useRef(null),u=m.useRef(null);m.useEffect(()=>{const x=p.current;if(!x)return;const j=new ResizeObserver(C=>{for(const T of C)h(T.contentRect.width)});return j.observe(x),()=>j.disconnect()},[]);const{resourceOptions:c}=jt(),f=m.useMemo(()=>{const x=[{label:"Automations",options:[]},{label:"Blocks",options:[]},{label:"Deployments",options:[]},{label:"Flows",options:[]},{label:"Work Pools",options:[]},{label:"Work Queues",options:[]}];for(const j of c){const C={label:j.name,value:j.resourceId};switch(j.type){case"automation":x[0].options.push(C);break;case"block":x[1].options.push(C);break;case"deployment":x[2].options.push(C);break;case"flow":x[3].options.push(C);break;case"work-pool":x[4].options.push(C);break;case"work-queue":x[5].options.push(C);break}}return x.map(j=>({...j,options:j.options.sort((C,T)=>C.label.localeCompare(T.label))})).filter(j=>j.options.length>0)},[c]),i=m.useMemo(()=>{if(!o)return f;const x=o.toLowerCase();return f.map(j=>({...j,options:j.options.filter(C=>C.label.toLowerCase().includes(x)||C.value.toLowerCase().includes(x))})).filter(j=>j.options.length>0)},[f,o]),d=m.useMemo(()=>{if(!o.trim()||!o.includes("."))return!1;const x=o.toLowerCase();return!c.some(j=>j.resourceId.toLowerCase()===x)},[o,c]),g=m.useCallback(x=>{const j=u.current;if(!j||a===0||x.length===0)return Math.min(x.length,qt);const C=x.length>1?a-Ut:a;let T=0;for(let A=0;A<x.length&&(j.textContent=x.slice(0,A+1).join(", "),j.offsetWidth<=C);A++)T=A+1;return T===x.length?x.length:Math.max(1,T)},[a]),v=()=>{if(t.length===0)return e.jsx("span",{className:"text-muted-foreground",children:n});const x=t.map(A=>c.find(qe=>qe.resourceId===A)?.name??A),j=g(x),C=x.slice(0,j),T=x.length-j;return e.jsxs("div",{ref:p,className:"flex flex-1 min-w-0 items-center gap-2",children:[e.jsx("div",{className:"flex flex-1 min-w-0 items-center gap-2 overflow-hidden",children:e.jsx("span",{className:"truncate",children:C.join(", ")})}),T>0&&e.jsxs(re,{variant:"bodySmall",className:"shrink-0",children:["+ ",T]}),e.jsx("div",{ref:u,className:"absolute invisible whitespace-nowrap","aria-hidden":"true"})]})},I=x=>{s(x),l("")};return e.jsxs(D,{children:[e.jsx(R,{selected:t.length>0,children:v()}),e.jsxs(M,{children:[e.jsx(O,{value:r,onValueChange:l,placeholder:"Search resources..."}),e.jsxs(V,{children:[e.jsx(W,{children:"No resources found"}),d&&e.jsx(F,{children:e.jsxs(N,{selected:t.includes(o),onSelect:()=>I(o),closeOnSelect:!1,value:o,children:['Add "',o,'"']},"__custom__")}),i.map(x=>e.jsx(F,{heading:x.label,children:x.options.map(j=>e.jsx(N,{selected:t.includes(j.value),onSelect:()=>I(j.value),closeOnSelect:!1,value:j.value,children:j.label},j.value))},x.label))]})]})]})}function Bt(t){const s=new Map;for(const n of t){const r=n.split(".");for(let l=1;l<r.length;l++){const o=r.slice(0,l).join(".");s.set(o,(s.get(o)??0)+1)}}return Array.from(s.entries()).filter(([,n])=>n>1&&n<t.length).map(([n])=>`${n}.*`)}function Te({selectedEvents:t,onToggleEvent:s,emptyMessage:n="All events"}){const[r,l]=m.useState(""),o=m.useDeferredValue(r),[a]=m.useState(()=>({since:new Date(Date.now()-10080*60*1e3).toISOString(),until:new Date().toISOString()})),{data:h=[]}=L(tt("event",{filter:{occurred:a,order:"DESC"},time_unit:"day",time_interval:1})),p=m.useMemo(()=>{const d=h.map(v=>v.label),g=Bt(d);return[...d,...g].sort((v,I)=>v.localeCompare(I))},[h]),u=m.useMemo(()=>{if(!o)return p;const d=o.toLowerCase();return p.filter(g=>g.toLowerCase().includes(d))},[p,o]),c=m.useMemo(()=>{if(!o.trim())return!1;const d=o.toLowerCase();return!p.some(g=>g.toLowerCase()===d)},[o,p]),f=()=>{if(t.length===0)return e.jsx("span",{className:"text-muted-foreground",children:n});const d=t.slice(0,2),g=t.length-d.length;return e.jsxs("div",{className:"flex min-w-0 items-center justify-start gap-1",children:[e.jsx("span",{className:"truncate min-w-0 text-left",children:d.join(", ")}),g>0&&e.jsxs("span",{className:"shrink-0 text-muted-foreground",children:["+",g]})]})},i=d=>{s(d),l("")};return e.jsxs(D,{children:[e.jsx(R,{selected:t.length>0,children:f()}),e.jsxs(M,{children:[e.jsx(O,{value:r,onValueChange:l,placeholder:"Search events..."}),e.jsxs(V,{children:[e.jsx(W,{children:"No events found"}),e.jsxs(F,{children:[c&&e.jsxs(N,{selected:t.includes(o),onSelect:()=>i(o),closeOnSelect:!1,value:o,children:['Add "',o,'"']},"__custom__"),u.map(d=>e.jsx(N,{selected:t.includes(d),onSelect:()=>i(d),closeOnSelect:!1,value:d,children:d},d))]})]})]})]})}const Qt=()=>{const t=_(),s=E({name:"trigger.posture"});return e.jsxs("div",{className:"space-y-4",children:[e.jsx("div",{className:"flex items-end gap-4",children:e.jsx(It,{})}),e.jsx(w,{control:t.control,name:"trigger.expect",render:({field:n})=>{const r=n.value??[];return e.jsxs(S,{children:[e.jsx(b,{children:"Any event matching"}),e.jsx(y,{children:e.jsx(Te,{selectedEvents:r,onToggleEvent:l=>{const o=r.includes(l)?r.filter(a=>a!==l):[...r,l];n.onChange(o)}})}),e.jsx(k,{})]})}}),e.jsx(w,{control:t.control,name:"trigger.match",render:({field:n})=>{const r=n.value?.["prefect.resource.id"]??[],l=Array.isArray(r)?r:[r];return e.jsxs(S,{children:[e.jsx(b,{children:"From the following resources"}),e.jsx(y,{children:e.jsx(_e,{selectedResourceIds:l,onToggleResource:o=>{const a=l.includes(o)?l.filter(h=>h!==o):[...l,o];a.length>0?n.onChange({"prefect.resource.id":a}):n.onChange({})}})}),e.jsx(k,{})]})}}),e.jsxs("div",{className:"flex items-end gap-2",children:[e.jsx(w,{control:t.control,name:"trigger.threshold",render:({field:n})=>e.jsxs(S,{className:"w-20",children:[e.jsx(y,{children:e.jsx(X,{type:"number",min:1,...n,onChange:r=>n.onChange(Number(r.target.value))})}),e.jsx(k,{})]})}),e.jsx("span",{className:"pb-2 text-sm text-muted-foreground",children:"times within"}),e.jsx(w,{control:t.control,name:"trigger.within",render:({field:n})=>e.jsxs(S,{children:[e.jsx(y,{children:e.jsx(se,{value:n.value??0,onChange:n.onChange,min:s==="Proactive"?10:0})}),e.jsx(k,{})]})})]}),e.jsxs(vt,{children:[e.jsxs(St,{className:"flex items-center gap-2 text-sm font-medium",children:[e.jsx(st,{className:"h-4 w-4 transition-transform data-[state=open]:rotate-90"}),"Evaluation Options"]}),e.jsxs(bt,{className:"mt-4 space-y-4 pl-6",children:[e.jsx(w,{control:t.control,name:"trigger.after",render:({field:n})=>{const r=n.value??[];return e.jsxs(S,{children:[e.jsx(b,{children:"Evaluate trigger only after observing an event matching"}),e.jsx(y,{children:e.jsx(Te,{selectedEvents:r,onToggleEvent:l=>{const o=r.includes(l)?r.filter(a=>a!==l):[...r,l];n.onChange(o)}})}),e.jsx(k,{})]})}}),e.jsx(w,{control:t.control,name:"trigger.match_related",render:({field:n})=>{const r=n.value?.["prefect.resource.id"]??[],l=Array.isArray(r)?r:[r];return e.jsxs(S,{children:[e.jsx(b,{children:"Filter for events related to"}),e.jsx(y,{children:e.jsx(_e,{selectedResourceIds:l,onToggleResource:o=>{const a=l.includes(o)?l.filter(h=>h!==o):[...l,o];a.length>0?n.onChange({"prefect.resource.id":a}):n.onChange({})}})}),e.jsx(k,{})]})}})]})]})]})},zt=2,Jt=40,Gt=({selectedDeploymentIds:t,onSelectDeploymentIds:s})=>{const[n,r]=m.useState(""),l=m.useDeferredValue(n),[o,a]=m.useState(0),h=m.useRef(null),p=m.useRef(null),u=m.useMemo(()=>new Set(t),[t]);m.useEffect(()=>{const x=h.current;if(!x)return;const j=new ResizeObserver(C=>{for(const T of C)a(T.contentRect.width)});return j.observe(x),()=>j.disconnect()},[]);const{data:c=[]}=L(xe({deployments:l?{operator:"and_",name:{like_:l}}:void 0,limit:100,offset:0,sort:"NAME_ASC"})),{data:f=[]}=L(xe({deployments:u.size>0?{operator:"and_",id:{any_:t}}:void 0,limit:u.size||1,offset:0,sort:"NAME_ASC"},{enabled:u.size>0})),i=x=>{const j=new Set(u);u.has(x)?j.delete(x):j.add(x),s(Array.from(j))},d=()=>{s([])},g=m.useCallback(x=>{const j=p.current;if(!j||o===0||x.length===0)return Math.min(x.length,zt);const C=x.length>1?o-Jt:o;let T=0;for(let A=0;A<x.length&&(j.textContent=x.slice(0,A+1).join(", "),j.offsetWidth<=C);A++)T=A+1;return T===x.length?x.length:Math.max(1,T)},[o]),v=()=>{if(u.size===0)return"All deployments";const x=f.filter(A=>u.has(A.id)).map(A=>A.name),j=g(x),C=x.slice(0,j),T=x.length-j;return e.jsxs("div",{ref:h,className:"flex flex-1 min-w-0 items-center gap-2",children:[e.jsx("div",{className:"flex flex-1 min-w-0 items-center gap-2 overflow-hidden",children:e.jsx("span",{className:"truncate",children:C.join(", ")})}),T>0&&e.jsxs(re,{variant:"bodySmall",className:"shrink-0",children:["+ ",T]}),e.jsx("div",{ref:p,className:"absolute invisible whitespace-nowrap","aria-hidden":"true"})]})},I=m.useMemo(()=>c.filter(x=>!l||x.name.toLowerCase().includes(l.toLowerCase())),[c,l]);return e.jsxs(D,{children:[e.jsx(R,{"aria-label":"Select deployments",selected:u.size===0,children:v()}),e.jsxs(M,{children:[e.jsx(O,{value:n,onValueChange:r,placeholder:"Search deployments..."}),e.jsxs(V,{children:[e.jsx(W,{children:"No deployments found"}),e.jsxs(F,{children:[e.jsxs(N,{"aria-label":"All deployments",onSelect:d,closeOnSelect:!1,value:"__all__",children:[e.jsx(ge,{checked:u.size===0}),"All deployments"]}),I.map(x=>e.jsxs(N,{"aria-label":x.name,onSelect:()=>i(x.id),closeOnSelect:!1,value:x.id,children:[e.jsx(ge,{checked:u.has(x.id)}),x.name]},x.id))]})]})]})]})},Ht=[{value:"Reactive",label:"Enters"},{value:"Proactive",label:"Stays in"}],Yt=30,ne=()=>{const t=_();return e.jsx(w,{control:t.control,name:"trigger.posture",render:({field:s})=>e.jsx(S,{children:e.jsx(y,{children:e.jsxs(B,{value:s.value,onValueChange:n=>{const r=s.value;if(s.onChange(n),r==="Reactive"&&n==="Proactive"){const l=t.getValues("trigger.expect")??[];t.setValue("trigger.after",l),t.setValue("trigger.expect",[]),t.getValues("trigger.within")===0&&t.setValue("trigger.within",Yt)}else if(r==="Proactive"&&n==="Reactive"){const l=t.getValues("trigger.after")??[];t.setValue("trigger.expect",l),t.setValue("trigger.after",[])}},children:[e.jsx(Q,{"aria-label":"select posture",className:"w-[160px]",children:e.jsx(z,{placeholder:"Select posture"})}),e.jsx(J,{children:Ht.map(n=>e.jsx(G,{value:n.value,children:n.label},n.value))})]})})})})},Kt=86400,Xt=30*Kt,Zt=[{value:"prefect.deployment.ready",label:"Ready"},{value:"prefect.deployment.not-ready",label:"Not Ready"},{value:"prefect.deployment.disabled",label:"Disabled"}],Pe="prefect.deployment.",$e="prefect.deployment.*",es=t=>t?(Array.isArray(t)?t:[t]).filter(n=>n!==$e).map(n=>n.replace(Pe,"")):[],ts=t=>t.length===0?$e:t.map(s=>`${Pe}${s}`),ss=()=>{const t=_(),s=E({name:"trigger.posture"}),n=E({name:"trigger.match"}),r=m.useMemo(()=>{const a=n?.["prefect.resource.id"];return es(a)},[n]),l=m.useCallback(o=>{const a=t.getValues("trigger.match")??{};t.setValue("trigger.match",{...a,"prefect.resource.id":ts(o)})},[t]);return e.jsxs("div",{className:"space-y-4",children:[e.jsxs(S,{children:[e.jsx(b,{children:"Deployments"}),e.jsx(y,{children:e.jsx(Gt,{selectedDeploymentIds:r,onSelectDeploymentIds:l})})]}),e.jsxs(S,{children:[e.jsx(b,{children:"Deployment"}),e.jsxs("div",{className:"grid gap-2",style:{gridTemplateColumns:"10rem 1fr"},children:[e.jsx(ne,{}),e.jsx(w,{control:t.control,name:"trigger.expect",render:({field:o})=>{const a=o.value?.[0];return e.jsxs(B,{value:a??"",onValueChange:h=>o.onChange([h]),children:[e.jsx(Q,{className:"w-full",children:e.jsx(z,{placeholder:"Select status"})}),e.jsx(J,{children:Zt.map(h=>e.jsx(G,{value:h.value,children:h.label},h.value))})]})}})]})]}),s==="Proactive"&&e.jsx(w,{control:t.control,name:"trigger.within",render:({field:o})=>e.jsxs(S,{children:[e.jsx(b,{children:"Within"}),e.jsx(y,{children:e.jsx(se,{value:o.value??0,onChange:o.onChange,min:10,max:Xt})}),e.jsx(k,{})]})})]})},rs=2;function ns({selectedFlowIds:t,onToggleFlow:s,emptyMessage:n="Any flow"}){const[r,l]=m.useState(""),o=m.useDeferredValue(r),{data:a=[]}=L(ie({flows:o?{operator:"and_",name:{like_:o}}:void 0,limit:100,offset:0,sort:"NAME_ASC"})),{data:h=[]}=L(ie({flows:t.length>0?{operator:"and_",id:{any_:t}}:void 0,limit:t.length||1,offset:0,sort:"NAME_ASC"},{enabled:t.length>0})),p=m.useMemo(()=>a.filter(c=>!o||c.name.toLowerCase().includes(o.toLowerCase())),[a,o]),u=()=>{if(t.length===0)return e.jsx("span",{className:"text-muted-foreground",children:n});const f=h.filter(d=>t.includes(d.id)).map(d=>d.name).slice(0,rs),i=t.length-f.length;return e.jsxs("div",{className:"flex min-w-0 items-center justify-start gap-1",children:[e.jsx("span",{className:"truncate min-w-0 text-left",children:f.join(", ")}),i>0&&e.jsxs("span",{className:"shrink-0 text-muted-foreground",children:["+",i]})]})};return e.jsxs(D,{children:[e.jsx(R,{selected:t.length>0,children:u()}),e.jsxs(M,{children:[e.jsx(O,{value:r,onValueChange:l,placeholder:"Search flows..."}),e.jsxs(V,{children:[e.jsx(W,{children:"No flows found"}),e.jsx(F,{children:p.map(c=>e.jsx(N,{selected:t.includes(c.id),onSelect:()=>{s(c.id),l("")},closeOnSelect:!1,value:c.id,children:c.name},c.id))})]})]})]})}const P="All run states",$="All except scheduled";function os(t){return t.length!==We.length-1?!1:!t.includes("Scheduled")}function as({selectedStates:t,onStateChange:s,emptyMessage:n="Any state"}){const[r,l]=m.useState(""),o=m.useDeferredValue(r),a=m.useMemo(()=>t.length===0?P:os(t)?$:t,[t]),h=m.useMemo(()=>{const i=o.toLowerCase();return We.filter(d=>d.toLowerCase().includes(i))},[o]),p=m.useMemo(()=>{const i=o.toLowerCase();return P.toLowerCase().includes(i)||$.toLowerCase().includes(i)},[o]),u=i=>{i===P?s([]):i===$&&s([...ft]),l("")},c=i=>{t.includes(i)?s(t.filter(d=>d!==i)):s([...t,i]),l("")},f=()=>a===P?e.jsx("span",{className:"text-muted-foreground",children:n}):a===$?e.jsx("span",{children:"All except scheduled"}):e.jsx("div",{className:"flex flex-wrap gap-1",children:t.map(i=>e.jsx(je,{type:be[i],name:i,className:"cursor-pointer"},i))});return e.jsxs(D,{children:[e.jsx(R,{selected:t.length>0,children:f()}),e.jsxs(M,{children:[e.jsx(O,{value:r,onValueChange:l,placeholder:"Search states..."}),e.jsx(W,{children:"No state found"}),e.jsx(V,{children:e.jsxs(F,{children:[p&&e.jsxs(e.Fragment,{children:[e.jsx(N,{selected:a===P,onSelect:()=>u(P),value:P,closeOnSelect:!1,children:"All run states"},P),e.jsx(N,{selected:a===$,onSelect:()=>u($),value:$,closeOnSelect:!1,children:"All except scheduled"},$)]}),h.map(i=>e.jsx(N,{selected:t.includes(i),onSelect:()=>c(i),value:i,closeOnSelect:!1,children:e.jsx(je,{type:be[i],name:i})},i))]})})]})]})}function ls(t){return t.length===0?["prefect.flow-run.*"]:t.map(s=>`prefect.flow-run.${s}`)}function cs(t){return!t||t.length===0?[]:t.includes("prefect.flow-run.*")?[]:t.filter(s=>s.startsWith("prefect.flow-run.")).map(s=>s.replace("prefect.flow-run.",""))}function is(t){if(!t)return[];const s=t["prefect.resource.id"];return s?(Array.isArray(s)?s:[s]).filter(r=>r.startsWith("prefect.flow.")).map(r=>r.replace("prefect.flow.","")):[]}function us(t){if(!t)return[];const s=t["prefect.resource.id"];return s?(Array.isArray(s)?s:[s]).filter(r=>r.startsWith("prefect.tag.")).map(r=>r.replace("prefect.tag.","")):[]}function Ae(t,s){const n=t.map(a=>`prefect.flow.${a}`),r=s.map(a=>`prefect.tag.${a}`);if(n.length===0&&r.length===0)return{};const l=n.length>0?"flow":"tag",o=[...n,...r];return{"prefect.resource.role":l,"prefect.resource.id":o}}const ds=()=>{const t=_(),s=E({name:"trigger.posture"}),n=s==="Proactive"?"trigger.after":"trigger.expect",r=E({name:"trigger.match_related"}),l=is(r),o=us(r),a=u=>{const c=l,f=c.includes(u)?c.filter(d=>d!==u):[...c,u],i=f.length>0?[]:o;t.setValue("trigger.match_related",Ae(f,i))},h=u=>{t.setValue("trigger.match_related",Ae(l,u))},p=l.length===0;return e.jsxs("div",{className:"space-y-4",children:[e.jsxs(S,{children:[e.jsx(b,{children:"Flows"}),e.jsx(y,{children:e.jsx(ns,{selectedFlowIds:l,onToggleFlow:a,emptyMessage:"All flows"})})]}),p&&e.jsxs(S,{children:[e.jsx(b,{children:"Flow Run Tags"}),e.jsx(y,{children:e.jsx(wt,{value:o,onChange:h,placeholder:"All tags"})})]}),e.jsxs(S,{children:[e.jsx(b,{children:"Flow Run"}),e.jsxs("div",{className:"grid grid-cols-[10rem_1fr] gap-2",children:[e.jsx(ne,{}),e.jsx(w,{control:t.control,name:n,render:({field:u})=>{const c=u.value??[],f=cs(c);return e.jsx(y,{children:e.jsx(as,{selectedStates:f,onStateChange:i=>{u.onChange(ls(i))},emptyMessage:"Any state"})})}})]})]}),s==="Proactive"&&e.jsx(w,{control:t.control,name:"trigger.within",render:({field:u})=>e.jsxs(S,{children:[e.jsx(b,{children:"For"}),e.jsx(y,{children:e.jsx(se,{value:u.value??0,onChange:u.onChange,min:0})}),e.jsx(k,{})]})})]})},hs=({defaultValue:t="Form",value:s,onValueChange:n,formContent:r,jsonContent:l})=>{const o=s!==void 0?{value:s,onValueChange:n}:{defaultValue:t};return e.jsxs(rt,{...o,children:[e.jsx("div",{className:"flex justify-center",children:e.jsxs(nt,{children:[e.jsx(ve,{value:"Form",children:"Form"}),e.jsx(ve,{value:"JSON",children:"JSON"})]})}),e.jsx(Se,{value:"Form",children:r}),e.jsx(Se,{value:"JSON",children:l})]})},ms=({value:t,onChange:s,error:n})=>{const[r,l]=m.useState(null),o=()=>{try{const h=JSON.parse(t);s(JSON.stringify(h,null,2))}catch{}},a=h=>{try{const p=JSON.parse(h);return Oe.parse(p),l(null),!0}catch(p){return p instanceof SyntaxError?l("Invalid JSON syntax"):p instanceof Fe&&l(p.errors[0]?.message??"Invalid trigger configuration"),!1}};return e.jsxs("div",{className:"space-y-2",children:[e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsx(pe,{children:"Trigger Configuration"}),e.jsx(U,{variant:"ghost",size:"sm",onClick:o,children:"Format"})]}),e.jsxs("p",{className:"text-sm text-muted-foreground",children:["Edit the trigger configuration as JSON."," ",e.jsx("a",{href:"https://docs.prefect.io/v3/automate/events/automations-triggers",target:"_blank",rel:"noopener noreferrer",className:"underline hover:text-foreground",children:"View documentation"})]}),e.jsx(ot,{value:t,onChange:s,onBlur:()=>a(t)}),(r||n)&&e.jsx("p",{className:"text-sm text-destructive",children:r||n})]})},Ee={"deployment-status":"Deployment status","flow-run-state":"Flow run state","work-pool-status":"Work pool status","work-queue-status":"Work queue status",custom:"Custom"},ps=({onValueChange:t,value:s})=>e.jsxs("div",{className:"space-y-2",children:[e.jsx(pe,{htmlFor:"automations-trigger-template-select",children:"Trigger Template"}),e.jsxs(B,{value:s,onValueChange:t,children:[e.jsx(Q,{id:"automations-trigger-template-select",className:"w-full",children:e.jsx(z,{placeholder:"Select template"})}),e.jsx(J,{children:e.jsx(De,{children:Object.keys(Ee).map(n=>e.jsx(G,{value:n,children:Ee[n]},n))})})]})]}),fs=({onTemplateChange:t})=>{const s=_();return e.jsx(w,{control:s.control,name:"triggerTemplate",render:({field:n})=>e.jsx(S,{children:e.jsx(y,{children:e.jsx(ps,{value:n.value,onValueChange:r=>{n.onChange(r),t?.(r)}})})})})},xs={type:"event",posture:"Reactive",threshold:1,within:0},gs=t=>{switch(t){case"flow-run-state":return{type:"event",match:{"prefect.resource.id":"prefect.flow-run.*"},match_related:{},after:[],expect:["prefect.flow-run.*"],for_each:["prefect.resource.id"],posture:"Reactive",threshold:1,within:0};case"deployment-status":return{type:"event",match:{"prefect.resource.id":"prefect.deployment.*"},match_related:{},after:[],expect:["prefect.deployment.not-ready"],for_each:["prefect.resource.id"],posture:"Reactive",threshold:1,within:0};case"work-pool-status":return{type:"event",match:{"prefect.resource.id":"prefect.work-pool.*"},match_related:{},after:[],expect:["prefect.work-pool.not-ready","prefect.work-pool.not_ready"],for_each:["prefect.resource.id"],posture:"Reactive",threshold:1,within:0};case"work-queue-status":return{type:"event",match:{"prefect.resource.id":"prefect.work-queue.*"},match_related:{},after:[],expect:["prefect.work-queue.not-ready"],for_each:["prefect.resource.id"],posture:"Reactive",threshold:1,within:0};case"custom":return{type:"event",match:{"prefect.resource.id":["prefect.flow-run.*"]},match_related:{},after:[],expect:["prefect.flow-run.Failed"],for_each:[],posture:"Reactive",threshold:5,within:60};default:return xs}};function js({selectedWorkPoolIds:t,onToggleWorkPool:s,emptyMessage:n="All work pools"}){const[r,l]=m.useState(""),o=m.useDeferredValue(r),{data:a=[]}=L(me()),h=m.useMemo(()=>a.filter(c=>c.status!==null).filter(c=>!o||c.name.toLowerCase().includes(o.toLowerCase())),[a,o]),p=m.useMemo(()=>a.filter(c=>t.includes(c.id)),[a,t]),u=()=>{if(t.length===0)return e.jsx("span",{className:"text-muted-foreground",children:n});const c=p.map(f=>f.name);return e.jsx("span",{className:"truncate min-w-0 text-left",children:c.join(", ")})};return e.jsxs(D,{children:[e.jsx(R,{selected:t.length>0,children:u()}),e.jsxs(M,{children:[e.jsx(O,{value:r,onValueChange:l,placeholder:"Search work pools..."}),e.jsxs(V,{children:[e.jsx(W,{children:"No work pools found"}),e.jsx(F,{children:h.map(c=>e.jsx(N,{selected:t.includes(c.id),onSelect:()=>{s(c.id),l("")},closeOnSelect:!1,value:c.id,children:c.name},c.id))})]})]})]})}const oe=[{value:"ready",label:"Ready",events:["prefect.work-pool.ready"]},{value:"not_ready",label:"Not Ready",events:["prefect.work-pool.not-ready","prefect.work-pool.not_ready"]},{value:"paused",label:"Paused",events:["prefect.work-pool.paused"]}];function Le(t){if(!t||t.length===0)return"not_ready";for(const s of oe)if(s.events.some(n=>t.includes(n)))return s.value;return"not_ready"}function vs(t){const s=oe.find(n=>n.value===t);return s?[...s.events]:[]}function Ss(t){return oe.filter(s=>s.value!==t).flatMap(s=>[...s.events])}function bs(t){if(!t)return[];const s=t["prefect.resource.id"];return s?s==="prefect.work-pool.*"?[]:(Array.isArray(s)?s:[s]).filter(r=>r.startsWith("prefect.work-pool.")&&r!=="prefect.work-pool.*").map(r=>r.replace("prefect.work-pool.","")):[]}function ws(t){return t.length===0?{"prefect.resource.id":"prefect.work-pool.*"}:{"prefect.resource.id":t.map(s=>`prefect.work-pool.${s}`)}}const ys=()=>{const t=_(),s=E({name:"trigger.posture"}),n=E({name:"trigger.expect"}),r=E({name:"trigger.after"}),l=Le(s==="Proactive"?r:n),o=a=>{const h=vs(a),p=Ss(a);s==="Proactive"?(t.setValue("trigger.after",h),t.setValue("trigger.expect",p)):(t.setValue("trigger.expect",h),t.setValue("trigger.after",[]))};return e.jsxs(B,{value:l,onValueChange:o,children:[e.jsx(Q,{"aria-label":"select status",className:"min-w-0 flex-1",children:e.jsx(z,{placeholder:"Select status"})}),e.jsx(J,{children:oe.map(a=>e.jsx(G,{value:a.value,children:a.label},a.value))})]})},Cs=()=>{const t=_(),s=E({name:"trigger.posture"}),n=E({name:"trigger.match"}),r=bs(n),l=o=>{const a=r,h=a.includes(o)?a.filter(p=>p!==o):[...a,o];t.setValue("trigger.match",ws(h))};return e.jsxs("div",{className:"space-y-4",children:[e.jsxs(S,{children:[e.jsx(b,{children:"Work Pools"}),e.jsx(y,{children:e.jsx(js,{selectedWorkPoolIds:r,onToggleWorkPool:l,emptyMessage:"All work pools"})})]}),e.jsxs(S,{children:[e.jsx(b,{children:"Work Pool"}),e.jsxs("div",{className:"flex gap-2",children:[e.jsx(ne,{}),e.jsx(ys,{})]})]}),s==="Proactive"&&e.jsx(w,{control:t.control,name:"trigger.within",render:({field:o})=>e.jsxs(S,{children:[e.jsx(b,{children:"For"}),e.jsx(y,{children:e.jsx(se,{value:o.value??30,onChange:o.onChange,min:0})}),e.jsx(k,{})]})})]})};function Ns({selectedWorkPoolIds:t,onToggleWorkPool:s,emptyMessage:n="All work pools"}){const[r,l]=m.useState(""),o=m.useDeferredValue(r),{data:a=[]}=L(me({limit:100,offset:0})),h=m.useMemo(()=>a.filter(u=>u.status?o?u.name.toLowerCase().includes(o.toLowerCase()):!0:!1),[a,o]),p=()=>{if(t.length===0)return e.jsx("span",{className:"text-muted-foreground",children:n});const u=a.filter(c=>t.includes(c.id)).map(c=>c.name);return e.jsx("span",{className:"truncate min-w-0 text-left",children:u.join(", ")})};return e.jsxs(D,{children:[e.jsx(R,{selected:t.length>0,children:p()}),e.jsxs(M,{children:[e.jsx(O,{value:r,onValueChange:l,placeholder:"Search work pools..."}),e.jsxs(V,{children:[e.jsx(W,{children:"No work pools found"}),e.jsx(F,{children:h.map(u=>e.jsx(N,{selected:t.includes(u.id),onSelect:()=>{s(u.id),l("")},closeOnSelect:!1,value:u.id,children:u.name},u.id))})]})]})]})}function ks({selectedWorkQueueIds:t,onToggleWorkQueue:s,workPoolIds:n=[],emptyMessage:r="All work queues"}){const[l,o]=m.useState(""),a=m.useDeferredValue(l),{data:h=[]}=L(Me({limit:100,offset:0})),p=m.useMemo(()=>h.filter(f=>n.length>0&&(!f.work_pool_id||!n.includes(f.work_pool_id))?!1:a?f.name.toLowerCase().includes(a.toLowerCase()):!0),[h,n,a]),u=m.useMemo(()=>{const f={};for(const d of p){const g=d.work_pool_name??"Unknown";f[g]||(f[g]=[]),f[g].push(d)}return Object.keys(f).sort((d,g)=>d.localeCompare(g)).map(d=>({poolName:d,queues:f[d].sort((g,v)=>g.name.localeCompare(v.name))}))},[p]),c=()=>{if(t.length===0)return e.jsx("span",{className:"text-muted-foreground",children:r});const f=h.filter(i=>t.includes(i.id)).map(i=>i.name);return e.jsx("span",{className:"truncate min-w-0 text-left",children:f.join(", ")})};return e.jsxs(D,{children:[e.jsx(R,{selected:t.length>0,children:c()}),e.jsxs(M,{children:[e.jsx(O,{value:l,onValueChange:o,placeholder:"Search work queues..."}),e.jsxs(V,{children:[e.jsx(W,{children:"No work queues found"}),u.map(f=>e.jsx(F,{heading:f.poolName,children:f.queues.map(i=>e.jsx(N,{selected:t.includes(i.id),onSelect:()=>{s(i.id),o("")},closeOnSelect:!1,value:i.id,children:i.name},i.id))},f.poolName))]})]})]})}const _s=[{value:"prefect.work-queue.ready",label:"Ready"},{value:"prefect.work-queue.not-ready",label:"Not Ready"},{value:"prefect.work-queue.paused",label:"Paused"}];function Ts(t){if(!t)return[];const s=t["prefect.resource.id"];return s?(Array.isArray(s)?s:[s]).filter(r=>r.startsWith("prefect.work-pool.")).map(r=>r.replace("prefect.work-pool.","")):[]}function As(t){if(!t)return[];const s=t["prefect.resource.id"];if(!s)return[];const n=Array.isArray(s)?s:[s];return n.includes("prefect.work-queue.*")?[]:n.filter(r=>r.startsWith("prefect.work-queue.")).map(r=>r.replace("prefect.work-queue.",""))}function Es(t){return t.length===0?{}:{"prefect.resource.role":"work-pool","prefect.resource.id":t.map(n=>`prefect.work-pool.${n}`)}}function Ls(t){return t.length===0?{"prefect.resource.id":"prefect.work-queue.*"}:{"prefect.resource.id":t.map(n=>`prefect.work-queue.${n}`)}}const Fs=()=>{const t=_(),s=E({name:"trigger.posture"}),n=E({name:"trigger.match_related"}),r=E({name:"trigger.match"}),l=Ts(n),o=As(r),a=p=>{const u=l,c=u.includes(p)?u.filter(f=>f!==p):[...u,p];t.setValue("trigger.match_related",Es(c))},h=p=>{const u=o,c=u.includes(p)?u.filter(f=>f!==p):[...u,p];t.setValue("trigger.match",Ls(c))};return e.jsxs("div",{className:"space-y-4",children:[e.jsxs(S,{children:[e.jsx(b,{children:"Work Pools"}),e.jsx(y,{children:e.jsx(Ns,{selectedWorkPoolIds:l,onToggleWorkPool:a,emptyMessage:"All work pools"})})]}),e.jsxs(S,{children:[e.jsx(b,{children:"Work Queues"}),e.jsx(y,{children:e.jsx(ks,{selectedWorkQueueIds:o,onToggleWorkQueue:h,workPoolIds:l,emptyMessage:"All work queues"})})]}),e.jsxs(S,{children:[e.jsx(b,{children:"Work Queue"}),e.jsxs("div",{className:"grid grid-cols-[10rem_1fr] gap-2",children:[e.jsx(ne,{}),e.jsx(w,{control:t.control,name:"trigger.expect",render:({field:p})=>{const u=p.value?.[0];return e.jsx(y,{children:e.jsxs(B,{value:u??"",onValueChange:c=>p.onChange([c]),children:[e.jsx(Q,{className:"w-full",children:e.jsx(z,{placeholder:"Select status"})}),e.jsx(J,{children:_s.map(c=>e.jsx(G,{value:c.value,children:c.label},c.value))})]})})}})]})]}),s==="Proactive"&&e.jsx(w,{control:t.control,name:"trigger.within",render:({field:p})=>e.jsxs(S,{children:[e.jsx(b,{children:"For"}),e.jsx(y,{children:e.jsx(se,{value:p.value??0,onChange:p.onChange,min:0})}),e.jsx(k,{})]})})]})},Ds=()=>{const t=_(),s=t.watch("triggerTemplate"),n=t.watch("trigger"),[r,l]=m.useState("Form"),[o,a]=m.useState(""),[h,p]=m.useState(void 0),u=m.useCallback(()=>JSON.stringify(n,null,2),[n]);m.useEffect(()=>{r==="Form"&&a(u())},[r,u]);const c=m.useCallback(g=>{try{const v=JSON.parse(g);return{valid:!0,trigger:Oe.parse(v)}}catch(v){return v instanceof SyntaxError?{valid:!1,error:"Invalid JSON syntax"}:v instanceof Fe?{valid:!1,error:v.errors[0]?.message??"Invalid trigger configuration"}:{valid:!1,error:"Unknown error"}}},[]),f=m.useCallback(g=>{if(r!==g){if(g==="Form"){const v=c(o);if(!v.valid){p(v.error);return}v.trigger&&t.setValue("trigger",v.trigger),p(void 0)}else a(u()),p(void 0);l(g)}},[r,o,c,t,u]),i=m.useCallback(g=>{a(g);const v=c(g);v.valid&&v.trigger&&(t.setValue("trigger",v.trigger),p(void 0))},[c,t]),d=g=>{const v=gs(g);t.setValue("trigger",v),a(JSON.stringify(v,null,2)),p(void 0)};return e.jsxs("div",{className:"space-y-6",children:[e.jsx(fs,{onTemplateChange:d}),s&&e.jsx(hs,{value:r,onValueChange:f,formContent:e.jsx(Rs,{template:s}),jsonContent:e.jsx(ms,{value:o,onChange:i,error:h})})]})},Rs=({template:t})=>{switch(t){case"flow-run-state":return e.jsx(ds,{});case"deployment-status":return e.jsx(ss,{});case"work-pool-status":return e.jsx(Cs,{});case"work-queue-status":return e.jsx(Fs,{});case"custom":return e.jsx(Qt,{});default:return null}},ce=["Trigger","Actions","Details"],Ms={actions:[{type:void 0}],trigger:{type:"event",posture:"Reactive",threshold:1,within:0}},Gs=({defaultValues:t={},onSubmit:s,submitLabel:n="Save",isSubmitting:r=!1})=>{const o=!!(t&&Object.keys(t).length>0)?new Set([0,1,2]):new Set([0]),a=ut(ce.length,0,o),h=ze({resolver:Be(ht),defaultValues:{...Ms,...t}}),p=ce[a.currentStep],u={Trigger:{render:()=>e.jsx(Ds,{}),trigger:()=>h.trigger("trigger")},Actions:{render:()=>e.jsx(Mt,{}),trigger:()=>h.trigger("actions")},Details:{render:()=>e.jsx(Ot,{}),trigger:()=>h.trigger(["description","name"])}},c=async f=>{await u[f].trigger()&&a.incrementStep()};return e.jsx(it,{...h,children:e.jsx("form",{onSubmit:f=>{h.handleSubmit(s)(f)},children:e.jsxs("div",{className:"flex flex-col gap-8",children:[e.jsx(dt,{steps:ce,currentStepNum:a.currentStep,onClick:f=>a.changeStep(f.stepNum),completedSteps:a.completedStepsSet,visitedSteps:a.visitedStepsSet}),e.jsxs(at,{className:"p-4 pt-8",children:[e.jsxs(lt,{children:[u[p].render(),e.jsx(k,{children:h.formState.errors.root?.message})]}),e.jsxs(ct,{className:"mt-6 flex gap-2 justify-end",children:[e.jsx(U,{type:"button",variant:"outline",children:e.jsx(Ue,{to:"/automations",children:"Cancel"})}),e.jsx(U,{disabled:a.isStartingStep,type:"button",variant:"outline",onClick:a.decrementStep,children:"Previous"}),a.isFinalStep?e.jsx(U,{type:"submit",loading:r,children:n},"save"):e.jsx(U,{type:"button",onClick:()=>{c(p)},children:"Next"},"next")]})]})]})})})};export{Gs as A};
|
|
2
|
-
//# sourceMappingURL=automation-wizard-
|
|
1
|
+
import{j as e,r as m,u as L,L as Ue}from"./vendor-tanstack-CWDKYA_B.js";import{a as Be}from"./zod-CjGf5GIv.js";import{g as _,p as E,q as Qe,Z as Fe,c as ze}from"./vendor-forms-D-iybWES.js";import{S as B,a as Q,b as z,c as J,d as De,di as Je,e as G,p as X,al as re,b5 as Ge,br as He,ac as D,ad as R,ae as M,af as O,ah as W,ag as V,ai as F,aj as N,be as Ye,ab as ie,bN as Re,I as Z,M as me,d2 as Me,bm as Ke,bp as Xe,dj as Ze,q as U,i as pe,aW as et,a_ as tt,ap as st,cP as xe,ak as ge,aq as je,aw as rt,ax as nt,ay as ve,az as Se,L as ot,C as at,o as lt,dk as ct}from"./index-CQlQauOE.js";import{b as w,c as S,d as b,e as y,a as k,F as it}from"./form-DvAgEGjn.js";import{u as ut,S as dt}from"./use-stepper-DRdSNO1_.js";import{U as ee,T as Oe,A as ht}from"./automation-schema-crrFcHTg.js";import{S as mt,R as pt,a as We,b as be,c as ft}from"./index-xd6ftCzl.js";import{T as Ve}from"./textarea-CjmPCtZi.js";import{R as xt,a as gt}from"./radio-group-B4HH3BMW.js";import{u as jt,C as vt,a as St,b as bt}from"./collapsible-CjJyAdbn.js";import{T as wt}from"./tags-input-9pBchAz7.js";const we={"cancel-flow-run":"Cancel a flow run","suspend-flow-run":"Suspend a flow run","resume-flow-run":"Resume a flow run","change-flow-run-state":"Change flow run's state","run-deployment":"Run a deployment","pause-deployment":"Pause a deployment","resume-deployment":"Resume a deployment","pause-work-queue":"Pause a work queue","resume-work-queue":"Resume a work queue","pause-work-pool":"Pause a work pool","resume-work-pool":"Resume a work pool","pause-automation":"Pause an automation","resume-automation":"Resume an automation","send-notification":"Send a notification"},yt=({index:t})=>{const s=_();return e.jsx(w,{control:s.control,name:`actions.${t}.type`,render:({field:n})=>e.jsxs(S,{children:[e.jsx(b,{children:"Action Type"}),e.jsx(y,{children:e.jsxs(B,{...n,onValueChange:r=>{n.onChange(r);const l=Ct({index:t,type:r});l&&s.setValue(l,ee)},children:[e.jsx(Q,{"aria-label":"select action",className:"w-full",children:e.jsx(z,{placeholder:"Select action"})}),e.jsx(J,{children:e.jsxs(De,{children:[e.jsx(Je,{children:"Actions"}),Object.keys(we).map(r=>e.jsx(G,{value:r,children:we[r]},r))]})})]})})]})})};function Ct({index:t,type:s}){switch(s){case"run-deployment":case"pause-deployment":case"resume-deployment":return`actions.${t}.deployment_id`;case"pause-work-queue":case"resume-work-queue":return`actions.${t}.work_queue_id`;case"pause-work-pool":case"resume-work-pool":return`actions.${t}.work_pool_id`;case"pause-automation":case"resume-automation":return`actions.${t}.automation_id`;default:return null}}const Nt=({index:t})=>{const s=_(),n=s.watch(`actions.${t}.state`);return e.jsxs(e.Fragment,{children:[e.jsx(w,{control:s.control,name:`actions.${t}.state`,render:({field:r})=>e.jsxs(S,{children:[e.jsx(b,{children:"State"}),e.jsx(y,{children:e.jsx(mt,{value:r.value,onValueChange:r.onChange})}),e.jsx(k,{})]})}),e.jsx(w,{control:s.control,name:`actions.${t}.name`,render:({field:r})=>e.jsxs(S,{children:[e.jsx(b,{children:"Name"}),e.jsx(y,{children:e.jsx(X,{type:"text",...r,value:r.value??"",placeholder:n?pt[n]:void 0})}),e.jsx(k,{})]})}),e.jsx(w,{control:s.control,name:`actions.${t}.message`,render:({field:r})=>e.jsxs(S,{children:[e.jsx(b,{children:"Message"}),e.jsx(y,{children:e.jsx(Ve,{...r,placeholder:"State changed by Automation <id>"})}),e.jsx(k,{})]})})]})},ae=({action:t})=>{const s=t==="Resume"?"Resume a flow run inferred from the triggering event":`${t} flow run inferred from the triggering event`;return e.jsx(re,{variant:"bodySmall",className:"text-muted-foreground",children:s})},kt=4,te=({length:t=kt})=>Array.from({length:t},(s,n)=>e.jsx(Ge,{className:"mt-2 p-4 h-2 w-full"},n)),H={value:ee,name:"Infer Automation"},_t=(t,s)=>{if(s===H.value)return H.name;const n=t?.find(r=>r.id===s);if(n)return n.name},ye=({action:t,index:s})=>{const[n,r]=m.useState(""),l=_(),{data:o,isSuccess:a}=L(He()),h=m.useDeferredValue(n),p=m.useMemo(()=>o?o.filter(c=>c.name.toLowerCase().includes(h.toLowerCase())):[],[o,h]),u=H.name.toLowerCase().includes(h.toLowerCase());return e.jsx(w,{control:l.control,name:`actions.${s}.automation_id`,render:({field:c})=>{const f=_t(o,c.value);return e.jsxs(S,{className:"flex flex-col",children:[e.jsxs(b,{children:["Automation To ",t]}),e.jsxs(D,{children:[e.jsx(R,{selected:!!f,"aria-label":`Select Automation to ${t}`,children:f??"Select automation"}),e.jsxs(M,{children:[e.jsx(O,{value:n,onValueChange:r,placeholder:"Search for an automation..."}),e.jsx(W,{children:"No automation found"}),e.jsx(V,{children:e.jsxs(F,{children:[u&&e.jsx(N,{selected:c.value===H.value,onSelect:i=>{c.onChange(i),r("")},value:H.value,children:H.name}),a?p.map(i=>e.jsx(N,{selected:c.value===i.id,onSelect:d=>{c.onChange(d),r("")},value:i.id,children:i.name},i.id)):e.jsx(te,{})]})})]})]}),e.jsx(k,{})]})}})},Tt=(t={page:1,limit:100,sort:"NAME_ASC"})=>{const{data:s,status:n}=L(Ye(t)),r=new Set(s?.results.map(a=>a.flow_id)),{data:l,status:o}=L(ie({flows:{operator:"or_",id:{any_:Array.from(r)}},sort:"NAME_DESC",offset:0},{enabled:r.size>0}));return m.useMemo(()=>{if(l&&s){const a=new Map(l.map(d=>[d.id,d])),h=s.results.map(d=>({...d,flow:a.get(d.flow_id)})),{count:p,limit:u,pages:c,page:f}=s;return{data:{count:p,limit:u,pages:c,page:f,results:h},status:"success"}}return o==="error"||n==="error"?{data:void 0,status:"error"}:{data:void 0,status:"pending"}},[s,n,l,o])},q={value:ee,name:"Infer Deployment"},At=(t,s)=>{if(s===q.value)return q.name;const n=t?.find(r=>r.id===s);if(n)return e.jsx(Ie,{deploymentWithFlow:n})},le=({action:t,index:s})=>{const[n,r]=m.useState(""),l=_(),o=l.watch(`actions.${s}.type`),a=E({name:`actions.${s}.deployment_id`}),h=Re(n,500),{data:p}=Tt({page:1,sort:"NAME_ASC",deployments:{operator:"or_",flow_or_deployment_name:{like_:h}}}),u=q.name.toLowerCase().includes(n.toLowerCase()),c=p?.results;return e.jsxs(e.Fragment,{children:[e.jsx(w,{control:l.control,name:`actions.${s}.deployment_id`,render:({field:f})=>{const i=At(c,f.value);return e.jsxs(S,{className:"flex flex-col",children:[e.jsxs(b,{children:["Deployment To ",t]}),e.jsxs(D,{children:[e.jsx(R,{selected:!!i,"aria-label":`Select Deployment to ${t}`,children:i??"Select deployment"}),e.jsxs(M,{children:[e.jsx(O,{value:n,onValueChange:r,placeholder:"Search for an deployment..."}),e.jsx(W,{children:"No deployment found"}),e.jsx(V,{children:e.jsxs(F,{children:[u&&e.jsx(N,{selected:f.value===q.value,onSelect:f.onChange,value:q.value,children:q.name}),c?c.map(d=>e.jsx(N,{"aria-label":d.name,selected:f.value===d.id,onSelect:f.onChange,value:d.id,children:e.jsx(Ie,{deploymentWithFlow:d})},d.id)):e.jsx(te,{})]})})]})]}),e.jsx(k,{})]})}}),a!==q.value&&o==="run-deployment"&&e.jsx("div",{children:"TODO: Additional fields"})]})},Ie=({deploymentWithFlow:t})=>t.flow?e.jsxs("div",{className:"flex items-center gap-0.5",children:[e.jsx("div",{children:t.flow.name}),e.jsx(Z,{className:"size-4",id:"ChevronRight"}),e.jsx("div",{children:t.name})]}):t.name,Y={value:ee,name:"Infer Work Pool"},Et=(t,s)=>{if(s===Y.value)return Y.name;const n=t?.find(r=>r.id===s);if(n)return n.name},Ce=({action:t,index:s})=>{const[n,r]=m.useState(""),l=_(),{data:o,isSuccess:a}=L(me()),h=m.useDeferredValue(n),p=m.useMemo(()=>o?o.filter(c=>c.name.toLowerCase().includes(h.toLowerCase())):[],[o,h]),u=Y.name.toLowerCase().includes(h.toLowerCase());return e.jsx(w,{control:l.control,name:`actions.${s}.work_pool_id`,render:({field:c})=>{const f=Et(o,c.value);return e.jsxs(S,{className:"flex flex-col",children:[e.jsxs(b,{children:["Work Pool To ",t]}),e.jsxs(D,{children:[e.jsx(R,{selected:!!f,"aria-label":`Select Work Pool to ${t}`,children:f??"Select Work Pool"}),e.jsxs(M,{children:[e.jsx(O,{value:n,onValueChange:r,placeholder:"Search for a work pool..."}),e.jsx(W,{children:"No work pool found"}),e.jsx(V,{children:e.jsxs(F,{children:[u&&e.jsx(N,{selected:c.value===Y.value,onSelect:i=>{c.onChange(i),r("")},value:Y.value,children:Y.name}),a?p.map(i=>e.jsx(N,{selected:c.value===i.id,onSelect:d=>{c.onChange(d),r("")},value:i.id,children:i.name},i.id)):e.jsx(te,{})]})})]})]}),e.jsx(k,{})]})}})},K={value:ee,name:"Infer Work Queue"},Lt=(t,s)=>{if(s===K.value)return K.name;const n=t?.find(r=>r.id===s);if(n)return n.name},Ne=({action:t,index:s})=>{const[n,r]=m.useState(""),l=_(),{data:o}=L(Me()),a=m.useDeferredValue(n),h=m.useMemo(()=>{if(!o)return;const u=new Map,c=o.filter(f=>f.name.toLowerCase().includes(a.toLowerCase()));for(const f of c){const{work_pool_name:i}=f;if(!i)throw new Error("'work_pool_name expected");u.set(i,[...u.get(i)??[],f])}return u},[o,a]),p=K.name.toLowerCase().includes(a.toLowerCase());return e.jsx(w,{control:l.control,name:`actions.${s}.work_queue_id`,render:({field:u})=>{const c=Lt(o,u.value);return e.jsxs(S,{className:"flex flex-col",children:[e.jsxs(b,{children:["Work Queue To ",t]}),e.jsxs(D,{children:[e.jsx(R,{selected:!!c,"aria-label":`Select Work Queue to ${t}`,children:c??"Select Work Queue"}),e.jsxs(M,{children:[e.jsx(O,{value:n,onValueChange:r,placeholder:"Search for a work queue..."}),e.jsx(W,{children:"No work queue found"}),e.jsx(V,{children:e.jsxs(F,{children:[p&&e.jsx(N,{selected:u.value===K.value,onSelect:f=>{u.onChange(f),r("")},value:K.value,children:K.name}),h?Array.from(h).map(([f,i])=>e.jsxs("div",{className:"border-b",children:[e.jsx(N,{disabled:!0,children:f}),i.map(d=>e.jsx(N,{selected:u.value===d.id,onSelect:g=>{u.onChange(g),r("")},value:d.id,children:d.name},d.id))]},f)):e.jsx(te,{})]})})]})]}),e.jsx(k,{})]})}})},Ft=({index:t})=>{const s=_(),[n,r]=m.useState(""),{data:l,isLoading:o}=L(Ke({offset:0,block_schemas:{operator:"and_",block_capabilities:{all_:["notify"]}}})),a=m.useMemo(()=>l?.map(d=>d.slug)??[],[l]),{data:h,isLoading:p}=L(Xe({block_types:a.length>0?{slug:{any_:a}}:void 0,include_secrets:!1,sort:"BLOCK_TYPE_AND_NAME_ASC",offset:0},{enabled:a.length>0})),u=o||p,c=m.useMemo(()=>!l||!h?[]:l.map(d=>({blockType:d,documents:h.filter(g=>g.block_type_id===d.id)})).filter(d=>d.documents.length>0),[l,h]),f=m.useMemo(()=>{if(!n)return c;const d=n.toLowerCase();return c.map(g=>({...g,documents:g.documents.filter(v=>v.name?.toLowerCase().includes(d))})).filter(g=>g.documents.length>0)},[c,n]),i=m.useCallback(d=>{if(!(!d||!h))return h.find(g=>g.id===d)},[h]);return e.jsxs("div",{className:"space-y-4",children:[e.jsx(w,{control:s.control,name:`actions.${t}.block_document_id`,render:({field:d})=>{const g=i(d.value);return e.jsxs(S,{className:"flex flex-col",children:[e.jsx(b,{children:"Block"}),e.jsxs(D,{children:[e.jsx(R,{selected:!!g,"aria-label":"Select notification block",children:g?g.name:"Select a notification block"}),e.jsxs(M,{children:[e.jsx(O,{value:n,onValueChange:r,placeholder:"Search for a block..."}),e.jsx(W,{children:"No notification blocks found"}),e.jsx(V,{children:u?e.jsx(te,{}):f.map(v=>e.jsx(F,{heading:v.blockType.name,children:v.documents.map(I=>e.jsx(N,{value:I.id,selected:d.value===I.id,onSelect:d.onChange,children:I.name},I.id))},v.blockType.id))})]})]}),e.jsx(k,{})]})}}),e.jsx(ke,{index:t,name:"subject",label:"Subject",placeholder:"Enter notification subject..."}),e.jsx(ke,{index:t,name:"body",label:"Body",placeholder:"Enter notification body...",multiline:!0}),e.jsxs("div",{className:"flex items-start gap-2 rounded-md border border-blue-200 bg-blue-50 p-3 text-sm text-blue-800 dark:border-blue-800 dark:bg-blue-950 dark:text-blue-200",children:[e.jsx(Z,{id:"Info",className:"mt-0.5 size-4 shrink-0"}),e.jsxs("p",{children:["In addition to any fields present on the triggering event, the following objects can be used in notification templates:"," ",e.jsx("code",{className:"rounded bg-blue-100 px-1 py-0.5 font-mono text-xs dark:bg-blue-900",children:"flow"}),","," ",e.jsx("code",{className:"rounded bg-blue-100 px-1 py-0.5 font-mono text-xs dark:bg-blue-900",children:"deployment"}),","," ",e.jsx("code",{className:"rounded bg-blue-100 px-1 py-0.5 font-mono text-xs dark:bg-blue-900",children:"flow_run"}),","," ",e.jsx("code",{className:"rounded bg-blue-100 px-1 py-0.5 font-mono text-xs dark:bg-blue-900",children:"work_pool"}),","," ",e.jsx("code",{className:"rounded bg-blue-100 px-1 py-0.5 font-mono text-xs dark:bg-blue-900",children:"work_queue"}),", and"," ",e.jsx("code",{className:"rounded bg-blue-100 px-1 py-0.5 font-mono text-xs dark:bg-blue-900",children:"metric"}),"."]})]})]})},ke=({index:t,name:s,label:n,placeholder:r,multiline:l=!1})=>{const o=_(),{validateTemplate:a}=Ze(),[h,p]=m.useState(null),[u,c]=m.useState(!1),f=o.watch(`actions.${t}.${s}`),i=Re(f,1e3);m.useEffect(()=>{(async()=>{if(!i||i.trim()===""){p(null);return}c(!0);try{const v=await a(i);v.valid?p(null):p(v.error)}catch{p(null)}finally{c(!1)}})()},[i,a]);const d=l?Ve:X;return e.jsx(w,{control:o.control,name:`actions.${t}.${s}`,render:({field:g})=>e.jsxs(S,{children:[e.jsxs(b,{className:"flex items-center gap-2",children:[n,u&&e.jsx(Z,{id:"Loader2",className:"size-3 animate-spin"})]}),e.jsx(y,{children:e.jsx(d,{...g,value:g.value??"",placeholder:r,className:h?"border-destructive":""})}),h&&e.jsx("p",{className:"text-sm text-destructive",children:h}),e.jsx(k,{})]})})},Dt=({index:t,onRemove:s})=>e.jsxs("div",{className:"space-y-2",children:[e.jsxs("div",{className:"flex justify-between items-center",children:[e.jsxs(re,{variant:"body",className:"font-semibold",children:["Action ",t+1]}),e.jsx(U,{size:"icon","aria-label":`remove action ${t+1}`,onClick:s,variant:"outline",children:e.jsx(Z,{id:"Trash2",className:"size-4"})})]}),e.jsx(yt,{index:t}),e.jsx(Rt,{index:t}),e.jsx("hr",{className:"my-8"})]},t),Rt=({index:t})=>{switch(E({name:`actions.${t}.type`})){case"change-flow-run-state":return e.jsx(Nt,{index:t});case"run-deployment":return e.jsx(le,{action:"Run",index:t});case"pause-deployment":return e.jsx(le,{action:"Pause",index:t});case"resume-deployment":return e.jsx(le,{action:"Resume",index:t});case"pause-work-queue":return e.jsx(Ne,{action:"Pause",index:t});case"resume-work-queue":return e.jsx(Ne,{action:"Resume",index:t});case"pause-work-pool":return e.jsx(Ce,{action:"Pause",index:t});case"resume-work-pool":return e.jsx(Ce,{action:"Resume",index:t});case"pause-automation":return e.jsx(ye,{action:"Pause",index:t});case"resume-automation":return e.jsx(ye,{action:"Resume",index:t});case"send-notification":return e.jsx(Ft,{index:t});case"cancel-flow-run":return e.jsx(ae,{action:"Cancel"});case"suspend-flow-run":return e.jsx(ae,{action:"Suspend"});case"resume-flow-run":return e.jsx(ae,{action:"Resume"});default:return null}},Mt=()=>{const t=_(),{fields:s,append:n,remove:r}=Qe({control:t.control,name:"actions",shouldUnregister:!1,rules:{minLength:1}});return e.jsxs("div",{children:[s.map(({id:l},o)=>e.jsx(Dt,{index:o,onRemove:()=>r(o)},l)),e.jsxs(U,{type:"button",variant:"outline",onClick:()=>n({type:"cancel-flow-run"}),children:[e.jsx(Z,{id:"Plus",className:"mr-2 size-4"})," Add Action"]})]})},Ot=()=>{const t=_();return e.jsxs("div",{className:"flex flex-col gap-4",children:[e.jsx(w,{control:t.control,name:"name",render:({field:s})=>e.jsxs(S,{children:[e.jsx(b,{children:"Automation Name"}),e.jsx(y,{children:e.jsx(X,{type:"text",...s,value:s.value??""})}),e.jsx(k,{})]})}),e.jsx(w,{control:t.control,name:"description",render:({field:s})=>e.jsxs(S,{children:[e.jsx(b,{children:"Description (Optional)"}),e.jsx(y,{children:e.jsx(X,{type:"text",...s,value:s.value??""})}),e.jsx(k,{})]})})]})},Wt=[{value:"Reactive",label:"Observe"},{value:"Proactive",label:"Don't observe"}],Vt=30,It=()=>{const t=_(),s=n=>{const r=t.getValues("trigger.posture");if(t.setValue("trigger.posture",n),r==="Reactive"&&n==="Proactive"){const l=t.getValues("trigger.expect")??[];t.setValue("trigger.after",l),t.setValue("trigger.expect",[]),t.getValues("trigger.within")===0&&t.setValue("trigger.within",Vt)}else if(r==="Proactive"&&n==="Reactive"){const l=t.getValues("trigger.after")??[];t.setValue("trigger.expect",l),t.setValue("trigger.after",[])}};return e.jsx(w,{control:t.control,name:"trigger.posture",render:({field:n})=>e.jsxs(S,{children:[e.jsx(b,{children:"When I"}),e.jsx(y,{children:e.jsx(xt,{value:n.value,onValueChange:s,className:"flex gap-4",children:Wt.map(r=>e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(gt,{value:r.value,id:`custom-${r.value}`}),e.jsx(pe,{htmlFor:`custom-${r.value}`,children:r.label})]},r.value))})})]})})},ue=60,de=3600,he=86400,Pt=[{label:"Seconds",value:1},{label:"Minutes",value:ue},{label:"Hours",value:de},{label:"Days",value:he}];function $t(t){return t>0&&t%he===0?he:t>0&&t%de===0?de:t>0&&t%ue===0?ue:1}function se({value:t,onChange:s,min:n=0,max:r,className:l,disabled:o=!1}){const[a,h]=m.useState(()=>$t(t)),p=m.useMemo(()=>Pt.filter(i=>i.value>=n),[n]),u=m.useMemo(()=>t/a,[t,a]),c=m.useCallback(i=>{let d=i*a;r!==void 0&&d>r&&(d=r),s(d)},[s,a,r]),f=m.useCallback(i=>{const d=Number(i),g=a;h(d);let v=t/g*d;r!==void 0&&v>r&&(v=r),s(v)},[s,a,t,r]);return m.useEffect(()=>{if(!p.some(i=>i.value===a)){const i=p[0];i&&h(i.value)}},[p,a]),e.jsxs("div",{className:et("grid grid-cols-[1fr_7rem] gap-2 w-full",l),children:[e.jsx(X,{type:"number",min:0,value:u,onChange:i=>c(Number(i.target.value)),disabled:o,"aria-label":"Duration quantity"}),e.jsxs(B,{value:String(a),onValueChange:f,disabled:o,children:[e.jsx(Q,{"aria-label":"Duration unit",children:e.jsx(z,{})}),e.jsx(J,{children:p.map(i=>e.jsx(G,{value:String(i.value),children:i.label},i.value))})]})]})}const qt=2,Ut=40;function _e({selectedResourceIds:t,onToggleResource:s,emptyMessage:n="All resources"}){const[r,l]=m.useState(""),o=m.useDeferredValue(r),[a,h]=m.useState(0),p=m.useRef(null),u=m.useRef(null);m.useEffect(()=>{const x=p.current;if(!x)return;const j=new ResizeObserver(C=>{for(const T of C)h(T.contentRect.width)});return j.observe(x),()=>j.disconnect()},[]);const{resourceOptions:c}=jt(),f=m.useMemo(()=>{const x=[{label:"Automations",options:[]},{label:"Blocks",options:[]},{label:"Deployments",options:[]},{label:"Flows",options:[]},{label:"Work Pools",options:[]},{label:"Work Queues",options:[]}];for(const j of c){const C={label:j.name,value:j.resourceId};switch(j.type){case"automation":x[0].options.push(C);break;case"block":x[1].options.push(C);break;case"deployment":x[2].options.push(C);break;case"flow":x[3].options.push(C);break;case"work-pool":x[4].options.push(C);break;case"work-queue":x[5].options.push(C);break}}return x.map(j=>({...j,options:j.options.sort((C,T)=>C.label.localeCompare(T.label))})).filter(j=>j.options.length>0)},[c]),i=m.useMemo(()=>{if(!o)return f;const x=o.toLowerCase();return f.map(j=>({...j,options:j.options.filter(C=>C.label.toLowerCase().includes(x)||C.value.toLowerCase().includes(x))})).filter(j=>j.options.length>0)},[f,o]),d=m.useMemo(()=>{if(!o.trim()||!o.includes("."))return!1;const x=o.toLowerCase();return!c.some(j=>j.resourceId.toLowerCase()===x)},[o,c]),g=m.useCallback(x=>{const j=u.current;if(!j||a===0||x.length===0)return Math.min(x.length,qt);const C=x.length>1?a-Ut:a;let T=0;for(let A=0;A<x.length&&(j.textContent=x.slice(0,A+1).join(", "),j.offsetWidth<=C);A++)T=A+1;return T===x.length?x.length:Math.max(1,T)},[a]),v=()=>{if(t.length===0)return e.jsx("span",{className:"text-muted-foreground",children:n});const x=t.map(A=>c.find(qe=>qe.resourceId===A)?.name??A),j=g(x),C=x.slice(0,j),T=x.length-j;return e.jsxs("div",{ref:p,className:"flex flex-1 min-w-0 items-center gap-2",children:[e.jsx("div",{className:"flex flex-1 min-w-0 items-center gap-2 overflow-hidden",children:e.jsx("span",{className:"truncate",children:C.join(", ")})}),T>0&&e.jsxs(re,{variant:"bodySmall",className:"shrink-0",children:["+ ",T]}),e.jsx("div",{ref:u,className:"absolute invisible whitespace-nowrap","aria-hidden":"true"})]})},I=x=>{s(x),l("")};return e.jsxs(D,{children:[e.jsx(R,{selected:t.length>0,children:v()}),e.jsxs(M,{children:[e.jsx(O,{value:r,onValueChange:l,placeholder:"Search resources..."}),e.jsxs(V,{children:[e.jsx(W,{children:"No resources found"}),d&&e.jsx(F,{children:e.jsxs(N,{selected:t.includes(o),onSelect:()=>I(o),closeOnSelect:!1,value:o,children:['Add "',o,'"']},"__custom__")}),i.map(x=>e.jsx(F,{heading:x.label,children:x.options.map(j=>e.jsx(N,{selected:t.includes(j.value),onSelect:()=>I(j.value),closeOnSelect:!1,value:j.value,children:j.label},j.value))},x.label))]})]})]})}function Bt(t){const s=new Map;for(const n of t){const r=n.split(".");for(let l=1;l<r.length;l++){const o=r.slice(0,l).join(".");s.set(o,(s.get(o)??0)+1)}}return Array.from(s.entries()).filter(([,n])=>n>1&&n<t.length).map(([n])=>`${n}.*`)}function Te({selectedEvents:t,onToggleEvent:s,emptyMessage:n="All events"}){const[r,l]=m.useState(""),o=m.useDeferredValue(r),[a]=m.useState(()=>({since:new Date(Date.now()-10080*60*1e3).toISOString(),until:new Date().toISOString()})),{data:h=[]}=L(tt("event",{filter:{occurred:a,order:"DESC"},time_unit:"day",time_interval:1})),p=m.useMemo(()=>{const d=h.map(v=>v.label),g=Bt(d);return[...d,...g].sort((v,I)=>v.localeCompare(I))},[h]),u=m.useMemo(()=>{if(!o)return p;const d=o.toLowerCase();return p.filter(g=>g.toLowerCase().includes(d))},[p,o]),c=m.useMemo(()=>{if(!o.trim())return!1;const d=o.toLowerCase();return!p.some(g=>g.toLowerCase()===d)},[o,p]),f=()=>{if(t.length===0)return e.jsx("span",{className:"text-muted-foreground",children:n});const d=t.slice(0,2),g=t.length-d.length;return e.jsxs("div",{className:"flex min-w-0 items-center justify-start gap-1",children:[e.jsx("span",{className:"truncate min-w-0 text-left",children:d.join(", ")}),g>0&&e.jsxs("span",{className:"shrink-0 text-muted-foreground",children:["+",g]})]})},i=d=>{s(d),l("")};return e.jsxs(D,{children:[e.jsx(R,{selected:t.length>0,children:f()}),e.jsxs(M,{children:[e.jsx(O,{value:r,onValueChange:l,placeholder:"Search events..."}),e.jsxs(V,{children:[e.jsx(W,{children:"No events found"}),e.jsxs(F,{children:[c&&e.jsxs(N,{selected:t.includes(o),onSelect:()=>i(o),closeOnSelect:!1,value:o,children:['Add "',o,'"']},"__custom__"),u.map(d=>e.jsx(N,{selected:t.includes(d),onSelect:()=>i(d),closeOnSelect:!1,value:d,children:d},d))]})]})]})]})}const Qt=()=>{const t=_(),s=E({name:"trigger.posture"});return e.jsxs("div",{className:"space-y-4",children:[e.jsx("div",{className:"flex items-end gap-4",children:e.jsx(It,{})}),e.jsx(w,{control:t.control,name:"trigger.expect",render:({field:n})=>{const r=n.value??[];return e.jsxs(S,{children:[e.jsx(b,{children:"Any event matching"}),e.jsx(y,{children:e.jsx(Te,{selectedEvents:r,onToggleEvent:l=>{const o=r.includes(l)?r.filter(a=>a!==l):[...r,l];n.onChange(o)}})}),e.jsx(k,{})]})}}),e.jsx(w,{control:t.control,name:"trigger.match",render:({field:n})=>{const r=n.value?.["prefect.resource.id"]??[],l=Array.isArray(r)?r:[r];return e.jsxs(S,{children:[e.jsx(b,{children:"From the following resources"}),e.jsx(y,{children:e.jsx(_e,{selectedResourceIds:l,onToggleResource:o=>{const a=l.includes(o)?l.filter(h=>h!==o):[...l,o];a.length>0?n.onChange({"prefect.resource.id":a}):n.onChange({})}})}),e.jsx(k,{})]})}}),e.jsxs("div",{className:"flex items-end gap-2",children:[e.jsx(w,{control:t.control,name:"trigger.threshold",render:({field:n})=>e.jsxs(S,{className:"w-20",children:[e.jsx(y,{children:e.jsx(X,{type:"number",min:1,...n,onChange:r=>n.onChange(Number(r.target.value))})}),e.jsx(k,{})]})}),e.jsx("span",{className:"pb-2 text-sm text-muted-foreground",children:"times within"}),e.jsx(w,{control:t.control,name:"trigger.within",render:({field:n})=>e.jsxs(S,{children:[e.jsx(y,{children:e.jsx(se,{value:n.value??0,onChange:n.onChange,min:s==="Proactive"?10:0})}),e.jsx(k,{})]})})]}),e.jsxs(vt,{children:[e.jsxs(St,{className:"flex items-center gap-2 text-sm font-medium",children:[e.jsx(st,{className:"h-4 w-4 transition-transform data-[state=open]:rotate-90"}),"Evaluation Options"]}),e.jsxs(bt,{className:"mt-4 space-y-4 pl-6",children:[e.jsx(w,{control:t.control,name:"trigger.after",render:({field:n})=>{const r=n.value??[];return e.jsxs(S,{children:[e.jsx(b,{children:"Evaluate trigger only after observing an event matching"}),e.jsx(y,{children:e.jsx(Te,{selectedEvents:r,onToggleEvent:l=>{const o=r.includes(l)?r.filter(a=>a!==l):[...r,l];n.onChange(o)}})}),e.jsx(k,{})]})}}),e.jsx(w,{control:t.control,name:"trigger.match_related",render:({field:n})=>{const r=n.value?.["prefect.resource.id"]??[],l=Array.isArray(r)?r:[r];return e.jsxs(S,{children:[e.jsx(b,{children:"Filter for events related to"}),e.jsx(y,{children:e.jsx(_e,{selectedResourceIds:l,onToggleResource:o=>{const a=l.includes(o)?l.filter(h=>h!==o):[...l,o];a.length>0?n.onChange({"prefect.resource.id":a}):n.onChange({})}})}),e.jsx(k,{})]})}})]})]})]})},zt=2,Jt=40,Gt=({selectedDeploymentIds:t,onSelectDeploymentIds:s})=>{const[n,r]=m.useState(""),l=m.useDeferredValue(n),[o,a]=m.useState(0),h=m.useRef(null),p=m.useRef(null),u=m.useMemo(()=>new Set(t),[t]);m.useEffect(()=>{const x=h.current;if(!x)return;const j=new ResizeObserver(C=>{for(const T of C)a(T.contentRect.width)});return j.observe(x),()=>j.disconnect()},[]);const{data:c=[]}=L(xe({deployments:l?{operator:"and_",name:{like_:l}}:void 0,limit:100,offset:0,sort:"NAME_ASC"})),{data:f=[]}=L(xe({deployments:u.size>0?{operator:"and_",id:{any_:t}}:void 0,limit:u.size||1,offset:0,sort:"NAME_ASC"},{enabled:u.size>0})),i=x=>{const j=new Set(u);u.has(x)?j.delete(x):j.add(x),s(Array.from(j))},d=()=>{s([])},g=m.useCallback(x=>{const j=p.current;if(!j||o===0||x.length===0)return Math.min(x.length,zt);const C=x.length>1?o-Jt:o;let T=0;for(let A=0;A<x.length&&(j.textContent=x.slice(0,A+1).join(", "),j.offsetWidth<=C);A++)T=A+1;return T===x.length?x.length:Math.max(1,T)},[o]),v=()=>{if(u.size===0)return"All deployments";const x=f.filter(A=>u.has(A.id)).map(A=>A.name),j=g(x),C=x.slice(0,j),T=x.length-j;return e.jsxs("div",{ref:h,className:"flex flex-1 min-w-0 items-center gap-2",children:[e.jsx("div",{className:"flex flex-1 min-w-0 items-center gap-2 overflow-hidden",children:e.jsx("span",{className:"truncate",children:C.join(", ")})}),T>0&&e.jsxs(re,{variant:"bodySmall",className:"shrink-0",children:["+ ",T]}),e.jsx("div",{ref:p,className:"absolute invisible whitespace-nowrap","aria-hidden":"true"})]})},I=m.useMemo(()=>c.filter(x=>!l||x.name.toLowerCase().includes(l.toLowerCase())),[c,l]);return e.jsxs(D,{children:[e.jsx(R,{"aria-label":"Select deployments",selected:u.size===0,children:v()}),e.jsxs(M,{children:[e.jsx(O,{value:n,onValueChange:r,placeholder:"Search deployments..."}),e.jsxs(V,{children:[e.jsx(W,{children:"No deployments found"}),e.jsxs(F,{children:[e.jsxs(N,{"aria-label":"All deployments",onSelect:d,closeOnSelect:!1,value:"__all__",children:[e.jsx(ge,{checked:u.size===0}),"All deployments"]}),I.map(x=>e.jsxs(N,{"aria-label":x.name,onSelect:()=>i(x.id),closeOnSelect:!1,value:x.id,children:[e.jsx(ge,{checked:u.has(x.id)}),x.name]},x.id))]})]})]})]})},Ht=[{value:"Reactive",label:"Enters"},{value:"Proactive",label:"Stays in"}],Yt=30,ne=()=>{const t=_();return e.jsx(w,{control:t.control,name:"trigger.posture",render:({field:s})=>e.jsx(S,{children:e.jsx(y,{children:e.jsxs(B,{value:s.value,onValueChange:n=>{const r=s.value;if(s.onChange(n),r==="Reactive"&&n==="Proactive"){const l=t.getValues("trigger.expect")??[];t.setValue("trigger.after",l),t.setValue("trigger.expect",[]),t.getValues("trigger.within")===0&&t.setValue("trigger.within",Yt)}else if(r==="Proactive"&&n==="Reactive"){const l=t.getValues("trigger.after")??[];t.setValue("trigger.expect",l),t.setValue("trigger.after",[])}},children:[e.jsx(Q,{"aria-label":"select posture",className:"w-[160px]",children:e.jsx(z,{placeholder:"Select posture"})}),e.jsx(J,{children:Ht.map(n=>e.jsx(G,{value:n.value,children:n.label},n.value))})]})})})})},Kt=86400,Xt=30*Kt,Zt=[{value:"prefect.deployment.ready",label:"Ready"},{value:"prefect.deployment.not-ready",label:"Not Ready"},{value:"prefect.deployment.disabled",label:"Disabled"}],Pe="prefect.deployment.",$e="prefect.deployment.*",es=t=>t?(Array.isArray(t)?t:[t]).filter(n=>n!==$e).map(n=>n.replace(Pe,"")):[],ts=t=>t.length===0?$e:t.map(s=>`${Pe}${s}`),ss=()=>{const t=_(),s=E({name:"trigger.posture"}),n=E({name:"trigger.match"}),r=m.useMemo(()=>{const a=n?.["prefect.resource.id"];return es(a)},[n]),l=m.useCallback(o=>{const a=t.getValues("trigger.match")??{};t.setValue("trigger.match",{...a,"prefect.resource.id":ts(o)})},[t]);return e.jsxs("div",{className:"space-y-4",children:[e.jsxs(S,{children:[e.jsx(b,{children:"Deployments"}),e.jsx(y,{children:e.jsx(Gt,{selectedDeploymentIds:r,onSelectDeploymentIds:l})})]}),e.jsxs(S,{children:[e.jsx(b,{children:"Deployment"}),e.jsxs("div",{className:"grid gap-2",style:{gridTemplateColumns:"10rem 1fr"},children:[e.jsx(ne,{}),e.jsx(w,{control:t.control,name:"trigger.expect",render:({field:o})=>{const a=o.value?.[0];return e.jsxs(B,{value:a??"",onValueChange:h=>o.onChange([h]),children:[e.jsx(Q,{className:"w-full",children:e.jsx(z,{placeholder:"Select status"})}),e.jsx(J,{children:Zt.map(h=>e.jsx(G,{value:h.value,children:h.label},h.value))})]})}})]})]}),s==="Proactive"&&e.jsx(w,{control:t.control,name:"trigger.within",render:({field:o})=>e.jsxs(S,{children:[e.jsx(b,{children:"Within"}),e.jsx(y,{children:e.jsx(se,{value:o.value??0,onChange:o.onChange,min:10,max:Xt})}),e.jsx(k,{})]})})]})},rs=2;function ns({selectedFlowIds:t,onToggleFlow:s,emptyMessage:n="Any flow"}){const[r,l]=m.useState(""),o=m.useDeferredValue(r),{data:a=[]}=L(ie({flows:o?{operator:"and_",name:{like_:o}}:void 0,limit:100,offset:0,sort:"NAME_ASC"})),{data:h=[]}=L(ie({flows:t.length>0?{operator:"and_",id:{any_:t}}:void 0,limit:t.length||1,offset:0,sort:"NAME_ASC"},{enabled:t.length>0})),p=m.useMemo(()=>a.filter(c=>!o||c.name.toLowerCase().includes(o.toLowerCase())),[a,o]),u=()=>{if(t.length===0)return e.jsx("span",{className:"text-muted-foreground",children:n});const f=h.filter(d=>t.includes(d.id)).map(d=>d.name).slice(0,rs),i=t.length-f.length;return e.jsxs("div",{className:"flex min-w-0 items-center justify-start gap-1",children:[e.jsx("span",{className:"truncate min-w-0 text-left",children:f.join(", ")}),i>0&&e.jsxs("span",{className:"shrink-0 text-muted-foreground",children:["+",i]})]})};return e.jsxs(D,{children:[e.jsx(R,{selected:t.length>0,children:u()}),e.jsxs(M,{children:[e.jsx(O,{value:r,onValueChange:l,placeholder:"Search flows..."}),e.jsxs(V,{children:[e.jsx(W,{children:"No flows found"}),e.jsx(F,{children:p.map(c=>e.jsx(N,{selected:t.includes(c.id),onSelect:()=>{s(c.id),l("")},closeOnSelect:!1,value:c.id,children:c.name},c.id))})]})]})]})}const P="All run states",$="All except scheduled";function os(t){return t.length!==We.length-1?!1:!t.includes("Scheduled")}function as({selectedStates:t,onStateChange:s,emptyMessage:n="Any state"}){const[r,l]=m.useState(""),o=m.useDeferredValue(r),a=m.useMemo(()=>t.length===0?P:os(t)?$:t,[t]),h=m.useMemo(()=>{const i=o.toLowerCase();return We.filter(d=>d.toLowerCase().includes(i))},[o]),p=m.useMemo(()=>{const i=o.toLowerCase();return P.toLowerCase().includes(i)||$.toLowerCase().includes(i)},[o]),u=i=>{i===P?s([]):i===$&&s([...ft]),l("")},c=i=>{t.includes(i)?s(t.filter(d=>d!==i)):s([...t,i]),l("")},f=()=>a===P?e.jsx("span",{className:"text-muted-foreground",children:n}):a===$?e.jsx("span",{children:"All except scheduled"}):e.jsx("div",{className:"flex flex-wrap gap-1",children:t.map(i=>e.jsx(je,{type:be[i],name:i,className:"cursor-pointer"},i))});return e.jsxs(D,{children:[e.jsx(R,{selected:t.length>0,children:f()}),e.jsxs(M,{children:[e.jsx(O,{value:r,onValueChange:l,placeholder:"Search states..."}),e.jsx(W,{children:"No state found"}),e.jsx(V,{children:e.jsxs(F,{children:[p&&e.jsxs(e.Fragment,{children:[e.jsx(N,{selected:a===P,onSelect:()=>u(P),value:P,closeOnSelect:!1,children:"All run states"},P),e.jsx(N,{selected:a===$,onSelect:()=>u($),value:$,closeOnSelect:!1,children:"All except scheduled"},$)]}),h.map(i=>e.jsx(N,{selected:t.includes(i),onSelect:()=>c(i),value:i,closeOnSelect:!1,children:e.jsx(je,{type:be[i],name:i})},i))]})})]})]})}function ls(t){return t.length===0?["prefect.flow-run.*"]:t.map(s=>`prefect.flow-run.${s}`)}function cs(t){return!t||t.length===0?[]:t.includes("prefect.flow-run.*")?[]:t.filter(s=>s.startsWith("prefect.flow-run.")).map(s=>s.replace("prefect.flow-run.",""))}function is(t){if(!t)return[];const s=t["prefect.resource.id"];return s?(Array.isArray(s)?s:[s]).filter(r=>r.startsWith("prefect.flow.")).map(r=>r.replace("prefect.flow.","")):[]}function us(t){if(!t)return[];const s=t["prefect.resource.id"];return s?(Array.isArray(s)?s:[s]).filter(r=>r.startsWith("prefect.tag.")).map(r=>r.replace("prefect.tag.","")):[]}function Ae(t,s){const n=t.map(a=>`prefect.flow.${a}`),r=s.map(a=>`prefect.tag.${a}`);if(n.length===0&&r.length===0)return{};const l=n.length>0?"flow":"tag",o=[...n,...r];return{"prefect.resource.role":l,"prefect.resource.id":o}}const ds=()=>{const t=_(),s=E({name:"trigger.posture"}),n=s==="Proactive"?"trigger.after":"trigger.expect",r=E({name:"trigger.match_related"}),l=is(r),o=us(r),a=u=>{const c=l,f=c.includes(u)?c.filter(d=>d!==u):[...c,u],i=f.length>0?[]:o;t.setValue("trigger.match_related",Ae(f,i))},h=u=>{t.setValue("trigger.match_related",Ae(l,u))},p=l.length===0;return e.jsxs("div",{className:"space-y-4",children:[e.jsxs(S,{children:[e.jsx(b,{children:"Flows"}),e.jsx(y,{children:e.jsx(ns,{selectedFlowIds:l,onToggleFlow:a,emptyMessage:"All flows"})})]}),p&&e.jsxs(S,{children:[e.jsx(b,{children:"Flow Run Tags"}),e.jsx(y,{children:e.jsx(wt,{value:o,onChange:h,placeholder:"All tags"})})]}),e.jsxs(S,{children:[e.jsx(b,{children:"Flow Run"}),e.jsxs("div",{className:"grid grid-cols-[10rem_1fr] gap-2",children:[e.jsx(ne,{}),e.jsx(w,{control:t.control,name:n,render:({field:u})=>{const c=u.value??[],f=cs(c);return e.jsx(y,{children:e.jsx(as,{selectedStates:f,onStateChange:i=>{u.onChange(ls(i))},emptyMessage:"Any state"})})}})]})]}),s==="Proactive"&&e.jsx(w,{control:t.control,name:"trigger.within",render:({field:u})=>e.jsxs(S,{children:[e.jsx(b,{children:"For"}),e.jsx(y,{children:e.jsx(se,{value:u.value??0,onChange:u.onChange,min:0})}),e.jsx(k,{})]})})]})},hs=({defaultValue:t="Form",value:s,onValueChange:n,formContent:r,jsonContent:l})=>{const o=s!==void 0?{value:s,onValueChange:n}:{defaultValue:t};return e.jsxs(rt,{...o,children:[e.jsx("div",{className:"flex justify-center",children:e.jsxs(nt,{children:[e.jsx(ve,{value:"Form",children:"Form"}),e.jsx(ve,{value:"JSON",children:"JSON"})]})}),e.jsx(Se,{value:"Form",children:r}),e.jsx(Se,{value:"JSON",children:l})]})},ms=({value:t,onChange:s,error:n})=>{const[r,l]=m.useState(null),o=()=>{try{const h=JSON.parse(t);s(JSON.stringify(h,null,2))}catch{}},a=h=>{try{const p=JSON.parse(h);return Oe.parse(p),l(null),!0}catch(p){return p instanceof SyntaxError?l("Invalid JSON syntax"):p instanceof Fe&&l(p.errors[0]?.message??"Invalid trigger configuration"),!1}};return e.jsxs("div",{className:"space-y-2",children:[e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsx(pe,{children:"Trigger Configuration"}),e.jsx(U,{variant:"ghost",size:"sm",onClick:o,children:"Format"})]}),e.jsxs("p",{className:"text-sm text-muted-foreground",children:["Edit the trigger configuration as JSON."," ",e.jsx("a",{href:"https://docs.prefect.io/v3/automate/events/automations-triggers",target:"_blank",rel:"noopener noreferrer",className:"underline hover:text-foreground",children:"View documentation"})]}),e.jsx(ot,{value:t,onChange:s,onBlur:()=>a(t)}),(r||n)&&e.jsx("p",{className:"text-sm text-destructive",children:r||n})]})},Ee={"deployment-status":"Deployment status","flow-run-state":"Flow run state","work-pool-status":"Work pool status","work-queue-status":"Work queue status",custom:"Custom"},ps=({onValueChange:t,value:s})=>e.jsxs("div",{className:"space-y-2",children:[e.jsx(pe,{htmlFor:"automations-trigger-template-select",children:"Trigger Template"}),e.jsxs(B,{value:s,onValueChange:t,children:[e.jsx(Q,{id:"automations-trigger-template-select",className:"w-full",children:e.jsx(z,{placeholder:"Select template"})}),e.jsx(J,{children:e.jsx(De,{children:Object.keys(Ee).map(n=>e.jsx(G,{value:n,children:Ee[n]},n))})})]})]}),fs=({onTemplateChange:t})=>{const s=_();return e.jsx(w,{control:s.control,name:"triggerTemplate",render:({field:n})=>e.jsx(S,{children:e.jsx(y,{children:e.jsx(ps,{value:n.value,onValueChange:r=>{n.onChange(r),t?.(r)}})})})})},xs={type:"event",posture:"Reactive",threshold:1,within:0},gs=t=>{switch(t){case"flow-run-state":return{type:"event",match:{"prefect.resource.id":"prefect.flow-run.*"},match_related:{},after:[],expect:["prefect.flow-run.*"],for_each:["prefect.resource.id"],posture:"Reactive",threshold:1,within:0};case"deployment-status":return{type:"event",match:{"prefect.resource.id":"prefect.deployment.*"},match_related:{},after:[],expect:["prefect.deployment.not-ready"],for_each:["prefect.resource.id"],posture:"Reactive",threshold:1,within:0};case"work-pool-status":return{type:"event",match:{"prefect.resource.id":"prefect.work-pool.*"},match_related:{},after:[],expect:["prefect.work-pool.not-ready","prefect.work-pool.not_ready"],for_each:["prefect.resource.id"],posture:"Reactive",threshold:1,within:0};case"work-queue-status":return{type:"event",match:{"prefect.resource.id":"prefect.work-queue.*"},match_related:{},after:[],expect:["prefect.work-queue.not-ready"],for_each:["prefect.resource.id"],posture:"Reactive",threshold:1,within:0};case"custom":return{type:"event",match:{"prefect.resource.id":["prefect.flow-run.*"]},match_related:{},after:[],expect:["prefect.flow-run.Failed"],for_each:[],posture:"Reactive",threshold:5,within:60};default:return xs}};function js({selectedWorkPoolIds:t,onToggleWorkPool:s,emptyMessage:n="All work pools"}){const[r,l]=m.useState(""),o=m.useDeferredValue(r),{data:a=[]}=L(me()),h=m.useMemo(()=>a.filter(c=>c.status!==null).filter(c=>!o||c.name.toLowerCase().includes(o.toLowerCase())),[a,o]),p=m.useMemo(()=>a.filter(c=>t.includes(c.id)),[a,t]),u=()=>{if(t.length===0)return e.jsx("span",{className:"text-muted-foreground",children:n});const c=p.map(f=>f.name);return e.jsx("span",{className:"truncate min-w-0 text-left",children:c.join(", ")})};return e.jsxs(D,{children:[e.jsx(R,{selected:t.length>0,children:u()}),e.jsxs(M,{children:[e.jsx(O,{value:r,onValueChange:l,placeholder:"Search work pools..."}),e.jsxs(V,{children:[e.jsx(W,{children:"No work pools found"}),e.jsx(F,{children:h.map(c=>e.jsx(N,{selected:t.includes(c.id),onSelect:()=>{s(c.id),l("")},closeOnSelect:!1,value:c.id,children:c.name},c.id))})]})]})]})}const oe=[{value:"ready",label:"Ready",events:["prefect.work-pool.ready"]},{value:"not_ready",label:"Not Ready",events:["prefect.work-pool.not-ready","prefect.work-pool.not_ready"]},{value:"paused",label:"Paused",events:["prefect.work-pool.paused"]}];function Le(t){if(!t||t.length===0)return"not_ready";for(const s of oe)if(s.events.some(n=>t.includes(n)))return s.value;return"not_ready"}function vs(t){const s=oe.find(n=>n.value===t);return s?[...s.events]:[]}function Ss(t){return oe.filter(s=>s.value!==t).flatMap(s=>[...s.events])}function bs(t){if(!t)return[];const s=t["prefect.resource.id"];return s?s==="prefect.work-pool.*"?[]:(Array.isArray(s)?s:[s]).filter(r=>r.startsWith("prefect.work-pool.")&&r!=="prefect.work-pool.*").map(r=>r.replace("prefect.work-pool.","")):[]}function ws(t){return t.length===0?{"prefect.resource.id":"prefect.work-pool.*"}:{"prefect.resource.id":t.map(s=>`prefect.work-pool.${s}`)}}const ys=()=>{const t=_(),s=E({name:"trigger.posture"}),n=E({name:"trigger.expect"}),r=E({name:"trigger.after"}),l=Le(s==="Proactive"?r:n),o=a=>{const h=vs(a),p=Ss(a);s==="Proactive"?(t.setValue("trigger.after",h),t.setValue("trigger.expect",p)):(t.setValue("trigger.expect",h),t.setValue("trigger.after",[]))};return e.jsxs(B,{value:l,onValueChange:o,children:[e.jsx(Q,{"aria-label":"select status",className:"min-w-0 flex-1",children:e.jsx(z,{placeholder:"Select status"})}),e.jsx(J,{children:oe.map(a=>e.jsx(G,{value:a.value,children:a.label},a.value))})]})},Cs=()=>{const t=_(),s=E({name:"trigger.posture"}),n=E({name:"trigger.match"}),r=bs(n),l=o=>{const a=r,h=a.includes(o)?a.filter(p=>p!==o):[...a,o];t.setValue("trigger.match",ws(h))};return e.jsxs("div",{className:"space-y-4",children:[e.jsxs(S,{children:[e.jsx(b,{children:"Work Pools"}),e.jsx(y,{children:e.jsx(js,{selectedWorkPoolIds:r,onToggleWorkPool:l,emptyMessage:"All work pools"})})]}),e.jsxs(S,{children:[e.jsx(b,{children:"Work Pool"}),e.jsxs("div",{className:"flex gap-2",children:[e.jsx(ne,{}),e.jsx(ys,{})]})]}),s==="Proactive"&&e.jsx(w,{control:t.control,name:"trigger.within",render:({field:o})=>e.jsxs(S,{children:[e.jsx(b,{children:"For"}),e.jsx(y,{children:e.jsx(se,{value:o.value??30,onChange:o.onChange,min:0})}),e.jsx(k,{})]})})]})};function Ns({selectedWorkPoolIds:t,onToggleWorkPool:s,emptyMessage:n="All work pools"}){const[r,l]=m.useState(""),o=m.useDeferredValue(r),{data:a=[]}=L(me({limit:100,offset:0})),h=m.useMemo(()=>a.filter(u=>u.status?o?u.name.toLowerCase().includes(o.toLowerCase()):!0:!1),[a,o]),p=()=>{if(t.length===0)return e.jsx("span",{className:"text-muted-foreground",children:n});const u=a.filter(c=>t.includes(c.id)).map(c=>c.name);return e.jsx("span",{className:"truncate min-w-0 text-left",children:u.join(", ")})};return e.jsxs(D,{children:[e.jsx(R,{selected:t.length>0,children:p()}),e.jsxs(M,{children:[e.jsx(O,{value:r,onValueChange:l,placeholder:"Search work pools..."}),e.jsxs(V,{children:[e.jsx(W,{children:"No work pools found"}),e.jsx(F,{children:h.map(u=>e.jsx(N,{selected:t.includes(u.id),onSelect:()=>{s(u.id),l("")},closeOnSelect:!1,value:u.id,children:u.name},u.id))})]})]})]})}function ks({selectedWorkQueueIds:t,onToggleWorkQueue:s,workPoolIds:n=[],emptyMessage:r="All work queues"}){const[l,o]=m.useState(""),a=m.useDeferredValue(l),{data:h=[]}=L(Me({limit:100,offset:0})),p=m.useMemo(()=>h.filter(f=>n.length>0&&(!f.work_pool_id||!n.includes(f.work_pool_id))?!1:a?f.name.toLowerCase().includes(a.toLowerCase()):!0),[h,n,a]),u=m.useMemo(()=>{const f={};for(const d of p){const g=d.work_pool_name??"Unknown";f[g]||(f[g]=[]),f[g].push(d)}return Object.keys(f).sort((d,g)=>d.localeCompare(g)).map(d=>({poolName:d,queues:f[d].sort((g,v)=>g.name.localeCompare(v.name))}))},[p]),c=()=>{if(t.length===0)return e.jsx("span",{className:"text-muted-foreground",children:r});const f=h.filter(i=>t.includes(i.id)).map(i=>i.name);return e.jsx("span",{className:"truncate min-w-0 text-left",children:f.join(", ")})};return e.jsxs(D,{children:[e.jsx(R,{selected:t.length>0,children:c()}),e.jsxs(M,{children:[e.jsx(O,{value:l,onValueChange:o,placeholder:"Search work queues..."}),e.jsxs(V,{children:[e.jsx(W,{children:"No work queues found"}),u.map(f=>e.jsx(F,{heading:f.poolName,children:f.queues.map(i=>e.jsx(N,{selected:t.includes(i.id),onSelect:()=>{s(i.id),o("")},closeOnSelect:!1,value:i.id,children:i.name},i.id))},f.poolName))]})]})]})}const _s=[{value:"prefect.work-queue.ready",label:"Ready"},{value:"prefect.work-queue.not-ready",label:"Not Ready"},{value:"prefect.work-queue.paused",label:"Paused"}];function Ts(t){if(!t)return[];const s=t["prefect.resource.id"];return s?(Array.isArray(s)?s:[s]).filter(r=>r.startsWith("prefect.work-pool.")).map(r=>r.replace("prefect.work-pool.","")):[]}function As(t){if(!t)return[];const s=t["prefect.resource.id"];if(!s)return[];const n=Array.isArray(s)?s:[s];return n.includes("prefect.work-queue.*")?[]:n.filter(r=>r.startsWith("prefect.work-queue.")).map(r=>r.replace("prefect.work-queue.",""))}function Es(t){return t.length===0?{}:{"prefect.resource.role":"work-pool","prefect.resource.id":t.map(n=>`prefect.work-pool.${n}`)}}function Ls(t){return t.length===0?{"prefect.resource.id":"prefect.work-queue.*"}:{"prefect.resource.id":t.map(n=>`prefect.work-queue.${n}`)}}const Fs=()=>{const t=_(),s=E({name:"trigger.posture"}),n=E({name:"trigger.match_related"}),r=E({name:"trigger.match"}),l=Ts(n),o=As(r),a=p=>{const u=l,c=u.includes(p)?u.filter(f=>f!==p):[...u,p];t.setValue("trigger.match_related",Es(c))},h=p=>{const u=o,c=u.includes(p)?u.filter(f=>f!==p):[...u,p];t.setValue("trigger.match",Ls(c))};return e.jsxs("div",{className:"space-y-4",children:[e.jsxs(S,{children:[e.jsx(b,{children:"Work Pools"}),e.jsx(y,{children:e.jsx(Ns,{selectedWorkPoolIds:l,onToggleWorkPool:a,emptyMessage:"All work pools"})})]}),e.jsxs(S,{children:[e.jsx(b,{children:"Work Queues"}),e.jsx(y,{children:e.jsx(ks,{selectedWorkQueueIds:o,onToggleWorkQueue:h,workPoolIds:l,emptyMessage:"All work queues"})})]}),e.jsxs(S,{children:[e.jsx(b,{children:"Work Queue"}),e.jsxs("div",{className:"grid grid-cols-[10rem_1fr] gap-2",children:[e.jsx(ne,{}),e.jsx(w,{control:t.control,name:"trigger.expect",render:({field:p})=>{const u=p.value?.[0];return e.jsx(y,{children:e.jsxs(B,{value:u??"",onValueChange:c=>p.onChange([c]),children:[e.jsx(Q,{className:"w-full",children:e.jsx(z,{placeholder:"Select status"})}),e.jsx(J,{children:_s.map(c=>e.jsx(G,{value:c.value,children:c.label},c.value))})]})})}})]})]}),s==="Proactive"&&e.jsx(w,{control:t.control,name:"trigger.within",render:({field:p})=>e.jsxs(S,{children:[e.jsx(b,{children:"For"}),e.jsx(y,{children:e.jsx(se,{value:p.value??0,onChange:p.onChange,min:0})}),e.jsx(k,{})]})})]})},Ds=()=>{const t=_(),s=t.watch("triggerTemplate"),n=t.watch("trigger"),[r,l]=m.useState("Form"),[o,a]=m.useState(""),[h,p]=m.useState(void 0),u=m.useCallback(()=>JSON.stringify(n,null,2),[n]);m.useEffect(()=>{r==="Form"&&a(u())},[r,u]);const c=m.useCallback(g=>{try{const v=JSON.parse(g);return{valid:!0,trigger:Oe.parse(v)}}catch(v){return v instanceof SyntaxError?{valid:!1,error:"Invalid JSON syntax"}:v instanceof Fe?{valid:!1,error:v.errors[0]?.message??"Invalid trigger configuration"}:{valid:!1,error:"Unknown error"}}},[]),f=m.useCallback(g=>{if(r!==g){if(g==="Form"){const v=c(o);if(!v.valid){p(v.error);return}v.trigger&&t.setValue("trigger",v.trigger),p(void 0)}else a(u()),p(void 0);l(g)}},[r,o,c,t,u]),i=m.useCallback(g=>{a(g);const v=c(g);v.valid&&v.trigger&&(t.setValue("trigger",v.trigger),p(void 0))},[c,t]),d=g=>{const v=gs(g);t.setValue("trigger",v),a(JSON.stringify(v,null,2)),p(void 0)};return e.jsxs("div",{className:"space-y-6",children:[e.jsx(fs,{onTemplateChange:d}),s&&e.jsx(hs,{value:r,onValueChange:f,formContent:e.jsx(Rs,{template:s}),jsonContent:e.jsx(ms,{value:o,onChange:i,error:h})})]})},Rs=({template:t})=>{switch(t){case"flow-run-state":return e.jsx(ds,{});case"deployment-status":return e.jsx(ss,{});case"work-pool-status":return e.jsx(Cs,{});case"work-queue-status":return e.jsx(Fs,{});case"custom":return e.jsx(Qt,{});default:return null}},ce=["Trigger","Actions","Details"],Ms={actions:[{type:void 0}],trigger:{type:"event",posture:"Reactive",threshold:1,within:0}},Gs=({defaultValues:t={},onSubmit:s,submitLabel:n="Save",isSubmitting:r=!1})=>{const o=!!(t&&Object.keys(t).length>0)?new Set([0,1,2]):new Set([0]),a=ut(ce.length,0,o),h=ze({resolver:Be(ht),defaultValues:{...Ms,...t}}),p=ce[a.currentStep],u={Trigger:{render:()=>e.jsx(Ds,{}),trigger:()=>h.trigger("trigger")},Actions:{render:()=>e.jsx(Mt,{}),trigger:()=>h.trigger("actions")},Details:{render:()=>e.jsx(Ot,{}),trigger:()=>h.trigger(["description","name"])}},c=async f=>{await u[f].trigger()&&a.incrementStep()};return e.jsx(it,{...h,children:e.jsx("form",{onSubmit:f=>{h.handleSubmit(s)(f)},children:e.jsxs("div",{className:"flex flex-col gap-8",children:[e.jsx(dt,{steps:ce,currentStepNum:a.currentStep,onClick:f=>a.changeStep(f.stepNum),completedSteps:a.completedStepsSet,visitedSteps:a.visitedStepsSet}),e.jsxs(at,{className:"p-4 pt-8",children:[e.jsxs(lt,{children:[u[p].render(),e.jsx(k,{children:h.formState.errors.root?.message})]}),e.jsxs(ct,{className:"mt-6 flex gap-2 justify-end",children:[e.jsx(U,{type:"button",variant:"outline",children:e.jsx(Ue,{to:"/automations",children:"Cancel"})}),e.jsx(U,{disabled:a.isStartingStep,type:"button",variant:"outline",onClick:a.decrementStep,children:"Previous"}),a.isFinalStep?e.jsx(U,{type:"submit",loading:r,children:n},"save"):e.jsx(U,{type:"button",onClick:()=>{c(p)},children:"Next"},"next")]})]})]})})})};export{Gs as A};
|
|
2
|
+
//# sourceMappingURL=automation-wizard-DPKDA6ji.js.map
|