var P=Object.defineProperty;var j=Object.getOwnPropertySymbols;var v=Object.prototype.hasOwnProperty,w=Object.prototype.propertyIsEnumerable;var b=(t,a,s)=>a in t?P(t,a,{enumerable:!0,configurable:!0,writable:!0,value:s}):t[a]=s,l=(t,a)=>{for(var s in a||(a={}))v.call(a,s)&&b(t,s,a[s]);if(j)for(var s of j(a))w.call(a,s)&&b(t,s,a[s]);return t};import{r as c,a as L,j as e,_ as n,L as S,bs as K,c as M}from"./main-634.js";import{t as k}from"./bf-275-83.js";import{a5 as T,a6 as B}from"./bf-746-82.js";import{N as F}from"./bf-123-109.js";import{g as H}from"./bf-993-173.js";import"./bf-822-108.js";import"./bf-25-81.js";function U({elasticEmailConf:t,setElasticEmailConf:a,step:s,setstep:z,isInfo:m}){const[o,x]=c.useState({authorized:!1,errorMsg:""}),[h,g]=c.useState({name:"",api_key:""}),[A,N]=c.useState(!1),[p,u]=c.useState(!1),{css:_}=L(),I=()=>{const r=l({},t);if(!r.name||!r.api_key){g({name:r.name?"":n("Integration name cann't be empty"),api_key:r.api_key?"":n("API Key cann't be empty")});return}u("auth");const d={api_key:r.api_key};M(d,"bitforms_elasticemail_authorize").then(i=>{i!=null&&i.success?x({authorized:!0,errorMsg:""}):x({authorized:!1,errorMsg:(i==null?void 0:i.data)||""}),N(!0),u(!1)})},y=r=>{const d=l({},t),i=l({},h);i[r.target.name]="",d[r.target.name]=r.target.value,g(i),a(d)},f=()=>{setTimeout(()=>{document.getElementById("btcd-settings-wrp").scrollTop=0},300),!(t!=null&&t.default)&&H(t,a,u),z(2)};return e.jsxs("div",{className:"btcd-stp-page",style:{width:s===1&&900,height:s===1&&"auto"},children:[e.jsx(T,{title:k.elasticemail.title,youTubeLink:k.elasticemail.link}),e.jsx("div",{className:"mt-3",children:e.jsx("b",{children:n("Integration Name:")})}),e.jsx("input",{className:"btcd-paper-inp w-6 mt-1",onChange:y,name:"name",value:t.name,type:"text",placeholder:n("Integration Name..."),disabled:m}),e.jsx("div",{style:{color:"red",fontSize:"15px"},children:h.name}),e.jsx("div",{className:"mt-3",children:e.jsx("b",{children:n("API Key:")})}),e.jsx("input",{className:"btcd-paper-inp w-6 mt-1",onChange:y,name:"api_key",value:t.api_key,type:"text",placeholder:n("API Key..."),disabled:m}),e.jsx("div",{style:{color:"red",fontSize:"15px"},children:h.api_key}),e.jsxs("small",{className:"d-blk mt-5",children:[n("To get API Key, Please Visit")," ",e.jsx("a",{className:"btcd-link",href:"https://app.elasticemail.com/marketing/settings/new/manage-api",target:"_blank",rel:"noreferrer",children:n("Elastic Email API Console")})]}),p==="auth"&&e.jsxs("div",{className:"flx mt-5",children:[e.jsx(S,{size:25,clr:"#022217",className:"mr-2"}),"Checking API Key!!!"]}),A&&!o.authorized&&!p&&e.jsxs("div",{className:"flx mt-5",style:{color:"red"},children:[e.jsx(K,{size:"15",className:_({mr:10})})," ",o.errorMsg||"Couldn't authorize, Please check API Key"]}),!m&&e.jsxs(e.Fragment,{children:[e.jsx(B,{isAuthorized:o.authorized,isLoading:p,handleAuthorize:()=>I()}),e.jsx("br",{}),e.jsx(F,{nextPageHandler:()=>f(),disabled:!o.authorized})]})]})}export{U as default};
