import{B as e,Et as t,H as n,Lt as r,Rt as i,Tt as a,Ut as o,W as s,bt as c,q as l,r as u,tt as d,yt as f}from"../chunks/De2yIhEs.js";import"../chunks/B3S62nzQ.js";import"../chunks/n2WO9qDz.js";import"../chunks/Cj9ecUMW.js";import"../chunks/BFbU5qhn.js";import"../chunks/BojM3cNZ.js";import"../chunks/CXy0rHsr.js";import{B as p,U as m,n as h}from"../chunks/BOHDQCOY.js";import"../chunks/BNS5LF6k.js";import{r as g}from"../chunks/G937Ab70.js";import"../chunks/BrMTXoyD.js";import{n as _,t as v}from"../chunks/D-p4QoPR.js";import{t as y}from"../chunks/CS-HNviX.js";var b=s(`<!> <!>`,1);function x(s,x){i(x,!0);let S=t(!1),C=t(null);u(async()=>{v.definitions.length===0&&await _.load()});async function w(e){a(S,!0),a(C,null);try{await _.create(e),await g(`/actions/custom`)}catch(e){throw e instanceof Error&&a(C,e.message,!0),e}finally{a(S,!1)}}function T(){g(`/actions/custom`)}p(s,{heading:`Create Custom Action`,description:`Create a blank action or start from a built-in action template.`,actions:e=>{m(e,{variant:`secondary`,onclick:T,children:(e,t)=>{o(),n(e,l(`← Back to List`))},$$slots:{default:!0}})},children:(t,r)=>{var i=b(),a=f(i),o=e=>{h(e,{variant:`error`,title:`Unable to create custom action`,get message(){return d(C)},actionLabel:`Back to list`,onAction:T,testId:`custom-action-create-error-state`})};e(a,e=>{d(C)&&e(o)});var s=c(a,2),l=e=>{h(e,{variant:`loading`,title:`Loading templates`,message:`Fetching template definitions before creating your custom action.`,testId:`custom-action-create-loading-state`})},u=e=>{y(e,{get definitions(){return v.definitions},onSubmit:w,onCancel:T,get submitting(){return d(S)}})};e(s,e=>{v.loading?e(l):e(u,!1)}),n(t,i)},$$slots:{actions:!0,default:!0}}),r()}export{x as component};