prefect 3.6.15__py3-none-any.whl → 3.6.16.dev3__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.
Files changed (259) hide show
  1. prefect/__init__.py +20 -0
  2. prefect/_build_info.py +3 -3
  3. prefect/_internal/analytics/__init__.py +80 -0
  4. prefect/_internal/analytics/_config.py +2 -0
  5. prefect/_internal/analytics/ci_detection.py +39 -0
  6. prefect/_internal/analytics/client.py +132 -0
  7. prefect/_internal/analytics/device_id.py +55 -0
  8. prefect/_internal/analytics/emit.py +90 -0
  9. prefect/_internal/analytics/enabled.py +33 -0
  10. prefect/_internal/analytics/events.py +14 -0
  11. prefect/_internal/analytics/milestones.py +177 -0
  12. prefect/_internal/analytics/notice.py +60 -0
  13. prefect/_internal/analytics/service.py +238 -0
  14. prefect/analytics/__init__.py +67 -0
  15. prefect/deployments/runner.py +20 -0
  16. prefect/flow_engine.py +16 -0
  17. prefect/flows.py +8 -0
  18. prefect/logging/formatters.py +24 -1
  19. prefect/server/ui-v2/assets/{artifact-card-BBzQR-Cj.js → artifact-card-BclosG8t.js} +2 -2
  20. prefect/server/ui-v2/assets/{artifact-card-BBzQR-Cj.js.map → artifact-card-BclosG8t.js.map} +1 -1
  21. prefect/server/ui-v2/assets/artifact._id-C0r4BJr2.js +2 -0
  22. prefect/server/ui-v2/assets/artifact._id-C0r4BJr2.js.map +1 -0
  23. prefect/server/ui-v2/assets/{automation-wizard-EYSfXlQ7.js → automation-wizard-Bmgt6nn8.js} +2 -2
  24. prefect/server/ui-v2/assets/{automation-wizard-EYSfXlQ7.js.map → automation-wizard-Bmgt6nn8.js.map} +1 -1
  25. prefect/server/ui-v2/assets/automation._id-Ccke3KJz.js +2 -0
  26. prefect/server/ui-v2/assets/{automation._id-Dn7jABys.js.map → automation._id-Ccke3KJz.js.map} +1 -1
  27. prefect/server/ui-v2/assets/{automation_._id.edit-COrqswD3.js → automation_._id.edit-BlKPUTVf.js} +2 -2
  28. prefect/server/ui-v2/assets/{automation_._id.edit-COrqswD3.js.map → automation_._id.edit-BlKPUTVf.js.map} +1 -1
  29. prefect/server/ui-v2/assets/{automations-header-DN_dmMXW.js → automations-header-Df2zw3SC.js} +2 -2
  30. prefect/server/ui-v2/assets/{automations-header-DN_dmMXW.js.map → automations-header-Df2zw3SC.js.map} +1 -1
  31. prefect/server/ui-v2/assets/{base-job-template-form-section-De2ACYbw.js → base-job-template-form-section-oZD6U-RW.js} +2 -2
  32. prefect/server/ui-v2/assets/{base-job-template-form-section-De2ACYbw.js.map → base-job-template-form-section-oZD6U-RW.js.map} +1 -1
  33. prefect/server/ui-v2/assets/{block-type-details-Cklc7TkK.js → block-type-details-CYrdaLot.js} +2 -2
  34. prefect/server/ui-v2/assets/{block-type-details-Cklc7TkK.js.map → block-type-details-CYrdaLot.js.map} +1 -1
  35. prefect/server/ui-v2/assets/block-type-logo-CyAWq7mC.js +2 -0
  36. prefect/server/ui-v2/assets/block-type-logo-CyAWq7mC.js.map +1 -0
  37. prefect/server/ui-v2/assets/{block._id-tuz1Bcj2.js → block._id-CBgHrpTP.js} +2 -2
  38. prefect/server/ui-v2/assets/{block._id-tuz1Bcj2.js.map → block._id-CBgHrpTP.js.map} +1 -1
  39. prefect/server/ui-v2/assets/{block_._id.edit-CFEYhF5R.js → block_._id.edit-CW-kdi4O.js} +2 -2
  40. prefect/server/ui-v2/assets/{block_._id.edit-CFEYhF5R.js.map → block_._id.edit-CW-kdi4O.js.map} +1 -1
  41. prefect/server/ui-v2/assets/{catalog-CCPRo7nY.js → catalog-Brh0kn1I.js} +2 -2
  42. prefect/server/ui-v2/assets/{catalog-CCPRo7nY.js.map → catalog-Brh0kn1I.js.map} +1 -1
  43. prefect/server/ui-v2/assets/catalog_._slug-MCgzguIZ.js +2 -0
  44. prefect/server/ui-v2/assets/{catalog_._slug-Bl2J2oI3.js.map → catalog_._slug-MCgzguIZ.js.map} +1 -1
  45. prefect/server/ui-v2/assets/{catalog_._slug_.create-9UD_SxDN.js → catalog_._slug_.create-DBaeHi9Q.js} +2 -2
  46. prefect/server/ui-v2/assets/{catalog_._slug_.create-9UD_SxDN.js.map → catalog_._slug_.create-DBaeHi9Q.js.map} +1 -1
  47. prefect/server/ui-v2/assets/{collapsible-BVQTBG_U.js → collapsible-B_NJS0uJ.js} +2 -2
  48. prefect/server/ui-v2/assets/{collapsible-BVQTBG_U.js.map → collapsible-B_NJS0uJ.js.map} +1 -1
  49. prefect/server/ui-v2/assets/{concurrency-limit._id-CsgRxA0a.js → concurrency-limit._id-qzNUQzQa.js} +2 -2
  50. prefect/server/ui-v2/assets/{concurrency-limit._id-CsgRxA0a.js.map → concurrency-limit._id-qzNUQzQa.js.map} +1 -1
  51. prefect/server/ui-v2/assets/create-BwXG6EIb.js +2 -0
  52. prefect/server/ui-v2/assets/{create-D--LHaji.js.map → create-BwXG6EIb.js.map} +1 -1
  53. prefect/server/ui-v2/assets/{create-BycfZHGQ.js → create-MoiIE9Ms.js} +2 -2
  54. prefect/server/ui-v2/assets/{create-BycfZHGQ.js.map → create-MoiIE9Ms.js.map} +1 -1
  55. prefect/server/ui-v2/assets/data-table-CPkppyg6.js +2 -0
  56. prefect/server/ui-v2/assets/data-table-CPkppyg6.js.map +1 -0
  57. prefect/server/ui-v2/assets/delete-confirmation-dialog-CwDK_2QS.js +2 -0
  58. prefect/server/ui-v2/assets/{delete-confirmation-dialog-DHkm2p8m.js.map → delete-confirmation-dialog-CwDK_2QS.js.map} +1 -1
  59. prefect/server/ui-v2/assets/{deployment-action-header-D5GOooPm.js → deployment-action-header-Vp9YsCJO.js} +2 -2
  60. prefect/server/ui-v2/assets/{deployment-action-header-D5GOooPm.js.map → deployment-action-header-Vp9YsCJO.js.map} +1 -1
  61. prefect/server/ui-v2/assets/{deployment-form-wfg6HeAJ.js → deployment-form-CJcg_6DJ.js} +3 -3
  62. prefect/server/ui-v2/assets/{deployment-form-wfg6HeAJ.js.map → deployment-form-CJcg_6DJ.js.map} +1 -1
  63. prefect/server/ui-v2/assets/{deployment-links-6iugOgDh.js → deployment-links-CIkJIuHh.js} +2 -2
  64. prefect/server/ui-v2/assets/{deployment-links-6iugOgDh.js.map → deployment-links-CIkJIuHh.js.map} +1 -1
  65. prefect/server/ui-v2/assets/deployment._id-C6XrGMp_.js +2 -0
  66. prefect/server/ui-v2/assets/{deployment._id-Ci9zge5n.js.map → deployment._id-C6XrGMp_.js.map} +1 -1
  67. prefect/server/ui-v2/assets/{deployment._id-whsGcHdu.js → deployment._id-CWgTYmTG.js} +2 -2
  68. prefect/server/ui-v2/assets/{deployment._id-whsGcHdu.js.map → deployment._id-CWgTYmTG.js.map} +1 -1
  69. prefect/server/ui-v2/assets/deployment_._id.duplicate-Bg0s0ZJn.js +2 -0
  70. prefect/server/ui-v2/assets/{deployment_._id.duplicate-D9ZWkh8H.js.map → deployment_._id.duplicate-Bg0s0ZJn.js.map} +1 -1
  71. prefect/server/ui-v2/assets/deployment_._id.edit-CnoB0UeG.js +2 -0
  72. prefect/server/ui-v2/assets/{deployment_._id.edit-CS7sObzC.js.map → deployment_._id.edit-CnoB0UeG.js.map} +1 -1
  73. prefect/server/ui-v2/assets/{deployment_._id.run-g7SZuDFi.js → deployment_._id.run-BqPK6rTB.js} +2 -2
  74. prefect/server/ui-v2/assets/{deployment_._id.run-g7SZuDFi.js.map → deployment_._id.run-BqPK6rTB.js.map} +1 -1
  75. prefect/server/ui-v2/assets/{dropdown-menu-0atiOSFo.js → dropdown-menu-D7Gwbd15.js} +2 -2
  76. prefect/server/ui-v2/assets/{dropdown-menu-0atiOSFo.js.map → dropdown-menu-D7Gwbd15.js.map} +1 -1
  77. prefect/server/ui-v2/assets/{event-resource-display-DHiAb1Up.js → event-resource-display-CDRgVKd4.js} +2 -2
  78. prefect/server/ui-v2/assets/{event-resource-display-DHiAb1Up.js.map → event-resource-display-CDRgVKd4.js.map} +1 -1
  79. prefect/server/ui-v2/assets/event._eventDate._eventId-C73GMDkK.js +2 -0
  80. prefect/server/ui-v2/assets/{event._eventDate._eventId-D7Twzb22.js.map → event._eventDate._eventId-C73GMDkK.js.map} +1 -1
  81. prefect/server/ui-v2/assets/{flow-run-graph-BhzuSJLm.js → flow-run-graph-ckiE3mA9.js} +2 -2
  82. prefect/server/ui-v2/assets/{flow-run-graph-BhzuSJLm.js.map → flow-run-graph-ckiE3mA9.js.map} +1 -1
  83. prefect/server/ui-v2/assets/{flow-run._id-CqpH6bvx.js → flow-run._id-BukrNCAq.js} +2 -2
  84. prefect/server/ui-v2/assets/{flow-run._id-CqpH6bvx.js.map → flow-run._id-BukrNCAq.js.map} +1 -1
  85. prefect/server/ui-v2/assets/{flow-run._id-lIIQBD7H.js → flow-run._id-CtI5VZ2M.js} +2 -2
  86. prefect/server/ui-v2/assets/{flow-run._id-lIIQBD7H.js.map → flow-run._id-CtI5VZ2M.js.map} +1 -1
  87. prefect/server/ui-v2/assets/flow-run._id-s1UJuakA.js +4 -0
  88. prefect/server/ui-v2/assets/{flow-run._id-RLy2kBh0.js.map → flow-run._id-s1UJuakA.js.map} +1 -1
  89. prefect/server/ui-v2/assets/{flow-runs-pagination-BATUweRV.js → flow-runs-pagination-SLbYtvaR.js} +2 -2
  90. prefect/server/ui-v2/assets/{flow-runs-pagination-BATUweRV.js.map → flow-runs-pagination-SLbYtvaR.js.map} +1 -1
  91. prefect/server/ui-v2/assets/flow._id-CZ5P0v4N.js +2 -0
  92. prefect/server/ui-v2/assets/{flow._id-BdQGWPKP.js.map → flow._id-CZ5P0v4N.js.map} +1 -1
  93. prefect/server/ui-v2/assets/{form-DLrbC7rV.js → form-mws4law8.js} +2 -2
  94. prefect/server/ui-v2/assets/{form-DLrbC7rV.js.map → form-mws4law8.js.map} +1 -1
  95. prefect/server/ui-v2/assets/{header-BTAWyeXv.js → header-Bes1LmY7.js} +2 -2
  96. prefect/server/ui-v2/assets/{header-BTAWyeXv.js.map → header-Bes1LmY7.js.map} +1 -1
  97. prefect/server/ui-v2/assets/{header-ChFAx5uR.js → header-Bj_zBR-a.js} +2 -2
  98. prefect/server/ui-v2/assets/{header-ChFAx5uR.js.map → header-Bj_zBR-a.js.map} +1 -1
  99. prefect/server/ui-v2/assets/{header-CyQqOj1w.js → header-CPxTHSvz.js} +2 -2
  100. prefect/server/ui-v2/assets/{header-CyQqOj1w.js.map → header-CPxTHSvz.js.map} +1 -1
  101. prefect/server/ui-v2/assets/{index-m48E4KcG.js → index-B8vo2Lrg.js} +5 -5
  102. prefect/server/ui-v2/assets/{index-m48E4KcG.js.map → index-B8vo2Lrg.js.map} +1 -1
  103. prefect/server/ui-v2/assets/{index-D5RT-SAp.js → index-BBeh-3Nh.js} +2 -2
  104. prefect/server/ui-v2/assets/{index-D5RT-SAp.js.map → index-BBeh-3Nh.js.map} +1 -1
  105. prefect/server/ui-v2/assets/index-BLnEvHia.js +2 -0
  106. prefect/server/ui-v2/assets/{index-7i4X9TeK.js.map → index-BLnEvHia.js.map} +1 -1
  107. prefect/server/ui-v2/assets/index-BpKoubXu.js +2 -0
  108. prefect/server/ui-v2/assets/index-BpKoubXu.js.map +1 -0
  109. prefect/server/ui-v2/assets/index-By6YGqR3.js +2 -0
  110. prefect/server/ui-v2/assets/index-By6YGqR3.js.map +1 -0
  111. prefect/server/ui-v2/assets/index-CEi3BlKI.js +2 -0
  112. prefect/server/ui-v2/assets/index-CEi3BlKI.js.map +1 -0
  113. prefect/server/ui-v2/assets/{index-BaWDC4da.js → index-CS-zxv7Z.js} +2 -2
  114. prefect/server/ui-v2/assets/{index-BaWDC4da.js.map → index-CS-zxv7Z.js.map} +1 -1
  115. prefect/server/ui-v2/assets/{index-kP_I5Qfd.js → index-CToHKh4q.js} +2 -2
  116. prefect/server/ui-v2/assets/{index-kP_I5Qfd.js.map → index-CToHKh4q.js.map} +1 -1
  117. prefect/server/ui-v2/assets/{index-CKGj5lSu.js → index-CUVvZndW.js} +2 -2
  118. prefect/server/ui-v2/assets/{index-CKGj5lSu.js.map → index-CUVvZndW.js.map} +1 -1
  119. prefect/server/ui-v2/assets/{index-CxUfZRkN.js → index-CYVn-I3i.js} +2 -2
  120. prefect/server/ui-v2/assets/{index-CxUfZRkN.js.map → index-CYVn-I3i.js.map} +1 -1
  121. prefect/server/ui-v2/assets/{index-CnlN-VC_.js → index-Cun0JN4t.js} +2 -2
  122. prefect/server/ui-v2/assets/{index-CnlN-VC_.js.map → index-Cun0JN4t.js.map} +1 -1
  123. prefect/server/ui-v2/assets/{index-BwCLKpNb.js → index-D6ynV6U7.js} +2 -2
  124. prefect/server/ui-v2/assets/{index-BwCLKpNb.js.map → index-D6ynV6U7.js.map} +1 -1
  125. prefect/server/ui-v2/assets/{index-CHf6xi9j.js → index-DdNUJLRW.js} +2 -2
  126. prefect/server/ui-v2/assets/{index-CHf6xi9j.js.map → index-DdNUJLRW.js.map} +1 -1
  127. prefect/server/ui-v2/assets/{index-CQnWiUE5.js → index-DlHOXQhu.js} +2 -2
  128. prefect/server/ui-v2/assets/{index-CQnWiUE5.js.map → index-DlHOXQhu.js.map} +1 -1
  129. prefect/server/ui-v2/assets/{index-Eqdr6Ff7.js → index-DyVw8YE8.js} +2 -2
  130. prefect/server/ui-v2/assets/{index-Eqdr6Ff7.js.map → index-DyVw8YE8.js.map} +1 -1
  131. prefect/server/ui-v2/assets/{index-Btb_-PDp.js → index-DzRz7D2P.js} +2 -2
  132. prefect/server/ui-v2/assets/{index-Btb_-PDp.js.map → index-DzRz7D2P.js.map} +1 -1
  133. prefect/server/ui-v2/assets/{index-DQGif3jm.js → index-DzUcVNZg.js} +2 -2
  134. prefect/server/ui-v2/assets/{index-DQGif3jm.js.map → index-DzUcVNZg.js.map} +1 -1
  135. prefect/server/ui-v2/assets/{index-DNh9ZBy4.js → index-IBvMMs6S.js} +2 -2
  136. prefect/server/ui-v2/assets/{index-DNh9ZBy4.js.map → index-IBvMMs6S.js.map} +1 -1
  137. prefect/server/ui-v2/assets/index-_kpA__te.js +2 -0
  138. prefect/server/ui-v2/assets/{index-CiSFHkhI.js.map → index-_kpA__te.js.map} +1 -1
  139. prefect/server/ui-v2/assets/index-m9O-nIOl.css +1 -0
  140. prefect/server/ui-v2/assets/{index-lyQav_XM.js → index-wOvyf10b.js} +2 -2
  141. prefect/server/ui-v2/assets/{index-lyQav_XM.js.map → index-wOvyf10b.js.map} +1 -1
  142. prefect/server/ui-v2/assets/{json-input-Ba-BeBcw.js → json-input-Ce-HlRqa.js} +2 -2
  143. prefect/server/ui-v2/assets/{json-input-Ba-BeBcw.js.map → json-input-Ce-HlRqa.js.map} +1 -1
  144. prefect/server/ui-v2/assets/{key-value-DkSKn6jE.js → key-value-XHEZOtZX.js} +2 -2
  145. prefect/server/ui-v2/assets/{key-value-DkSKn6jE.js.map → key-value-XHEZOtZX.js.map} +1 -1
  146. prefect/server/ui-v2/assets/{key._key-Cjx57ymg.js → key._key-LpsMf3zD.js} +2 -2
  147. prefect/server/ui-v2/assets/{key._key-Cjx57ymg.js.map → key._key-LpsMf3zD.js.map} +1 -1
  148. prefect/server/ui-v2/assets/{lazy-markdown-Du2Xu3Yp.js → lazy-markdown-1Hz0xzca.js} +2 -2
  149. prefect/server/ui-v2/assets/{lazy-markdown-Du2Xu3Yp.js.map → lazy-markdown-1Hz0xzca.js.map} +1 -1
  150. prefect/server/ui-v2/assets/{login-DxMF9Jvj.js → login-D5uepl9L.js} +2 -2
  151. prefect/server/ui-v2/assets/{login-DxMF9Jvj.js.map → login-D5uepl9L.js.map} +1 -1
  152. prefect/server/ui-v2/assets/{markdown-input-DPi8zyRr.js → markdown-input-CG6M9zD0.js} +2 -2
  153. prefect/server/ui-v2/assets/{markdown-input-DPi8zyRr.js.map → markdown-input-CG6M9zD0.js.map} +1 -1
  154. prefect/server/ui-v2/assets/python-example-snippet-DRHcUlCX.js +3 -0
  155. prefect/server/ui-v2/assets/{python-example-snippet-DfCFYPN_.js.map → python-example-snippet-DRHcUlCX.js.map} +1 -1
  156. prefect/server/ui-v2/assets/{python-input-mr6GD840.js → python-input-BsUS8fw1.js} +2 -2
  157. prefect/server/ui-v2/assets/{python-input-mr6GD840.js.map → python-input-BsUS8fw1.js.map} +1 -1
  158. prefect/server/ui-v2/assets/{radio-group-Co3cN0Kv.js → radio-group-BUsmwdrt.js} +2 -2
  159. prefect/server/ui-v2/assets/{radio-group-Co3cN0Kv.js.map → radio-group-BUsmwdrt.js.map} +1 -1
  160. prefect/server/ui-v2/assets/{route-error-state-DnBaNT2T.js → route-error-state-BFBpiIhD.js} +2 -2
  161. prefect/server/ui-v2/assets/{route-error-state-DnBaNT2T.js.map → route-error-state-BFBpiIhD.js.map} +1 -1
  162. prefect/server/ui-v2/assets/{schema-form-CWDHSME9.js → schema-form-BwTmkvJk.js} +2 -2
  163. prefect/server/ui-v2/assets/schema-form-BwTmkvJk.js.map +1 -0
  164. prefect/server/ui-v2/assets/{schema-form-input-string-format-datetime-BSWlW_aQ.js → schema-form-input-string-format-datetime-nrb3g-JJ.js} +4 -4
  165. prefect/server/ui-v2/assets/{schema-form-input-string-format-datetime-BSWlW_aQ.js.map → schema-form-input-string-format-datetime-nrb3g-JJ.js.map} +1 -1
  166. prefect/server/ui-v2/assets/{settings-DU5y6tJE.js → settings-CUBtK5aW.js} +2 -2
  167. prefect/server/ui-v2/assets/{settings-DU5y6tJE.js.map → settings-CUBtK5aW.js.map} +1 -1
  168. prefect/server/ui-v2/assets/{sort-filter-DpuWNkQo.js → sort-filter-Cv8zAXMp.js} +2 -2
  169. prefect/server/ui-v2/assets/{sort-filter-DpuWNkQo.js.map → sort-filter-Cv8zAXMp.js.map} +1 -1
  170. prefect/server/ui-v2/assets/{table-bBL6C0ZK.js → table-BBNGfPra.js} +2 -2
  171. prefect/server/ui-v2/assets/{table-bBL6C0ZK.js.map → table-BBNGfPra.js.map} +1 -1
  172. prefect/server/ui-v2/assets/{tags-input-BLPMVWpZ.js → tags-input-DHrnkwjQ.js} +2 -2
  173. prefect/server/ui-v2/assets/{tags-input-BLPMVWpZ.js.map → tags-input-DHrnkwjQ.js.map} +1 -1
  174. prefect/server/ui-v2/assets/task-run-concurrency-limits-reset-dialog-Z8-yFZ2_.js +2 -0
  175. prefect/server/ui-v2/assets/{task-run-concurrency-limits-reset-dialog-S69sih55.js.map → task-run-concurrency-limits-reset-dialog-Z8-yFZ2_.js.map} +1 -1
  176. prefect/server/ui-v2/assets/{task-run._id-Dl3Azs8t.js → task-run._id-BY58gqs2.js} +2 -2
  177. prefect/server/ui-v2/assets/{task-run._id-Dl3Azs8t.js.map → task-run._id-BY58gqs2.js.map} +1 -1
  178. prefect/server/ui-v2/assets/{task-run._id-B_tIDm4K.js → task-run._id-u73Jxfqw.js} +3 -3
  179. prefect/server/ui-v2/assets/{task-run._id-B_tIDm4K.js.map → task-run._id-u73Jxfqw.js.map} +1 -1
  180. prefect/server/ui-v2/assets/task-runs-pagination-DUy3147A.js +2 -0
  181. prefect/server/ui-v2/assets/{task-runs-pagination-VdR-LO4r.js.map → task-runs-pagination-DUy3147A.js.map} +1 -1
  182. prefect/server/ui-v2/assets/{textarea-B3_TtPRi.js → textarea-DUhh6-kq.js} +2 -2
  183. prefect/server/ui-v2/assets/{textarea-B3_TtPRi.js.map → textarea-DUhh6-kq.js.map} +1 -1
  184. prefect/server/ui-v2/assets/timezone-select-D4Q6VBtD.js +2 -0
  185. prefect/server/ui-v2/assets/{timezone-select-BuPYznge.js.map → timezone-select-D4Q6VBtD.js.map} +1 -1
  186. prefect/server/ui-v2/assets/{toggle-group-Cn07UIim.js → toggle-group-7WUJn2Tx.js} +2 -2
  187. prefect/server/ui-v2/assets/{toggle-group-Cn07UIim.js.map → toggle-group-7WUJn2Tx.js.map} +1 -1
  188. prefect/server/ui-v2/assets/use-delete-automation-confirmation-dialog-D4AD5Ndf.js +2 -0
  189. prefect/server/ui-v2/assets/{use-delete-automation-confirmation-dialog-DpdsLH4t.js.map → use-delete-automation-confirmation-dialog-D4AD5Ndf.js.map} +1 -1
  190. prefect/server/ui-v2/assets/{use-delete-block-document-confirmation-dialog-Cq5nGhzr.js → use-delete-block-document-confirmation-dialog-DnwWEGUY.js} +2 -2
  191. prefect/server/ui-v2/assets/{use-delete-block-document-confirmation-dialog-Cq5nGhzr.js.map → use-delete-block-document-confirmation-dialog-DnwWEGUY.js.map} +1 -1
  192. prefect/server/ui-v2/assets/{use-flow-runs-selected-rows-DmQSWBTu.js → use-flow-runs-selected-rows-C-tehPRB.js} +2 -2
  193. prefect/server/ui-v2/assets/{use-flow-runs-selected-rows-DmQSWBTu.js.map → use-flow-runs-selected-rows-C-tehPRB.js.map} +1 -1
  194. prefect/server/ui-v2/assets/{use-get-artifacts-flow-task-runs-DTwcWiqW.js → use-get-artifacts-flow-task-runs-DRWRrmrb.js} +2 -2
  195. prefect/server/ui-v2/assets/{use-get-artifacts-flow-task-runs-DTwcWiqW.js.map → use-get-artifacts-flow-task-runs-DRWRrmrb.js.map} +1 -1
  196. prefect/server/ui-v2/assets/{use-quick-run-CPempwLh.js → use-quick-run-B4Xj-YQQ.js} +2 -2
  197. prefect/server/ui-v2/assets/{use-quick-run-CPempwLh.js.map → use-quick-run-B4Xj-YQQ.js.map} +1 -1
  198. prefect/server/ui-v2/assets/use-state-favicon-au2TZdMV.js +2 -0
  199. prefect/server/ui-v2/assets/{use-state-favicon-M09DmrNy.js.map → use-state-favicon-au2TZdMV.js.map} +1 -1
  200. prefect/server/ui-v2/assets/{use-stepper-CDucnvzp.js → use-stepper-DyIb3vlq.js} +2 -2
  201. prefect/server/ui-v2/assets/{use-stepper-CDucnvzp.js.map → use-stepper-DyIb3vlq.js.map} +1 -1
  202. prefect/server/ui-v2/assets/{utilities-BRCNRcQl.js → utilities-D9Y2wo66.js} +2 -2
  203. prefect/server/ui-v2/assets/{utilities-BRCNRcQl.js.map → utilities-D9Y2wo66.js.map} +1 -1
  204. prefect/server/ui-v2/assets/vendor-recharts-BvvJP9Po.js +34 -0
  205. prefect/server/ui-v2/assets/vendor-recharts-BvvJP9Po.js.map +1 -0
  206. prefect/server/ui-v2/assets/{work-pool-filter-C2tpSS-w.js → work-pool-filter-CSOATj2D.js} +2 -2
  207. prefect/server/ui-v2/assets/{work-pool-filter-C2tpSS-w.js.map → work-pool-filter-CSOATj2D.js.map} +1 -1
  208. prefect/server/ui-v2/assets/work-pool-queue-toggle-Dh7B1zMo.js +2 -0
  209. prefect/server/ui-v2/assets/{work-pool-queue-toggle-BQ9b-Wxy.js.map → work-pool-queue-toggle-Dh7B1zMo.js.map} +1 -1
  210. prefect/server/ui-v2/assets/work-pool._workPoolName-B_NFWXKS.js +2 -0
  211. prefect/server/ui-v2/assets/{work-pool._workPoolName-C_LiL3SE.js.map → work-pool._workPoolName-B_NFWXKS.js.map} +1 -1
  212. prefect/server/ui-v2/assets/{work-pool_._workPoolName.edit-DBHlrVVx.js → work-pool_._workPoolName.edit-Cyzn8g-S.js} +2 -2
  213. prefect/server/ui-v2/assets/{work-pool_._workPoolName.edit-DBHlrVVx.js.map → work-pool_._workPoolName.edit-Cyzn8g-S.js.map} +1 -1
  214. prefect/server/ui-v2/assets/{work-pool_._workPoolName.queue._workQueueName-DkITxJOP.js → work-pool_._workPoolName.queue._workQueueName-DQzqQWPT.js} +2 -2
  215. prefect/server/ui-v2/assets/{work-pool_._workPoolName.queue._workQueueName-DkITxJOP.js.map → work-pool_._workPoolName.queue._workQueueName-DQzqQWPT.js.map} +1 -1
  216. prefect/server/ui-v2/assets/{work-queue-icon-text-D4BWBVDN.js → work-queue-icon-text-BOpcJ8YU.js} +2 -2
  217. prefect/server/ui-v2/assets/{work-queue-icon-text-D4BWBVDN.js.map → work-queue-icon-text-BOpcJ8YU.js.map} +1 -1
  218. prefect/server/ui-v2/index.html +3 -3
  219. {prefect-3.6.15.dist-info → prefect-3.6.16.dev3.dist-info}/METADATA +2 -1
  220. {prefect-3.6.15.dist-info → prefect-3.6.16.dev3.dist-info}/RECORD +223 -211
  221. prefect/server/ui-v2/assets/artifact._id-BFdf1WUA.js +0 -2
  222. prefect/server/ui-v2/assets/artifact._id-BFdf1WUA.js.map +0 -1
  223. prefect/server/ui-v2/assets/automation._id-Dn7jABys.js +0 -2
  224. prefect/server/ui-v2/assets/block-type-logo-Cbpfxded.js +0 -2
  225. prefect/server/ui-v2/assets/block-type-logo-Cbpfxded.js.map +0 -1
  226. prefect/server/ui-v2/assets/catalog_._slug-Bl2J2oI3.js +0 -2
  227. prefect/server/ui-v2/assets/create-D--LHaji.js +0 -2
  228. prefect/server/ui-v2/assets/data-table-rlbkLcrY.js +0 -2
  229. prefect/server/ui-v2/assets/data-table-rlbkLcrY.js.map +0 -1
  230. prefect/server/ui-v2/assets/delete-confirmation-dialog-DHkm2p8m.js +0 -2
  231. prefect/server/ui-v2/assets/deployment._id-Ci9zge5n.js +0 -2
  232. prefect/server/ui-v2/assets/deployment_._id.duplicate-D9ZWkh8H.js +0 -2
  233. prefect/server/ui-v2/assets/deployment_._id.edit-CS7sObzC.js +0 -2
  234. prefect/server/ui-v2/assets/event._eventDate._eventId-D7Twzb22.js +0 -2
  235. prefect/server/ui-v2/assets/flow-run._id-RLy2kBh0.js +0 -4
  236. prefect/server/ui-v2/assets/flow._id-BdQGWPKP.js +0 -2
  237. prefect/server/ui-v2/assets/index-7i4X9TeK.js +0 -2
  238. prefect/server/ui-v2/assets/index-BkiGTHwU.js +0 -2
  239. prefect/server/ui-v2/assets/index-BkiGTHwU.js.map +0 -1
  240. prefect/server/ui-v2/assets/index-COouj_0-.css +0 -1
  241. prefect/server/ui-v2/assets/index-CiSFHkhI.js +0 -2
  242. prefect/server/ui-v2/assets/index-DATPYZfT.js +0 -2
  243. prefect/server/ui-v2/assets/index-DATPYZfT.js.map +0 -1
  244. prefect/server/ui-v2/assets/index-VH4TnZ4e.js +0 -2
  245. prefect/server/ui-v2/assets/index-VH4TnZ4e.js.map +0 -1
  246. prefect/server/ui-v2/assets/python-example-snippet-DfCFYPN_.js +0 -3
  247. prefect/server/ui-v2/assets/schema-form-CWDHSME9.js.map +0 -1
  248. prefect/server/ui-v2/assets/task-run-concurrency-limits-reset-dialog-S69sih55.js +0 -2
  249. prefect/server/ui-v2/assets/task-runs-pagination-VdR-LO4r.js +0 -2
  250. prefect/server/ui-v2/assets/timezone-select-BuPYznge.js +0 -2
  251. prefect/server/ui-v2/assets/use-delete-automation-confirmation-dialog-DpdsLH4t.js +0 -2
  252. prefect/server/ui-v2/assets/use-state-favicon-M09DmrNy.js +0 -2
  253. prefect/server/ui-v2/assets/vendor-recharts-BAN776s_.js +0 -34
  254. prefect/server/ui-v2/assets/vendor-recharts-BAN776s_.js.map +0 -1
  255. prefect/server/ui-v2/assets/work-pool-queue-toggle-BQ9b-Wxy.js +0 -2
  256. prefect/server/ui-v2/assets/work-pool._workPoolName-C_LiL3SE.js +0 -2
  257. {prefect-3.6.15.dist-info → prefect-3.6.16.dev3.dist-info}/WHEEL +0 -0
  258. {prefect-3.6.15.dist-info → prefect-3.6.16.dev3.dist-info}/entry_points.txt +0 -0
  259. {prefect-3.6.15.dist-info → prefect-3.6.16.dev3.dist-info}/licenses/LICENSE +0 -0
