var P=Object.defineProperty;var j=Object.getOwnPropertySymbols;var C=Object.prototype.hasOwnProperty,E=Object.prototype.propertyIsEnumerable;var f=(i,a,s)=>a in i?P(i,a,{enumerable:!0,configurable:!0,writable:!0,value:s}):i[a]=s,c=(i,a)=>{for(var s in a||(a={}))C.call(a,s)&&f(i,s,a[s]);if(j)for(var s of j(a))E.call(a,s)&&f(i,s,a[s]);return i};import{_ as e,j as t,d as L,q as g}from"./main.2.8.1.js";import{d as u}from"./react-router-dom.9mCuUg3q.js";import{B as K}from"./BackIcn._kGL_vVw.js";import{z as A,a9 as B}from"./Note.BeM7sN-p.js";import{r as F}from"./LemlistCommonFunc.xDxHOpMN.js";import{t as G}from"./tutorialLinks.kMkIDzcD.js";import{T as N}from"./TutorialLink.BAFX--T3.js";import"./CopyIcn.3gZpHton.js";function V({lemlistConf:i,setLemlistConf:a,step:s,setstep:z,setSnackbar:_,isInfo:p,isLoading:l,setIsLoading:b}){const[d,v]=u.useState(!1),[h,x]=u.useState({name:"",api_key:""}),[T,w]=u.useState(!1),{lemlist:o}=G,S=()=>{const r=c({},i);if(!r.name||!r.api_key){x({name:r.name?"":e("Integration name can't be empty","bit-integrations"),api_key:r.api_key?"":e("Access Api Key can't be empty","bit-integrations")});return}b("auth");const m={api_key:r.api_key};L(m,"lemlist_authorize").then(n=>{if(n&&n.success){const k=c({},i);k.tokenDetails=n.data,a(k),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"));w(!0),b(!1)})},y=r=>{const m=c({},i),n=c({},h);n[r.target.name]="",m[r.target.name]=r.target.value,x(n),a(m)},I=()=>{setTimeout(()=>{document.getElementById("btcd-settings-wrp").scrollTop=0},300),F(i,a,b,_),z(2)},$=`
            <h4>${e("Get Api key","bit-integrations")}</h4>
            <ul>
                <li>${e("First go to your Lemlist dashboard.","bit-integrations")}</li>
                <li>${e('Click on the "Team Setting" from sidebar',"bit-integrations")}</li>
                <li>${e('Then Click "Integrations"',"bit-integrations")}</li>
                <li>${e('Then click "Api", Then click "Generate Api Key"',"bit-integrations")}</li>
            </ul>`;return t.jsxs("div",{className:"btcd-stp-page",style:{width:s===1&&900,height:s===1&&"auto"},children:[t.jsx(N,{title:"Lemlist",youTubeLink:o==null?void 0:o.youTubeLink}),t.jsx(N,{title:"Lemlist",docLink:o==null?void 0:o.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:y,name:"name",value:i.name,type:"text",placeholder:e("Integration Name...","bit-integrations"),disabled:p}),t.jsx("div",{style:{color:"red",fontSize:"15px"},children:h.name}),t.jsx("div",{className:"mt-3 wdt-250",children:t.jsx("b",{children:e("Access API Key:","bit-integrations")})}),t.jsx("input",{className:"btcd-paper-inp w-6 mt-1",onChange:y,name:"api_key",value:i.api_key,type:"text",placeholder:e("Access API Key...","bit-integrations"),disabled:p}),t.jsx("div",{style:{color:"red",fontSize:"15px"},children:h.api_key}),t.jsxs("small",{className:"d-blk mt-3",children:[e("To get API key, please visit","bit-integrations")," ",t.jsx("a",{className:"btcd-link",href:"https://api.lemlist.com/teams/tea_beEpCu2irsJfn3PJr/settings/integrations#api",target:"_blank",rel:"noreferrer",children:e("Lemlist API Token","bit-integrations")})]}),t.jsx("br",{}),t.jsx("br",{}),l==="auth"&&t.jsxs("div",{className:"flx mt-5",children:[t.jsx(A,{size:25,clr:"#022217",className:"mr-2"}),e("Checking API Key!!!","bit-integrations")]}),T&&!d&&!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:"×"}),e("Sorry, Api key is invalid","bit-integrations")]}),!p&&t.jsxs(t.Fragment,{children:[t.jsxs("button",{onClick:S,className:"btn btcd-btn-lg purple sh-sm flx",type:"button",disabled:d||l,children:[d?e("Authorized ✔","bit-integrations"):e("Authorize","bit-integrations"),l&&t.jsx(A,{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:!d,children:[e("Next","bit-integrations"),t.jsx(K,{className:"ml-1 rev-icn"})]})]}),t.jsx(B,{note:$})]})}export{V as default};
