import{B as e,Et as t,H as n,Lt as r,Rt as i,Tt as a,U as o,Ut as s,W as c,bt as l,kt as u,q as d,r as f,tt as p,yt as m}from"../chunks/De2yIhEs.js";import"../chunks/D5dhgX4z.js";import"../chunks/UJE8BsR4.js";import"../chunks/Cj9ecUMW.js";import"../chunks/BFbU5qhn.js";import"../chunks/tmK-_Zu8.js";import"../chunks/CXy0rHsr.js";import{t as h}from"../chunks/60F0m2ed.js";import{B as g,U as _,n as v}from"../chunks/DVD-VP-F.js";import"../chunks/BNS5LF6k.js";import{r as y}from"../chunks/DLl5XHy4.js";import"../chunks/BrMTXoyD.js";import{n as b,t as x}from"../chunks/U2gI3XA6.js";import{t as S}from"../chunks/CoakvsTA.js";var C=c(`<!> <!>`,1);function w(c,w){i(w,!0);let T=x,E=u(()=>h.params.id),D=u(()=>T.actions.find(e=>e.id===p(E))),O=t(!0),k=t(!1),A=t(null);f(async()=>{(T.actions.length===0||!T.lastLoadedAt)&&await b.load({include_archived:!0}),a(O,!1)});async function j(e){if(p(E)){a(k,!0),a(A,null);try{await b.update(p(E),e),await y(`/actions/custom`)}catch(e){throw e instanceof Error&&a(A,e.message,!0),e}finally{a(k,!1)}}}function M(){y(`/actions/custom`)}g(c,{heading:`Edit Custom Action`,description:`Modify the configuration for this custom action.`,actions:e=>{_(e,{variant:`secondary`,onclick:M,children:(e,t)=>{s(),n(e,d(`← Back to List`))},$$slots:{default:!0}})},children:(t,r)=>{var i=o(),a=m(i),s=e=>{v(e,{variant:`loading`,title:`Loading custom action`,message:`Retrieving action details for editing.`,testId:`custom-action-edit-loading-state`})},c=t=>{var r=o(),i=m(r),a=e=>{v(e,{variant:`empty`,title:`Custom action not found`,message:`This action may have been removed or you may no longer have access.`,actionLabel:`Back to list`,onAction:M,testId:`custom-action-edit-empty-state`})},s=t=>{var r=C(),i=m(r),a=e=>{v(e,{variant:`error`,title:`Unable to update custom action`,get message(){return p(A)},actionLabel:`Back to list`,onAction:M,testId:`custom-action-edit-error-state`})};e(i,e=>{p(A)&&e(a)}),S(l(i,2),{get initialData(){return p(D)},get definitions(){return T.definitions},onSubmit:j,onCancel:M,get submitting(){return p(k)}}),n(t,r)};e(i,e=>{p(D)?e(s,!1):e(a)},!0),n(t,r)};e(a,e=>{p(O)||T.loading?e(s):e(c,!1)}),n(t,i)},$$slots:{actions:!0,default:!0}}),r()}export{w as component};