var I=Object.defineProperty;var j=Object.getOwnPropertySymbols;var w=Object.prototype.hasOwnProperty,T=Object.prototype.propertyIsEnumerable;var y=(t,s,a)=>s in t?I(t,s,{enumerable:!0,configurable:!0,writable:!0,value:a}):t[s]=a,u=(t,s)=>{for(var a in s||(s={}))w.call(s,a)&&y(t,a,s[a]);if(j)for(var a of j(s))T.call(s,a)&&y(t,a,s[a]);return t};import{r as b,j as e}from"./main-333.js";import{B as P}from"./bi.429.767.js";import{_ as i,L as k,b as f}from"./bi.636.93.js";import{T as _,t as E}from"./bi.318.783.js";function M({sendyConf:t,setSendyConf:s,step:a,setstep:N,isInfo:l}){const[c,S]=b.useState(!1),[o,x]=b.useState({name:"",api_key:""}),[v,L]=b.useState(!1),[m,g]=b.useState(!1),{sendy:n}=E,A=()=>{const r=u({},t);if(!r.name||!r.api_key){x({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 d={api_key:r.api_key,sendy_url:r.sendy_url};f(d,"sendy_authorize").then(p=>{p.success&&S(!0),L(!0),g(!1)})},h=r=>{const d=u({},t),p=u({},o);p[r.target.name]="",d[r.target.name]=r.target.value,x(p),s(d)},z=()=>{setTimeout(()=>{document.getElementById("btcd-settings-wrp").scrollTop=0},300),N(2)};return e.jsxs("div",{className:"btcd-stp-page",style:{width:a===1&&900,height:a===1&&"auto"},children:[(n==null?void 0:n.youTubeLink)&&e.jsx(_,{title:"Sendy",youTubeLink:n==null?void 0:n.youTubeLink}),(n==null?void 0:n.docLink)&&e.jsx(_,{title:"Sendy",docLink:n==null?void 0:n.docLink}),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:l}),e.jsx("div",{style:{color:"red",fontSize:"15px"},children:o.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:l}),e.jsx("div",{style:{color:"red",fontSize:"15px"},children:o.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:l}),e.jsx("div",{style:{color:"red",fontSize:"15px"},children:o.sendy_url}),m==="auth"&&e.jsxs("div",{className:"flx mt-5",children:[e.jsx(k,{size:25,clr:"#022217",className:"mr-2"}),"Checking API Key!!!"]}),v&&!c&&!m&&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"]}),!l&&e.jsxs(e.Fragment,{children:[e.jsxs("button",{onClick:A,className:"btn btcd-btn-lg purple sh-sm flx",type:"button",disabled:c||m,children:[c?i("Authorized ✔","bit-integrations"):i("Authorize","bit-integrations"),m&&e.jsx(k,{size:20,clr:"#022217",className:"ml-2"})]}),e.jsx("br",{}),e.jsxs("button",{onClick:()=>z(),className:"btn f-right btcd-btn-lg purple sh-sm flx",type:"button",disabled:!c,children:[i("Next","bit-integrations"),e.jsx(P,{className:"ml-1 rev-icn"})]})]})]})}export{M as default};
