var S=Object.defineProperty;var j=Object.getOwnPropertySymbols;var w=Object.prototype.hasOwnProperty,P=Object.prototype.propertyIsEnumerable;var f=(n,t,i)=>t in n?S(n,t,{enumerable:!0,configurable:!0,writable:!0,value:i}):n[t]=i,m=(n,t)=>{for(var i in t||(t={}))w.call(t,i)&&f(n,i,t[i]);if(j)for(var i of j(t))P.call(t,i)&&f(n,i,t[i]);return n};import{j as e,_ as s,b as E}from"./main.2.8.10.js";import{b as d}from"./react-router.DMwpH23k.js";import{B as T}from"./BackIcn.BFDZx8No.js";import{y as k}from"./Note.DalStCGz.js";import{r as K}from"./EnchargeCommonFunc.CY6U3Haz.js";import{T as L}from"./TutorialLink.D6K_DiHL.js";import"./react-vendor.P7K3d6op.js";import"./CopyIcn.BnhKHfEP.js";function G({formID:n,enchargeConf:t,setEnchargeConf:i,step:g,setstep:N,setSnackbar:u,isInfo:p}){const[o,A]=d.useState(!1),[h,x]=d.useState({name:"",api_key:""}),[_,z]=d.useState(!1),[l,b]=d.useState(!1),v=()=>{const a=m({},t);if(!a.name||!a.api_key){x({name:a.name?"":s("Integration name can't be empty","bit-integrations"),api_key:a.api_key?"":s("API Key can't be empty","bit-integrations")});return}b("auth");const c={api_key:a.api_key};E(c,"encharge_authorize").then(r=>{r!=null&&r.success&&(A(!0),u({show:!0,msg:s("Authorized Successfully","bit-integrations")})),z(!0),b(!1)})},y=a=>{const c=m({},t),r=m({},h);r[a.target.name]="",c[a.target.name]=a.target.value,x(r),i(c)},I=()=>{setTimeout(()=>{document.getElementById("btcd-settings-wrp").scrollTop=0},300),N(2),K(t,i,b,u)};return e.jsxs("div",{className:"btcd-stp-page",style:{width:g===1&&900,height:g===1&&"auto"},children:[e.jsx(L,{linkKey:"encharge"}),e.jsx("div",{className:"mt-3",children:e.jsx("b",{children:s("Integration Name:","bit-integrations")})}),e.jsx("input",{className:"btcd-paper-inp w-6 mt-1",onChange:y,name:"name",value:t.name,type:"text",placeholder:s("Integration Name...","bit-integrations"),disabled:p}),e.jsx("div",{style:{color:"red",fontSize:"15px"},children:h.name}),e.jsx("div",{className:"mt-3",children:e.jsx("b",{children:s("API Key:","bit-integrations")})}),e.jsx("input",{className:"btcd-paper-inp w-6 mt-1",onChange:y,name:"api_key",value:t.api_key,type:"text",placeholder:s("API key","bit-integrations"),disabled:p}),e.jsx("div",{style:{color:"red",fontSize:"15px"},children:h.api_key}),e.jsxs("small",{className:"d-blk mt-5",children:[s("To get API , Please Visit","bit-integrations")," ",e.jsx("a",{className:"btcd-link",href:"https://app.encharge.io/account/info",target:"_blank",rel:"noreferrer",children:s("Encharge API Console","bit-integrations")})]}),l==="auth"&&e.jsxs("div",{className:"flx mt-5",children:[e.jsx(k,{size:25,clr:"#022217",className:"mr-2"}),s("Checking API Key!!!","bit-integrations")]}),_&&!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:"×"}),s("Sorry, Api key is invalid","bit-integrations")]}),!p&&e.jsxs(e.Fragment,{children:[e.jsxs("button",{onClick:v,className:"btn btcd-btn-lg purple sh-sm flx",type:"button",disabled:o||l,children:[o?s("Authorized ✔","bit-integrations"):s("Authorize","bit-integrations"),l&&e.jsx(k,{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:!o,children:[s("Next","bit-integrations"),e.jsx(T,{className:"ml-1 rev-icn"})]})]})]})}export{G as default};
