var C=Object.defineProperty;var A=Object.getOwnPropertySymbols;var v=Object.prototype.hasOwnProperty,E=Object.prototype.propertyIsEnumerable;var f=(r,s,a)=>s in r?C(r,s,{enumerable:!0,configurable:!0,writable:!0,value:a}):r[s]=a,d=(r,s)=>{for(var a in s||(s={}))v.call(s,a)&&f(r,a,s[a]);if(A)for(var a of A(s))E.call(s,a)&&f(r,a,s[a]);return r};import{r as b,j as e}from"./main-406.js";import{B as L}from"./bi.46.744.js";import{_ as i,L as k,N as F,b as B}from"./bi.394.85.js";import{a as G}from"./bi.696.855.js";import{T as N,t as M}from"./bi.150.760.js";function O({formID:r,convertKitConf:s,setConvertKitConf:a,step:x,setstep:S,setSnackbar:g,isInfo:h,isLoading:l,setIsLoading:u}){const{convertKit:t}=M,[o,_]=b.useState(!1),[p,j]=b.useState({name:"",api_secret:""}),[z,w]=b.useState(!1),I=()=>{const n=d({},s);if(!n.name||!n.api_secret){j({name:n.name?"":i("Integration name cann't be empty","bit-integrations"),api_secret:n.api_secret?"":i("Access API Secret Key cann't be empty","bit-integrations")});return}u("auth");const m={api_secret:n.api_secret};B(m,"convertKit_authorize").then(c=>{c!=null&&c.success&&(_(!0),g({show:!0,msg:i("Authorized Successfully","bit-integrations")})),w(!0),u(!1)})},y=n=>{const m=d({},s),c=d({},p);c[n.target.name]="",m[n.target.name]=n.target.value,j(c),a(m)},T=()=>{setTimeout(()=>{document.getElementById("btcd-settings-wrp").scrollTop=0},300),G(s,a,u,g),S(2)},P=`
            <h4>Get api secret key</h4>
            <ul>
                <li>First go to your ConvertKit dashboard.</li>
                <li>Click "Settings", Then click "Advanced"</li>
            </ul>`;return e.jsxs("div",{className:"btcd-stp-page",style:{width:x===1&&900,height:x===1&&"auto"},children:[(t==null?void 0:t.youTubeLink)&&e.jsx(N,{title:t==null?void 0:t.title,youTubeLink:t==null?void 0:t.youTubeLink}),(t==null?void 0:t.docLink)&&e.jsx(N,{title:t==null?void 0:t.title,docLink:t==null?void 0:t.docLink}),e.jsx("div",{className:"mt-3 wdt-200",children:e.jsx("b",{children:i("Integration Name:","bit-integrations")})}),e.jsx("input",{className:"btcd-paper-inp w-6 mt-1",onChange:y,name:"name",value:s.name,type:"text",placeholder:i("Integration Name...","bit-integrations"),disabled:h}),e.jsx("div",{style:{color:"red",fontSize:"15px"},children:p.name}),e.jsx("div",{className:"mt-3 wdt-200",children:e.jsx("b",{children:i("Access API Secret Key:","bit-integrations")})}),e.jsx("input",{className:"btcd-paper-inp w-6 mt-1",onChange:y,name:"api_secret",value:s.api_secret,type:"text",placeholder:i("Access API Secret Key...","bit-integrations"),disabled:h}),e.jsx("div",{style:{color:"red",fontSize:"15px"},children:p.api_secret}),e.jsxs("small",{className:"d-blk mt-3",children:[i("To Get API Secret Key, Please Visit","bit-integrations")," ",e.jsx("a",{className:"btcd-link",href:"https://app.convertkit.com/account_settings/advanced_settings",target:"_blank",rel:"noreferrer",children:i("ConvertKit API Token","bit-integrations")})]}),e.jsx("br",{}),e.jsx("br",{}),l==="auth"&&e.jsxs("div",{className:"flx mt-5",children:[e.jsx(k,{size:25,clr:"#022217",className:"mr-2"}),"Checking API Secret Key!!!"]}),z&&!o&&!l&&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 Secret key is invalid"]}),!h&&e.jsxs(e.Fragment,{children:[e.jsxs("button",{onClick:I,className:"btn btcd-btn-lg purple sh-sm flx",type:"button",disabled:o||l,children:[o?i("Authorized ✔","bit-integrations"):i("Authorize","bit-integrations"),l&&e.jsx(k,{size:20,clr:"#022217",className:"ml-2"})]}),e.jsx("br",{}),e.jsxs("button",{onClick:()=>T(),className:"btn f-right btcd-btn-lg purple sh-sm flx",type:"button",disabled:!o,children:[i("Next","bit-integrations"),e.jsx(L,{className:"ml-1 rev-icn"})]})]}),e.jsx(F,{note:P})]})}export{O as default};
