var L=Object.defineProperty;var y=Object.getOwnPropertySymbols;var E=Object.prototype.hasOwnProperty,C=Object.prototype.propertyIsEnumerable;var N=(c,e,a)=>e in c?L(c,e,{enumerable:!0,configurable:!0,writable:!0,value:a}):c[e]=a,o=(c,e)=>{for(var a in e||(e={}))E.call(e,a)&&N(c,a,e[a]);if(y)for(var a of y(e))C.call(e,a)&&N(c,a,e[a]);return c};import{r as x,j as t}from"./main-406.js";import{_ as n,L as _,N as M,b as B,W as g}from"./bi.394.85.js";import{B as F}from"./bi.46.744.js";import{r as P}from"./bi.642.891.js";import{T as v,t as $}from"./bi.150.760.js";function J({formID:c,mailifyConf:e,setMailifyConf:a,step:A,setstep:z,setSnackbar:w,isInfo:l,isLoading:d,setIsLoading:m}){const{mailify:s}=$,[p,T]=x.useState(!1),[h,j]=x.useState({name:"",api_key:""}),[S,f]=x.useState(!1),I=()=>{const r=o({},e);if(!r.name||!r.api_key){j({name:r.name?"":n("Integration name cann't be empty","bit-integrations"),account_id:r.account_id?"":n("Access Account ID cann't be empty","bit-integrations"),api_key:r.api_key?"":n("Access Api Key cann't be empty","bit-integrations")});return}m("auth");const u={account_id:r.account_id,api_key:r.api_key};B(u,"mailify_authorize").then(i=>{if(i&&i.success){const k=o({},e);k.tokenDetails=i.data,a(k),T(!0),g.success(n("Authorized Successfully","bit-integrations"))}else i&&i.data&&i.data.data||!i.success&&typeof i.data=="string"?g.error(`${n("Authorization failed Cause:","bit-integrations")}${i.data.data||i.data}. ${n("please try again","bit-integrations")}`):g.error(n("Authorization failed. please try again","bit-integrations"));f(!0),m(!1)})},b=r=>{const u=o({},e),i=o({},h);i[r.target.name]="",u[r.target.name]=r.target.value,j(i),a(u)},D=()=>{setTimeout(()=>{document.getElementById("btcd-settings-wrp").scrollTop=0},300),P(e,a,m,w),z(2)},K=`
            <h4>Get Account Id and Api key</h4>
            <ul>
                <li>First go to your Mailify dashboard.</li>
                <li>Click on the "Settings" from Top-Right corner dropdown</li>
                <li>Then Click "Developers", Then click "Add an Api Key"</li>
            </ul>`;return t.jsxs("div",{className:"btcd-stp-page",style:{width:A===1&&900,height:A===1&&"auto"},children:[(s==null?void 0:s.youTubeLink)&&t.jsx(v,{title:s==null?void 0:s.title,youTubeLink:s==null?void 0:s.youTubeLink}),(s==null?void 0:s.docLink)&&t.jsx(v,{title:s==null?void 0:s.title,docLink:s==null?void 0:s.docLink}),t.jsx("div",{className:"mt-3 wdt-200",children:t.jsx("b",{children:n("Integration Name:","bit-integrations")})}),t.jsx("input",{className:"btcd-paper-inp w-6 mt-1",onChange:b,name:"name",value:e.name,type:"text",placeholder:n("Integration Name...","bit-integrations"),disabled:l}),t.jsx("div",{style:{color:"red",fontSize:"15px"},children:h.name}),t.jsx("div",{className:"mt-3 wdt-200",children:t.jsx("b",{children:n("Access Account ID:","bit-integrations")})}),t.jsx("input",{className:"btcd-paper-inp w-6 mt-1",onChange:b,name:"account_id",value:e.account_id,type:"text",placeholder:n("Access Account ID...","bit-integrations"),disabled:l}),t.jsx("div",{style:{color:"red",fontSize:"15px"},children:h.account_id}),t.jsx("div",{className:"mt-3 wdt-250",children:t.jsx("b",{children:n("Access Api Key:","bit-integrations")})}),t.jsx("input",{className:"btcd-paper-inp w-6 mt-1",onChange:b,name:"api_key",value:e.api_key,type:"text",placeholder:n("Access Api Key...","bit-integrations"),disabled:l}),t.jsx("div",{style:{color:"red",fontSize:"15px"},children:h.api_key}),t.jsxs("small",{className:"d-blk mt-3",children:[n("To Get Account Id and Api Key, Please Visit","bit-integrations")," ",t.jsx("a",{className:"btcd-link",href:"https://app.mailify.com/#!/p/home",target:"_blank",rel:"noreferrer",children:n("Mailify API Token","bit-integrations")})]}),t.jsx("br",{}),t.jsx("br",{}),d==="auth"&&t.jsxs("div",{className:"flx mt-5",children:[t.jsx(_,{size:25,clr:"#022217",className:"mr-2"}),"Checking Api Key!!!"]}),S&&!p&&!d&&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:"×"}),"Sorry, Api key is invalid"]}),!l&&t.jsxs(t.Fragment,{children:[t.jsxs("button",{onClick:I,className:"btn btcd-btn-lg purple sh-sm flx",type:"button",disabled:p||d,children:[p?n("Authorized ✔","bit-integrations"):n("Authorize","bit-integrations"),d&&t.jsx(_,{size:20,clr:"#022217",className:"ml-2"})]}),t.jsx("br",{}),t.jsxs("button",{onClick:()=>D(),className:"btn f-right btcd-btn-lg purple sh-sm flx",type:"button",disabled:!p,children:[n("Next","bit-integrations"),t.jsx(F,{className:"ml-1 rev-icn"})]})]}),t.jsx(M,{note:K})]})}export{J as default};
