var T=Object.defineProperty;var f=Object.getOwnPropertySymbols;var K=Object.prototype.hasOwnProperty,$=Object.prototype.propertyIsEnumerable;var N=(r,i,s)=>i in r?T(r,i,{enumerable:!0,configurable:!0,writable:!0,value:s}):r[i]=s,c=(r,i)=>{for(var s in i||(i={}))K.call(i,s)&&N(r,s,i[s]);if(f)for(var s of f(i))$.call(i,s)&&N(r,s,i[s]);return r};import{_ as e,j as t,b as E,q as g}from"./main.2.8.10.js";import{b as x}from"./react-router.DMwpH23k.js";import{B}from"./BackIcn.BFDZx8No.js";import{y as _,a9 as D}from"./Note.DalStCGz.js";import{r as F}from"./SendPulseCommonFunc.CT4Iq455.js";import{T as G}from"./TutorialLink.D6K_DiHL.js";import"./react-vendor.P7K3d6op.js";import"./CopyIcn.BnhKHfEP.js";function U({formID:r,sendPulseConf:i,setSendPulseConf:s,step:u,setstep:A,setSnackbar:S,isInfo:l,isLoading:o,setIsLoading:h}){const[d,v]=x.useState(!1),[m,j]=x.useState({name:"",client_secret:""}),[z,k]=x.useState(!1),w=()=>{const a=c({},i);if(!a.name||!a.client_secret){j({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}h("auth");const b={client_id:a.client_id,client_secret:a.client_secret};E(b,"sendPulse_authorize").then(n=>{if(n&&n.success){const y=c({},i);y.tokenDetails=n.data,s(y),v(!0),g.success(e("Authorized Successfully","bit-integrations"))}else n&&n.data&&n.data.data||!n.success&&typeof n.data=="string"?g.error(`${e("Authorization failed Cause:","bit-integrations")}${n.data.data||n.data}. ${e("please try again","bit-integrations")}`):g.error(e("Authorization failed. please try again","bit-integrations"));k(!0),h(!1)})},p=a=>{const b=c({},i),n=c({},m);n[a.target.name]="",b[a.target.name]=a.target.value,j(n),s(b)},C=()=>{setTimeout(()=>{document.getElementById("btcd-settings-wrp").scrollTop=0},300),F(i,s,h,S),A(2)},I=`
            <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:u===1&&900,height:u===1&&"auto"},children:[t.jsx(G,{linkKey:"sendPulse"}),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:p,name:"name",value:i.name,type:"text",placeholder:e("Integration Name...","bit-integrations"),disabled:l}),t.jsx("div",{style:{color:"red",fontSize:"15px"},children:m.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:p,name:"client_id",value:i.client_id,type:"text",placeholder:e("Access client ID...","bit-integrations"),disabled:l}),t.jsx("div",{style:{color:"red",fontSize:"15px"},children:m.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:p,name:"client_secret",value:i.client_secret,type:"text",placeholder:e("Access Client Secret Key...","bit-integrations"),disabled:l}),t.jsx("div",{style:{color:"red",fontSize:"15px"},children:m.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",{}),o==="auth"&&t.jsxs("div",{className:"flx mt-5",children:[t.jsx(_,{size:25,clr:"#022217",className:"mr-2"}),"Checking Client Secret Key!!!"]}),z&&!d&&!o&&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")]}),!l&&t.jsxs(t.Fragment,{children:[t.jsxs("button",{onClick:w,className:"btn btcd-btn-lg purple sh-sm flx",type:"button",disabled:d||o,children:[d?e("Authorized ✔","bit-integrations"):e("Authorize","bit-integrations"),o&&t.jsx(_,{size:20,clr:"#022217",className:"ml-2"})]}),t.jsx("br",{}),t.jsxs("button",{onClick:()=>C(),className:"btn f-right btcd-btn-lg purple sh-sm flx",type:"button",disabled:!d,children:[e("Next","bit-integrations"),t.jsx(B,{className:"ml-1 rev-icn"})]})]}),t.jsx(D,{note:I})]})}export{U as default};
