var w=Object.defineProperty;var k=Object.getOwnPropertySymbols;var P=Object.prototype.hasOwnProperty,T=Object.prototype.propertyIsEnumerable;var f=(n,a,s)=>a in n?w(n,a,{enumerable:!0,configurable:!0,writable:!0,value:s}):n[a]=s,d=(n,a)=>{for(var s in a||(a={}))P.call(a,s)&&f(n,s,a[s]);if(k)for(var s of k(a))T.call(a,s)&&f(n,s,a[s]);return n};import{r as h,j as t}from"./main-406.js";import{B as E}from"./bi.46.744.js";import{_ as i,L as N,b as K}from"./bi.394.85.js";import{a as C}from"./bi.782.738.js";import{T as A,t as F}from"./bi.150.760.js";function H({formID:n,sendinBlueConf:a,setSendinBlueConf:s,step:x,setstep:v,setSnackbar:u,isInfo:p}){const[c,_]=h.useState(!1),[b,y]=h.useState({name:"",api_key:""}),[z,I]=h.useState(!1),[l,g]=h.useState(!1),{sendinBlue:e}=F,L=()=>{const r=d({},a);if(!r.name||!r.api_key){y({name:r.name?"":i("Integration name cann't be empty","bit-integrations"),api_key:r.api_key?"":i("API Key cann't be empty","bit-integrations")});return}g("auth");const m={api_key:r.api_key};K(m,"sblue_authorize").then(o=>{o!=null&&o.success&&(_(!0),u({show:!0,msg:i("Authorized Successfully","bit-integrations")})),I(!0),g(!1)})},j=r=>{const m=d({},a),o=d({},b);o[r.target.name]="",m[r.target.name]=r.target.value,y(o),s(m)},S=()=>{setTimeout(()=>{document.getElementById("btcd-settings-wrp").scrollTop=0},300),v(2),C(a,s,g,u)};return t.jsxs("div",{className:"btcd-stp-page",style:{width:x===1&&900,height:x===1&&"auto"},children:[(e==null?void 0:e.youTubeLink)&&t.jsx(A,{title:e==null?void 0:e.title,youTubeLink:e==null?void 0:e.youTubeLink}),(e==null?void 0:e.docLink)&&t.jsx(A,{title:e==null?void 0:e.title,docLink:e==null?void 0:e.docLink}),t.jsx("div",{className:"mt-3",children:t.jsx("b",{children:i("Integration Name:","bit-integrations")})}),t.jsx("input",{className:"btcd-paper-inp w-6 mt-1",onChange:j,name:"name",value:a.name,type:"text",placeholder:i("Integration Name...","bit-integrations"),disabled:p}),t.jsx("div",{style:{color:"red",fontSize:"15px"},children:b.name}),t.jsx("div",{className:"mt-3",children:t.jsx("b",{children:i("API Key:","bit-integrations")})}),t.jsx("input",{className:"btcd-paper-inp w-6 mt-1",onChange:j,name:"api_key",value:a.api_key,type:"text",placeholder:i("API Key...","bit-integrations"),disabled:p}),t.jsx("div",{style:{color:"red",fontSize:"15px"},children:b.api_key}),t.jsxs("small",{className:"d-blk mt-5",children:[i("To get API , Please Visit","bit-integrations")," ",t.jsx("a",{className:"btcd-link",href:"https://account.sendinblue.com/advanced/api",target:"_blank",rel:"noreferrer",children:i("Brevo(Sendinblue) API Console","bit-integrations")})]}),l==="auth"&&t.jsxs("div",{className:"flx mt-5",children:[t.jsx(N,{size:25,clr:"#022217",className:"mr-2"}),"Checking API Key!!!"]}),z&&!c&&!l&&t.jsxs("div",{className:"flx mt-5",style:{color:"red"},children:[t.jsx("span",{className:"btcd-icn mr-2",style:{fontSize:30,marginTop:-5},children:"×"}),"Sorry, API key is invalid"]}),!p&&t.jsxs(t.Fragment,{children:[t.jsxs("button",{onClick:L,className:"btn btcd-btn-lg purple sh-sm flx",type:"button",disabled:c||l,children:[c?i("Authorized ✔","bit-integrations"):i("Authorize","bit-integrations"),l&&t.jsx(N,{size:20,clr:"#022217",className:"ml-2"})]}),t.jsx("br",{}),t.jsxs("button",{onClick:()=>S(),className:"btn f-right btcd-btn-lg purple sh-sm flx",type:"button",disabled:!c,children:[i("Next","bit-integrations"),t.jsx(E,{className:"ml-1 rev-icn"})]})]})]})}export{H as default};
