BetterDiscordApp-rauenzi/js/main.min.js

1 line
105 KiB
JavaScript

var Core=function(e){var t={};function s(n){if(t[n])return t[n].exports;var r=t[n]={i:n,l:!1,exports:{}};return e[n].call(r.exports,r,r.exports,s),r.l=!0,r.exports}return s.m=e,s.c=t,s.d=function(e,t,n){s.o(e,t)||Object.defineProperty(e,t,{enumerable:!0,get:n})},s.r=function(e){"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(e,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(e,"__esModule",{value:!0})},s.t=function(e,t){if(1&t&&(e=s(e)),8&t)return e;if(4&t&&"object"==typeof e&&e&&e.__esModule)return e;var n=Object.create(null);if(s.r(n),Object.defineProperty(n,"default",{enumerable:!0,value:e}),2&t&&"string"!=typeof e)for(var r in e)s.d(n,r,function(t){return e[t]}.bind(null,r));return n},s.n=function(e){var t=e&&e.__esModule?function(){return e.default}:function(){return e};return s.d(t,"a",t),t},s.o=function(e,t){return Object.prototype.hasOwnProperty.call(e,t)},s.p="",s(s.s=6)}([function(e,t){e.exports=require("fs")},function(e,t){e.exports=require("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,s){"use strict";s.r(t);var n={};s.r(n),s.d(n,"Menu",function(){return ge}),s.d(n,"Card",function(){return me}),s.d(n,"Layer",function(){return fe});var r={};s.r(r),s.d(r,"VoiceMode",function(){return ke}),s.d(r,"ClassNormalizer",function(){return Me}),s.d(r,"DeveloperMode",function(){return Be}),s.d(r,"PublicServers",function(){return Ne}),s.d(r,"DarkMode",function(){return Te}),s.d(r,"MinimalMode",function(){return $e}),s.d(r,"TwentyFourHour",function(){return je}),s.d(r,"ColoredText",function(){return Le}),s.d(r,"VoiceDisconnect",function(){return Oe}),s.d(r,"EmoteMenu",function(){return Ue}),s.d(r,"EmoteAutocaps",function(){return _e}),s.d(r,"EmoteModule",function(){return He});var i={local:!1,localServer:"//localhost:8080",minified:!0,version:"0.3.0",branch:"master",repo:"rauenzi",minSupportedVersion:"0.3.0",bbdVersion:"0.2.17"},o={TwitchGlobal:{url:"https://twitchemotes.com/api_cache/v3/global.json",backup:"https://rauenzi.github.io/BetterDiscordApp/data/emotedata_twitch_global.json",variable:"TwitchGlobal",getEmoteURL:e=>`https://static-cdn.jtvnw.net/emoticons/v1/${e.id}/1.0`,getOldData:(e,t)=>({id:e.match(/\/([0-9]+)\//)[1],code:t,emoticon_set:0,description:null})},TwitchSubscriber:{url:"https://rauenzi.github.io/BetterDiscordApp/data/emotedata_twitch_subscriber.json",variable:"TwitchSubscriber",getEmoteURL:e=>`https://static-cdn.jtvnw.net/emoticons/v1/${e}/1.0`,getOldData:e=>e.match(/\/([0-9]+)\//)[1]},FrankerFaceZ:{url:"https://rauenzi.github.io/BetterDiscordApp/data/emotedata_ffz.json",variable:"FrankerFaceZ",getEmoteURL:e=>`https://cdn.frankerfacez.com/emoticon/${e}/1`,getOldData:e=>e.match(/\/([0-9]+)\//)[1]},BTTV:{url:"https://api.betterttv.net/emotes",variable:"BTTV",parser:e=>{const t={};for(let s=0,n=e.emotes.length;s<n;s++){const n=e.emotes[s];t[n.regex]=n.url}return t},getEmoteURL:e=>`${e}`,getOldData:e=>e},BTTV2:{url:"https://rauenzi.github.io/BetterDiscordApp/data/emotedata_bttv.json",variable:"BTTV2",oldVariable:"emotesBTTV2",getEmoteURL:e=>`https://cdn.betterttv.net/emote/${e}/1x`,getOldData:e=>e.match(/emote\/(.+)\//)[1]}},a=[{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}]}],l=[{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}]}];class c{static get screenWidth(){return Math.max(document.documentElement.clientWidth,window.innerWidth||0)}static get screenHeight(){return Math.max(document.documentElement.clientHeight,window.innerHeight||0)}static stripBOM(e){return 65279===e.charCodeAt(0)&&(e=e.slice(1)),e}static getTextArea(){return $(".channelTextArea-1LDbYG textarea")}static getInternalInstance(e){return e[Object.keys(e).find(e=>e.startsWith("__reactInternalInstance"))]||null}static insertText(e,t){e.focus(),e.selectionStart=0,e.selectionEnd=e.value.length,document.execCommand("insertText",!1,t)}static injectCss(e){$("<link/>",{type:"text/css",rel:"stylesheet",href:e}).appendTo($("head"))}static injectJs(e){return new Promise(t=>{$("<script/>",{type:"text/javascript",src:e,onload:t}).appendTo($("body"))})}static escapeID(e){return e.replace(/^[^a-z]+|[^\w-]+/gi,"")}static log(e,t){console.log(`%c[BandagedBD]%c [${e}]%c ${t}`,"color: #3a71c1; font-weight: 700;","color: #3a71c1;","")}static warn(e,t){console.warn(`%c[BandagedBD]%c [${e}]%c ${t}`,"color: #E8A400; font-weight: 700;","color: #E8A400;","")}static err(e,t,s){console.log(`%c[BandagedBD]%c [${e}]%c ${t}`,"color: red; font-weight: 700;","color: red;",""),s&&(console.groupCollapsed("%cError: "+s.message,"color: red;"),console.error(s.stack),console.groupEnd())}static escape(e){return e.replace(/[-\/\\^$*+?.()|[\]{}]/g,"\\$&")}static testJSON(e){try{return JSON.parse(e),!0}catch(e){return!1}}static suppressErrors(e,t){return(...s)=>{try{return e(...s)}catch(e){this.err("SuppressedError","Error occurred in "+t,e)}}}static monkeyPatch(e,t,s){const{before:n,after:r,instead:i,once:o=!1,silent:a=!1,force:l=!1}=s,d=s.displayName||e.displayName||e.name||e.constructor.displayName||e.constructor.name;if(a||console.log("patch",t,"of",d),!e[t]){if(!l)return console.error(t,"does not exist for",d);e[t]=function(){}}const h=e[t],u=()=>{a||console.log("unpatch",t,"of",d),e[t]=h};return e[t]=function(){const s={thisObject:this,methodArguments:arguments,cancelPatch:u,originalMethod:h,callOriginalMethod:()=>s.returnValue=s.originalMethod.apply(s.thisObject,s.methodArguments)};if(i){const n=c.suppressErrors(i,"`instead` callback of "+e[t].displayName)(s);void 0!==n&&(s.returnValue=n)}else n&&c.suppressErrors(n,"`before` callback of "+e[t].displayName)(s),s.callOriginalMethod(),r&&c.suppressErrors(r,"`after` callback of "+e[t].displayName)(s);return o&&u(),s.returnValue},e[t].__monkeyPatched=!0,e[t].__originalMethod||(e[t].__originalMethod=h),e[t].displayName="patched "+(e[t].displayName||t),u}static onRemoved(e,t){const s=new MutationObserver(n=>{for(let r=0;r<n.length;r++){const i=n[r],o=Array.from(i.removedNodes),a=o.indexOf(e)>-1,l=o.some(t=>t.contains(e));(a||l)&&(s.disconnect(),t())}});s.observe(document.body,{subtree:!0,childList:!0})}static isEmpty(e){if(null==e||null==e||""==e)return!0;if("object"!=typeof e)return!1;if(Array.isArray(e))return 0==e.length;for(const t in e)if(e.hasOwnProperty(t))return!1;return!0}static memoizeObject(e){const t=new Proxy(e,{get:function(e,t){if(e.hasOwnProperty(t)){if(Object.getOwnPropertyDescriptor(e,t).get){const s=e[t];delete e[t],e[t]=s}return e[t]}},set:function(e,t,s){return e.hasOwnProperty(t)?this.err("MemoizedObject","Trying to overwrite existing property"):(e[t]=s,e[t])}});return Object.defineProperty(t,"hasOwnProperty",{value:function(e){return void 0!==this[e]}}),t}static className(){const e=[],t={}.hasOwnProperty;for(let s=0;s<arguments.length;s++){const n=arguments[s];if(!n)continue;const r=typeof n;if("string"===r||"number"===r)e.push(n);else if(Array.isArray(n)&&n.length){const t=this.classNames.apply(null,n);t&&e.push(t)}else if("object"===r)for(const s in n)t.call(n,s)&&n[s]&&e.push(s)}return e.join(" ")}}const d=c.memoizeObject({get React(){return u.getByProps("createElement","cloneElement")},get ReactDOM(){return u.getByProps("render","findDOMNode")},get Flux(){return u.getByProps("connectStores")},get Events(){return u.getByPrototypes("setMaxListeners","emit")},get GuildStore(){return u.getByProps("getGuild")},get SortedGuildStore(){return u.getByProps("getSortedGuilds")},get SelectedGuildStore(){return u.getByProps("getLastSelectedGuildId")},get GuildSync(){return u.getByProps("getSyncedGuilds")},get GuildInfo(){return u.getByProps("getAcronym")},get GuildChannelsStore(){return u.getByProps("getChannels","getDefaultChannel")},get GuildMemberStore(){return u.getByProps("getMember")},get MemberCountStore(){return u.getByProps("getMemberCounts")},get GuildEmojiStore(){return u.getByProps("getEmojis")},get GuildActions(){return u.getByProps("markGuildAsRead")},get GuildPermissions(){return u.getByProps("getGuildPermissions")},get ChannelStore(){return u.getByProps("getChannels","getDMFromUserId")},get SelectedChannelStore(){return u.getByProps("getLastSelectedChannelId")},get ChannelActions(){return u.getByProps("selectChannel")},get PrivateChannelActions(){return u.getByProps("openPrivateChannel")},get ChannelSelector(){return u.getByProps("selectGuild","selectChannel")},get UserInfoStore(){return u.getByProps("getToken")},get UserSettingsStore(){return u.getByProps("guildPositions")},get AccountManager(){return u.getByProps("register","login")},get UserSettingsUpdater(){return u.getByProps("updateRemoteSettings")},get OnlineWatcher(){return u.getByProps("isOnline")},get CurrentUserIdle(){return u.getByProps("getIdleTime")},get RelationshipStore(){return u.getByProps("isBlocked","getFriendIDs")},get RelationshipManager(){return u.getByProps("addRelationship")},get MentionStore(){return u.getByProps("getMentions")},get UserStore(){return u.getByProps("getCurrentUser")},get UserStatusStore(){return u.getByProps("getStatus","getState")},get UserTypingStore(){return u.getByProps("isTyping")},get UserActivityStore(){return u.getByProps("getActivity")},get UserNameResolver(){return u.getByProps("getName")},get UserNoteStore(){return u.getByProps("getNote")},get UserNoteActions(){return u.getByProps("updateNote")},get EmojiInfo(){return u.getByProps("isEmojiDisabled")},get EmojiUtils(){return u.getByProps("getGuildEmoji")},get EmojiStore(){return u.getByProps("getByCategory","EMOJI_NAME_RE")},get InviteStore(){return u.getByProps("getInvites")},get InviteResolver(){return u.getByProps("findInvite")},get InviteActions(){return u.getByProps("acceptInvite")},get DiscordConstants(){return u.getByProps("Permissions","ActivityTypes","StatusTypes")},get DiscordPermissions(){return u.getByProps("Permissions","ActivityTypes","StatusTypes").Permissions},get PermissionUtils(){return u.getByProps("getHighestRole")},get ColorConverter(){return u.getByProps("hex2int")},get ColorShader(){return u.getByProps("darken")},get TinyColor(){return u.getByPrototypes("toRgb")},get ClassResolver(){return u.getByProps("getClass")},get ButtonData(){return u.getByProps("ButtonSizes")},get IconNames(){return u.getByProps("IconNames")},get NavigationUtils(){return u.getByProps("transitionTo","replaceWith","getHistory")},get MessageStore(){return u.getByProps("getMessages")},get MessageActions(){return u.getByProps("jumpToMessage","_sendMessage")},get MessageQueue(){return u.getByProps("enqueue")},get MessageParser(){return u.getByProps("createMessage","parse","unparse")},get hljs(){return u.getByProps("highlight","highlightBlock")},get SimpleMarkdown(){return u.getByProps("parseBlock","parseInline","defaultOutput")},get ExperimentStore(){return u.getByProps("getExperimentOverrides")},get ExperimentsManager(){return u.getByProps("isDeveloper")},get CurrentExperiment(){return u.getByProps("getExperimentId")},get ImageResolver(){return u.getByProps("getUserAvatarURL","getGuildIconURL")},get ImageUtils(){return u.getByProps("getSizedImageSrc")},get AvatarDefaults(){return u.getByProps("getUserAvatarURL","DEFAULT_AVATARS")},get WindowInfo(){return u.getByProps("isFocused","windowSize")},get TagInfo(){return u.getByProps("VALID_TAG_NAMES")},get DOMInfo(){return u.getByProps("canUseDOM")},get LocaleManager(){return u.getByProps("setLocale")},get Moment(){return u.getByProps("parseZone")},get LocationManager(){return u.getByProps("createLocation")},get Timestamps(){return u.getByProps("fromTimestamp")},get TimeFormatter(){return u.getByProps("dateFormat")},get Strings(){return u.getByProps("Messages").Messages},get StringFormats(){return u.getByProps("a","z")},get StringUtils(){return u.getByProps("toASCII")},get URLParser(){return u.getByProps("Url","parse")},get ExtraURLs(){return u.getByProps("getArticleURL")},get DNDActions(){return u.getByProps("beginDrag")},get DNDSources(){return u.getByProps("addTarget")},get DNDObjects(){return u.getByProps("DragSource")},get MediaDeviceInfo(){return u.getByProps("Codecs","SUPPORTED_BROWSERS")},get MediaInfo(){return u.getByProps("getOutputVolume")},get MediaEngineInfo(){return u.getByProps("MediaEngineFeatures")},get VoiceInfo(){return u.getByProps("EchoCancellation")},get VideoStream(){return u.getByProps("getVideoStream")},get SoundModule(){return u.getByProps("playSound")},get ElectronModule(){return u.getByProps("setBadge")},get Dispatcher(){return u.getByProps("dirtyDispatch")},get PathUtils(){return u.getByProps("hasBasename")},get NotificationModule(){return u.getByProps("showNotification")},get RouterModule(){return u.getByProps("Router")},get APIModule(){return u.getByProps("getAPIBaseURL")},get AnalyticEvents(){return u.getByProps("AnalyticEventConfigs")},get KeyGenerator(){return u.getByRegex(/"binary"/)},get Buffers(){return u.getByProps("Buffer","kMaxLength")},get DeviceStore(){return u.getByProps("getDevices")},get SoftwareInfo(){return u.getByProps("os")},get CurrentContext(){return u.getByProps("setTagsContext")}});class h{static byProperties(e,t=(e=>e)){return s=>{const n=t(s);return!!n&&e.every(e=>void 0!==n[e])}}static byPrototypeFields(e,t=(e=>e)){return s=>{const n=t(s);return!!n&&(!!n.prototype&&e.every(e=>void 0!==n.prototype[e]))}}static byCode(e,t=(e=>e)){return s=>{const n=t(s);return!!n&&-1!==n.toString([]).search(e)}}static byString(...e){return t=>{const s=t.toString([]);for(const t of e)if(!s.includes(t))return!1;return!0}}static byDisplayName(e){return t=>t&&t.displayName===e}static combine(...e){return t=>e.every(e=>e(t))}}class u{static find(e,t=!0){return this.getModule(e,t)}static findAll(e){return this.getModule(e,!1)}static findByUniqueProperties(e,t=!0){return t?this.getByProps(...e):this.getAllByProps(...e)}static findByDisplayName(e){return this.getByDisplayName(e)}static getModule(e,t=!0){const s=this.getAllModules(),n=[];for(const r in s){if(!s.hasOwnProperty(r))continue;const i=s[r],{exports:o}=i;let a=null;if(o&&(o.__esModule&&o.default&&e(o.default)&&(a=o.default),e(o)&&(a=o),a)){if(t)return a;n.push(a)}}return t||0==n.length?void 0:n}static getModules(e){return this.getModule(e,!1)}static getModuleByName(e,t){if(d.hasOwnProperty(e))return d[e];if(!t)return;const s=this.getModule(t,!0);return s?d[e]=s:void 0}static getByDisplayName(e){return this.getModule(h.byDisplayName(e),!0)}static getByRegex(e,t=!0){return this.getModule(h.byCode(e),t)}static getByPrototypes(...e){return this.getModule(h.byPrototypeFields(e),!0)}static getAllByPrototypes(...e){return this.getModule(h.byPrototypeFields(e),!1)}static getByProps(...e){return this.getModule(h.byProperties(e),!0)}static getAllByProps(...e){return this.getModule(h.byProperties(e),!1)}static getByString(...e){return this.getModule(h.byString(...e),!0)}static getAllByString(...e){return this.getModule(h.byString(...e),!1)}static get require(){if(this._require)return this._require;const e="bbd-webpackmodules",t="function"==typeof window.webpackJsonp?window.webpackJsonp([],{[e]:(e,t,s)=>t.default=s},[e]).default:window.webpackJsonp.push([[],{[e]:(e,t,s)=>e.exports=s},[[e]]]);return delete t.m[e],delete t.c[e],this._require=t}static getAllModules(){return this.require.c}}const p=s(0),m=s(1),g=DiscordNative.globals.releaseChannel;var f=new class{constructor(){this.data={misc:{}},this.pluginData={}}initialize(){p.existsSync(this.baseFolder)||p.mkdirSync(this.baseFolder),p.existsSync(this.dataFolder)||p.mkdirSync(this.dataFolder),p.existsSync(this.BDFile)||p.writeFileSync(this.BDFile,JSON.stringify(this.data.misc,null,4));const e=p.readdirSync(this.dataFolder).filter(e=>!p.statSync(m.resolve(this.dataFolder,e)).isDirectory()&&e.endsWith(".json"));for(const t of e)this.data[t.split(".")[0]]=require(m.resolve(this.dataFolder,t))}get baseFolder(){return this._baseFolder||(this._baseFolder=m.resolve(i.dataPath,"data"))}get dataFolder(){return this._dataFolder||(this._dataFolder=m.resolve(this.baseFolder,`${g}`))}get BDFile(){return this._BDFile||(this._BDFile=m.resolve(i.dataPath,"data",`${g}.json`))}getPluginFile(e){return m.resolve(i.dataPath,"plugins",e+".config.json")}_getFile(e){return"settings"==e||"plugins"==e||"themes"==e?m.resolve(this.dataFolder,`${e}.json`):m.resolve(this.dataFolder,"misc.json")}getBDData(e){return this.data.misc[e]||""}setBDData(e,t){this.data.misc[e]=t,p.writeFileSync(m.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,p.writeFileSync(m.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:p.existsSync(this.getPluginFile(e))?(this.pluginData[e]=JSON.parse(p.readFileSync(this.getPluginFile(e))),this.pluginData[e][t]||void 0):void 0}setPluginData(e,t,s){void 0!==s&&(void 0===this.pluginData[e]&&(this.pluginData[e]={}),this.pluginData[e][t]=s,p.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],p.writeFileSync(this.getPluginFile(e),JSON.stringify(this.pluginData[e],null,4))}};const b=s(4);var y=new class extends b{constructor(){super(),this.setMaxListeners(20)}dispatch(e,...t){this.emit(e,...t)}},v=new class{constructor(){this.state={},this.collections=[],this.panels=[],this.registerCollection("settings","Settings",l)}initialize(){f.initialize(),this.loadSettings(),this.patchSections()}registerCollection(e,t,s,n=null){this.collections.find(t=>t.id==e)&&c.err("Settings","Already have a collection with id "+e),this.collections.push({type:"collection",id:e,name:t,settings:s,button:n}),this.setup()}removeCollection(e){const t=this.collections.findIndex(t=>t.id==e);!t<0&&c.err("Settings","No collection with id "+e),this.collections.splice(t,1)}registerPanel(e,t){const{element:s,onClick:n}=t,r={label:e,section:e};n?r.onClick=n:r.element=s instanceof d.React.Component?()=>d.React.createElement(s,{}):"function"==typeof s?s:()=>s,this.panels.push(r)}getPath(e,t="",s=""){return{collection:3==e.length?e[0]:t,category:3==e.length?e[1]:2==e.length?e[0]:s,setting:e[e.length-1]}}setup(){for(let e=0;e<this.collections.length;e++){const t=this.collections[e],s=this.collections[e].settings;this.state[t.id]||(this.state[t.id]={});for(let e=0;e<s.length;e++){const n=s[e];if("category"!=n.type)this.state[t.id].hasOwnProperty(n.id)||(this.state[t.id][n.id]=n.value);else{this.state[t.id].hasOwnProperty(n.id)||(this.state[t.id][n.id]={});for(let e=0;e<n.settings.length;e++){const s=n.settings[e];if(this.state[t.id][n.id].hasOwnProperty(s.id)||(this.state[t.id][n.id][s.id]=s.value),s.enableWith){const e=this.getPath(s.enableWith.split("."),t.id,n.id);if(s.hasOwnProperty("disabled"))continue;Object.defineProperty(s,"disabled",{get:()=>!this.state[e.collection][e.category][e.setting]})}}}}if(t.enableWith){const e=this.getPath(t.enableWith.split("."));Object.defineProperty(t,"disabled",{get:()=>!this.state[e.collection][e.category][e.setting]})}}}async patchSections(){const e=await this.getUserSettings();c.monkeyPatch(e.prototype,"generateSections",{after:e=>{let t=e.returnValue.findIndex(e=>"linux"==e.section.toLowerCase())+1;const s=s=>{e.returnValue.splice(t,0,s),t++};s({section:"DIVIDER"}),s({section:"HEADER",label:"BandagedBD"});for(const e of this.collections)e.disabled||s({section:e.name,label:e.name,element:()=>oe.buildSettingsPanel(e.name,e.settings,this.state[e.id],this.onSettingChange.bind(this,e.id),e.button?e.button:null)});for(const e of this.panels)s(e);s({section:"BBD Test",label:"Test Tab",onClick:function(){ve.success("This can just be a click listener!",{forceShow:!0})}}),s({section:"CUSTOM",element:()=>oe.attribution})}}),this.forceUpdate()}forceUpdate(){const e=u.getByProps("standardSidebarView").standardSidebarView.split(" ")[0],t=document.querySelector(`.${e}`);c.getInternalInstance(t).return.return.return.return.return.return.stateNode.forceUpdate()}getUserSettings(){return new Promise(e=>{const t=c.monkeyPatch(u.getByProps("getUserSettingsSections").default.prototype,"render",{after:s=>{e(s.returnValue.type),s.thisObject.forceUpdate(),t()}})})}saveSettings(){f.setData("settings",this.state)}loadSettings(){const e=f.getData("settings");if(!e)return this.saveSettings();for(const t in this.state){e[t]||Object.assign(e,{[t]:this.state[t]});for(const s in this.state[t]){e[t][s]||Object.assign(e[t][s],{[s]:this.state[t][s]});for(const n in this.state[t][s])null!=e[t][s][n]&&(this.state[t][s][n]=e[t][s][n])}}this.saveSettings()}onSettingChange(e,t,s,n){const r=this.collections.length;this.state[e][t][s]=n,y.dispatch("setting-updated",e,t,s,n);const i=this.collections.length;this.saveSettings(),r!=i&&this.forceUpdate()}getSetting(e,t,s){return 2==arguments.length?this.collections[0].find(e=>e.id==arguments[0]).settings.find(e=>e.id==arguments[1]):this.collections.find(t=>t.id==e).find(e=>e.id==t).settings.find(e=>e.id==s)}get(e,t,s){return 2==arguments.length&&(s=t,t=e,e="settings"),!(!this.state[e]||!this.state[e][t])&&this.state[e][t][s]}on(e,t,s,n){const r=(r,i,o,a)=>{r===e&&i===t&&o===s&&n(a)};return y.on("setting-updated",r),()=>{y.off("setting-updated",r)}}};class w extends Error{constructor(e,t,s,n){super(s),this.name=e,this.file=t,this.error=n}}class C extends Error{constructor(e){super(e),this.name="MetaError"}}const E=s(1),S=s(0),P=s(3).Module;P.globalPaths.push(E.resolve(s(2).remote.app.getAppPath(),"node_modules"));const x=/[^\S\r\n]*?\n[^\S\r\n]*?\*[^\S\r\n]?/,k=/^\\@/;class D{get name(){return""}get moduleExtension(){return""}get extension(){return""}get contentFolder(){return""}get prefix(){return"content"}get collection(){return"settings"}get category(){return"content"}get id(){return"autoReload"}emit(e,...t){return y.emit(`${this.prefix}-${e}`,...t)}constructor(){this.timeCache={},this.contentList=[],this.state={},this.originalRequire=P._extensions[this.moduleExtension],P._extensions[this.moduleExtension]=this.getContentRequire(),v.on(this.collection,this.category,this.id,e=>{e?this.watchContent():this.unwatchContent()})}initializeContent(){}getContentModification(e,t){return t}startContent(){}stopContent(){}loadState(){const e=f.getData(`${this.prefix}s`);e&&Object.assign(this.state,e)}saveState(){f.setData(`${this.prefix}s`,this.state)}watchContent(){if(this.watcher)return c.err(this.name,"Already watching content.");c.log(this.name,"Starting to watch content."),this.watcher=S.watch(this.contentFolder,{persistent:!1},async(e,t)=>{if(!e||!t||!t.endsWith(this.extension))return;await new Promise(e=>setTimeout(e,50));try{S.statSync(E.resolve(this.contentFolder,t))}catch(e){if("ENOENT"!==e.code)return;delete this.timeCache[t],this.unloadContent(t,!0)}if(!S.statSync(E.resolve(this.contentFolder,t)).isFile())return;const s=S.statSync(E.resolve(this.contentFolder,t));s&&s.mtime&&s.mtime.getTime()&&"number"==typeof s.mtime.getTime()&&this.timeCache[t]!=s.mtime.getTime()&&(this.timeCache[t]=s.mtime.getTime(),"rename"==e&&this.loadContent(t,!0),"change"==e&&this.reloadContent(t,!0))})}unwatchContent(){if(!this.watcher)return c.err(this.name,"Was not watching content.");this.watcher.close(),delete this.watcher,c.log(this.name,"No longer watching content.")}extractMeta(e){const t=e.split("\n")[0];if(t.includes("//META"))return this.parseOldMeta(e);if(t.includes("/**"))return this.parseNewMeta(e);throw new C("META was not found.")}parseOldMeta(e){const t=e.split("\n")[0],s=t.substring(t.lastIndexOf("//META")+6,t.lastIndexOf("*//"));if(!c.testJSON(s))throw new C("META could not be parsed.");const n=JSON.parse(s);if(!n.name)throw new C("META missing name data.");return n}parseNewMeta(e){const t=e.split("/**",2)[1].split("*/",1)[0],s={};let n="",r="";for(const e of t.split(x))if(0!==e.length)if("@"===e.charAt(0)&&" "!==e.charAt(1)){s[n]=r;const t=e.indexOf(" ");n=e.substr(1,t-1),r=e.substr(t+1)}else r+=" "+e.replace("\\n","\n").replace(k,"@");return s[n]=r.trim(),delete s[""],s}getContentRequire(){const e=this,t=this.originalRequire;return function(s,n){const r=E.resolve(e.contentFolder,E.basename(n));if(!S.existsSync(r)||n!==S.realpathSync(r))return Reflect.apply(t,this,arguments);let i=S.readFileSync(n,"utf8");i=c.stripBOM(i);const o=e.extractMeta(i);o.id=o.name,o.filename=E.basename(n),i=e.getContentModification(s,i,o),s._compile(i,n)}}loadContent(e,t=!1){if(void 0===e)return;try{require(E.resolve(this.contentFolder,e))}catch(n){return new w(e,e,"Could not be compiled.",{message:n.message,stack:n.stack})}const s=require(E.resolve(this.contentFolder,e));if(this.contentList.find(e=>e.id==s.id))return new w(s.name,e,`There is already a plugin with name ${s.name}`);const n=this.initializeContent(s);return n||(this.contentList.push(s),t&&ve.success(`${s.name} v${s.version} was loaded.`),this.emit("loaded",s.id),this.state[s.id]?this.startContent(s):this.state[s.id]=!1)}unloadContent(e,t=!0,s=!1){const n="string"==typeof e?this.contentList.find(t=>t.id==e||t.filename==e):e;return!!n&&(this.state[n.id]&&(s?this.stopContent(n):this.disableContent(n)),delete require.cache[require.resolve(E.resolve(this.contentFolder,n.filename))],this.contentList.splice(this.contentList.indexOf(n),1),this.emit("unloaded",n.id),t&&ve.success(`${n.name} was unloaded.`),!0)}reloadContent(e,t=!0){const s="string"==typeof e?this.contentList.find(t=>t.id==e||t.filename==e):e,n=this.unloadContent(s,t,!0);return n?this.loadContent(s.filename,t):n}isLoaded(e){return!!this.contentList.find(t=>t.id==e||t.filename==e)}isEnabled(e){const t=this.contentList.find(t=>t.id==e||t.filename==e);return!!t&&this.state[t.id]}enableContent(e){const t="string"==typeof e?this.contentList.find(t=>t.id==e):e;t&&(this.state[t.id]||(this.state[t.id]=!0,this.startContent(t),this.saveState()))}disableContent(e){const t="string"==typeof e?this.contentList.find(t=>t.id==e):e;t&&this.state[t.id]&&(this.state[t.id]=!1,this.stopContent(t),this.saveState())}toggleContent(e){this.state[e]?this.disableContent(e):this.enableContent(e)}loadNewContent(){const e=S.readdirSync(this.contentFolder),t=this.contentList.filter(t=>!e.includes(t.filename)).map(e=>e.id);return{added:e.filter(e=>!this.contentList.find(t=>t.filename==e)&&e.endsWith(this.extension)&&S.statSync(E.resolve(this.contentFolder,e)).isFile()),removed:t}}updateList(){const e=this.loadNewContent();for(const t of e.added)this.loadContent(t);for(const t of e.removed)this.unloadContent(t)}loadAllContent(){this.loadState();const e=[],t=S.readdirSync(this.contentFolder);for(const s of t){if(!S.statSync(E.resolve(this.contentFolder,s)).isFile()||!s.endsWith(this.extension))continue;const t=this.loadContent(s,!1);t instanceof w&&e.push(t)}return this.saveState(),v.get(this.collection,this.category,this.id)&&this.watchContent(),e}}const M=s(1),B=s(2).remote;var N=new class extends D{get name(){return"PluginManager"}get moduleExtension(){return".js"}get extension(){return".plugin.js"}get contentFolder(){return M.resolve(i.dataPath,"plugins")}get prefix(){return"plugin"}constructor(){super(),this.onSwitch=this.onSwitch.bind(this),this.observer=new MutationObserver(e=>{for(let t=0,s=e.length;t<s;t++)this.onMutation(e[t])})}updatePluginList(){return this.updateList()}enablePlugin(e){return this.enableContent(e)}disablePlugin(e){return this.disableContent(e)}togglePlugin(e){return this.toggleContent(e)}unloadPlugin(e){return this.unloadContent(e)}loadPlugin(e){const t=this.loadContent(e);t&&we.showContentErrors({themes:[t]})}reloadPlugin(e){const t=this.reloadContent(e);return t&&we.showContentErrors({plugins:[t]}),"string"==typeof e?this.contentList.find(t=>t.id==e||t.filename==e):e}loadAllPlugins(){const e=this.loadAllContent();return this.setupFunctions(),v.registerPanel("Plugins",{element:()=>oe.getContentPanel("Plugins",this.contentList,this.state,{folder:this.contentFolder,onChange:this.togglePlugin.bind(this),reload:this.reloadPlugin.bind(this),refreshList:this.updatePluginList.bind(this)})}),e}initializeContent(e){if(!e.type)return new w(e.name,e.filename,"Plugin had no exports",{message:"Plugin had no exports or no name property.",stack:""});try{const t=new e.type;e.plugin=t,e.name=t.getName()||e.name,e.author=t.getAuthor()||e.author||"No author",e.description=t.getDescription()||e.description||"No description",e.version=t.getVersion()||e.version||"No version";try{"function"==typeof e.plugin.load&&e.plugin.load()}catch(t){return this.state[e.id]=!1,new w(e.name,e.filename,"load() could not be fired.",{message:t.message,stack:t.stack})}}catch(t){return new w(e.name,e.filename,"Could not be constructed.",{message:t.message,stack:t.stack})}}getContentModification(e,t,s){return e._compile(t,e.filename),c.isEmpty(e.exports)?t+=`\nmodule.exports = ${JSON.stringify(s)};\nmodule.exports.type = ${s.exports||s.name};`:(s.type=e.exports,e.exports=s,"")}startContent(e){return this.startPlugin(e)}stopContent(e){return this.stopPlugin(e)}startPlugin(e){const t="string"==typeof e?this.contentList.find(t=>t.id==e):e;if(!t)return;const s=t.plugin;try{s.start(),this.emit("started",t.id),ve.show(`${t.name} v${t.version} has started.`)}catch(e){return this.state[t.id]=!1,ve.error(`${t.name} v${t.version} could not be started.`),c.err("Plugins",t.name+" could not be started.",e),new w(t.name,t.filename,"start() could not be fired.",{message:e.message,stack:e.stack})}}stopPlugin(e){const t="string"==typeof e?this.contentList.find(t=>t.id==e):e;if(!t)return;const s=t.plugin;try{s.stop(),this.emit("stopped",t.id),ve.show(`${t.name} v${t.version} has stopped.`)}catch(e){return this.state[t.id]=!1,ve.error(`${t.name} v${t.version} could not be stopped.`),c.err("Plugins",t.name+" could not be stopped.",e),new w(t.name,t.filename,"stop() could not be fired.",{message:e.message,stack:e.stack})}}setupFunctions(){B.getCurrentWebContents().on("did-navigate-in-page",this.onSwitch.bind(this)),this.observer.observe(document,{childList:!0,subtree:!0})}onSwitch(){this.emit("page-switch");for(let e=0;e<this.contentList.length;e++){const t=this.contentList[e].plugin;if(this.state[this.contentList[e].id]&&"function"==typeof t.onSwitch)try{t.onSwitch()}catch(t){c.err("Plugins","Unable to fire onSwitch for "+this.contentList[e].name+".",t)}}}onMutation(e){for(let t=0;t<this.contentList.length;t++){const s=this.contentList[t].plugin;if(this.state[this.contentList[t].id]&&"function"==typeof s.observer)try{s.observer(e)}catch(e){c.err("Plugins","Unable to fire observer for "+this.contentList[t].name+".",e)}}}};const T=s(1);var j=new class extends D{get name(){return"ThemeManager"}get moduleExtension(){return".css"}get extension(){return".theme.css"}get contentFolder(){return T.resolve(i.dataPath,"themes")}get prefix(){return"theme"}updateThemeList(){return this.updateList()}loadAllThemes(){return v.registerPanel("Themes",{element:()=>oe.getContentPanel("Themes",this.contentList,this.state,{folder:this.contentFolder,onChange:this.toggleTheme.bind(this),reload:this.reloadTheme.bind(this),refreshList:this.updateThemeList.bind(this)})}),this.loadAllContent()}enableTheme(e){return this.enableContent(e)}disableTheme(e){return this.disableContent(e)}toggleTheme(e){return this.toggleContent(e)}unloadTheme(e){return this.unloadContent(e)}loadTheme(e){const t=this.loadContent(e);t&&we.showContentErrors({themes:[t]})}reloadTheme(e){const t=this.reloadContent(e);t&&we.showContentErrors({themes:[t]})}getContentModification(e,t,s){return s.css=t.split("\n").slice(1).join("\n"),`module.exports = ${JSON.stringify(s)};`}startContent(e){return this.addTheme(e)}stopContent(e){return this.removeTheme(e)}addTheme(e){const t="string"==typeof e?this.contentList.find(t=>t.id==e):e;if(!t)return;const s=document.createElement("style");s.id=c.escapeID(t.id),s.textContent=unescape(t.css),document.head.append(s),t.element=s}removeTheme(e){const t="string"==typeof e?this.contentList.find(t=>t.id==e):e;if(!t)return;const s=t.element||document.getElementById(c.escapeID(t.id));s&&s.remove()}};const F=d.React,L=d.ReactDOM,O="bd-settings-title h2-2gWE-o title-3sZWYQ size16-14cGz5 height20-mO2eIN weightSemiBold-NJexzi defaultColor-1_ajX0 defaultMarginh2-2LTaUL marginBottom20-32qID7",A="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 I extends F.Component{constructor(e){super(e)}render(){const e=this.props.isGroup?A:O,t=this.props.className?`${e} ${this.props.className}`:e;return F.createElement("h2",{className:t,onClick:()=>{this.props.onClick&&this.props.onClick()}},this.props.text,this.props.button&&F.createElement("button",{className:"bd-title-button",onClick:this.props.button.onClick},this.props.button.title),this.props.otherChildren)}}class R extends F.Component{constructor(e){super(e)}render(){return F.createElement("svg",{xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 12 12",style:{width:"18px",height:"18px"}},F.createElement("g",{className:"background",fill:"none",fillRule:"evenodd"},F.createElement("path",{d:"M0 0h12v12H0"}),F.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 G extends F.Component{constructor(e){super(e)}render(){return F.createElement("svg",{xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 24 24",fill:"#dcddde",className:"bd-reload "+this.props.className,onClick:this.props.onClick,style:{width:this.props.size||"24px",height:this.props.size||"24px"}},F.createElement("path",{d:"M17.65 6.35C16.2 4.9 14.21 4 12 4c-4.42 0-7.99 3.58-7.99 8s3.57 8 7.99 8c3.73 0 6.84-2.55 7.73-6h-2.08c-.82 2.33-3.04 4-5.65 4-3.31 0-6-2.69-6-6s2.69-6 6-6c1.66 0 3.14.69 4.22 1.78L13 11h7V4l-2.35 2.35z"}),F.createElement("path",{fill:"none",d:"M0 0h24v24H0z"}))}}class z extends F.Component{constructor(e){super(e),this.onChange=this.onChange.bind(this),this.showSettings=this.showSettings.bind(this),this.state={checked:this.props.enabled,settingsOpen:!1},this.hasSettings="function"==typeof this.props.content.plugin.getSettingsPanel,this.settingsPanel="",this.panelRef=F.createRef(),this.reload=this.reload.bind(this)}reload(){this.props.reload&&(this.props.content=this.props.reload(this.props.content.id),this.forceUpdate())}componentDidUpdate(){if(this.state.settingsOpen){this.settingsPanel instanceof Node&&this.panelRef.current.appendChild(this.settingsPanel);const e=(e,t)=>{const s=e.scrollTop,n=s+e.clientHeight,r=t.offsetTop,i=r+t.clientHeight;return r<s||i>n},t=$(this.panelRef.current),s=t.parents(".scroller-2FKFPG");if(!e(s[0],t[0]))return;s.animate({scrollTop:t.offset().top-s.offset().top+s.scrollTop()-30},300)}}getString(e){return"string"==typeof e?e:e.toString()}render(){const e=this,{content:t}=this.props,s=this.getString(t.name),n=this.getString(t.author),r=this.getString(t.description),i=this.getString(t.version),o=t.website,a=t.source;if(this.state.settingsOpen){try{e.settingsPanel=t.plugin.getSettingsPanel()}catch(e){c.err("Plugins","Unable to get settings panel for "+t.name+".",e)}const n={id:`plugin-settings-${s}`,className:"plugin-settings",ref:this.panelRef};return"string"==typeof this.settingsPanel&&(n.dangerouslySetInnerHTML=this.settingsPanel),F.createElement("li",{className:"settings-open ui-switch-item"},F.createElement("div",{style:{float:"right",cursor:"pointer"},onClick:()=>{this.panelRef.current.innerHTML="",e.setState({settingsOpen:!1})}},F.createElement(R,null)),F.createElement("div",n,this.settingsPanel instanceof F.Component?this.settingsPanel:null))}return F.createElement("li",{"data-name":s,"data-version":i,className:"settings-closed ui-switch-item"},F.createElement("div",{className:"bda-header"},F.createElement("span",{className:"bda-header-title"},F.createElement("span",{className:"bda-name"},s)," v",F.createElement("span",{className:"bda-version"},i)," by ",F.createElement("span",{className:"bda-author"},n)),F.createElement("div",{className:"bda-controls"},!v.get("settings","content","autoReload")&&F.createElement(G,{className:"bd-reload-card",onClick:this.reload}),F.createElement("label",{className:"ui-switch-wrapper ui-flex-child",style:{flex:"0 0 auto"}},F.createElement("input",{checked:this.state.checked,onChange:this.onChange,className:"ui-switch-checkbox",type:"checkbox"}),F.createElement("div",{className:this.state.checked?"ui-switch checked":"ui-switch"})))),F.createElement("div",{className:"bda-description-wrap scroller-wrap fade"},F.createElement("div",{className:"bda-description scroller"},r)),(o||a||this.hasSettings)&&F.createElement("div",{className:"bda-footer"},F.createElement("span",{className:"bda-links"},o&&F.createElement("a",{className:"bda-link bda-link-website",href:o,target:"_blank"},"Website"),o&&a&&" | ",a&&F.createElement("a",{className:"bda-link bda-link-source",href:a,target:"_blank"},"Source")),this.hasSettings&&F.createElement("button",{onClick:this.showSettings,className:"bda-settings-button",disabled:!this.state.checked},"Settings")))}onChange(){this.setState({checked:!this.state.checked}),this.props.onChange&&this.props.onChange(this.props.content.id)}showSettings(){this.hasSettings&&this.setState({settingsOpen:!0})}}class V extends F.Component{constructor(e){super(e),this.state={checked:this.props.enabled,reloads:0},this.onChange=this.onChange.bind(this),this.reload=this.reload.bind(this)}reload(){this.props.reload&&(this.props.content=this.props.reload(this.props.content.id),this.forceUpdate())}render(){const{content:e}=this.props,t=e.name,s=e.description,n=e.version,r=e.author,i=e.website,o=e.source;return F.createElement("li",{"data-name":t,"data-version":n,className:"settings-closed ui-switch-item"},F.createElement("div",{className:"bda-header"},F.createElement("span",{className:"bda-header-title"},F.createElement("span",{className:"bda-name"},t)," v",F.createElement("span",{className:"bda-version"},n)," by ",F.createElement("span",{className:"bda-author"},r)),F.createElement("div",{className:"bda-controls"},!v.get("settings","content","autoReload")&&F.createElement(G,{className:"bd-reload-card",onClick:this.reload}),F.createElement("label",{className:"ui-switch-wrapper ui-flex-child",style:{flex:"0 0 auto"}},F.createElement("input",{checked:this.state.checked,onChange:this.onChange,className:"ui-switch-checkbox",type:"checkbox"}),F.createElement("div",{className:this.state.checked?"ui-switch checked":"ui-switch"})))),F.createElement("div",{className:"bda-description-wrap scroller-wrap fade"},F.createElement("div",{className:"bda-description scroller"},s)),(i||o)&&F.createElement("div",{className:"bda-footer"},F.createElement("span",{className:"bda-links"},i&&F.createElement("a",{className:"bda-link",href:i,target:"_blank"},"Website"),i&&o&&" | ",o&&F.createElement("a",{className:"bda-link",href:o,target:"_blank"},"Source"))))}onChange(){this.setState({checked:!this.state.checked}),this.props.onChange&&this.props.onChange(this.props.content.id)}}class H extends F.Component{reload(){this.props.refreshList&&this.props.refreshList(),this.forceUpdate()}render(){const{title:e,folder:t,contentList:n,contentState:r,onChange:i,reload:o}=this.props,a=!v.get("settings","content","autoReload"),l=t?{title:`Open ${e} Folder`,onClick:()=>{s(2).shell.openItem(t)}}:null;return[F.createElement(I,{key:"title",text:e,button:l,otherChildren:a&&F.createElement(G,{onClick:this.reload.bind(this)})}),F.createElement("ul",{key:"ContentList",className:"bda-slist"},n.sort((e,t)=>e.name.toLowerCase().localeCompare(t.name.toLowerCase())).map(e=>{const t=e.type?z:V;return F.createElement(t,{showReloadIcon:a,key:e.id,enabled:r[e.id],content:e,onChange:i,reload:o})}))]}}class W extends F.Component{render(){return F.createElement("div",{className:"bd-divider divider-3573oO marginTop8-1DLZ1n marginBottom40-2vIwTv"})}}const U="flex-1xMQg5 flex-1O1GKY vertical-V37hAW flex-1O1GKY directionColumn-35P_nr justifyStart-2NDFzi alignStretch-DpGPf3 noWrap-3jynv6 switchItem-2hKKKK",_="flex-1xMQg5 flex-1O1GKY horizontal-1ae9ci horizontal-2EEEnY flex-1O1GKY directionRow-3v3tfG justifyStart-2NDFzi alignStart-H-X2h- noWrap-3jynv6",q="flexChild-faoVW3",J="titleDefault-a8-ZSr title-31JmR4 da-titleDefault da-title",Z="flexChild-faoVW3 da-flexChild switchDisabled-3HsXAJ switch-3wwwcV da-switchDisabled da-switch valueUnchecked-2lU_20 value-2hFrkk sizeDefault-2YlOZr size-3rFEHg themeDefault-24hCdX",Y="flexChild-faoVW3 da-flexChild switchDisabled-3HsXAJ switch-3wwwcV da-switchDisabled da-switch valueChecked-m-4IJZ value-2hFrkk sizeDefault-2YlOZr size-3rFEHg themeDefault-24hCdX",K="flexChild-faoVW3 da-flexChild switchEnabled-V2WDBB switch-3wwwcV da-switchEnabled da-switch valueUnchecked-2lU_20 value-2hFrkk sizeDefault-2YlOZr size-3rFEHg themeDefault-24hCdX",X="flexChild-faoVW3 da-flexChild switchEnabled-V2WDBB switch-3wwwcV da-switchEnabled da-switch valueChecked-m-4IJZ value-2hFrkk sizeDefault-2YlOZr size-3rFEHg themeDefault-24hCdX",Q="checkboxEnabled-CtinEn checkbox-2tyjJg",ee="checkboxDisabled-1MA81A checkbox-2tyjJg",te="description-3_Ncsb formText-3fs7AJ note-1V3kyJ modeDefault-3a2Ph1 primary-jw0I4K",se="divider-3573oO dividerDefault-3rvLe-";class ne extends F.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?Y:Z:this.state.checked?X:K;return F.createElement("div",{className:U,style:{flex:"1 1 auto"}},F.createElement("div",{className:_,style:{flex:"1 1 auto"}},F.createElement("div",{className:q,style:{flex:"1 1 auto"}},F.createElement("label",{htmlFor:this.props.id,className:J},this.props.name||this.props.data.text)),F.createElement("div",{className:e,tabIndex:"0",style:{flex:"0 0 auto"}},F.createElement("input",{id:this.props.id,className:this.props.disabled?ee:Q,type:"checkbox",tabIndex:"-1",checked:this.state.checked,onChange:e=>this.onChange(e)}))),F.createElement("div",{className:te,style:{flex:"1 1 auto"}},this.props.note||this.props.data.info),F.createElement("div",{className:se}))}}const re="bd-settings-group";class ie extends F.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=F.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"}`:"",s=`${re} ${t}`;return F.createElement("div",{className:s},F.createElement(I,{text:this.props.name,collapsible:this.props.collapsible,onClick:()=>this.toggleCollapse(),button:this.props.button,isGroup:!0}),F.createElement("div",{className:"bd-settings-container",ref:this.container},e.filter(e=>!e.hidden).map(e=>F.createElement(ne,{disabled:e.disabled,id:e.id,key:e.id,name:e.name,note:e.note,checked:e.value,onChange:this.onChange}))),this.props.showDivider&&F.createElement(W,null))}}class oe{static buildSettingsPanel(e,t,s,n,r=null){return t.forEach(e=>{e.settings.forEach(t=>t.value=s[e.id][t.id])}),this.getSettingsPanel(e,t,n,r)}static getSettingsPanel(e,t,s,n=null){return[F.createElement(I,{text:e,button:n}),t.map(e=>F.createElement(ie,Object.assign({},e,{onChange:s})))]}static getContentPanel(e,t,s,n={}){return F.createElement(H,Object.assign({},{title:e,contentList:t,contentState:s},n))}static get attribution(){return F.createElement("div",{style:{fontSize:"12px",fontWeight:"600",color:"#72767d",padding:"2px 10px"}},`BBD v${i.bbdVersion} by `,F.createElement("a",{href:"https://github.com/rauenzi/",target:"_blank"},"Zerebos"))}}class ae extends F.Component{constructor(e){super(e)}render(){let e=`scrollerWrap-2lJEkd scrollerThemed-2oenus themeGhostHairline-DBD-2d${this.props.fade?" scrollerFade-1Ijw5y":""}`,t="scroller-2FKFPG scroller";this.props.sidebar&&(t="scroller-2FKFPG firefoxFixScrollFlex-cnI2ix sidebarRegionScroller-3MXcoP sidebar-region-scroller scroller"),this.props.contentColumn&&(t="scroller-2FKFPG firefoxFixScrollFlex-cnI2ix contentRegionScroller-26nc1e content-region-scroller scroller",e="scrollerWrap-2lJEkd firefoxFixScrollFlex-cnI2ix contentRegionScrollerWrap-3YZXdm content-region-scroller-wrap scrollerThemed-2oenus themeGhost-28MSn0 scrollerTrack-1ZIpsv");const{children:s}=this.props;return F.createElement("div",{key:"scrollerwrap",className:e},F.createElement("div",{key:"scroller",ref:"scroller",className:t},s))}}class le extends F.Component{constructor(e){super(e)}render(){const{sidebar:e,content:t,tools:s}=this.props.children;return F.createElement("div",{className:"standardSidebarView-3F1I7i ui-standard-sidebar-view"},F.createElement("div",{className:"sidebarRegion-VFTUkN sidebar-region"},F.createElement(ae,{key:"sidebarScroller",ref:"sidebarScroller",sidebar:!0,fade:e.fade||!0,dark:e.dark||!0,children:e.component})),F.createElement("div",{className:"contentRegion-3nDuYy content-region"},F.createElement("div",{className:"contentTransitionWrap-3hqOEW content-transition-wrap"},F.createElement("div",{className:"scrollerWrap-2lJEkd firefoxFixScrollFlex-cnI2ix contentRegionScrollerWrap-3YZXdm content-region-scroller-wrap scrollerThemed-2oenus themeGhost-28MSn0 scrollerTrack-1ZIpsv"},F.createElement("div",{className:"scroller-2FKFPG firefoxFixScrollFlex-cnI2ix contentRegionScroller-26nc1e content-region-scroller scroller",ref:"contentScroller"},F.createElement("div",{className:"contentColumn-2hrIYH contentColumnDefault-1VQkGM content-column default"},t.component),s.component)))))}}class ce extends F.Component{constructor(e){super(e),this.onClick=this.onClick.bind(this)}render(){return F.createElement("div",{className:"tools-container toolsContainer-1edPuj"},F.createElement("div",{className:"tools tools-3-3s-N"},F.createElement("div",{className:"container-1sFeqf"},F.createElement("div",{className:"btn-close closeButton-1tv5uR",onClick:this.onClick},F.createElement(R,null)),F.createElement("div",{className:"esc-text keybind-KpFkfr"},"ESC"))))}onClick(){this.props.onClick&&this.props.onClick(),$(".closeButton-1tv5uR").first().click()}}class de extends F.Component{constructor(e){super(e),this.setInitialState(),this.onClick=this.onClick.bind(this)}setInitialState(){this.state={selected:this.props.selected||!1}}render(){return F.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 he extends F.Component{constructor(e){super(e)}render(){return F.createElement("div",{className:"ui-tab-bar-separator margin-top-8 margin-bottom-8"})}}class ue extends F.Component{constructor(e){super(e)}render(){return F.createElement("div",{className:"ui-tab-bar-header"},this.props.text)}}class pe{static get Item(){return de}static get Header(){return ue}static get Separator(){return he}}class me extends F.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 F.createElement("div",{className:`card-3Qj_Yx cardPrimary-1Hv-to marginBottom8-AtZOdT bd-server-card${e.pinned?" bd-server-card-pinned":""}`},F.createElement("img",{ref:"img",className:"bd-server-image",src:e.iconUrl,onError:this.handleError.bind(this)}),F.createElement("div",{className:"flexChild-faoVW3 bd-server-content"},F.createElement("div",{className:"flex-1xMQg5 flex-1O1GKY horizontal-1ae9ci horizontal-2EEEnY directionRow-3v3tfG noWrap-3jynv6 bd-server-header"},F.createElement("h5",{className:"h5-18_1nd defaultColor-1_ajX0 margin-reset bd-server-name"},e.name),F.createElement("h5",{className:"h5-18_1nd defaultColor-1_ajX0 margin-reset bd-server-member-count"},e.members," Members")),F.createElement("div",{className:"flex-1xMQg5 flex-1O1GKY horizontal-1ae9ci horizontal-2EEEnY directionRow-3v3tfG noWrap-3jynv6"},F.createElement("div",{className:"scrollerWrap-2lJEkd scrollerThemed-2oenus themeGhostHairline-DBD-2d scrollerFade-1Ijw5y bd-server-description-container"},F.createElement("div",{className:"scroller-2FKFPG scroller bd-server-description"},e.description))),F.createElement("div",{className:"flex-1xMQg5 flex-1O1GKY horizontal-1ae9ci horizontal-2EEEnY directionRow-3v3tfG noWrap-3jynv6 bd-server-footer"},F.createElement("div",{className:"flexChild-faoVW3 bd-server-tags",style:{flex:"1 1 auto"}},e.categories.join(", ")),this.state.joined&&F.createElement("button",{type:"button",className:"button-38aScr lookFilled-1Gx00P colorBrand-3pXr91 sizeMin-1mJd1x grow-q77ONN colorGreen-29iAKY",style:{minHeight:"12px",marginTop:"4px",backgroundColor:"#3ac15c"}},F.createElement("div",{className:"ui-button-contents"},"Joined")),e.error&&F.createElement("button",{type:"button",className:"button-38aScr lookFilled-1Gx00P colorBrand-3pXr91 sizeMin-1mJd1x grow-q77ONN disabled-9aF2ug",style:{minHeight:"12px",marginTop:"4px",backgroundColor:"#c13a3a"}},F.createElement("div",{className:"ui-button-contents"},"Error")),!e.error&&!this.state.joined&&F.createElement("button",{type:"button",className:"button-38aScr lookFilled-1Gx00P colorBrand-3pXr91 sizeMin-1mJd1x grow-q77ONN",style:{minHeight:"12px",marginTop:"4px"},onClick:()=>{this.join()}},F.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 ge extends F.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=u.getByProps("getGuilds"),this.AvatarDefaults=u.getByProps("getUserAvatarURL","DEFAULT_AVATARS"),this.InviteActions=u.getByProps("acceptInvite"),this.SortedGuildStore=u.getByProps("getSortedGuilds")}componentDidMount(){this.checkConnection()}setInitialState(){this.state={selectedCategory:-1,title:"Loading...",loading:!0,servers:[],next:null,connection:{state:0,user:null}}}close(){L.unmountComponentAtNode(document.getElementById(this.props.rootId))}search(e,t){const s=this;$.ajax({method:"GET",url:`${s.endPoint}${e}${e?"&schema=new":"?schema=new"}`,success:e=>{let n=e.results.reduce((e,t)=>(t.joined=!1,e.push(t),e),[]);t||(n=s.state.servers.concat(n));let r=e.size+e.from;e.next=`?from=${r}`,s.state.term&&(e.next+=`&term=${s.state.term}`),s.state.selectedCategory&&(e.next+=`&category=${s.categoryButtons[s.state.selectedCategory]}`),r>=e.total&&(r=e.total,e.next=null);let i=`Showing 1-${r} of ${e.total} results in ${s.categoryButtons[s.state.selectedCategory]}`;s.state.term&&(i+=` for ${s.state.term}`),s.setState({loading:!1,title:i,servers:n,next:e.next}),t&&(s.refs.sbv.refs.contentScroller.scrollTop=0)},error:()=>{s.setState({loading:!1,title:"Failed to load servers. Check console for details"})}})}join(e){if(e.props.pinned)return this.InviteActions.acceptInvite(e.props.invite_code);$.ajax({method:"GET",url:`${this.joinEndPoint}/${e.props.server.identifier}`,headers:{Accept:"application/json;","Content-Type":"application/json;","x-discord-token":this.state.connection.user.accessToken},crossDomain:!0,xhrFields:{withCredentials:!0},success:()=>{e.setState({joined:!0})}})}connect(){const e=this.windowOptions;e.x=Math.round(window.screenX+window.innerWidth/2-e.width/2),e.y=Math.round(window.screenY+window.innerHeight/2-e.height/2),this.joinWindow=new(window.require("electron").remote.BrowserWindow)(e);this.joinWindow.webContents.on("did-navigate",(e,t)=>{"https://auth.discordservers.com/info"==t&&(this.joinWindow.close(),this.checkConnection())}),this.joinWindow.loadURL("https://auth.discordservers.com/connect?scopes=guilds.join&previousUrl=https://auth.discordservers.com/info")}get windowOptions(){return{width:500,height:550,backgroundColor:"#282b30",show:!0,resizable:!1,maximizable:!1,minimizable:!1,alwaysOnTop:!0,frame:!1,center:!1,webPreferences:{nodeIntegration:!1}}}get bdServer(){const e=this.SortedGuildStore.guildPositions,t=this.AvatarDefaults.DEFAULT_AVATARS;return F.createElement(me,{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 F.createElement(le,{ref:"sbv",children:this.component})}get component(){return{sidebar:{component:this.sidebar},content:{component:this.content},tools:{component:F.createElement(ce,{key:"pt",ref:"tools",onClick:this.close})}}}get sidebar(){return F.createElement("div",{className:"sidebar",key:"ps"},F.createElement("div",{className:"ui-tab-bar SIDE"},F.createElement("div",{className:"ui-tab-bar-header",style:{fontSize:"16px"}},"Public Servers"),F.createElement(pe.Separator,null),this.searchInput,F.createElement(pe.Separator,null),F.createElement(pe.Header,{text:"Categories"}),this.categoryButtons.map((e,t)=>F.createElement(pe.Item,{id:t,onClick:this.changeCategory,key:t,text:e,selected:this.state.selectedCategory===t})),F.createElement(pe.Separator,null),this.footer,this.connection))}get searchInput(){return F.createElement("div",{className:"ui-form-item"},F.createElement("div",{className:"ui-text-input flex-vertical",style:{width:"172px",marginLeft:"10px"}},F.createElement("input",{ref:"searchinput",onKeyDown:this.searchKeyDown,onChange:()=>{},type:"text",className:"input default",placeholder:"Search...",maxLength:"50"})))}searchKeyDown(e){const t=this;if(t.state.loading||13!==e.which)return;t.setState({loading:!0,title:"Loading...",term:e.target.value});let s=`?term=${e.target.value}`;0!==t.state.selectedCategory&&(s+=`&category=${t.categoryButtons[t.state.selectedCategory]}`),t.search(s,!0)}get categoryButtons(){return["All","FPS Games","MMO Games","Strategy Games","MOBA Games","RPG Games","Tabletop Games","Sandbox Games","Simulation Games","Music","Community","Language","Programming","Other"]}changeCategory(e){const t=this;t.state.loading||(t.refs.searchinput.value="",t.setState({loading:!0,selectedCategory:e,title:"Loading...",term:null}),0!==e?t.search(`?category=${t.categoryButtons[e]}`,!0):t.search("",!0))}get content(){const e=this,t=this.SortedGuildStore.guildPositions,s=this.AvatarDefaults.DEFAULT_AVATARS;return 1===e.state.connection.state?e.notConnected:[F.createElement("div",{ref:"content",key:"pc",className:"contentColumn-2hrIYH contentColumnDefault-1VQkGM content-column default"},F.createElement(I,{text:e.state.title}),e.bdServer,e.state.servers.map(n=>F.createElement(me,{key:n.identifier,server:n,join:e.join,guildList:t,fallback:s[Math.floor(5*Math.random())]})),e.state.next&&F.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"}},F.createElement("div",{className:"ui-button-contents"},e.state.loading?"Loading":"Load More")),e.state.servers.length>0&&F.createElement(I,{text:e.state.title}))]}get notConnected(){return[F.createElement("div",{key:"ncc",ref:"content",className:"contentColumn-2hrIYH contentColumnDefault-1VQkGM content-column default"},F.createElement("h2",{className:"ui-form-title h2 margin-reset margin-bottom-20"},"Not connected to discordservers.com!",F.createElement("button",{onClick:this.connect,type:"button",className:"ui-button filled brand small grow",style:{display:"inline-block",minHeight:"18px",marginLeft:"10px",lineHeight:"14px"}},F.createElement("div",{className:"ui-button-contents"},"Connect"))),this.bdServer)]}get footer(){return F.createElement("div",{className:"ui-tab-bar-header"},F.createElement("a",{href:"https://discordservers.com",target:"_blank"},"Discordservers.com"))}get connection(){const{connection:e}=this.state;return 2!==e.state?F.createElement("span",null):F.createElement("span",null,F.createElement(pe.Separator,null),F.createElement("span",{style:{color:"#b9bbbe",fontSize:"10px",marginLeft:"10px"}},"Connected as: ",`${e.user.username}#${e.user.discriminator}`),F.createElement("div",{style:{padding:"5px 10px 0 10px"}},F.createElement("button",{style:{width:"100%",minHeight:"20px"},type:"button",className:"ui-button filled brand small grow"},F.createElement("div",{className:"ui-button-contents",onClick:this.connect},"Reconnect"))))}}class fe extends F.Component{constructor(e){super(e)}componentDidMount(){$(window).on(`keyup.${this.props.id}`,e=>{27===e.which&&L.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 F.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 be=u.getByProps("channels").channels.split(" ")[0],ye=u.getByProps("membersWrap").membersWrap.split(" ")[0];class ve{static get shouldShowToasts(){return v.get("settings","general","showToasts")}static async success(e,t={}){return this.show(e,Object.assign(t,{type:"success"}))}static async info(e,t={}){return this.show(e,Object.assign(t,{type:"info"}))}static async warning(e,t={}){return this.show(e,Object.assign(t,{type:"warning"}))}static async error(e,t={}){return this.show(e,Object.assign(t,{type:"error"}))}static async default(e,t={}){return this.show(e,Object.assign(t,{type:""}))}static show(e,t={}){const{type:s="",icon:n=!0,timeout:r=3e3,forceShow:i=!1}=t;if(!this.shouldShowToasts&&!i)return;this.ensureContainer();const o=document.createElement("div");o.classList.add("bd-toast"),s&&o.classList.add("toast-"+s),s&&n&&o.classList.add("icon"),o.innerText=e,document.querySelector(".bd-toasts").appendChild(o),setTimeout(()=>{o.classList.add("closing"),setTimeout(()=>{o.remove(),document.querySelectorAll(".bd-toasts .bd-toast").length||document.querySelector(".bd-toasts").remove()},300)},r)}static ensureContainer(){if(document.querySelector(".bd-toasts"))return;const e=document.querySelector(`.${be} + div`),t=e.querySelector(`.${ye}`),s=e?e.querySelector("form"):null,n=e?e.getBoundingClientRect().left:310,r=t?t.getBoundingClientRect().left:0,i=r?r-e.getBoundingClientRect().left:e.offsetWidth,o=s?s.offsetHeight:80,a=document.createElement("div");a.classList.add("bd-toasts"),a.style.setProperty("left",n+"px"),a.style.setProperty("width",i+"px"),a.style.setProperty("bottom",o+"px"),document.querySelector("#app-mount").appendChild(a)}}class we{static get shouldShowContentErrors(){return v.get("settings","content","contentErrors")}static get ModalStack(){return u.getByProps("push","update","pop","popWithKey")}static get AlertModal(){return u.getByPrototypes("handleCancel","handleSubmit","handleMinorConfirm")}static get TextElement(){return u.getByProps("Sizes","Weights")}static get ConfirmationModal(){return u.getModule(e=>e.defaultProps&&e.key&&"confirm-modal"==e.key())}static default(e,t){const s=$(`<div class="bd-modal-wrapper theme-dark">\n <div class="bd-backdrop backdrop-1wrmKB"></div>\n <div class="bd-modal modal-1UGdnR">\n <div class="bd-modal-inner inner-1JeGVc">\n <div class="header header-1R_AjF">\n <div class="title">${e}</div>\n </div>\n <div class="bd-modal-body">\n <div class="scroller-wrap fade">\n <div class="scroller">\n ${t}\n </div>\n </div>\n </div>\n <div class="footer footer-2yfCgX">\n <button type="button">Okay</button>\n </div>\n </div>\n </div>\n </div>`);s.find(".footer button").on("click",()=>{s.addClass("closing"),setTimeout(()=>{s.remove()},300)}),s.find(".bd-backdrop").on("click",()=>{s.addClass("closing"),setTimeout(()=>{s.remove()},300)}),s.appendTo("#app-mount")}static alert(e,t){if(this.ModalStack&&this.AlertModal)return this.default(e,t);this.ModalStack.push(function(s){return F.createElement(this.AlertModal,Object.assign({title:e,body:t},s))})}static showConfirmationModal(e,t,s={}){const n=this.TextElement,r=this.ConfirmationModal,i=this.ModalStack;if(!this.ModalStack||!this.ConfirmationModal||!this.TextElement)return this.alert(e,t);const{onConfirm:o,onCancel:a,confirmText:l,cancelText:c,danger:d=!1}=s;"string"==typeof t?t=n({color:n.Colors.PRIMARY,children:[t]}):Array.isArray(t)&&(t=n({color:n.Colors.PRIMARY,children:t})),t=[t];const h=()=>{};i.push(function(s){return F.createElement(r,Object.assign({header:e,children:t,red:d,confirmText:l||"Okay",cancelText:c||"Cancel",onConfirm:o||h,onCancel:a||h},s))})}static showContentErrors({plugins:e=[],themes:t=[]}){if(!e||!t||!this.shouldShowContentErrors)return;if(!e.length&&!t.length)return;const s=$('<div class="bd-modal-wrapper theme-dark">\n <div class="bd-backdrop backdrop-1wrmKB"></div>\n <div class="bd-modal bd-content-modal modal-1UGdnR">\n <div class="bd-modal-inner inner-1JeGVc">\n <div class="header header-1R_AjF"><div class="title">Content Errors</div></div>\n <div class="bd-modal-body">\n <div class="tab-bar-container">\n <div class="tab-bar TOP">\n <div class="tab-bar-item">Plugins</div>\n <div class="tab-bar-item">Themes</div>\n </div>\n </div>\n <div class="table-header">\n <div class="table-column column-name">Name</div>\n <div class="table-column column-message">Message</div>\n <div class="table-column column-error">Error</div>\n </div>\n <div class="scroller-wrap fade">\n <div class="scroller">\n\n </div>\n </div>\n </div>\n <div class="footer footer-2yfCgX">\n <button type="button">Okay</button>\n </div>\n </div>\n </div>\n </div>'),n=function(e){const t=$('<div class="errors">');for(const s of e){const e=$(`<div class="error">\n <div class="table-column column-name">${s.name?s.name:s.file}</div>\n <div class="table-column column-message">${s.message}</div>\n <div class="table-column column-error"><a class="error-link" href="">${s.error?s.error.message:""}</a></div>\n </div>`);t.append(e),s.error&&e.find("a").on("click",e=>{e.preventDefault(),c.err("ContentManager",`Error details for ${s.name?s.name:s.file}.`,s.error)})}return t},r=[n(e),n(t)];s.find(".tab-bar-item").on("click",e=>{e.preventDefault(),s.find(".tab-bar-item").removeClass("selected"),$(e.target).addClass("selected"),s.find(".scroller").empty().append(r[$(e.target).index()])}),s.find(".footer button").on("click",()=>{s.addClass("closing"),setTimeout(()=>{s.remove()},300)}),s.find(".bd-backdrop").on("click",()=>{s.addClass("closing"),setTimeout(()=>{s.remove()},300)}),s.appendTo("#app-mount"),e.length?s.find(".tab-bar-item")[0].click():s.find(".tab-bar-item")[1].click()}}const Ce={get React(){return d.React},get ReactDOM(){return d.ReactDOM},get WindowConfigFile(){if(this._windowConfigFile)return this._windowConfigFile;const e=s(2).remote.app,t=s(1),n=e.getAppPath(),r=e.getPath("userData"),i=t.resolve(r,e.getVersion(),"modules","discord_desktop_core","injector","config.json"),o=t.resolve(n,"..","app","config.json"),a=s(0),l=a.existsSync(o)?o:a.existsSync(i)?i:null;return this._windowConfigFile=l||null},getAllWindowPreferences:function(){return this.WindowConfigFile?require(this.WindowConfigFile):{}},getWindowPreference:function(e){if(this.WindowConfigFile)return this.getAllWindowPreferences()[e]},setWindowPreference:function(e,t){if(!this.WindowConfigFile)return;const n=s(0),r=this.getAllWindowPreferences();r[e]=t,delete s.c[this.WindowConfigFile],n.writeFileSync(this.WindowConfigFile,JSON.stringify(r,null,4))},injectCSS:function(e,t){$("head").append($("<style>",{id:c.escapeID(e),text:t}))},clearCSS:function(e){$("#"+c.escapeID(e)).remove()},linkJS:function(e,t){$("head").append($("<script>",{id:c.escapeID(e),src:t,type:"text/javascript"}))},unlinkJS:function(e){$("#"+c.escapeID(e)).remove()},alert:function(e,t){we.alert(e,t)},showConfirmationModal:function(e,t,s={}){return we.showConfirmationModal(e,t,s)},showToast:function(e,t={}){ve.show(e,t)},findModule:function(e){return u.getModule(e)},findAllModules:function(e){return u.getModule(e,!1)},findModuleByProps:function(...e){return u.getByProps(...e)},findModuleByPrototypes:function(...e){return u.getByPrototypes(...e)},findModuleByDisplayName:function(e){return u.getByDisplayName(e)},getInternalInstance:function(e){if(e instanceof window.jQuery||e instanceof Element)return e instanceof jQuery&&(e=e[0]),c.getInternalInstance(e)},loadData:function(e,t){return f.getPluginData(e,t)}};Ce.getData=Ce.loadData,Ce.saveData=function(e,t,s){return f.setPluginData(e,t,s)},Ce.setData=Ce.saveData,Ce.deleteData=function(e,t){return f.deletePluginData(e,t)},Ce.monkeyPatch=function(e,t,s){return c.monkeyPatch(e,t,s)},Ce.onRemoved=function(e,t){return c.onRemoved(e,t)},Ce.suppressErrors=function(e,t){return c.suppressErrors(e,t)},Ce.testJSON=function(e){return c.testJSON(e)},Ce.getBDData=function(e){return f.getBDData(e)},Ce.setBDData=function(e,t){return f.setBDData(e,t)};var Ee=Ce;class Se extends F.Component{render(){return F.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"},F.createElement("metadata",null),F.createElement("defs",null,F.createElement("filter",{id:"shadow1"},F.createElement("feDropShadow",{dx:"20",dy:"0",stdDeviation:"20","flood-color":"rgba(0,0,0,0.35)"})),F.createElement("filter",{id:"shadow2"},F.createElement("feDropShadow",{dx:"15",dy:"0",stdDeviation:"20","flood-color":"rgba(255,255,255,0.15)"})),F.createElement("filter",{id:"shadow3"},F.createElement("feDropShadow",{dx:"10",dy:"0",stdDeviation:"20","flood-color":"rgba(0,0,0,0.35)"}))),F.createElement("g",null,F.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"}),F.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"}),F.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 Pe=new class{constructor(){this.editorDetached=!1}initialize(){Ee.suppressErrors(this.patchSocial.bind(this),"BD Social Patch")(),Ee.suppressErrors(this.patchGuildPills.bind(this),"BD Guild Pills Patch")(),Ee.suppressErrors(this.patchGuildListItems.bind(this),"BD Guild List Items Patch")(),Ee.suppressErrors(this.patchGuildSeparator.bind(this),"BD Guild Separator Patch")()}get messageClasses(){return u.getByProps("message","containerCozy")}get guildClasses(){const e=u.getByProps("wrapper","unreadMentionsBar"),t=u.getByProps("guildsError","selected"),s=u.getByProps("blobContainer");return Object.assign({},e,t,s)}get MessageContentComponent(){return u.getModule(e=>e.defaultProps&&e.defaultProps.hasOwnProperty("disableButtons"))}get TimeFormatter(){return u.getByProps("dateFormat")}get TooltipWrapper(){return u.getByDisplayName("TooltipDeprecated")}get NativeModule(){return u.getByProps("setBadge")}get Tooltips(){return u.getModule(e=>e.hide&&e.show&&!e.search&&!e.submit&&!e.search&&!e.activateRagingDemon&&!e.dismiss)}get KeyGenerator(){return u.getModule(e=>e.toString&&/"binary"/.test(e.toString()))}patchSocial(){if(this.socialPatch)return;const e=Ee.findModule(e=>"TabBar"==e.displayName),t=Ee.findModule(e=>"Anchor"==e.displayName);e&&t&&(this.socialPatch=Ee.monkeyPatch(e.prototype,"render",{after:e=>{const s=e.returnValue.props.children;if(!s||!s.length)return;if("Separator"!==s[s.length-2].type.displayName)return;if(!s[s.length-1].type.toString().includes("socialLinks"))return;const n=s[s.length-1].type;s[s.length-1].type=function(){const e=n(...arguments);return e.props.children.push(Ee.React.createElement(t,{className:"bd-social-link",href:"https://github.com/rauenzi/BetterDiscordApp",rel:"author",title:"BandagedBD",target:"_blank"},Ee.React.createElement(Se,{size:"16px",className:"bd-social-logo"}))),e}}}))}patchGuildListItems(){if(this.guildListItemsPatch)return;const e=this.guildClasses.listItem.split(" ")[0],t=this.guildClasses.blobContainer.split(" ")[0],s=Ee.getInternalInstance(document.querySelector(`.${e} .${t}`).parentElement).return.type;s&&(this.guildListItemsPatch=Ee.monkeyPatch(s.prototype,"render",{after:e=>{const t=e.returnValue,s=e.thisObject.props;return t.props.className+=" bd-guild",s.unread&&(t.props.className+=" bd-unread"),s.selected&&(t.props.className+=" bd-selected"),s.audio&&(t.props.className+=" bd-audio"),s.video&&(t.props.className+=" bd-video"),s.badge&&(t.props.className+=" bd-badge"),s.animatable&&(t.props.className+=" bd-animatable"),t}}))}patchGuildPills(){if(this.guildPillPatch)return;const e=Ee.findModule(e=>e.default&&e.default.toString&&e.default.toString().includes("translate3d"));e&&(this.guildPillPatch=Ee.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=Ee.findModuleByDisplayName("Guilds"),t=Ee.findModuleByProps("renderListItem");if(!t||!e)return;const s=function(){const e=t.Separator(...arguments);return e.props.className+=" bd-guild-separator",e};this.guildSeparatorPatch=Ee.monkeyPatch(e.prototype,"render",{after:e=>{e.returnValue.props.children[1].props.children[3].type=s}})}};class xe{get name(){return"Unnamed Builtin"}get collection(){return"settings"}get category(){return"general"}get id(){return"None"}async initialize(){v.get(this.collection,this.category,this.id)&&await this.enable(),y.on("setting-updated",(e,t,s,n)=>{e==this.collection&&t===this.category&&s===this.id&&(n?this.enable():this.disable())})}registerSetting(e,t,s,n,r){return 4==arguments.length?(e=this.collection,t=arguments[0],s=arguments[1],n=arguments[2],r=arguments[3]):3==arguments.length&&(e=this.collection,t=this.category,s=arguments[0],n=arguments[1],r=arguments[2]),v.on(e,t,s,e=>{e?n():r()})}get(e,t,s){return 2==arguments.length?(e=this.collection,t=arguments[0],s=arguments[1]):1==arguments.length&&(e=this.collection,t=this.category,s=arguments[0]),v.get(e,t,s)}async enable(){this.log("Enabled"),await this.enabled()}async disable(){this.log("Disabled"),await this.disabled()}async enabled(){}async disabled(){}log(...e){c.log(this.name,...e)}warn(...e){c.warn(this.name,...e)}error(...e){c.err(this.name,...e)}}var ke=new class extends xe{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 De=new RegExp("^(?!da-)((?:[A-Za-z]|[0-9]|-)+)-(?:[A-Za-z]|[0-9]|-|_){6}$");var Me=new class extends xe{get id(){return"classNormalizer"}get category(){return"general"}get name(){return"ClassNormalizer"}enabled(){this.hasPatched||(this.patchClassModules(u.getModules(this.moduleFilter.bind(this))),this.normalizeElement(document.querySelector("#app-mount")),this.hasPatched=!0,this.patchDOMMethods())}disabled(){this.hasPatched&&(this.unpatchClassModules(u.getModules(this.moduleFilter.bind(this))),this.revertElement(document.querySelector("#app-mount")),this.hasPatched=!1)}patchClassModules(e){for(const t of e)this.patchClassModule("da",t)}unpatchClassModules(e){for(const t of e)this.unpatchClassModule("da",t)}shouldIgnore(e){return!isNaN(e)||(!!(e.endsWith("px")||e.endsWith("ch")||e.endsWith("em")||e.endsWith("ms"))||(!!e.startsWith("layerContainer-")||(!(!e.startsWith("#")||7!=e.length&&4!=e.length)||!(!e.includes("calc(")&&!e.includes("rgba")))))}moduleFilter(e){if("object"!=typeof e||Array.isArray(e))return!1;if(e.__esModule)return!1;if(!Object.keys(e).length)return!1;for(const t in e){const s=e[t];if("string"!=typeof s)return!1;if(!this.shouldIgnore(s)){if(1===s.split("-").length)return!1;if(!De.test(s.split(" ")[0]))return!1}}return!0}patchClassModule(e,t){for(const s in t){const n=t[s];if(this.shouldIgnore(n))continue;const r=n.split(" ");for(const n of r){const r=n.match(De)[1];if(!r)continue;const i=r.split("-").map((e,t)=>t?e[0].toUpperCase()+e.slice(1):e).join("");t[s]+=` ${e}-${i}`}}}unpatchClassModule(e,t){for(const s in t){const n=t[s];if(this.shouldIgnore(n))continue;let r="";const i=n.split(" ");for(const t of i)t.startsWith(`${e}-`)||(r+=` ${t}`);t[s]=r.trim()}}normalizeElement(e){if(!(e instanceof Element))return;const t=e.classList;for(let s=0,n=t.length;s<n;s++){if(!De.test(t[s]))continue;const n=t[s].match(De)[1].split("-").map((e,t)=>t?e[0].toUpperCase()+e.slice(1):e).join("");e.classList.add(`da-${n}`)}for(const t of e.children)this.normalizeElement(t)}revertElement(e){if(!(e instanceof Element))return;e.children&&e.children.length&&this.revertElement(e.children[0]),e.nextElementSibling&&this.revertElement(e.nextElementSibling);const t=e.classList,s=[];for(let e=0;e<t.length;e++)t[e].startsWith("da-")&&s.push(t[e]);e.classList.remove(...s)}patchDOMMethods(){const e=DOMTokenList.prototype.contains;DOMTokenList.prototype.contains=function(t){return t.split(" ").every(t=>e.call(this,t))}}},Be=new class extends xe{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 s=$("<div/>",{class:"itemGroup-1tL0uz"}),n=$("<div/>",{class:"item-1Yvehc",click:()=>{d.ElectronModule.copy(this.lastSelector),t.hide()}}).append($("<span/>",{text:"Copy Selector"}));s.append(n),t.append(s),t.hasClass("undefined")&&t.css("top","-="+s.outerHeight())}),e.stopPropagation()})}disableSelectors(){$(document).off("contextmenu.bdDevmode"),$(document).off("contextmenu.bdDevModeCtx")}getRules(e,t=e.ownerDocument.styleSheets){return[...t].filter(e=>!e.href||!e.href.includes("BetterDiscordApp")).map(e=>[...e.cssRules||[]]).flat().filter(t=>t&&t.selectorText&&e.matches(t.selectorText)&&t.style.length&&t.selectorText.split(", ").length<8&&!t.selectorText.split(", ").includes("*"))}getSelector(e){if(e.id)return`#${e.id}`;const t=this.getRules(e),s=t[t.length-1];return s?s.selectorText:e.classList.length?`.${Array.from(e.classList).join(".")}`:`.${Array.from(e.parentElement.classList).join(".")}`}},Ne=new class extends xe{get name(){return"PublicServers"}get category(){return"general"}get id(){return"publicServers"}enabled(){const e=Pe.guildClasses.wrapper.split(" ")[0];$(`.${e} .scroller-2FKFPG >:first-child`).after(this.button)}disabled(){$("#bd-pub-li").remove()}get component(){return d.React.createElement(n.Layer,{rootId:"pubslayerroot",id:"pubslayer"},d.React.createElement(n.Menu,{rootId:"pubslayerroot"}))}get root(){const e=document.getElementById("pubslayerroot");return e||(this.injectRoot()?this.root:null)}injectRoot(){return!!$(".layers, .layers-3iHuyZ").length&&($(".layers, .layers-3iHuyZ").append($("<div/>",{id:"pubslayerroot"})),!0)}render(){const e=this.root;e?d.ReactDOM.render(this.component,e):this.error("FAILED TO LOCATE ROOT: .layers")}get button(){return $("<div/>",{class:Pe.guildClasses.listItem,id:"bd-pub-li"}).append($("<div/>",{class:"wrapper-25eVIn "+Pe.guildClasses.circleButtonMask,text:"public",id:"bd-pub-button",click:()=>{this.render()}}))}},Te=new class extends xe{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")}},$e=new class extends xe{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")}},je=new class extends xe{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 s=t.returnValue.match(e);if(s&&4===s.length)return"AM"===s[3]?t.returnValue=t.returnValue.replace(s[0],`${"12"===s[1]?"00":s[1].padStart(2,"0")}:${s[2]}`):t.returnValue=t.returnValue.replace(s[0],`${"12"===s[1]?"12":parseInt(s[1])+12}:${s[2]}`)},s=c.monkeyPatch(d.TimeFormatter,"calendarFormat",{after:t}),n=c.monkeyPatch(d.TimeFormatter,"dateFormat",{after:t});this.cancel24Hour=()=>{s(),n()}}};const Fe=u.getModule(e=>e.defaultProps&&e.defaultProps.hasOwnProperty("disableButtons"));var Le=new class extends xe{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=c.monkeyPatch(Fe.prototype,"render",{after:e=>{c.monkeyPatch(e.returnValue.props,"children",{silent:!0,after:({returnValue:t})=>{const s=t.props.children[1],n=e.thisObject.props.message.colorString;return s&&n&&(s.props.style={color:n}),t}})}}))}removeColoredText(){document.querySelectorAll(".markup-2BOw-j").forEach(e=>{e.style.setProperty("color","")})}},Oe=new class extends xe{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(){d.ChannelActions.selectVoiceChannel(null,null)}};class Ae extends d.React.Component{constructor(e){super(e);const t=!!(Ue&&Ue.favoriteEmotes&&Ue.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 v.get("emotes","general","animateOnHover")}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&&Ue.favoriteEmotes[this.label]?this.setState({isFavorite:!0}):this.state.isFavorite&&!Ue.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 d.React.createElement(Pe.TooltipWrapper,{color:"black",position:"top",text:this.label,delay:750},d.React.createElement("div",{className:"emotewrapper"+(this.props.jumboable?" jumboable":""),onMouseEnter:this.onMouseEnter,onMouseLeave:this.onMouseLeave,onClick:this.onClick},d.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}),d.React.createElement("input",{className:"fav"+(this.state.isFavorite?" active":""),title:"Favorite!",type:"button",onClick:e=>{e.preventDefault(),e.stopPropagation(),this.state.isFavorite?(delete Ue.favoriteEmotes[this.label],Ue.updateFavorites()):Ue.favorite(this.label,this.props.url),this.setState({isFavorite:!this.state.isFavorite})}})))}}const Ie={TwitchGlobal:{},TwitchSubscriber:{},BTTV:{},FrankerFaceZ:{},BTTV2:{}},Re={TwitchGlobal:"twitch",TwitchSubscriber:"twitch",BTTV:"bttv",FrankerFaceZ:"ffz",BTTV2:"bttv"},Ge=[],ze=["twitch","bttv","ffz"],Ve=["flip","spin","pulse","spin2","spin3","1spin","2spin","3spin","tr","bl","br","shake","shake2","shake3","flap"];var He=new class extends xe{get name(){return"Emotes"}get collection(){return"settings"}get category(){return"general"}get id(){return"emotes"}get categories(){return Object.keys(Re).filter(e=>this.isCategoryEnabled(Re[e]))}isCategoryEnabled(e){return super.get("emotes","categories",e)}get(e){return super.get("emotes","general",e)}get MessageContentComponent(){return u.getModule(e=>e.defaultProps&&e.defaultProps.hasOwnProperty("disableButtons"))}get Emotes(){return Ie}get TwitchGlobal(){return Ie.TwitchGlobal}get TwitchSubscriber(){return Ie.TwitchSubscriber}get BTTV(){return Ie.BTTV}get FrankerFaceZ(){return Ie.FrankerFaceZ}get BTTV2(){return Ie.BTTV2}get blacklist(){return Ge}getCategory(e){return Ie[e]}initialize(){super.initialize()}async enabled(){v.registerCollection("emotes","Emotes",a,{title:"Clear Emote Cache",onClick:()=>{this.clearEmoteData(),this.loadEmoteData(o)}})}disabled(){v.removeCollection("emotes"),this.emptyEmotes(),this.cancelEmoteRender&&(this.cancelEmoteRender(),delete this.cancelEmoteRender)}emptyEmotes(){for(const e in Ie)Object.assign(Ie,{[e]:{}})}patchMessageContent(){this.cancelEmoteRender||(this.cancelEmoteRender=c.monkeyPatch(this.MessageContentComponent.prototype,"render",{after:({returnValue:e})=>{c.monkeyPatch(e.props,"children",{silent:!0,after:({returnValue:e})=>{if(0==this.categories.length)return;const t=e.props.children[1];if(!t.props.children)return;const s=t.props.children[1];if(s&&s.length){for(let e=0;e<s.length;e++){const t=s[e];if("string"!=typeof t)continue;const n=t.split(/([^\s]+)([\s]|$)/g);for(let t=0,r=this.categories.length;t<r;t++)for(let r=0,i=n.length;r<i;r++){const i=n[r].split(":"),o=i[0];let a=i[1]?i[1]:"",l=a.slice(0);if(o.length<4||Ge.includes(o))continue;Ve.includes(a)&&v.get(this.category,"general","modifiers")||(a=""),ze.includes(l)?a=l:l="";let h=this.categories[t];if("twitch"===l?Ie.TwitchGlobal[o]?h="TwitchGlobal":Ie.TwitchSubscriber[o]&&(h="TwitchSubscriber"):"bttv"===l?Ie.BTTV[o]?h="BTTV":Ie.BTTV2[o]&&(h="BTTV2"):"ffz"===l&&Ie.FrankerFaceZ[o]&&(h="FrankerFaceZ"),!Ie[h][o]||!v.get(this.category,"categories",Re[h]))continue;const u=s[e].match(new RegExp(`([\\s]|^)${c.escape(a?o+":"+a:o)}([\\s]|$)`));if(!u)continue;const p=s[e].substring(0,u.index+u[1].length),m=s[e].substring(u.index+u[0].length-u[2].length);s[e]=p;const g=d.React.createElement(Ae,{name:o,url:Ie[h][o],modifier:a});s.splice(e+1,0,m),s.splice(e+1,0,g)}}if(s.every(e=>"string"==typeof e&&""==e.replace(/\s*/,"")||(!(!e.type||"BDEmote"!=e.type.name)||!!(e.props&&e.props.children&&e.props.children.props&&e.props.children.props.emojiName))))for(const e of s)"object"==typeof e&&("BDEmote"==e.type.name?e.props.jumboable=!0:e.props&&e.props.children&&e.props.children.props&&e.props.children.props.emojiName&&(e.props.children.props.jumboable=!0))}}})}}))}async loadEmoteData(e){this.emotesLoaded=!1;const t=s(0),n=i.dataPath+"emote_data.json";if(t.existsSync(n)&&this.isCacheValid()){ve.show("Loading emotes from cache.",{type:"info"}),c.log("Emotes","Loading emotes from local cache.");const s=await new Promise(e=>{t.readFile(n,"utf8",(t,s)=>{c.log("Emotes","Emotes loaded from cache."),t&&(s={}),e(s)})});let r=c.testJSON(s);r&&Object.assign(Ie,JSON.parse(s));for(const t in e)r=Object.keys(Ie[e[t].variable]).length>0;if(r)return ve.show("Emotes successfully loaded.",{type:"success"}),this.emotesLoaded=!0,void y.dispatch("emotes-loaded");c.log("Emotes","Cache was corrupt, downloading..."),t.unlinkSync(n)}if(v.get(this.category,"general","download")){ve.show("Downloading emotes in the background do not reload.",{type:"info"});for(const t in e){await new Promise(e=>setTimeout(e,1e3));const s=await this.downloadEmotes(e[t]);Ie[e[t].variable]=s}ve.show("All emotes successfully downloaded.",{type:"success"});try{t.writeFileSync(n,JSON.stringify(Ie),"utf8")}catch(e){c.err("Emotes","Could not save emote data.",e)}this.emotesLoaded=!0,y.dispatch("emotes-loaded")}}downloadEmotes(e){const t=s(5),n={url:e.url,timeout:e.timeout?e.timeout:5e3};return c.log("Emotes",`Downloading: ${e.variable} (${e.url})`),new Promise((s,r)=>{t(n,(t,n,i)=>{if(t)return c.err("Emotes","Could not download "+e.variable,t),e.backup?(e.url=e.backup,e.backup=null,e.backupParser&&(e.parser=e.backupParser),s(this.downloadEmotes(e))):r({});let o={};try{o=JSON.parse(i)}catch(t){return c.err("Emotes","Could not download "+e.variable,t),e.backup?(e.url=e.backup,e.backup=null,e.backupParser&&(e.parser=e.backupParser),s(this.downloadEmotes(e))):r({})}"function"==typeof e.parser&&(o=e.parser(o));for(const t in o)t.length<4||Ge.includes(t)?delete o[t]:o[t]=e.getEmoteURL(o[t]);s(o),c.log("Emotes","Downloaded: "+e.variable)})})}getBlacklist(){return new Promise(e=>{$.getJSON("https://rauenzi.github.io/BetterDiscordApp/data/emotefilter.json",function(t){e(Ge.push(...t.blacklist))})})}isCacheValid(){const e=f.getBDData("emoteCacheDays")||f.setBDData("emoteCacheDays",7)||7,t=new Date(f.getBDData("emoteCacheDate")||null),s=new Date;return!(Math.round(Math.abs((s.getTime()-t.getTime())/864e5))>e)||(f.setBDData("emoteCacheDate",s.toJSON()),!1)}clearEmoteData(){const e=s(0),t=i.dataPath+"emote_data.json";e.existsSync(t)&&e.unlinkSync(t),f.setBDData("emoteCacheDate",(new Date).toJSON());for(const e in Ie)Object.assign(Ie,{[e]:{}})}};const We=(e,t,s={})=>{const{onContextMenu:n,onClick:r}=s,i=$(`<div class="emote-container">\n <img class="emote-icon" alt="${e}" src="${t}" title="${e}">\n </div>`)[0];return n&&i.addEventListener("contextmenu",n),i.addEventListener("click",r),i};var Ue=new class extends xe{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=f.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(),He.emotesLoaded&&this.updateTwitchEmotes(),y.on("emotes-loaded",this.updateTwitchEmotes)}disabled(){y.off("emotes-loaded",this.updateTwitchEmotes),this.observer.disconnect(),this.disableHideEmojis(),this.hideEmojiCancel&&this.hideEmojiCancel()}enableHideEmojis(){$(".emojiPicker-3m1S-j").addClass("bda-qme-hidden")}disableHideEmojis(){$(".emojiPicker-3m1S-j").removeClass("bda-qme-hidden")}insertEmote(e){const t=c.getTextArea();c.insertText(t[0]," "==t.val().slice(-1)?t.val()+e:t.val()+" "+e)}favContext(e){e.stopPropagation();const t=e.target.closest(".emote-container").children[0],s=$('<div id="removemenu" class="bd-context-menu context-menu theme-dark">Remove</div>');s.css({top:e.pageY-$("#bda-qem-favourite-container").offset().top,left:e.pageX-$("#bda-qem-favourite-container").offset().left}),$(t).parent().append(s),s.on("click",e=>{e.preventDefault(),e.stopPropagation(),$(t).remove(),delete this.favoriteEmotes[$(t).attr("title")],this.updateFavorites(),$(document).off("mousedown.emotemenu")}),$(document).on("mousedown.emotemenu",function(e){"removemenu"!=e.target.id&&($("#removemenu").remove(),$(document).off("mousedown.emotemenu"))})}switchMenu(e){let t="string"==typeof e?e:$(e.target).attr("id");"bda-qem-emojis"==t&&this.hideEmojis&&(t="bda-qem-favourite");const s=$("#bda-qem-twitch"),n=$("#bda-qem-favourite"),r=$("#bda-qem-emojis");switch(s.removeClass("active"),n.removeClass("active"),r.removeClass("active"),$(".emojiPicker-3m1S-j").hide(),$("#bda-qem-favourite-container").hide(),$("#bda-qem-twitch-container").hide(),t){case"bda-qem-twitch":s.addClass("active"),$("#bda-qem-twitch-container").show();break;case"bda-qem-favourite":n.addClass("active"),$("#bda-qem-favourite-container").show();break;case"bda-qem-emojis":r.addClass("active"),$(".emojiPicker-3m1S-j").show(),$(".emojiPicker-3m1S-j input").focus()}t&&(this.lastTab=t)}observe(e){if(!(e.addedNodes.length&&e.addedNodes[0]instanceof Element))return;const t=e.addedNodes[0];if(!t.classList.contains("popout-3sVMXz")||t.classList.contains("popoutLeft-30WmrD")||!t.getElementsByClassName("emojiPicker-3m1S-j").length)return;const s=$(t);this.hideEmojis?s.addClass("bda-qme-hidden"):s.removeClass("bda-qme-hidden"),s.prepend(this.qmeHeader),s.append(this.teContainer),s.append(this.faContainer),this.switchMenu(this.lastTab)}favorite(e,t){this.favoriteEmotes.hasOwnProperty(e)||(this.favoriteEmotes[e]=t),this.updateFavorites()}updateTwitchEmotes(){for(;this.teContainerInner.firstChild;)this.teContainerInner.firstChild.remove();for(const e in He.getCategory("TwitchGlobal")){if(!He.getCategory("TwitchGlobal").hasOwnProperty(e))continue;const t=He.getCategory("TwitchGlobal")[e],s=We(e,t,{onClick:this.insertEmote.bind(this,e)});this.teContainerInner.append(s)}}updateFavorites(){for(;this.faContainerInner.firstChild;)this.faContainerInner.firstChild.remove();for(const e in this.favoriteEmotes){const t=this.favoriteEmotes[e],s=We(e,t,{onClick:this.insertEmote.bind(this,e),onContextMenu:this.favContext.bind(this)});this.faContainerInner.append(s)}f.setBDData("bdfavemotes",btoa(JSON.stringify(this.favoriteEmotes)))}},_e=new class extends xe{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 s=this.capitalize(t.toLowerCase());null!=s&&c.insertText(c.getTextArea()[0],e.replace(t,s))}})}disabled(){$("body").off(".bdac")}capitalize(e){const t=He.getCategory("TwitchGlobal");for(const s in t)if(t.hasOwnProperty(s)&&e==(s+"").toLowerCase())return s}};function qe(){}qe.prototype.setConfig=function(e){Object.assign(i,e)},qe.prototype.init=async function(){if(i.version<i.minSupportedVersion)return void we.alert("Not Supported","BetterDiscord v"+i.version+" (your version) is not supported by the latest js ("+i.bbdVersion+").<br><br> Please download the latest version from <a href='https://github.com/rauenzi/BetterDiscordApp/releases/latest' target='_blank'>GitHub</a>");const e=i.updater?i.updater.LatestVersion:i.latestVersion;e>i.version&&we.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 `),c.log("Startup","Initializing Settings"),v.initialize(),c.log("Startup","Initializing EmoteModule"),this.injectExternals(),await this.checkForGuilds(),Pe.initialize(),c.log("Startup","Updating Settings");for(const e in r)r[e].initialize();c.log("Startup","Loading Plugins");const t=N.loadAllPlugins();c.log("Startup","Loading Themes");const s=j.loadAllThemes();$("#customcss").detach().appendTo(document.head),c.log("Startup","Removing Loading Icon"),document.getElementsByClassName("bd-loaderv2")[0].remove(),c.log("Startup","Initializing Main Observer"),this.initObserver(),c.log("Startup","Collecting Startup Errors"),we.showContentErrors({plugins:t,themes:s})},qe.prototype.checkForGuilds=function(){return new Promise(e=>{const t=function(){const s=Pe.guildClasses.wrapper.split(" ")[0],n=Pe.guildClasses.listItem.split(" ")[0],r=Pe.guildClasses.blobContainer.split(" ")[0];if(document.querySelectorAll(`.${s} .${n} .${r}`).length>0)return e(i.deferLoaded=!0);setTimeout(t,100)};$(document).ready(function(){setTimeout(t,100)})})},qe.prototype.injectExternals=async function(){await c.injectJs("https://cdnjs.cloudflare.com/ajax/libs/ace/1.2.9/ace.js"),window.require.original&&(window.require=window.require.original)},qe.prototype.initObserver=function(){new MutationObserver(e=>{for(let t=0,s=e.length;t<s;t++){const s=e[t];if(!(s.addedNodes.length&&s.addedNodes[0]instanceof Element))continue;const n=s.addedNodes[0];n.classList.contains("layer-3QrUeG")&&n.getElementsByClassName("guild-settings-base-section").length&&n.setAttribute("layer-id","server-settings")}}).observe(document,{childList:!0,subtree:!0})};var Je=new qe;s.d(t,"default",function(){return Ye}),s.d(t,"patchModuleLoad",function(){return Ke}),function(){const e=s(0),t=process.platform,n=("win32"===t?process.env.APPDATA:"darwin"===t?process.env.HOME+"/Library/Preferences":process.env.HOME+"/.config")+"/BetterDiscord/";let r={};if(e.existsSync(`${n}localStorage.json`))try{r=JSON.parse(e.readFileSync(`${n}localStorage.json`))}catch(e){console.log(e)}else if(e.existsSync("localStorage.json"))try{r=JSON.parse(e.readFileSync("localStorage.json"))}catch(e){console.log(e)}const i=r;i.setItem=function(e,t){i[e]=t,this.save()},i.getItem=function(e){return i[e]||null},i.save=function(){e.writeFileSync(`${n}localStorage.json`,JSON.stringify(this),null,4)};new Proxy(i,{set:function(e,t,s){i[t]=s,i.save()},get:function(e,t){return i[t]||null}});window.localStorage=null}();const Ze=document.createElement("div");Ze.className="bd-loaderv2",Ze.title="BandagedBD is loading...",document.body.appendChild(Ze),window.BdApi=Ee,window.pluginModule=N,window.themeModule=j,window.bdEmotes=He.Emotes,window.bemotes=He.blacklist,window.bdPluginStorage=class{static get(e,t){return c.warn("Deprecation Notice",`${e}, please use BdApi.loadData() or BdApi.getData(). bdPluginStorage may be removed in future versions.`),f.getPluginData(e,t)||null}static set(e,t,s){if(c.warn("Deprecation Notice",`${e}, please use BdApi.saveData() or BdApi.setData(). bdPluginStorage may be removed in future versions.`),void 0===s)return c.warn("Deprecation Notice","Trying to set undefined value in plugin "+e);f.setPluginData(e,t,s)}static delete(e,t){c.warn("Deprecation Notice",`${e}, please use BdApi.deleteData(). bdPluginStorage may be removed in future versions.`),f.deletePluginData(e,t)}},window.settingsModule=v,window.DataStore=f,window.BDEvents=y,window.bdConfig=i;class Ye{constructor(e){Je.setConfig(e)}init(){Je.init()}}function Ke(){const e=s(3),t=e._load;return e._load=function(e){if("betterdiscord"===e||e.startsWith("betterdiscord/")){if("api"==e.substr("betterdiscord/".length))return Ee}return t.apply(this,arguments)},function(){e._load=t}}}]).default;