BetterDiscordApp-rauenzi/js/main.min.js

1 line
116 KiB
JavaScript

var Core=function(e){var t={};function s(n){if(t[n])return t[n].exports;var o=t[n]={i:n,l:!1,exports:{}};return e[n].call(o.exports,o,o.exports,s),o.l=!0,o.exports}return s.m=e,s.c=t,s.d=function(e,t,n){s.o(e,t)||Object.defineProperty(e,t,{enumerable:!0,get:n})},s.r=function(e){"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(e,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(e,"__esModule",{value:!0})},s.t=function(e,t){if(1&t&&(e=s(e)),8&t)return e;if(4&t&&"object"==typeof e&&e&&e.__esModule)return e;var n=Object.create(null);if(s.r(n),Object.defineProperty(n,"default",{enumerable:!0,value:e}),2&t&&"string"!=typeof e)for(var o in e)s.d(n,o,function(t){return e[t]}.bind(null,o));return n},s.n=function(e){var t=e&&e.__esModule?function(){return e.default}:function(){return e};return s.d(t,"a",t),t},s.o=function(e,t){return Object.prototype.hasOwnProperty.call(e,t)},s.p="",s(s.s=6)}([function(e,t){e.exports=require("fs")},function(e,t){e.exports=require("electron")},function(e,t){e.exports=require("path")},function(e,t){e.exports=require("module")},function(e,t){e.exports=require("events")},function(e,t){e.exports=require("request")},function(e,t,s){"use strict";s.r(t);var n={};s.r(n),s.d(n,"Menu",function(){return Ne}),s.d(n,"Card",function(){return De}),s.d(n,"Layer",function(){return Me});var o={};s.r(o),s.d(o,"VoiceMode",function(){return Ae}),s.d(o,"ClassNormalizer",function(){return Ge}),s.d(o,"DeveloperMode",function(){return Ve}),s.d(o,"PublicServers",function(){return Ue}),s.d(o,"DarkMode",function(){return ze}),s.d(o,"MinimalMode",function(){return He}),s.d(o,"TwentyFourHour",function(){return We}),s.d(o,"ColoredText",function(){return _e}),s.d(o,"VoiceDisconnect",function(){return Je}),s.d(o,"EmoteMenu",function(){return Ze}),s.d(o,"EmoteAutocaps",function(){return Ke}),s.d(o,"EmoteModule",function(){return et});var r={emotesLoaded:!1},i={"Custom css live update":{id:"bda-css-0",info:"",implemented:!0,hidden:!0,cat:"core"},"Custom css auto udpate":{id:"bda-css-1",info:"",implemented:!0,hidden:!0,cat:"core"},"BetterDiscord Blue":{id:"bda-gs-b",info:"Replace Discord blue with BD Blue",implemented:!1,hidden:!1,cat:"core"},"Public Servers":{id:"bda-gs-1",info:"Display public servers button",implemented:!0,hidden:!1,cat:"core",category:"modules"},"Minimal Mode":{id:"bda-gs-2",info:"Hide elements and reduce the size of elements.",implemented:!0,hidden:!1,cat:"core",category:"modules"},"Voice Mode":{id:"bda-gs-4",info:"Only show voice chat",implemented:!0,hidden:!1,cat:"core",category:"modules"},"Hide Channels":{id:"bda-gs-3",info:"Hide channels in minimal mode",implemented:!0,hidden:!1,cat:"core",category:"modules"},"Dark Mode":{id:"bda-gs-5",info:"Make certain elements dark by default(wip)",implemented:!0,hidden:!1,cat:"core",category:"modules"},"Voice Disconnect":{id:"bda-dc-0",info:"Disconnect from voice server when closing Discord",implemented:!0,hidden:!1,cat:"core",category:"modules"},"24 Hour Timestamps":{id:"bda-gs-6",info:"Replace 12hr timestamps with proper ones",implemented:!0,hidden:!1,cat:"core",category:"modules"},"Coloured Text":{id:"bda-gs-7",info:"Make text colour the same as role colour",implemented:!0,hidden:!1,cat:"core",category:"modules"},"Normalize Classes":{id:"fork-ps-4",info:"Adds stable classes to elements to help themes. (e.g. adds .da-channels to .channels-Ie2l6A)",implemented:!0,hidden:!1,cat:"core",category:"modules"},"Content Error Modal":{id:"fork-ps-1",info:"Shows a modal with plugin/theme errors",implemented:!0,hidden:!1,cat:"core",category:"content manager"},"Show Toasts":{id:"fork-ps-2",info:"Shows a small notification for important information",implemented:!0,hidden:!1,cat:"core",category:"content manager"},"Scroll To Settings":{id:"fork-ps-3",info:"Auto-scrolls to a plugin's settings when the button is clicked (only if out of view)",implemented:!0,hidden:!1,cat:"core",category:"content manager"},"Automatic Loading":{id:"fork-ps-5",info:"Automatically loads, reloads, and unloads plugins and themes",implemented:!0,hidden:!1,cat:"core",category:"content manager"},"Developer Mode":{id:"bda-gs-8",info:"Developer Mode",implemented:!0,hidden:!1,cat:"core",category:"developer settings"},"Copy Selector":{id:"fork-dm-1",info:'Adds a "Copy Selector" option to context menus when developer mode is active',implemented:!0,hidden:!1,cat:"core",category:"developer settings"},"Enable Transparency":{id:"fork-wp-1",info:"Enables the main window to be see-through (requires restart)",implemented:!0,hidden:!1,cat:"core",category:"window preferences"},"Window Frame":{id:"fork-wp-2",info:"Adds the native os window frame to the main window",implemented:!1,hidden:!0,cat:"core",category:"window preferences"},"Download Emotes":{id:"fork-es-3",info:"Download emotes when the cache is expired",implemented:!0,hidden:!1,cat:"emote"},"Twitch Emotes":{id:"bda-es-7",info:"Show Twitch emotes",implemented:!0,hidden:!1,cat:"emote"},"FrankerFaceZ Emotes":{id:"bda-es-1",info:"Show FrankerFaceZ Emotes",implemented:!0,hidden:!1,cat:"emote"},"BetterTTV Emotes":{id:"bda-es-2",info:"Show BetterTTV Emotes",implemented:!0,hidden:!1,cat:"emote"},"Emote Menu":{id:"bda-es-0",info:"Show Twitch/Favourite emotes in emote menu",implemented:!0,hidden:!1,cat:"emote"},"Emoji Menu":{id:"bda-es-9",info:"Show Discord emoji menu",implemented:!0,hidden:!1,cat:"emote"},"Emote Auto Capitalization":{id:"bda-es-4",info:"Autocapitalize emote commands",implemented:!0,hidden:!1,cat:"emote"},"Show Names":{id:"bda-es-6",info:"Show emote names on hover",implemented:!0,hidden:!1,cat:"emote"},"Show emote modifiers":{id:"bda-es-8",info:"Enable emote mods (flip, spin, pulse, spin2, spin3, 1spin, 2spin, 3spin, tr, bl, br, shake, shake2, shake3, flap)",implemented:!0,hidden:!1,cat:"emote"},"Animate On Hover":{id:"fork-es-2",info:"Only animate the emote modifiers on hover",implemented:!0,hidden:!1,cat:"emote"}},a={"bda-gs-1":!0,"bda-gs-2":!1,"bda-gs-3":!1,"bda-gs-4":!1,"bda-gs-5":!0,"bda-gs-6":!1,"bda-gs-7":!1,"bda-gs-8":!1,"bda-es-0":!0,"bda-es-1":!0,"bda-es-2":!0,"bda-es-4":!1,"bda-es-6":!0,"bda-es-7":!0,"bda-gs-b":!1,"bda-es-8":!0,"bda-dc-0":!1,"bda-css-0":!1,"bda-css-1":!1,"bda-es-9":!0,"fork-dm-1":!1,"fork-ps-1":!0,"fork-ps-2":!0,"fork-ps-3":!0,"fork-ps-4":!0,"fork-ps-5":!0,"fork-es-2":!1,"fork-es-3":!0,"fork-wp-1":!1,"fork-wp-2":!1},l={local:!1,localServer:"//localhost:8080",minified:!0,version:"0.3.0",branch:"master",repo:"rauenzi",minSupportedVersion:"0.3.0",bbdVersion:"0.2.17"},c={},d={},u={},h={},p={TwitchGlobal:{},TwitchSubscriber:{},BTTV:{},FrankerFaceZ:{},BTTV2:{}},m=[],g=["flip","spin","pulse","spin2","spin3","1spin","2spin","3spin","tr","bl","br","shake","shake2","shake3","flap"],f=["twitch","bttv","ffz"];class b{static get screenWidth(){return Math.max(document.documentElement.clientWidth,window.innerWidth||0)}static get screenHeight(){return Math.max(document.documentElement.clientHeight,window.innerHeight||0)}static stripBOM(e){return 65279===e.charCodeAt(0)&&(e=e.slice(1)),e}static getTextArea(){return $(".channelTextArea-1LDbYG textarea")}static getInternalInstance(e){return e[Object.keys(e).find(e=>e.startsWith("__reactInternalInstance"))]||null}static insertText(e,t){e.focus(),e.selectionStart=0,e.selectionEnd=e.value.length,document.execCommand("insertText",!1,t)}static injectCss(e){$("<link/>",{type:"text/css",rel:"stylesheet",href:e}).appendTo($("head"))}static injectJs(e){return new Promise(t=>{$("<script/>",{type:"text/javascript",src:e,onload:t}).appendTo($("body"))})}static escapeID(e){return e.replace(/^[^a-z]+|[^\w-]+/gi,"")}static log(e,t){console.log(`%c[BandagedBD]%c [${e}]%c ${t}`,"color: #3a71c1; font-weight: 700;","color: #3a71c1;","")}static warn(e,t){console.warn(`%c[BandagedBD]%c [${e}]%c ${t}`,"color: #E8A400; font-weight: 700;","color: #E8A400;","")}static err(e,t,s){console.log(`%c[BandagedBD]%c [${e}]%c ${t}`,"color: red; font-weight: 700;","color: red;",""),s&&(console.groupCollapsed("%cError: "+s.message,"color: red;"),console.error(s.stack),console.groupEnd())}static escape(e){return e.replace(/[-\/\\^$*+?.()|[\]{}]/g,"\\$&")}static testJSON(e){try{return JSON.parse(e),!0}catch(e){return!1}}static suppressErrors(e,t){return(...s)=>{try{return e(...s)}catch(e){this.err("SuppressedError","Error occurred in "+t,e)}}}static monkeyPatch(e,t,s){const{before:n,after:o,instead:r,once:i=!1,silent:a=!1,force:l=!1}=s,c=s.displayName||e.displayName||e.name||e.constructor.displayName||e.constructor.name;if(a||console.log("patch",t,"of",c),!e[t]){if(!l)return console.error(t,"does not exist for",c);e[t]=function(){}}const d=e[t],u=()=>{a||console.log("unpatch",t,"of",c),e[t]=d};return e[t]=function(){const s={thisObject:this,methodArguments:arguments,cancelPatch:u,originalMethod:d,callOriginalMethod:()=>s.returnValue=s.originalMethod.apply(s.thisObject,s.methodArguments)};if(r){const n=b.suppressErrors(r,"`instead` callback of "+e[t].displayName)(s);void 0!==n&&(s.returnValue=n)}else n&&b.suppressErrors(n,"`before` callback of "+e[t].displayName)(s),s.callOriginalMethod(),o&&b.suppressErrors(o,"`after` callback of "+e[t].displayName)(s);return i&&u(),s.returnValue},e[t].__monkeyPatched=!0,e[t].__originalMethod||(e[t].__originalMethod=d),e[t].displayName="patched "+(e[t].displayName||t),u}static onRemoved(e,t){const s=new MutationObserver(n=>{for(let o=0;o<n.length;o++){const r=n[o],i=Array.from(r.removedNodes),a=i.indexOf(e)>-1,l=i.some(t=>t.contains(e));(a||l)&&(s.disconnect(),t())}});s.observe(document.body,{subtree:!0,childList:!0})}static memoizeObject(e){const t=new Proxy(e,{get:function(e,t){if(e.hasOwnProperty(t)){if(Object.getOwnPropertyDescriptor(e,t).get){const s=e[t];delete e[t],e[t]=s}return e[t]}},set:function(e,t,s){return e.hasOwnProperty(t)?this.err("MemoizedObject","Trying to overwrite existing property"):(e[t]=s,e[t])}});return Object.defineProperty(t,"hasOwnProperty",{value:function(e){return void 0!==this[e]}}),t}}const y=b.memoizeObject({get React(){return C.getByProps("createElement","cloneElement")},get ReactDOM(){return C.getByProps("render","findDOMNode")},get Flux(){return C.getByProps("connectStores")},get Events(){return C.getByPrototypes("setMaxListeners","emit")},get GuildStore(){return C.getByProps("getGuild")},get SortedGuildStore(){return C.getByProps("getSortedGuilds")},get SelectedGuildStore(){return C.getByProps("getLastSelectedGuildId")},get GuildSync(){return C.getByProps("getSyncedGuilds")},get GuildInfo(){return C.getByProps("getAcronym")},get GuildChannelsStore(){return C.getByProps("getChannels","getDefaultChannel")},get GuildMemberStore(){return C.getByProps("getMember")},get MemberCountStore(){return C.getByProps("getMemberCounts")},get GuildEmojiStore(){return C.getByProps("getEmojis")},get GuildActions(){return C.getByProps("markGuildAsRead")},get GuildPermissions(){return C.getByProps("getGuildPermissions")},get ChannelStore(){return C.getByProps("getChannels","getDMFromUserId")},get SelectedChannelStore(){return C.getByProps("getLastSelectedChannelId")},get ChannelActions(){return C.getByProps("selectChannel")},get PrivateChannelActions(){return C.getByProps("openPrivateChannel")},get ChannelSelector(){return C.getByProps("selectGuild","selectChannel")},get UserInfoStore(){return C.getByProps("getToken")},get UserSettingsStore(){return C.getByProps("guildPositions")},get AccountManager(){return C.getByProps("register","login")},get UserSettingsUpdater(){return C.getByProps("updateRemoteSettings")},get OnlineWatcher(){return C.getByProps("isOnline")},get CurrentUserIdle(){return C.getByProps("getIdleTime")},get RelationshipStore(){return C.getByProps("isBlocked","getFriendIDs")},get RelationshipManager(){return C.getByProps("addRelationship")},get MentionStore(){return C.getByProps("getMentions")},get UserStore(){return C.getByProps("getCurrentUser")},get UserStatusStore(){return C.getByProps("getStatus","getState")},get UserTypingStore(){return C.getByProps("isTyping")},get UserActivityStore(){return C.getByProps("getActivity")},get UserNameResolver(){return C.getByProps("getName")},get UserNoteStore(){return C.getByProps("getNote")},get UserNoteActions(){return C.getByProps("updateNote")},get EmojiInfo(){return C.getByProps("isEmojiDisabled")},get EmojiUtils(){return C.getByProps("getGuildEmoji")},get EmojiStore(){return C.getByProps("getByCategory","EMOJI_NAME_RE")},get InviteStore(){return C.getByProps("getInvites")},get InviteResolver(){return C.getByProps("findInvite")},get InviteActions(){return C.getByProps("acceptInvite")},get DiscordConstants(){return C.getByProps("Permissions","ActivityTypes","StatusTypes")},get DiscordPermissions(){return C.getByProps("Permissions","ActivityTypes","StatusTypes").Permissions},get PermissionUtils(){return C.getByProps("getHighestRole")},get ColorConverter(){return C.getByProps("hex2int")},get ColorShader(){return C.getByProps("darken")},get TinyColor(){return C.getByPrototypes("toRgb")},get ClassResolver(){return C.getByProps("getClass")},get ButtonData(){return C.getByProps("ButtonSizes")},get IconNames(){return C.getByProps("IconNames")},get NavigationUtils(){return C.getByProps("transitionTo","replaceWith","getHistory")},get MessageStore(){return C.getByProps("getMessages")},get MessageActions(){return C.getByProps("jumpToMessage","_sendMessage")},get MessageQueue(){return C.getByProps("enqueue")},get MessageParser(){return C.getByProps("createMessage","parse","unparse")},get hljs(){return C.getByProps("highlight","highlightBlock")},get SimpleMarkdown(){return C.getByProps("parseBlock","parseInline","defaultOutput")},get ExperimentStore(){return C.getByProps("getExperimentOverrides")},get ExperimentsManager(){return C.getByProps("isDeveloper")},get CurrentExperiment(){return C.getByProps("getExperimentId")},get ImageResolver(){return C.getByProps("getUserAvatarURL","getGuildIconURL")},get ImageUtils(){return C.getByProps("getSizedImageSrc")},get AvatarDefaults(){return C.getByProps("getUserAvatarURL","DEFAULT_AVATARS")},get WindowInfo(){return C.getByProps("isFocused","windowSize")},get TagInfo(){return C.getByProps("VALID_TAG_NAMES")},get DOMInfo(){return C.getByProps("canUseDOM")},get LocaleManager(){return C.getByProps("setLocale")},get Moment(){return C.getByProps("parseZone")},get LocationManager(){return C.getByProps("createLocation")},get Timestamps(){return C.getByProps("fromTimestamp")},get TimeFormatter(){return C.getByProps("dateFormat")},get Strings(){return C.getByProps("Messages").Messages},get StringFormats(){return C.getByProps("a","z")},get StringUtils(){return C.getByProps("toASCII")},get URLParser(){return C.getByProps("Url","parse")},get ExtraURLs(){return C.getByProps("getArticleURL")},get DNDActions(){return C.getByProps("beginDrag")},get DNDSources(){return C.getByProps("addTarget")},get DNDObjects(){return C.getByProps("DragSource")},get MediaDeviceInfo(){return C.getByProps("Codecs","SUPPORTED_BROWSERS")},get MediaInfo(){return C.getByProps("getOutputVolume")},get MediaEngineInfo(){return C.getByProps("MediaEngineFeatures")},get VoiceInfo(){return C.getByProps("EchoCancellation")},get VideoStream(){return C.getByProps("getVideoStream")},get SoundModule(){return C.getByProps("playSound")},get ElectronModule(){return C.getByProps("setBadge")},get Dispatcher(){return C.getByProps("dirtyDispatch")},get PathUtils(){return C.getByProps("hasBasename")},get NotificationModule(){return C.getByProps("showNotification")},get RouterModule(){return C.getByProps("Router")},get APIModule(){return C.getByProps("getAPIBaseURL")},get AnalyticEvents(){return C.getByProps("AnalyticEventConfigs")},get KeyGenerator(){return C.getByRegex(/"binary"/)},get Buffers(){return C.getByProps("Buffer","kMaxLength")},get DeviceStore(){return C.getByProps("getDevices")},get SoftwareInfo(){return C.getByProps("os")},get CurrentContext(){return C.getByProps("setTagsContext")}});class v{static byProperties(e,t=(e=>e)){return s=>{const n=t(s);return!!n&&e.every(e=>void 0!==n[e])}}static byPrototypeFields(e,t=(e=>e)){return s=>{const n=t(s);return!!n&&(!!n.prototype&&e.every(e=>void 0!==n.prototype[e]))}}static byCode(e,t=(e=>e)){return s=>{const n=t(s);return!!n&&-1!==n.toString([]).search(e)}}static byString(...e){return t=>{const s=t.toString([]);for(const t of e)if(!s.includes(t))return!1;return!0}}static byDisplayName(e){return t=>t&&t.displayName===e}static combine(...e){return t=>e.every(e=>e(t))}}class C{static find(e,t=!0){return this.getModule(e,t)}static findAll(e){return this.getModule(e,!1)}static findByUniqueProperties(e,t=!0){return t?this.getByProps(...e):this.getAllByProps(...e)}static findByDisplayName(e){return this.getByDisplayName(e)}static getModule(e,t=!0){const s=this.getAllModules(),n=[];for(const o in s){if(!s.hasOwnProperty(o))continue;const r=s[o],{exports:i}=r;let a=null;if(i&&(i.__esModule&&i.default&&e(i.default)&&(a=i.default),e(i)&&(a=i),a)){if(t)return a;n.push(a)}}return t||0==n.length?void 0:n}static getModules(e){return this.getModule(e,!1)}static getModuleByName(e,t){if(y.hasOwnProperty(e))return y[e];if(!t)return;const s=this.getModule(t,!0);return s?y[e]=s:void 0}static getByDisplayName(e){return this.getModule(v.byDisplayName(e),!0)}static getByRegex(e,t=!0){return this.getModule(v.byCode(e),t)}static getByPrototypes(...e){return this.getModule(v.byPrototypeFields(e),!0)}static getAllByPrototypes(...e){return this.getModule(v.byPrototypeFields(e),!1)}static getByProps(...e){return this.getModule(v.byProperties(e),!0)}static getAllByProps(...e){return this.getModule(v.byProperties(e),!1)}static getByString(...e){return this.getModule(v.byString(...e),!0)}static getAllByString(...e){return this.getModule(v.byString(...e),!1)}static get require(){if(this._require)return this._require;const e="bbd-webpackmodules",t="function"==typeof window.webpackJsonp?window.webpackJsonp([],{[e]:(e,t,s)=>t.default=s},[e]).default:window.webpackJsonp.push([[],{[e]:(e,t,s)=>e.exports=s},[[e]]]);return delete t.m[e],delete t.c[e],this._require=t}static getAllModules(){return this.require.c}}const w=s(0),E=s(2),S=DiscordNative.globals.releaseChannel;var k=new class{constructor(){this.data={settings:{stable:{},canary:{},ptb:{}}},this.pluginData={}}initialize(){w.existsSync(this.BDFile)||w.writeFileSync(this.BDFile,JSON.stringify(this.data,null,4));const e=require(this.BDFile);if(e.hasOwnProperty("settings")&&(this.data=e),!w.existsSync(this.settingsFile))return;let t=require(this.settingsFile);w.unlinkSync(this.settingsFile),t=t.hasOwnProperty("settings")?Object.assign({stable:{},canary:{},ptb:{}},{[S]:t}):Object.assign({stable:{},canary:{},ptb:{}},t),this.setBDData("settings",t)}get BDFile(){return this._BDFile||(this._BDFile=E.resolve(l.dataPath,"bdstorage.json"))}get settingsFile(){return this._settingsFile||(this._settingsFile=E.resolve(l.dataPath,"bdsettings.json"))}getPluginFile(e){return E.resolve(l.dataPath,"plugins",e+".config.json")}getSettingGroup(e){return this.data.settings[S][e]||null}setSettingGroup(e,t){this.data.settings[S][e]=t,w.writeFileSync(this.BDFile,JSON.stringify(this.data,null,4))}getBDData(e){return this.data[e]||""}setBDData(e,t){this.data[e]=t,w.writeFileSync(this.BDFile,JSON.stringify(this.data,null,4))}getPluginData(e,t){return void 0!==this.pluginData[e]?this.pluginData[e][t]||void 0:w.existsSync(this.getPluginFile(e))?(this.pluginData[e]=JSON.parse(w.readFileSync(this.getPluginFile(e))),this.pluginData[e][t]||void 0):void 0}setPluginData(e,t,s){void 0!==s&&(void 0===this.pluginData[e]&&(this.pluginData[e]={}),this.pluginData[e][t]=s,w.writeFileSync(this.getPluginFile(e),JSON.stringify(this.pluginData[e],null,4)))}deletePluginData(e,t){void 0===this.pluginData[e]&&(this.pluginData[e]={}),delete this.pluginData[e][t],w.writeFileSync(this.getPluginFile(e),JSON.stringify(this.pluginData[e],null,4))}};const x=s(4);var P=new class extends x{constructor(){super(),this.setMaxListeners(20)}dispatch(e,...t){this.emit(e,...t)}};function D(){}D.prototype.loadPlugins=function(){this.loadPluginData();const e=A.loadPlugins(),t=Object.keys(h);for(let s=0;s<t.length;s++){let n,o;try{o=(n=h[t[s]].plugin).getName(),n.load&&"function"==typeof n.load&&n.load()}catch(n){c[o]=!1,b.err("Plugins",o+" could not be loaded.",n),e.push({name:o,file:h[t[s]].filename,message:"load() could not be fired.",error:{message:n.message,stack:n.stack}});continue}if(c[o]||(c[o]=!1),c[o])try{n.start(),Ce.show(`${n.getName()} v${n.getVersion()} has started.`)}catch(n){c[o]=!1,b.err("Plugins",o+" could not be started.",n),e.push({name:o,file:h[t[s]].filename,message:"start() could not be fired.",error:{message:n.message,stack:n.stack}})}}return this.savePluginData(),s(1).remote.getCurrentWebContents().on("did-navigate-in-page",this.channelSwitch.bind(this)),e},D.prototype.startPlugin=function(e,t=!1){try{h[e].plugin.start(),t||Ce.show(`${h[e].plugin.getName()} v${h[e].plugin.getVersion()} has started.`)}catch(s){t||Ce.show(`${h[e].plugin.getName()} v${h[e].plugin.getVersion()} could not be started.`,{type:"error"}),c[e]=!1,this.savePluginData(),b.err("Plugins",e+" could not be started.",s)}},D.prototype.stopPlugin=function(e,t=!1){try{h[e].plugin.stop(),t||Ce.show(`${h[e].plugin.getName()} v${h[e].plugin.getVersion()} has stopped.`)}catch(s){t||Ce.show(`${h[e].plugin.getName()} v${h[e].plugin.getVersion()} could not be stopped.`,{type:"error"}),b.err("Plugins",h[e].plugin.getName()+" could not be stopped.",s)}},D.prototype.enablePlugin=function(e,t=!1){c[e]||(c[e]=!0,this.savePluginData(),this.startPlugin(e,t))},D.prototype.disablePlugin=function(e,t=!1){c[e]&&(c[e]=!1,this.savePluginData(),this.stopPlugin(e,t))},D.prototype.togglePlugin=function(e){c[e]?this.disablePlugin(e):this.enablePlugin(e)},D.prototype.loadPlugin=function(e){const t=A.loadContent(e,"plugin");if(t)return $e.showContentErrors({plugins:[t]}),Ce.show(`${e} could not be loaded.`,{type:"error"}),b.err("ContentManager",`${e} could not be loaded.`,t);const s=Object.values(h).find(t=>t.filename==e).plugin;try{s.load&&"function"==typeof s.load&&s.load()}catch(e){$e.showContentErrors({plugins:[e]})}b.log("ContentManager",`${s.getName()} v${s.getVersion()} was loaded.`),Ce.show(`${s.getName()} v${s.getVersion()} was loaded.`,{type:"success"}),P.dispatch("plugin-loaded",s.getName())},D.prototype.unloadPlugin=function(e){const t=Object.values(h).find(t=>t.filename==e)||h[e];if(!t)return;const s=t.plugin.getName();c[s]&&this.disablePlugin(s,!0);const n=A.unloadContent(h[s].filename,"plugin");if(delete h[s],n)return $e.showContentErrors({plugins:[n]}),Ce.show(`${s} could not be unloaded. It may have not been loaded yet.`,{type:"error"}),b.err("ContentManager",`${s} could not be unloaded. It may have not been loaded yet.`,n);b.log("ContentManager",`${s} was unloaded.`),Ce.show(`${s} was unloaded.`,{type:"success"}),P.dispatch("plugin-unloaded",s)},D.prototype.reloadPlugin=function(e){const t=Object.values(h).find(t=>t.filename==e)||h[e];if(!t)return this.loadPlugin(e);const s=t.plugin.getName(),n=c[s];n&&this.stopPlugin(s,!0);const o=A.reloadContent(h[s].filename,"plugin");if(o)return $e.showContentErrors({plugins:[o]}),Ce.show(`${s} could not be reloaded.`,{type:"error"}),b.err("ContentManager",`${s} could not be reloaded.`,o);h[s].plugin.load&&"function"==typeof h[s].plugin.load&&h[s].plugin.load(),n&&this.startPlugin(s,!0),b.log("ContentManager",`${s} v${h[s].plugin.getVersion()} was reloaded.`),Ce.show(`${s} v${h[s].plugin.getVersion()} was reloaded.`,{type:"success"}),P.dispatch("plugin-reloaded",s)},D.prototype.updatePluginList=function(){const e=A.loadNewContent("plugin");for(const t of e.added)this.loadPlugin(t);for(const t of e.removed)this.unloadPlugin(t)},D.prototype.loadPluginData=function(){const e=k.getSettingGroup("plugins");e&&Object.assign(c,e)},D.prototype.savePluginData=function(){k.setSettingGroup("plugins",c)},D.prototype.newMessage=function(){const e=Object.keys(h);for(let t=0;t<e.length;t++){const s=h[e[t]].plugin;if(c[s.getName()]&&"function"==typeof s.onMessage)try{s.onMessage()}catch(e){b.err("Plugins","Unable to fire onMessage for "+s.getName()+".",e)}}},D.prototype.channelSwitch=function(){const e=Object.keys(h);for(let t=0;t<e.length;t++){const s=h[e[t]].plugin;if(c[s.getName()]&&"function"==typeof s.onSwitch)try{s.onSwitch()}catch(e){b.err("Plugins","Unable to fire onSwitch for "+s.getName()+".",e)}}},D.prototype.rawObserver=function(e){const t=Object.keys(h);for(let s=0;s<t.length;s++){const n=h[t[s]].plugin;if(c[n.getName()]&&"function"==typeof n.observer)try{n.observer(e)}catch(e){b.err("Plugins","Unable to fire observer for "+n.getName()+".",e)}}};var N=new D;function M(){}M.prototype.loadThemes=function(){this.loadThemeData();const e=A.loadThemes(),t=Object.keys(u);for(let e=0;e<t.length;e++){const s=u[t[e]].name;d[s]||(d[s]=!1),d[s]&&$("head").append($("<style>",{id:b.escapeID(s),text:unescape(u[s].css)}))}for(const e in d)u[e]||delete d[e];return this.saveThemeData(),e},M.prototype.enableTheme=function(e,t=!1){d[e]=!0,this.saveThemeData(),$("head").append($("<style>",{id:b.escapeID(e),text:unescape(u[e].css)})),t||Ce.show(`${u[e].name} v${u[e].version} has been applied.`)},M.prototype.disableTheme=function(e,t=!1){d[e]=!1,this.saveThemeData(),$(`#${b.escapeID(u[e].name)}`).remove(),t||Ce.show(`${u[e].name} v${u[e].version} has been disabled.`)},M.prototype.toggleTheme=function(e){d[e]?this.disableTheme(e):this.enableTheme(e)},M.prototype.loadTheme=function(e){const t=A.loadContent(e,"theme");if(t)return $e.showContentErrors({themes:[t]}),Ce.show(`${e} could not be loaded. It may not have been loaded.`,{type:"error"}),b.err("ContentManager",`${e} could not be loaded.`,t);const s=Object.values(u).find(t=>t.filename==e);b.log("ContentManager",`${s.name} v${s.version} was loaded.`),Ce.show(`${s.name} v${s.version} was loaded.`,{type:"success"}),P.dispatch("theme-loaded",s.name)},M.prototype.unloadTheme=function(e){const t=Object.values(u).find(t=>t.filename==e)||u[e];if(!t)return;const s=t.name;d[s]&&this.disableTheme(s,!0);const n=A.unloadContent(u[s].filename,"theme");if(delete u[s],n)return $e.showContentErrors({themes:[n]}),Ce.show(`${s} could not be unloaded. It may have not been loaded yet.`,{type:"error"}),b.err("ContentManager",`${s} could not be unloaded. It may have not been loaded yet.`,n);b.log("ContentManager",`${s} was unloaded.`),Ce.show(`${s} was unloaded.`,{type:"success"}),P.dispatch("theme-unloaded",s)},M.prototype.reloadTheme=function(e){const t=Object.values(u).find(t=>t.filename==e)||u[e];if(!t)return this.loadTheme(e);const s=t.name,n=A.reloadContent(u[s].filename,"theme");if(d[s]&&(this.disableTheme(s,!0),this.enableTheme(s,!0)),n)return $e.showContentErrors({themes:[n]}),Ce.show(`${s} could not be reloaded.`,{type:"error"}),b.err("ContentManager",`${s} could not be reloaded.`,n);b.log("ContentManager",`${s} v${u[s].version} was reloaded.`),Ce.show(`${s} v${u[s].version} was reloaded.`,{type:"success"}),P.dispatch("theme-reloaded",s)},M.prototype.updateThemeList=function(){const e=A.loadNewContent("theme");for(const t of e.added)this.loadTheme(t);for(const t of e.removed)this.unloadTheme(t)},M.prototype.loadThemeData=function(){const e=k.getSettingGroup("themes");e&&Object.assign(d,e)},M.prototype.saveThemeData=function(){k.setSettingGroup("themes",d)};var B=new M;const T=s(2),j=s(0),O=s(3).Module;O.globalPaths.push(T.resolve(s(1).remote.app.getAppPath(),"node_modules"));class F extends Error{constructor(e){super(e),this.name="MetaError"}}const R=O._extensions[".js"],I=O._extensions[".css"]?O._extensions[".css"]:()=>null;var A=new class{constructor(){this.timeCache={},this.watchers={},O._extensions[".js"]=this.getContentRequire("plugin"),O._extensions[".css"]=this.getContentRequire("theme")}get pluginsFolder(){return this._pluginsFolder||(this._pluginsFolder=j.realpathSync(T.resolve(l.dataPath+"plugins/")))}get themesFolder(){return this._themesFolder||(this._themesFolder=j.realpathSync(T.resolve(l.dataPath+"themes/")))}watchContent(e){if(this.watchers[e])return;const t="plugin"===e,s=t?this.pluginsFolder:this.themesFolder,n=t?".plugin.js":".theme.css";this.watchers[e]=j.watch(s,{persistent:!1},async(e,o)=>{if(!e||!o||!o.endsWith(n))return;await new Promise(e=>setTimeout(e,50));try{j.statSync(T.resolve(s,o))}catch(e){if("ENOENT"!==e.code)return;return delete this.timeCache[o],t?N.unloadPlugin(o):B.unloadTheme(o)}if(!j.statSync(T.resolve(s,o)).isFile())return;const r=j.statSync(T.resolve(s,o));r&&r.mtime&&r.mtime.getTime()&&"number"==typeof r.mtime.getTime()&&this.timeCache[o]!=r.mtime.getTime()&&(this.timeCache[o]=r.mtime.getTime(),"rename"==e&&(t?N.loadPlugin(o):B.loadTheme(o)),"change"==e&&(t?N.reloadPlugin(o):B.reloadTheme(o)))})}unwatchContent(e){this.watchers[e]&&(this.watchers[e].close(),delete this.watchers[e])}extractMeta(e){const t=e.split("\n")[0],s=t.substring(t.lastIndexOf("//META")+6,t.lastIndexOf("*//"));if(t.indexOf("META")<0)throw new F("META was not found.");if(!b.testJSON(s))throw new F("META could not be parsed.");const n=JSON.parse(s);if(!n.name)throw new F("META missing name data.");return n}getContentRequire(e){const t="plugin"===e,s=this,n=t?R:I;return function(e,o){const r=t?s.pluginsFolder:s.themesFolder,i=T.resolve(r,T.basename(o));if(!j.existsSync(i)||o!==j.realpathSync(i))return Reflect.apply(n,this,arguments);let a=j.readFileSync(o,"utf8");a=b.stripBOM(a);const l=s.extractMeta(a);l.filename=T.basename(o),t||(l.css=a.split("\n").slice(1).join("\n"),a=`module.exports = ${JSON.stringify(l)};`),t&&(a+=`\nmodule.exports = ${JSON.stringify(l)};\nmodule.exports.type = ${l.name};`),e._compile(a,o)}}makePlaceholderPlugin(e){return{plugin:{start:()=>{},getName:()=>e.name||e.filename,getAuthor:()=>"???",getDescription:()=>e.message?e.message:"This plugin was unable to be loaded. Check the author's page for updates.",getVersion:()=>"???"},name:e.name||e.filename,filename:e.filename,source:e.source?e.source:"",website:e.website?e.website:""}}loadContent(e,t){if(void 0===e||void 0===t)return;const s="plugin"===t,n=s?this.pluginsFolder:this.themesFolder;try{require(T.resolve(n,e))}catch(t){return{name:e,file:e,message:"Could not be compiled.",error:{message:t.message,stack:t.stack}}}const o=require(T.resolve(n,e));if(s){if(!o.type)return;try{o.plugin=new o.type,delete h[o.plugin.getName()],h[o.plugin.getName()]=o}catch(t){return{name:e,file:e,message:"Could not be constructed.",error:{message:t.message,stack:t.stack}}}}else delete u[o.name],u[o.name]=o}unloadContent(e,t){if(void 0===e||void 0===t)return;const s="plugin"===t?this.pluginsFolder:this.themesFolder;try{delete require.cache[require.resolve(T.resolve(s,e))]}catch(t){return{name:e,file:e,message:"Could not be unloaded.",error:{message:t.message,stack:t.stack}}}}isLoaded(e,t){const s="plugin"===t?this.pluginsFolder:this.themesFolder;try{require.cache[require.resolve(T.resolve(s,e))]}catch(e){return!1}return!0}reloadContent(e,t){const s=this.unloadContent(e,t);return s||this.loadContent(e,t)}loadNewContent(e){const t="plugin"===e,s=t?".plugin.js":".theme.css",n=t?this.pluginsFolder:this.themesFolder,o=j.readdirSync(n),r=Object.values(t?h:u),i=r.filter(e=>!o.includes(e.filename)).map(e=>t?e.plugin.getName():e.name);return{added:o.filter(e=>!r.find(t=>t.filename==e)&&e.endsWith(s)&&j.statSync(T.resolve(n,e)).isFile()),removed:i}}loadAllContent(e){const t="plugin"===e,s=t?".plugin.js":".theme.css",n=t?this.pluginsFolder:this.themesFolder,o=[],r=j.readdirSync(n);for(const t of r){if(!j.statSync(T.resolve(n,t)).isFile()||!t.endsWith(s))continue;const r=this.loadContent(t,e);r&&o.push(r)}return o}loadPlugins(){return this.loadAllContent("plugin")}loadThemes(){return this.loadAllContent("theme")}};const L=y.React,G=y.ReactDOM;class V extends L.Component{constructor(e){super(e),this.setInitialState(),this.onClick=this.onClick.bind(this)}setInitialState(){this.state={selected:this.props.selected||!1}}render(){return L.createElement("div",{className:`ui-tab-bar-item${this.props.selected?" selected":""}`,onClick:this.onClick},this.props.text)}onClick(){this.props.onClick&&this.props.onClick(this.props.id)}}class U extends L.Component{constructor(e){super(e)}render(){return L.createElement("div",{className:"ui-tab-bar-separator margin-top-8 margin-bottom-8"})}}class z extends L.Component{constructor(e){super(e)}render(){return L.createElement("div",{className:"ui-tab-bar-header"},this.props.text)}}class H{static get Item(){return V}static get Header(){return z}static get Separator(){return U}}class W extends L.Component{constructor(e){super(e);const t=this,s=$("[class*=side] > [class*=selected]");s.length&&(t.scn=s.attr("class"));const n=$("[class*=side] > [class*=notSelected]");n.length&&(t.nscn=n.attr("class")),$("[class*='side-'] > [class*='item-']").on("click",()=>{t.setState({selected:null})}),t.setInitialState(),t.onClick=t.onClick.bind(t)}setInitialState(){const e=this;e.state={selected:null,items:e.props.items};const t=e.props.items.find(e=>e.selected);t&&(e.state.selected=t.id)}render(){const e=this,{headerText:t}=e.props,{items:s,selected:n}=e.state;return L.createElement("div",null,L.createElement(H.Separator,null),L.createElement(H.Header,{text:t}),s.map(t=>{const{id:s,text:o}=t;return L.createElement(H.Item,{key:s,selected:n===s,text:o,id:s,onClick:e.onClick})}))}onClick(e){const t=this,s=$("[class*=side] > [class*=selected]");s.length&&(s.off("click.bdsb").on("click.bsb",e=>{$(e.target).attr("class",t.scn)}),s.attr("class",t.nscn)),t.setState({selected:null}),t.setState({selected:e}),t.props.onClick&&t.props.onClick(e)}}class q{constructor(e){this.onClick=e}get items(){return[{text:"Settings",id:"core"},{text:"Emotes",id:"emotes"},{text:"Plugins",id:"plugins"},{text:"Themes",id:"themes"},{text:"Custom CSS",id:"customcss"}]}get component(){return L.createElement("span",null,L.createElement(W,{onClick:this.onClick,headerText:"Bandaged BD",items:this.items}),L.createElement("div",{style:{fontSize:"12px",fontWeight:"600",color:"#72767d",padding:"2px 10px"}},`BD v${l.version} by `,L.createElement("a",{href:"https://github.com/Jiiks/",target:"_blank"},"Jiiks")),L.createElement("div",{style:{fontSize:"12px",fontWeight:"600",color:"#72767d",padding:"2px 10px"}},`BBD v${l.bbdVersion} by `,L.createElement("a",{href:"https://github.com/rauenzi/",target:"_blank"},"Zerebos")))}get root(){const e=$("#bd-settings-sidebar");return e.length?e[0]:this.injectRoot()?this.root:null}injectRoot(){const e=$("[class*='side-'] > [class*='item-']:not([class*=Danger])").last();return!!e.length&&($("<span/>",{id:"bd-settings-sidebar"}).insertBefore(e.prev()),!0)}render(){const e=this.root;e?(G.render(this.component,e),b.onRemoved(e,()=>{G.unmountComponentAtNode(e)})):console.log("FAILED TO LOCATE ROOT: [class*='side-'] > [class*='item-']:not([class*=Danger])")}}class _ extends L.Component{constructor(e){super(e)}render(){let e=`scrollerWrap-2lJEkd scrollerThemed-2oenus themeGhostHairline-DBD-2d${this.props.fade?" scrollerFade-1Ijw5y":""}`,t="scroller-2FKFPG scroller";this.props.sidebar&&(t="scroller-2FKFPG firefoxFixScrollFlex-cnI2ix sidebarRegionScroller-3MXcoP sidebar-region-scroller scroller"),this.props.contentColumn&&(t="scroller-2FKFPG firefoxFixScrollFlex-cnI2ix contentRegionScroller-26nc1e content-region-scroller scroller",e="scrollerWrap-2lJEkd firefoxFixScrollFlex-cnI2ix contentRegionScrollerWrap-3YZXdm content-region-scroller-wrap scrollerThemed-2oenus themeGhost-28MSn0 scrollerTrack-1ZIpsv");const{children:s}=this.props;return L.createElement("div",{key:"scrollerwrap",className:e},L.createElement("div",{key:"scroller",ref:"scroller",className:t},s))}}class J extends L.Component{constructor(e){super(e)}render(){return L.createElement("ul",{className:this.props.className},this.props.children)}}class Y extends L.Component{constructor(e){super(e)}render(){return L.createElement("div",{className:"contentColumn-2hrIYH contentColumnDefault-1VQkGM content-column default"},L.createElement("h2",{className:"ui-form-title h2 margin-reset margin-bottom-20"},this.props.title),this.props.children)}}const Z="bd-settings-title h2-2gWE-o title-3sZWYQ size16-14cGz5 height20-mO2eIN weightSemiBold-NJexzi defaultColor-1_ajX0 defaultMarginh2-2LTaUL marginBottom20-32qID7";class K extends L.Component{constructor(e){super(e)}render(){const e=this.props.className?`${Z} ${this.props.className}`:Z;return L.createElement("h2",{className:e,onClick:()=>{this.props.onClick&&this.props.onClick()}},this.props.text)}}const Q="bd-vertical-container";class X extends L.Component{render(){const e=this.props.className?`${Q} ${this.props.className}`:Q;return L.createElement("div",{className:e},this.props.children)}}class ee extends L.Component{render(){return L.createElement("div",{className:"bd-divider divider-3573oO marginTop8-1DLZ1n marginBottom40-2vIwTv"})}}const te="flex-1xMQg5 flex-1O1GKY vertical-V37hAW flex-1O1GKY directionColumn-35P_nr justifyStart-2NDFzi alignStretch-DpGPf3 noWrap-3jynv6 switchItem-2hKKKK",se="flex-1xMQg5 flex-1O1GKY horizontal-1ae9ci horizontal-2EEEnY flex-1O1GKY directionRow-3v3tfG justifyStart-2NDFzi alignStart-H-X2h- noWrap-3jynv6",ne="flexChild-faoVW3",oe="titleDefault-a8-ZSr title-31JmR4 da-titleDefault da-title",re="flexChild-faoVW3 da-flexChild switchEnabled-V2WDBB switch-3wwwcV da-switchEnabled da-switch valueUnchecked-2lU_20 value-2hFrkk sizeDefault-2YlOZr size-3rFEHg themeDefault-24hCdX",ie="flexChild-faoVW3 da-flexChild switchEnabled-V2WDBB switch-3wwwcV da-switchEnabled da-switch valueChecked-m-4IJZ value-2hFrkk sizeDefault-2YlOZr size-3rFEHg themeDefault-24hCdX",ae="checkboxEnabled-CtinEn checkbox-2tyjJg",le="description-3_Ncsb formText-3fs7AJ note-1V3kyJ modeDefault-3a2Ph1 primary-jw0I4K",ce="divider-3573oO dividerDefault-3rvLe-";class de extends L.Component{constructor(e){super(e),console.log(e),this.state={checked:this.props.checked}}onChange(){this.props.onChange(this.props.id,!this.state.checked),this.setState({checked:!this.state.checked})}render(){return L.createElement("div",{className:te,style:{flex:"1 1 auto"}},L.createElement("div",{className:se,style:{flex:"1 1 auto"}},L.createElement("div",{className:ne,style:{flex:"1 1 auto"}},L.createElement("label",{htmlFor:this.props.id,className:oe},this.props.name||this.props.data.text)),L.createElement("div",{className:this.state.checked?ie:re,tabIndex:"0",style:{flex:"0 0 auto"}},L.createElement("input",{id:this.props.id,className:ae,type:"checkbox",tabIndex:"-1",checked:this.state.checked,onChange:e=>this.onChange(e)}))),L.createElement("div",{className:le,style:{flex:"1 1 auto"}},this.props.note||this.props.data.info),L.createElement("div",{className:ce}))}}class ue extends L.Component{constructor(e){super(e),this.container=L.createRef(),this.state={collapsed:this.props.collapsible&&this.props.collapsed}}collapseGroup(){if(this.state.collapsed)return this.expandGroup();const e=G.findDOMNode(this.container.current);e.style.setProperty("height",e.scrollHeight+"px"),this.setState({collapsed:!0},()=>setImmediate(()=>e.style.setProperty("height","")))}expandGroup(){const e=G.findDOMNode(this.container.current);e.style.setProperty("height",e.scrollHeight+"px"),this.setState({collapsed:!1},()=>setTimeout(()=>e.style.setProperty("height",""),300))}render(){const{settings:e}=this.props,t=this.state.collapsed?"bd-settings-group bd-settings-group-collapsed":"bd-settings-group";return L.createElement("div",{className:t},L.createElement(K,{text:this.props.title,collapsible:this.props.collapsible,onClick:()=>this.collapseGroup()}),L.createElement(X,{className:"bd-settings-container",ref:this.container},e.map(e=>L.createElement(de,{id:e.id,key:e.id,name:e.text,note:e.info,checked:a[e.id],onChange:(e,t)=>{this.props.onChange(e,t)}}))),this.props.showDivider&&L.createElement(ee,null))}}class he extends L.Component{constructor(e){super(e)}render(){return L.createElement("div",{className:"contentColumn-2hrIYH contentColumnDefault-1VQkGM content-column default"},this.props.sections.map(e=>L.createElement(ue,Object.assign({},e,{onChange:this.props.onChange}))))}}class pe extends L.Component{constructor(e){super(e)}render(){return L.createElement("svg",{xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 12 12",style:{width:"18px",height:"18px"}},L.createElement("g",{className:"background",fill:"none",fillRule:"evenodd"},L.createElement("path",{d:"M0 0h12v12H0"}),L.createElement("path",{className:"fill",fill:"#dcddde",d:"M9.5 3.205L8.795 2.5 6 5.295 3.205 2.5l-.705.705L5.295 6 2.5 8.795l.705.705L6 6.705 8.795 9.5l.705-.705L6.705 6"})))}}class me extends L.Component{constructor(e){super(e),this.onClick=this.onClick.bind(this)}render(){return L.createElement("div",{className:"tools-container toolsContainer-1edPuj"},L.createElement("div",{className:"tools tools-3-3s-N"},L.createElement("div",{className:"container-1sFeqf"},L.createElement("div",{className:"btn-close closeButton-1tv5uR",onClick:this.onClick},L.createElement(pe,null)),L.createElement("div",{className:"esc-text keybind-KpFkfr"},"ESC"))))}onClick(){this.props.onClick&&this.props.onClick(),$(".closeButton-1tv5uR").first().click()}}class ge extends L.Component{constructor(e){super(e)}render(){const{settings:e}=this.props;return L.createElement("div",{className:"contentColumn-2hrIYH contentColumnDefault-1VQkGM content-column default"},L.createElement(K,{text:this.props.title}),this.props.button&&L.createElement("button",{key:"title-button",className:"bd-pfbtn",onClick:this.props.button.onClick},this.props.button.title),e.map(e=>L.createElement(de,{id:e.id,key:e.id,data:e,checked:a[e.id],onChange:(e,t)=>{this.props.onChange(e,t)}})))}}class fe extends L.Component{constructor(e){super(e)}render(){return L.createElement("svg",{xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 24 24",fill:"#dcddde",className:"bd-reload "+this.props.className,onClick:this.props.onClick,style:{width:this.props.size||"24px",height:this.props.size||"24px"}},L.createElement("path",{d:"M17.65 6.35C16.2 4.9 14.21 4 12 4c-4.42 0-7.99 3.58-7.99 8s3.57 8 7.99 8c3.73 0 6.84-2.55 7.73-6h-2.08c-.82 2.33-3.04 4-5.65 4-3.31 0-6-2.69-6-6s2.69-6 6-6c1.66 0 3.14.69 4.22 1.78L13 11h7V4l-2.35 2.35z"}),L.createElement("path",{fill:"none",d:"M0 0h24v24H0z"}))}}class be extends L.Component{constructor(e){super(e),this.onChange=this.onChange.bind(this),this.showSettings=this.showSettings.bind(this),this.setInitialState(),this.hasSettings="function"==typeof this.props.plugin.getSettingsPanel,this.settingsPanel="",this.reload=this.reload.bind(this),this.onReload=this.onReload.bind(this)}setInitialState(){this.state={checked:c[this.props.plugin.getName()],settings:!1,reloads:0}}onReload(e){e===this.props.plugin.getName()&&this.setState({reloads:this.state.reloads+1})}componentDidUpdate(){if(this.state.settings){if("object"==typeof this.settingsPanel&&this.refs.settingspanel.appendChild(this.settingsPanel),!a["fork-ps-3"])return;const e=(e,t)=>{const s=e.scrollTop,n=s+e.clientHeight,o=t.offsetTop,r=o+t.clientHeight;return o<s||r>n},t=$(G.findDOMNode(this)),s=t.parents(".scroller");if(!e(s[0],t[0]))return;s.animate({scrollTop:t.offset().top-s.offset().top+s.scrollTop()-30},300)}}reload(){const e=this.props.plugin.getName();N.reloadPlugin(e),this.props.plugin=h[e].plugin,this.onReload(this.props.plugin.getName())}getString(e){return"string"==typeof e?e:e.toString()}render(){const e=this,{plugin:t}=this.props,s=this.getString(t.getName()),n=this.getString(t.getAuthor()),o=this.getString(t.getDescription()),r=this.getString(t.getVersion()),i=h[s].website,l=h[s].source;if(this.state.settings){try{e.settingsPanel=t.getSettingsPanel()}catch(e){b.err("Plugins","Unable to get settings panel for "+t.getName()+".",e)}return L.createElement("li",{className:"settings-open ui-switch-item"},L.createElement("div",{style:{float:"right",cursor:"pointer"},onClick:()=>{this.refs.settingspanel.innerHTML="",e.setState({settings:!1})}},L.createElement(pe,null)),"object"==typeof e.settingsPanel&&L.createElement("div",{id:`plugin-settings-${s}`,className:"plugin-settings",ref:"settingspanel"}),"object"!=typeof e.settingsPanel&&L.createElement("div",{id:`plugin-settings-${s}`,className:"plugin-settings",ref:"settingspanel",dangerouslySetInnerHTML:{__html:e.settingsPanel}}))}return L.createElement("li",{"data-name":s,"data-version":r,className:"settings-closed ui-switch-item"},L.createElement("div",{className:"bda-header"},L.createElement("span",{className:"bda-header-title"},L.createElement("span",{className:"bda-name"},s)," v",L.createElement("span",{className:"bda-version"},r)," by ",L.createElement("span",{className:"bda-author"},n)),L.createElement("div",{className:"bda-controls"},!a["fork-ps-5"]&&L.createElement(fe,{className:"bd-reload-card",onClick:this.reload}),L.createElement("label",{className:"ui-switch-wrapper ui-flex-child",style:{flex:"0 0 auto"}},L.createElement("input",{checked:this.state.checked,onChange:this.onChange,className:"ui-switch-checkbox",type:"checkbox"}),L.createElement("div",{className:this.state.checked?"ui-switch checked":"ui-switch"})))),L.createElement("div",{className:"bda-description-wrap scroller-wrap fade"},L.createElement("div",{className:"bda-description scroller"},o)),(i||l||this.hasSettings)&&L.createElement("div",{className:"bda-footer"},L.createElement("span",{className:"bda-links"},i&&L.createElement("a",{className:"bda-link bda-link-website",href:i,target:"_blank"},"Website"),i&&l&&" | ",l&&L.createElement("a",{className:"bda-link bda-link-source",href:l,target:"_blank"},"Source")),this.hasSettings&&L.createElement("button",{onClick:this.showSettings,className:"bda-settings-button",disabled:!this.state.checked},"Settings")))}onChange(){this.setState({checked:!this.state.checked}),N.togglePlugin(this.props.plugin.getName())}showSettings(){this.hasSettings&&this.setState({settings:!0})}}const ye=C.getByProps("channels").channels.split(" ")[0],ve=C.getByProps("membersWrap").membersWrap.split(" ")[0];class Ce{static get shouldShowToasts(){return a["fork-ps-2"]}static async success(e,t={}){return this.show(e,Object.assign(t,{type:"success"}))}static async info(e,t={}){return this.show(e,Object.assign(t,{type:"info"}))}static async warning(e,t={}){return this.show(e,Object.assign(t,{type:"warning"}))}static async error(e,t={}){return this.show(e,Object.assign(t,{type:"error"}))}static async default(e,t={}){return this.show(e,Object.assign(t,{type:""}))}static show(e,t={}){const{type:s="",icon:n=!0,timeout:o=3e3,forceShow:r=!1}=t;if(!this.shouldShowToasts&&!r)return;this.ensureContainer();const i=document.createElement("div");i.classList.add("bd-toast"),s&&i.classList.add("toast-"+s),s&&n&&i.classList.add("icon"),i.innerText=e,document.querySelector(".bd-toasts").appendChild(i),setTimeout(()=>{i.classList.add("closing"),setTimeout(()=>{i.remove(),document.querySelectorAll(".bd-toasts .bd-toast").length||document.querySelector(".bd-toasts").remove()},300)},o)}static ensureContainer(){if(document.querySelector(".bd-toasts"))return;const e=document.querySelector(`.${ye} + div`),t=e.querySelector(`.${ve}`),s=e?e.querySelector("form"):null,n=e?e.getBoundingClientRect().left:310,o=t?t.getBoundingClientRect().left:0,r=o?o-e.getBoundingClientRect().left:e.offsetWidth,i=s?s.offsetHeight:80,a=document.createElement("div");a.classList.add("bd-toasts"),a.style.setProperty("left",n+"px"),a.style.setProperty("width",r+"px"),a.style.setProperty("bottom",i+"px"),document.querySelector("#app-mount").appendChild(a)}}class we extends L.Component{constructor(e){super(e),this.setInitialState(),this.onChange=this.onChange.bind(this),this.reload=this.reload.bind(this)}setInitialState(){this.state={checked:d[this.props.theme.name],reloads:0}}onReload(e){e===this.props.theme.name&&this.setState({reloads:this.state.reloads+1})}reload(){const e=this.props.theme.name;B.reloadTheme(e)?Ce.show(`Could not reload ${u[e].name}. Check console for details.`,{type:"error"}):Ce.show(`${u[e].name} v${u[e].version} has been reloaded.`,{type:"success"}),this.props.theme=u[e],this.onReload(this.props.theme.name)}render(){const{theme:e}=this.props,t=e.name,s=e.description,n=e.version,o=e.author,r=u[t].website,i=u[t].source;return L.createElement("li",{"data-name":t,"data-version":n,className:"settings-closed ui-switch-item"},L.createElement("div",{className:"bda-header"},L.createElement("span",{className:"bda-header-title"},L.createElement("span",{className:"bda-name"},t)," v",L.createElement("span",{className:"bda-version"},n)," by ",L.createElement("span",{className:"bda-author"},o)),L.createElement("div",{className:"bda-controls"},!a["fork-ps-5"]&&L.createElement(fe,{className:"bd-reload-card",onClick:this.reload}),L.createElement("label",{className:"ui-switch-wrapper ui-flex-child",style:{flex:"0 0 auto"}},L.createElement("input",{checked:this.state.checked,onChange:this.onChange,className:"ui-switch-checkbox",type:"checkbox"}),L.createElement("div",{className:this.state.checked?"ui-switch checked":"ui-switch"})))),L.createElement("div",{className:"bda-description-wrap scroller-wrap fade"},L.createElement("div",{className:"bda-description scroller"},s)),(r||i)&&L.createElement("div",{className:"bda-footer"},L.createElement("span",{className:"bda-links"},r&&L.createElement("a",{className:"bda-link",href:r,target:"_blank"},"Website"),r&&i&&" | ",i&&L.createElement("a",{className:"bda-link",href:i,target:"_blank"},"Source"))))}onChange(){this.setState({checked:!this.state.checked}),B.toggleTheme(this.props.theme.name)}}class Ee extends L.Component{constructor(e){super(e),this.onClick=this.onClick.bind(this),this.setInitialState()}setInitialState(){this.state={checked:this.props.checked||!1}}render(){return L.createElement("li",null,L.createElement("div",{className:"checkbox checkbox-3kaeSU da-checkbox checkbox-3EVISJ da-checkbox",onClick:this.onClick},L.createElement("div",{className:"checkbox-inner checkboxInner-3yjcPe da-checkboxInner"},L.createElement("input",{className:"checkboxElement-1qV33p da-checkboxElement",checked:this.state.checked,onChange:()=>{},type:"checkbox"}),L.createElement("span",null)),L.createElement("span",null,this.props.text)))}onClick(){this.props.onChange(this.props.id,!this.state.checked),this.setState({checked:!this.state.checked})}}class Se extends y.React.Component{constructor(e){super(e),this.onClick=this.onClick.bind(this),this.updateCss=this.updateCss.bind(this),this.saveCss=this.saveCss.bind(this),this.onChange=this.onChange.bind(this)}componentDidMount(){$("#app-mount").addClass("bd-detached-editor"),Oe.editorDetached=!0,this.editor=ace.edit("bd-customcss-editor-detached"),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",()=>{a["bda-css-0"]&&(this.saveCss(),this.updateCss())})}componentWillUnmount(){$("#app-mount").removeClass("bd-detached-editor"),Oe.editorDetached=!1,this.editor.destroy()}updateLineCount(){const e=this.refs.editor.value.split("\n").length;e!=this.props.lines&&(this.refs.lines.textContent=Array.from(new Array(e),(e,t)=>t+1).join(".\n")+".",this.props.lines=e)}get options(){return{lineNumbers:!0,mode:"css",indentUnit:4,theme:"material",scrollbarStyle:"simple"}}get css(){const e=k.getBDData("bdcustomcss");let t="";return e&&""!==e&&(t=atob(e)),t}get root(){const e=$("#bd-customcss-detach-container");return e.length?e[0]:this.injectRoot()?this.detachedRoot:null}injectRoot(){return!!$(".app, .app-2rEoOp").length&&($("<div/>",{id:"bd-customcss-detach-container"}).insertAfter($(".app, .app-2rEoOp")),!0)}render(){const e=this;return y.React.createElement("div",{className:"bd-detached-css-editor",id:"bd-customcss-detach-editor"},y.React.createElement("div",{id:"bd-customcss-innerpane"},y.React.createElement("div",{className:"editor-wrapper"},y.React.createElement("div",{id:"bd-customcss-editor-detached",className:"editor",ref:"editor"},e.css)),y.React.createElement("div",{id:"bd-customcss-attach-controls"},y.React.createElement("ul",{className:"checkbox-group"},y.React.createElement(Ee,{id:"live-update",text:"Live Update",onChange:e.onChange,checked:a["bda-css-0"]})),y.React.createElement("div",{id:"bd-customcss-detach-controls-button"},y.React.createElement("button",{style:{borderRadius:"3px 0 0 3px",borderRight:"1px solid #3f4146"},className:"btn btn-primary",onClick:()=>{e.onClick("update")}},"Update"),y.React.createElement("button",{style:{borderRadius:"0",borderLeft:"1px solid #2d2d2d",borderRight:"1px solid #2d2d2d"},className:"btn btn-primary",onClick:()=>{e.onClick("save")}},"Save"),y.React.createElement("button",{style:{borderRadius:"0 3px 3px 0",borderLeft:"1px solid #3f4146"},className:"btn btn-primary",onClick:()=>{e.onClick("attach")}},"Attach"),y.React.createElement("span",{style:{fontSize:"10px",marginLeft:"5px"}},"Unsaved changes are lost on attach")))))}onChange(e,t){switch(e){case"live-update":a["bda-css-0"]=t,st.saveSettings()}}onClick(e){const t=this;switch(e){case"attach":$("#editor-detached").length&&t.props.attach(),y.ReactDOM.unmountComponentAtNode(t.root),t.root.remove();break;case"update":t.updateCss();break;case"save":t.saveCss()}}updateCss(){0==$("#customcss").length&&$("head").append('<style id="customcss"></style>'),$("#customcss").text(this.editor.session.getValue()).detach().appendTo(document.head)}saveCss(){k.setBDData("bdcustomcss",btoa(this.editor.session.getValue()))}}class ke extends y.React.Component{constructor(e){super(e),this.props.lines=0,this.setInitialState(),this.attach=this.attach.bind(this),this.detachedEditor=y.React.createElement(Se,{attach:this.attach}),this.onClick=this.onClick.bind(this),this.updateCss=this.updateCss.bind(this),this.saveCss=this.saveCss.bind(this),this.detach=this.detach.bind(this)}setInitialState(){this.state={detached:this.props.detached||Oe.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",()=>{a["bda-css-0"]&&(this.saveCss(),this.updateCss())})}componentWillUnmount(){this.editor.destroy()}componentDidUpdate(e,t){t.detached&&!this.state.detached&&y.ReactDOM.unmountComponentAtNode(this.detachedRoot)}codeMirror(){}get options(){return{lineNumbers:!0,mode:"css",indentUnit:4,theme:"material",scrollbarStyle:"simple"}}get css(){const e=k.getBDData("bdcustomcss");let t="";return e&&""!==e&&(t=atob(e)),t}updateLineCount(){const e=this.refs.editor.value.split("\n").length;e!=this.props.lines&&(this.refs.lines.textContent=Array.from(new Array(e),(e,t)=>t+1).join(".\n")+".",this.props.lines=e)}render(){const e=this,{detached:t}=e.state;return y.React.createElement("div",{className:"contentColumn-2hrIYH contentColumnDefault-1VQkGM content-column default",style:{padding:"60px 40px 0px"}},t&&y.React.createElement("div",{id:"editor-detached"},y.React.createElement(K,{text:"Custom CSS Editor"}),y.React.createElement("h3",null,"Editor Detached"),y.React.createElement("button",{className:"btn btn-primary",onClick:()=>{e.attach()}},"Attach")),!t&&y.React.createElement("div",null,y.React.createElement(K,{text:"Custom CSS Editor"}),y.React.createElement("div",{className:"editor-wrapper"},y.React.createElement("div",{id:"bd-customcss-editor",className:"editor",ref:"editor"},e.css)),y.React.createElement("div",{id:"bd-customcss-attach-controls"},y.React.createElement("ul",{className:"checkbox-group"},y.React.createElement(Ee,{id:"live-update",text:"Live Update",onChange:this.onChange,checked:a["bda-css-0"]})),y.React.createElement("div",{id:"bd-customcss-detach-controls-button"},y.React.createElement("button",{style:{borderRadius:"3px 0 0 3px",borderRight:"1px solid #3f4146"},className:"btn btn-primary",onClick:()=>{e.onClick("update")}},"Update"),y.React.createElement("button",{style:{borderRadius:"0",borderLeft:"1px solid #2d2d2d",borderRight:"1px solid #2d2d2d"},className:"btn btn-primary",onClick:()=>{e.onClick("save")}},"Save"),y.React.createElement("button",{style:{borderRadius:"0 3px 3px 0",borderLeft:"1px solid #3f4146"},className:"btn btn-primary",onClick:()=>{e.onClick("detach")}},"Detach"),y.React.createElement("span",{style:{fontSize:"10px",marginLeft:"5px"}},"Unsaved changes are lost on detach"),y.React.createElement("div",{className:"help-text"},"Press ",y.React.createElement("code",{className:"inline"},"ctrl"),"+",y.React.createElement("span",{className:"inline"},",")," with the editor focused to access the editor's settings.")))))}onClick(e){switch(e){case"update":this.updateCss();break;case"save":this.saveCss();break;case"detach":this.detach()}}onChange(e,t){switch(e){case"live-update":a["bda-css-0"]=t,st.saveSettings()}}updateCss(){0==$("#customcss").length&&$("head").append('<style id="customcss"></style>'),$("#customcss").text(this.editor.session.getValue()).detach().appendTo(document.head)}saveCss(){k.setBDData("bdcustomcss",btoa(this.editor.session.getValue()))}detach(){this.setState({detached:!0});const e=this.detachedRoot;e?y.ReactDOM.render(this.detachedEditor,e):console.log("FAILED TO INJECT ROOT: .app")}get detachedRoot(){const e=$("#bd-customcss-detach-container");return e.length?e[0]:this.injectDetachedRoot()?this.detachedRoot:null}injectDetachedRoot(){return!!$(".app, .app-2rEoOp").length&&($("<div/>",{id:"bd-customcss-detach-container"}).insertAfter($(".app, .app-2rEoOp")),!0)}attach(){this.setState({detached:!1})}}class xe{constructor(e){this.sideBarOnClick=this.sideBarOnClick.bind(this),this.onChange=e.onChange,this.sidebar=new q(this.sideBarOnClick)}get root(){const e=$("#bd-settingspane-container");return e.length?e[0]:this.injectRoot()?this.root:null}injectRoot(){if(!$(".layer-3QrUeG .standardSidebarView-3F1I7i, .layer-3QrUeG .ui-standard-sidebar-view").length)return!1;const e=$("<div/>",{class:"contentRegion-3nDuYy content-region",id:"bd-settingspane-container"});return $(".layer-3QrUeG .standardSidebarView-3F1I7i, .layer-3QrUeG .ui-standard-sidebar-view").append(e),b.onRemoved(e[0],()=>{G.unmountComponentAtNode(e[0])}),!0}get coreSettings(){const e=this.getSettings("core"),t=[...new Set(e.map(e=>e.category))].map(t=>({title:t,settings:e.filter(e=>e.category==t)}));return console.log(t),t}get emoteSettings(){return this.getSettings("emote")}getSettings(e){return Object.keys(i).reduce((t,s)=>{const n=i[s];return n.cat===e&&n.implemented&&!n.hidden&&(n.text=s,t.push(n)),t},[])}sideBarOnClick(e){const t=this;switch($(".contentRegion-3nDuYy, .content-region").first().hide(),$(t.root).show(),e){case"core":t.renderCoreSettings();break;case"emotes":t.renderEmoteSettings();break;case"customcss":t.renderCustomCssEditor();break;case"plugins":t.renderPluginPane();break;case"themes":t.renderThemePane()}}renderSidebar(){const e=this;$("[class*='side-'] > [class*='item-']").off("click.v2settingspanel").on("click.v2settingspanel",()=>{G.unmountComponentAtNode(e.root),$(e.root).hide(),$(".contentRegion-3nDuYy, .content-region").first().show()}),e.sidebar.render()}get core2(){return this.coreSettings.map(e=>L.createElement(ue,Object.assign({},e,{onChange:this.onChange})))}get coreComponent(){return L.createElement(_,{contentColumn:!0,fade:!0,dark:!0,children:[L.createElement(he,{key:"cspanel",onChange:this.onChange,sections:this.coreSettings}),L.createElement(me,{key:"tools"})]})}get emoteComponent(){return L.createElement(_,{contentColumn:!0,fade:!0,dark:!0,children:[L.createElement(ge,{key:"espanel",title:"Emote Settings",onChange:this.onChange,settings:this.emoteSettings,button:{title:"Clear Emote Cache",onClick:()=>{P.dispatch("emotes-clear")}}}),L.createElement(me,{key:"tools"})]})}get customCssComponent(){return L.createElement(_,{contentColumn:!0,fade:!0,dark:!0,children:[L.createElement(ke,{key:"csseditor"}),L.createElement(me,{key:"tools"})]})}contentComponent(e){const t="plugins"==e?this.pluginsComponent:this.themesComponent,s=e.replace("s",""),n=this;return L.createElement(class extends L.Component{constructor(e){super(e),this.onChange=this.onChange.bind(this)}componentDidMount(){P.on(`${s}-reloaded`,this.onChange),P.on(`${s}-loaded`,this.onChange),P.on(`${s}-unloaded`,this.onChange)}componentWillUnmount(){P.off(`${s}-reloaded`,this.onChange),P.off(`${s}-loaded`,this.onChange),P.off(`${s}-unloaded`,this.onChange)}onChange(){n.sideBarOnClick(e)}render(){return t}})}get pluginsComponent(){const e=Object.keys(h).sort((e,t)=>e.toLowerCase().localeCompare(t.toLowerCase())).reduce((e,t)=>(e.push(L.createElement(be,{key:t,plugin:h[t].plugin})),e),[]),t=L.createElement(J,{key:"plugin-list",className:"bda-slist",children:e}),n=!a["fork-ps-5"]&&L.createElement(fe,{className:"bd-reload-header",size:"18px",onClick:async()=>{N.updatePluginList(),this.sideBarOnClick("plugins")}}),o=L.createElement("button",{key:"folder-button",className:"bd-pfbtn",onClick:()=>{s(1).shell.openItem(A.pluginsFolder)}},"Open Plugin Folder"),r=L.createElement(Y,{key:"pcolumn",title:"Plugins",children:[n,o,t]});return L.createElement(_,{contentColumn:!0,fade:!0,dark:!0,children:[r,L.createElement(me,{key:"tools"})]})}get themesComponent(){const e=Object.keys(u).sort((e,t)=>e.toLowerCase().localeCompare(t.toLowerCase())).reduce((e,t)=>(e.push(L.createElement(we,{key:t,theme:u[t]})),e),[]),t=L.createElement(J,{key:"theme-list",className:"bda-slist",children:e}),n=!a["fork-ps-5"]&&L.createElement(fe,{className:"bd-reload-header",size:"18px",onClick:async()=>{B.updateThemeList(),this.sideBarOnClick("themes")}}),o=L.createElement("button",{key:"folder-button",className:"bd-pfbtn",onClick:()=>{s(1).shell.openItem(A.themesFolder)}},"Open Theme Folder"),r=L.createElement(Y,{key:"tcolumn",title:"Themes",children:[n,o,t]});return L.createElement(_,{contentColumn:!0,fade:!0,dark:!0,children:[r,L.createElement(me,{key:"tools"})]})}renderCoreSettings(){const e=this.root;e?G.render(this.coreComponent,e):console.log("FAILED TO LOCATE ROOT: .layer-3QrUeG .standardSidebarView-3F1I7i")}renderEmoteSettings(){const e=this.root;e?G.render(this.emoteComponent,e):console.log("FAILED TO LOCATE ROOT: .layer-3QrUeG .standardSidebarView-3F1I7i")}renderCustomCssEditor(){const e=this.root;e?G.render(this.customCssComponent,e):console.log("FAILED TO LOCATE ROOT: .layer-3QrUeG .standardSidebarView-3F1I7i")}renderPluginPane(){const e=this.root;e?G.render(this.contentComponent("plugins"),e):console.log("FAILED TO LOCATE ROOT: .layer-3QrUeG .standardSidebarView-3F1I7i")}renderThemePane(){const e=this.root;e?G.render(this.contentComponent("themes"),e):console.log("FAILED TO LOCATE ROOT: .layer-3QrUeG .standardSidebarView-3F1I7i")}}class Pe extends L.Component{constructor(e){super(e)}render(){const{sidebar:e,content:t,tools:s}=this.props.children;return L.createElement("div",{className:"standardSidebarView-3F1I7i ui-standard-sidebar-view"},L.createElement("div",{className:"sidebarRegion-VFTUkN sidebar-region"},L.createElement(_,{key:"sidebarScroller",ref:"sidebarScroller",sidebar:!0,fade:e.fade||!0,dark:e.dark||!0,children:e.component})),L.createElement("div",{className:"contentRegion-3nDuYy content-region"},L.createElement("div",{className:"contentTransitionWrap-3hqOEW content-transition-wrap"},L.createElement("div",{className:"scrollerWrap-2lJEkd firefoxFixScrollFlex-cnI2ix contentRegionScrollerWrap-3YZXdm content-region-scroller-wrap scrollerThemed-2oenus themeGhost-28MSn0 scrollerTrack-1ZIpsv"},L.createElement("div",{className:"scroller-2FKFPG firefoxFixScrollFlex-cnI2ix contentRegionScroller-26nc1e content-region-scroller scroller",ref:"contentScroller"},L.createElement("div",{className:"contentColumn-2hrIYH contentColumnDefault-1VQkGM content-column default"},t.component),s.component)))))}}class De extends L.Component{constructor(e){super(e),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(){const{server:e}=this.props;return L.createElement("div",{className:`card-3Qj_Yx cardPrimary-1Hv-to marginBottom8-AtZOdT bd-server-card${e.pinned?" bd-server-card-pinned":""}`},L.createElement("img",{ref:"img",className:"bd-server-image",src:e.iconUrl,onError:this.handleError.bind(this)}),L.createElement("div",{className:"flexChild-faoVW3 bd-server-content"},L.createElement("div",{className:"flex-1xMQg5 flex-1O1GKY horizontal-1ae9ci horizontal-2EEEnY directionRow-3v3tfG noWrap-3jynv6 bd-server-header"},L.createElement("h5",{className:"h5-18_1nd defaultColor-1_ajX0 margin-reset bd-server-name"},e.name),L.createElement("h5",{className:"h5-18_1nd defaultColor-1_ajX0 margin-reset bd-server-member-count"},e.members," Members")),L.createElement("div",{className:"flex-1xMQg5 flex-1O1GKY horizontal-1ae9ci horizontal-2EEEnY directionRow-3v3tfG noWrap-3jynv6"},L.createElement("div",{className:"scrollerWrap-2lJEkd scrollerThemed-2oenus themeGhostHairline-DBD-2d scrollerFade-1Ijw5y bd-server-description-container"},L.createElement("div",{className:"scroller-2FKFPG scroller bd-server-description"},e.description))),L.createElement("div",{className:"flex-1xMQg5 flex-1O1GKY horizontal-1ae9ci horizontal-2EEEnY directionRow-3v3tfG noWrap-3jynv6 bd-server-footer"},L.createElement("div",{className:"flexChild-faoVW3 bd-server-tags",style:{flex:"1 1 auto"}},e.categories.join(", ")),this.state.joined&&L.createElement("button",{type:"button",className:"button-38aScr lookFilled-1Gx00P colorBrand-3pXr91 sizeMin-1mJd1x grow-q77ONN colorGreen-29iAKY",style:{minHeight:"12px",marginTop:"4px",backgroundColor:"#3ac15c"}},L.createElement("div",{className:"ui-button-contents"},"Joined")),e.error&&L.createElement("button",{type:"button",className:"button-38aScr lookFilled-1Gx00P colorBrand-3pXr91 sizeMin-1mJd1x grow-q77ONN disabled-9aF2ug",style:{minHeight:"12px",marginTop:"4px",backgroundColor:"#c13a3a"}},L.createElement("div",{className:"ui-button-contents"},"Error")),!e.error&&!this.state.joined&&L.createElement("button",{type:"button",className:"button-38aScr lookFilled-1Gx00P colorBrand-3pXr91 sizeMin-1mJd1x grow-q77ONN",style:{minHeight:"12px",marginTop:"4px"},onClick:()=>{this.join()}},L.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 Ne extends L.Component{constructor(e){super(e),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=C.getByProps("getGuilds"),this.AvatarDefaults=C.getByProps("getUserAvatarURL","DEFAULT_AVATARS"),this.InviteActions=C.getByProps("acceptInvite"),this.SortedGuildStore=C.getByProps("getSortedGuilds")}componentDidMount(){this.checkConnection()}setInitialState(){this.state={selectedCategory:-1,title:"Loading...",loading:!0,servers:[],next:null,connection:{state:0,user:null}}}close(){G.unmountComponentAtNode(document.getElementById(this.props.rootId))}search(e,t){const s=this;$.ajax({method:"GET",url:`${s.endPoint}${e}${e?"&schema=new":"?schema=new"}`,success:e=>{let n=e.results.reduce((e,t)=>(t.joined=!1,e.push(t),e),[]);t||(n=s.state.servers.concat(n));let o=e.size+e.from;e.next=`?from=${o}`,s.state.term&&(e.next+=`&term=${s.state.term}`),s.state.selectedCategory&&(e.next+=`&category=${s.categoryButtons[s.state.selectedCategory]}`),o>=e.total&&(o=e.total,e.next=null);let r=`Showing 1-${o} of ${e.total} results in ${s.categoryButtons[s.state.selectedCategory]}`;s.state.term&&(r+=` for ${s.state.term}`),s.setState({loading:!1,title:r,servers:n,next:e.next}),t&&(s.refs.sbv.refs.contentScroller.scrollTop=0)},error:()=>{s.setState({loading:!1,title:"Failed to load servers. Check console for details"})}})}join(e){if(e.props.pinned)return this.InviteActions.acceptInvite(e.props.invite_code);$.ajax({method:"GET",url:`${this.joinEndPoint}/${e.props.server.identifier}`,headers:{Accept:"application/json;","Content-Type":"application/json;","x-discord-token":this.state.connection.user.accessToken},crossDomain:!0,xhrFields:{withCredentials:!0},success:()=>{e.setState({joined:!0})}})}connect(){const e=this.windowOptions;e.x=Math.round(window.screenX+window.innerWidth/2-e.width/2),e.y=Math.round(window.screenY+window.innerHeight/2-e.height/2),this.joinWindow=new(window.require("electron").remote.BrowserWindow)(e);this.joinWindow.webContents.on("did-navigate",(e,t)=>{"https://auth.discordservers.com/info"==t&&(this.joinWindow.close(),this.checkConnection())}),this.joinWindow.loadURL("https://auth.discordservers.com/connect?scopes=guilds.join&previousUrl=https://auth.discordservers.com/info")}get windowOptions(){return{width:500,height:550,backgroundColor:"#282b30",show:!0,resizable:!1,maximizable:!1,minimizable:!1,alwaysOnTop:!0,frame:!1,center:!1,webPreferences:{nodeIntegration:!1}}}get bdServer(){const e=this.SortedGuildStore.guildPositions,t=this.AvatarDefaults.DEFAULT_AVATARS;return L.createElement(De,{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:e,fallback:t[Math.floor(5*Math.random())]})}get endPoint(){return"https://search.discordservers.com"}get joinEndPoint(){return"https://j.discordservers.com"}get connectEndPoint(){return"https://join.discordservers.com/connect"}checkConnection(){const e=this;try{$.ajax({method:"GET",url:"https://auth.discordservers.com/info",headers:{Accept:"application/json;","Content-Type":"application/json;"},crossDomain:!0,xhrFields:{withCredentials:!0},success:t=>{e.setState({selectedCategory:0,connection:{state:2,user:t}}),e.search("",!0)},error:()=>{e.setState({title:"Not connected to discordservers.com!",loading:!0,selectedCategory:-1,connection:{state:1,user:null}})}})}catch(t){e.setState({title:"Not connected to discordservers.com!",loading:!0,selectedCategory:-1,connection:{state:1,user:null}})}}render(){return L.createElement(Pe,{ref:"sbv",children:this.component})}get component(){return{sidebar:{component:this.sidebar},content:{component:this.content},tools:{component:L.createElement(me,{key:"pt",ref:"tools",onClick:this.close})}}}get sidebar(){return L.createElement("div",{className:"sidebar",key:"ps"},L.createElement("div",{className:"ui-tab-bar SIDE"},L.createElement("div",{className:"ui-tab-bar-header",style:{fontSize:"16px"}},"Public Servers"),L.createElement(H.Separator,null),this.searchInput,L.createElement(H.Separator,null),L.createElement(H.Header,{text:"Categories"}),this.categoryButtons.map((e,t)=>L.createElement(H.Item,{id:t,onClick:this.changeCategory,key:t,text:e,selected:this.state.selectedCategory===t})),L.createElement(H.Separator,null),this.footer,this.connection))}get searchInput(){return L.createElement("div",{className:"ui-form-item"},L.createElement("div",{className:"ui-text-input flex-vertical",style:{width:"172px",marginLeft:"10px"}},L.createElement("input",{ref:"searchinput",onKeyDown:this.searchKeyDown,onChange:()=>{},type:"text",className:"input default",placeholder:"Search...",maxLength:"50"})))}searchKeyDown(e){const t=this;if(t.state.loading||13!==e.which)return;t.setState({loading:!0,title:"Loading...",term:e.target.value});let s=`?term=${e.target.value}`;0!==t.state.selectedCategory&&(s+=`&category=${t.categoryButtons[t.state.selectedCategory]}`),t.search(s,!0)}get categoryButtons(){return["All","FPS Games","MMO Games","Strategy Games","MOBA Games","RPG Games","Tabletop Games","Sandbox Games","Simulation Games","Music","Community","Language","Programming","Other"]}changeCategory(e){const t=this;t.state.loading||(t.refs.searchinput.value="",t.setState({loading:!0,selectedCategory:e,title:"Loading...",term:null}),0!==e?t.search(`?category=${t.categoryButtons[e]}`,!0):t.search("",!0))}get content(){const e=this,t=this.SortedGuildStore.guildPositions,s=this.AvatarDefaults.DEFAULT_AVATARS;return 1===e.state.connection.state?e.notConnected:[L.createElement("div",{ref:"content",key:"pc",className:"contentColumn-2hrIYH contentColumnDefault-1VQkGM content-column default"},L.createElement(K,{text:e.state.title}),e.bdServer,e.state.servers.map(n=>L.createElement(De,{key:n.identifier,server:n,join:e.join,guildList:t,fallback:s[Math.floor(5*Math.random())]})),e.state.next&&L.createElement("button",{type:"button",onClick:()=>{e.state.loading||(e.setState({loading:!0}),e.search(e.state.next,!1))},className:"ui-button filled brand small grow",style:{width:"100%",marginTop:"10px",marginBottom:"10px"}},L.createElement("div",{className:"ui-button-contents"},e.state.loading?"Loading":"Load More")),e.state.servers.length>0&&L.createElement(K,{text:e.state.title}))]}get notConnected(){return[L.createElement("div",{key:"ncc",ref:"content",className:"contentColumn-2hrIYH contentColumnDefault-1VQkGM content-column default"},L.createElement("h2",{className:"ui-form-title h2 margin-reset margin-bottom-20"},"Not connected to discordservers.com!",L.createElement("button",{onClick:this.connect,type:"button",className:"ui-button filled brand small grow",style:{display:"inline-block",minHeight:"18px",marginLeft:"10px",lineHeight:"14px"}},L.createElement("div",{className:"ui-button-contents"},"Connect"))),this.bdServer)]}get footer(){return L.createElement("div",{className:"ui-tab-bar-header"},L.createElement("a",{href:"https://discordservers.com",target:"_blank"},"Discordservers.com"))}get connection(){const{connection:e}=this.state;return 2!==e.state?L.createElement("span",null):L.createElement("span",null,L.createElement(H.Separator,null),L.createElement("span",{style:{color:"#b9bbbe",fontSize:"10px",marginLeft:"10px"}},"Connected as: ",`${e.user.username}#${e.user.discriminator}`),L.createElement("div",{style:{padding:"5px 10px 0 10px"}},L.createElement("button",{style:{width:"100%",minHeight:"20px"},type:"button",className:"ui-button filled brand small grow"},L.createElement("div",{className:"ui-button-contents",onClick:this.connect},"Reconnect"))))}}class Me extends L.Component{constructor(e){super(e)}componentDidMount(){$(window).on(`keyup.${this.props.id}`,e=>{27===e.which&&G.unmountComponentAtNode(this.refs.root.parentNode)}),$(`#${this.props.id}`).animate({opacity:1},{step:function(e){$(this).css("transform",`scale(${1.1-.1*e}) 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(e){$(this).css("transform",`scale(${1.1-.1*e}) translateZ(0px)`)},duration:200,done:()=>{$(`#${this.props.rootId}`).remove()}}),$('[class*="layer-"]').removeClass("publicServersOpen").animate({opacity:1},{step:function(e){$(this).css("transform",`scale(${.07*e+.93}) translateZ(0px)`)},duration:200,done:()=>{$('[class*="layer-"]').css("opacity","").css("transform","")}})}componentWillMount(){$('[class*="layer-"]').addClass("publicServersOpen").animate({opacity:0},{step:function(e){$(this).css("transform",`scale(${.07*e+.93}) translateZ(0px)`)},duration:200})}render(){return L.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 $e{static get shouldShowContentErrors(){return a["fork-ps-1"]}static get ModalStack(){return C.getByProps("push","update","pop","popWithKey")}static get AlertModal(){return C.getByPrototypes("handleCancel","handleSubmit","handleMinorConfirm")}static get TextElement(){return C.getByProps("Sizes","Weights")}static get ConfirmationModal(){return C.getModule(e=>e.defaultProps&&e.key&&"confirm-modal"==e.key())}static default(e,t){const s=$(`<div class="bd-modal-wrapper theme-dark">\n <div class="bd-backdrop backdrop-1wrmKB"></div>\n <div class="bd-modal modal-1UGdnR">\n <div class="bd-modal-inner inner-1JeGVc">\n <div class="header header-1R_AjF">\n <div class="title">${e}</div>\n </div>\n <div class="bd-modal-body">\n <div class="scroller-wrap fade">\n <div class="scroller">\n ${t}\n </div>\n </div>\n </div>\n <div class="footer footer-2yfCgX">\n <button type="button">Okay</button>\n </div>\n </div>\n </div>\n </div>`);s.find(".footer button").on("click",()=>{s.addClass("closing"),setTimeout(()=>{s.remove()},300)}),s.find(".bd-backdrop").on("click",()=>{s.addClass("closing"),setTimeout(()=>{s.remove()},300)}),s.appendTo("#app-mount")}static alert(e,t){if(this.ModalStack&&this.AlertModal)return this.default(e,t);this.ModalStack.push(function(s){return L.createElement(this.AlertModal,Object.assign({title:e,body:t},s))})}static showConfirmationModal(e,t,s={}){const n=this.TextElement,o=this.ConfirmationModal,r=this.ModalStack;if(!this.ModalStack||!this.ConfirmationModal||!this.TextElement)return this.alert(e,t);const{onConfirm:i,onCancel:a,confirmText:l,cancelText:c,danger:d=!1}=s;"string"==typeof t?t=n({color:n.Colors.PRIMARY,children:[t]}):Array.isArray(t)&&(t=n({color:n.Colors.PRIMARY,children:t})),t=[t];const u=()=>{};r.push(function(s){return L.createElement(o,Object.assign({header:e,children:t,red:d,confirmText:l||"Okay",cancelText:c||"Cancel",onConfirm:i||u,onCancel:a||u},s))})}static showContentErrors({plugins:e=[],themes:t=[]}){if(!e||!t||!this.shouldShowContentErrors)return;if(!e.length&&!t.length)return;const s=$('<div class="bd-modal-wrapper theme-dark">\n <div class="bd-backdrop backdrop-1wrmKB"></div>\n <div class="bd-modal bd-content-modal modal-1UGdnR">\n <div class="bd-modal-inner inner-1JeGVc">\n <div class="header header-1R_AjF"><div class="title">Content Errors</div></div>\n <div class="bd-modal-body">\n <div class="tab-bar-container">\n <div class="tab-bar TOP">\n <div class="tab-bar-item">Plugins</div>\n <div class="tab-bar-item">Themes</div>\n </div>\n </div>\n <div class="table-header">\n <div class="table-column column-name">Name</div>\n <div class="table-column column-message">Message</div>\n <div class="table-column column-error">Error</div>\n </div>\n <div class="scroller-wrap fade">\n <div class="scroller">\n\n </div>\n </div>\n </div>\n <div class="footer footer-2yfCgX">\n <button type="button">Okay</button>\n </div>\n </div>\n </div>\n </div>'),n=function(e){const t=$('<div class="errors">');for(const s of e){const e=$(`<div class="error">\n <div class="table-column column-name">${s.name?s.name:s.file}</div>\n <div class="table-column column-message">${s.message}</div>\n <div class="table-column column-error"><a class="error-link" href="">${s.error?s.error.message:""}</a></div>\n </div>`);t.append(e),s.error&&e.find("a").on("click",e=>{e.preventDefault(),b.err("ContentManager",`Error details for ${s.name?s.name:s.file}.`,s.error)})}return t},o=[n(e),n(t)];s.find(".tab-bar-item").on("click",e=>{e.preventDefault(),s.find(".tab-bar-item").removeClass("selected"),$(e.target).addClass("selected"),s.find(".scroller").empty().append(o[$(e.target).index()])}),s.find(".footer button").on("click",()=>{s.addClass("closing"),setTimeout(()=>{s.remove()},300)}),s.find(".bd-backdrop").on("click",()=>{s.addClass("closing"),setTimeout(()=>{s.remove()},300)}),s.appendTo("#app-mount"),e.length?s.find(".tab-bar-item")[0].click():s.find(".tab-bar-item")[1].click()}}const Be={get React(){return y.React},get ReactDOM(){return y.ReactDOM},get WindowConfigFile(){if(this._windowConfigFile)return this._windowConfigFile;const e=s(1).remote.app,t=s(2),n=e.getAppPath(),o=e.getPath("userData"),r=t.resolve(o,e.getVersion(),"modules","discord_desktop_core","injector","config.json"),i=t.resolve(n,"..","app","config.json"),a=s(0),l=a.existsSync(i)?i:a.existsSync(r)?r:null;return this._windowConfigFile=l||null},getAllWindowPreferences:function(){return this.WindowConfigFile?require(this.WindowConfigFile):{}},getWindowPreference:function(e){if(this.WindowConfigFile)return this.getAllWindowPreferences()[e]},setWindowPreference:function(e,t){if(!this.WindowConfigFile)return;const n=s(0),o=this.getAllWindowPreferences();o[e]=t,delete s.c[this.WindowConfigFile],n.writeFileSync(this.WindowConfigFile,JSON.stringify(o,null,4))},injectCSS:function(e,t){$("head").append($("<style>",{id:b.escapeID(e),text:t}))},clearCSS:function(e){$("#"+b.escapeID(e)).remove()},linkJS:function(e,t){$("head").append($("<script>",{id:b.escapeID(e),src:t,type:"text/javascript"}))},unlinkJS:function(e){$("#"+b.escapeID(e)).remove()},getPlugin:function(e){return h.hasOwnProperty(e)?h[e].plugin:null},alert:function(e,t){$e.alert(e,t)},showConfirmationModal:function(e,t,s={}){return $e.showConfirmationModal(e,t,s)},showToast:function(e,t={}){Ce.show(e,t)},findModule:function(e){return C.getModule(e)},findAllModules:function(e){return C.getModule(e,!1)},findModuleByProps:function(...e){return C.getByProps(...e)},findModuleByPrototypes:function(...e){return C.getByPrototypes(...e)},findModuleByDisplayName:function(e){return C.getByDisplayName(e)},getInternalInstance:function(e){if(e instanceof window.jQuery||e instanceof Element)return e instanceof jQuery&&(e=e[0]),b.getInternalInstance(e)},loadData:function(e,t){return k.getPluginData(e,t)}};Be.getData=Be.loadData,Be.saveData=function(e,t,s){return k.setPluginData(e,t,s)},Be.setData=Be.saveData,Be.deleteData=function(e,t){return k.deletePluginData(e,t)},Be.monkeyPatch=function(e,t,s){return b.monkeyPatch(e,t,s)},Be.onRemoved=function(e,t){return b.onRemoved(e,t)},Be.suppressErrors=function(e,t){return b.suppressErrors(e,t)},Be.testJSON=function(e){return b.testJSON(e)},Be.isPluginEnabled=function(e){return!!c[e]},Be.isThemeEnabled=function(e){return!!d[e]},Be.isSettingEnabled=function(e){return!!a[e]},Be.getBDData=function(e){return k.getBDData(e)},Be.setBDData=function(e,t){return k.setBDData(e,t)};var Te=Be;class je extends L.Component{render(){return L.createElement("svg",{height:"100%",width:this.props.size||"16px",className:"bd-logo "+this.props.className,style:{fillRule:"evenodd",clipRule:"evenodd",strokeLinecap:"round",strokeLinejoin:"round"},viewBox:"0 0 2000 2000"},L.createElement("metadata",null),L.createElement("defs",null,L.createElement("filter",{id:"shadow1"},L.createElement("feDropShadow",{dx:"20",dy:"0",stdDeviation:"20","flood-color":"rgba(0,0,0,0.35)"})),L.createElement("filter",{id:"shadow2"},L.createElement("feDropShadow",{dx:"15",dy:"0",stdDeviation:"20","flood-color":"rgba(255,255,255,0.15)"})),L.createElement("filter",{id:"shadow3"},L.createElement("feDropShadow",{dx:"10",dy:"0",stdDeviation:"20","flood-color":"rgba(0,0,0,0.35)"}))),L.createElement("g",null,L.createElement("path",{style:{filter:"url(#shadow3)"},d:"M1195.44+135.442L1195.44+135.442L997.6+136.442C1024.2+149.742+1170.34+163.542+1193.64+179.742C1264.34+228.842+1319.74+291.242+1358.24+365.042C1398.14+441.642+1419.74+530.642+1422.54+629.642L1422.54+630.842L1422.54+632.042C1422.54+773.142+1422.54+1228.14+1422.54+1369.14L1422.54+1370.34L1422.54+1371.54C1419.84+1470.54+1398.24+1559.54+1358.24+1636.14C1319.74+1709.94+1264.44+1772.34+1193.64+1821.44C1171.04+1837.14+1025.7+1850.54+1000+1863.54L1193.54+1864.54C1539.74+1866.44+1864.54+1693.34+1864.54+1296.64L1864.54+716.942C1866.44+312.442+1541.64+135.442+1195.44+135.442Z",fill:"#171717",opacity:"1"}),L.createElement("path",{style:{filter:"url(#shadow2)"},d:"M1695.54+631.442C1685.84+278.042+1409.34+135.442+1052.94+135.442L361.74+136.442L803.74+490.442L1060.74+490.442C1335.24+490.442+1335.24+835.342+1060.74+835.342L1060.74+1164.84C1150.22+1164.84+1210.53+1201.48+1241.68+1250.87C1306.07+1353+1245.76+1509.64+1060.74+1509.64L361.74+1863.54L1052.94+1864.54C1409.24+1864.54+1685.74+1721.94+1695.54+1368.54C1695.54+1205.94+1651.04+1084.44+1572.64+999.942C1651.04+915.542+1695.54+794.042+1695.54+631.442Z",fill:"#3E82E5",opacity:"1"}),L.createElement("path",{style:{filter:"url(#shadow1)"},d:"M1469.25+631.442C1459.55+278.042+1183.05+135.442+826.65+135.442L135.45+135.442L135.45+1004C135.45+1004+135.427+1255.21+355.626+1255.21C575.825+1255.21+575.848+1004+575.848+1004L577.45+490.442L834.45+490.442C1108.95+490.442+1108.95+835.342+834.45+835.342L664.65+835.342L664.65+1164.84L834.45+1164.84C923.932+1164.84+984.244+1201.48+1015.39+1250.87C1079.78+1353+1019.47+1509.64+834.45+1509.64L135.45+1509.64L135.45+1864.54L826.65+1864.54C1182.95+1864.54+1459.45+1721.94+1469.25+1368.54C1469.25+1205.94+1424.75+1084.44+1346.35+999.942C1424.75+915.542+1469.25+794.042+1469.25+631.442Z",fill:"#FFFFFF",opacity:"1"})))}}var Oe=new class{constructor(){this.editorDetached=!1}initialize(){Te.suppressErrors(this.patchSocial.bind(this),"BD Social Patch")(),Te.suppressErrors(this.patchGuildPills.bind(this),"BD Guild Pills Patch")(),Te.suppressErrors(this.patchGuildListItems.bind(this),"BD Guild List Items Patch")(),Te.suppressErrors(this.patchGuildSeparator.bind(this),"BD Guild Separator Patch")()}get messageClasses(){return C.getByProps("message","containerCozy")}get guildClasses(){const e=C.getByProps("wrapper","unreadMentionsBar"),t=C.getByProps("guildsError","selected"),s=C.getByProps("blobContainer");return Object.assign({},e,t,s)}get MessageContentComponent(){return C.getModule(e=>e.defaultProps&&e.defaultProps.hasOwnProperty("disableButtons"))}get TimeFormatter(){return C.getByProps("dateFormat")}get TooltipWrapper(){return C.getByDisplayName("TooltipDeprecated")}get NativeModule(){return C.getByProps("setBadge")}get Tooltips(){return C.getModule(e=>e.hide&&e.show&&!e.search&&!e.submit&&!e.search&&!e.activateRagingDemon&&!e.dismiss)}get KeyGenerator(){return C.getModule(e=>e.toString&&/"binary"/.test(e.toString()))}patchSocial(){if(this.socialPatch)return;const e=Te.findModule(e=>"TabBar"==e.displayName),t=Te.findModule(e=>"Anchor"==e.displayName);e&&t&&(this.socialPatch=Te.monkeyPatch(e.prototype,"render",{after:e=>{const s=e.returnValue.props.children;if(!s||!s.length)return;if("Separator"!==s[s.length-2].type.displayName)return;if(!s[s.length-1].type.toString().includes("socialLinks"))return;const n=s[s.length-1].type;s[s.length-1].type=function(){const e=n(...arguments);return e.props.children.push(Te.React.createElement(t,{className:"bd-social-link",href:"https://github.com/rauenzi/BetterDiscordApp",rel:"author",title:"BandagedBD",target:"_blank"},Te.React.createElement(je,{size:"16px",className:"bd-social-logo"}))),e}}}))}patchGuildListItems(){if(this.guildListItemsPatch)return;const e=this.guildClasses.listItem.split(" ")[0],t=this.guildClasses.blobContainer.split(" ")[0],s=Te.getInternalInstance(document.querySelector(`.${e} .${t}`).parentElement).return.type;s&&(this.guildListItemsPatch=Te.monkeyPatch(s.prototype,"render",{after:e=>{const t=e.returnValue,s=e.thisObject.props;return t.props.className+=" bd-guild",s.unread&&(t.props.className+=" bd-unread"),s.selected&&(t.props.className+=" bd-selected"),s.audio&&(t.props.className+=" bd-audio"),s.video&&(t.props.className+=" bd-video"),s.badge&&(t.props.className+=" bd-badge"),s.animatable&&(t.props.className+=" bd-animatable"),t}}))}patchGuildPills(){if(this.guildPillPatch)return;const e=Te.findModule(e=>e.default&&e.default.toString&&e.default.toString().includes("translate3d"));e&&(this.guildPillPatch=Te.monkeyPatch(e,"default",{after:e=>{const t=e.methodArguments[0];return t.unread&&(e.returnValue.props.className+=" bd-unread"),t.selected&&(e.returnValue.props.className+=" bd-selected"),t.hovered&&(e.returnValue.props.className+=" bd-hovered"),e.returnValue}}))}patchGuildSeparator(){if(this.guildSeparatorPatch)return;const e=Te.findModuleByDisplayName("Guilds"),t=Te.findModuleByProps("renderListItem");if(!t||!e)return;const s=function(){const e=t.Separator(...arguments);return e.props.className+=" bd-guild-separator",e};this.guildSeparatorPatch=Te.monkeyPatch(e.prototype,"render",{after:e=>{e.returnValue.props.children[1].props.children[3].type=s}})}},Fe=new class{constructor(){this.renderer=new xe({onChange:this.updateSettings.bind(this)})}renderSidebar(){this.renderer.renderSidebar()}initialize(){if(k.initialize(),!k.getSettingGroup("settings"))return this.saveSettings();const e=this.loadSettings();$('<style id="customcss">').text(atob(k.getBDData("bdcustomcss"))).appendTo(document.head);for(const t in e)void 0!==e[t]&&(a[t]=e[t]);this.saveSettings(),this.patchSections()}async patchSections(){const e=await this.getUserSettings();b.monkeyPatch(e.prototype,"generateSections",{after:e=>{console.log(e),e.returnValue.splice(23,0,{section:"DIVIDER"}),e.returnValue.splice(24,0,{section:"HEADER",label:"BandagedBD"}),e.returnValue.splice(25,0,{section:"BBD Settings",label:"Settings",element:()=>this.renderer.core2}),e.returnValue.splice(26,0,{section:"BBD Test",label:"Test Tab",onClick:function(){Ce.success("This can just be a click listener!",{forceShow:!0})}})}});const t=C.getByProps("standardSidebarView").standardSidebarView.split(" ")[0],s=document.querySelector(`.${t}`);b.getInternalInstance(s).return.return.return.return.return.return.stateNode.forceUpdate()}getUserSettings(){return new Promise(e=>{const t=b.monkeyPatch(C.getByProps("getUserSettingsSections").default.prototype,"render",{after:s=>{e(s.returnValue.type),s.thisObject.forceUpdate(),t()}})})}saveSettings(){k.setSettingGroup("settings",a)}loadSettings(){return k.getSettingGroup("settings")}updateSettings(e,t){P.dispatch("setting-updated","Modules",e,t),a[e]=t,"fork-ps-5"==e&&(t?(A.watchContent("plugin"),A.watchContent("theme")):(A.unwatchContent("plugin"),A.unwatchContent("theme"))),"fork-wp-1"==e&&(Te.setWindowPreference("transparent",t),t?Te.setWindowPreference("backgroundColor",null):Te.setWindowPreference("backgroundColor","#2f3136")),this.saveSettings()}initializeSettings(){a["fork-ps-5"]&&(A.watchContent("plugin"),A.watchContent("theme")),this.saveSettings()}};function Re(e,t,s,n){const o=(o,r,i)=>{e===o&&r===t&&(i?s():n())};return P.on("setting-updated",o),()=>{P.off("setting-updated",o)}}class Ie{get name(){return"Unnamed Builtin"}get category(){return"Modules"}get id(){return"None"}async initialize(){a[this.id]&&await this.enable(),P.on("setting-updated",(e,t,s)=>{e===this.category&&t===this.id&&(s?this.enable():this.disable())})}async enable(){this.log("Enabled"),await this.enabled()}async disable(){this.log("Disabled"),await this.disabled()}async enabled(){}async disabled(){}log(...e){b.log(this.name,...e)}warn(...e){b.warn(this.name,...e)}error(...e){b.err(this.name,...e)}}var Ae=new class extends Ie{get name(){return"VoiceMode"}get category(){return"Modules"}get id(){return"bda-gs-4"}enabled(){$(".scroller.guild-channels ul").first().css("display","none"),$(".scroller.guild-channels header").first().css("display","none"),$(".app.flex-vertical, .app-2rEoOp").first().css("overflow","hidden"),$(".chat-3bRxxu").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")}disabled(){$(".scroller.guild-channels ul").first().css("display",""),$(".scroller.guild-channels header").first().css("display",""),$(".app.flex-vertical, .app-2rEoOp").first().css("overflow",""),$(".chat-3bRxxu").first().css("visibility","").css("min-width",""),$(".flex-vertical.channels-wrap").first().css("flex-grow",""),$(".guild-header .btn.btn-hamburger").first().css("visibility","")}};const Le=new RegExp("^(?!da-)((?:[A-Za-z]|[0-9]|-)+)-(?:[A-Za-z]|[0-9]|-|_){6}$");var Ge=new class extends Ie{get id(){return"fork-ps-4"}get category(){return"Modules"}get name(){return"ClassNormalizer"}enabled(){this.hasPatched||(this.patchClassModules(C.getModules(this.moduleFilter.bind(this))),this.normalizeElement(document.querySelector("#app-mount")),this.hasPatched=!0)}disabled(){this.hasPatched&&(this.unpatchClassModules(C.getModules(this.moduleFilter.bind(this))),this.revertElement(document.querySelector("#app-mount")),this.hasPatched=!1)}patchClassModules(e){for(const t of e)this.patchClassModule("da",t)}unpatchClassModules(e){for(const t of e)this.unpatchClassModule("da",t)}shouldIgnore(e){return!isNaN(e)||(!!(e.endsWith("px")||e.endsWith("ch")||e.endsWith("em")||e.endsWith("ms"))||(!!e.startsWith("layerContainer-")||(!(!e.startsWith("#")||7!=e.length&&4!=e.length)||!(!e.includes("calc(")&&!e.includes("rgba")))))}moduleFilter(e){if("object"!=typeof e||Array.isArray(e))return!1;if(e.__esModule)return!1;if(!Object.keys(e).length)return!1;for(const t in e){const s=e[t];if("string"!=typeof s)return!1;if(!this.shouldIgnore(s)){if(1===s.split("-").length)return!1;if(!Le.test(s.split(" ")[0]))return!1}}return!0}patchClassModule(e,t){for(const s in t){const n=t[s];if(this.shouldIgnore(n))continue;const o=n.split(" ");for(const n of o){const o=n.match(Le)[1];if(!o)continue;const r=o.split("-").map((e,t)=>t?e[0].toUpperCase()+e.slice(1):e).join("");t[s]+=` ${e}-${r}`}}}unpatchClassModule(e,t){for(const s in t){const n=t[s];if(this.shouldIgnore(n))continue;let o="";const r=n.split(" ");for(const t of r)t.startsWith(`${e}-`)||(o+=` ${t}`);t[s]=o.trim()}}normalizeElement(e){if(!(e instanceof Element))return;const t=e.classList;for(let s=0,n=t.length;s<n;s++){if(!Le.test(t[s]))continue;const n=t[s].match(Le)[1].split("-").map((e,t)=>t?e[0].toUpperCase()+e.slice(1):e).join("");e.classList.add(`da-${n}`)}for(const t of e.children)this.normalizeElement(t)}revertElement(e){if(!(e instanceof Element))return;e.children&&e.children.length&&this.revertElement(e.children[0]),e.nextElementSibling&&this.revertElement(e.nextElementSibling);const t=e.classList,s=[];for(let e=0;e<t.length;e++)t[e].startsWith("da-")&&s.push(t[e]);e.classList.remove(...s)}},Ve=new class extends Ie{get name(){return"DeveloperMode"}get category(){return"Modules"}get id(){return"bda-gs-8"}get selectorModeID(){return"fork-dm-1"}get selectorMode(){return a[this.selectorModeID]}constructor(){super(),this.enableSelectors=this.enableSelectors.bind(this),this.disableSelectors=this.disableSelectors.bind(this)}enabled(){$(window).on("keydown.bdDevmode",e=>{119!==e.which&&118!=e.which||this.log("Debugger Activated")}),this.selectorMode&&this.enableSelectors(),this.selectorCancel=Re(this.category,this.selectorModeID,this.enableSelectors,this.disableSelectors)}disabled(){$(window).off("keydown.bdDevmode"),this.selectorMode&&this.disableSelectors(),this.selectorCancel&&this.selectorCancel()}enableSelectors(){$(document).on("contextmenu.bdDevmode",e=>{this.lastSelector=this.getSelector(e.toElement);setImmediate(()=>{let t=$(".contextMenu-HLZMGh");t.length<=0&&((t=$('<div class="contextMenu-HLZMGh bd-context-menu"></div>')).addClass($(".app, .app-2rEoOp").hasClass("theme-dark")?"theme-dark":"theme-light"),t.appendTo(".app, .app-2rEoOp"),t.css("top",e.clientY),t.css("left",e.clientX),$(document).on("click.bdDevModeCtx",()=>{t.remove(),$(document).off(".bdDevModeCtx")}),$(document).on("contextmenu.bdDevModeCtx",()=>{t.remove(),$(document).off(".bdDevModeCtx")}),$(document).on("keyup.bdDevModeCtx",e=>{27===e.keyCode&&(t.remove(),$(document).off(".bdDevModeCtx"))}));const s=$("<div/>",{class:"itemGroup-1tL0uz"}),n=$("<div/>",{class:"item-1Yvehc",click:()=>{y.ElectronModule.copy(this.lastSelector),t.hide()}}).append($("<span/>",{text:"Copy Selector"}));s.append(n),t.append(s),t.hasClass("undefined")&&t.css("top","-="+s.outerHeight())}),e.stopPropagation()})}disableSelectors(){$(document).off("contextmenu.bdDevmode"),$(document).off("contextmenu.bdDevModeCtx")}getRules(e,t=e.ownerDocument.styleSheets){return[...t].filter(e=>!e.href||!e.href.includes("BetterDiscordApp")).map(e=>[...e.cssRules||[]]).flat().filter(t=>t&&t.selectorText&&e.matches(t.selectorText)&&t.style.length&&t.selectorText.split(", ").length<8&&!t.selectorText.split(", ").includes("*"))}getSelector(e){if(e.id)return`#${e.id}`;const t=this.getRules(e),s=t[t.length-1];return s?s.selectorText:e.classList.length?`.${Array.from(e.classList).join(".")}`:`.${Array.from(e.parentElement.classList).join(".")}`}},Ue=new class extends Ie{get name(){return"PublicServers"}get category(){return"Modules"}get id(){return"bda-gs-1"}enabled(){const e=Oe.guildClasses.wrapper.split(" ")[0];$(`.${e} .scroller-2FKFPG >:first-child`).after(this.button)}disabled(){$("#bd-pub-li").remove()}get component(){return y.React.createElement(n.Layer,{rootId:"pubslayerroot",id:"pubslayer"},y.React.createElement(n.Menu,{rootId:"pubslayerroot"}))}get root(){const e=document.getElementById("pubslayerroot");return e||(this.injectRoot()?this.root:null)}injectRoot(){return!!$(".layers, .layers-3iHuyZ").length&&($(".layers, .layers-3iHuyZ").append($("<div/>",{id:"pubslayerroot"})),!0)}render(){const e=this.root;e?y.ReactDOM.render(this.component,e):console.log("FAILED TO LOCATE ROOT: .layers")}get button(){return $("<div/>",{class:Oe.guildClasses.listItem,id:"bd-pub-li",style:a["bda-gs-1"]?"":"display: none;"}).append($("<div/>",{class:"wrapper-25eVIn "+Oe.guildClasses.circleButtonMask,text:"public",id:"bd-pub-button",click:()=>{this.render()}}))}},ze=new class extends Ie{get name(){return"DarkMode"}get category(){return"Modules"}get id(){return"bda-gs-5"}enabled(){$("#app-mount").addClass("bda-dark").addClass("bd-dark")}disabled(){$("#app-mount").removeClass("bda-dark").removeClass("bd-dark")}},He=new class extends Ie{get name(){return"MinimalMode"}get category(){return"Modules"}get id(){return"bda-gs-2"}get hideChannelsID(){return"bda-gs-3"}get hideChannels(){return a[this.hideChannelsID]}constructor(){super(),this.enableHideChannels=this.enableHideChannels.bind(this),this.disableHideChannels=this.disableHideChannels.bind(this)}enabled(){$("body").addClass("bd-minimal"),this.hideChannels&&this.enableHideChannels(),this.hideChannelCancel=Re(this.category,this.hideChannelsID,this.enableHideChannels,this.disableHideChannels)}disabled(){$("body").removeClass("bd-minimal"),this.hideChannels&&this.disableHideChannels(),this.hideChannelCancel&&this.hideChannelCancel()}enableHideChannels(){$("body").addClass("bd-minimal-chan")}disableHideChannels(){$("body").removeClass("bd-minimal-chan")}},We=new class extends Ie{get name(){return"24Hour"}get category(){return"Modules"}get id(){return"bda-gs-6"}enabled(){this.inject24Hour()}disabled(){this.cancel24Hour&&(this.cancel24Hour(),delete this.cancel24Hour)}inject24Hour(){if(this.cancel24Hour)return;const e=new RegExp("([0-9]{1,2}):([0-9]{1,2})\\s(AM|PM)"),t=t=>{const s=t.returnValue.match(e);if(s&&4===s.length)return"AM"===s[3]?t.returnValue=t.returnValue.replace(s[0],`${"12"===s[1]?"00":s[1].padStart(2,"0")}:${s[2]}`):t.returnValue=t.returnValue.replace(s[0],`${"12"===s[1]?"12":parseInt(s[1])+12}:${s[2]}`)},s=b.monkeyPatch(y.TimeFormatter,"calendarFormat",{after:t}),n=b.monkeyPatch(y.TimeFormatter,"dateFormat",{after:t});this.cancel24Hour=()=>{s(),n()}}};const qe=C.getModule(e=>e.defaultProps&&e.defaultProps.hasOwnProperty("disableButtons"));var _e=new class extends Ie{get name(){return"ColoredText"}get category(){return"Modules"}get id(){return"bda-gs-7"}enabled(){this.injectColoredText()}disabled(){this.cancelColoredText&&(this.cancelColoredText(),delete this.cancelColoredText)}injectColoredText(){this.cancelColoredText||(this.cancelColoredText=b.monkeyPatch(qe.prototype,"render",{after:e=>{b.monkeyPatch(e.returnValue.props,"children",{silent:!0,after:({returnValue:t})=>{const s=t.props.children[1],n=e.thisObject.props.message.colorString;return s&&n&&(s.props.style={color:n}),t}})}}))}removeColoredText(){document.querySelectorAll(".markup-2BOw-j").forEach(e=>{e.style.setProperty("color","")})}},Je=new class extends Ie{get name(){return"VoiceDisconnect"}get category(){return"Modules"}get id(){return"bda-dc-0"}constructor(){super(),this.beforeUnload=this.beforeUnload.bind(this)}enabled(){window.addEventListener("beforeunload",this.beforeUnload)}disabled(){window.removeEventListener("beforeunload",this.beforeUnload)}beforeUnload(){y.ChannelActions.selectVoiceChannel(null,null)}};const Ye=(e,t,s={})=>{const{onContextMenu:n,onClick:o}=s,r=$(`<div class="emote-container">\n <img class="emote-icon" alt="${e}" src="${t}" title="${e}">\n </div>`)[0];return n&&r.addEventListener("contextmenu",n),r.addEventListener("click",o),r};var Ze=new class extends Ie{get name(){return"EmoteMenu"}get category(){return"Modules"}get id(){return"bda-es-0"}get hideEmojisID(){return"bda-es-9"}get hideEmojis(){return a[this.hideEmojisID]}constructor(){super(),this.lastTab="bda-qem-emojis",this.favoriteEmotes={},this.qmeHeader=$('<div id="bda-qem">\n <button class="active" id="bda-qem-twitch">Twitch</button>\n <button id="bda-qem-favourite">Favourite</button>\n <button id="bda-qem-emojis">Emojis</buttond>\n</div>')[0];for(const e of this.qmeHeader.getElementsByTagName("button"))e.addEventListener("click",this.switchMenu.bind(this));this.teContainer=$('<div id="bda-qem-twitch-container">\n <div class="scroller-wrap scrollerWrap-2lJEkd fade">\n <div class="scroller scroller-2FKFPG">\n <div class="emote-menu-inner">\n\n </div>\n </div>\n </div>\n</div>')[0],this.teContainerInner=this.teContainer.querySelector(".emote-menu-inner"),this.faContainer=$('<div id="bda-qem-favourite-container">\n <div class="scroller-wrap scrollerWrap-2lJEkd fade">\n <div class="scroller scroller-2FKFPG">\n <div class="emote-menu-inner">\n\n </div>\n </div>\n </div>\n</div>')[0],this.faContainerInner=this.faContainer.querySelector(".emote-menu-inner"),this.observer=new MutationObserver(e=>{for(const t of e)this.observe(t)}),this.enableHideEmojis=this.enableHideEmojis.bind(this),this.disableHideEmojis=this.disableHideEmojis.bind(this),this.updateTwitchEmotes=this.updateTwitchEmotes.bind(this)}initialize(){super.initialize();const e=k.getBDData("bdfavemotes");""!==e&&null!==e&&(this.favoriteEmotes=JSON.parse(atob(e))),this.updateFavorites()}async enabled(){this.log("Starting to observe"),this.observer.observe(document.getElementById("app-mount"),{childList:!0,subtree:!0}),this.hideEmojiCancel=Re(this.category,this.hideEmojisID,this.enableHideEmojis,this.disableHideEmojis),this.hideEmojis&&this.enableHideEmojis(),r.emotesLoaded&&this.updateTwitchEmotes(),P.on("emotes-loaded",this.updateTwitchEmotes)}disabled(){P.off("emotes-loaded",this.updateTwitchEmotes),this.observer.disconnect(),this.disableHideEmojis(),this.hideEmojiCancel&&this.hideEmojiCancel()}async waitForEmotes(){if(!r.emotesLoaded)return new Promise(e=>{P.on("emotes-loaded",e)})}enableHideEmojis(){$(".emojiPicker-3m1S-j").addClass("bda-qme-hidden")}disableHideEmojis(){$(".emojiPicker-3m1S-j").removeClass("bda-qme-hidden")}insertEmote(e){const t=b.getTextArea();b.insertText(t[0]," "==t.val().slice(-1)?t.val()+e:t.val()+" "+e)}favContext(e){e.stopPropagation();const t=e.target.closest(".emote-container").children[0],s=$('<div id="removemenu" class="bd-context-menu context-menu theme-dark">Remove</div>');s.css({top:e.pageY-$("#bda-qem-favourite-container").offset().top,left:e.pageX-$("#bda-qem-favourite-container").offset().left}),$(t).parent().append(s),s.on("click",e=>{e.preventDefault(),e.stopPropagation(),$(t).remove(),delete this.favoriteEmotes[$(t).attr("title")],this.updateFavorites(),$(document).off("mousedown.emotemenu")}),$(document).on("mousedown.emotemenu",function(e){"removemenu"!=e.target.id&&($("#removemenu").remove(),$(document).off("mousedown.emotemenu"))})}switchMenu(e){let t="string"==typeof e?e:$(e.target).attr("id");"bda-qem-emojis"==t&&this.hideEmojis&&(t="bda-qem-favourite");const s=$("#bda-qem-twitch"),n=$("#bda-qem-favourite"),o=$("#bda-qem-emojis");switch(s.removeClass("active"),n.removeClass("active"),o.removeClass("active"),$(".emojiPicker-3m1S-j").hide(),$("#bda-qem-favourite-container").hide(),$("#bda-qem-twitch-container").hide(),t){case"bda-qem-twitch":s.addClass("active"),$("#bda-qem-twitch-container").show();break;case"bda-qem-favourite":n.addClass("active"),$("#bda-qem-favourite-container").show();break;case"bda-qem-emojis":o.addClass("active"),$(".emojiPicker-3m1S-j").show(),$(".emojiPicker-3m1S-j input").focus()}t&&(this.lastTab=t)}observe(e){if(!(e.addedNodes.length&&e.addedNodes[0]instanceof Element))return;const t=e.addedNodes[0];if(!t.classList.contains("popout-3sVMXz")||t.classList.contains("popoutLeft-30WmrD")||!t.getElementsByClassName("emojiPicker-3m1S-j").length)return;const s=$(t);this.hideEmojis?s.addClass("bda-qme-hidden"):s.removeClass("bda-qme-hidden"),s.prepend(this.qmeHeader),s.append(this.teContainer),s.append(this.faContainer),this.switchMenu(this.lastTab)}favorite(e,t){this.favoriteEmotes.hasOwnProperty(e)||(this.favoriteEmotes[e]=t),this.updateFavorites()}updateTwitchEmotes(){for(;this.teContainerInner.firstChild;)this.teContainerInner.firstChild.remove();for(const e in p.TwitchGlobal){if(!p.TwitchGlobal.hasOwnProperty(e))continue;const t=p.TwitchGlobal[e],s=Ye(e,t,{onClick:this.insertEmote.bind(this,e)});this.teContainerInner.append(s)}}updateFavorites(){for(;this.faContainerInner.firstChild;)this.faContainerInner.firstChild.remove();for(const e in this.favoriteEmotes){const t=this.favoriteEmotes[e],s=Ye(e,t,{onClick:this.insertEmote.bind(this,e),onContextMenu:this.favContext.bind(this)});this.faContainerInner.append(s)}k.setBDData("bdfavemotes",btoa(JSON.stringify(this.favoriteEmotes)))}},Ke=new class extends Ie{get name(){return"EmoteAutocapitalize"}get category(){return"Modules"}get id(){return"bda-es-4"}enabled(){$("body").off(".bdac"),$("body").on("keyup.bdac change.bdac paste.bdac",$(".channelTextArea-1LDbYG textarea:first"),()=>{const e=$(".channelTextArea-1LDbYG textarea:first").val();if(null==e)return;const t=e.split(" ").pop();if(t.length>3){if("danSgame"==t)return;const s=this.capitalize(t.toLowerCase());null!=s&&b.insertText(b.getTextArea()[0],e.replace(t,s))}})}disabled(){$("body").off(".bdac")}capitalize(e){const t=p.TwitchGlobal;for(const s in t)if(t.hasOwnProperty(s)&&e==(s+"").toLowerCase())return s}};class Qe extends y.React.Component{constructor(e){super(e);const t=!!(Ze&&Ze.favoriteEmotes&&Ze.favoriteEmotes[this.label]);this.state={shouldAnimate:!this.animateOnHover,isFavorite:t},this.onMouseEnter=this.onMouseEnter.bind(this),this.onMouseLeave=this.onMouseLeave.bind(this),this.onClick=this.onClick.bind(this)}get animateOnHover(){return a["fork-es-2"]}get label(){return this.props.modifier?`${this.props.name}:${this.props.modifier}`:this.props.name}get modifierClass(){return this.props.modifier?` emote${this.props.modifier}`:""}onMouseEnter(){!this.state.shouldAnimate&&this.animateOnHover&&this.setState({shouldAnimate:!0}),!this.state.isFavorite&&Ze.favoriteEmotes[this.label]?this.setState({isFavorite:!0}):this.state.isFavorite&&!Ze.favoriteEmotes[this.label]&&this.setState({isFavorite:!1})}onMouseLeave(){this.state.shouldAnimate&&this.animateOnHover&&this.setState({shouldAnimate:!1})}onClick(e){this.props.onClick&&this.props.onClick(e)}render(){return y.React.createElement(Oe.TooltipWrapper,{color:"black",position:"top",text:this.label,delay:750},y.React.createElement("div",{className:"emotewrapper"+(this.props.jumboable?" jumboable":""),onMouseEnter:this.onMouseEnter,onMouseLeave:this.onMouseLeave,onClick:this.onClick},y.React.createElement("img",{draggable:!1,className:"emote"+this.modifierClass+(this.props.jumboable?" jumboable":"")+(this.state.shouldAnimate?"":" stop-animation"),dataModifier:this.props.modifier,alt:this.label,src:this.props.url}),y.React.createElement("input",{className:"fav"+(this.state.isFavorite?" active":""),title:"Favorite!",type:"button",onClick:e=>{e.preventDefault(),e.stopPropagation(),this.state.isFavorite?(delete Ze.favoriteEmotes[this.label],Ze.updateFavorites()):Ze.favorite(this.label,this.props.url),this.setState({isFavorite:!this.state.isFavorite})}})))}}const Xe={TwitchGlobal:"bda-es-7",TwitchSubscriber:"bda-es-7",BTTV:"bda-es-2",FrankerFaceZ:"bda-es-1",BTTV2:"bda-es-2"};var et=new class extends Ie{get name(){return"Emotes"}get category(){return"Modules"}get id(){return""}get categories(){return Object.keys(Xe).filter(e=>a[Xe[e]])}get MessageContentComponent(){return C.getModule(e=>e.defaultProps&&e.defaultProps.hasOwnProperty("disableButtons"))}async initialize(){super.initialize()}disabled(){this.cancelEmoteRender||(this.cancelEmoteRender(),delete this.cancelEmoteRender)}patchMessageContent(){this.cancelEmoteRender||(this.cancelEmoteRender=b.monkeyPatch(this.MessageContentComponent.prototype,"render",{after:({returnValue:e})=>{b.monkeyPatch(e.props,"children",{silent:!0,after:({returnValue:e})=>{if(0==this.categories.length)return;const t=e.props.children[1];if(!t.props.children)return;const s=t.props.children[1];if(s&&s.length){for(let e=0;e<s.length;e++){const t=s[e];if("string"!=typeof t)continue;const n=t.split(/([^\s]+)([\s]|$)/g);for(let t=0,o=this.categories.length;t<o;t++)for(let o=0,r=n.length;o<r;o++){const r=n[o].split(":"),i=r[0];let l=r[1]?r[1]:"",c=l.slice(0);if(i.length<4||m.includes(i))continue;g.includes(l)&&a["bda-es-8"]||(l=""),f.includes(c)?l=c:c="";let d=this.categories[t];if("twitch"===c?p.TwitchGlobal[i]?d="TwitchGlobal":p.TwitchSubscriber[i]&&(d="TwitchSubscriber"):"bttv"===c?p.BTTV[i]?d="BTTV":p.BTTV2[i]&&(d="BTTV2"):"ffz"===c&&p.FrankerFaceZ[i]&&(d="FrankerFaceZ"),!p[d][i]||!a[Xe[d]])continue;const u=s[e].match(new RegExp(`([\\s]|^)${b.escape(l?i+":"+l:i)}([\\s]|$)`));if(!u)continue;const h=s[e].substring(0,u.index+u[1].length),v=s[e].substring(u.index+u[0].length-u[2].length);s[e]=h;const C=y.React.createElement(Qe,{name:i,url:p[d][i],modifier:l});s.splice(e+1,0,v),s.splice(e+1,0,C)}}if(s.every(e=>"string"==typeof e&&""==e.replace(/\s*/,"")||(!(!e.type||"BDEmote"!=e.type.name)||!!(e.props&&e.props.children&&e.props.children.props&&e.props.children.props.emojiName))))for(const e of s)"object"==typeof e&&("BDEmote"==e.type.name?e.props.jumboable=!0:e.props&&e.props.children&&e.props.children.props&&e.props.children.props.emojiName&&(e.props.children.props.jumboable=!0))}}})}}))}async loadEmoteData(e){const t=s(0),n=l.dataPath+"emote_data.json";if(t.existsSync(n)&&this.isCacheValid()){Ce.show("Loading emotes from cache.",{type:"info"}),b.log("Emotes","Loading emotes from local cache.");const s=await new Promise(e=>{t.readFile(n,"utf8",(t,s)=>{b.log("Emotes","Emotes loaded from cache."),t&&(s={}),e(s)})});let o=b.testJSON(s);o&&Object.assign(p,JSON.parse(s));for(const t in e)o=Object.keys(p[e[t].variable]).length>0;if(o)return Ce.show("Emotes successfully loaded.",{type:"success"}),r.emotesLoaded=!0,void P.dispatch("emotes-loaded");b.log("Emotes","Cache was corrupt, downloading..."),t.unlinkSync(n)}if(a["fork-es-3"]){Ce.show("Downloading emotes in the background do not reload.",{type:"info"});for(const t in e){await new Promise(e=>setTimeout(e,1e3));const s=await this.downloadEmotes(e[t]);p[e[t].variable]=s}Ce.show("All emotes successfully downloaded.",{type:"success"});try{t.writeFileSync(n,JSON.stringify(p),"utf8")}catch(e){b.err("Emotes","Could not save emote data.",e)}r.emotesLoaded=!0,P.dispatch("emotes-loaded")}}downloadEmotes(e){const t=s(5),n={url:e.url,timeout:e.timeout?e.timeout:5e3};return b.log("Emotes",`Downloading: ${e.variable} (${e.url})`),new Promise((s,o)=>{t(n,(t,n,r)=>{if(t)return b.err("Emotes","Could not download "+e.variable,t),e.backup?(e.url=e.backup,e.backup=null,e.backupParser&&(e.parser=e.backupParser),s(this.downloadEmotes(e))):o({});let i={};try{i=JSON.parse(r)}catch(t){return b.err("Emotes","Could not download "+e.variable,t),e.backup?(e.url=e.backup,e.backup=null,e.backupParser&&(e.parser=e.backupParser),s(this.downloadEmotes(e))):o({})}"function"==typeof e.parser&&(i=e.parser(i));for(const t in i)t.length<4||m.includes(t)?delete i[t]:i[t]=e.getEmoteURL(i[t]);s(i),b.log("Emotes","Downloaded: "+e.variable)})})}getBlacklist(){return new Promise(e=>{$.getJSON("https://rauenzi.github.io/BetterDiscordApp/data/emotefilter.json",function(t){e(m.push(...t.blacklist))})})}isCacheValid(){const e=k.getBDData("emoteCacheDays")||k.setBDData("emoteCacheDays",7)||7,t=new Date(k.getBDData("emoteCacheDate")||null),s=new Date;return!(Math.round(Math.abs((s.getTime()-t.getTime())/864e5))>e)||(k.setBDData("emoteCacheDate",s.toJSON()),!1)}clearEmoteData(){const e=s(0),t=l.dataPath+"emote_data.json";e.existsSync(t)&&e.unlinkSync(t),k.setBDData("emoteCacheDate",(new Date).toJSON());for(const e in p)Object.assign(p,{[e]:{}})}};function tt(){}tt.prototype.setConfig=function(e){Object.assign(l,e)},tt.prototype.init=async function(){if(l.version<l.minSupportedVersion)return void $e.alert("Not Supported","BetterDiscord v"+l.version+" (your version) is not supported by the latest js ("+l.bbdVersion+").<br><br> Please download the latest version from <a href='https://github.com/rauenzi/BetterDiscordApp/releases/latest' target='_blank'>GitHub</a>");const e=l.updater?l.updater.LatestVersion:l.latestVersion;e>l.version&&$e.alert("Update Available",`\n An update for BandagedBD is available (${e})! Please Reinstall!<br /><br />\n <a href='https://github.com/rauenzi/BetterDiscordApp/releases/latest' target='_blank'>Download Installer</a>\n `),b.log("Startup","Initializing Settings"),Fe.initialize(),b.log("Startup","Initializing EmoteModule"),this.injectExternals(),await this.checkForGuilds(),Oe.initialize(),b.log("Startup","Updating Settings"),Fe.initializeSettings();for(const e in o)o[e].initialize();b.log("Startup","Loading Plugins");const t=N.loadPlugins();b.log("Startup","Loading Themes");const s=B.loadThemes();$("#customcss").detach().appendTo(document.head),b.log("Startup","Removing Loading Icon"),document.getElementsByClassName("bd-loaderv2")[0].remove(),b.log("Startup","Initializing Main Observer"),this.initObserver(),b.log("Startup","Collecting Startup Errors"),$e.showContentErrors({plugins:t,themes:s})},tt.prototype.checkForGuilds=function(){return new Promise(e=>{const t=function(){const s=Oe.guildClasses.wrapper.split(" ")[0],n=Oe.guildClasses.listItem.split(" ")[0],o=Oe.guildClasses.blobContainer.split(" ")[0];if(document.querySelectorAll(`.${s} .${n} .${o}`).length>0)return e(l.deferLoaded=!0);setTimeout(t,100)};$(document).ready(function(){setTimeout(t,100)})})},tt.prototype.injectExternals=async function(){await b.injectJs("https://cdnjs.cloudflare.com/ajax/libs/ace/1.2.9/ace.js"),window.require.original&&(window.require=window.require.original)},tt.prototype.initObserver=function(){new MutationObserver(e=>{for(let t=0,s=e.length;t<s;t++){const s=e[t];if(void 0!==N&&N.rawObserver(s),!(s.addedNodes.length&&s.addedNodes[0]instanceof Element))continue;const n=s.addedNodes[0];n.classList.contains("layer-3QrUeG")&&n.getElementsByClassName("guild-settings-base-section").length&&n.setAttribute("layer-id","server-settings")}}).observe(document,{childList:!0,subtree:!0})};var st=new tt;s.d(t,"default",function(){return ot}),s.d(t,"patchModuleLoad",function(){return rt}),function(){const e=s(0),t=process.platform,n=("win32"===t?process.env.APPDATA:"darwin"===t?process.env.HOME+"/Library/Preferences":process.env.HOME+"/.config")+"/BetterDiscord/";let o={};if(e.existsSync(`${n}localStorage.json`))try{o=JSON.parse(e.readFileSync(`${n}localStorage.json`))}catch(e){console.log(e)}else if(e.existsSync("localStorage.json"))try{o=JSON.parse(e.readFileSync("localStorage.json"))}catch(e){console.log(e)}const r=o;r.setItem=function(e,t){r[e]=t,this.save()},r.getItem=function(e){return r[e]||null},r.save=function(){e.writeFileSync(`${n}localStorage.json`,JSON.stringify(this),null,4)};const i=new Proxy(r,{set:function(e,t,s){r[t]=s,r.save()},get:function(e,t){return r[t]||null}});window.localStorage=i}();const nt=document.createElement("div");nt.className="bd-loaderv2",nt.title="BandagedBD is loading...",document.body.appendChild(nt),window.BdApi=Te,window.settings=i,window.settingsCookie=a,window.pluginCookie=c,window.themeCookie=d,window.pluginModule=N,window.themeModule=B,window.bdthemes=u,window.bdplugins=h,window.bdEmotes=p,window.bemotes=m,window.bdPluginStorage=class{static get(e,t){return b.warn("Deprecation Notice",`${e}, please use BdApi.loadData() or BdApi.getData(). bdPluginStorage may be removed in future versions.`),k.getPluginData(e,t)||null}static set(e,t,s){if(b.warn("Deprecation Notice",`${e}, please use BdApi.saveData() or BdApi.setData(). bdPluginStorage may be removed in future versions.`),void 0===s)return b.warn("Deprecation Notice","Trying to set undefined value in plugin "+e);k.setPluginData(e,t,s)}static delete(e,t){b.warn("Deprecation Notice",`${e}, please use BdApi.deleteData(). bdPluginStorage may be removed in future versions.`),k.deletePluginData(e,t)}},window.BDEvents=P,window.bdConfig=l;class ot{constructor(e){st.setConfig(e)}init(){st.init()}}function rt(){const e=s(3),t=e._load;return e._load=function(e){if("betterdiscord"===e||e.startsWith("betterdiscord/")){if("api"==e.substr("betterdiscord/".length))return Te}return t.apply(this,arguments)},function(){e._load=t}}}]).default;