var w=Object.defineProperty;var _=Object.getOwnPropertySymbols;var I=Object.prototype.hasOwnProperty,E=Object.prototype.propertyIsEnumerable;var j=(t,a,s)=>a in t?w(t,a,{enumerable:!0,configurable:!0,writable:!0,value:s}):t[a]=s,l=(t,a)=>{for(var s in a||(a={}))I.call(a,s)&&j(t,s,a[s]);if(_)for(var s of _(a))E.call(a,s)&&j(t,s,a[s]);return t};import{r as c,j as e,_ as n,L as S,bs as L,c as P}from"./main-634.js";import{t as f}from"./bf-275-83.js";import{a5 as T,a6 as B}from"./bf-746-82.js";import{N as F}from"./bf-123-109.js";import{r as K}from"./bf-389-175.js";import"./bf-822-108.js";import"./bf-25-81.js";function D({telegramConf:t,setTelegramConf:a,step:s,setstep:z,setSnackbar:d,isInfo:p}){const[h,y]=c.useState(!1),[o,x]=c.useState({name:"",bot_api_key:"",apiError:""}),[A,N]=c.useState(!1),[u,g]=c.useState(!1),k=()=>{const i=l({},t);if(!i.name||!i.bot_api_key){x({name:i.name?"":n("Integration name cann't be empty"),bot_api_key:i.bot_api_key?"":n("API Key cann't be empty")});return}g("auth");const m={bot_api_key:i.bot_api_key};P(m,"bitforms_telegram_authorize").then(r=>{r!=null&&r.success?(y(!0),d({show:!0,msg:n("Authorized Successfully")})):(y(!1),x({apiError:r==null?void 0:r.data.description}),d({show:!0,msg:n("Authorized Filled")})),N(!0),g(!1)})},b=i=>{const m=l({},t),r=l({},o);r[i.target.name]="",m[i.target.name]=i.target.value,x(r),a(m)},v=()=>{setTimeout(()=>{document.getElementById("btcd-settings-wrp").scrollTop=0},300),K(t,a,g,d),z(2)};return e.jsxs(e.Fragment,{children:[e.jsx(T,{title:f.telegram.title,youTubeLink:f.telegram.link}),e.jsxs("div",{className:"btcd-stp-page",style:{width:s===1&&900,height:s===1&&"100%"},children:[e.jsx("div",{className:"mt-3",children:e.jsx("b",{children:n("Integration Name:")})}),e.jsx("input",{className:"btcd-paper-inp w-6 mt-1",onChange:b,name:"name",value:t.name,type:"text",placeholder:n("Integration Name..."),disabled:p}),e.jsx("div",{style:{color:"red",fontSize:"15px",marginTop:"5px"},children:o.name}),e.jsx("div",{className:"mt-3",children:e.jsx("b",{children:n("Bot API Key:")})}),e.jsx("input",{className:"btcd-paper-inp w-6 mt-1",onChange:b,name:"bot_api_key",value:t.bot_api_key,type:"text",placeholder:n("Bot API Key..."),disabled:p}),e.jsx("div",{style:{color:"red",fontSize:"15px",marginTop:"5px"},children:o.bot_api_key}),u==="auth"&&e.jsxs("div",{className:"flx mt-5",children:[e.jsx(S,{size:25,clr:"#022217",className:"mr-2"}),"Checking API Key!!!"]}),A&&!h&&!u&&e.jsxs("div",{className:"flx mt-5",style:{color:"red"},children:[e.jsx("span",{className:"mr-2",style:{fontSize:30,marginTop:-5},children:e.jsx(L,{size:"15"})}),o.apiError]}),!p&&e.jsxs(e.Fragment,{children:[e.jsx(B,{isAuthorized:h,isLoading:u,handleAuthorize:()=>k()}),e.jsx("br",{}),e.jsx(F,{nextPageHandler:()=>v(),disabled:!h})]})]})]})}export{D as default};
