var L=Object.defineProperty;var A=Object.getOwnPropertySymbols;var P=Object.prototype.hasOwnProperty,E=Object.prototype.propertyIsEnumerable;var k=(a,t,i)=>t in a?L(a,t,{enumerable:!0,configurable:!0,writable:!0,value:i}):a[t]=i,h=(a,t)=>{for(var i in t||(t={}))P.call(t,i)&&k(a,i,t[i]);if(A)for(var i of A(t))E.call(t,i)&&k(a,i,t[i]);return a};import{r as y,j as e}from"./main-333.js";import{B as K}from"./bi.429.767.js";import{_ as s,L as _,N as R,b as B}from"./bi.636.93.js";import{c as F,a as U}from"./bi.143.764.js";import{T as N,t as $}from"./bi.318.783.js";function O({formID:a,activeCampaingConf:t,setActiveCampaingConf:i,step:j,setstep:f,setSnackbar:b,isInfo:o,isLoading:c,setIsLoading:d}){const{activeCampaign:r}=$,[u,z]=y.useState(!1),[m,g]=y.useState({name:"",api_key:""}),[w,S]=y.useState(!1),I=()=>{const n=h({},t);if(!n.name||!n.api_key||!n.api_url){g({name:n.name?"":s("Integration name can't be empty","bit-integrations"),api_key:n.api_key?"":s("Access Api Key can't be empty","bit-integrations"),api_url:n.api_url?"":s("Access API URL can't be empty","bit-integrations")});return}d("auth");const p={api_key:n.api_key,api_url:n.api_url};B(p,"aCampaign_authorize").then(l=>{l!=null&&l.success&&(z(!0),b({show:!0,msg:s("Authorized Successfully","bit-integrations")})),S(!0),d(!1)})},x=n=>{const p=h({},t),l=h({},m);l[n.target.name]="",p[n.target.name]=n.target.value,g(l),i(p)},T=()=>{setTimeout(()=>{document.getElementById("btcd-settings-wrp").scrollTop=0},300),F(t,i,d,b),U(t,i,d,b),f(2)},v=`
            <h4>${s("Get api url and api key","bit-integrations")}</h4>
            <ul>
                <li>${s("First go to activeCampaign your dashboard.","bit-integrations")}</li>
                <li>${s("Click Settings, Then click Developer","bit-integrations")}"</li>
            </ul>`;return e.jsxs("div",{className:"btcd-stp-page",style:{width:j===1&&900,height:j===1&&"auto"},children:[(r==null?void 0:r.youTubeLink)&&e.jsx(N,{title:"ActiveCampaign",youTubeLink:r==null?void 0:r.youTubeLink}),(r==null?void 0:r.docLink)&&e.jsx(N,{title:"ActiveCampaign",docLink:r==null?void 0:r.docLink}),e.jsx("div",{className:"mt-3 wdt-200",children:e.jsx("b",{children:s("Integration Name:","bit-integrations")})}),e.jsx("input",{className:"btcd-paper-inp w-6 mt-1",onChange:x,name:"name",value:t.name,type:"text",placeholder:s("Integration Name...","bit-integrations"),disabled:o}),e.jsx("div",{style:{color:"red",fontSize:"15px"},children:m.name}),e.jsx("div",{className:"mt-3 wdt-200",children:e.jsx("b",{children:s("Access API URL:","bit-integrations")})}),e.jsx("input",{className:"btcd-paper-inp w-6 mt-1",onChange:x,name:"api_url",value:t.api_url,type:"text",placeholder:s("Access API URL...","bit-integrations"),disabled:o}),e.jsx("div",{style:{color:"red",fontSize:"15px"},children:m.api_url}),e.jsx("div",{className:"mt-3 wdt-200",children:e.jsx("b",{children:s("Access API Key:","bit-integrations")})}),e.jsx("input",{className:"btcd-paper-inp w-6 mt-1",onChange:x,name:"api_key",value:t.api_key,type:"text",placeholder:s("Access API Key...","bit-integrations"),disabled:o}),e.jsx("div",{style:{color:"red",fontSize:"15px"},children:m.api_key}),c==="auth"&&e.jsxs("div",{className:"flx mt-5",children:[e.jsx(_,{size:25,clr:"#022217",className:"mr-2"}),"Checking API Key!!!"]}),w&&!u&&!c&&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:I,className:"btn btcd-btn-lg purple sh-sm flx",type:"button",disabled:u||c,children:[u?s("Authorized ✔","bit-integrations"):s("Authorize","bit-integrations"),c&&e.jsx(_,{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:!u,children:[s("Next","bit-integrations"),e.jsx(K,{className:"ml-1 rev-icn"})]})]}),e.jsx(R,{note:v})]})}export{O as default};