@@ -1,2 +1,2 @@
1
- import{j as e,r as m,t as E,L as Qe}from"./vendor-tanstack-BcZfOOfy.js";import{a as Je}from"./zod-Cuos7J7w.js";import{g as _,p as D,q as Ge,Z as Re,c as Ye}from"./vendor-forms-ClCIacbh.js";import{S as B,a as z,b as Q,c as J,d as Me,dk as He,e as G,b5 as Ke,bm as Ve,bp as Oe,ac as R,ad as M,ae as V,af as O,ah as W,ag as I,ai as F,aj as k,I as Y,dl as We,bN as me,p as Z,al as re,br as Xe,be as Ze,ab as ie,M as pe,d4 as Ie,q as U,i as xe,aW as et,a_ as tt,ap as st,cZ as je,ak as ve,aq as be,aw as rt,ax as nt,ay as Se,az as we,L as ot,C as at,o as lt,dm as ct}from"./index-m48E4KcG.js";import{b as w,c as b,d as S,e as y,a as C,F as it}from"./form-DLrbC7rV.js";import{u as ut,S as dt}from"./use-stepper-CDucnvzp.js";import{U as te,T as Pe,A as ht}from"./automation-schema-BIBsyp0j.js";import{T as fe}from"./textarea-B3_TtPRi.js";import{S as mt,R as pt,a as $e,b as ye,c as xt}from"./index-BwCLKpNb.js";import{R as ft,a as gt}from"./radio-group-Co3cN0Kv.js";import{u as jt,C as vt,a as bt,b as St}from"./collapsible-BVQTBG_U.js";import{T as wt}from"./tags-input-BLPMVWpZ.js";const Ce={"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","call-webhook":"Call a webhook"},yt=({index:t})=>{const s=_();return e.jsx(w,{control:s.control,name:`actions.${t}.type`,render:({field:n})=>e.jsxs(b,{children:[e.jsx(S,{children:"Action Type"}),e.jsx(y,{children:e.jsxs(B,{...n,onValueChange:r=>{n.onChange(r);const a=Ct({index:t,type:r});a&&s.setValue(a,te)},children:[e.jsx(z,{"aria-label":"select action",className:"w-full",children:e.jsx(Q,{placeholder:"Select action"})}),e.jsx(J,{children:e.jsxs(Me,{children:[e.jsx(He,{children:"Actions"}),Object.keys(Ce).map(r=>e.jsx(G,{value:r,children:Ce[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 kt=4,ee=({length:t=kt})=>Array.from({length:t},(s,n)=>e.jsx(Ke,{className:"mt-2 p-4 h-2 w-full"},n)),Nt=({index:t})=>{const s=_(),[n,r]=m.useState(""),{data:a,isLoading:o}=E(Ve({offset:0,block_types:{slug:{any_:["webhook"]}}})),l=m.useMemo(()=>a?.map(i=>i.slug)??[],[a]),{data:h,isLoading:p}=E(Oe({block_types:l.length>0?{slug:{any_:l}}:void 0,include_secrets:!1,sort:"BLOCK_TYPE_AND_NAME_ASC",offset:0},{enabled:l.length>0})),d=o||p,c=m.useMemo(()=>!a||!h?[]:a.map(i=>({blockType:i,documents:h.filter(f=>f.block_type_id===i.id)})).filter(i=>i.documents.length>0),[a,h]),x=m.useMemo(()=>{if(!n)return c;const i=n.toLowerCase();return c.map(f=>({...f,documents:f.documents.filter(j=>j.name?.toLowerCase().includes(i))})).filter(f=>f.documents.length>0)},[c,n]),u=m.useCallback(i=>{if(!(!i||!h))return h.find(f=>f.id===i)},[h]);return e.jsxs("div",{className:"space-y-4",children:[e.jsx(w,{control:s.control,name:`actions.${t}.block_document_id`,render:({field:i})=>{const f=u(i.value);return e.jsxs(b,{className:"flex flex-col",children:[e.jsx(S,{children:"Block"}),e.jsxs(R,{children:[e.jsx(M,{selected:!!f,"aria-label":"Select webhook block",children:f?f.name:"Select a webhook block"}),e.jsxs(V,{children:[e.jsx(O,{value:n,onValueChange:r,placeholder:"Search for a block..."}),e.jsx(W,{children:"No webhook blocks found"}),e.jsx(I,{children:d?e.jsx(ee,{}):x.map(j=>e.jsx(F,{heading:j.blockType.name,children:j.documents.map(A=>e.jsx(k,{value:A.id,selected:i.value===A.id,onSelect:i.onChange,children:A.name},A.id))},j.blockType.id))})]})]}),e.jsx(C,{})]})}}),e.jsx(_t,{index:t}),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(Y,{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 webhook payload 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"}),", and"," ",e.jsx("code",{className:"rounded bg-blue-100 px-1 py-0.5 font-mono text-xs dark:bg-blue-900",children:"work_queue"}),"."]})]})]})},_t=({index:t})=>{const s=_(),{validateTemplate:n}=We(),[r,a]=m.useState(null),[o,l]=m.useState(!1),h=s.watch(`actions.${t}.payload`),p=me(h,1e3);return m.useEffect(()=>{(async()=>{if(!p||p.trim()===""){a(null);return}l(!0);try{const c=await n(p);c.valid?a(null):a(c.error)}catch{a(null)}finally{l(!1)}})()},[p,n]),e.jsx(w,{control:s.control,name:`actions.${t}.payload`,render:({field:d})=>e.jsxs(b,{children:[e.jsxs(S,{className:"flex items-center gap-2",children:["Payload",o&&e.jsx(Y,{id:"Loader2",className:"size-3 animate-spin"})]}),e.jsx(y,{children:e.jsx(fe,{...d,value:d.value??"",placeholder:"Enter webhook payload...",className:r?"border-destructive":"",rows:5})}),r&&e.jsx("p",{className:"text-sm text-destructive",children:r}),e.jsx(C,{})]})})},Tt=({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(b,{children:[e.jsx(S,{children:"State"}),e.jsx(y,{children:e.jsx(mt,{value:r.value,onValueChange:r.onChange})}),e.jsx(C,{})]})}),e.jsx(w,{control:s.control,name:`actions.${t}.name`,render:({field:r})=>e.jsxs(b,{children:[e.jsx(S,{children:"Name"}),e.jsx(y,{children:e.jsx(Z,{type:"text",...r,value:r.value??"",placeholder:n?pt[n]:void 0})}),e.jsx(C,{})]})}),e.jsx(w,{control:s.control,name:`actions.${t}.message`,render:({field:r})=>e.jsxs(b,{children:[e.jsx(S,{children:"Message"}),e.jsx(y,{children:e.jsx(fe,{...r,placeholder:"State changed by Automation <id>"})}),e.jsx(C,{})]})})]})},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})},H={value:te,name:"Infer Automation"},At=(t,s)=>{if(s===H.value)return H.name;const n=t?.find(r=>r.id===s);if(n)return n.name},ke=({action:t,index:s})=>{const[n,r]=m.useState(""),a=_(),{data:o,isSuccess:l}=E(Xe()),h=m.useDeferredValue(n),p=m.useMemo(()=>o?o.filter(c=>c.name.toLowerCase().includes(h.toLowerCase())):[],[o,h]),d=H.name.toLowerCase().includes(h.toLowerCase());return e.jsx(w,{control:a.control,name:`actions.${s}.automation_id`,render:({field:c})=>{const x=At(o,c.value);return e.jsxs(b,{className:"flex flex-col",children:[e.jsxs(S,{children:["Automation To ",t]}),e.jsxs(R,{children:[e.jsx(M,{selected:!!x,"aria-label":`Select Automation to ${t}`,children:x??"Select automation"}),e.jsxs(V,{children:[e.jsx(O,{value:n,onValueChange:r,placeholder:"Search for an automation..."}),e.jsx(W,{children:"No automation found"}),e.jsx(I,{children:e.jsxs(F,{children:[d&&e.jsx(k,{selected:c.value===H.value,onSelect:u=>{c.onChange(u),r("")},value:H.value,children:H.name}),l?p.map(u=>e.jsx(k,{selected:c.value===u.id,onSelect:i=>{c.onChange(i),r("")},value:u.id,children:u.name},u.id)):e.jsx(ee,{})]})})]})]}),e.jsx(C,{})]})}})},Et=(t={page:1,limit:100,sort:"NAME_ASC"})=>{const{data:s,status:n}=E(Ze(t)),r=new Set(s?.results.map(l=>l.flow_id)),{data:a,status:o}=E(ie({flows:{operator:"or_",id:{any_:Array.from(r)}},sort:"NAME_DESC",offset:0},{enabled:r.size>0}));return m.useMemo(()=>{if(a&&s){const l=new Map(a.map(i=>[i.id,i])),h=s.results.map(i=>({...i,flow:l.get(i.flow_id)})),{count:p,limit:d,pages:c,page:x}=s;return{data:{count:p,limit:d,pages:c,page:x,results:h},status:"success"}}return o==="error"||n==="error"?{data:void 0,status:"error"}:{data:void 0,status:"pending"}},[s,n,a,o])},q={value:te,name:"Infer Deployment"},Lt=(t,s)=>{if(s===q.value)return q.name;const n=t?.find(r=>r.id===s);if(n)return e.jsx(qe,{deploymentWithFlow:n})},le=({action:t,index:s})=>{const[n,r]=m.useState(""),a=_(),o=a.watch(`actions.${s}.type`),l=D({name:`actions.${s}.deployment_id`}),h=me(n,500),{data:p}=Et({page:1,sort:"NAME_ASC",deployments:{operator:"or_",flow_or_deployment_name:{like_:h}}}),d=q.name.toLowerCase().includes(n.toLowerCase()),c=p?.results;return e.jsxs(e.Fragment,{children:[e.jsx(w,{control:a.control,name:`actions.${s}.deployment_id`,render:({field:x})=>{const u=Lt(c,x.value);return e.jsxs(b,{className:"flex flex-col",children:[e.jsxs(S,{children:["Deployment To ",t]}),e.jsxs(R,{children:[e.jsx(M,{selected:!!u,"aria-label":`Select Deployment to ${t}`,children:u??"Select deployment"}),e.jsxs(V,{children:[e.jsx(O,{value:n,onValueChange:r,placeholder:"Search for an deployment..."}),e.jsx(W,{children:"No deployment found"}),e.jsx(I,{children:e.jsxs(F,{children:[d&&e.jsx(k,{selected:x.value===q.value,onSelect:x.onChange,value:q.value,children:q.name}),c?c.map(i=>e.jsx(k,{"aria-label":i.name,selected:x.value===i.id,onSelect:x.onChange,value:i.id,children:e.jsx(qe,{deploymentWithFlow:i})},i.id)):e.jsx(ee,{})]})})]})]}),e.jsx(C,{})]})}}),l!==q.value&&o==="run-deployment"&&e.jsx("div",{children:"TODO: Additional fields"})]})},qe=({deploymentWithFlow:t})=>t.flow?e.jsxs("div",{className:"flex items-center gap-0.5",children:[e.jsx("div",{children:t.flow.name}),e.jsx(Y,{className:"size-4",id:"ChevronRight"}),e.jsx("div",{children:t.name})]}):t.name,K={value:te,name:"Infer Work Pool"},Dt=(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(""),a=_(),{data:o,isSuccess:l}=E(pe()),h=m.useDeferredValue(n),p=m.useMemo(()=>o?o.filter(c=>c.name.toLowerCase().includes(h.toLowerCase())):[],[o,h]),d=K.name.toLowerCase().includes(h.toLowerCase());return e.jsx(w,{control:a.control,name:`actions.${s}.work_pool_id`,render:({field:c})=>{const x=Dt(o,c.value);return e.jsxs(b,{className:"flex flex-col",children:[e.jsxs(S,{children:["Work Pool To ",t]}),e.jsxs(R,{children:[e.jsx(M,{selected:!!x,"aria-label":`Select Work Pool to ${t}`,children:x??"Select Work Pool"}),e.jsxs(V,{children:[e.jsx(O,{value:n,onValueChange:r,placeholder:"Search for a work pool..."}),e.jsx(W,{children:"No work pool found"}),e.jsx(I,{children:e.jsxs(F,{children:[d&&e.jsx(k,{selected:c.value===K.value,onSelect:u=>{c.onChange(u),r("")},value:K.value,children:K.name}),l?p.map(u=>e.jsx(k,{selected:c.value===u.id,onSelect:i=>{c.onChange(i),r("")},value:u.id,children:u.name},u.id)):e.jsx(ee,{})]})})]})]}),e.jsx(C,{})]})}})},X={value:te,name:"Infer Work Queue"},Ft=(t,s)=>{if(s===X.value)return X.name;const n=t?.find(r=>r.id===s);if(n)return n.name},_e=({action:t,index:s})=>{const[n,r]=m.useState(""),a=_(),{data:o}=E(Ie()),l=m.useDeferredValue(n),h=m.useMemo(()=>{if(!o)return;const d=new Map,c=o.filter(x=>x.name.toLowerCase().includes(l.toLowerCase()));for(const x of c){const{work_pool_name:u}=x;if(!u)throw new Error("'work_pool_name expected");d.set(u,[...d.get(u)??[],x])}return d},[o,l]),p=X.name.toLowerCase().includes(l.toLowerCase());return e.jsx(w,{control:a.control,name:`actions.${s}.work_queue_id`,render:({field:d})=>{const c=Ft(o,d.value);return e.jsxs(b,{className:"flex flex-col",children:[e.jsxs(S,{children:["Work Queue To ",t]}),e.jsxs(R,{children:[e.jsx(M,{selected:!!c,"aria-label":`Select Work Queue to ${t}`,children:c??"Select Work Queue"}),e.jsxs(V,{children:[e.jsx(O,{value:n,onValueChange:r,placeholder:"Search for a work queue..."}),e.jsx(W,{children:"No work queue found"}),e.jsx(I,{children:e.jsxs(F,{children:[p&&e.jsx(k,{selected:d.value===X.value,onSelect:x=>{d.onChange(x),r("")},value:X.value,children:X.name}),h?Array.from(h).map(([x,u])=>e.jsxs("div",{className:"border-b",children:[e.jsx(k,{disabled:!0,children:x}),u.map(i=>e.jsx(k,{selected:d.value===i.id,onSelect:f=>{d.onChange(f),r("")},value:i.id,children:i.name},i.id))]},x)):e.jsx(ee,{})]})})]})]}),e.jsx(C,{})]})}})},Rt=({index:t})=>{const s=_(),[n,r]=m.useState(""),{data:a,isLoading:o}=E(Ve({offset:0,block_schemas:{operator:"and_",block_capabilities:{all_:["notify"]}}})),l=m.useMemo(()=>a?.map(i=>i.slug)??[],[a]),{data:h,isLoading:p}=E(Oe({block_types:l.length>0?{slug:{any_:l}}:void 0,include_secrets:!1,sort:"BLOCK_TYPE_AND_NAME_ASC",offset:0},{enabled:l.length>0})),d=o||p,c=m.useMemo(()=>!a||!h?[]:a.map(i=>({blockType:i,documents:h.filter(f=>f.block_type_id===i.id)})).filter(i=>i.documents.length>0),[a,h]),x=m.useMemo(()=>{if(!n)return c;const i=n.toLowerCase();return c.map(f=>({...f,documents:f.documents.filter(j=>j.name?.toLowerCase().includes(i))})).filter(f=>f.documents.length>0)},[c,n]),u=m.useCallback(i=>{if(!(!i||!h))return h.find(f=>f.id===i)},[h]);return e.jsxs("div",{className:"space-y-4",children:[e.jsx(w,{control:s.control,name:`actions.${t}.block_document_id`,render:({field:i})=>{const f=u(i.value);return e.jsxs(b,{className:"flex flex-col",children:[e.jsx(S,{children:"Block"}),e.jsxs(R,{children:[e.jsx(M,{selected:!!f,"aria-label":"Select notification block",children:f?f.name:"Select a notification block"}),e.jsxs(V,{children:[e.jsx(O,{value:n,onValueChange:r,placeholder:"Search for a block..."}),e.jsx(W,{children:"No notification blocks found"}),e.jsx(I,{children:d?e.jsx(ee,{}):x.map(j=>e.jsx(F,{heading:j.blockType.name,children:j.documents.map(A=>e.jsx(k,{value:A.id,selected:i.value===A.id,onSelect:i.onChange,children:A.name},A.id))},j.blockType.id))})]})]}),e.jsx(C,{})]})}}),e.jsx(Te,{index:t,name:"subject",label:"Subject",placeholder:"Enter notification subject..."}),e.jsx(Te,{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(Y,{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"}),"."]})]})]})},Te=({index:t,name:s,label:n,placeholder:r,multiline:a=!1})=>{const o=_(),{validateTemplate:l}=We(),[h,p]=m.useState(null),[d,c]=m.useState(!1),x=o.watch(`actions.${t}.${s}`),u=me(x,1e3);m.useEffect(()=>{(async()=>{if(!u||u.trim()===""){p(null);return}c(!0);try{const j=await l(u);j.valid?p(null):p(j.error)}catch{p(null)}finally{c(!1)}})()},[u,l]);const i=a?fe:Z;return e.jsx(w,{control:o.control,name:`actions.${t}.${s}`,render:({field:f})=>e.jsxs(b,{children:[e.jsxs(S,{className:"flex items-center gap-2",children:[n,d&&e.jsx(Y,{id:"Loader2",className:"size-3 animate-spin"})]}),e.jsx(y,{children:e.jsx(i,{...f,value:f.value??"",placeholder:r,className:h?"border-destructive":""})}),h&&e.jsx("p",{className:"text-sm text-destructive",children:h}),e.jsx(C,{})]})})},Mt=({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(Y,{id:"Trash2",className:"size-4"})})]}),e.jsx(yt,{index:t}),e.jsx(Vt,{index:t}),e.jsx("hr",{className:"my-8"})]},t),Vt=({index:t})=>{switch(D({name:`actions.${t}.type`})){case"change-flow-run-state":return e.jsx(Tt,{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(_e,{action:"Pause",index:t});case"resume-work-queue":return e.jsx(_e,{action:"Resume",index:t});case"pause-work-pool":return e.jsx(Ne,{action:"Pause",index:t});case"resume-work-pool":return e.jsx(Ne,{action:"Resume",index:t});case"pause-automation":return e.jsx(ke,{action:"Pause",index:t});case"resume-automation":return e.jsx(ke,{action:"Resume",index:t});case"send-notification":return e.jsx(Rt,{index:t});case"call-webhook":return e.jsx(Nt,{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}},Ot=()=>{const t=_(),{fields:s,append:n,remove:r}=Ge({control:t.control,name:"actions",shouldUnregister:!1,rules:{minLength:1}});return e.jsxs("div",{children:[s.map(({id:a},o)=>e.jsx(Mt,{index:o,onRemove:()=>r(o)},a)),e.jsxs(U,{type:"button",variant:"outline",onClick:()=>n({type:"cancel-flow-run"}),children:[e.jsx(Y,{id:"Plus",className:"mr-2 size-4"})," Add Action"]})]})},Wt=()=>{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(b,{children:[e.jsx(S,{children:"Automation Name"}),e.jsx(y,{children:e.jsx(Z,{type:"text",...s,value:s.value??""})}),e.jsx(C,{})]})}),e.jsx(w,{control:t.control,name:"description",render:({field:s})=>e.jsxs(b,{children:[e.jsx(S,{children:"Description (Optional)"}),e.jsx(y,{children:e.jsx(Z,{type:"text",...s,value:s.value??""})}),e.jsx(C,{})]})})]})},It=[{value:"Reactive",label:"Observe"},{value:"Proactive",label:"Don't observe"}],Pt=30,$t=()=>{const t=_(),s=n=>{const r=t.getValues("trigger.posture");if(t.setValue("trigger.posture",n),r==="Reactive"&&n==="Proactive"){const a=t.getValues("trigger.expect")??[];t.setValue("trigger.after",a),t.setValue("trigger.expect",[]),t.getValues("trigger.within")===0&&t.setValue("trigger.within",Pt)}else if(r==="Proactive"&&n==="Reactive"){const a=t.getValues("trigger.after")??[];t.setValue("trigger.expect",a),t.setValue("trigger.after",[])}};return e.jsx(w,{control:t.control,name:"trigger.posture",render:({field:n})=>e.jsxs(b,{children:[e.jsx(S,{children:"When I"}),e.jsx(y,{children:e.jsx(ft,{value:n.value,onValueChange:s,className:"flex gap-4",children:It.map(r=>e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(gt,{value:r.value,id:`custom-${r.value}`}),e.jsx(xe,{htmlFor:`custom-${r.value}`,children:r.label})]},r.value))})})]})})},ue=60,de=3600,he=86400,qt=[{label:"Seconds",value:1},{label:"Minutes",value:ue},{label:"Hours",value:de},{label:"Days",value:he}];function Ut(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:a,disabled:o=!1}){const[l,h]=m.useState(()=>Ut(t)),p=m.useMemo(()=>qt.filter(u=>u.value>=n),[n]),d=m.useMemo(()=>t/l,[t,l]),c=m.useCallback(u=>{let i=u*l;r!==void 0&&i>r&&(i=r),s(i)},[s,l,r]),x=m.useCallback(u=>{const i=Number(u),f=l;h(i);let j=t/f*i;r!==void 0&&j>r&&(j=r),s(j)},[s,l,t,r]);return m.useEffect(()=>{if(!p.some(u=>u.value===l)){const u=p[0];u&&h(u.value)}},[p,l]),e.jsxs("div",{className:et("grid grid-cols-[1fr_7rem] gap-2 w-full",a),children:[e.jsx(Z,{type:"number",min:0,value:d,onChange:u=>c(Number(u.target.value)),disabled:o,"aria-label":"Duration quantity"}),e.jsxs(B,{value:String(l),onValueChange:x,disabled:o,children:[e.jsx(z,{"aria-label":"Duration unit",children:e.jsx(Q,{})}),e.jsx(J,{children:p.map(u=>e.jsx(G,{value:String(u.value),children:u.label},u.value))})]})]})}const Bt=2,zt=40;function Ae({selectedResourceIds:t,onToggleResource:s,emptyMessage:n="All resources"}){const[r,a]=m.useState(""),o=m.useDeferredValue(r),[l,h]=m.useState(0),p=m.useRef(null),d=m.useRef(null);m.useEffect(()=>{const g=p.current;if(!g)return;const v=new ResizeObserver(N=>{for(const T of N)h(T.contentRect.width)});return v.observe(g),()=>v.disconnect()},[]);const{resourceOptions:c}=jt(),x=m.useMemo(()=>{const g=[{label:"Automations",options:[]},{label:"Blocks",options:[]},{label:"Deployments",options:[]},{label:"Flows",options:[]},{label:"Work Pools",options:[]},{label:"Work Queues",options:[]}];for(const v of c){const N={label:v.name,value:v.resourceId};switch(v.type){case"automation":g[0].options.push(N);break;case"block":g[1].options.push(N);break;case"deployment":g[2].options.push(N);break;case"flow":g[3].options.push(N);break;case"work-pool":g[4].options.push(N);break;case"work-queue":g[5].options.push(N);break}}return g.map(v=>({...v,options:v.options.sort((N,T)=>N.label.localeCompare(T.label))})).filter(v=>v.options.length>0)},[c]),u=m.useMemo(()=>{if(!o)return x;const g=o.toLowerCase();return x.map(v=>({...v,options:v.options.filter(N=>N.label.toLowerCase().includes(g)||N.value.toLowerCase().includes(g))})).filter(v=>v.options.length>0)},[x,o]),i=m.useMemo(()=>{if(!o.trim()||!o.includes("."))return!1;const g=o.toLowerCase();return!c.some(v=>v.resourceId.toLowerCase()===g)},[o,c]),f=m.useCallback(g=>{const v=d.current;if(!v||l===0||g.length===0)return Math.min(g.length,Bt);const N=g.length>1?l-zt:l;let T=0;for(let L=0;L<g.length&&(v.textContent=g.slice(0,L+1).join(", "),v.offsetWidth<=N);L++)T=L+1;return T===g.length?g.length:Math.max(1,T)},[l]),j=()=>{if(t.length===0)return e.jsx("span",{className:"text-muted-foreground",children:n});const g=t.map(L=>c.find(ze=>ze.resourceId===L)?.name??L),v=f(g),N=g.slice(0,v),T=g.length-v;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:N.join(", ")})}),T>0&&e.jsxs(re,{variant:"bodySmall",className:"shrink-0",children:["+ ",T]}),e.jsx("div",{ref:d,className:"absolute invisible whitespace-nowrap","aria-hidden":"true"})]})},A=g=>{s(g),a("")};return e.jsxs(R,{children:[e.jsx(M,{selected:t.length>0,children:j()}),e.jsxs(V,{children:[e.jsx(O,{value:r,onValueChange:a,placeholder:"Search resources..."}),e.jsxs(I,{children:[e.jsx(W,{children:"No resources found"}),i&&e.jsx(F,{children:e.jsxs(k,{selected:t.includes(o),onSelect:()=>A(o),closeOnSelect:!1,value:o,children:['Add "',o,'"']},"__custom__")}),u.map(g=>e.jsx(F,{heading:g.label,children:g.options.map(v=>e.jsx(k,{selected:t.includes(v.value),onSelect:()=>A(v.value),closeOnSelect:!1,value:v.value,children:v.label},v.value))},g.label))]})]})]})}function Qt(t){const s=new Map;for(const n of t){const r=n.split(".");for(let a=1;a<r.length;a++){const o=r.slice(0,a).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 Ee({selectedEvents:t,onToggleEvent:s,emptyMessage:n="All events"}){const[r,a]=m.useState(""),o=m.useDeferredValue(r),[l]=m.useState(()=>({since:new Date(Date.now()-10080*60*1e3).toISOString(),until:new Date().toISOString()})),{data:h=[]}=E(tt("event",{filter:{occurred:l,order:"DESC"},time_unit:"day",time_interval:1})),p=m.useMemo(()=>{const i=h.map(j=>j.label),f=Qt(i);return[...i,...f].sort((j,A)=>j.localeCompare(A))},[h]),d=m.useMemo(()=>{if(!o)return p;const i=o.toLowerCase();return p.filter(f=>f.toLowerCase().includes(i))},[p,o]),c=m.useMemo(()=>{if(!o.trim())return!1;const i=o.toLowerCase();return!p.some(f=>f.toLowerCase()===i)},[o,p]),x=()=>{if(t.length===0)return e.jsx("span",{className:"text-muted-foreground",children:n});const i=t.slice(0,2),f=t.length-i.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:i.join(", ")}),f>0&&e.jsxs("span",{className:"shrink-0 text-muted-foreground",children:["+",f]})]})},u=i=>{s(i),a("")};return e.jsxs(R,{children:[e.jsx(M,{selected:t.length>0,children:x()}),e.jsxs(V,{children:[e.jsx(O,{value:r,onValueChange:a,placeholder:"Search events..."}),e.jsxs(I,{children:[e.jsx(W,{children:"No events found"}),e.jsxs(F,{children:[c&&e.jsxs(k,{selected:t.includes(o),onSelect:()=>u(o),closeOnSelect:!1,value:o,children:['Add "',o,'"']},"__custom__"),d.map(i=>e.jsx(k,{selected:t.includes(i),onSelect:()=>u(i),closeOnSelect:!1,value:i,children:i},i))]})]})]})]})}const Jt=()=>{const t=_(),s=D({name:"trigger.posture"});return e.jsxs("div",{className:"space-y-4",children:[e.jsx("div",{className:"flex items-end gap-4",children:e.jsx($t,{})}),e.jsx(w,{control:t.control,name:"trigger.expect",render:({field:n})=>{const r=n.value??[];return e.jsxs(b,{children:[e.jsx(S,{children:"Any event matching"}),e.jsx(y,{children:e.jsx(Ee,{selectedEvents:r,onToggleEvent:a=>{const o=r.includes(a)?r.filter(l=>l!==a):[...r,a];n.onChange(o)}})}),e.jsx(C,{})]})}}),e.jsx(w,{control:t.control,name:"trigger.match",render:({field:n})=>{const r=n.value?.["prefect.resource.id"]??[],a=Array.isArray(r)?r:[r];return e.jsxs(b,{children:[e.jsx(S,{children:"From the following resources"}),e.jsx(y,{children:e.jsx(Ae,{selectedResourceIds:a,onToggleResource:o=>{const l=a.includes(o)?a.filter(h=>h!==o):[...a,o];l.length>0?n.onChange({"prefect.resource.id":l}):n.onChange({})}})}),e.jsx(C,{})]})}}),e.jsxs("div",{className:"flex items-end gap-2",children:[e.jsx(w,{control:t.control,name:"trigger.threshold",render:({field:n})=>e.jsxs(b,{className:"w-20",children:[e.jsx(y,{children:e.jsx(Z,{type:"number",min:1,...n,onChange:r=>n.onChange(Number(r.target.value))})}),e.jsx(C,{})]})}),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(b,{children:[e.jsx(y,{children:e.jsx(se,{value:n.value??0,onChange:n.onChange,min:s==="Proactive"?10:0})}),e.jsx(C,{})]})})]}),e.jsxs(vt,{children:[e.jsxs(bt,{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(St,{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(b,{children:[e.jsx(S,{children:"Evaluate trigger only after observing an event matching"}),e.jsx(y,{children:e.jsx(Ee,{selectedEvents:r,onToggleEvent:a=>{const o=r.includes(a)?r.filter(l=>l!==a):[...r,a];n.onChange(o)}})}),e.jsx(C,{})]})}}),e.jsx(w,{control:t.control,name:"trigger.match_related",render:({field:n})=>{const r=n.value?.["prefect.resource.id"]??[],a=Array.isArray(r)?r:[r];return e.jsxs(b,{children:[e.jsx(S,{children:"Filter for events related to"}),e.jsx(y,{children:e.jsx(Ae,{selectedResourceIds:a,onToggleResource:o=>{const l=a.includes(o)?a.filter(h=>h!==o):[...a,o];l.length>0?n.onChange({"prefect.resource.id":l}):n.onChange({})}})}),e.jsx(C,{})]})}})]})]})]})},Gt=2,Yt=40,Ht=({selectedDeploymentIds:t,onSelectDeploymentIds:s})=>{const[n,r]=m.useState(""),a=m.useDeferredValue(n),[o,l]=m.useState(0),h=m.useRef(null),p=m.useRef(null),d=m.useMemo(()=>new Set(t),[t]);m.useEffect(()=>{const g=h.current;if(!g)return;const v=new ResizeObserver(N=>{for(const T of N)l(T.contentRect.width)});return v.observe(g),()=>v.disconnect()},[]);const{data:c=[]}=E(je({deployments:a?{operator:"and_",name:{like_:a}}:void 0,limit:100,offset:0,sort:"NAME_ASC"})),{data:x=[]}=E(je({deployments:d.size>0?{operator:"and_",id:{any_:t}}:void 0,limit:d.size||1,offset:0,sort:"NAME_ASC"},{enabled:d.size>0})),u=g=>{const v=new Set(d);d.has(g)?v.delete(g):v.add(g),s(Array.from(v))},i=()=>{s([])},f=m.useCallback(g=>{const v=p.current;if(!v||o===0||g.length===0)return Math.min(g.length,Gt);const N=g.length>1?o-Yt:o;let T=0;for(let L=0;L<g.length&&(v.textContent=g.slice(0,L+1).join(", "),v.offsetWidth<=N);L++)T=L+1;return T===g.length?g.length:Math.max(1,T)},[o]),j=()=>{if(d.size===0)return"All deployments";const g=x.filter(L=>d.has(L.id)).map(L=>L.name),v=f(g),N=g.slice(0,v),T=g.length-v;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:N.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"})]})},A=m.useMemo(()=>c.filter(g=>!a||g.name.toLowerCase().includes(a.toLowerCase())),[c,a]);return e.jsxs(R,{children:[e.jsx(M,{"aria-label":"Select deployments",selected:d.size===0,children:j()}),e.jsxs(V,{children:[e.jsx(O,{value:n,onValueChange:r,placeholder:"Search deployments..."}),e.jsxs(I,{children:[e.jsx(W,{children:"No deployments found"}),e.jsxs(F,{children:[e.jsxs(k,{"aria-label":"All deployments",onSelect:i,closeOnSelect:!1,value:"__all__",children:[e.jsx(ve,{checked:d.size===0}),"All deployments"]}),A.map(g=>e.jsxs(k,{"aria-label":g.name,onSelect:()=>u(g.id),closeOnSelect:!1,value:g.id,children:[e.jsx(ve,{checked:d.has(g.id)}),g.name]},g.id))]})]})]})]})},Kt=[{value:"Reactive",label:"Enters"},{value:"Proactive",label:"Stays in"}],Xt=30,ne=()=>{const t=_();return e.jsx(w,{control:t.control,name:"trigger.posture",render:({field:s})=>e.jsx(b,{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 a=t.getValues("trigger.expect")??[];t.setValue("trigger.after",a),t.setValue("trigger.expect",[]),t.getValues("trigger.within")===0&&t.setValue("trigger.within",Xt)}else if(r==="Proactive"&&n==="Reactive"){const a=t.getValues("trigger.after")??[];t.setValue("trigger.expect",a),t.setValue("trigger.after",[])}},children:[e.jsx(z,{"aria-label":"select posture",className:"w-[160px]",children:e.jsx(Q,{placeholder:"Select posture"})}),e.jsx(J,{children:Kt.map(n=>e.jsx(G,{value:n.value,children:n.label},n.value))})]})})})})},Zt=86400,es=30*Zt,ts=[{value:"prefect.deployment.ready",label:"Ready"},{value:"prefect.deployment.not-ready",label:"Not Ready"},{value:"prefect.deployment.disabled",label:"Disabled"}],Ue="prefect.deployment.",Be="prefect.deployment.*",ss=t=>t?(Array.isArray(t)?t:[t]).filter(n=>n!==Be).map(n=>n.replace(Ue,"")):[],rs=t=>t.length===0?Be:t.map(s=>`${Ue}${s}`),ns=()=>{const t=_(),s=D({name:"trigger.posture"}),n=D({name:"trigger.match"}),r=m.useMemo(()=>{const l=n?.["prefect.resource.id"];return ss(l)},[n]),a=m.useCallback(o=>{const l=t.getValues("trigger.match")??{};t.setValue("trigger.match",{...l,"prefect.resource.id":rs(o)})},[t]);return e.jsxs("div",{className:"space-y-4",children:[e.jsxs(b,{children:[e.jsx(S,{children:"Deployments"}),e.jsx(y,{children:e.jsx(Ht,{selectedDeploymentIds:r,onSelectDeploymentIds:a})})]}),e.jsxs(b,{children:[e.jsx(S,{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 l=o.value?.[0];return e.jsxs(B,{value:l??"",onValueChange:h=>o.onChange([h]),children:[e.jsx(z,{className:"w-full",children:e.jsx(Q,{placeholder:"Select status"})}),e.jsx(J,{children:ts.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(b,{children:[e.jsx(S,{children:"Within"}),e.jsx(y,{children:e.jsx(se,{value:o.value??0,onChange:o.onChange,min:10,max:es})}),e.jsx(C,{})]})})]})},os=2;function as({selectedFlowIds:t,onToggleFlow:s,emptyMessage:n="Any flow"}){const[r,a]=m.useState(""),o=m.useDeferredValue(r),{data:l=[]}=E(ie({flows:o?{operator:"and_",name:{like_:o}}:void 0,limit:100,offset:0,sort:"NAME_ASC"})),{data:h=[]}=E(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(()=>l.filter(c=>!o||c.name.toLowerCase().includes(o.toLowerCase())),[l,o]),d=()=>{if(t.length===0)return e.jsx("span",{className:"text-muted-foreground",children:n});const x=h.filter(i=>t.includes(i.id)).map(i=>i.name).slice(0,os),u=t.length-x.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:x.join(", ")}),u>0&&e.jsxs("span",{className:"shrink-0 text-muted-foreground",children:["+",u]})]})};return e.jsxs(R,{children:[e.jsx(M,{selected:t.length>0,children:d()}),e.jsxs(V,{children:[e.jsx(O,{value:r,onValueChange:a,placeholder:"Search flows..."}),e.jsxs(I,{children:[e.jsx(W,{children:"No flows found"}),e.jsx(F,{children:p.map(c=>e.jsx(k,{selected:t.includes(c.id),onSelect:()=>{s(c.id),a("")},closeOnSelect:!1,value:c.id,children:c.name},c.id))})]})]})]})}const P="All run states",$="All except scheduled";function ls(t){return t.length!==$e.length-1?!1:!t.includes("Scheduled")}function cs({selectedStates:t,onStateChange:s,emptyMessage:n="Any state"}){const[r,a]=m.useState(""),o=m.useDeferredValue(r),l=m.useMemo(()=>t.length===0?P:ls(t)?$:t,[t]),h=m.useMemo(()=>{const u=o.toLowerCase();return $e.filter(i=>i.toLowerCase().includes(u))},[o]),p=m.useMemo(()=>{const u=o.toLowerCase();return P.toLowerCase().includes(u)||$.toLowerCase().includes(u)},[o]),d=u=>{u===P?s([]):u===$&&s([...xt]),a("")},c=u=>{t.includes(u)?s(t.filter(i=>i!==u)):s([...t,u]),a("")},x=()=>l===P?e.jsx("span",{className:"text-muted-foreground",children:n}):l===$?e.jsx("span",{children:"All except scheduled"}):e.jsx("div",{className:"flex flex-wrap gap-1",children:t.map(u=>e.jsx(be,{type:ye[u],name:u,className:"cursor-pointer"},u))});return e.jsxs(R,{children:[e.jsx(M,{selected:t.length>0,children:x()}),e.jsxs(V,{children:[e.jsx(O,{value:r,onValueChange:a,placeholder:"Search states..."}),e.jsx(W,{children:"No state found"}),e.jsx(I,{children:e.jsxs(F,{children:[p&&e.jsxs(e.Fragment,{children:[e.jsx(k,{selected:l===P,onSelect:()=>d(P),value:P,closeOnSelect:!1,children:"All run states"},P),e.jsx(k,{selected:l===$,onSelect:()=>d($),value:$,closeOnSelect:!1,children:"All except scheduled"},$)]}),h.map(u=>e.jsx(k,{selected:t.includes(u),onSelect:()=>c(u),value:u,closeOnSelect:!1,children:e.jsx(be,{type:ye[u],name:u})},u))]})})]})]})}function is(t){return t.length===0?["prefect.flow-run.*"]:t.map(s=>`prefect.flow-run.${s}`)}function us(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 ds(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 hs(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 Le(t,s){const n=t.map(l=>`prefect.flow.${l}`),r=s.map(l=>`prefect.tag.${l}`);if(n.length===0&&r.length===0)return{};const a=n.length>0?"flow":"tag",o=[...n,...r];return{"prefect.resource.role":a,"prefect.resource.id":o}}const ms=()=>{const t=_(),s=D({name:"trigger.posture"}),n=s==="Proactive"?"trigger.after":"trigger.expect",r=D({name:"trigger.match_related"}),a=ds(r),o=hs(r),l=d=>{const c=a,x=c.includes(d)?c.filter(i=>i!==d):[...c,d],u=x.length>0?[]:o;t.setValue("trigger.match_related",Le(x,u))},h=d=>{t.setValue("trigger.match_related",Le(a,d))},p=a.length===0;return e.jsxs("div",{className:"space-y-4",children:[e.jsxs(b,{children:[e.jsx(S,{children:"Flows"}),e.jsx(y,{children:e.jsx(as,{selectedFlowIds:a,onToggleFlow:l,emptyMessage:"All flows"})})]}),p&&e.jsxs(b,{children:[e.jsx(S,{children:"Flow Run Tags"}),e.jsx(y,{children:e.jsx(wt,{value:o,onChange:h,placeholder:"All tags"})})]}),e.jsxs(b,{children:[e.jsx(S,{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:d})=>{const c=d.value??[],x=us(c);return e.jsx(y,{children:e.jsx(cs,{selectedStates:x,onStateChange:u=>{d.onChange(is(u))},emptyMessage:"Any state"})})}})]})]}),s==="Proactive"&&e.jsx(w,{control:t.control,name:"trigger.within",render:({field:d})=>e.jsxs(b,{children:[e.jsx(S,{children:"For"}),e.jsx(y,{children:e.jsx(se,{value:d.value??0,onChange:d.onChange,min:0})}),e.jsx(C,{})]})})]})},ps=({defaultValue:t="Form",value:s,onValueChange:n,formContent:r,jsonContent:a})=>{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(Se,{value:"Form",children:"Form"}),e.jsx(Se,{value:"JSON",children:"JSON"})]})}),e.jsx(we,{value:"Form",children:r}),e.jsx(we,{value:"JSON",children:a})]})},xs=({value:t,onChange:s,error:n})=>{const[r,a]=m.useState(null),o=()=>{try{const h=JSON.parse(t);s(JSON.stringify(h,null,2))}catch{}},l=h=>{try{const p=JSON.parse(h);return Pe.parse(p),a(null),!0}catch(p){return p instanceof SyntaxError?a("Invalid JSON syntax"):p instanceof Re&&a(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(xe,{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:()=>l(t)}),(r||n)&&e.jsx("p",{className:"text-sm text-destructive",children:r||n})]})},De={"deployment-status":"Deployment status","flow-run-state":"Flow run state","work-pool-status":"Work pool status","work-queue-status":"Work queue status",custom:"Custom"},fs=({onValueChange:t,value:s})=>e.jsxs("div",{className:"space-y-2",children:[e.jsx(xe,{htmlFor:"automations-trigger-template-select",children:"Trigger Template"}),e.jsxs(B,{value:s,onValueChange:t,children:[e.jsx(z,{id:"automations-trigger-template-select",className:"w-full",children:e.jsx(Q,{placeholder:"Select template"})}),e.jsx(J,{children:e.jsx(Me,{children:Object.keys(De).map(n=>e.jsx(G,{value:n,children:De[n]},n))})})]})]}),gs=({onTemplateChange:t})=>{const s=_();return e.jsx(w,{control:s.control,name:"triggerTemplate",render:({field:n})=>e.jsx(b,{children:e.jsx(y,{children:e.jsx(fs,{value:n.value,onValueChange:r=>{n.onChange(r),t?.(r)}})})})})},js={type:"event",posture:"Reactive",threshold:1,within:0},vs=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 js}};function bs({selectedWorkPoolIds:t,onToggleWorkPool:s,emptyMessage:n="All work pools"}){const[r,a]=m.useState(""),o=m.useDeferredValue(r),{data:l=[]}=E(pe()),h=m.useMemo(()=>l.filter(c=>c.status!==null).filter(c=>!o||c.name.toLowerCase().includes(o.toLowerCase())),[l,o]),p=m.useMemo(()=>l.filter(c=>t.includes(c.id)),[l,t]),d=()=>{if(t.length===0)return e.jsx("span",{className:"text-muted-foreground",children:n});const c=p.map(x=>x.name);return e.jsx("span",{className:"truncate min-w-0 text-left",children:c.join(", ")})};return e.jsxs(R,{children:[e.jsx(M,{selected:t.length>0,children:d()}),e.jsxs(V,{children:[e.jsx(O,{value:r,onValueChange:a,placeholder:"Search work pools..."}),e.jsxs(I,{children:[e.jsx(W,{children:"No work pools found"}),e.jsx(F,{children:h.map(c=>e.jsx(k,{selected:t.includes(c.id),onSelect:()=>{s(c.id),a("")},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 Fe(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 Ss(t){const s=oe.find(n=>n.value===t);return s?[...s.events]:[]}function ws(t){return oe.filter(s=>s.value!==t).flatMap(s=>[...s.events])}function ys(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 Cs(t){return t.length===0?{"prefect.resource.id":"prefect.work-pool.*"}:{"prefect.resource.id":t.map(s=>`prefect.work-pool.${s}`)}}const ks=()=>{const t=_(),s=D({name:"trigger.posture"}),n=D({name:"trigger.expect"}),r=D({name:"trigger.after"}),a=Fe(s==="Proactive"?r:n),o=l=>{const h=Ss(l),p=ws(l);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:a,onValueChange:o,children:[e.jsx(z,{"aria-label":"select status",className:"min-w-0 flex-1",children:e.jsx(Q,{placeholder:"Select status"})}),e.jsx(J,{children:oe.map(l=>e.jsx(G,{value:l.value,children:l.label},l.value))})]})},Ns=()=>{const t=_(),s=D({name:"trigger.posture"}),n=D({name:"trigger.match"}),r=ys(n),a=o=>{const l=r,h=l.includes(o)?l.filter(p=>p!==o):[...l,o];t.setValue("trigger.match",Cs(h))};return e.jsxs("div",{className:"space-y-4",children:[e.jsxs(b,{children:[e.jsx(S,{children:"Work Pools"}),e.jsx(y,{children:e.jsx(bs,{selectedWorkPoolIds:r,onToggleWorkPool:a,emptyMessage:"All work pools"})})]}),e.jsxs(b,{children:[e.jsx(S,{children:"Work Pool"}),e.jsxs("div",{className:"flex gap-2",children:[e.jsx(ne,{}),e.jsx(ks,{})]})]}),s==="Proactive"&&e.jsx(w,{control:t.control,name:"trigger.within",render:({field:o})=>e.jsxs(b,{children:[e.jsx(S,{children:"For"}),e.jsx(y,{children:e.jsx(se,{value:o.value??30,onChange:o.onChange,min:0})}),e.jsx(C,{})]})})]})};function _s({selectedWorkPoolIds:t,onToggleWorkPool:s,emptyMessage:n="All work pools"}){const[r,a]=m.useState(""),o=m.useDeferredValue(r),{data:l=[]}=E(pe({limit:100,offset:0})),h=m.useMemo(()=>l.filter(d=>d.status?o?d.name.toLowerCase().includes(o.toLowerCase()):!0:!1),[l,o]),p=()=>{if(t.length===0)return e.jsx("span",{className:"text-muted-foreground",children:n});const d=l.filter(c=>t.includes(c.id)).map(c=>c.name);return e.jsx("span",{className:"truncate min-w-0 text-left",children:d.join(", ")})};return e.jsxs(R,{children:[e.jsx(M,{selected:t.length>0,children:p()}),e.jsxs(V,{children:[e.jsx(O,{value:r,onValueChange:a,placeholder:"Search work pools..."}),e.jsxs(I,{children:[e.jsx(W,{children:"No work pools found"}),e.jsx(F,{children:h.map(d=>e.jsx(k,{selected:t.includes(d.id),onSelect:()=>{s(d.id),a("")},closeOnSelect:!1,value:d.id,children:d.name},d.id))})]})]})]})}function Ts({selectedWorkQueueIds:t,onToggleWorkQueue:s,workPoolIds:n=[],emptyMessage:r="All work queues"}){const[a,o]=m.useState(""),l=m.useDeferredValue(a),{data:h=[]}=E(Ie({limit:100,offset:0})),p=m.useMemo(()=>h.filter(x=>n.length>0&&(!x.work_pool_id||!n.includes(x.work_pool_id))?!1:l?x.name.toLowerCase().includes(l.toLowerCase()):!0),[h,n,l]),d=m.useMemo(()=>{const x={};for(const i of p){const f=i.work_pool_name??"Unknown";x[f]||(x[f]=[]),x[f].push(i)}return Object.keys(x).sort((i,f)=>i.localeCompare(f)).map(i=>({poolName:i,queues:x[i].sort((f,j)=>f.name.localeCompare(j.name))}))},[p]),c=()=>{if(t.length===0)return e.jsx("span",{className:"text-muted-foreground",children:r});const x=h.filter(u=>t.includes(u.id)).map(u=>u.name);return e.jsx("span",{className:"truncate min-w-0 text-left",children:x.join(", ")})};return e.jsxs(R,{children:[e.jsx(M,{selected:t.length>0,children:c()}),e.jsxs(V,{children:[e.jsx(O,{value:a,onValueChange:o,placeholder:"Search work queues..."}),e.jsxs(I,{children:[e.jsx(W,{children:"No work queues found"}),d.map(x=>e.jsx(F,{heading:x.poolName,children:x.queues.map(u=>e.jsx(k,{selected:t.includes(u.id),onSelect:()=>{s(u.id),o("")},closeOnSelect:!1,value:u.id,children:u.name},u.id))},x.poolName))]})]})]})}const As=[{value:"prefect.work-queue.ready",label:"Ready"},{value:"prefect.work-queue.not-ready",label:"Not Ready"},{value:"prefect.work-queue.paused",label:"Paused"}];function Es(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 Ls(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 Ds(t){return t.length===0?{}:{"prefect.resource.role":"work-pool","prefect.resource.id":t.map(n=>`prefect.work-pool.${n}`)}}function Fs(t){return t.length===0?{"prefect.resource.id":"prefect.work-queue.*"}:{"prefect.resource.id":t.map(n=>`prefect.work-queue.${n}`)}}const Rs=()=>{const t=_(),s=D({name:"trigger.posture"}),n=D({name:"trigger.match_related"}),r=D({name:"trigger.match"}),a=Es(n),o=Ls(r),l=p=>{const d=a,c=d.includes(p)?d.filter(x=>x!==p):[...d,p];t.setValue("trigger.match_related",Ds(c))},h=p=>{const d=o,c=d.includes(p)?d.filter(x=>x!==p):[...d,p];t.setValue("trigger.match",Fs(c))};return e.jsxs("div",{className:"space-y-4",children:[e.jsxs(b,{children:[e.jsx(S,{children:"Work Pools"}),e.jsx(y,{children:e.jsx(_s,{selectedWorkPoolIds:a,onToggleWorkPool:l,emptyMessage:"All work pools"})})]}),e.jsxs(b,{children:[e.jsx(S,{children:"Work Queues"}),e.jsx(y,{children:e.jsx(Ts,{selectedWorkQueueIds:o,onToggleWorkQueue:h,workPoolIds:a,emptyMessage:"All work queues"})})]}),e.jsxs(b,{children:[e.jsx(S,{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 d=p.value?.[0];return e.jsx(y,{children:e.jsxs(B,{value:d??"",onValueChange:c=>p.onChange([c]),children:[e.jsx(z,{className:"w-full",children:e.jsx(Q,{placeholder:"Select status"})}),e.jsx(J,{children:As.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(b,{children:[e.jsx(S,{children:"For"}),e.jsx(y,{children:e.jsx(se,{value:p.value??0,onChange:p.onChange,min:0})}),e.jsx(C,{})]})})]})},Ms=()=>{const t=_(),s=t.watch("triggerTemplate"),n=t.watch("trigger"),[r,a]=m.useState("Form"),[o,l]=m.useState(""),[h,p]=m.useState(void 0),d=m.useCallback(()=>JSON.stringify(n,null,2),[n]);m.useEffect(()=>{r==="Form"&&l(d())},[r,d]);const c=m.useCallback(f=>{try{const j=JSON.parse(f);return{valid:!0,trigger:Pe.parse(j)}}catch(j){return j instanceof SyntaxError?{valid:!1,error:"Invalid JSON syntax"}:j instanceof Re?{valid:!1,error:j.errors[0]?.message??"Invalid trigger configuration"}:{valid:!1,error:"Unknown error"}}},[]),x=m.useCallback(f=>{if(r!==f){if(f==="Form"){const j=c(o);if(!j.valid){p(j.error);return}j.trigger&&t.setValue("trigger",j.trigger),p(void 0)}else l(d()),p(void 0);a(f)}},[r,o,c,t,d]),u=m.useCallback(f=>{l(f);const j=c(f);j.valid&&j.trigger&&(t.setValue("trigger",j.trigger),p(void 0))},[c,t]),i=f=>{const j=vs(f);t.setValue("trigger",j),l(JSON.stringify(j,null,2)),p(void 0)};return e.jsxs("div",{className:"space-y-6",children:[e.jsx(gs,{onTemplateChange:i}),s&&e.jsx(ps,{value:r,onValueChange:x,formContent:e.jsx(Vs,{template:s}),jsonContent:e.jsx(xs,{value:o,onChange:u,error:h})})]})},Vs=({template:t})=>{switch(t){case"flow-run-state":return e.jsx(ms,{});case"deployment-status":return e.jsx(ns,{});case"work-pool-status":return e.jsx(Ns,{});case"work-queue-status":return e.jsx(Rs,{});case"custom":return e.jsx(Jt,{});default:return null}},ce=["Trigger","Actions","Details"],Os={actions:[{type:void 0}],trigger:{type:"event",posture:"Reactive",threshold:1,within:0}},Hs=({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]),l=ut(ce.length,0,o),h=Ye({resolver:Je(ht),defaultValues:{...Os,...t}}),p=ce[l.currentStep],d={Trigger:{render:()=>e.jsx(Ms,{}),trigger:()=>h.trigger("trigger")},Actions:{render:()=>e.jsx(Ot,{}),trigger:()=>h.trigger("actions")},Details:{render:()=>e.jsx(Wt,{}),trigger:()=>h.trigger(["description","name"])}},c=async x=>{await d[x].trigger()&&l.incrementStep()};return e.jsx(it,{...h,children:e.jsx("form",{onSubmit:x=>{h.handleSubmit(s)(x)},children:e.jsxs("div",{className:"flex flex-col gap-8",children:[e.jsx(dt,{steps:ce,currentStepNum:l.currentStep,onClick:x=>l.changeStep(x.stepNum),completedSteps:l.completedStepsSet,visitedSteps:l.visitedStepsSet}),e.jsxs(at,{className:"p-4 pt-8",children:[e.jsxs(lt,{children:[d[p].render(),e.jsx(C,{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(Qe,{to:"/automations",children:"Cancel"})}),e.jsx(U,{disabled:l.isStartingStep,type:"button",variant:"outline",onClick:l.decrementStep,children:"Previous"}),l.isFinalStep?e.jsx(U,{type:"submit",loading:r,children:n},"save"):e.jsx(U,{type:"button",onClick:()=>{c(p)},children:"Next"},"next")]})]})]})})})};export{Hs as A};
2
- //# sourceMappingURL=automation-wizard-EYSfXlQ7.js.map
1
+ import{j as e,r as m,t as E,L as ze}from"./vendor-tanstack-BcZfOOfy.js";import{a as Je}from"./zod-Cuos7J7w.js";import{g as _,p as D,q as Ge,Z as Re,c as Ye}from"./vendor-forms-ClCIacbh.js";import{S as B,a as Q,b as z,c as J,d as Me,dn as He,e as G,b9 as Ke,bq as Ve,bt as Oe,ag as R,ah as M,ai as V,aj as O,al as W,ak as I,am as F,an as k,I as Y,dp as We,bQ as me,p as Z,ap as re,bv as Xe,bi as Ze,af as ie,T as pe,d7 as Ie,q as U,i as xe,a_ as et,b2 as tt,at as st,d0 as je,ao as ve,au as be,aA as rt,aB as nt,aC as Se,aD as we,L as ot,C as at,o as lt,dq as ct}from"./index-B8vo2Lrg.js";import{b as w,c as b,d as S,e as y,a as C,F as it}from"./form-mws4law8.js";import{u as ut,S as dt}from"./use-stepper-DyIb3vlq.js";import{U as te,T as Pe,A as ht}from"./automation-schema-BIBsyp0j.js";import{T as fe}from"./textarea-DUhh6-kq.js";import{S as mt,R as pt,a as $e,b as ye,c as xt}from"./index-D6ynV6U7.js";import{R as ft,a as gt}from"./radio-group-BUsmwdrt.js";import{u as jt,C as vt,a as bt,b as St}from"./collapsible-B_NJS0uJ.js";import{T as wt}from"./tags-input-DHrnkwjQ.js";const Ce={"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","call-webhook":"Call a webhook"},yt=({index:t})=>{const s=_();return e.jsx(w,{control:s.control,name:`actions.${t}.type`,render:({field:n})=>e.jsxs(b,{children:[e.jsx(S,{children:"Action Type"}),e.jsx(y,{children:e.jsxs(B,{...n,onValueChange:r=>{n.onChange(r);const a=Ct({index:t,type:r});a&&s.setValue(a,te)},children:[e.jsx(Q,{"aria-label":"select action",className:"w-full",children:e.jsx(z,{placeholder:"Select action"})}),e.jsx(J,{children:e.jsxs(Me,{children:[e.jsx(He,{children:"Actions"}),Object.keys(Ce).map(r=>e.jsx(G,{value:r,children:Ce[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 kt=4,ee=({length:t=kt})=>Array.from({length:t},(s,n)=>e.jsx(Ke,{className:"mt-2 p-4 h-2 w-full"},n)),Nt=({index:t})=>{const s=_(),[n,r]=m.useState(""),{data:a,isLoading:o}=E(Ve({offset:0,block_types:{slug:{any_:["webhook"]}}})),l=m.useMemo(()=>a?.map(i=>i.slug)??[],[a]),{data:h,isLoading:p}=E(Oe({block_types:l.length>0?{slug:{any_:l}}:void 0,include_secrets:!1,sort:"BLOCK_TYPE_AND_NAME_ASC",offset:0},{enabled:l.length>0})),d=o||p,c=m.useMemo(()=>!a||!h?[]:a.map(i=>({blockType:i,documents:h.filter(f=>f.block_type_id===i.id)})).filter(i=>i.documents.length>0),[a,h]),x=m.useMemo(()=>{if(!n)return c;const i=n.toLowerCase();return c.map(f=>({...f,documents:f.documents.filter(j=>j.name?.toLowerCase().includes(i))})).filter(f=>f.documents.length>0)},[c,n]),u=m.useCallback(i=>{if(!(!i||!h))return h.find(f=>f.id===i)},[h]);return e.jsxs("div",{className:"space-y-4",children:[e.jsx(w,{control:s.control,name:`actions.${t}.block_document_id`,render:({field:i})=>{const f=u(i.value);return e.jsxs(b,{className:"flex flex-col",children:[e.jsx(S,{children:"Block"}),e.jsxs(R,{children:[e.jsx(M,{selected:!!f,"aria-label":"Select webhook block",children:f?f.name:"Select a webhook block"}),e.jsxs(V,{children:[e.jsx(O,{value:n,onValueChange:r,placeholder:"Search for a block..."}),e.jsx(W,{children:"No webhook blocks found"}),e.jsx(I,{children:d?e.jsx(ee,{}):x.map(j=>e.jsx(F,{heading:j.blockType.name,children:j.documents.map(A=>e.jsx(k,{value:A.id,selected:i.value===A.id,onSelect:i.onChange,children:A.name},A.id))},j.blockType.id))})]})]}),e.jsx(C,{})]})}}),e.jsx(_t,{index:t}),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(Y,{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 webhook payload 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"}),", and"," ",e.jsx("code",{className:"rounded bg-blue-100 px-1 py-0.5 font-mono text-xs dark:bg-blue-900",children:"work_queue"}),"."]})]})]})},_t=({index:t})=>{const s=_(),{validateTemplate:n}=We(),[r,a]=m.useState(null),[o,l]=m.useState(!1),h=s.watch(`actions.${t}.payload`),p=me(h,1e3);return m.useEffect(()=>{(async()=>{if(!p||p.trim()===""){a(null);return}l(!0);try{const c=await n(p);c.valid?a(null):a(c.error)}catch{a(null)}finally{l(!1)}})()},[p,n]),e.jsx(w,{control:s.control,name:`actions.${t}.payload`,render:({field:d})=>e.jsxs(b,{children:[e.jsxs(S,{className:"flex items-center gap-2",children:["Payload",o&&e.jsx(Y,{id:"Loader2",className:"size-3 animate-spin"})]}),e.jsx(y,{children:e.jsx(fe,{...d,value:d.value??"",placeholder:"Enter webhook payload...",className:r?"border-destructive":"",rows:5})}),r&&e.jsx("p",{className:"text-sm text-destructive",children:r}),e.jsx(C,{})]})})},Tt=({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(b,{children:[e.jsx(S,{children:"State"}),e.jsx(y,{children:e.jsx(mt,{value:r.value,onValueChange:r.onChange})}),e.jsx(C,{})]})}),e.jsx(w,{control:s.control,name:`actions.${t}.name`,render:({field:r})=>e.jsxs(b,{children:[e.jsx(S,{children:"Name"}),e.jsx(y,{children:e.jsx(Z,{type:"text",...r,value:r.value??"",placeholder:n?pt[n]:void 0})}),e.jsx(C,{})]})}),e.jsx(w,{control:s.control,name:`actions.${t}.message`,render:({field:r})=>e.jsxs(b,{children:[e.jsx(S,{children:"Message"}),e.jsx(y,{children:e.jsx(fe,{...r,placeholder:"State changed by Automation <id>"})}),e.jsx(C,{})]})})]})},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})},H={value:te,name:"Infer Automation"},At=(t,s)=>{if(s===H.value)return H.name;const n=t?.find(r=>r.id===s);if(n)return n.name},ke=({action:t,index:s})=>{const[n,r]=m.useState(""),a=_(),{data:o,isSuccess:l}=E(Xe()),h=m.useDeferredValue(n),p=m.useMemo(()=>o?o.filter(c=>c.name.toLowerCase().includes(h.toLowerCase())):[],[o,h]),d=H.name.toLowerCase().includes(h.toLowerCase());return e.jsx(w,{control:a.control,name:`actions.${s}.automation_id`,render:({field:c})=>{const x=At(o,c.value);return e.jsxs(b,{className:"flex flex-col",children:[e.jsxs(S,{children:["Automation To ",t]}),e.jsxs(R,{children:[e.jsx(M,{selected:!!x,"aria-label":`Select Automation to ${t}`,children:x??"Select automation"}),e.jsxs(V,{children:[e.jsx(O,{value:n,onValueChange:r,placeholder:"Search for an automation..."}),e.jsx(W,{children:"No automation found"}),e.jsx(I,{children:e.jsxs(F,{children:[d&&e.jsx(k,{selected:c.value===H.value,onSelect:u=>{c.onChange(u),r("")},value:H.value,children:H.name}),l?p.map(u=>e.jsx(k,{selected:c.value===u.id,onSelect:i=>{c.onChange(i),r("")},value:u.id,children:u.name},u.id)):e.jsx(ee,{})]})})]})]}),e.jsx(C,{})]})}})},Et=(t={page:1,limit:100,sort:"NAME_ASC"})=>{const{data:s,status:n}=E(Ze(t)),r=new Set(s?.results.map(l=>l.flow_id)),{data:a,status:o}=E(ie({flows:{operator:"or_",id:{any_:Array.from(r)}},sort:"NAME_DESC",offset:0},{enabled:r.size>0}));return m.useMemo(()=>{if(a&&s){const l=new Map(a.map(i=>[i.id,i])),h=s.results.map(i=>({...i,flow:l.get(i.flow_id)})),{count:p,limit:d,pages:c,page:x}=s;return{data:{count:p,limit:d,pages:c,page:x,results:h},status:"success"}}return o==="error"||n==="error"?{data:void 0,status:"error"}:{data:void 0,status:"pending"}},[s,n,a,o])},q={value:te,name:"Infer Deployment"},Lt=(t,s)=>{if(s===q.value)return q.name;const n=t?.find(r=>r.id===s);if(n)return e.jsx(qe,{deploymentWithFlow:n})},le=({action:t,index:s})=>{const[n,r]=m.useState(""),a=_(),o=a.watch(`actions.${s}.type`),l=D({name:`actions.${s}.deployment_id`}),h=me(n,500),{data:p}=Et({page:1,sort:"NAME_ASC",deployments:{operator:"or_",flow_or_deployment_name:{like_:h}}}),d=q.name.toLowerCase().includes(n.toLowerCase()),c=p?.results;return e.jsxs(e.Fragment,{children:[e.jsx(w,{control:a.control,name:`actions.${s}.deployment_id`,render:({field:x})=>{const u=Lt(c,x.value);return e.jsxs(b,{className:"flex flex-col",children:[e.jsxs(S,{children:["Deployment To ",t]}),e.jsxs(R,{children:[e.jsx(M,{selected:!!u,"aria-label":`Select Deployment to ${t}`,children:u??"Select deployment"}),e.jsxs(V,{children:[e.jsx(O,{value:n,onValueChange:r,placeholder:"Search for an deployment..."}),e.jsx(W,{children:"No deployment found"}),e.jsx(I,{children:e.jsxs(F,{children:[d&&e.jsx(k,{selected:x.value===q.value,onSelect:x.onChange,value:q.value,children:q.name}),c?c.map(i=>e.jsx(k,{"aria-label":i.name,selected:x.value===i.id,onSelect:x.onChange,value:i.id,children:e.jsx(qe,{deploymentWithFlow:i})},i.id)):e.jsx(ee,{})]})})]})]}),e.jsx(C,{})]})}}),l!==q.value&&o==="run-deployment"&&e.jsx("div",{children:"TODO: Additional fields"})]})},qe=({deploymentWithFlow:t})=>t.flow?e.jsxs("div",{className:"flex items-center gap-0.5",children:[e.jsx("div",{children:t.flow.name}),e.jsx(Y,{className:"size-4",id:"ChevronRight"}),e.jsx("div",{children:t.name})]}):t.name,K={value:te,name:"Infer Work Pool"},Dt=(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(""),a=_(),{data:o,isSuccess:l}=E(pe()),h=m.useDeferredValue(n),p=m.useMemo(()=>o?o.filter(c=>c.name.toLowerCase().includes(h.toLowerCase())):[],[o,h]),d=K.name.toLowerCase().includes(h.toLowerCase());return e.jsx(w,{control:a.control,name:`actions.${s}.work_pool_id`,render:({field:c})=>{const x=Dt(o,c.value);return e.jsxs(b,{className:"flex flex-col",children:[e.jsxs(S,{children:["Work Pool To ",t]}),e.jsxs(R,{children:[e.jsx(M,{selected:!!x,"aria-label":`Select Work Pool to ${t}`,children:x??"Select Work Pool"}),e.jsxs(V,{children:[e.jsx(O,{value:n,onValueChange:r,placeholder:"Search for a work pool..."}),e.jsx(W,{children:"No work pool found"}),e.jsx(I,{children:e.jsxs(F,{children:[d&&e.jsx(k,{selected:c.value===K.value,onSelect:u=>{c.onChange(u),r("")},value:K.value,children:K.name}),l?p.map(u=>e.jsx(k,{selected:c.value===u.id,onSelect:i=>{c.onChange(i),r("")},value:u.id,children:u.name},u.id)):e.jsx(ee,{})]})})]})]}),e.jsx(C,{})]})}})},X={value:te,name:"Infer Work Queue"},Ft=(t,s)=>{if(s===X.value)return X.name;const n=t?.find(r=>r.id===s);if(n)return n.name},_e=({action:t,index:s})=>{const[n,r]=m.useState(""),a=_(),{data:o}=E(Ie()),l=m.useDeferredValue(n),h=m.useMemo(()=>{if(!o)return;const d=new Map,c=o.filter(x=>x.name.toLowerCase().includes(l.toLowerCase()));for(const x of c){const{work_pool_name:u}=x;if(!u)throw new Error("'work_pool_name expected");d.set(u,[...d.get(u)??[],x])}return d},[o,l]),p=X.name.toLowerCase().includes(l.toLowerCase());return e.jsx(w,{control:a.control,name:`actions.${s}.work_queue_id`,render:({field:d})=>{const c=Ft(o,d.value);return e.jsxs(b,{className:"flex flex-col",children:[e.jsxs(S,{children:["Work Queue To ",t]}),e.jsxs(R,{children:[e.jsx(M,{selected:!!c,"aria-label":`Select Work Queue to ${t}`,children:c??"Select Work Queue"}),e.jsxs(V,{children:[e.jsx(O,{value:n,onValueChange:r,placeholder:"Search for a work queue..."}),e.jsx(W,{children:"No work queue found"}),e.jsx(I,{children:e.jsxs(F,{children:[p&&e.jsx(k,{selected:d.value===X.value,onSelect:x=>{d.onChange(x),r("")},value:X.value,children:X.name}),h?Array.from(h).map(([x,u])=>e.jsxs("div",{className:"border-b",children:[e.jsx(k,{disabled:!0,children:x}),u.map(i=>e.jsx(k,{selected:d.value===i.id,onSelect:f=>{d.onChange(f),r("")},value:i.id,children:i.name},i.id))]},x)):e.jsx(ee,{})]})})]})]}),e.jsx(C,{})]})}})},Rt=({index:t})=>{const s=_(),[n,r]=m.useState(""),{data:a,isLoading:o}=E(Ve({offset:0,block_schemas:{operator:"and_",block_capabilities:{all_:["notify"]}}})),l=m.useMemo(()=>a?.map(i=>i.slug)??[],[a]),{data:h,isLoading:p}=E(Oe({block_types:l.length>0?{slug:{any_:l}}:void 0,include_secrets:!1,sort:"BLOCK_TYPE_AND_NAME_ASC",offset:0},{enabled:l.length>0})),d=o||p,c=m.useMemo(()=>!a||!h?[]:a.map(i=>({blockType:i,documents:h.filter(f=>f.block_type_id===i.id)})).filter(i=>i.documents.length>0),[a,h]),x=m.useMemo(()=>{if(!n)return c;const i=n.toLowerCase();return c.map(f=>({...f,documents:f.documents.filter(j=>j.name?.toLowerCase().includes(i))})).filter(f=>f.documents.length>0)},[c,n]),u=m.useCallback(i=>{if(!(!i||!h))return h.find(f=>f.id===i)},[h]);return e.jsxs("div",{className:"space-y-4",children:[e.jsx(w,{control:s.control,name:`actions.${t}.block_document_id`,render:({field:i})=>{const f=u(i.value);return e.jsxs(b,{className:"flex flex-col",children:[e.jsx(S,{children:"Block"}),e.jsxs(R,{children:[e.jsx(M,{selected:!!f,"aria-label":"Select notification block",children:f?f.name:"Select a notification block"}),e.jsxs(V,{children:[e.jsx(O,{value:n,onValueChange:r,placeholder:"Search for a block..."}),e.jsx(W,{children:"No notification blocks found"}),e.jsx(I,{children:d?e.jsx(ee,{}):x.map(j=>e.jsx(F,{heading:j.blockType.name,children:j.documents.map(A=>e.jsx(k,{value:A.id,selected:i.value===A.id,onSelect:i.onChange,children:A.name},A.id))},j.blockType.id))})]})]}),e.jsx(C,{})]})}}),e.jsx(Te,{index:t,name:"subject",label:"Subject",placeholder:"Enter notification subject..."}),e.jsx(Te,{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(Y,{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"}),"."]})]})]})},Te=({index:t,name:s,label:n,placeholder:r,multiline:a=!1})=>{const o=_(),{validateTemplate:l}=We(),[h,p]=m.useState(null),[d,c]=m.useState(!1),x=o.watch(`actions.${t}.${s}`),u=me(x,1e3);m.useEffect(()=>{(async()=>{if(!u||u.trim()===""){p(null);return}c(!0);try{const j=await l(u);j.valid?p(null):p(j.error)}catch{p(null)}finally{c(!1)}})()},[u,l]);const i=a?fe:Z;return e.jsx(w,{control:o.control,name:`actions.${t}.${s}`,render:({field:f})=>e.jsxs(b,{children:[e.jsxs(S,{className:"flex items-center gap-2",children:[n,d&&e.jsx(Y,{id:"Loader2",className:"size-3 animate-spin"})]}),e.jsx(y,{children:e.jsx(i,{...f,value:f.value??"",placeholder:r,className:h?"border-destructive":""})}),h&&e.jsx("p",{className:"text-sm text-destructive",children:h}),e.jsx(C,{})]})})},Mt=({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(Y,{id:"Trash2",className:"size-4"})})]}),e.jsx(yt,{index:t}),e.jsx(Vt,{index:t}),e.jsx("hr",{className:"my-8"})]},t),Vt=({index:t})=>{switch(D({name:`actions.${t}.type`})){case"change-flow-run-state":return e.jsx(Tt,{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(_e,{action:"Pause",index:t});case"resume-work-queue":return e.jsx(_e,{action:"Resume",index:t});case"pause-work-pool":return e.jsx(Ne,{action:"Pause",index:t});case"resume-work-pool":return e.jsx(Ne,{action:"Resume",index:t});case"pause-automation":return e.jsx(ke,{action:"Pause",index:t});case"resume-automation":return e.jsx(ke,{action:"Resume",index:t});case"send-notification":return e.jsx(Rt,{index:t});case"call-webhook":return e.jsx(Nt,{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}},Ot=()=>{const t=_(),{fields:s,append:n,remove:r}=Ge({control:t.control,name:"actions",shouldUnregister:!1,rules:{minLength:1}});return e.jsxs("div",{children:[s.map(({id:a},o)=>e.jsx(Mt,{index:o,onRemove:()=>r(o)},a)),e.jsxs(U,{type:"button",variant:"outline",onClick:()=>n({type:"cancel-flow-run"}),children:[e.jsx(Y,{id:"Plus",className:"mr-2 size-4"})," Add Action"]})]})},Wt=()=>{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(b,{children:[e.jsx(S,{children:"Automation Name"}),e.jsx(y,{children:e.jsx(Z,{type:"text",...s,value:s.value??""})}),e.jsx(C,{})]})}),e.jsx(w,{control:t.control,name:"description",render:({field:s})=>e.jsxs(b,{children:[e.jsx(S,{children:"Description (Optional)"}),e.jsx(y,{children:e.jsx(Z,{type:"text",...s,value:s.value??""})}),e.jsx(C,{})]})})]})},It=[{value:"Reactive",label:"Observe"},{value:"Proactive",label:"Don't observe"}],Pt=30,$t=()=>{const t=_(),s=n=>{const r=t.getValues("trigger.posture");if(t.setValue("trigger.posture",n),r==="Reactive"&&n==="Proactive"){const a=t.getValues("trigger.expect")??[];t.setValue("trigger.after",a),t.setValue("trigger.expect",[]),t.getValues("trigger.within")===0&&t.setValue("trigger.within",Pt)}else if(r==="Proactive"&&n==="Reactive"){const a=t.getValues("trigger.after")??[];t.setValue("trigger.expect",a),t.setValue("trigger.after",[])}};return e.jsx(w,{control:t.control,name:"trigger.posture",render:({field:n})=>e.jsxs(b,{children:[e.jsx(S,{children:"When I"}),e.jsx(y,{children:e.jsx(ft,{value:n.value,onValueChange:s,className:"flex gap-4",children:It.map(r=>e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(gt,{value:r.value,id:`custom-${r.value}`}),e.jsx(xe,{htmlFor:`custom-${r.value}`,children:r.label})]},r.value))})})]})})},ue=60,de=3600,he=86400,qt=[{label:"Seconds",value:1},{label:"Minutes",value:ue},{label:"Hours",value:de},{label:"Days",value:he}];function Ut(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:a,disabled:o=!1}){const[l,h]=m.useState(()=>Ut(t)),p=m.useMemo(()=>qt.filter(u=>u.value>=n),[n]),d=m.useMemo(()=>t/l,[t,l]),c=m.useCallback(u=>{let i=u*l;r!==void 0&&i>r&&(i=r),s(i)},[s,l,r]),x=m.useCallback(u=>{const i=Number(u),f=l;h(i);let j=t/f*i;r!==void 0&&j>r&&(j=r),s(j)},[s,l,t,r]);return m.useEffect(()=>{if(!p.some(u=>u.value===l)){const u=p[0];u&&h(u.value)}},[p,l]),e.jsxs("div",{className:et("grid grid-cols-[1fr_7rem] gap-2 w-full",a),children:[e.jsx(Z,{type:"number",min:0,value:d,onChange:u=>c(Number(u.target.value)),disabled:o,"aria-label":"Duration quantity"}),e.jsxs(B,{value:String(l),onValueChange:x,disabled:o,children:[e.jsx(Q,{"aria-label":"Duration unit",children:e.jsx(z,{})}),e.jsx(J,{children:p.map(u=>e.jsx(G,{value:String(u.value),children:u.label},u.value))})]})]})}const Bt=2,Qt=40;function Ae({selectedResourceIds:t,onToggleResource:s,emptyMessage:n="All resources"}){const[r,a]=m.useState(""),o=m.useDeferredValue(r),[l,h]=m.useState(0),p=m.useRef(null),d=m.useRef(null);m.useEffect(()=>{const g=p.current;if(!g)return;const v=new ResizeObserver(N=>{for(const T of N)h(T.contentRect.width)});return v.observe(g),()=>v.disconnect()},[]);const{resourceOptions:c}=jt(),x=m.useMemo(()=>{const g=[{label:"Automations",options:[]},{label:"Blocks",options:[]},{label:"Deployments",options:[]},{label:"Flows",options:[]},{label:"Work Pools",options:[]},{label:"Work Queues",options:[]}];for(const v of c){const N={label:v.name,value:v.resourceId};switch(v.type){case"automation":g[0].options.push(N);break;case"block":g[1].options.push(N);break;case"deployment":g[2].options.push(N);break;case"flow":g[3].options.push(N);break;case"work-pool":g[4].options.push(N);break;case"work-queue":g[5].options.push(N);break}}return g.map(v=>({...v,options:v.options.sort((N,T)=>N.label.localeCompare(T.label))})).filter(v=>v.options.length>0)},[c]),u=m.useMemo(()=>{if(!o)return x;const g=o.toLowerCase();return x.map(v=>({...v,options:v.options.filter(N=>N.label.toLowerCase().includes(g)||N.value.toLowerCase().includes(g))})).filter(v=>v.options.length>0)},[x,o]),i=m.useMemo(()=>{if(!o.trim()||!o.includes("."))return!1;const g=o.toLowerCase();return!c.some(v=>v.resourceId.toLowerCase()===g)},[o,c]),f=m.useCallback(g=>{const v=d.current;if(!v||l===0||g.length===0)return Math.min(g.length,Bt);const N=g.length>1?l-Qt:l;let T=0;for(let L=0;L<g.length&&(v.textContent=g.slice(0,L+1).join(", "),v.offsetWidth<=N);L++)T=L+1;return T===g.length?g.length:Math.max(1,T)},[l]),j=()=>{if(t.length===0)return e.jsx("span",{className:"text-muted-foreground",children:n});const g=t.map(L=>c.find(Qe=>Qe.resourceId===L)?.name??L),v=f(g),N=g.slice(0,v),T=g.length-v;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:N.join(", ")})}),T>0&&e.jsxs(re,{variant:"bodySmall",className:"shrink-0",children:["+ ",T]}),e.jsx("div",{ref:d,className:"absolute invisible whitespace-nowrap","aria-hidden":"true"})]})},A=g=>{s(g),a("")};return e.jsxs(R,{children:[e.jsx(M,{selected:t.length>0,children:j()}),e.jsxs(V,{children:[e.jsx(O,{value:r,onValueChange:a,placeholder:"Search resources..."}),e.jsxs(I,{children:[e.jsx(W,{children:"No resources found"}),i&&e.jsx(F,{children:e.jsxs(k,{selected:t.includes(o),onSelect:()=>A(o),closeOnSelect:!1,value:o,children:['Add "',o,'"']},"__custom__")}),u.map(g=>e.jsx(F,{heading:g.label,children:g.options.map(v=>e.jsx(k,{selected:t.includes(v.value),onSelect:()=>A(v.value),closeOnSelect:!1,value:v.value,children:v.label},v.value))},g.label))]})]})]})}function zt(t){const s=new Map;for(const n of t){const r=n.split(".");for(let a=1;a<r.length;a++){const o=r.slice(0,a).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 Ee({selectedEvents:t,onToggleEvent:s,emptyMessage:n="All events"}){const[r,a]=m.useState(""),o=m.useDeferredValue(r),[l]=m.useState(()=>({since:new Date(Date.now()-10080*60*1e3).toISOString(),until:new Date().toISOString()})),{data:h=[]}=E(tt("event",{filter:{occurred:l,order:"DESC"},time_unit:"day",time_interval:1})),p=m.useMemo(()=>{const i=h.map(j=>j.label),f=zt(i);return[...i,...f].sort((j,A)=>j.localeCompare(A))},[h]),d=m.useMemo(()=>{if(!o)return p;const i=o.toLowerCase();return p.filter(f=>f.toLowerCase().includes(i))},[p,o]),c=m.useMemo(()=>{if(!o.trim())return!1;const i=o.toLowerCase();return!p.some(f=>f.toLowerCase()===i)},[o,p]),x=()=>{if(t.length===0)return e.jsx("span",{className:"text-muted-foreground",children:n});const i=t.slice(0,2),f=t.length-i.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:i.join(", ")}),f>0&&e.jsxs("span",{className:"shrink-0 text-muted-foreground",children:["+",f]})]})},u=i=>{s(i),a("")};return e.jsxs(R,{children:[e.jsx(M,{selected:t.length>0,children:x()}),e.jsxs(V,{children:[e.jsx(O,{value:r,onValueChange:a,placeholder:"Search events..."}),e.jsxs(I,{children:[e.jsx(W,{children:"No events found"}),e.jsxs(F,{children:[c&&e.jsxs(k,{selected:t.includes(o),onSelect:()=>u(o),closeOnSelect:!1,value:o,children:['Add "',o,'"']},"__custom__"),d.map(i=>e.jsx(k,{selected:t.includes(i),onSelect:()=>u(i),closeOnSelect:!1,value:i,children:i},i))]})]})]})]})}const Jt=()=>{const t=_(),s=D({name:"trigger.posture"});return e.jsxs("div",{className:"space-y-4",children:[e.jsx("div",{className:"flex items-end gap-4",children:e.jsx($t,{})}),e.jsx(w,{control:t.control,name:"trigger.expect",render:({field:n})=>{const r=n.value??[];return e.jsxs(b,{children:[e.jsx(S,{children:"Any event matching"}),e.jsx(y,{children:e.jsx(Ee,{selectedEvents:r,onToggleEvent:a=>{const o=r.includes(a)?r.filter(l=>l!==a):[...r,a];n.onChange(o)}})}),e.jsx(C,{})]})}}),e.jsx(w,{control:t.control,name:"trigger.match",render:({field:n})=>{const r=n.value?.["prefect.resource.id"]??[],a=Array.isArray(r)?r:[r];return e.jsxs(b,{children:[e.jsx(S,{children:"From the following resources"}),e.jsx(y,{children:e.jsx(Ae,{selectedResourceIds:a,onToggleResource:o=>{const l=a.includes(o)?a.filter(h=>h!==o):[...a,o];l.length>0?n.onChange({"prefect.resource.id":l}):n.onChange({})}})}),e.jsx(C,{})]})}}),e.jsxs("div",{className:"flex items-end gap-2",children:[e.jsx(w,{control:t.control,name:"trigger.threshold",render:({field:n})=>e.jsxs(b,{className:"w-20",children:[e.jsx(y,{children:e.jsx(Z,{type:"number",min:1,...n,onChange:r=>n.onChange(Number(r.target.value))})}),e.jsx(C,{})]})}),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(b,{children:[e.jsx(y,{children:e.jsx(se,{value:n.value??0,onChange:n.onChange,min:s==="Proactive"?10:0})}),e.jsx(C,{})]})})]}),e.jsxs(vt,{children:[e.jsxs(bt,{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(St,{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(b,{children:[e.jsx(S,{children:"Evaluate trigger only after observing an event matching"}),e.jsx(y,{children:e.jsx(Ee,{selectedEvents:r,onToggleEvent:a=>{const o=r.includes(a)?r.filter(l=>l!==a):[...r,a];n.onChange(o)}})}),e.jsx(C,{})]})}}),e.jsx(w,{control:t.control,name:"trigger.match_related",render:({field:n})=>{const r=n.value?.["prefect.resource.id"]??[],a=Array.isArray(r)?r:[r];return e.jsxs(b,{children:[e.jsx(S,{children:"Filter for events related to"}),e.jsx(y,{children:e.jsx(Ae,{selectedResourceIds:a,onToggleResource:o=>{const l=a.includes(o)?a.filter(h=>h!==o):[...a,o];l.length>0?n.onChange({"prefect.resource.id":l}):n.onChange({})}})}),e.jsx(C,{})]})}})]})]})]})},Gt=2,Yt=40,Ht=({selectedDeploymentIds:t,onSelectDeploymentIds:s})=>{const[n,r]=m.useState(""),a=m.useDeferredValue(n),[o,l]=m.useState(0),h=m.useRef(null),p=m.useRef(null),d=m.useMemo(()=>new Set(t),[t]);m.useEffect(()=>{const g=h.current;if(!g)return;const v=new ResizeObserver(N=>{for(const T of N)l(T.contentRect.width)});return v.observe(g),()=>v.disconnect()},[]);const{data:c=[]}=E(je({deployments:a?{operator:"and_",name:{like_:a}}:void 0,limit:100,offset:0,sort:"NAME_ASC"})),{data:x=[]}=E(je({deployments:d.size>0?{operator:"and_",id:{any_:t}}:void 0,limit:d.size||1,offset:0,sort:"NAME_ASC"},{enabled:d.size>0})),u=g=>{const v=new Set(d);d.has(g)?v.delete(g):v.add(g),s(Array.from(v))},i=()=>{s([])},f=m.useCallback(g=>{const v=p.current;if(!v||o===0||g.length===0)return Math.min(g.length,Gt);const N=g.length>1?o-Yt:o;let T=0;for(let L=0;L<g.length&&(v.textContent=g.slice(0,L+1).join(", "),v.offsetWidth<=N);L++)T=L+1;return T===g.length?g.length:Math.max(1,T)},[o]),j=()=>{if(d.size===0)return"All deployments";const g=x.filter(L=>d.has(L.id)).map(L=>L.name),v=f(g),N=g.slice(0,v),T=g.length-v;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:N.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"})]})},A=m.useMemo(()=>c.filter(g=>!a||g.name.toLowerCase().includes(a.toLowerCase())),[c,a]);return e.jsxs(R,{children:[e.jsx(M,{"aria-label":"Select deployments",selected:d.size===0,children:j()}),e.jsxs(V,{children:[e.jsx(O,{value:n,onValueChange:r,placeholder:"Search deployments..."}),e.jsxs(I,{children:[e.jsx(W,{children:"No deployments found"}),e.jsxs(F,{children:[e.jsxs(k,{"aria-label":"All deployments",onSelect:i,closeOnSelect:!1,value:"__all__",children:[e.jsx(ve,{checked:d.size===0}),"All deployments"]}),A.map(g=>e.jsxs(k,{"aria-label":g.name,onSelect:()=>u(g.id),closeOnSelect:!1,value:g.id,children:[e.jsx(ve,{checked:d.has(g.id)}),g.name]},g.id))]})]})]})]})},Kt=[{value:"Reactive",label:"Enters"},{value:"Proactive",label:"Stays in"}],Xt=30,ne=()=>{const t=_();return e.jsx(w,{control:t.control,name:"trigger.posture",render:({field:s})=>e.jsx(b,{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 a=t.getValues("trigger.expect")??[];t.setValue("trigger.after",a),t.setValue("trigger.expect",[]),t.getValues("trigger.within")===0&&t.setValue("trigger.within",Xt)}else if(r==="Proactive"&&n==="Reactive"){const a=t.getValues("trigger.after")??[];t.setValue("trigger.expect",a),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:Kt.map(n=>e.jsx(G,{value:n.value,children:n.label},n.value))})]})})})})},Zt=86400,es=30*Zt,ts=[{value:"prefect.deployment.ready",label:"Ready"},{value:"prefect.deployment.not-ready",label:"Not Ready"},{value:"prefect.deployment.disabled",label:"Disabled"}],Ue="prefect.deployment.",Be="prefect.deployment.*",ss=t=>t?(Array.isArray(t)?t:[t]).filter(n=>n!==Be).map(n=>n.replace(Ue,"")):[],rs=t=>t.length===0?Be:t.map(s=>`${Ue}${s}`),ns=()=>{const t=_(),s=D({name:"trigger.posture"}),n=D({name:"trigger.match"}),r=m.useMemo(()=>{const l=n?.["prefect.resource.id"];return ss(l)},[n]),a=m.useCallback(o=>{const l=t.getValues("trigger.match")??{};t.setValue("trigger.match",{...l,"prefect.resource.id":rs(o)})},[t]);return e.jsxs("div",{className:"space-y-4",children:[e.jsxs(b,{children:[e.jsx(S,{children:"Deployments"}),e.jsx(y,{children:e.jsx(Ht,{selectedDeploymentIds:r,onSelectDeploymentIds:a})})]}),e.jsxs(b,{children:[e.jsx(S,{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 l=o.value?.[0];return e.jsxs(B,{value:l??"",onValueChange:h=>o.onChange([h]),children:[e.jsx(Q,{className:"w-full",children:e.jsx(z,{placeholder:"Select status"})}),e.jsx(J,{children:ts.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(b,{children:[e.jsx(S,{children:"Within"}),e.jsx(y,{children:e.jsx(se,{value:o.value??0,onChange:o.onChange,min:10,max:es})}),e.jsx(C,{})]})})]})},os=2;function as({selectedFlowIds:t,onToggleFlow:s,emptyMessage:n="Any flow"}){const[r,a]=m.useState(""),o=m.useDeferredValue(r),{data:l=[]}=E(ie({flows:o?{operator:"and_",name:{like_:o}}:void 0,limit:100,offset:0,sort:"NAME_ASC"})),{data:h=[]}=E(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(()=>l.filter(c=>!o||c.name.toLowerCase().includes(o.toLowerCase())),[l,o]),d=()=>{if(t.length===0)return e.jsx("span",{className:"text-muted-foreground",children:n});const x=h.filter(i=>t.includes(i.id)).map(i=>i.name).slice(0,os),u=t.length-x.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:x.join(", ")}),u>0&&e.jsxs("span",{className:"shrink-0 text-muted-foreground",children:["+",u]})]})};return e.jsxs(R,{children:[e.jsx(M,{selected:t.length>0,children:d()}),e.jsxs(V,{children:[e.jsx(O,{value:r,onValueChange:a,placeholder:"Search flows..."}),e.jsxs(I,{children:[e.jsx(W,{children:"No flows found"}),e.jsx(F,{children:p.map(c=>e.jsx(k,{selected:t.includes(c.id),onSelect:()=>{s(c.id),a("")},closeOnSelect:!1,value:c.id,children:c.name},c.id))})]})]})]})}const P="All run states",$="All except scheduled";function ls(t){return t.length!==$e.length-1?!1:!t.includes("Scheduled")}function cs({selectedStates:t,onStateChange:s,emptyMessage:n="Any state"}){const[r,a]=m.useState(""),o=m.useDeferredValue(r),l=m.useMemo(()=>t.length===0?P:ls(t)?$:t,[t]),h=m.useMemo(()=>{const u=o.toLowerCase();return $e.filter(i=>i.toLowerCase().includes(u))},[o]),p=m.useMemo(()=>{const u=o.toLowerCase();return P.toLowerCase().includes(u)||$.toLowerCase().includes(u)},[o]),d=u=>{u===P?s([]):u===$&&s([...xt]),a("")},c=u=>{t.includes(u)?s(t.filter(i=>i!==u)):s([...t,u]),a("")},x=()=>l===P?e.jsx("span",{className:"text-muted-foreground",children:n}):l===$?e.jsx("span",{children:"All except scheduled"}):e.jsx("div",{className:"flex flex-wrap gap-1",children:t.map(u=>e.jsx(be,{type:ye[u],name:u,className:"cursor-pointer"},u))});return e.jsxs(R,{children:[e.jsx(M,{selected:t.length>0,children:x()}),e.jsxs(V,{children:[e.jsx(O,{value:r,onValueChange:a,placeholder:"Search states..."}),e.jsx(W,{children:"No state found"}),e.jsx(I,{children:e.jsxs(F,{children:[p&&e.jsxs(e.Fragment,{children:[e.jsx(k,{selected:l===P,onSelect:()=>d(P),value:P,closeOnSelect:!1,children:"All run states"},P),e.jsx(k,{selected:l===$,onSelect:()=>d($),value:$,closeOnSelect:!1,children:"All except scheduled"},$)]}),h.map(u=>e.jsx(k,{selected:t.includes(u),onSelect:()=>c(u),value:u,closeOnSelect:!1,children:e.jsx(be,{type:ye[u],name:u})},u))]})})]})]})}function is(t){return t.length===0?["prefect.flow-run.*"]:t.map(s=>`prefect.flow-run.${s}`)}function us(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 ds(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 hs(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 Le(t,s){const n=t.map(l=>`prefect.flow.${l}`),r=s.map(l=>`prefect.tag.${l}`);if(n.length===0&&r.length===0)return{};const a=n.length>0?"flow":"tag",o=[...n,...r];return{"prefect.resource.role":a,"prefect.resource.id":o}}const ms=()=>{const t=_(),s=D({name:"trigger.posture"}),n=s==="Proactive"?"trigger.after":"trigger.expect",r=D({name:"trigger.match_related"}),a=ds(r),o=hs(r),l=d=>{const c=a,x=c.includes(d)?c.filter(i=>i!==d):[...c,d],u=x.length>0?[]:o;t.setValue("trigger.match_related",Le(x,u))},h=d=>{t.setValue("trigger.match_related",Le(a,d))},p=a.length===0;return e.jsxs("div",{className:"space-y-4",children:[e.jsxs(b,{children:[e.jsx(S,{children:"Flows"}),e.jsx(y,{children:e.jsx(as,{selectedFlowIds:a,onToggleFlow:l,emptyMessage:"All flows"})})]}),p&&e.jsxs(b,{children:[e.jsx(S,{children:"Flow Run Tags"}),e.jsx(y,{children:e.jsx(wt,{value:o,onChange:h,placeholder:"All tags"})})]}),e.jsxs(b,{children:[e.jsx(S,{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:d})=>{const c=d.value??[],x=us(c);return e.jsx(y,{children:e.jsx(cs,{selectedStates:x,onStateChange:u=>{d.onChange(is(u))},emptyMessage:"Any state"})})}})]})]}),s==="Proactive"&&e.jsx(w,{control:t.control,name:"trigger.within",render:({field:d})=>e.jsxs(b,{children:[e.jsx(S,{children:"For"}),e.jsx(y,{children:e.jsx(se,{value:d.value??0,onChange:d.onChange,min:0})}),e.jsx(C,{})]})})]})},ps=({defaultValue:t="Form",value:s,onValueChange:n,formContent:r,jsonContent:a})=>{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(Se,{value:"Form",children:"Form"}),e.jsx(Se,{value:"JSON",children:"JSON"})]})}),e.jsx(we,{value:"Form",children:r}),e.jsx(we,{value:"JSON",children:a})]})},xs=({value:t,onChange:s,error:n})=>{const[r,a]=m.useState(null),o=()=>{try{const h=JSON.parse(t);s(JSON.stringify(h,null,2))}catch{}},l=h=>{try{const p=JSON.parse(h);return Pe.parse(p),a(null),!0}catch(p){return p instanceof SyntaxError?a("Invalid JSON syntax"):p instanceof Re&&a(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(xe,{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:()=>l(t)}),(r||n)&&e.jsx("p",{className:"text-sm text-destructive",children:r||n})]})},De={"deployment-status":"Deployment status","flow-run-state":"Flow run state","work-pool-status":"Work pool status","work-queue-status":"Work queue status",custom:"Custom"},fs=({onValueChange:t,value:s})=>e.jsxs("div",{className:"space-y-2",children:[e.jsx(xe,{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(Me,{children:Object.keys(De).map(n=>e.jsx(G,{value:n,children:De[n]},n))})})]})]}),gs=({onTemplateChange:t})=>{const s=_();return e.jsx(w,{control:s.control,name:"triggerTemplate",render:({field:n})=>e.jsx(b,{children:e.jsx(y,{children:e.jsx(fs,{value:n.value,onValueChange:r=>{n.onChange(r),t?.(r)}})})})})},js={type:"event",posture:"Reactive",threshold:1,within:0},vs=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 js}};function bs({selectedWorkPoolIds:t,onToggleWorkPool:s,emptyMessage:n="All work pools"}){const[r,a]=m.useState(""),o=m.useDeferredValue(r),{data:l=[]}=E(pe()),h=m.useMemo(()=>l.filter(c=>c.status!==null).filter(c=>!o||c.name.toLowerCase().includes(o.toLowerCase())),[l,o]),p=m.useMemo(()=>l.filter(c=>t.includes(c.id)),[l,t]),d=()=>{if(t.length===0)return e.jsx("span",{className:"text-muted-foreground",children:n});const c=p.map(x=>x.name);return e.jsx("span",{className:"truncate min-w-0 text-left",children:c.join(", ")})};return e.jsxs(R,{children:[e.jsx(M,{selected:t.length>0,children:d()}),e.jsxs(V,{children:[e.jsx(O,{value:r,onValueChange:a,placeholder:"Search work pools..."}),e.jsxs(I,{children:[e.jsx(W,{children:"No work pools found"}),e.jsx(F,{children:h.map(c=>e.jsx(k,{selected:t.includes(c.id),onSelect:()=>{s(c.id),a("")},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 Fe(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 Ss(t){const s=oe.find(n=>n.value===t);return s?[...s.events]:[]}function ws(t){return oe.filter(s=>s.value!==t).flatMap(s=>[...s.events])}function ys(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 Cs(t){return t.length===0?{"prefect.resource.id":"prefect.work-pool.*"}:{"prefect.resource.id":t.map(s=>`prefect.work-pool.${s}`)}}const ks=()=>{const t=_(),s=D({name:"trigger.posture"}),n=D({name:"trigger.expect"}),r=D({name:"trigger.after"}),a=Fe(s==="Proactive"?r:n),o=l=>{const h=Ss(l),p=ws(l);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:a,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(l=>e.jsx(G,{value:l.value,children:l.label},l.value))})]})},Ns=()=>{const t=_(),s=D({name:"trigger.posture"}),n=D({name:"trigger.match"}),r=ys(n),a=o=>{const l=r,h=l.includes(o)?l.filter(p=>p!==o):[...l,o];t.setValue("trigger.match",Cs(h))};return e.jsxs("div",{className:"space-y-4",children:[e.jsxs(b,{children:[e.jsx(S,{children:"Work Pools"}),e.jsx(y,{children:e.jsx(bs,{selectedWorkPoolIds:r,onToggleWorkPool:a,emptyMessage:"All work pools"})})]}),e.jsxs(b,{children:[e.jsx(S,{children:"Work Pool"}),e.jsxs("div",{className:"flex gap-2",children:[e.jsx(ne,{}),e.jsx(ks,{})]})]}),s==="Proactive"&&e.jsx(w,{control:t.control,name:"trigger.within",render:({field:o})=>e.jsxs(b,{children:[e.jsx(S,{children:"For"}),e.jsx(y,{children:e.jsx(se,{value:o.value??30,onChange:o.onChange,min:0})}),e.jsx(C,{})]})})]})};function _s({selectedWorkPoolIds:t,onToggleWorkPool:s,emptyMessage:n="All work pools"}){const[r,a]=m.useState(""),o=m.useDeferredValue(r),{data:l=[]}=E(pe({limit:100,offset:0})),h=m.useMemo(()=>l.filter(d=>d.status?o?d.name.toLowerCase().includes(o.toLowerCase()):!0:!1),[l,o]),p=()=>{if(t.length===0)return e.jsx("span",{className:"text-muted-foreground",children:n});const d=l.filter(c=>t.includes(c.id)).map(c=>c.name);return e.jsx("span",{className:"truncate min-w-0 text-left",children:d.join(", ")})};return e.jsxs(R,{children:[e.jsx(M,{selected:t.length>0,children:p()}),e.jsxs(V,{children:[e.jsx(O,{value:r,onValueChange:a,placeholder:"Search work pools..."}),e.jsxs(I,{children:[e.jsx(W,{children:"No work pools found"}),e.jsx(F,{children:h.map(d=>e.jsx(k,{selected:t.includes(d.id),onSelect:()=>{s(d.id),a("")},closeOnSelect:!1,value:d.id,children:d.name},d.id))})]})]})]})}function Ts({selectedWorkQueueIds:t,onToggleWorkQueue:s,workPoolIds:n=[],emptyMessage:r="All work queues"}){const[a,o]=m.useState(""),l=m.useDeferredValue(a),{data:h=[]}=E(Ie({limit:100,offset:0})),p=m.useMemo(()=>h.filter(x=>n.length>0&&(!x.work_pool_id||!n.includes(x.work_pool_id))?!1:l?x.name.toLowerCase().includes(l.toLowerCase()):!0),[h,n,l]),d=m.useMemo(()=>{const x={};for(const i of p){const f=i.work_pool_name??"Unknown";x[f]||(x[f]=[]),x[f].push(i)}return Object.keys(x).sort((i,f)=>i.localeCompare(f)).map(i=>({poolName:i,queues:x[i].sort((f,j)=>f.name.localeCompare(j.name))}))},[p]),c=()=>{if(t.length===0)return e.jsx("span",{className:"text-muted-foreground",children:r});const x=h.filter(u=>t.includes(u.id)).map(u=>u.name);return e.jsx("span",{className:"truncate min-w-0 text-left",children:x.join(", ")})};return e.jsxs(R,{children:[e.jsx(M,{selected:t.length>0,children:c()}),e.jsxs(V,{children:[e.jsx(O,{value:a,onValueChange:o,placeholder:"Search work queues..."}),e.jsxs(I,{children:[e.jsx(W,{children:"No work queues found"}),d.map(x=>e.jsx(F,{heading:x.poolName,children:x.queues.map(u=>e.jsx(k,{selected:t.includes(u.id),onSelect:()=>{s(u.id),o("")},closeOnSelect:!1,value:u.id,children:u.name},u.id))},x.poolName))]})]})]})}const As=[{value:"prefect.work-queue.ready",label:"Ready"},{value:"prefect.work-queue.not-ready",label:"Not Ready"},{value:"prefect.work-queue.paused",label:"Paused"}];function Es(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 Ls(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 Ds(t){return t.length===0?{}:{"prefect.resource.role":"work-pool","prefect.resource.id":t.map(n=>`prefect.work-pool.${n}`)}}function Fs(t){return t.length===0?{"prefect.resource.id":"prefect.work-queue.*"}:{"prefect.resource.id":t.map(n=>`prefect.work-queue.${n}`)}}const Rs=()=>{const t=_(),s=D({name:"trigger.posture"}),n=D({name:"trigger.match_related"}),r=D({name:"trigger.match"}),a=Es(n),o=Ls(r),l=p=>{const d=a,c=d.includes(p)?d.filter(x=>x!==p):[...d,p];t.setValue("trigger.match_related",Ds(c))},h=p=>{const d=o,c=d.includes(p)?d.filter(x=>x!==p):[...d,p];t.setValue("trigger.match",Fs(c))};return e.jsxs("div",{className:"space-y-4",children:[e.jsxs(b,{children:[e.jsx(S,{children:"Work Pools"}),e.jsx(y,{children:e.jsx(_s,{selectedWorkPoolIds:a,onToggleWorkPool:l,emptyMessage:"All work pools"})})]}),e.jsxs(b,{children:[e.jsx(S,{children:"Work Queues"}),e.jsx(y,{children:e.jsx(Ts,{selectedWorkQueueIds:o,onToggleWorkQueue:h,workPoolIds:a,emptyMessage:"All work queues"})})]}),e.jsxs(b,{children:[e.jsx(S,{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 d=p.value?.[0];return e.jsx(y,{children:e.jsxs(B,{value:d??"",onValueChange:c=>p.onChange([c]),children:[e.jsx(Q,{className:"w-full",children:e.jsx(z,{placeholder:"Select status"})}),e.jsx(J,{children:As.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(b,{children:[e.jsx(S,{children:"For"}),e.jsx(y,{children:e.jsx(se,{value:p.value??0,onChange:p.onChange,min:0})}),e.jsx(C,{})]})})]})},Ms=()=>{const t=_(),s=t.watch("triggerTemplate"),n=t.watch("trigger"),[r,a]=m.useState("Form"),[o,l]=m.useState(""),[h,p]=m.useState(void 0),d=m.useCallback(()=>JSON.stringify(n,null,2),[n]);m.useEffect(()=>{r==="Form"&&l(d())},[r,d]);const c=m.useCallback(f=>{try{const j=JSON.parse(f);return{valid:!0,trigger:Pe.parse(j)}}catch(j){return j instanceof SyntaxError?{valid:!1,error:"Invalid JSON syntax"}:j instanceof Re?{valid:!1,error:j.errors[0]?.message??"Invalid trigger configuration"}:{valid:!1,error:"Unknown error"}}},[]),x=m.useCallback(f=>{if(r!==f){if(f==="Form"){const j=c(o);if(!j.valid){p(j.error);return}j.trigger&&t.setValue("trigger",j.trigger),p(void 0)}else l(d()),p(void 0);a(f)}},[r,o,c,t,d]),u=m.useCallback(f=>{l(f);const j=c(f);j.valid&&j.trigger&&(t.setValue("trigger",j.trigger),p(void 0))},[c,t]),i=f=>{const j=vs(f);t.setValue("trigger",j),l(JSON.stringify(j,null,2)),p(void 0)};return e.jsxs("div",{className:"space-y-6",children:[e.jsx(gs,{onTemplateChange:i}),s&&e.jsx(ps,{value:r,onValueChange:x,formContent:e.jsx(Vs,{template:s}),jsonContent:e.jsx(xs,{value:o,onChange:u,error:h})})]})},Vs=({template:t})=>{switch(t){case"flow-run-state":return e.jsx(ms,{});case"deployment-status":return e.jsx(ns,{});case"work-pool-status":return e.jsx(Ns,{});case"work-queue-status":return e.jsx(Rs,{});case"custom":return e.jsx(Jt,{});default:return null}},ce=["Trigger","Actions","Details"],Os={actions:[{type:void 0}],trigger:{type:"event",posture:"Reactive",threshold:1,within:0}},Hs=({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]),l=ut(ce.length,0,o),h=Ye({resolver:Je(ht),defaultValues:{...Os,...t}}),p=ce[l.currentStep],d={Trigger:{render:()=>e.jsx(Ms,{}),trigger:()=>h.trigger("trigger")},Actions:{render:()=>e.jsx(Ot,{}),trigger:()=>h.trigger("actions")},Details:{render:()=>e.jsx(Wt,{}),trigger:()=>h.trigger(["description","name"])}},c=async x=>{await d[x].trigger()&&l.incrementStep()};return e.jsx(it,{...h,children:e.jsx("form",{onSubmit:x=>{h.handleSubmit(s)(x)},children:e.jsxs("div",{className:"flex flex-col gap-8",children:[e.jsx(dt,{steps:ce,currentStepNum:l.currentStep,onClick:x=>l.changeStep(x.stepNum),completedSteps:l.completedStepsSet,visitedSteps:l.visitedStepsSet}),e.jsxs(at,{className:"p-4 pt-8",children:[e.jsxs(lt,{children:[d[p].render(),e.jsx(C,{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(ze,{to:"/automations",children:"Cancel"})}),e.jsx(U,{disabled:l.isStartingStep,type:"button",variant:"outline",onClick:l.decrementStep,children:"Previous"}),l.isFinalStep?e.jsx(U,{type:"submit",loading:r,children:n},"save"):e.jsx(U,{type:"button",onClick:()=>{c(p)},children:"Next"},"next")]})]})]})})})};export{Hs as A};
2
+ //# sourceMappingURL=automation-wizard-Bmgt6nn8.js.map