var $=Object.defineProperty;var k=Object.getOwnPropertySymbols;var P=Object.prototype.hasOwnProperty,K=Object.prototype.propertyIsEnumerable;var A=(i,s,n)=>s in i?$(i,s,{enumerable:!0,configurable:!0,writable:!0,value:n}):i[s]=n,c=(i,s)=>{for(var n in s||(s={}))P.call(s,n)&&A(i,n,s[n]);if(k)for(var n of k(s))K.call(s,n)&&A(i,n,s[n]);return i};import{r as x,j as e}from"./main-333.js";import{_ as t,L as _,N as L,b as E,V as y}from"./bi.636.93.js";import{B}from"./bi.429.767.js";import{r as F}from"./bi.295.920.js";import{T as f,t as D}from"./bi.318.783.js";function J({campaignMonitorConf:i,setCampaignMonitorConf:s,step:n,setstep:N,setSnackbar:v,isInfo:o,isLoading:d,setIsLoading:p}){const[m,z]=x.useState(!1),[b,g]=x.useState({name:"",api_key:""}),[w,C]=x.useState(!1),{campaignMonitor:a}=D,S=()=>{const r=c({},i);if(!r.name||!r.client_id||!r.api_key){g({name:r.name?"":t("Integration name can't be empty","bit-integrations"),client_id:r.client_id?"":t("Client Id can't be empty","bit-integrations"),api_key:r.api_key?"":t("Access Api Key can't be empty","bit-integrations")});return}p("auth");const h={api_key:r.api_key,client_id:r.client_id};E(h,"campaign_monitor_authorize").then(l=>{if(l&&l.success){const j=c({},i);j.tokenDetails=l.data,s(j),z(!0),y.success(t("Authorized Successfully","bit-integrations"))}else l&&l.data||!l.success&&typeof l.data.Message=="string"?y.error(`${t("Authorization failed Cause:","bit-integrations")}${l.data.Message}. ${t("please try again","bit-integrations")}`):y.error(t("Authorization failed. please try again","bit-integrations"));C(!0),p(!1)})},u=r=>{const h=c({},i),l=c({},b);l[r.target.name]="",h[r.target.name]=r.target.value,g(l),s(h)},I=()=>{setTimeout(()=>{document.getElementById("btcd-settings-wrp").scrollTop=0},300),F(i,s,p,v),N(2)},T=`
            <h4>${t("Get Client Id & Api key","bit-integrations")}</h4>
            <ul>
                <li>${t("First go to your CampaignMonitor dashboard.","bit-integrations")}</li>
                <li>${t('Click on Your "Profile Image" at the top right',"bit-integrations")}</li>
                <li>${t('Click on the "Account Settings"',"bit-integrations")}</li>
                <li>${t('Then Click "API keys"',"bit-integrations")}</li>
            </ul>`;return e.jsxs("div",{className:"btcd-stp-page",style:{width:n===1&&900,height:n===1&&"auto"},children:[(a==null?void 0:a.youTubeLink)&&e.jsx(f,{title:"Campaign Monitor",youTubeLink:a==null?void 0:a.youTubeLink}),(a==null?void 0:a.docLink)&&e.jsx(f,{title:"Campaign Monitor",docLink:a==null?void 0:a.docLink}),e.jsx("div",{className:"mt-3 wdt-200",children:e.jsx("b",{children:t("Integration Name:","bit-integrations")})}),e.jsx("input",{className:"btcd-paper-inp w-6 mt-1",onChange:u,name:"name",value:i.name,type:"text",placeholder:t("Integration Name...","bit-integrations"),disabled:o}),e.jsx("div",{style:{color:"red",fontSize:"15px"},children:b.name}),e.jsx("div",{className:"mt-3 wdt-250",children:e.jsx("b",{children:t("Client id:","bit-integrations")})}),e.jsx("input",{className:"btcd-paper-inp w-6 mt-1",onChange:u,name:"client_id",value:i.client_id,type:"text",placeholder:t("client ID...","bit-integrations"),disabled:o}),e.jsx("div",{style:{color:"red",fontSize:"15px"},children:b.client_id}),e.jsx("div",{className:"mt-3 wdt-250",children:e.jsx("b",{children:t("Access API Key:","bit-integrations")})}),e.jsx("input",{className:"btcd-paper-inp w-6 mt-1",onChange:u,name:"api_key",value:i.api_key,type:"text",placeholder:t("Access API Key...","bit-integrations"),disabled:o}),e.jsx("div",{style:{color:"red",fontSize:"15px"},children:b.api_key}),e.jsxs("small",{className:"d-blk mt-3",children:[t("To Get Client Id & Api Key, Please Visit","bit-integrations")," ",e.jsx("a",{className:"btcd-link",href:"https://bitcode2.createsend.com/account/apikeys",target:"_blank",rel:"noreferrer",children:t("Campaign Monitor API Key","bit-integrations")})]}),e.jsx("br",{}),e.jsx("br",{}),d==="auth"&&e.jsxs("div",{className:"flx mt-5",children:[e.jsx(_,{size:25,clr:"#022217",className:"mr-2"}),"Checking Api Key!!!"]}),w&&!m&&!d&&e.jsxs("div",{className:"flx mt-5",style:{color:"red"},children:[e.jsx("span",{className:"btcd-icn mr-2",style:{fontSize:30,marginTop:-5},children:"×"}),"Sorry, Api key is invalid"]}),!o&&e.jsxs(e.Fragment,{children:[e.jsxs("button",{onClick:S,className:"btn btcd-btn-lg purple sh-sm flx",type:"button",disabled:m||d,children:[m?t("Authorized ✔","bit-integrations"):t("Authorize","bit-integrations"),d&&e.jsx(_,{size:20,clr:"#022217",className:"ml-2"})]}),e.jsx("br",{}),e.jsxs("button",{onClick:()=>I(),className:"btn f-right btcd-btn-lg purple sh-sm flx",type:"button",disabled:!m,children:[t("Next","bit-integrations"),e.jsx(B,{className:"ml-1 rev-icn"})]})]}),e.jsx(L,{note:T})]})}export{J as default};
