var o=Object.defineProperty;var w=Object.getOwnPropertySymbols;var y=Object.prototype.hasOwnProperty,A=Object.prototype.propertyIsEnumerable;var N=(n,e,l)=>e in n?o(n,e,{enumerable:!0,configurable:!0,writable:!0,value:l}):n[e]=l,h=(n,e)=>{for(var l in e||(e={}))y.call(e,l)&&N(n,l,e[l]);if(w)for(var l of w(e))A.call(e,l)&&N(n,l,e[l]);return n};import{j as t,_ as m,L as M}from"./main.2.8.10.js";import{a as k,u}from"./CopyIcn.BnhKHfEP.js";import{b as $,e as B}from"./react-router.DMwpH23k.js";/* empty css                */import{b as R}from"./Table.DSsAy4VI.js";import{g as T,a as S}from"./DiscordCommonFunc.Dgxk7_Uh.js";function _({formFields:n,discordConf:e,setDiscordConf:l}){var x;const[r,c]=$.useState({show:!1}),j=s=>{const p=h({},e);s.target.value!==""?p.actions.attachments=s.target.value:delete p.actions.attachments,l(h({},p))};return t.jsxs("div",{className:"pos-rel",children:[t.jsx("div",{className:"d-flx flx-wrp",children:t.jsx(R,{onChange:()=>c({show:"attachments"}),checked:"attachments"in e.actions,className:"wdt-200 mt-4 mr-2",value:"Attachment",title:m("Attachments","bit-integrations"),subTitle:m("Add attachments from Bit Integrations to send Discord.","bit-integrations")})}),t.jsxs(k,{className:"custom-conf-mdl",mainMdlCls:"o-v",btnClass:"purple",btnTxt:"Ok",show:r.show==="attachments",close:()=>c({show:!1}),action:()=>c({show:!1}),title:m("Select Attachment","bit-integrations"),children:[t.jsx("div",{className:"btcd-hr mt-2"}),t.jsx("div",{className:"mt-2",children:m("Please select file upload fields","bit-integrations")}),t.jsxs("select",{onChange:s=>j(s),name:"attachments",value:(x=e.actions)==null?void 0:x.attachments,className:"btcd-paper-inp w-10 mt-2",children:[t.jsx("option",{value:"",children:m("Select file upload field","bit-integrations")}),n.filter(s=>s.type==="file").map(s=>t.jsx("option",{value:s.name,children:s.label},s.name+1))]})]})]})}function O({formFields:n,discordConf:e,setDiscordConf:l,isLoading:r,setIsLoading:c}){var v,g;const{id:j}=B(),x=a=>{const i=h({},e);i[a.target.name]=a.target.value,l(i)},s=(a,i)=>{const b=h({},e);b[i]=a,i==="selectedServer"&&(b.selectedServer!==""||b.selectedServer!==null)&&a&&(b.selectedChannel="",S(b,l,c)),l(h({},b))},p=a=>{const i=h({},e);i.body=a,l(i)};return t.jsxs(t.Fragment,{children:[t.jsx("br",{}),t.jsxs("div",{className:"flx",children:[t.jsx("b",{className:"wdt-200 d-in-b",children:m("Select Servers:","bit-integrations")}),t.jsx(u,{options:(v=e==null?void 0:e.servers)==null?void 0:v.map(a=>({label:a.name,value:a.id})),className:"msl-wrp-options dropdown-custom-width",defaultValue:e==null?void 0:e.selectedServer,onChange:a=>s(a,"selectedServer"),disabled:r.Servers,singleSelect:!0}),t.jsx("button",{onClick:()=>T(e,l,c),className:"icn-btn sh-sm ml-2 mr-2 tooltip",style:{"--tooltip-txt":`'${m("Refresh Server List","bit-integrations")}'`},type:"button",disabled:r.servers,children:"↻"})]}),t.jsx("br",{}),(e==null?void 0:e.selectedServer)&&t.jsx(t.Fragment,{children:t.jsxs("div",{className:"flx",children:[t.jsx("b",{className:"wdt-200 d-in-b",children:m("Select Channels:","bit-integrations")}),t.jsx(u,{options:(g=e==null?void 0:e.channels)==null?void 0:g.map(a=>({label:a.name,value:a.id})),className:"msl-wrp-options dropdown-custom-width",defaultValue:e==null?void 0:e.selectedChannel,onChange:a=>s(a,"selectedChannel"),disabled:r.Channels,singleSelect:!0}),t.jsx("button",{onClick:()=>S(e,l,c),className:"icn-btn sh-sm ml-2 mr-2 tooltip",style:{"--tooltip-txt":`'${m("Refresh Channel List","bit-integrations")}'`},type:"button",disabled:r.channels,children:"↻"})]})}),r&&t.jsx(M,{style:{display:"flex",justifyContent:"center",alignItems:"center",height:100,transform:"scale(0.7)"}}),(e==null?void 0:e.selectedChannel)&&(e==null?void 0:e.selectedServer)&&t.jsxs(t.Fragment,{children:[t.jsxs("div",{className:"flx mt-4",children:[t.jsx("b",{className:"wdt-200 d-in-b mr-16",children:m("Messages:","bit-integrations")}),t.jsx("textarea",{className:"w-7",onChange:x,name:"body",rows:"5",value:e.body}),t.jsx(u,{options:n.filter(a=>a.type!=="file").map(a=>({label:a.label,value:`\${${a.name}}`})),className:"btcd-paper-drpdwn wdt-600 ml-2",onChange:a=>p(a)})]}),t.jsx("div",{className:"mt-4",children:t.jsx("b",{className:"wdt-100",children:m("Utilities","bit-integrations")})}),t.jsx("div",{className:"btcd-hr mt-1"}),t.jsx(_,{discordConf:e,setDiscordConf:l,formFields:n})]})]})}export{O as D};
