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