import{j as t,h as l,z as p}from"./vendor-tanstack-BpuysabX.js";import{D as x,B as b,g,h as m,bD as f,bQ as j,bS as h,bT as v,bU as D,bV as B,bW as S,y as c}from"./index-CREafGO4.js";import"./automation-schema-DnZvg-v_.js";import{A}from"./automation-wizard-B6t3MhGq.js";import{t as N}from"./event-to-trigger-BEzU9b5I.js";import"./vendor-radix-DIu41Ss_.js";import"./vendor-recharts-C2XeLr4O.js";import"./vendor-forms-Buh7U8Ay.js";import"./vendor-date-C1t37jsh.js";import"./zod-CtcMvSO9.js";import"./form-DC8L1tSC.js";import"./use-stepper-C-n__du8.js";import"./textarea-Bxh8agz9.js";import"./index-DVVSN4AL.js";import"./radio-group-B1MsDBBw.js";import"./collapsible-B3ULeOqx.js";import"./tags-input-Bd-BicQ9.js";const y=()=>t.jsxs("div",{className:"flex items-center justify-between",children:[t.jsx(C,{}),t.jsx(x,{label:"Documentation",id:"automations-guide"})]}),C=()=>t.jsx("div",{className:"flex items-center gap-2",children:t.jsx(b,{children:t.jsxs(g,{children:[t.jsx(m,{children:t.jsx(f,{to:"/automations",className:"text-xl font-semibold",children:"Automations"})}),t.jsx(j,{}),t.jsx(m,{className:"text-xl font-semibold",children:t.jsx(h,{children:"Create"})})]})})});function E(){const{eventId:r,eventDate:e}=D.useSearch(),o=!!(r&&e),{data:a}=p({...B(r??"",e?S(e):new Date),enabled:o});if(!o||!a)return;const{trigger:i,triggerTemplate:n}=N(a);return{trigger:i,triggerTemplate:n}}const J=function(){const{createAutomation:e,isPending:o}=v(),a=l(),i=E(),n=s=>{const u={name:s.name,description:s.description??"",enabled:!0,trigger:s.trigger,actions:s.actions};e(u,{onSuccess:()=>{c.success("Automation created successfully"),a({to:"/automations"})},onError:d=>{c.error(`Failed to create automation: ${d.message}`)}})};return t.jsxs("div",{className:"flex flex-col gap-4",children:[t.jsx(y,{}),t.jsx(A,{defaultValues:i,onSubmit:n,isSubmitting:o})]})};export{J as component};
//# sourceMappingURL=create-CxJKBHMZ.js.map
