var I=Object.defineProperty;var _=Object.getOwnPropertySymbols;var E=Object.prototype.hasOwnProperty,S=Object.prototype.propertyIsEnumerable;var f=(r,e,i)=>e in r?I(r,e,{enumerable:!0,configurable:!0,writable:!0,value:i}):r[e]=i,d=(r,e)=>{for(var i in e||(e={}))E.call(e,i)&&f(r,i,e[i]);if(_)for(var i of _(e))S.call(e,i)&&f(r,i,e[i]);return r};import{j as t,_ as s,b as T}from"./main.2.9.0.js";import{b as p}from"./react-router.DMwpH23k.js";import{B as P}from"./BackIcn._8Wofmn2.js";import{y as N}from"./Note.NSUdvR3c.js";import{r as B}from"./TelegramCommonFunc.D6FpaQ6s.js";import{T as K}from"./TutorialLink.CFG7bS5c.js";import"./react-vendor.P7K3d6op.js";import"./CopyIcn.CEA_lFLo.js";function H({formID:r,telegramConf:e,setTelegramConf:i,step:x,setstep:z,setSnackbar:b,isInfo:h}){const[o,y]=p.useState(!1),[c,g]=p.useState({name:"",bot_api_key:"",apiError:""}),[A,k]=p.useState(!1),[m,u]=p.useState(!1),v=()=>{const a=d({},e);if(!a.name||!a.bot_api_key){g({name:a.name?"":s("Integration name can't be empty","bit-integrations"),bot_api_key:a.bot_api_key?"":s("API Key can't be empty","bit-integrations")});return}u("auth");const l={bot_api_key:a.bot_api_key};T(l,"telegram_authorize").then(n=>{n!=null&&n.success?(y(!0),b({show:!0,msg:s("Authorized Successfully","bit-integrations")})):(y(!1),g({apiError:n==null?void 0:n.data.description}),b({show:!0,msg:s("Authorized Filled","bit-integrations")})),k(!0),u(!1)})},j=a=>{const l=d({},e),n=d({},c);n[a.target.name]="",l[a.target.name]=a.target.value,g(n),i(l)},w=()=>{setTimeout(()=>{document.getElementById("btcd-settings-wrp").scrollTop=0},300),B(e,i,u,b),z(2)};return t.jsxs("div",{className:"btcd-stp-page",style:{width:x===1&&900,height:x===1&&"auto"},children:[t.jsx(K,{linkKey:"telegram"}),t.jsx("div",{className:"mt-3",children:t.jsx("b",{children:s("Integration Name:","bit-integrations")})}),t.jsx("input",{className:"btcd-paper-inp w-6 mt-1",onChange:j,name:"name",value:e.name,type:"text",placeholder:s("Integration Name...","bit-integrations"),disabled:h}),t.jsx("div",{style:{color:"red",fontSize:"15px",marginTop:"5px"},children:c.name}),t.jsx("div",{className:"mt-3",children:t.jsx("b",{children:s("Bot API Key:","bit-integrations")})}),t.jsx("input",{className:"btcd-paper-inp w-6 mt-1",onChange:j,name:"bot_api_key",value:e.bot_api_key,type:"text",placeholder:s("Bot API Key...","bit-integrations"),disabled:h}),t.jsx("div",{style:{color:"red",fontSize:"15px",marginTop:"5px"},children:c.bot_api_key}),m==="auth"&&t.jsxs("div",{className:"flx mt-5",children:[t.jsx(N,{size:25,clr:"#022217",className:"mr-2"}),s("Checking API Key!!!","bit-integrations")]}),A&&!o&&!m&&t.jsxs("div",{className:"flx mt-5",style:{color:"red"},children:[t.jsx("span",{className:"btcd-icn mr-2",style:{fontSize:30,marginTop:-5},children:"×"}),c.apiError]}),!h&&t.jsxs(t.Fragment,{children:[t.jsxs("button",{onClick:v,className:"btn btcd-btn-lg purple sh-sm flx",type:"button",disabled:o||m,children:[o?s("Authorized ✔","bit-integrations"):s("Authorize","bit-integrations"),m&&t.jsx(N,{size:20,clr:"#022217",className:"ml-2"})]}),t.jsx("br",{}),t.jsxs("button",{onClick:()=>w(),className:"btn f-right btcd-btn-lg purple sh-sm flx",type:"button",disabled:!o,children:[s("Next","bit-integrations"),t.jsx(P,{className:"ml-1 rev-icn"})]})]})]})}export{H as default};
