BetterDiscordApp-rauenzi/js/main.min.js

1 line
103 KiB
JavaScript

var Core=function(e){var t={};function n(s){if(t[s])return t[s].exports;var o=t[s]={i:s,l:!1,exports:{}};return e[s].call(o.exports,o,o.exports,n),o.l=!0,o.exports}return n.m=e,n.c=t,n.d=function(e,t,s){n.o(e,t)||Object.defineProperty(e,t,{enumerable:!0,get:s})},n.r=function(e){"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(e,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(e,"__esModule",{value:!0})},n.t=function(e,t){if(1&t&&(e=n(e)),8&t)return e;if(4&t&&"object"==typeof e&&e&&e.__esModule)return e;var s=Object.create(null);if(n.r(s),Object.defineProperty(s,"default",{enumerable:!0,value:e}),2&t&&"string"!=typeof e)for(var o in e)n.d(s,o,function(t){return e[t]}.bind(null,o));return s},n.n=function(e){var t=e&&e.__esModule?function(){return e.default}:function(){return e};return n.d(t,"a",t),t},n.o=function(e,t){return Object.prototype.hasOwnProperty.call(e,t)},n.p="",n(n.s=6)}([function(e,t){e.exports=require("fs")},function(e,t){e.exports=require("path")},function(e,t){e.exports=require("electron")},function(e,t){e.exports=require("module")},function(e,t){e.exports=require("events")},function(e,t){e.exports=require("request")},function(e,t,n){"use strict";n.r(t);var s={};n.r(s),n.d(s,"Menu",function(){return ye}),n.d(s,"Card",function(){return be}),n.d(s,"Layer",function(){return ve});var o={};n.r(o),n.d(o,"VoiceMode",function(){return $e}),n.d(o,"ClassNormalizer",function(){return Ne}),n.d(o,"DeveloperMode",function(){return je}),n.d(o,"PublicServers",function(){return Fe}),n.d(o,"DarkMode",function(){return Oe}),n.d(o,"MinimalMode",function(){return Ae}),n.d(o,"TwentyFourHour",function(){return Ie}),n.d(o,"ColoredText",function(){return Re}),n.d(o,"VoiceDisconnect",function(){return Ge}),n.d(o,"EmoteMenu",function(){return He}),n.d(o,"EmoteAutocaps",function(){return We}),n.d(o,"EmoteModule",function(){return Ue});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"],b=[{type:"collection",id:"settings",name:"Settings",settings:[{type:"category",id:"general",name:"General",collapsible:!0,settings:[{type:"switch",id:"emotes",name:"Emote System",note:"Enables BD's emote system",value:!0},{type:"switch",id:"publicServers",name:"Public Servers",note:"Display public servers button",value:!0},{type:"switch",id:"voiceDisconnect",name:"Voice Disconnect",note:"Disconnect from voice server when closing Discord",value:!1},{type:"switch",id:"twentyFourHour",name:"24 Hour Timestamps",note:"Hides channels when in minimal mode",value:!1},{type:"switch",id:"classNormalizer",name:"Normalize Classes",note:"Adds stable classes to elements to help themes. (e.g. adds .da-channels to .channels-Ie2l6A)",value:!0},{type:"switch",id:"showToasts",name:"Show Toasts",note:"Shows a small notification for important information",value:!0}]},{type:"category",id:"appearance",name:"Appearance",collapsible:!0,settings:[{type:"switch",id:"voiceMode",name:"Voice Mode",note:"Hides everything that isn't voice chat",value:!1},{type:"switch",id:"minimalMode",name:"Minimal Mode",note:"Hide elements and reduce the size of elements",value:!1},{type:"switch",id:"hideChannels",name:"Hide Channels",note:"Hides channels when in minimal mode",value:!1,enableWith:"minimalMode"},{type:"switch",id:"darkMode",name:"Dark Mode",note:"Make certain elements dark by default",value:!0},{type:"switch",id:"coloredText",name:"Colored Text",note:"Make text colour the same as role color",value:!1}]},{type:"category",id:"content",name:"Content Manager",collapsible:!0,settings:[{type:"switch",id:"contentErrors",name:"Show Content Errors",note:"Shows a modal with plugin/theme errors",value:!0},{type:"switch",id:"autoScroll",name:"Scroll To Settings",note:"Auto-scrolls to a plugin's settings when the button is clicked (only if out of view)",value:!0},{type:"switch",id:"autoReload",name:"Automatic Loading",note:"Automatically loads, reloads, and unloads plugins and themes",value:!0}]},{type:"category",id:"developer",name:"Developer Settings",collapsible:!0,shown:!1,settings:[{type:"switch",id:"developerMode",name:"Developer Mode",note:"Allows activating debugger when pressing F8",value:!1},{type:"switch",id:"copySelector",name:"Copy Selector",note:'Adds a "Copy Selector" option to context menus when developer mode is active',value:!1,enableWith:"developerMode"}]},{type:"category",id:"window",name:"Window Preferences",collapsible:!0,shown:!1,settings:[{type:"switch",id:"transparency",name:"Enable Transparency",note:"Enables the main window to be see-through (requires restart)",value:!1},{type:"switch",id:"frame",name:"Window Frame",note:"Adds the native os window frame to the main window",value:!1,hidden:!0}]}]},{type:"collection",id:"emotes",name:"Emotes",enableWith:"settings.general.emotes",settings:[{type:"category",id:"general",name:"General",collapsible:!0,settings:[{type:"switch",id:"download",name:"Download Emotes",note:"Download emotes once a week to stay up to date",value:!0},{type:"switch",id:"emoteMenu",name:"Emote Menu",note:"Show Twitch/Favourite emotes in emote menu",value:!0},{type:"switch",id:"hideEmojiMenu",name:"Hide Emoji Menu",note:"Hides Discord's emoji menu when using emote menu",value:!1,enableWith:"emoteMenu"},{type:"switch",id:"autoCaps",name:"Emote Autocapitalization",note:"Autocapitalize emote commands",value:!1},{type:"switch",id:"showNames",name:"Show Names",note:"Show emote names on hover",value:!0},{type:"switch",id:"modifiers",name:"Show Emote Modifiers",note:"Enable emote mods (flip, spin, pulse, spin2, spin3, 1spin, 2spin, 3spin, tr, bl, br, shake, shake2, shake3, flap)",value:!0},{type:"switch",id:"animateOnHover",name:"Animate On Hover",note:"Only animate the emote modifiers on hover",value:!1}]},{type:"category",id:"categories",name:"Categories",collapsible:!0,settings:[{type:"switch",id:"twitch",name:"Twitch",note:"Show Twitch global & subscriber emotes",value:!0},{type:"switch",id:"ffz",name:"FrankerFaceZ",note:"Show emotes from FFZ",value:!0},{type:"switch",id:"bttv",name:"BetterTTV",note:"Show emotes from BTTV",value:!0}]}]}],y={};class v{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,n){console.log(`%c[BandagedBD]%c [${e}]%c ${t}`,"color: red; font-weight: 700;","color: red;",""),n&&(console.groupCollapsed("%cError: "+n.message,"color: red;"),console.error(n.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(...n)=>{try{return e(...n)}catch(e){this.err("SuppressedError","Error occurred in "+t,e)}}}static monkeyPatch(e,t,n){const{before:s,after:o,instead:r,once:i=!1,silent:a=!1,force:l=!1}=n,c=n.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 n={thisObject:this,methodArguments:arguments,cancelPatch:u,originalMethod:d,callOriginalMethod:()=>n.returnValue=n.originalMethod.apply(n.thisObject,n.methodArguments)};if(r){const s=v.suppressErrors(r,"`instead` callback of "+e[t].displayName)(n);void 0!==s&&(n.returnValue=s)}else s&&v.suppressErrors(s,"`before` callback of "+e[t].displayName)(n),n.callOriginalMethod(),o&&v.suppressErrors(o,"`after` callback of "+e[t].displayName)(n);return i&&u(),n.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 n=new MutationObserver(s=>{for(let o=0;o<s.length;o++){const r=s[o],i=Array.from(r.removedNodes),a=i.indexOf(e)>-1,l=i.some(t=>t.contains(e));(a||l)&&(n.disconnect(),t())}});n.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 n=e[t];delete e[t],e[t]=n}return e[t]}},set:function(e,t,n){return e.hasOwnProperty(t)?this.err("MemoizedObject","Trying to overwrite existing property"):(e[t]=n,e[t])}});return Object.defineProperty(t,"hasOwnProperty",{value:function(e){return void 0!==this[e]}}),t}static className(){const e=[],t={}.hasOwnProperty;for(let n=0;n<arguments.length;n++){const s=arguments[n];if(!s)continue;const o=typeof s;if("string"===o||"number"===o)e.push(s);else if(Array.isArray(s)&&s.length){const t=this.classNames.apply(null,s);t&&e.push(t)}else if("object"===o)for(const n in s)t.call(s,n)&&s[n]&&e.push(n)}return e.join(" ")}}const w=v.memoizeObject({get React(){return S.getByProps("createElement","cloneElement")},get ReactDOM(){return S.getByProps("render","findDOMNode")},get Flux(){return S.getByProps("connectStores")},get Events(){return S.getByPrototypes("setMaxListeners","emit")},get GuildStore(){return S.getByProps("getGuild")},get SortedGuildStore(){return S.getByProps("getSortedGuilds")},get SelectedGuildStore(){return S.getByProps("getLastSelectedGuildId")},get GuildSync(){return S.getByProps("getSyncedGuilds")},get GuildInfo(){return S.getByProps("getAcronym")},get GuildChannelsStore(){return S.getByProps("getChannels","getDefaultChannel")},get GuildMemberStore(){return S.getByProps("getMember")},get MemberCountStore(){return S.getByProps("getMemberCounts")},get GuildEmojiStore(){return S.getByProps("getEmojis")},get GuildActions(){return S.getByProps("markGuildAsRead")},get GuildPermissions(){return S.getByProps("getGuildPermissions")},get ChannelStore(){return S.getByProps("getChannels","getDMFromUserId")},get SelectedChannelStore(){return S.getByProps("getLastSelectedChannelId")},get ChannelActions(){return S.getByProps("selectChannel")},get PrivateChannelActions(){return S.getByProps("openPrivateChannel")},get ChannelSelector(){return S.getByProps("selectGuild","selectChannel")},get UserInfoStore(){return S.getByProps("getToken")},get UserSettingsStore(){return S.getByProps("guildPositions")},get AccountManager(){return S.getByProps("register","login")},get UserSettingsUpdater(){return S.getByProps("updateRemoteSettings")},get OnlineWatcher(){return S.getByProps("isOnline")},get CurrentUserIdle(){return S.getByProps("getIdleTime")},get RelationshipStore(){return S.getByProps("isBlocked","getFriendIDs")},get RelationshipManager(){return S.getByProps("addRelationship")},get MentionStore(){return S.getByProps("getMentions")},get UserStore(){return S.getByProps("getCurrentUser")},get UserStatusStore(){return S.getByProps("getStatus","getState")},get UserTypingStore(){return S.getByProps("isTyping")},get UserActivityStore(){return S.getByProps("getActivity")},get UserNameResolver(){return S.getByProps("getName")},get UserNoteStore(){return S.getByProps("getNote")},get UserNoteActions(){return S.getByProps("updateNote")},get EmojiInfo(){return S.getByProps("isEmojiDisabled")},get EmojiUtils(){return S.getByProps("getGuildEmoji")},get EmojiStore(){return S.getByProps("getByCategory","EMOJI_NAME_RE")},get InviteStore(){return S.getByProps("getInvites")},get InviteResolver(){return S.getByProps("findInvite")},get InviteActions(){return S.getByProps("acceptInvite")},get DiscordConstants(){return S.getByProps("Permissions","ActivityTypes","StatusTypes")},get DiscordPermissions(){return S.getByProps("Permissions","ActivityTypes","StatusTypes").Permissions},get PermissionUtils(){return S.getByProps("getHighestRole")},get ColorConverter(){return S.getByProps("hex2int")},get ColorShader(){return S.getByProps("darken")},get TinyColor(){return S.getByPrototypes("toRgb")},get ClassResolver(){return S.getByProps("getClass")},get ButtonData(){return S.getByProps("ButtonSizes")},get IconNames(){return S.getByProps("IconNames")},get NavigationUtils(){return S.getByProps("transitionTo","replaceWith","getHistory")},get MessageStore(){return S.getByProps("getMessages")},get MessageActions(){return S.getByProps("jumpToMessage","_sendMessage")},get MessageQueue(){return S.getByProps("enqueue")},get MessageParser(){return S.getByProps("createMessage","parse","unparse")},get hljs(){return S.getByProps("highlight","highlightBlock")},get SimpleMarkdown(){return S.getByProps("parseBlock","parseInline","defaultOutput")},get ExperimentStore(){return S.getByProps("getExperimentOverrides")},get ExperimentsManager(){return S.getByProps("isDeveloper")},get CurrentExperiment(){return S.getByProps("getExperimentId")},get ImageResolver(){return S.getByProps("getUserAvatarURL","getGuildIconURL")},get ImageUtils(){return S.getByProps("getSizedImageSrc")},get AvatarDefaults(){return S.getByProps("getUserAvatarURL","DEFAULT_AVATARS")},get WindowInfo(){return S.getByProps("isFocused","windowSize")},get TagInfo(){return S.getByProps("VALID_TAG_NAMES")},get DOMInfo(){return S.getByProps("canUseDOM")},get LocaleManager(){return S.getByProps("setLocale")},get Moment(){return S.getByProps("parseZone")},get LocationManager(){return S.getByProps("createLocation")},get Timestamps(){return S.getByProps("fromTimestamp")},get TimeFormatter(){return S.getByProps("dateFormat")},get Strings(){return S.getByProps("Messages").Messages},get StringFormats(){return S.getByProps("a","z")},get StringUtils(){return S.getByProps("toASCII")},get URLParser(){return S.getByProps("Url","parse")},get ExtraURLs(){return S.getByProps("getArticleURL")},get DNDActions(){return S.getByProps("beginDrag")},get DNDSources(){return S.getByProps("addTarget")},get DNDObjects(){return S.getByProps("DragSource")},get MediaDeviceInfo(){return S.getByProps("Codecs","SUPPORTED_BROWSERS")},get MediaInfo(){return S.getByProps("getOutputVolume")},get MediaEngineInfo(){return S.getByProps("MediaEngineFeatures")},get VoiceInfo(){return S.getByProps("EchoCancellation")},get VideoStream(){return S.getByProps("getVideoStream")},get SoundModule(){return S.getByProps("playSound")},get ElectronModule(){return S.getByProps("setBadge")},get Dispatcher(){return S.getByProps("dirtyDispatch")},get PathUtils(){return S.getByProps("hasBasename")},get NotificationModule(){return S.getByProps("showNotification")},get RouterModule(){return S.getByProps("Router")},get APIModule(){return S.getByProps("getAPIBaseURL")},get AnalyticEvents(){return S.getByProps("AnalyticEventConfigs")},get KeyGenerator(){return S.getByRegex(/"binary"/)},get Buffers(){return S.getByProps("Buffer","kMaxLength")},get DeviceStore(){return S.getByProps("getDevices")},get SoftwareInfo(){return S.getByProps("os")},get CurrentContext(){return S.getByProps("setTagsContext")}});class C{static byProperties(e,t=(e=>e)){return n=>{const s=t(n);return!!s&&e.every(e=>void 0!==s[e])}}static byPrototypeFields(e,t=(e=>e)){return n=>{const s=t(n);return!!s&&(!!s.prototype&&e.every(e=>void 0!==s.prototype[e]))}}static byCode(e,t=(e=>e)){return n=>{const s=t(n);return!!s&&-1!==s.toString([]).search(e)}}static byString(...e){return t=>{const n=t.toString([]);for(const t of e)if(!n.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 S{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 n=this.getAllModules(),s=[];for(const o in n){if(!n.hasOwnProperty(o))continue;const r=n[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;s.push(a)}}return t||0==s.length?void 0:s}static getModules(e){return this.getModule(e,!1)}static getModuleByName(e,t){if(w.hasOwnProperty(e))return w[e];if(!t)return;const n=this.getModule(t,!0);return n?w[e]=n:void 0}static getByDisplayName(e){return this.getModule(C.byDisplayName(e),!0)}static getByRegex(e,t=!0){return this.getModule(C.byCode(e),t)}static getByPrototypes(...e){return this.getModule(C.byPrototypeFields(e),!0)}static getAllByPrototypes(...e){return this.getModule(C.byPrototypeFields(e),!1)}static getByProps(...e){return this.getModule(C.byProperties(e),!0)}static getAllByProps(...e){return this.getModule(C.byProperties(e),!1)}static getByString(...e){return this.getModule(C.byString(...e),!0)}static getAllByString(...e){return this.getModule(C.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,n)=>t.default=n},[e]).default:window.webpackJsonp.push([[],{[e]:(e,t,n)=>e.exports=n},[[e]]]);return delete t.m[e],delete t.c[e],this._require=t}static getAllModules(){return this.require.c}}const E=n(0),P=n(1),x=DiscordNative.globals.releaseChannel;var k=new class{constructor(){this.data={misc:{}},this.pluginData={}}initialize(){E.existsSync(this.baseFolder)||E.mkdirSync(this.baseFolder),E.existsSync(this.dataFolder)||E.mkdirSync(this.dataFolder),E.existsSync(this.BDFile)||E.writeFileSync(this.BDFile,JSON.stringify(this.data.misc,null,4));const e=E.readdirSync(this.dataFolder).filter(e=>!E.statSync(P.resolve(this.dataFolder,e)).isDirectory()&&e.endsWith(".json"));for(const t of e)this.data[t.split(".")[0]]=require(P.resolve(this.dataFolder,t))}get baseFolder(){return this._baseFolder||(this._baseFolder=P.resolve(l.dataPath,"data"))}get dataFolder(){return this._dataFolder||(this._dataFolder=P.resolve(this.baseFolder,`${x}`))}get BDFile(){return this._BDFile||(this._BDFile=P.resolve(l.dataPath,"data",`${x}.json`))}getPluginFile(e){return P.resolve(l.dataPath,"plugins",e+".config.json")}_getFile(e){return"settings"==e||"plugins"==e||"themes"==e?P.resolve(this.dataFolder,`${e}.json`):P.resolve(this.dataFolder,"misc.json")}getBDData(e){return this.data.misc[e]||""}setBDData(e,t){this.data.misc[e]=t,E.writeFileSync(P.resolve(this.dataFolder,"misc.json"),JSON.stringify(this.data.misc,null,4))}getData(e){return this.data[e]||""}setData(e,t){this.data[e]=t,E.writeFileSync(P.resolve(this.dataFolder,`${e}.json`),JSON.stringify(t,null,4))}getPluginData(e,t){return void 0!==this.pluginData[e]?this.pluginData[e][t]||void 0:E.existsSync(this.getPluginFile(e))?(this.pluginData[e]=JSON.parse(E.readFileSync(this.getPluginFile(e))),this.pluginData[e][t]||void 0):void 0}setPluginData(e,t,n){void 0!==n&&(void 0===this.pluginData[e]&&(this.pluginData[e]={}),this.pluginData[e][t]=n,E.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],E.writeFileSync(this.getPluginFile(e),JSON.stringify(this.pluginData[e],null,4))}};const D=n(4);var M=new class extends D{constructor(){super(),this.setMaxListeners(20)}dispatch(e,...t){this.emit(e,...t)}};function B(){}B.prototype.loadPlugins=function(){this.loadPluginData();const e=G.loadPlugins(),t=Object.keys(h);for(let n=0;n<t.length;n++){let s,o;try{o=(s=h[t[n]].plugin).getName(),s.load&&"function"==typeof s.load&&s.load()}catch(s){c[o]=!1,v.err("Plugins",o+" could not be loaded.",s),e.push({name:o,file:h[t[n]].filename,message:"load() could not be fired.",error:{message:s.message,stack:s.stack}});continue}if(c[o]||(c[o]=!1),c[o])try{s.start(),Se.show(`${s.getName()} v${s.getVersion()} has started.`)}catch(s){c[o]=!1,v.err("Plugins",o+" could not be started.",s),e.push({name:o,file:h[t[n]].filename,message:"start() could not be fired.",error:{message:s.message,stack:s.stack}})}}return this.savePluginData(),n(2).remote.getCurrentWebContents().on("did-navigate-in-page",this.channelSwitch.bind(this)),e},B.prototype.startPlugin=function(e,t=!1){try{h[e].plugin.start(),t||Se.show(`${h[e].plugin.getName()} v${h[e].plugin.getVersion()} has started.`)}catch(n){t||Se.show(`${h[e].plugin.getName()} v${h[e].plugin.getVersion()} could not be started.`,{type:"error"}),c[e]=!1,this.savePluginData(),v.err("Plugins",e+" could not be started.",n)}},B.prototype.stopPlugin=function(e,t=!1){try{h[e].plugin.stop(),t||Se.show(`${h[e].plugin.getName()} v${h[e].plugin.getVersion()} has stopped.`)}catch(n){t||Se.show(`${h[e].plugin.getName()} v${h[e].plugin.getVersion()} could not be stopped.`,{type:"error"}),v.err("Plugins",h[e].plugin.getName()+" could not be stopped.",n)}},B.prototype.enablePlugin=function(e,t=!1){c[e]||(c[e]=!0,this.savePluginData(),this.startPlugin(e,t))},B.prototype.disablePlugin=function(e,t=!1){c[e]&&(c[e]=!1,this.savePluginData(),this.stopPlugin(e,t))},B.prototype.togglePlugin=function(e){c[e]?this.disablePlugin(e):this.enablePlugin(e)},B.prototype.loadPlugin=function(e){const t=G.loadContent(e,"plugin");if(t)return Ee.showContentErrors({plugins:[t]}),Se.show(`${e} could not be loaded.`,{type:"error"}),v.err("ContentManager",`${e} could not be loaded.`,t);const n=Object.values(h).find(t=>t.filename==e).plugin;try{n.load&&"function"==typeof n.load&&n.load()}catch(e){Ee.showContentErrors({plugins:[e]})}v.log("ContentManager",`${n.getName()} v${n.getVersion()} was loaded.`),Se.show(`${n.getName()} v${n.getVersion()} was loaded.`,{type:"success"}),M.dispatch("plugin-loaded",n.getName())},B.prototype.unloadPlugin=function(e){const t=Object.values(h).find(t=>t.filename==e)||h[e];if(!t)return;const n=t.plugin.getName();c[n]&&this.disablePlugin(n,!0);const s=G.unloadContent(h[n].filename,"plugin");if(delete h[n],s)return Ee.showContentErrors({plugins:[s]}),Se.show(`${n} could not be unloaded. It may have not been loaded yet.`,{type:"error"}),v.err("ContentManager",`${n} could not be unloaded. It may have not been loaded yet.`,s);v.log("ContentManager",`${n} was unloaded.`),Se.show(`${n} was unloaded.`,{type:"success"}),M.dispatch("plugin-unloaded",n)},B.prototype.reloadPlugin=function(e){const t=Object.values(h).find(t=>t.filename==e)||h[e];if(!t)return this.loadPlugin(e);const n=t.plugin.getName(),s=c[n];s&&this.stopPlugin(n,!0);const o=G.reloadContent(h[n].filename,"plugin");if(o)return Ee.showContentErrors({plugins:[o]}),Se.show(`${n} could not be reloaded.`,{type:"error"}),v.err("ContentManager",`${n} could not be reloaded.`,o);h[n].plugin.load&&"function"==typeof h[n].plugin.load&&h[n].plugin.load(),s&&this.startPlugin(n,!0),v.log("ContentManager",`${n} v${h[n].plugin.getVersion()} was reloaded.`),Se.show(`${n} v${h[n].plugin.getVersion()} was reloaded.`,{type:"success"}),M.dispatch("plugin-reloaded",n)},B.prototype.updatePluginList=function(){const e=G.loadNewContent("plugin");for(const t of e.added)this.loadPlugin(t);for(const t of e.removed)this.unloadPlugin(t)},B.prototype.loadPluginData=function(){const e=k.getData("plugins");e&&Object.assign(c,e)},B.prototype.savePluginData=function(){k.setData("plugins",c)},B.prototype.newMessage=function(){const e=Object.keys(h);for(let t=0;t<e.length;t++){const n=h[e[t]].plugin;if(c[n.getName()]&&"function"==typeof n.onMessage)try{n.onMessage()}catch(e){v.err("Plugins","Unable to fire onMessage for "+n.getName()+".",e)}}},B.prototype.channelSwitch=function(){const e=Object.keys(h);for(let t=0;t<e.length;t++){const n=h[e[t]].plugin;if(c[n.getName()]&&"function"==typeof n.onSwitch)try{n.onSwitch()}catch(e){v.err("Plugins","Unable to fire onSwitch for "+n.getName()+".",e)}}},B.prototype.rawObserver=function(e){const t=Object.keys(h);for(let n=0;n<t.length;n++){const s=h[t[n]].plugin;if(c[s.getName()]&&"function"==typeof s.observer)try{s.observer(e)}catch(e){v.err("Plugins","Unable to fire observer for "+s.getName()+".",e)}}};var T=new B;function N(){}N.prototype.loadThemes=function(){this.loadThemeData();const e=G.loadThemes(),t=Object.keys(u);for(let e=0;e<t.length;e++){const n=u[t[e]].name;d[n]||(d[n]=!1),d[n]&&$("head").append($("<style>",{id:v.escapeID(n),text:unescape(u[n].css)}))}for(const e in d)u[e]||delete d[e];return this.saveThemeData(),e},N.prototype.enableTheme=function(e,t=!1){d[e]=!0,this.saveThemeData(),$("head").append($("<style>",{id:v.escapeID(e),text:unescape(u[e].css)})),t||Se.show(`${u[e].name} v${u[e].version} has been applied.`)},N.prototype.disableTheme=function(e,t=!1){d[e]=!1,this.saveThemeData(),$(`#${v.escapeID(u[e].name)}`).remove(),t||Se.show(`${u[e].name} v${u[e].version} has been disabled.`)},N.prototype.toggleTheme=function(e){d[e]?this.disableTheme(e):this.enableTheme(e)},N.prototype.loadTheme=function(e){const t=G.loadContent(e,"theme");if(t)return Ee.showContentErrors({themes:[t]}),Se.show(`${e} could not be loaded. It may not have been loaded.`,{type:"error"}),v.err("ContentManager",`${e} could not be loaded.`,t);const n=Object.values(u).find(t=>t.filename==e);v.log("ContentManager",`${n.name} v${n.version} was loaded.`),Se.show(`${n.name} v${n.version} was loaded.`,{type:"success"}),M.dispatch("theme-loaded",n.name)},N.prototype.unloadTheme=function(e){const t=Object.values(u).find(t=>t.filename==e)||u[e];if(!t)return;const n=t.name;d[n]&&this.disableTheme(n,!0);const s=G.unloadContent(u[n].filename,"theme");if(delete u[n],s)return Ee.showContentErrors({themes:[s]}),Se.show(`${n} could not be unloaded. It may have not been loaded yet.`,{type:"error"}),v.err("ContentManager",`${n} could not be unloaded. It may have not been loaded yet.`,s);v.log("ContentManager",`${n} was unloaded.`),Se.show(`${n} was unloaded.`,{type:"success"}),M.dispatch("theme-unloaded",n)},N.prototype.reloadTheme=function(e){const t=Object.values(u).find(t=>t.filename==e)||u[e];if(!t)return this.loadTheme(e);const n=t.name,s=G.reloadContent(u[n].filename,"theme");if(d[n]&&(this.disableTheme(n,!0),this.enableTheme(n,!0)),s)return Ee.showContentErrors({themes:[s]}),Se.show(`${n} could not be reloaded.`,{type:"error"}),v.err("ContentManager",`${n} could not be reloaded.`,s);v.log("ContentManager",`${n} v${u[n].version} was reloaded.`),Se.show(`${n} v${u[n].version} was reloaded.`,{type:"success"}),M.dispatch("theme-reloaded",n)},N.prototype.updateThemeList=function(){const e=G.loadNewContent("theme");for(const t of e.added)this.loadTheme(t);for(const t of e.removed)this.unloadTheme(t)},N.prototype.loadThemeData=function(){const e=k.getData("themes");e&&Object.assign(d,e)},N.prototype.saveThemeData=function(){k.setData("themes",d)};var j=new N;const F=n(1),O=n(0),A=n(3).Module;A.globalPaths.push(F.resolve(n(2).remote.app.getAppPath(),"node_modules"));class I extends Error{constructor(e){super(e),this.name="MetaError"}}const L=A._extensions[".js"],R=A._extensions[".css"]?A._extensions[".css"]:()=>null;var G=new class{constructor(){this.timeCache={},this.watchers={},A._extensions[".js"]=this.getContentRequire("plugin"),A._extensions[".css"]=this.getContentRequire("theme")}get pluginsFolder(){return this._pluginsFolder||(this._pluginsFolder=O.realpathSync(F.resolve(l.dataPath+"plugins/")))}get themesFolder(){return this._themesFolder||(this._themesFolder=O.realpathSync(F.resolve(l.dataPath+"themes/")))}watchContent(e){if(this.watchers[e])return;const t="plugin"===e,n=t?this.pluginsFolder:this.themesFolder,s=t?".plugin.js":".theme.css";this.watchers[e]=O.watch(n,{persistent:!1},async(e,o)=>{if(!e||!o||!o.endsWith(s))return;await new Promise(e=>setTimeout(e,50));try{O.statSync(F.resolve(n,o))}catch(e){if("ENOENT"!==e.code)return;return delete this.timeCache[o],t?T.unloadPlugin(o):j.unloadTheme(o)}if(!O.statSync(F.resolve(n,o)).isFile())return;const r=O.statSync(F.resolve(n,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?T.loadPlugin(o):j.loadTheme(o)),"change"==e&&(t?T.reloadPlugin(o):j.reloadTheme(o)))})}unwatchContent(e){this.watchers[e]&&(this.watchers[e].close(),delete this.watchers[e])}extractMeta(e){const t=e.split("\n")[0],n=t.substring(t.lastIndexOf("//META")+6,t.lastIndexOf("*//"));if(t.indexOf("META")<0)throw new I("META was not found.");if(!v.testJSON(n))throw new I("META could not be parsed.");const s=JSON.parse(n);if(!s.name)throw new I("META missing name data.");return s}getContentRequire(e){const t="plugin"===e,n=this,s=t?L:R;return function(e,o){const r=t?n.pluginsFolder:n.themesFolder,i=F.resolve(r,F.basename(o));if(!O.existsSync(i)||o!==O.realpathSync(i))return Reflect.apply(s,this,arguments);let a=O.readFileSync(o,"utf8");a=v.stripBOM(a);const l=n.extractMeta(a);l.filename=F.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 n="plugin"===t,s=n?this.pluginsFolder:this.themesFolder;try{require(F.resolve(s,e))}catch(t){return{name:e,file:e,message:"Could not be compiled.",error:{message:t.message,stack:t.stack}}}const o=require(F.resolve(s,e));if(n){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 n="plugin"===t?this.pluginsFolder:this.themesFolder;try{delete require.cache[require.resolve(F.resolve(n,e))]}catch(t){return{name:e,file:e,message:"Could not be unloaded.",error:{message:t.message,stack:t.stack}}}}isLoaded(e,t){const n="plugin"===t?this.pluginsFolder:this.themesFolder;try{require.cache[require.resolve(F.resolve(n,e))]}catch(e){return!1}return!0}reloadContent(e,t){const n=this.unloadContent(e,t);return n||this.loadContent(e,t)}loadNewContent(e){const t="plugin"===e,n=t?".plugin.js":".theme.css",s=t?this.pluginsFolder:this.themesFolder,o=O.readdirSync(s),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(n)&&O.statSync(F.resolve(s,e)).isFile()),removed:i}}loadAllContent(e){const t="plugin"===e,n=t?".plugin.js":".theme.css",s=t?this.pluginsFolder:this.themesFolder,o=[],r=O.readdirSync(s);for(const t of r){if(!O.statSync(F.resolve(s,t)).isFile()||!t.endsWith(n))continue;const r=this.loadContent(t,e);r&&o.push(r)}return o}loadPlugins(){return this.loadAllContent("plugin")}loadThemes(){return this.loadAllContent("theme")}};const V=w.React,H=w.ReactDOM,W="bd-settings-title h2-2gWE-o title-3sZWYQ size16-14cGz5 height20-mO2eIN weightSemiBold-NJexzi defaultColor-1_ajX0 defaultMarginh2-2LTaUL marginBottom20-32qID7",z="bd-settings-title bd-settings-group-title h5-18_1nd title-3sZWYQ size12-3R0845 height16-2Lv3qA weightSemiBold-NJexzi da-h5 da-title da-size12 da-height16 da-weightSemiBold marginBottom4-2qk4Hy da-marginBottom4 marginTop8-1DLZ1n da-marginTop8";class q extends V.Component{constructor(e){super(e)}render(){const e=this.props.isGroup?z:W,t=this.props.className?`${e} ${this.props.className}`:e;return V.createElement("h2",{className:t,onClick:()=>{this.props.onClick&&this.props.onClick()}},this.props.text,this.props.button&&V.createElement("button",{className:"bd-title-button",onClick:this.props.button.onClick},this.props.button.title))}}class U extends V.Component{render(){return V.createElement("div",{className:"bd-divider divider-3573oO marginTop8-1DLZ1n marginBottom40-2vIwTv"})}}const _="flex-1xMQg5 flex-1O1GKY vertical-V37hAW flex-1O1GKY directionColumn-35P_nr justifyStart-2NDFzi alignStretch-DpGPf3 noWrap-3jynv6 switchItem-2hKKKK",J="flex-1xMQg5 flex-1O1GKY horizontal-1ae9ci horizontal-2EEEnY flex-1O1GKY directionRow-3v3tfG justifyStart-2NDFzi alignStart-H-X2h- noWrap-3jynv6",Z="flexChild-faoVW3",Y="titleDefault-a8-ZSr title-31JmR4 da-titleDefault da-title",K="flexChild-faoVW3 da-flexChild switchDisabled-3HsXAJ switch-3wwwcV da-switchDisabled da-switch valueUnchecked-2lU_20 value-2hFrkk sizeDefault-2YlOZr size-3rFEHg themeDefault-24hCdX",X="flexChild-faoVW3 da-flexChild switchDisabled-3HsXAJ switch-3wwwcV da-switchDisabled da-switch valueChecked-m-4IJZ value-2hFrkk sizeDefault-2YlOZr size-3rFEHg themeDefault-24hCdX",Q="flexChild-faoVW3 da-flexChild switchEnabled-V2WDBB switch-3wwwcV da-switchEnabled da-switch valueUnchecked-2lU_20 value-2hFrkk sizeDefault-2YlOZr size-3rFEHg themeDefault-24hCdX",ee="flexChild-faoVW3 da-flexChild switchEnabled-V2WDBB switch-3wwwcV da-switchEnabled da-switch valueChecked-m-4IJZ value-2hFrkk sizeDefault-2YlOZr size-3rFEHg themeDefault-24hCdX",te="checkboxEnabled-CtinEn checkbox-2tyjJg",ne="checkboxDisabled-1MA81A checkbox-2tyjJg",se="description-3_Ncsb formText-3fs7AJ note-1V3kyJ modeDefault-3a2Ph1 primary-jw0I4K",oe="divider-3573oO dividerDefault-3rvLe-";class re extends V.Component{constructor(e){super(e),this.state={checked:this.props.checked}}onChange(){this.props.disabled||(this.props.onChange(this.props.id,!this.state.checked),this.setState({checked:!this.state.checked}))}render(){const e=this.props.disabled?this.state.checked?X:K:this.state.checked?ee:Q;return V.createElement("div",{className:_,style:{flex:"1 1 auto"}},V.createElement("div",{className:J,style:{flex:"1 1 auto"}},V.createElement("div",{className:Z,style:{flex:"1 1 auto"}},V.createElement("label",{htmlFor:this.props.id,className:Y},this.props.name||this.props.data.text)),V.createElement("div",{className:e,tabIndex:"0",style:{flex:"0 0 auto"}},V.createElement("input",{id:this.props.id,className:this.props.disabled?ne:te,type:"checkbox",tabIndex:"-1",checked:this.state.checked,onChange:e=>this.onChange(e)}))),V.createElement("div",{className:se,style:{flex:"1 1 auto"}},this.props.note||this.props.data.info),V.createElement("div",{className:oe}))}}const ie="bd-settings-group";class ae extends V.Component{constructor(e){if(super(e),this.props.button&&this.props.collapsible){const e=this.props.button.onClick;this.props.button.onClick=t=>{t.stopPropagation(),e(...arguments)}}this.props.hasOwnProperty("shown")||(this.props.shown=!0),this.container=V.createRef(),this.state={collapsed:this.props.collapsible&&!this.props.shown},this.onChange=this.onChange.bind(this)}toggleCollapse(){const e=this.container.current,t=this.state.collapsed?300:1;e.style.setProperty("height",e.scrollHeight+"px"),this.setState({collapsed:!this.state.collapsed},()=>setTimeout(()=>e.style.setProperty("height",""),t))}onChange(e,t){this.props.onChange&&(this.props.id?this.props.onChange(this.props.id,e,t):this.props.onChange(e,t),this.forceUpdate())}render(){const{settings:e}=this.props,t=this.props.collapsible?`collapsible ${this.state.collapsed&&"collapsed"}`:"",n=`${ie} ${t}`;return V.createElement("div",{className:n},V.createElement(q,{text:this.props.name,collapsible:this.props.collapsible,onClick:()=>this.toggleCollapse(),button:this.props.button,isGroup:!0}),V.createElement("div",{className:"bd-settings-container",ref:this.container},e.filter(e=>!e.hidden).map(e=>V.createElement(re,{disabled:e.disabled,id:e.id,key:e.id,name:e.name,note:e.note,checked:e.value,onChange:this.onChange}))),this.props.showDivider&&V.createElement(U,null))}}class le{get coreSettings(){const e=this.getSettings("core");return[...new Set(e.map(e=>e.category))].map(t=>({title:t,settings:e.filter(e=>e.category==t)}))}get emoteSettings(){return this.getSettings("emote")}getSettings(e){return Object.keys(i).reduce((t,n)=>{const s=i[n];return s.cat===e&&s.implemented&&!s.hidden&&(s.text=n,t.push(s)),t},[])}getSettingsPanel(e,t,n){return[V.createElement(q,{text:e}),t.map(e=>V.createElement(ae,Object.assign({},e,{onChange:n})))]}get core3(){return b.map((e,t)=>(0==t&&(e.button={title:"Call to Action!",onClick:()=>{Se.success("You did it!",{forceShow:!0})}}),e.settings.forEach(t=>t.value=y[e.id][t.id]),V.createElement(ae,Object.assign({},e,{onChange:this.onChange}))))}get core2(){return this.coreSettings.map((e,t)=>(0==t&&(e.button={title:"Call to Action!",onClick:()=>{Se.success("You did it!",{forceShow:!0})}}),e.settings.find(e=>"Hide Channels"==e.text)&&(e.settings.find(e=>"Hide Channels"==e.text).shouldHide=()=>!a["bda-gs-2"]),V.createElement(ae,Object.assign({},e,{onChange:this.onChange,collapsible:!0,collapsed:t>1}))))}get attribution(){return V.createElement("div",{style:{fontSize:"12px",fontWeight:"600",color:"#72767d",padding:"2px 10px"}},`BBD v${l.bbdVersion} by `,V.createElement("a",{href:"https://github.com/rauenzi/",target:"_blank"},"Zerebos"))}}class ce extends V.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:n}=this.props;return V.createElement("div",{key:"scrollerwrap",className:e},V.createElement("div",{key:"scroller",ref:"scroller",className:t},n))}}class de extends V.Component{constructor(e){super(e)}render(){const{sidebar:e,content:t,tools:n}=this.props.children;return V.createElement("div",{className:"standardSidebarView-3F1I7i ui-standard-sidebar-view"},V.createElement("div",{className:"sidebarRegion-VFTUkN sidebar-region"},V.createElement(ce,{key:"sidebarScroller",ref:"sidebarScroller",sidebar:!0,fade:e.fade||!0,dark:e.dark||!0,children:e.component})),V.createElement("div",{className:"contentRegion-3nDuYy content-region"},V.createElement("div",{className:"contentTransitionWrap-3hqOEW content-transition-wrap"},V.createElement("div",{className:"scrollerWrap-2lJEkd firefoxFixScrollFlex-cnI2ix contentRegionScrollerWrap-3YZXdm content-region-scroller-wrap scrollerThemed-2oenus themeGhost-28MSn0 scrollerTrack-1ZIpsv"},V.createElement("div",{className:"scroller-2FKFPG firefoxFixScrollFlex-cnI2ix contentRegionScroller-26nc1e content-region-scroller scroller",ref:"contentScroller"},V.createElement("div",{className:"contentColumn-2hrIYH contentColumnDefault-1VQkGM content-column default"},t.component),n.component)))))}}class ue extends V.Component{constructor(e){super(e)}render(){return V.createElement("svg",{xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 12 12",style:{width:"18px",height:"18px"}},V.createElement("g",{className:"background",fill:"none",fillRule:"evenodd"},V.createElement("path",{d:"M0 0h12v12H0"}),V.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 he extends V.Component{constructor(e){super(e),this.onClick=this.onClick.bind(this)}render(){return V.createElement("div",{className:"tools-container toolsContainer-1edPuj"},V.createElement("div",{className:"tools tools-3-3s-N"},V.createElement("div",{className:"container-1sFeqf"},V.createElement("div",{className:"btn-close closeButton-1tv5uR",onClick:this.onClick},V.createElement(ue,null)),V.createElement("div",{className:"esc-text keybind-KpFkfr"},"ESC"))))}onClick(){this.props.onClick&&this.props.onClick(),$(".closeButton-1tv5uR").first().click()}}class pe extends V.Component{constructor(e){super(e),this.setInitialState(),this.onClick=this.onClick.bind(this)}setInitialState(){this.state={selected:this.props.selected||!1}}render(){return V.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 me extends V.Component{constructor(e){super(e)}render(){return V.createElement("div",{className:"ui-tab-bar-separator margin-top-8 margin-bottom-8"})}}class ge extends V.Component{constructor(e){super(e)}render(){return V.createElement("div",{className:"ui-tab-bar-header"},this.props.text)}}class fe{static get Item(){return pe}static get Header(){return ge}static get Separator(){return me}}class be extends V.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 V.createElement("div",{className:`card-3Qj_Yx cardPrimary-1Hv-to marginBottom8-AtZOdT bd-server-card${e.pinned?" bd-server-card-pinned":""}`},V.createElement("img",{ref:"img",className:"bd-server-image",src:e.iconUrl,onError:this.handleError.bind(this)}),V.createElement("div",{className:"flexChild-faoVW3 bd-server-content"},V.createElement("div",{className:"flex-1xMQg5 flex-1O1GKY horizontal-1ae9ci horizontal-2EEEnY directionRow-3v3tfG noWrap-3jynv6 bd-server-header"},V.createElement("h5",{className:"h5-18_1nd defaultColor-1_ajX0 margin-reset bd-server-name"},e.name),V.createElement("h5",{className:"h5-18_1nd defaultColor-1_ajX0 margin-reset bd-server-member-count"},e.members," Members")),V.createElement("div",{className:"flex-1xMQg5 flex-1O1GKY horizontal-1ae9ci horizontal-2EEEnY directionRow-3v3tfG noWrap-3jynv6"},V.createElement("div",{className:"scrollerWrap-2lJEkd scrollerThemed-2oenus themeGhostHairline-DBD-2d scrollerFade-1Ijw5y bd-server-description-container"},V.createElement("div",{className:"scroller-2FKFPG scroller bd-server-description"},e.description))),V.createElement("div",{className:"flex-1xMQg5 flex-1O1GKY horizontal-1ae9ci horizontal-2EEEnY directionRow-3v3tfG noWrap-3jynv6 bd-server-footer"},V.createElement("div",{className:"flexChild-faoVW3 bd-server-tags",style:{flex:"1 1 auto"}},e.categories.join(", ")),this.state.joined&&V.createElement("button",{type:"button",className:"button-38aScr lookFilled-1Gx00P colorBrand-3pXr91 sizeMin-1mJd1x grow-q77ONN colorGreen-29iAKY",style:{minHeight:"12px",marginTop:"4px",backgroundColor:"#3ac15c"}},V.createElement("div",{className:"ui-button-contents"},"Joined")),e.error&&V.createElement("button",{type:"button",className:"button-38aScr lookFilled-1Gx00P colorBrand-3pXr91 sizeMin-1mJd1x grow-q77ONN disabled-9aF2ug",style:{minHeight:"12px",marginTop:"4px",backgroundColor:"#c13a3a"}},V.createElement("div",{className:"ui-button-contents"},"Error")),!e.error&&!this.state.joined&&V.createElement("button",{type:"button",className:"button-38aScr lookFilled-1Gx00P colorBrand-3pXr91 sizeMin-1mJd1x grow-q77ONN",style:{minHeight:"12px",marginTop:"4px"},onClick:()=>{this.join()}},V.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 ye extends V.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=S.getByProps("getGuilds"),this.AvatarDefaults=S.getByProps("getUserAvatarURL","DEFAULT_AVATARS"),this.InviteActions=S.getByProps("acceptInvite"),this.SortedGuildStore=S.getByProps("getSortedGuilds")}componentDidMount(){this.checkConnection()}setInitialState(){this.state={selectedCategory:-1,title:"Loading...",loading:!0,servers:[],next:null,connection:{state:0,user:null}}}close(){H.unmountComponentAtNode(document.getElementById(this.props.rootId))}search(e,t){const n=this;$.ajax({method:"GET",url:`${n.endPoint}${e}${e?"&schema=new":"?schema=new"}`,success:e=>{let s=e.results.reduce((e,t)=>(t.joined=!1,e.push(t),e),[]);t||(s=n.state.servers.concat(s));let o=e.size+e.from;e.next=`?from=${o}`,n.state.term&&(e.next+=`&term=${n.state.term}`),n.state.selectedCategory&&(e.next+=`&category=${n.categoryButtons[n.state.selectedCategory]}`),o>=e.total&&(o=e.total,e.next=null);let r=`Showing 1-${o} of ${e.total} results in ${n.categoryButtons[n.state.selectedCategory]}`;n.state.term&&(r+=` for ${n.state.term}`),n.setState({loading:!1,title:r,servers:s,next:e.next}),t&&(n.refs.sbv.refs.contentScroller.scrollTop=0)},error:()=>{n.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 V.createElement(be,{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 V.createElement(de,{ref:"sbv",children:this.component})}get component(){return{sidebar:{component:this.sidebar},content:{component:this.content},tools:{component:V.createElement(he,{key:"pt",ref:"tools",onClick:this.close})}}}get sidebar(){return V.createElement("div",{className:"sidebar",key:"ps"},V.createElement("div",{className:"ui-tab-bar SIDE"},V.createElement("div",{className:"ui-tab-bar-header",style:{fontSize:"16px"}},"Public Servers"),V.createElement(fe.Separator,null),this.searchInput,V.createElement(fe.Separator,null),V.createElement(fe.Header,{text:"Categories"}),this.categoryButtons.map((e,t)=>V.createElement(fe.Item,{id:t,onClick:this.changeCategory,key:t,text:e,selected:this.state.selectedCategory===t})),V.createElement(fe.Separator,null),this.footer,this.connection))}get searchInput(){return V.createElement("div",{className:"ui-form-item"},V.createElement("div",{className:"ui-text-input flex-vertical",style:{width:"172px",marginLeft:"10px"}},V.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 n=`?term=${e.target.value}`;0!==t.state.selectedCategory&&(n+=`&category=${t.categoryButtons[t.state.selectedCategory]}`),t.search(n,!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,n=this.AvatarDefaults.DEFAULT_AVATARS;return 1===e.state.connection.state?e.notConnected:[V.createElement("div",{ref:"content",key:"pc",className:"contentColumn-2hrIYH contentColumnDefault-1VQkGM content-column default"},V.createElement(q,{text:e.state.title}),e.bdServer,e.state.servers.map(s=>V.createElement(be,{key:s.identifier,server:s,join:e.join,guildList:t,fallback:n[Math.floor(5*Math.random())]})),e.state.next&&V.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"}},V.createElement("div",{className:"ui-button-contents"},e.state.loading?"Loading":"Load More")),e.state.servers.length>0&&V.createElement(q,{text:e.state.title}))]}get notConnected(){return[V.createElement("div",{key:"ncc",ref:"content",className:"contentColumn-2hrIYH contentColumnDefault-1VQkGM content-column default"},V.createElement("h2",{className:"ui-form-title h2 margin-reset margin-bottom-20"},"Not connected to discordservers.com!",V.createElement("button",{onClick:this.connect,type:"button",className:"ui-button filled brand small grow",style:{display:"inline-block",minHeight:"18px",marginLeft:"10px",lineHeight:"14px"}},V.createElement("div",{className:"ui-button-contents"},"Connect"))),this.bdServer)]}get footer(){return V.createElement("div",{className:"ui-tab-bar-header"},V.createElement("a",{href:"https://discordservers.com",target:"_blank"},"Discordservers.com"))}get connection(){const{connection:e}=this.state;return 2!==e.state?V.createElement("span",null):V.createElement("span",null,V.createElement(fe.Separator,null),V.createElement("span",{style:{color:"#b9bbbe",fontSize:"10px",marginLeft:"10px"}},"Connected as: ",`${e.user.username}#${e.user.discriminator}`),V.createElement("div",{style:{padding:"5px 10px 0 10px"}},V.createElement("button",{style:{width:"100%",minHeight:"20px"},type:"button",className:"ui-button filled brand small grow"},V.createElement("div",{className:"ui-button-contents",onClick:this.connect},"Reconnect"))))}}class ve extends V.Component{constructor(e){super(e)}componentDidMount(){$(window).on(`keyup.${this.props.id}`,e=>{27===e.which&&H.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 V.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)}}const we=S.getByProps("channels").channels.split(" ")[0],Ce=S.getByProps("membersWrap").membersWrap.split(" ")[0];class Se{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:n="",icon:s=!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"),n&&i.classList.add("toast-"+n),n&&s&&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(`.${we} + div`),t=e.querySelector(`.${Ce}`),n=e?e.querySelector("form"):null,s=e?e.getBoundingClientRect().left:310,o=t?t.getBoundingClientRect().left:0,r=o?o-e.getBoundingClientRect().left:e.offsetWidth,i=n?n.offsetHeight:80,a=document.createElement("div");a.classList.add("bd-toasts"),a.style.setProperty("left",s+"px"),a.style.setProperty("width",r+"px"),a.style.setProperty("bottom",i+"px"),document.querySelector("#app-mount").appendChild(a)}}class Ee{static get shouldShowContentErrors(){return a["fork-ps-1"]}static get ModalStack(){return S.getByProps("push","update","pop","popWithKey")}static get AlertModal(){return S.getByPrototypes("handleCancel","handleSubmit","handleMinorConfirm")}static get TextElement(){return S.getByProps("Sizes","Weights")}static get ConfirmationModal(){return S.getModule(e=>e.defaultProps&&e.key&&"confirm-modal"==e.key())}static default(e,t){const n=$(`<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>`);n.find(".footer button").on("click",()=>{n.addClass("closing"),setTimeout(()=>{n.remove()},300)}),n.find(".bd-backdrop").on("click",()=>{n.addClass("closing"),setTimeout(()=>{n.remove()},300)}),n.appendTo("#app-mount")}static alert(e,t){if(this.ModalStack&&this.AlertModal)return this.default(e,t);this.ModalStack.push(function(n){return V.createElement(this.AlertModal,Object.assign({title:e,body:t},n))})}static showConfirmationModal(e,t,n={}){const s=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}=n;"string"==typeof t?t=s({color:s.Colors.PRIMARY,children:[t]}):Array.isArray(t)&&(t=s({color:s.Colors.PRIMARY,children:t})),t=[t];const u=()=>{};r.push(function(n){return V.createElement(o,Object.assign({header:e,children:t,red:d,confirmText:l||"Okay",cancelText:c||"Cancel",onConfirm:i||u,onCancel:a||u},n))})}static showContentErrors({plugins:e=[],themes:t=[]}){if(!e||!t||!this.shouldShowContentErrors)return;if(!e.length&&!t.length)return;const n=$('<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>'),s=function(e){const t=$('<div class="errors">');for(const n of e){const e=$(`<div class="error">\n <div class="table-column column-name">${n.name?n.name:n.file}</div>\n <div class="table-column column-message">${n.message}</div>\n <div class="table-column column-error"><a class="error-link" href="">${n.error?n.error.message:""}</a></div>\n </div>`);t.append(e),n.error&&e.find("a").on("click",e=>{e.preventDefault(),v.err("ContentManager",`Error details for ${n.name?n.name:n.file}.`,n.error)})}return t},o=[s(e),s(t)];n.find(".tab-bar-item").on("click",e=>{e.preventDefault(),n.find(".tab-bar-item").removeClass("selected"),$(e.target).addClass("selected"),n.find(".scroller").empty().append(o[$(e.target).index()])}),n.find(".footer button").on("click",()=>{n.addClass("closing"),setTimeout(()=>{n.remove()},300)}),n.find(".bd-backdrop").on("click",()=>{n.addClass("closing"),setTimeout(()=>{n.remove()},300)}),n.appendTo("#app-mount"),e.length?n.find(".tab-bar-item")[0].click():n.find(".tab-bar-item")[1].click()}}const Pe={get React(){return w.React},get ReactDOM(){return w.ReactDOM},get WindowConfigFile(){if(this._windowConfigFile)return this._windowConfigFile;const e=n(2).remote.app,t=n(1),s=e.getAppPath(),o=e.getPath("userData"),r=t.resolve(o,e.getVersion(),"modules","discord_desktop_core","injector","config.json"),i=t.resolve(s,"..","app","config.json"),a=n(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 s=n(0),o=this.getAllWindowPreferences();o[e]=t,delete n.c[this.WindowConfigFile],s.writeFileSync(this.WindowConfigFile,JSON.stringify(o,null,4))},injectCSS:function(e,t){$("head").append($("<style>",{id:v.escapeID(e),text:t}))},clearCSS:function(e){$("#"+v.escapeID(e)).remove()},linkJS:function(e,t){$("head").append($("<script>",{id:v.escapeID(e),src:t,type:"text/javascript"}))},unlinkJS:function(e){$("#"+v.escapeID(e)).remove()},getPlugin:function(e){return h.hasOwnProperty(e)?h[e].plugin:null},alert:function(e,t){Ee.alert(e,t)},showConfirmationModal:function(e,t,n={}){return Ee.showConfirmationModal(e,t,n)},showToast:function(e,t={}){Se.show(e,t)},findModule:function(e){return S.getModule(e)},findAllModules:function(e){return S.getModule(e,!1)},findModuleByProps:function(...e){return S.getByProps(...e)},findModuleByPrototypes:function(...e){return S.getByPrototypes(...e)},findModuleByDisplayName:function(e){return S.getByDisplayName(e)},getInternalInstance:function(e){if(e instanceof window.jQuery||e instanceof Element)return e instanceof jQuery&&(e=e[0]),v.getInternalInstance(e)},loadData:function(e,t){return k.getPluginData(e,t)}};Pe.getData=Pe.loadData,Pe.saveData=function(e,t,n){return k.setPluginData(e,t,n)},Pe.setData=Pe.saveData,Pe.deleteData=function(e,t){return k.deletePluginData(e,t)},Pe.monkeyPatch=function(e,t,n){return v.monkeyPatch(e,t,n)},Pe.onRemoved=function(e,t){return v.onRemoved(e,t)},Pe.suppressErrors=function(e,t){return v.suppressErrors(e,t)},Pe.testJSON=function(e){return v.testJSON(e)},Pe.isPluginEnabled=function(e){return!!c[e]},Pe.isThemeEnabled=function(e){return!!d[e]},Pe.isSettingEnabled=function(e){return!!a[e]},Pe.getBDData=function(e){return k.getBDData(e)},Pe.setBDData=function(e,t){return k.setBDData(e,t)};var xe=Pe;class ke extends V.Component{render(){return V.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"},V.createElement("metadata",null),V.createElement("defs",null,V.createElement("filter",{id:"shadow1"},V.createElement("feDropShadow",{dx:"20",dy:"0",stdDeviation:"20","flood-color":"rgba(0,0,0,0.35)"})),V.createElement("filter",{id:"shadow2"},V.createElement("feDropShadow",{dx:"15",dy:"0",stdDeviation:"20","flood-color":"rgba(255,255,255,0.15)"})),V.createElement("filter",{id:"shadow3"},V.createElement("feDropShadow",{dx:"10",dy:"0",stdDeviation:"20","flood-color":"rgba(0,0,0,0.35)"}))),V.createElement("g",null,V.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"}),V.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"}),V.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 De=new class{constructor(){this.editorDetached=!1}initialize(){xe.suppressErrors(this.patchSocial.bind(this),"BD Social Patch")(),xe.suppressErrors(this.patchGuildPills.bind(this),"BD Guild Pills Patch")(),xe.suppressErrors(this.patchGuildListItems.bind(this),"BD Guild List Items Patch")(),xe.suppressErrors(this.patchGuildSeparator.bind(this),"BD Guild Separator Patch")()}get messageClasses(){return S.getByProps("message","containerCozy")}get guildClasses(){const e=S.getByProps("wrapper","unreadMentionsBar"),t=S.getByProps("guildsError","selected"),n=S.getByProps("blobContainer");return Object.assign({},e,t,n)}get MessageContentComponent(){return S.getModule(e=>e.defaultProps&&e.defaultProps.hasOwnProperty("disableButtons"))}get TimeFormatter(){return S.getByProps("dateFormat")}get TooltipWrapper(){return S.getByDisplayName("TooltipDeprecated")}get NativeModule(){return S.getByProps("setBadge")}get Tooltips(){return S.getModule(e=>e.hide&&e.show&&!e.search&&!e.submit&&!e.search&&!e.activateRagingDemon&&!e.dismiss)}get KeyGenerator(){return S.getModule(e=>e.toString&&/"binary"/.test(e.toString()))}patchSocial(){if(this.socialPatch)return;const e=xe.findModule(e=>"TabBar"==e.displayName),t=xe.findModule(e=>"Anchor"==e.displayName);e&&t&&(this.socialPatch=xe.monkeyPatch(e.prototype,"render",{after:e=>{const n=e.returnValue.props.children;if(!n||!n.length)return;if("Separator"!==n[n.length-2].type.displayName)return;if(!n[n.length-1].type.toString().includes("socialLinks"))return;const s=n[n.length-1].type;n[n.length-1].type=function(){const e=s(...arguments);return e.props.children.push(xe.React.createElement(t,{className:"bd-social-link",href:"https://github.com/rauenzi/BetterDiscordApp",rel:"author",title:"BandagedBD",target:"_blank"},xe.React.createElement(ke,{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],n=xe.getInternalInstance(document.querySelector(`.${e} .${t}`).parentElement).return.type;n&&(this.guildListItemsPatch=xe.monkeyPatch(n.prototype,"render",{after:e=>{const t=e.returnValue,n=e.thisObject.props;return t.props.className+=" bd-guild",n.unread&&(t.props.className+=" bd-unread"),n.selected&&(t.props.className+=" bd-selected"),n.audio&&(t.props.className+=" bd-audio"),n.video&&(t.props.className+=" bd-video"),n.badge&&(t.props.className+=" bd-badge"),n.animatable&&(t.props.className+=" bd-animatable"),t}}))}patchGuildPills(){if(this.guildPillPatch)return;const e=xe.findModule(e=>e.default&&e.default.toString&&e.default.toString().includes("translate3d"));e&&(this.guildPillPatch=xe.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=xe.findModuleByDisplayName("Guilds"),t=xe.findModuleByProps("renderListItem");if(!t||!e)return;const n=function(){const e=t.Separator(...arguments);return e.props.className+=" bd-guild-separator",e};this.guildSeparatorPatch=xe.monkeyPatch(e.prototype,"render",{after:e=>{e.returnValue.props.children[1].props.children[3].type=n}})}},Me=new class{constructor(){this.renderer=new le,this.config=b,this.state=y,this.setup(b,y)}initialize(){k.initialize(),this.loadSettings(),this.patchSections()}getPath(e,t="",n=""){return{collection:3==e.length?e[0]:t,category:3==e.length?e[1]:2==e.length?e[0]:n,setting:e[e.length-1]}}setup(e,t){const n={};for(let s=0;s<e.length;s++){const o=e[s],r=e[s].settings;n[o.id]={};for(let e=0;e<r.length;e++){const s=r[e];if("category"!=s.type)n[o.id][s.id]=s.value;else{n[o.id][s.id]={};for(let e=0;e<s.settings.length;e++){const r=s.settings[e];if(n[o.id][s.id][r.id]=r.value,r.enableWith){const e=this.getPath(r.enableWith.split("."),o.id,s.id);Object.defineProperty(r,"disabled",{get:()=>!t[e.collection][e.category][e.setting]})}}}}if(o.enableWith){const e=this.getPath(o.enableWith.split("."));Object.defineProperty(o,"disabled",{get:()=>!t[e.collection][e.category][e.setting]})}}this.defaultState=n,Object.assign(this.state,this.defaultState)}buildSettingsPanel(e,t,n,s){return t.forEach(e=>{e.settings.forEach(t=>t.value=n[e.id][t.id])}),this.renderer.getSettingsPanel(e,t,s)}async patchSections(){const e=await this.getUserSettings();v.monkeyPatch(e.prototype,"generateSections",{after:e=>{let t=e.returnValue.findIndex(e=>"linux"==e.section.toLowerCase())+1;const n=n=>{e.returnValue.splice(t,0,n),t++};console.log(e),n({section:"DIVIDER"}),n({section:"HEADER",label:"BandagedBD"});for(const e of this.config)e.disabled||n({section:e.name,label:e.name,element:()=>this.buildSettingsPanel(e.name,e.settings,y[e.id],this.onSettingChange.bind(this,e.id))});n({section:"BBD Test",label:"Test Tab",onClick:function(){Se.success("This can just be a click listener!",{forceShow:!0})}}),n({section:"CUSTOM",element:()=>this.renderer.attribution})}}),this.forceUpdate()}forceUpdate(){const e=S.getByProps("standardSidebarView").standardSidebarView.split(" ")[0],t=document.querySelector(`.${e}`);v.getInternalInstance(t).return.return.return.return.return.return.stateNode.forceUpdate()}getUserSettings(){return new Promise(e=>{const t=v.monkeyPatch(S.getByProps("getUserSettingsSections").default.prototype,"render",{after:n=>{e(n.returnValue.type),n.thisObject.forceUpdate(),t()}})})}saveSettings(){k.setData("settings",this.state)}loadSettings(){const e=k.getData("settings");if(!e)return this.saveSettings();for(const t in this.defaultState){e[t]||Object.assign(e,{[t]:this.defaultState[t]});for(const n in this.defaultState[t]){e[t][n]||Object.assign(e[t][n],{[n]:this.defaultState[t][n]});for(const s in this.defaultState[t][n])null!=e[t][n][s]&&(this.state[t][n][s]=e[t][n][s])}}this.saveSettings()}onSettingChange(e,t,n,s){const o=this.config.filter(e=>e.disabled).length;this.state[e][t][n]=s,M.dispatch("setting-updated",e,t,n,s);const r=this.config.filter(e=>e.disabled).length;this.saveSettings(),o!=r&&this.forceUpdate()}getSetting(e,t,n){return 2==arguments.length?this.config[0].find(e=>e.id==arguments[0]).settings.find(e=>e.id==arguments[1]):this.config.find(t=>t.id==e).find(e=>e.id==t).settings.find(e=>e.id==n)}get(e,t,n){return 2==arguments.length?this.state[this.config[0].id][arguments[0]][arguments[1]]:this.state[e][t][n]}on(e,t,n,s){const o=(o,r,i,a)=>{o===e&&r===t&&i===n&&s(a)};return M.on("setting-updated",o),()=>{M.off("setting-updated",o)}}updateSettings(e,t,n,s){"fork-ps-5"==n&&(s?(G.watchContent("plugin"),G.watchContent("theme")):(G.unwatchContent("plugin"),G.unwatchContent("theme"))),"fork-wp-1"==n&&(xe.setWindowPreference("transparent",s),s?xe.setWindowPreference("backgroundColor",null):xe.setWindowPreference("backgroundColor","#2f3136"))}initializeSettings(){this.saveSettings()}};class Be{get name(){return"Unnamed Builtin"}get collection(){return"settings"}get category(){return"general"}get id(){return"None"}async initialize(){y[this.collection][this.category][this.id]&&await this.enable(),M.on("setting-updated",(e,t,n,s)=>{e==this.collection&&t===this.category&&n===this.id&&(s?this.enable():this.disable())})}registerSetting(e,t,n,s,o){return 4==arguments.length?(e=this.collection,t=arguments[0],n=arguments[1],s=arguments[2],o=arguments[3]):3==arguments.length&&(e=this.collection,t=this.category,n=arguments[0],s=arguments[1],o=arguments[2]),Me.on(e,t,n,e=>{e?s():o()})}get(e,t,n){return 2==arguments.length?(e=this.collection,t=arguments[0],n=arguments[1]):1==arguments.length&&(e=this.collection,t=this.category,n=arguments[0]),Me.get(e,t,n)}async enable(){this.log("Enabled"),await this.enabled()}async disable(){this.log("Disabled"),await this.disabled()}async enabled(){}async disabled(){}log(...e){v.log(this.name,...e)}warn(...e){v.warn(this.name,...e)}error(...e){v.err(this.name,...e)}}var $e=new class extends Be{get name(){return"VoiceMode"}get category(){return"appearance"}get id(){return"voiceMode"}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 Te=new RegExp("^(?!da-)((?:[A-Za-z]|[0-9]|-)+)-(?:[A-Za-z]|[0-9]|-|_){6}$");var Ne=new class extends Be{get id(){return"classNormalizer"}get category(){return"general"}get name(){return"ClassNormalizer"}enabled(){this.hasPatched||(this.patchClassModules(S.getModules(this.moduleFilter.bind(this))),this.normalizeElement(document.querySelector("#app-mount")),this.hasPatched=!0)}disabled(){this.hasPatched&&(this.unpatchClassModules(S.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 n=e[t];if("string"!=typeof n)return!1;if(!this.shouldIgnore(n)){if(1===n.split("-").length)return!1;if(!Te.test(n.split(" ")[0]))return!1}}return!0}patchClassModule(e,t){for(const n in t){const s=t[n];if(this.shouldIgnore(s))continue;const o=s.split(" ");for(const s of o){const o=s.match(Te)[1];if(!o)continue;const r=o.split("-").map((e,t)=>t?e[0].toUpperCase()+e.slice(1):e).join("");t[n]+=` ${e}-${r}`}}}unpatchClassModule(e,t){for(const n in t){const s=t[n];if(this.shouldIgnore(s))continue;let o="";const r=s.split(" ");for(const t of r)t.startsWith(`${e}-`)||(o+=` ${t}`);t[n]=o.trim()}}normalizeElement(e){if(!(e instanceof Element))return;const t=e.classList;for(let n=0,s=t.length;n<s;n++){if(!Te.test(t[n]))continue;const s=t[n].match(Te)[1].split("-").map((e,t)=>t?e[0].toUpperCase()+e.slice(1):e).join("");e.classList.add(`da-${s}`)}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,n=[];for(let e=0;e<t.length;e++)t[e].startsWith("da-")&&n.push(t[e]);e.classList.remove(...n)}},je=new class extends Be{get name(){return"DeveloperMode"}get category(){return"developer"}get id(){return"developerMode"}get selectorModeID(){return"copySelector"}get selectorMode(){return this.get(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=this.registerSetting(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 n=$("<div/>",{class:"itemGroup-1tL0uz"}),s=$("<div/>",{class:"item-1Yvehc",click:()=>{w.ElectronModule.copy(this.lastSelector),t.hide()}}).append($("<span/>",{text:"Copy Selector"}));n.append(s),t.append(n),t.hasClass("undefined")&&t.css("top","-="+n.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),n=t[t.length-1];return n?n.selectorText:e.classList.length?`.${Array.from(e.classList).join(".")}`:`.${Array.from(e.parentElement.classList).join(".")}`}},Fe=new class extends Be{get name(){return"PublicServers"}get category(){return"general"}get id(){return"publicServers"}enabled(){const e=De.guildClasses.wrapper.split(" ")[0];$(`.${e} .scroller-2FKFPG >:first-child`).after(this.button)}disabled(){$("#bd-pub-li").remove()}get component(){return w.React.createElement(s.Layer,{rootId:"pubslayerroot",id:"pubslayer"},w.React.createElement(s.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?w.ReactDOM.render(this.component,e):this.error("FAILED TO LOCATE ROOT: .layers")}get button(){return $("<div/>",{class:De.guildClasses.listItem,id:"bd-pub-li"}).append($("<div/>",{class:"wrapper-25eVIn "+De.guildClasses.circleButtonMask,text:"public",id:"bd-pub-button",click:()=>{this.render()}}))}},Oe=new class extends Be{get name(){return"DarkMode"}get category(){return"appearance"}get id(){return"darkMode"}enabled(){$("#app-mount").addClass("bda-dark").addClass("bd-dark")}disabled(){$("#app-mount").removeClass("bda-dark").removeClass("bd-dark")}},Ae=new class extends Be{get name(){return"MinimalMode"}get category(){return"appearance"}get id(){return"minimalMode"}get hideChannelsID(){return"hideChannels"}get hideChannels(){return this.get(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=this.registerSetting(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")}},Ie=new class extends Be{get name(){return"24Hour"}get category(){return"general"}get id(){return"twentyFourHour"}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 n=t.returnValue.match(e);if(n&&4===n.length)return"AM"===n[3]?t.returnValue=t.returnValue.replace(n[0],`${"12"===n[1]?"00":n[1].padStart(2,"0")}:${n[2]}`):t.returnValue=t.returnValue.replace(n[0],`${"12"===n[1]?"12":parseInt(n[1])+12}:${n[2]}`)},n=v.monkeyPatch(w.TimeFormatter,"calendarFormat",{after:t}),s=v.monkeyPatch(w.TimeFormatter,"dateFormat",{after:t});this.cancel24Hour=()=>{n(),s()}}};const Le=S.getModule(e=>e.defaultProps&&e.defaultProps.hasOwnProperty("disableButtons"));var Re=new class extends Be{get name(){return"ColoredText"}get category(){return"appearance"}get id(){return"coloredText"}enabled(){this.injectColoredText()}disabled(){this.cancelColoredText&&(this.cancelColoredText(),delete this.cancelColoredText)}injectColoredText(){this.cancelColoredText||(this.cancelColoredText=v.monkeyPatch(Le.prototype,"render",{after:e=>{v.monkeyPatch(e.returnValue.props,"children",{silent:!0,after:({returnValue:t})=>{const n=t.props.children[1],s=e.thisObject.props.message.colorString;return n&&s&&(n.props.style={color:s}),t}})}}))}removeColoredText(){document.querySelectorAll(".markup-2BOw-j").forEach(e=>{e.style.setProperty("color","")})}},Ge=new class extends Be{get name(){return"VoiceDisconnect"}get category(){return"general"}get id(){return"voiceDisconnect"}constructor(){super(),this.beforeUnload=this.beforeUnload.bind(this)}enabled(){window.addEventListener("beforeunload",this.beforeUnload)}disabled(){window.removeEventListener("beforeunload",this.beforeUnload)}beforeUnload(){w.ChannelActions.selectVoiceChannel(null,null)}};const Ve=(e,t,n={})=>{const{onContextMenu:s,onClick:o}=n,r=$(`<div class="emote-container">\n <img class="emote-icon" alt="${e}" src="${t}" title="${e}">\n </div>`)[0];return s&&r.addEventListener("contextmenu",s),r.addEventListener("click",o),r};var He=new class extends Be{get name(){return"EmoteMenu"}get collection(){return"emotes"}get category(){return"general"}get id(){return"emoteMenu"}get hideEmojisID(){return"hideEmojiMenu"}get hideEmojis(){return this.get(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=this.registerSetting(this.hideEmojisID,this.enableHideEmojis,this.disableHideEmojis),this.hideEmojis&&this.enableHideEmojis(),r.emotesLoaded&&this.updateTwitchEmotes(),M.on("emotes-loaded",this.updateTwitchEmotes)}disabled(){M.off("emotes-loaded",this.updateTwitchEmotes),this.observer.disconnect(),this.disableHideEmojis(),this.hideEmojiCancel&&this.hideEmojiCancel()}async waitForEmotes(){if(!r.emotesLoaded)return new Promise(e=>{M.on("emotes-loaded",e)})}enableHideEmojis(){$(".emojiPicker-3m1S-j").addClass("bda-qme-hidden")}disableHideEmojis(){$(".emojiPicker-3m1S-j").removeClass("bda-qme-hidden")}insertEmote(e){const t=v.getTextArea();v.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],n=$('<div id="removemenu" class="bd-context-menu context-menu theme-dark">Remove</div>');n.css({top:e.pageY-$("#bda-qem-favourite-container").offset().top,left:e.pageX-$("#bda-qem-favourite-container").offset().left}),$(t).parent().append(n),n.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 n=$("#bda-qem-twitch"),s=$("#bda-qem-favourite"),o=$("#bda-qem-emojis");switch(n.removeClass("active"),s.removeClass("active"),o.removeClass("active"),$(".emojiPicker-3m1S-j").hide(),$("#bda-qem-favourite-container").hide(),$("#bda-qem-twitch-container").hide(),t){case"bda-qem-twitch":n.addClass("active"),$("#bda-qem-twitch-container").show();break;case"bda-qem-favourite":s.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 n=$(t);this.hideEmojis?n.addClass("bda-qme-hidden"):n.removeClass("bda-qme-hidden"),n.prepend(this.qmeHeader),n.append(this.teContainer),n.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],n=Ve(e,t,{onClick:this.insertEmote.bind(this,e)});this.teContainerInner.append(n)}}updateFavorites(){for(;this.faContainerInner.firstChild;)this.faContainerInner.firstChild.remove();for(const e in this.favoriteEmotes){const t=this.favoriteEmotes[e],n=Ve(e,t,{onClick:this.insertEmote.bind(this,e),onContextMenu:this.favContext.bind(this)});this.faContainerInner.append(n)}k.setBDData("bdfavemotes",btoa(JSON.stringify(this.favoriteEmotes)))}},We=new class extends Be{get name(){return"EmoteAutocapitalize"}get collection(){return"emotes"}get category(){return"general"}get id(){return"autoCaps"}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 n=this.capitalize(t.toLowerCase());null!=n&&v.insertText(v.getTextArea()[0],e.replace(t,n))}})}disabled(){$("body").off(".bdac")}capitalize(e){const t=p.TwitchGlobal;for(const n in t)if(t.hasOwnProperty(n)&&e==(n+"").toLowerCase())return n}};class ze extends w.React.Component{constructor(e){super(e);const t=!!(He&&He.favoriteEmotes&&He.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&&He.favoriteEmotes[this.label]?this.setState({isFavorite:!0}):this.state.isFavorite&&!He.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 w.React.createElement(De.TooltipWrapper,{color:"black",position:"top",text:this.label,delay:750},w.React.createElement("div",{className:"emotewrapper"+(this.props.jumboable?" jumboable":""),onMouseEnter:this.onMouseEnter,onMouseLeave:this.onMouseLeave,onClick:this.onClick},w.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}),w.React.createElement("input",{className:"fav"+(this.state.isFavorite?" active":""),title:"Favorite!",type:"button",onClick:e=>{e.preventDefault(),e.stopPropagation(),this.state.isFavorite?(delete He.favoriteEmotes[this.label],He.updateFavorites()):He.favorite(this.label,this.props.url),this.setState({isFavorite:!this.state.isFavorite})}})))}}const qe={TwitchGlobal:"twitch",TwitchSubscriber:"twitch",BTTV:"bttv",FrankerFaceZ:"ffz",BTTV2:"bttv"};var Ue=new class extends Be{get name(){return"Emotes"}get collection(){return"settings"}get category(){return"general"}get id(){return"emotes"}get categories(){return Object.keys(qe).filter(e=>this.isCategoryEnabled(qe[e]))}get MessageContentComponent(){return S.getModule(e=>e.defaultProps&&e.defaultProps.hasOwnProperty("disableButtons"))}isCategoryEnabled(e){return super.get("emotes","categories",e)}get(e){return super.get("emotes","general",e)}async enabled(){}disabled(){this.emptyEmotes(),this.cancelEmoteRender||(this.cancelEmoteRender(),delete this.cancelEmoteRender)}emptyEmotes(){for(const e in p)Object.assign(p,{[e]:{}})}patchMessageContent(){this.cancelEmoteRender||(this.cancelEmoteRender=v.monkeyPatch(this.MessageContentComponent.prototype,"render",{after:({returnValue:e})=>{v.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 n=t.props.children[1];if(n&&n.length){for(let e=0;e<n.length;e++){const t=n[e];if("string"!=typeof t)continue;const s=t.split(/([^\s]+)([\s]|$)/g);for(let t=0,o=this.categories.length;t<o;t++)for(let o=0,r=s.length;o<r;o++){const r=s[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[qe[d]])continue;const u=n[e].match(new RegExp(`([\\s]|^)${v.escape(l?i+":"+l:i)}([\\s]|$)`));if(!u)continue;const h=n[e].substring(0,u.index+u[1].length),b=n[e].substring(u.index+u[0].length-u[2].length);n[e]=h;const y=w.React.createElement(ze,{name:i,url:p[d][i],modifier:l});n.splice(e+1,0,b),n.splice(e+1,0,y)}}if(n.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 n)"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=n(0),s=l.dataPath+"emote_data.json";if(t.existsSync(s)&&this.isCacheValid()){Se.show("Loading emotes from cache.",{type:"info"}),v.log("Emotes","Loading emotes from local cache.");const n=await new Promise(e=>{t.readFile(s,"utf8",(t,n)=>{v.log("Emotes","Emotes loaded from cache."),t&&(n={}),e(n)})});let o=v.testJSON(n);o&&Object.assign(p,JSON.parse(n));for(const t in e)o=Object.keys(p[e[t].variable]).length>0;if(o)return Se.show("Emotes successfully loaded.",{type:"success"}),r.emotesLoaded=!0,void M.dispatch("emotes-loaded");v.log("Emotes","Cache was corrupt, downloading..."),t.unlinkSync(s)}if(a["fork-es-3"]){Se.show("Downloading emotes in the background do not reload.",{type:"info"});for(const t in e){await new Promise(e=>setTimeout(e,1e3));const n=await this.downloadEmotes(e[t]);p[e[t].variable]=n}Se.show("All emotes successfully downloaded.",{type:"success"});try{t.writeFileSync(s,JSON.stringify(p),"utf8")}catch(e){v.err("Emotes","Could not save emote data.",e)}r.emotesLoaded=!0,M.dispatch("emotes-loaded")}}downloadEmotes(e){const t=n(5),s={url:e.url,timeout:e.timeout?e.timeout:5e3};return v.log("Emotes",`Downloading: ${e.variable} (${e.url})`),new Promise((n,o)=>{t(s,(t,s,r)=>{if(t)return v.err("Emotes","Could not download "+e.variable,t),e.backup?(e.url=e.backup,e.backup=null,e.backupParser&&(e.parser=e.backupParser),n(this.downloadEmotes(e))):o({});let i={};try{i=JSON.parse(r)}catch(t){return v.err("Emotes","Could not download "+e.variable,t),e.backup?(e.url=e.backup,e.backup=null,e.backupParser&&(e.parser=e.backupParser),n(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]);n(i),v.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),n=new Date;return!(Math.round(Math.abs((n.getTime()-t.getTime())/864e5))>e)||(k.setBDData("emoteCacheDate",n.toJSON()),!1)}clearEmoteData(){const e=n(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 _e(){}_e.prototype.setConfig=function(e){Object.assign(l,e)},_e.prototype.init=async function(){if(l.version<l.minSupportedVersion)return void Ee.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&&Ee.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 `),v.log("Startup","Initializing Settings"),Me.initialize(),v.log("Startup","Initializing EmoteModule"),this.injectExternals(),await this.checkForGuilds(),De.initialize(),v.log("Startup","Updating Settings");for(const e in o)o[e].initialize();v.log("Startup","Loading Plugins");const t=T.loadPlugins();v.log("Startup","Loading Themes");const n=j.loadThemes();$("#customcss").detach().appendTo(document.head),v.log("Startup","Removing Loading Icon"),document.getElementsByClassName("bd-loaderv2")[0].remove(),v.log("Startup","Initializing Main Observer"),this.initObserver(),v.log("Startup","Collecting Startup Errors"),Ee.showContentErrors({plugins:t,themes:n})},_e.prototype.checkForGuilds=function(){return new Promise(e=>{const t=function(){const n=De.guildClasses.wrapper.split(" ")[0],s=De.guildClasses.listItem.split(" ")[0],o=De.guildClasses.blobContainer.split(" ")[0];if(document.querySelectorAll(`.${n} .${s} .${o}`).length>0)return e(l.deferLoaded=!0);setTimeout(t,100)};$(document).ready(function(){setTimeout(t,100)})})},_e.prototype.injectExternals=async function(){await v.injectJs("https://cdnjs.cloudflare.com/ajax/libs/ace/1.2.9/ace.js"),window.require.original&&(window.require=window.require.original)},_e.prototype.initObserver=function(){new MutationObserver(e=>{for(let t=0,n=e.length;t<n;t++){const n=e[t];if(void 0!==T&&T.rawObserver(n),!(n.addedNodes.length&&n.addedNodes[0]instanceof Element))continue;const s=n.addedNodes[0];s.classList.contains("layer-3QrUeG")&&s.getElementsByClassName("guild-settings-base-section").length&&s.setAttribute("layer-id","server-settings")}}).observe(document,{childList:!0,subtree:!0})};var Je=new _e;n.d(t,"default",function(){return Ye}),n.d(t,"patchModuleLoad",function(){return Ke}),function(){const e=n(0),t=process.platform,s=("win32"===t?process.env.APPDATA:"darwin"===t?process.env.HOME+"/Library/Preferences":process.env.HOME+"/.config")+"/BetterDiscord/";let o={};if(e.existsSync(`${s}localStorage.json`))try{o=JSON.parse(e.readFileSync(`${s}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(`${s}localStorage.json`,JSON.stringify(this),null,4)};const i=new Proxy(r,{set:function(e,t,n){r[t]=n,r.save()},get:function(e,t){return r[t]||null}});window.localStorage=i}();const Ze=document.createElement("div");Ze.className="bd-loaderv2",Ze.title="BandagedBD is loading...",document.body.appendChild(Ze),window.BdApi=xe,window.settings=i,window.settingsCookie=a,window.pluginCookie=c,window.themeCookie=d,window.pluginModule=T,window.themeModule=j,window.bdthemes=u,window.bdplugins=h,window.bdEmotes=p,window.bemotes=m,window.bdPluginStorage=class{static get(e,t){return v.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,n){if(v.warn("Deprecation Notice",`${e}, please use BdApi.saveData() or BdApi.setData(). bdPluginStorage may be removed in future versions.`),void 0===n)return v.warn("Deprecation Notice","Trying to set undefined value in plugin "+e);k.setPluginData(e,t,n)}static delete(e,t){v.warn("Deprecation Notice",`${e}, please use BdApi.deleteData(). bdPluginStorage may be removed in future versions.`),k.deletePluginData(e,t)}},window.BDEvents=M,window.bdConfig=l;class Ye{constructor(e){Je.setConfig(e)}init(){Je.init()}}function Ke(){const e=n(3),t=e._load;return e._load=function(e){if("betterdiscord"===e||e.startsWith("betterdiscord/")){if("api"==e.substr("betterdiscord/".length))return xe}return t.apply(this,arguments)},function(){e._load=t}}}]).default;