",{id:"rmenu","data-emoteid":$(r).prop("title"),text:"Remove",class:"context-menu theme-dark"});return o.css({top:a.pageY-$("#bda-qem-favourite-container").offset().top,left:a.pageX-$("#bda-qem-favourite-container").offset().left}),$(r).parent().append(o),o.on("click",function(d){return d.preventDefault(),d.stopPropagation(),$(this).remove(),delete quickEmoteMenu.favoriteEmotes[$(this).data("emoteid")],quickEmoteMenu.updateFavorites(),!1}),!1},QuickEmoteMenu.prototype.switchHandler=function(a){this.switchQem($(a).attr("id"))},QuickEmoteMenu.prototype.switchQem=function(a){var r=$("#bda-qem-twitch"),o=$("#bda-qem-favourite"),d=$("#bda-qem-emojis");r.removeClass("active"),o.removeClass("active"),d.removeClass("active"),$(".emojiPicker-3m1S-j").hide(),$("#bda-qem-favourite-container").hide(),$("#bda-qem-twitch-container").hide();"bda-qem-twitch"===a?(r.addClass("active"),$("#bda-qem-twitch-container").show()):"bda-qem-favourite"===a?(o.addClass("active"),$("#bda-qem-favourite-container").show()):"bda-qem-emojis"===a?(d.addClass("active"),$(".emojiPicker-3m1S-j").show(),$(".emojiPicker-3m1S-j .search-bar-inner input, .emojiPicker-3m1S-j .search-bar-inner input").focus()):void 0;this.lastTab=a;var l=$(".emote-icon");l.off(),l.on("click",function(){var u=$(this).attr("title"),h=utils.getTextArea();utils.insertText(h[0]," "==h.val().slice(-1)?h.val()+u:h.val()+" "+u)})},QuickEmoteMenu.prototype.obsCallback=function(a){var r=$(a);settingsCookie["bda-es-9"]?r.removeClass("bda-qme-hidden"):r.addClass("bda-qme-hidden");settingsCookie["bda-es-0"]&&(r.prepend(this.qmeHeader),r.append(this.teContainer),r.append(this.faContainer),this.lastTab==void 0&&(this.lastTab="bda-qem-favourite"),this.switchQem(this.lastTab))},QuickEmoteMenu.prototype.favorite=function(a,r){this.favoriteEmotes.hasOwnProperty(a)||(this.favoriteEmotes[a]=r),this.updateFavorites()},QuickEmoteMenu.prototype.updateFavorites=function(){var a="";for(var r in a+="
",this.faContainer=a,$("#bda-qem-favourite-container").replaceWith(a),window.bdStorage.set("bdfavemotes",btoa(JSON.stringify(this.favoriteEmotes)))};var _hash;function Utils(){}Utils.prototype.getTextArea=function(){return $(".channelTextArea-1LDbYG textarea")},Utils.prototype.insertText=function(a,r){a.focus(),a.selectionStart=0,a.selectionEnd=a.value.length,document.execCommand("insertText",!1,r)},Utils.prototype.jqDefer=function(a){window.jQuery?a():setTimeout(function(){this.jqDefer(a)},100)},Utils.prototype.getHash=function(){return new Promise(a=>{$.getJSON("https://api.github.com/repos/rauenzi/BetterDiscordApp/commits/master").done(function(r){_hash=r.sha,bdConfig.hash=_hash,a(_hash)}).fail(()=>{_hash=_bdhash||"48844445d65c6fb5a019eff14d7dcffcc1744071",a(_hash)})})},Utils.prototype.loadHtml=function(a,r){var o=$("
",{class:"bd-container"}).appendTo("body");a="//cdn.rawgit.com/Jiiks/BetterDiscordApp/"+_hash+"/html/"+a+".html",o.load(a,r())},Utils.prototype.injectJs=function(a){$("",{type:"text/javascript",src:a}).appendTo($("body"))},Utils.prototype.injectCss=function(a){$("
",{type:"text/css",rel:"stylesheet",href:a}).appendTo($("head"))},Utils.prototype.escapeID=function(a){return a.replace(/^[^a-z]+|[^\w-]+/gi,"")},Utils.prototype.log=function(a){console.log("%c[BetterDiscord] %c"+a+"","color: #3a71c1; font-weight: 700;","")},Utils.prototype.err=function(a,r){console.log("%c[BetterDiscord] %c"+a+"","color: red; font-weight: 700;",""),r&&(console.groupCollapsed("%cError: "+r.message,"color: red;"),console.error(r.stack),console.groupEnd())},Utils.prototype.escape=function(a){return a.replace(/[-/\\^$*+?.()|[\]{}]/g,"\\$&")},Utils.prototype.insertElement=function(a,r,o){for(var d=a.firstChild;d;){if(d.nodeType!=Node.TEXT_NODE){d=d.nextSibling;continue}var l=0;d.data.replace(r,function(u){var h=[].slice.call(arguments),g=h[h.length-2],b=h[1]?d.splitText(g+h[1].length+l):d.splitText(g+l);l-=d.data.length+u.length,b.data=b.data.substr(u.trim().length),d.parentNode.insertBefore(o,b),d=b}),r.lastIndex=0,d=d.nextSibling}return a},Utils.prototype.getTextNodes=function(a){var r=[];if(!a)return r;for(var d,o=0;o
(...o)=>{try{return a(...o)}catch(d){console.error("Error occurred in "+r,d)}},Utils.monkeyPatch=(a,r,o)=>{const{before:d,after:l,instead:u,once:h=!1,silent:g=!1,force:b=!1}=o,f=o.displayName||a.displayName||a.name||a.constructor.displayName||a.constructor.name;if(g||console.log("patch",r,"of",f),!a[r])if(b)a[r]=function(){};else return console.error(r,"does not exist for",f);const y=a[r],E=()=>{g||console.log("unpatch",r,"of",f),a[r]=y};return a[r]=function(){const C={thisObject:this,methodArguments:arguments,cancelPatch:E,originalMethod:y,callOriginalMethod:()=>C.returnValue=C.originalMethod.apply(C.thisObject,C.methodArguments)};if(u){const x=Utils.suppressErrors(u,"`instead` callback of "+a[r].displayName)(C);void 0!==x&&(C.returnValue=x)}else d&&Utils.suppressErrors(d,"`before` callback of "+a[r].displayName)(C),C.callOriginalMethod(),l&&Utils.suppressErrors(l,"`after` callback of "+a[r].displayName)(C);return h&&E(),C.returnValue},a[r].__monkeyPatched=!0,a[r].displayName="patched "+(a[r].displayName||r),E};function VoiceMode(){}VoiceMode.prototype.obsCallback=function(){var a=this;settingsCookie["bda-gs-4"]&&(a.disable(),setTimeout(function(){a.enable()},300))},VoiceMode.prototype.enable=function(){$(".scroller.guild-channels ul").first().css("display","none"),$(".scroller.guild-channels header").first().css("display","none"),$(".app.flex-vertical").first().css("overflow","hidden"),$(".chat.flex-vertical.flex-spacer").first().css("visibility","hidden").css("min-width","0px"),$(".flex-vertical.channels-wrap").first().css("flex-grow","100000"),$(".guild-header .btn.btn-hamburger").first().css("visibility","hidden")},VoiceMode.prototype.disable=function(){$(".scroller.guild-channels ul").first().css("display",""),$(".scroller.guild-channels header").first().css("display",""),$(".app.flex-vertical").first().css("overflow",""),$(".chat.flex-vertical.flex-spacer").first().css("visibility","").css("min-width",""),$(".flex-vertical.channels-wrap").first().css("flex-grow",""),$(".guild-header .btn.btn-hamburger").first().css("visibility","")};var pluginCookie={};function PluginModule(){}PluginModule.prototype.loadPlugins=function(){this.loadPluginData();for(var a=Object.keys(bdplugins),r=0;r",{id:utils.escapeID(o),html:unescape(bdthemes[o].css)}));for(let d in themeCookie)bdthemes[d]||delete themeCookie[d];this.saveThemeData()},ThemeModule.prototype.enableTheme=function(a){themeCookie[a]=!0,this.saveThemeData(),$("head").append(``),settingsCookie["fork-ps-2"]&&mainCore.showToast(`${bdthemes[a].name} v${bdthemes[a].version} has been applied.`)},ThemeModule.prototype.disableTheme=function(a){themeCookie[a]=!1,this.saveThemeData(),$(`#${utils.escapeID(bdthemes[a].name)}`).remove(),settingsCookie["fork-ps-2"]&&mainCore.showToast(`${bdthemes[a].name} v${bdthemes[a].version} has been removed.`)},ThemeModule.prototype.toggleTheme=function(a){themeCookie[a]?this.disableTheme(a):this.enableTheme(a)},ThemeModule.prototype.loadThemeData=function(){if($.cookie("bd-themes"))return themeCookie=JSON.parse($.cookie("bd-themes")),this.saveThemeData(),void $.removeCookie("bd-themes",{path:"/"});let a=bdSettingsStorage.get("themes");a&&(themeCookie=a)},ThemeModule.prototype.saveThemeData=function(){bdSettingsStorage.set("themes",themeCookie)};function BdApi(){}BdApi.injectCSS=function(a,r){$("head").append($(""),$("#customcss").html(this.editor.session.getValue()).detach().appendTo(document.head)}saveCss(){window.bdStorage.set("bdcustomcss",btoa(this.editor.session.getValue()))}}class V2C_CssEditor extends BDV2.reactComponent{constructor(a){super(a);let r=this;r.props.lines=0,r.setInitialState(),r.attach=r.attach.bind(r),r.detachedEditor=BDV2.react.createElement(V2C_CssEditorDetached,{attach:r.attach}),r.onClick=r.onClick.bind(r),r.updateCss=r.updateCss.bind(r),r.saveCss=r.saveCss.bind(r),r.detach=r.detach.bind(r)}setInitialState(){this.state={detached:this.props.detached||window.bdtemp.editorDetached}}componentDidMount(){this.editor=ace.edit("bd-customcss-editor"),this.editor.setTheme("ace/theme/monokai"),this.editor.session.setMode("ace/mode/css"),this.editor.setShowPrintMargin(!1),this.editor.setFontSize(14),this.editor.on("change",()=>{settingsCookie["bda-css-0"]&&(this.saveCss(),this.updateCss())})}componentWillUnmount(){this.editor.destroy()}componentDidUpdate(a,r){let o=this;r.detached&&!o.state.detached&&BDV2.reactDom.unmountComponentAtNode(o.detachedRoot)}codeMirror(){}get options(){return{lineNumbers:!0,mode:"css",indentUnit:4,theme:"material",scrollbarStyle:"simple"}}get css(){let a=window.bdStorage.get("bdcustomcss"),r="";return a&&""!==a&&(r=atob(a)),r}updateLineCount(){let a=this.refs.editor.value.split("\n").length;a==this.props.lines||(this.refs.lines.textContent=Array.from(Array(a),(r,o)=>o+1).join(".\n")+".",this.props.lines=a)}render(){let a=this,{detached:r}=a.state;return BDV2.react.createElement("div",{className:"content-column default",style:{padding:"60px 40px 0px"}},r&&BDV2.react.createElement("div",{id:"editor-detached"},BDV2.react.createElement(V2Components.SettingsTitle,{text:"Custom CSS Editor"}),BDV2.react.createElement("h3",null,"Editor Detached"),BDV2.react.createElement("button",{className:"btn btn-primary",onClick:()=>{a.attach()}},"Attach")),!r&&BDV2.react.createElement("div",null,BDV2.react.createElement(V2Components.SettingsTitle,{text:"Custom CSS Editor"}),BDV2.react.createElement("div",{className:"editor-wrapper"},BDV2.react.createElement("div",{id:"bd-customcss-editor",className:"editor",ref:"editor"},a.css)),BDV2.react.createElement("div",{id:"bd-customcss-attach-controls"},BDV2.react.createElement("ul",{className:"checkbox-group"},BDV2.react.createElement(V2Components.Checkbox,{id:"live-update",text:"Live Update",onChange:this.onChange,checked:settingsCookie["bda-css-0"]})),BDV2.react.createElement("div",{id:"bd-customcss-detach-controls-button"},BDV2.react.createElement("button",{style:{borderRadius:"3px 0 0 3px",borderRight:"1px solid #3f4146"},className:"btn btn-primary",onClick:()=>{a.onClick("update")}},"Update"),BDV2.react.createElement("button",{style:{borderRadius:"0",borderLeft:"1px solid #2d2d2d",borderRight:"1px solid #2d2d2d"},className:"btn btn-primary",onClick:()=>{a.onClick("save")}},"Save"),BDV2.react.createElement("button",{style:{borderRadius:"0 3px 3px 0",borderLeft:"1px solid #3f4146"},className:"btn btn-primary",onClick:()=>{a.onClick("detach")}},"Detach"),BDV2.react.createElement("span",{style:{fontSize:"10px",marginLeft:"5px"}},"Unsaved changes are lost on detach")))))}onClick(a){let r=this;"update"===a?r.updateCss():"save"===a?r.saveCss():"detach"===a?r.detach():void 0}onChange(a,r){"live-update"===a?(settingsCookie["bda-css-0"]=r,mainCore.saveSettings()):void 0}updateCss(){0==$("#customcss").length&&$("head").append(""),$("#customcss").html(this.editor.session.getValue()).detach().appendTo(document.head)}saveCss(){window.bdStorage.set("bdcustomcss",btoa(this.editor.session.getValue()))}detach(){let a=this;a.setState({detached:!0});let r=a.detachedRoot;return r?void BDV2.reactDom.render(a.detachedEditor,r):void console.log("FAILED TO INJECT ROOT: .app")}get detachedRoot(){let a=$("#bd-customcss-detach-container");return a.length?a[0]:this.injectDetachedRoot()?this.detachedRoot:null}injectDetachedRoot(){return!!$(".app").length&&($("",{id:"bd-customcss-detach-container"}).insertAfter($(".app")),!0)}attach(){let a=this;a.setState({detached:!1})}}class V2C_List extends BDV2.reactComponent{constructor(a){super(a)}render(){return BDV2.react.createElement("ul",{className:this.props.className},this.props.children)}}class V2C_ContentColumn extends BDV2.reactComponent{constructor(a){super(a)}render(){return BDV2.react.createElement("div",{className:"content-column default"},BDV2.react.createElement("h2",{className:"ui-form-title h2 margin-reset margin-bottom-20"},this.props.title),this.props.children)}}class V2C_PluginCard extends BDV2.reactComponent{constructor(a){super(a);let r=this;r.onChange=r.onChange.bind(r),r.showSettings=r.showSettings.bind(r),r.setInitialState(),r.hasSettings="function"==typeof r.props.plugin.getSettingsPanel,r.settingsPanel=""}setInitialState(){this.state={checked:pluginCookie[this.props.plugin.getName()],settings:!1}}componentDidUpdate(){if(this.state.settings){if("object"==typeof this.settingsPanel&&this.refs.settingspanel.appendChild(this.settingsPanel),!settingsCookie["fork-ps-3"])return;var a=(d,l)=>{let u=d.scrollTop,h=u+d.clientHeight,g=l.offsetTop,b=g+l.clientHeight;return gh};let r=$(BDV2.reactDom.findDOMNode(this)),o=r.parents(".scroller");if(!a(o[0],r[0]))return;o.animate({scrollTop:r.offset().top-o.offset().top+o.scrollTop()-30},300)}}render(){let a=this,{plugin:r}=this.props,o=r.getName(),d=r.getAuthor(),l=r.getDescription(),u=r.getVersion(),h=bdplugins[o].website,g=bdplugins[o].source;if(this.state.settings){try{a.settingsPanel=r.getSettingsPanel()}catch(b){utils.err("Unable to get settings panel for "+r.getName()+".",b)}return BDV2.react.createElement("li",{className:"settings-open ui-switch-item"},BDV2.react.createElement("div",{style:{float:"right",cursor:"pointer"},onClick:()=>{this.refs.settingspanel.innerHTML="",a.setState({settings:!1})}},BDV2.react.createElement(V2Components.XSvg,null)),"object"==typeof a.settingsPanel&&BDV2.react.createElement("div",{id:`plugin-settings-${o}`,className:"plugin-settings",ref:"settingspanel"}),"object"!=typeof a.settingsPanel&&BDV2.react.createElement("div",{id:`plugin-settings-${o}`,className:"plugin-settings",ref:"settingspanel",dangerouslySetInnerHTML:{__html:a.settingsPanel}}))}return BDV2.react.createElement("li",{"data-name":o,"data-version":u,className:"settings-closed ui-switch-item"},BDV2.react.createElement("div",{className:"bda-header"},BDV2.react.createElement("span",{className:"bda-header-title"},BDV2.react.createElement("span",{className:"bda-name"},o)," v",BDV2.react.createElement("span",{className:"bda-version"},u)," by ",BDV2.react.createElement("span",{className:"bda-author"},d)),BDV2.react.createElement("label",{className:"ui-switch-wrapper ui-flex-child",style:{flex:"0 0 auto"}},BDV2.react.createElement("input",{checked:this.state.checked,onChange:this.onChange,className:"ui-switch-checkbox",type:"checkbox"}),BDV2.react.createElement("div",{className:this.state.checked?"ui-switch checked":"ui-switch"}))),BDV2.react.createElement("div",{className:"bda-description-wrap scroller-wrap fade"},BDV2.react.createElement("div",{className:"bda-description scroller"},l)),(h||g||this.hasSettings)&&BDV2.react.createElement("div",{className:"bda-footer"},BDV2.react.createElement("span",{className:"bda-links"},h&&BDV2.react.createElement("a",{className:"bda-link bda-link-website",href:h,target:"_blank"},"Website"),h&&g&&" | ",g&&BDV2.react.createElement("a",{className:"bda-link bda-link-source",href:g,target:"_blank"},"Source")),this.hasSettings&&BDV2.react.createElement("button",{onClick:this.showSettings,className:"bda-settings-button",disabled:!this.state.checked},"Settings")))}onChange(){this.setState({checked:!this.state.checked}),pluginModule.togglePlugin(this.props.plugin.getName())}showSettings(){this.hasSettings&&this.setState({settings:!0})}}class V2C_ThemeCard extends BDV2.reactComponent{constructor(a){super(a),this.setInitialState(),this.onChange=this.onChange.bind(this)}setInitialState(){this.state={checked:themeCookie[this.props.theme.name]}}render(){let{theme:a}=this.props,r=a.name,o=a.description,d=a.version,l=a.author,u=bdthemes[r].website,h=bdthemes[r].source;return BDV2.react.createElement("li",{"data-name":r,"data-version":d,className:"settings-closed ui-switch-item"},BDV2.react.createElement("div",{className:"bda-header"},BDV2.react.createElement("span",{className:"bda-header-title"},BDV2.react.createElement("span",{className:"bda-name"},r)," v",BDV2.react.createElement("span",{className:"bda-version"},d)," by ",BDV2.react.createElement("span",{className:"bda-author"},l)),BDV2.react.createElement("label",{className:"ui-switch-wrapper ui-flex-child",style:{flex:"0 0 auto"}},BDV2.react.createElement("input",{checked:this.state.checked,onChange:this.onChange,className:"ui-switch-checkbox",type:"checkbox"}),BDV2.react.createElement("div",{className:this.state.checked?"ui-switch checked":"ui-switch"}))),BDV2.react.createElement("div",{className:"bda-description-wrap scroller-wrap fade"},BDV2.react.createElement("div",{className:"bda-description scroller"},o)),(u||h)&&BDV2.react.createElement("div",{className:"bda-footer"},BDV2.react.createElement("span",{className:"bda-links"},u&&BDV2.react.createElement("a",{className:"bda-link",href:u,target:"_blank"},"Website"),u&&h&&" | ",h&&BDV2.react.createElement("a",{className:"bda-link",href:h,target:"_blank"},"Source"))))}onChange(){this.setState({checked:!this.state.checked}),themeModule.toggleTheme(this.props.theme.name)}}class V2Cs_TabBar{static get Item(){return V2C_TabBarItem}static get Header(){return V2C_TabBarHeader}static get Separator(){return V2C_TabBarSeparator}}class V2Components{static get SettingsPanel(){return V2C_SettingsPanel}static get Switch(){return V2C_Switch}static get Scroller(){return V2C_Scroller}static get TabBar(){return V2Cs_TabBar}static get SideBar(){return V2C_SideBar}static get Tools(){return V2C_Tools}static get SettingsTitle(){return V2C_SettingsTitle}static get CssEditor(){return V2C_CssEditor}static get Checkbox(){return V2C_Checkbox}static get List(){return V2C_List}static get PluginCard(){return V2C_PluginCard}static get ThemeCard(){return V2C_ThemeCard}static get ContentColumn(){return V2C_ContentColumn}static get XSvg(){return V2C_XSvg}static get Layer(){return V2C_Layer}static get SidebarView(){return V2C_SidebarView}static get ServerCard(){return V2C_ServerCard}}class V2_SettingsPanel_Sidebar{constructor(a){this.onClick=a}get items(){return[{text:"Core",id:"core"},{text:"Zere's Fork",id:"fork"},{text:"Emotes",id:"emotes"},{text:"Custom CSS",id:"customcss"},{text:"Plugins",id:"plugins"},{text:"Themes",id:"themes"}]}get component(){return BDV2.react.createElement("span",null,BDV2.react.createElement(V2Components.SideBar,{onClick:this.onClick,headerText:"Bandaged BD",items:this.items}),BDV2.react.createElement("div",{style:{fontSize:"12px",fontWeight:"600",color:"#72767d",padding:"2px 10px"}},`BD v${bdVersion} by `,BDV2.react.createElement("a",{href:"https://github.com/Jiiks/",target:"_blank"},"Jiiks")),BDV2.react.createElement("div",{style:{fontSize:"12px",fontWeight:"600",color:"#72767d",padding:"2px 10px"}},`BBD v${bbdVersion} by `,BDV2.react.createElement("a",{href:"https://github.com/rauenzi/",target:"_blank"},"Zerebos")))}get root(){let a=$("#bd-settings-sidebar");return a.length?a[0]:this.injectRoot()?this.root:null}injectRoot(){let a=$("[class*='side-'] > [class*='item-']:not([class*=Danger])").last();return!!a.length&&($("",{id:"bd-settings-sidebar"}).insertBefore(a.prev()),!0)}render(){let a=this.root;return a?void BDV2.reactDom.render(this.component,a):void console.log("FAILED TO LOCATE ROOT: [class*='side-'] > [class*='item-']:not([class*=Danger])")}}class V2_SettingsPanel{constructor(){let a=this;a.sideBarOnClick=a.sideBarOnClick.bind(a),a.onChange=a.onChange.bind(a),a.updateSettings=this.updateSettings.bind(a),a.sidebar=new V2_SettingsPanel_Sidebar(a.sideBarOnClick)}get root(){let a=$("#bd-settingspane-container");return a.length?a[0]:this.injectRoot()?this.root:null}injectRoot(){return!!$(".layer-3QrUeG .ui-standard-sidebar-view, .layer-3QrUeG .ui-standard-sidebar-view").length&&($(".layer-3QrUeG .ui-standard-sidebar-view, .layer-3QrUeG .ui-standard-sidebar-view").append($("",{class:"content-region",id:"bd-settingspane-container"})),!0)}get coreSettings(){return this.getSettings("core")}get forkSettings(){return this.getSettings("fork")}get emoteSettings(){return this.getSettings("emote")}getSettings(a){return Object.keys(settings).reduce((r,o)=>{let d=settings[o];return d.cat===a&&d.implemented&&!d.hidden&&(d.text=o,r.push(d)),r},[])}sideBarOnClick(a){let r=this;$(".content-region").first().hide(),$(r.root).show();"core"===a?r.renderCoreSettings():"fork"===a?r.renderForkSettings():"emotes"===a?r.renderEmoteSettings():"customcss"===a?r.renderCustomCssEditor():"plugins"===a?r.renderPluginPane():"themes"===a?r.renderThemePane():void 0}onClick(){}onChange(a,r){settingsCookie[a]=r,this.updateSettings()}updateSettings(){let a=settingsCookie;a["bda-es-0"]?$("#twitchcord-button-container").show():$("#twitchcord-button-container").hide(),a["bda-gs-b"]?$("body").addClass("bd-blue"):$("body").removeClass("bd-blue"),a["bda-gs-2"]?$("body").addClass("bd-minimal"):$("body").removeClass("bd-minimal"),a["bda-gs-3"]?$("body").addClass("bd-minimal-chan"):$("body").removeClass("bd-minimal-chan"),a["bda-gs-1"]?$("#bd-pub-li").show():$("#bd-pub-li").hide(),a["bda-gs-4"]?voiceMode.enable():voiceMode.disable(),a["bda-gs-5"]?$("#app-mount").addClass("bda-dark"):$("#app-mount").removeClass("bda-dark"),a["bda-gs-6"]&&mainCore.inject24Hour(),a["bda-gs-7"]?mainCore.injectColoredText():mainCore.removeColoredText(),a["fork-ps-4"]?classNormalizer.start():classNormalizer.stop(),a["fork-es-2"]?$(".emote").each(()=>{$(this).addClass("stop-animation")}):$(".emote").each(()=>{$(this).removeClass("stop-animation")}),a["bda-gs-8"]?dMode.enable(a["fork-dm-1"]):dMode.disable(),mainCore.saveSettings()}renderSidebar(){let a=this;$("[class*='side-'] > [class*='item-']").off("click.v2settingspanel").on("click.v2settingspanel",()=>{BDV2.reactDom.unmountComponentAtNode(a.root),$(a.root).hide(),$(".content-region").first().show()}),a.sidebar.render()}get coreComponent(){return BDV2.react.createElement(V2Components.Scroller,{contentColumn:!0,fade:!0,dark:!0,children:[BDV2.react.createElement(V2Components.SettingsPanel,{key:"cspanel",title:"Core Settings",onChange:this.onChange,settings:this.coreSettings}),BDV2.react.createElement(V2Components.Tools,{key:"tools"})]})}get forkComponent(){return BDV2.react.createElement(V2Components.Scroller,{contentColumn:!0,fade:!0,dark:!0,children:[BDV2.react.createElement(V2Components.SettingsPanel,{key:"fspanel",title:"Zere's Fork Settings",onChange:this.onChange,settings:this.forkSettings,button:{title:"Clear Emote Cache",onClick:()=>{emoteModule.clearEmoteData(),emoteModule.init(),quickEmoteMenu.init()}}}),BDV2.react.createElement(V2Components.Tools,{key:"tools"})]})}get emoteComponent(){return BDV2.react.createElement(V2Components.Scroller,{contentColumn:!0,fade:!0,dark:!0,children:[BDV2.react.createElement(V2Components.SettingsPanel,{key:"espanel",title:"Emote Settings",onChange:this.onChange,settings:this.emoteSettings}),BDV2.react.createElement(V2Components.Tools,{key:"tools"})]})}get customCssComponent(){return BDV2.react.createElement(V2Components.Scroller,{contentColumn:!0,fade:!0,dark:!0,children:[BDV2.react.createElement(V2Components.CssEditor,{key:"csseditor"}),BDV2.react.createElement(V2Components.Tools,{key:"tools"})]})}get pluginsComponent(){let a=Object.keys(bdplugins).reduce((l,u)=>{return l.push(BDV2.react.createElement(V2Components.PluginCard,{key:u,plugin:bdplugins[u].plugin})),l},[]),r=BDV2.react.createElement(V2Components.List,{key:"plugin-list",className:"bda-slist",children:a}),o=BDV2.react.createElement("button",{key:"folder-button",className:"bd-pfbtn",onClick:()=>{betterDiscordIPC.send("asynchronous-message",{arg:"opendir",path:"plugindir"})}},"Open Plugin Folder"),d=BDV2.react.createElement(V2Components.ContentColumn,{key:"pcolumn",title:"Plugins",children:[o,r]});return BDV2.react.createElement(V2Components.Scroller,{contentColumn:!0,fade:!0,dark:!0,children:[d,BDV2.react.createElement(V2Components.Tools,{key:"tools"})]})}get themesComponent(){let a=Object.keys(bdthemes).reduce((l,u)=>{return l.push(BDV2.react.createElement(V2Components.ThemeCard,{key:u,theme:bdthemes[u]})),l},[]),r=BDV2.react.createElement(V2Components.List,{key:"theme-list",className:"bda-slist",children:a}),o=BDV2.react.createElement("button",{key:"folder-button",className:"bd-pfbtn",onClick:()=>{betterDiscordIPC.send("asynchronous-message",{arg:"opendir",path:"themedir"})}},"Open Theme Folder"),d=BDV2.react.createElement(V2Components.ContentColumn,{key:"tcolumn",title:"Themes",children:[o,r]});return BDV2.react.createElement(V2Components.Scroller,{contentColumn:!0,fade:!0,dark:!0,children:[d,BDV2.react.createElement(V2Components.Tools,{key:"tools"})]})}renderCoreSettings(){let a=this.root;return a?void BDV2.reactDom.render(this.coreComponent,a):void console.log("FAILED TO LOCATE ROOT: .layer .ui-standard-sidebar-view")}renderForkSettings(){let a=this.root;return a?void BDV2.reactDom.render(this.forkComponent,a):void console.log("FAILED TO LOCATE ROOT: .layer .ui-standard-sidebar-view")}renderEmoteSettings(){let a=this.root;return a?void BDV2.reactDom.render(this.emoteComponent,a):void console.log("FAILED TO LOCATE ROOT: .layer .ui-standard-sidebar-view")}renderCustomCssEditor(){let a=this.root;return a?void BDV2.reactDom.render(this.customCssComponent,a):void console.log("FAILED TO LOCATE ROOT: .layer .ui-standard-sidebar-view")}renderPluginPane(){let a=this.root;return a?void BDV2.reactDom.render(this.pluginsComponent,a):void console.log("FAILED TO LOCATE ROOT: .layer .ui-standard-sidebar-view")}renderThemePane(){let a=this.root;return a?void BDV2.reactDom.render(this.themesComponent,a):void console.log("FAILED TO LOCATE ROOT: .layer .ui-standard-sidebar-view")}}class V2C_Layer extends BDV2.reactComponent{constructor(a){super(a)}componentDidMount(){$(window).on(`keyup.${this.props.id}`,a=>{27===a.which&&BDV2.reactDom.unmountComponentAtNode(this.refs.root.parentNode)}),$(`#${this.props.id}`).animate({opacity:1},{step:function(a){$(this).css("transform",`scale(${1.1-0.1*a}) translateZ(0px)`)},duration:200,done:()=>{$(`#${this.props.id}`).css("opacity","").css("transform","")}})}componentWillUnmount(){$(window).off(`keyup.${this.props.id}`),$(`#${this.props.id}`).animate({opacity:0},{step:function(a){$(this).css("transform",`scale(${1.1-0.1*a}) translateZ(0px)`)},duration:200,done:()=>{$(`#${this.props.rootId}`).remove()}}),$("[class*=\"layer-\"]").removeClass("publicServersOpen").animate({opacity:1},{step:function(a){$(this).css("transform",`scale(${0.07*a+0.93}) translateZ(0px)`)},duration:200,done:()=>{$("[class*=\"layer-\"]").css("opacity","").css("transform","")}})}componentWillMount(){$("[class*=\"layer-\"]").addClass("publicServersOpen").animate({opacity:0},{step:function(a){$(this).css("transform",`scale(${0.07*a+0.93}) translateZ(0px)`)},duration:200})}render(){return BDV2.react.createElement("div",{className:"layer bd-layer layer-3QrUeG",id:this.props.id,ref:"root",style:{opacity:0,transform:"scale(1.1) translateZ(0px)"}},this.props.children)}}class V2C_SidebarView extends BDV2.reactComponent{constructor(a){super(a)}render(){let{sidebar:a,content:r,tools:o}=this.props.children;return BDV2.react.createElement("div",{className:"ui-standard-sidebar-view"},BDV2.react.createElement("div",{className:"sidebar-region"},BDV2.react.createElement(V2Components.Scroller,{key:"sidebarScroller",ref:"sidebarScroller",sidebar:!0,fade:a.fade||!0,dark:a.dark||!0,children:a.component})),BDV2.react.createElement("div",{className:"content-region"},BDV2.react.createElement("div",{className:"content-transition-wrap"},BDV2.react.createElement("div",{className:"scrollerWrap-2lJEkd content-region-scroller-wrap scrollerThemed-2oenus themeGhost-28MSn0 scrollerTrack-1ZIpsv"},BDV2.react.createElement("div",{className:"scroller-2FKFPG content-region-scroller scroller",ref:"contentScroller"},BDV2.react.createElement("div",{className:"content-column default"},r.component),o.component)))))}}class V2_PublicServers{constructor(){}get component(){return BDV2.react.createElement(V2Components.Layer,{rootId:"pubslayerroot",id:"pubslayer",children:BDV2.react.createElement(V2C_PublicServers,{rootId:"pubslayerroot"})})}get root(){let a=document.getElementById("pubslayerroot");return a?a:this.injectRoot()?this.root:null}injectRoot(){return!!$(".layers, .layers-3iHuyZ").length&&($(".layers, .layers-3iHuyZ").append($("",{id:"pubslayerroot"})),!0)}render(){let a=this.root;return a?void BDV2.reactDom.render(this.component,a):void console.log("FAILED TO LOCATE ROOT: .layers")}get button(){let a=$("",{class:BDV2.guildClasses.guild,id:"bd-pub-li",css:{height:"20px",display:settingsCookie["bda-gs-1"]?"":"none"}}).append($("",{class:BDV2.guildClasses.guildInner,css:{height:"20px","border-radius":"4px"}}).append($("",{}).append($("",{text:"public",id:"bd-pub-button",css:{"line-height":"20px","font-size":"12px"},click:()=>{this.render()}}))));return a}initialize(){let a=$(`.${BDV2.guildClasses.guilds}>:first-child`);a.after(this.button)}}class V2C_ServerCard extends BDV2.reactComponent{constructor(a){super(a),this.props.server.iconUrl||(this.props.server.iconUrl=this.props.fallback),this.state={imageError:!1,joined:this.props.guildList.includes(this.props.server.identifier)}}render(){let{server:a}=this.props;return BDV2.react.createElement("div",{className:`card-3Qj_Yx cardPrimary-1Hv-to marginBottom8-AtZOdT bd-server-card${a.pinned?" bd-server-card-pinned":""}`},BDV2.react.createElement("img",{ref:"img",className:"bd-server-image",src:a.iconUrl,onError:this.handleError.bind(this)}),BDV2.react.createElement("div",{className:"flexChild-faoVW3 bd-server-content"},BDV2.react.createElement("div",{className:"flex-1xMQg5 flex-1O1GKY horizontal-1ae9ci horizontal-2EEEnY directionRow-3v3tfG noWrap-3jynv6 bd-server-header"},BDV2.react.createElement("h5",{className:"h5-18_1nd defaultColor-1_ajX0 margin-reset bd-server-name"},a.name),BDV2.react.createElement("h5",{className:"h5-18_1nd defaultColor-1_ajX0 margin-reset bd-server-member-count"},a.members," Members")),BDV2.react.createElement("div",{className:"flex-1xMQg5 flex-1O1GKY horizontal-1ae9ci horizontal-2EEEnY directionRow-3v3tfG noWrap-3jynv6"},BDV2.react.createElement("div",{className:"scrollerWrap-2lJEkd scrollerThemed-2oenus themeGhostHairline-DBD-2d scrollerFade-1Ijw5y bd-server-description-container"},BDV2.react.createElement("div",{className:"scroller-2FKFPG scroller bd-server-description"},a.description))),BDV2.react.createElement("div",{className:"flex-1xMQg5 flex-1O1GKY horizontal-1ae9ci horizontal-2EEEnY directionRow-3v3tfG noWrap-3jynv6 bd-server-footer"},BDV2.react.createElement("div",{className:"flexChild-faoVW3 bd-server-tags",style:{flex:"1 1 auto"}},a.categories.join(", ")),this.state.joined&&BDV2.react.createElement("button",{type:"button",className:"button-38aScr lookFilled-1Gx00P colorBrand-3pXr91 sizeMin-1mJd1x grow-q77ONN colorGreen-29iAKY",style:{minHeight:"12px",marginTop:"4px",backgroundColor:"#3ac15c"}},BDV2.react.createElement("div",{className:"ui-button-contents"},"Joined")),a.error&&BDV2.react.createElement("button",{type:"button",className:"button-38aScr lookFilled-1Gx00P colorBrand-3pXr91 sizeMin-1mJd1x grow-q77ONN disabled-9aF2ug",style:{minHeight:"12px",marginTop:"4px",backgroundColor:"#c13a3a"}},BDV2.react.createElement("div",{className:"ui-button-contents"},"Error")),!a.error&&!this.state.joined&&BDV2.react.createElement("button",{type:"button",className:"button-38aScr lookFilled-1Gx00P colorBrand-3pXr91 sizeMin-1mJd1x grow-q77ONN",style:{minHeight:"12px",marginTop:"4px"},onClick:()=>{this.join()}},BDV2.react.createElement("div",{className:"ui-button-contents"},"Join")))))}handleError(){this.props.server.iconUrl=this.props.fallback,this.setState({imageError:!0})}join(){this.props.join(this)}}class V2C_PublicServers extends BDV2.reactComponent{constructor(a){super(a),this.setInitialState(),this.close=this.close.bind(this),this.changeCategory=this.changeCategory.bind(this),this.search=this.search.bind(this),this.searchKeyDown=this.searchKeyDown.bind(this),this.checkConnection=this.checkConnection.bind(this),this.join=this.join.bind(this),this.connect=this.connect.bind(this),this.GuildStore=BDV2.WebpackModules.findByUniqueProperties(["getGuilds"]),this.AvatarDefaults=BDV2.WebpackModules.findByUniqueProperties(["getUserAvatarURL","DEFAULT_AVATARS"]),this.InviteActions=BDV2.WebpackModules.findByUniqueProperties(["acceptInvite"]),this.SortedGuildStore=BDV2.WebpackModules.findByUniqueProperties(["getSortedGuilds"])}componentDidMount(){this.checkConnection()}setInitialState(){this.state={selectedCategory:-1,title:"Loading...",loading:!0,servers:[],next:null,connection:{state:0,user:null}}}close(){BDV2.reactDom.unmountComponentAtNode(document.getElementById(this.props.rootId))}search(a,r){let o=this;$.ajax({method:"GET",url:`${o.endPoint}${a}${a?"&schema=new":"?schema=new"}`,success:d=>{let l=d.results.reduce((b,f)=>{return f.joined=!1,b.push(f),b},[]);r||(l=o.state.servers.concat(l));let h=d.size+d.from;d.next=`?from=${h}`,o.state.term&&(d.next+=`&term=${o.state.term}`),o.state.selectedCategory&&(d.next+=`&category=${o.categoryButtons[o.state.selectedCategory]}`),h>=d.total&&(h=d.total,d.next=null);let g=`Showing 1-${h} of ${d.total} results in ${o.categoryButtons[o.state.selectedCategory]}`;o.state.term&&(g+=` for ${o.state.term}`),o.setState({loading:!1,title:g,servers:l,next:d.next}),r&&(o.refs.sbv.refs.contentScroller.scrollTop=0)},error:()=>{o.setState({loading:!1,title:"Failed to load servers. Check console for details"})}})}join(a){return a.props.pinned?this.InviteActions.acceptInvite(a.props.invite_code):void $.ajax({method:"GET",url:`${this.joinEndPoint}/${a.props.server.identifier}`,headers:{Accept:"application/json;","Content-Type":"application/json;","x-discord-id":this.state.connection.user.id,"x-discord-token":this.state.connection.user.accessToken},crossDomain:!0,xhrFields:{withCredentials:!0},success:()=>{a.setState({joined:!0})}})}connect(){let a=this,r=a.windowOptions;r.x=Math.round(window.screenX+window.innerWidth/2-r.width/2),r.y=Math.round(window.screenY+window.innerHeight/2-r.height/2),a.joinWindow=new(window.require("electron").remote.BrowserWindow)(r);let o=window.location.hostname.split(".")[0],d=a.connectEndPoint+("canary"===o||"ptb"===o?`/${o}`:"")+"?betterDiscord";a.joinWindow.webContents.on("did-navigate",(l,u)=>{"https://join.discordservers.com/session"!=u||(a.joinWindow.close(),a.checkConnection())}),a.joinWindow.loadURL(d)}get windowOptions(){return{width:500,height:550,backgroundColor:"#282b30",show:!0,resizable:!1,maximizable:!1,minimizable:!1,alwaysOnTop:!0,frame:!1,center:!1}}get bdServer(){let r=this.SortedGuildStore.guildPositions,o=this.AvatarDefaults.DEFAULT_AVATARS;return BDV2.react.createElement(V2Components.ServerCard,{server:{name:"BetterDiscord",online:"7500+",members:"20000+",categories:["community","programming","support"],description:"Official BetterDiscord server for support etc",identifier:"86004744966914048",iconUrl:"https://cdn.discordapp.com/icons/86004744966914048/292e7f6bfff2b71dfd13e508a859aedd.webp",nativejoin:!0,invite_code:"0Tmfo5ZbORCRqbAd",pinned:!0},pinned:!0,join:this.join,guildList:r,fallback:o[Math.floor(5*Math.random())]})}get endPoint(){return"https://search.discordservers.com"}get joinEndPoint(){return"https://join.discordservers.com"}get connectEndPoint(){return"https://join.discordservers.com/connect"}checkConnection(){let a=this;try{$.ajax({method:"GET",url:`${a.joinEndPoint}/session`,headers:{Accept:"application/json;","Content-Type":"application/json;"},crossDomain:!0,xhrFields:{withCredentials:!0},success:r=>{a.setState({selectedCategory:0,connection:{state:2,user:r}}),a.search("",!0)},error:r=>{if(403===r.status||404===r.status)return void a.setState({title:"Not connected to discordservers.com!",loading:!0,selectedCategory:-1,connection:{state:1,user:null}})}})}catch(r){a.setState({title:"Not connected to discordservers.com!",loading:!0,selectedCategory:-1,connection:{state:1,user:null}})}}render(){return BDV2.react.createElement(V2Components.SidebarView,{ref:"sbv",children:this.component})}get component(){return{sidebar:{component:this.sidebar},content:{component:this.content},tools:{component:BDV2.react.createElement(V2Components.Tools,{key:"pt",ref:"tools",onClick:this.close})}}}get sidebar(){return BDV2.react.createElement("div",{className:"sidebar",key:"ps"},BDV2.react.createElement("div",{className:"ui-tab-bar SIDE"},BDV2.react.createElement("div",{className:"ui-tab-bar-header",style:{fontSize:"16px"}},"Public Servers"),BDV2.react.createElement(V2Components.TabBar.Separator,null),this.searchInput,BDV2.react.createElement(V2Components.TabBar.Separator,null),BDV2.react.createElement(V2Components.TabBar.Header,{text:"Categories"}),this.categoryButtons.map((a,r)=>{return BDV2.react.createElement(V2Components.TabBar.Item,{id:r,onClick:this.changeCategory,key:r,text:a,selected:this.state.selectedCategory===r})}),BDV2.react.createElement(V2Components.TabBar.Separator,null),this.footer,this.connection))}get searchInput(){return BDV2.react.createElement("div",{className:"ui-form-item"},BDV2.react.createElement("div",{className:"ui-text-input flex-vertical",style:{width:"172px",marginLeft:"10px"}},BDV2.react.createElement("input",{ref:"searchinput",onKeyDown:this.searchKeyDown,onChange:()=>{},type:"text",className:"input default",placeholder:"Search...",maxLength:"50"})))}searchKeyDown(a){let r=this;if(!(r.state.loading||13!==a.which)){r.setState({loading:!0,title:"Loading...",term:a.target.value});let o=`?term=${a.target.value}`;0!==r.state.selectedCategory&&(o+=`&category=${r.categoryButtons[r.state.selectedCategory]}`),r.search(o,!0)}}get categoryButtons(){return["All","FPS Games","MMO Games","Strategy Games","Sports Games","Puzzle Games","Retro Games","Party Games","Tabletop Games","Sandbox Games","Simulation Games","Community","Language","Programming","Other"]}changeCategory(a){let r=this;if(!r.state.loading)return r.refs.searchinput.value="",r.setState({loading:!0,selectedCategory:a,title:"Loading...",term:null}),0===a?void r.search("",!0):void r.search(`?category=${r.categoryButtons[a]}`,!0)}get content(){let a=this,r=this.SortedGuildStore.guildPositions,o=this.AvatarDefaults.DEFAULT_AVATARS;return 1===a.state.connection.state?a.notConnected:[BDV2.react.createElement("div",{ref:"content",key:"pc",className:"content-column default"},BDV2.react.createElement(V2Components.SettingsTitle,{text:a.state.title}),a.bdServer,a.state.servers.map(d=>{return BDV2.react.createElement(V2Components.ServerCard,{key:d.identifier,server:d,join:a.join,guildList:r,fallback:o[Math.floor(5*Math.random())]})}),a.state.next&&BDV2.react.createElement("button",{type:"button",onClick:()=>{a.state.loading||(a.setState({loading:!0}),a.search(a.state.next,!1))},className:"ui-button filled brand small grow",style:{width:"100%",marginTop:"10px",marginBottom:"10px"}},BDV2.react.createElement("div",{className:"ui-button-contents"},a.state.loading?"Loading":"Load More")),0