var I=Object.defineProperty;var v=Object.getOwnPropertySymbols;var T=Object.prototype.hasOwnProperty,w=Object.prototype.propertyIsEnumerable;var _=(s,t,a)=>t in s?I(s,t,{enumerable:!0,configurable:!0,writable:!0,value:a}):s[t]=a,S=(s,t)=>{for(var a in t||(t={}))T.call(t,a)&&_(s,a,t[a]);if(v)for(var a of v(t))w.call(t,a)&&_(s,a,t[a]);return s};import{u as L,r,j as i}from"./main-406.js";import{d as C,_ as M,I as D,G as E,c as m}from"./bi.394.85.js";import{S as P}from"./bi.68.941.js";import F from"./bi.646.323.js";import{a as R,c as j}from"./bi.397.903.js";import{G as z}from"./bi.131.904.js";import"./bi.150.760.js";import"./bi.704.707.js";import"./bi.701.708.js";function X({formFields:s,setFlow:t,flow:a,allIntegURL:p}){const u=L(),[f,o]=r.useState(!1),[g,b]=r.useState({}),[n,y]=r.useState(1),[q,c]=r.useState({show:!1}),k=[{key:"send_date",label:"Send Date",required:!1},{key:"ttl",label:"Time to Live",required:!1},{key:"push_tag",label:"Push Tag",required:!1},{key:"display_time",label:"Display Time",required:!1},{key:"is_transactional",label:"Is Transactional",required:!1},{key:"segments",label:"Segments",required:!1},{key:"message",label:"Message",required:!0},{key:"title",label:"Title",required:!1},{key:"icon",label:"Icon",required:!0},{key:"image",label:"Image",required:!1},{key:"redirect_url",label:"Redirect URL",required:!0}],[e,d]=r.useState({name:"Gravitec",type:"Gravitec",app_key:"",app_secret:"",site_url:"",field_map:R(k),actionName:"",notificationFields:k,actions:{}}),N=()=>{o(!0),E(a,t,p,e,u,"","",o).then(l=>{var h;l.success?(m.success((h=l.data)==null?void 0:h.msg),u(p)):m.error(l.data||l)})},G=x=>{if(setTimeout(()=>{document.getElementById("btcd-settings-wrp").scrollTop=0},300),!j(e)){m.error("Please map mandatory fields");return}e.field_map.length>0&&y(x)};return i.jsxs("div",{children:[i.jsx(C,{snack:q,setSnackbar:c}),i.jsx("div",{className:"txt-center mt-2",children:i.jsx(P,{step:3,active:n})}),i.jsx(F,{gravitecConf:e,setGravitecConf:d,step:n,setStep:y,loading:g,setLoading:b,setSnackbar:c}),i.jsxs("div",{className:"btcd-stp-page",style:S({},n===2&&{width:900,height:"auto",overflow:"visible"}),children:[i.jsx(z,{formFields:s,gravitecConf:e,setGravitecConf:d,loading:g,setLoading:b,isLoading:f,setIsLoading:o,setSnackbar:c}),(e==null?void 0:e.actionName)&&i.jsxs("button",{onClick:()=>G(3),disabled:!j(e),className:"btn f-right btcd-btn-lg purple sh-sm flx",type:"button",children:[M("Next","bit-integrations")," "," ",i.jsx("div",{className:"btcd-icn icn-arrow_back rev-icn d-in-b"})]})]}),(e==null?void 0:e.actionName)&&i.jsx(D,{step:n,saveConfig:()=>N(),isLoading:f,dataConf:e,setDataConf:d,formFields:s})]})}export{X as default};
