var $=Object.defineProperty;var N=Object.getOwnPropertySymbols;var E=Object.prototype.hasOwnProperty,B=Object.prototype.propertyIsEnumerable;var S=(r,i,n)=>i in r?$(r,i,{enumerable:!0,configurable:!0,writable:!0,value:n}):r[i]=n,l=(r,i)=>{for(var n in i||(i={}))E.call(i,n)&&S(r,n,i[n]);if(N)for(var n of N(i))B.call(i,n)&&S(r,n,i[n]);return r};import{_ as e,j as t,d as D,q as x}from"./main.2.8.1.js";import{d as u}from"./react-router-dom.9mCuUg3q.js";import{B as F}from"./BackIcn._kGL_vVw.js";import{z as _,a9 as L}from"./Note.BeM7sN-p.js";import{r as G}from"./SendPulseCommonFunc.C4cM2Iq2.js";import{t as M}from"./tutorialLinks.kMkIDzcD.js";import{T as A}from"./TutorialLink.BAFX--T3.js";import"./CopyIcn.3gZpHton.js";function W({formID:r,sendPulseConf:i,setSendPulseConf:n,step:j,setstep:k,setSnackbar:z,isInfo:o,isLoading:d,setIsLoading:p}){const[m,v]=u.useState(!1),[b,y]=u.useState({name:"",client_secret:""}),[w,C]=u.useState(!1),{sendPulse:c}=M,T=()=>{const a=l({},i);if(!a.name||!a.client_secret){y({name:a.name?"":e("Integration name can't be empty","bit-integrations"),client_id:a.client_id?"":e("Access Client Id can't be empty","bit-integrations"),client_secret:a.client_secret?"":e("Access Client Secret Key can't be empty","bit-integrations")});return}p("auth");const h={client_id:a.client_id,client_secret:a.client_secret};D(h,"sendPulse_authorize").then(s=>{if(s&&s.success){const f=l({},i);f.tokenDetails=s.data,n(f),v(!0),x.success(e("Authorized Successfully","bit-integrations"))}else s&&s.data&&s.data.data||!s.success&&typeof s.data=="string"?x.error(`${e("Authorization failed Cause:","bit-integrations")}${s.data.data||s.data}. ${e("please try again","bit-integrations")}`):x.error(e("Authorization failed. please try again","bit-integrations"));C(!0),p(!1)})},g=a=>{const h=l({},i),s=l({},b);s[a.target.name]="",h[a.target.name]=a.target.value,y(s),n(h)},I=()=>{setTimeout(()=>{document.getElementById("btcd-settings-wrp").scrollTop=0},300),G(i,n,p,z),k(2)},K=`
            <h4>${e("Get client id and client secret key","bit-integrations")}</h4>
            <ul>
                <li>${e("First go to your SendPulse dashboard.","bit-integrations")}</li>
                <li>${e('Click "Integrations", Then click "API Keys"',"bit-integrations")}</li>
            </ul>`;return t.jsxs("div",{className:"btcd-stp-page",style:{width:j===1&&900,height:j===1&&"auto"},children:[t.jsx(A,{title:"SendPulse",youTubeLink:c==null?void 0:c.youTubeLink}),t.jsx(A,{title:"SendPulse",docLink:c==null?void 0:c.docLink}),t.jsx("div",{className:"mt-3 wdt-200",children:t.jsx("b",{children:e("Integration Name:","bit-integrations")})}),t.jsx("input",{className:"btcd-paper-inp w-6 mt-1",onChange:g,name:"name",value:i.name,type:"text",placeholder:e("Integration Name...","bit-integrations"),disabled:o}),t.jsx("div",{style:{color:"red",fontSize:"15px"},children:b.name}),t.jsx("div",{className:"mt-3 wdt-200",children:t.jsx("b",{children:e("Access Client id:","bit-integrations")})}),t.jsx("input",{className:"btcd-paper-inp w-6 mt-1",onChange:g,name:"client_id",value:i.client_id,type:"text",placeholder:e("Access client ID...","bit-integrations"),disabled:o}),t.jsx("div",{style:{color:"red",fontSize:"15px"},children:b.client_id}),t.jsx("div",{className:"mt-3 wdt-250",children:t.jsx("b",{children:e("Access Client Secret Key:","bit-integrations")})}),t.jsx("input",{className:"btcd-paper-inp w-6 mt-1",onChange:g,name:"client_secret",value:i.client_secret,type:"text",placeholder:e("Access Client Secret Key...","bit-integrations"),disabled:o}),t.jsx("div",{style:{color:"red",fontSize:"15px"},children:b.client_secret}),t.jsxs("small",{className:"d-blk mt-3",children:[e("To Get Client Id and Client Secret Key, Please Visit","bit-integrations")," ",t.jsx("a",{className:"btcd-link",href:"https://login.sendpulse.com/settings/#api",target:"_blank",rel:"noreferrer",children:e("Send Pulse API Token","bit-integrations")})]}),t.jsx("br",{}),t.jsx("br",{}),d==="auth"&&t.jsxs("div",{className:"flx mt-5",children:[t.jsx(_,{size:25,clr:"#022217",className:"mr-2"}),"Checking Client Secret Key!!!"]}),w&&!m&&!d&&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:"×"}),e("Sorry, Client Secret key is invalid","bit-integrations")]}),!o&&t.jsxs(t.Fragment,{children:[t.jsxs("button",{onClick:T,className:"btn btcd-btn-lg purple sh-sm flx",type:"button",disabled:m||d,children:[m?e("Authorized ✔","bit-integrations"):e("Authorize","bit-integrations"),d&&t.jsx(_,{size:20,clr:"#022217",className:"ml-2"})]}),t.jsx("br",{}),t.jsxs("button",{onClick:()=>I(),className:"btn f-right btcd-btn-lg purple sh-sm flx",type:"button",disabled:!m,children:[e("Next","bit-integrations"),t.jsx(F,{className:"ml-1 rev-icn"})]})]}),t.jsx(L,{note:K})]})}export{W as default};
