var w=Object.defineProperty;var b=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(b)for(var s of b(a))E.call(a,s)&&j(t,s,a[s]);return t};import{r as c,j as e,_ as o,L,aL as S,c as T}from"./main-40.js";import{t as f}from"./bf-892-199.js";import{T as P}from"./bf-679-136.js";import{A as B}from"./bf-541-403.js";import{N as F}from"./bf-504-404.js";import{r as K}from"./bf-361-384.js";/* empty css          */import"./bf-860-126.js";import"./bf-132-75.js";import"./bf-141-80.js";import"./bf-586-70.js";function V({telegramConf:t,setTelegramConf:a,step:s,setstep:A,setSnackbar:p,isInfo:d}){const[h,y]=c.useState(!1),[n,x]=c.useState({name:"",bot_api_key:"",apiError:""}),[z,N]=c.useState(!1),[u,g]=c.useState(!1),k=()=>{const r=l({},t);if(!r.name||!r.bot_api_key){x({name:r.name?"":o("Integration name cann't be empty"),bot_api_key:r.bot_api_key?"":o("API Key cann't be empty")});return}g("auth");const m={bot_api_key:r.bot_api_key};T(m,"bitforms_telegram_authorize").then(i=>{i!=null&&i.success?(y(!0),p({show:!0,msg:o("Authorized Successfully")})):(y(!1),x({apiError:i==null?void 0:i.data.description}),p({show:!0,msg:o("Authorized Filled")})),N(!0),g(!1)})},_=r=>{const m=l({},t),i=l({},n);i[r.target.name]="",m[r.target.name]=r.target.value,x(i),a(m)},v=()=>{setTimeout(()=>{document.getElementById("btcd-settings-wrp").scrollTop=0},300),K(t,a,g,p),A(2)};return e.jsxs(e.Fragment,{children:[e.jsx(P,{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:o("Integration Name:")})}),e.jsx("input",{className:"btcd-paper-inp w-6 mt-1",onChange:_,name:"name",value:t.name,type:"text",placeholder:o("Integration Name..."),disabled:d}),e.jsx("div",{style:{color:"red",fontSize:"15px",marginTop:"5px"},children:n.name}),e.jsx("div",{className:"mt-3",children:e.jsx("b",{children:o("Bot API Key:")})}),e.jsx("input",{className:"btcd-paper-inp w-6 mt-1",onChange:_,name:"bot_api_key",value:t.bot_api_key,type:"text",placeholder:o("Bot API Key..."),disabled:d}),e.jsx("div",{style:{color:"red",fontSize:"15px",marginTop:"5px"},children:n.bot_api_key}),u==="auth"&&e.jsxs("div",{className:"flx mt-5",children:[e.jsx(L,{size:25,clr:"#022217",className:"mr-2"}),"Checking API Key!!!"]}),z&&!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(S,{size:"15"})}),n.apiError]}),!d&&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{V as default};
