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