BetterDiscordApp-rauenzi/js/main.min.js

1 line
122 KiB
JavaScript

var Core=function(e){var t={};function s(n){if(t[n])return t[n].exports;var i=t[n]={i:n,l:!1,exports:{}};return e[n].call(i.exports,i,i.exports,s),i.l=!0,i.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 i in e)s.d(n,i,function(t){return e[t]}.bind(null,i));return n},s.n=function(e){var t=e&&e.__esModule?function(){return e.default}:function(){return e};return s.d(t,"a",t),t},s.o=function(e,t){return Object.prototype.hasOwnProperty.call(e,t)},s.p="",s(s.s=6)}([function(e,t){e.exports=require("fs")},function(e,t){e.exports=require("electron")},function(e,t){e.exports=require("path")},function(e,t){e.exports=require("module")},function(e,t){e.exports=require("events")},function(e,t){e.exports=require("request")},function(e,t,s){"use strict";s.r(t);var n={};s.r(n),s.d(n,"VoiceMode",function(){return De}),s.d(n,"ClassNormalizer",function(){return Be}),s.d(n,"DeveloperMode",function(){return Ne}),s.d(n,"PublicServers",function(){return je}),s.d(n,"DarkMode",function(){return Le}),s.d(n,"MinimalMode",function(){return Fe}),s.d(n,"TwentyFourHour",function(){return Oe}),s.d(n,"ColoredText",function(){return $e}),s.d(n,"VoiceDisconnect",function(){return ze}),s.d(n,"EmoteMenu",function(){return Ge}),s.d(n,"EmoteAutocaps",function(){return Je}),s.d(n,"EmoteModule",function(){return We}),s.d(n,"WindowPrefs",function(){return Ke}),s.d(n,"CustomCSS",function(){return Ct});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"},r={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]}},o=[{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}]}],a=[{type:"category",id:"general",name:"General",collapsible:!0,settings:[{type:"switch",id:"emotes",name:"Emote System",note:"Enables BD's emote system",value:!0},{type:"switch",id:"publicServers",name:"Public Servers",note:"Display public servers button",value:!0},{type:"switch",id:"voiceDisconnect",name:"Voice Disconnect",note:"Disconnect from voice server when closing Discord",value:!1},{type:"switch",id:"twentyFourHour",name:"24 Hour Timestamps",note:"Hides channels when in minimal mode",value:!1},{type:"switch",id:"classNormalizer",name:"Normalize Classes",note:"Adds stable classes to elements to help themes. (e.g. adds .da-channels to .channels-Ie2l6A)",value:!0},{type:"switch",id:"showToasts",name:"Show Toasts",note:"Shows a small notification for important information",value:!0}]},{type:"category",id:"appearance",name:"Appearance",collapsible:!0,settings:[{type:"switch",id:"voiceMode",name:"Voice Mode",note:"Hides everything that isn't voice chat",value:!1},{type:"switch",id:"minimalMode",name:"Minimal Mode",note:"Hide elements and reduce the size of elements",value:!1},{type:"switch",id:"hideChannels",name:"Hide Channels",note:"Hides channels when in minimal mode",value:!1,enableWith:"minimalMode"},{type:"switch",id:"darkMode",name:"Dark Mode",note:"Make certain elements dark by default",value:!0},{type:"switch",id:"coloredText",name:"Colored Text",note:"Make text colour the same as role color",value:!1}]},{type:"category",id:"content",name:"Content Manager",collapsible:!0,settings:[{type:"switch",id:"contentErrors",name:"Show Content Errors",note:"Shows a modal with plugin/theme errors",value:!0},{type:"switch",id:"autoScroll",name:"Scroll To Settings",note:"Auto-scrolls to a plugin's settings when the button is clicked (only if out of view)",value:!0},{type:"switch",id:"autoReload",name:"Automatic Loading",note:"Automatically loads, reloads, and unloads plugins and themes",value:!0}]},{type:"category",id:"developer",name:"Developer Settings",collapsible:!0,shown:!1,settings:[{type:"switch",id:"developerMode",name:"Developer Mode",note:"Allows activating debugger when pressing F8",value:!1},{type:"switch",id:"copySelector",name:"Copy Selector",note:'Adds a "Copy Selector" option to context menus when developer mode is active',value:!1,enableWith:"developerMode"}]},{type:"category",id:"window",name:"Window Preferences",collapsible:!0,shown:!1,settings:[{type:"switch",id:"transparency",name:"Enable Transparency",note:"Enables the main window to be see-through (requires restart)",value:!1},{type:"switch",id:"frame",name:"Window Frame",note:"Adds the native os window frame to the main window",value:!1,hidden:!0}]},{type:"category",id:"customcss",name:"Custom CSS",collapsible:!0,shown:!1,settings:[{type:"switch",id:"customcss",name:"Custom CSS",note:"Enables the Custom CSS tab",value:!0},{type:"switch",id:"liveUpdate",name:"Live Update",note:"Updates the css as you type",value:!1},{type:"switch",id:"startDetached",name:"Start Detached",note:"Clicking the Custom CSS tab opens the editor in a separate window",value:!1,disableWith:"nativeOpen"},{type:"switch",id:"nativeOpen",name:"Open in Native Editor",note:"Clicking the Custom CSS tab opens your custom css in your native editor",value:!1,disableWith:"startDetached"}]}];const l={err:"error",error:"error",dbg:"debug",debug:"debug",log:"log",warn:"warn",info:"info"};class c{static stacktrace(e,t,s){console.error(`%c[${e}]%c ${t}\n\n%c`,"color: #3a71c1; font-weight: 700;","color: red; font-weight: 700;","color: red;",s)}static err(e,...t){c._log(e,t,"error")}static warn(e,...t){c._log(e,t,"warn")}static info(e,...t){c._log(e,t,"info")}static debug(e,...t){c._log(e,t,"debug")}static log(e,...t){c._log(e,t)}static _log(e,t,s="log"){s=c.parseType(s),Array.isArray(t)||(t=[t]),console[s](`%c[BandagedBD]%c %c[${e}]%c`,"color: #3E82E5; font-weight: 700;","color: #3a71c1;","",...t)}static parseType(e){return l.hasOwnProperty(e)?l[e]:"log"}}class d{static getTextArea(){return $(".channelTextArea-1LDbYG textarea")}static insertText(e,t){e.focus(),e.selectionStart=0,e.selectionEnd=e.value.length,document.execCommand("insertText",!1,t)}static escape(e){return e.replace(/[-\/\\^$*+?.()|[\]{}]/g,"\\$&")}static testJSON(e){try{return JSON.parse(e)}catch(e){return!1}}static suppressErrors(e,t){return(...s)=>{try{return e(...s)}catch(e){c.stacktrace("SuppressedError","Error occurred in "+t,e)}}}static monkeyPatch(e,t,s){const{before:n,after:i,instead:r,once:o=!1,silent:a=!1,force:l=!1}=s,c=s.displayName||e.displayName||e.name||e.constructor.displayName||e.constructor.name;if(a||console.log("patch",t,"of",c),!e[t]){if(!l)return console.error(t,"does not exist for",c);e[t]=function(){}}const h=e[t],u=()=>{a||console.log("unpatch",t,"of",c),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(r){const n=d.suppressErrors(r,"`instead` callback of "+e[t].displayName)(s);void 0!==n&&(s.returnValue=n)}else n&&d.suppressErrors(n,"`before` callback of "+e[t].displayName)(s),s.callOriginalMethod(),i&&d.suppressErrors(i,"`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 i=0;i<n.length;i++){const r=n[i],o=Array.from(r.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)?c.error("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 formatString(e,t){for(const s in t){let n=t[s];Array.isArray(n)&&(n=JSON.stringify(n)),"object"==typeof n&&null!==n&&(n=n.toString()),e=e.replace(new RegExp(`{{${s}}}`,"g"),n)}return e}static findInTree(e,t,{walkable:s=null,ignore:n=[]}={}){if("string"==typeof t){if(e.hasOwnProperty(t))return e[t]}else if(t(e))return e;if("object"!=typeof e||null==e)return;let i=void 0;if(e instanceof Array){for(const r of e)if(void 0!==(i=this.findInTree(r,t,{walkable:s,ignore:n})))return i}else{const r=null==s?Object.keys(e):s;for(const o of r)if(e.hasOwnProperty(o)&&!n.includes(o)&&void 0!==(i=this.findInTree(e[o],t,{walkable:s,ignore:n})))return i}return i}static getNestedProp(e,t){return t.split(/\s?\.\s?/).reduce(function(e,t){return e&&e[t]},e)}static findInRenderTree(e,t,{walkable:s=["props","children","child","sibling"],ignore:n=[]}={}){return this.findInTree(e,t,{walkable:s,ignore:n})}static findInReactTree(e,t){return this.findInTree(e,t,{walkable:["props","children","return","stateNode"]})}static getReactInstance(e){return e.__reactInternalInstance$?e.__reactInternalInstance$:e[Object.keys(e).find(e=>e.startsWith("__reactInternalInstance"))]||null}static getOwnerInstance(e,{include:t,exclude:s=["Popout","Tooltip","Scroller","BackgroundFlash"],filter:n=(e=>e)}={}){if(void 0===e)return;const i=void 0===t,r=i?s:t;function o(e){const t=function(e){const t=e.type;return t&&(t.displayName||t.name)||null}(e);return null!==t&&!!(r.includes(t)^i)}let a=this.getReactInstance(e);for(a=a&&a.return;null!==a;a=a.return){if(null===a)continue;const e=a.stateNode;if(null!==a&&!(e instanceof HTMLElement)&&o(a)&&n(e))return e}return null}}var h=d.memoizeObject({get React(){return p.getByProps("createElement","cloneElement")},get ReactDOM(){return p.getByProps("render","findDOMNode")},get Flux(){return p.getByProps("connectStores")},get Events(){return p.getByPrototypes("setMaxListeners","emit")},get GuildStore(){return p.getByProps("getGuild")},get SortedGuildStore(){return p.getByProps("getSortedGuilds")},get SelectedGuildStore(){return p.getByProps("getLastSelectedGuildId")},get GuildSync(){return p.getByProps("getSyncedGuilds")},get GuildInfo(){return p.getByProps("getAcronym")},get GuildChannelsStore(){return p.getByProps("getChannels","getDefaultChannel")},get GuildMemberStore(){return p.getByProps("getMember")},get MemberCountStore(){return p.getByProps("getMemberCounts")},get GuildEmojiStore(){return p.getByProps("getEmojis")},get GuildActions(){return p.getByProps("markGuildAsRead")},get GuildPermissions(){return p.getByProps("getGuildPermissions")},get ChannelStore(){return p.getByProps("getChannels","getDMFromUserId")},get SelectedChannelStore(){return p.getByProps("getLastSelectedChannelId")},get ChannelActions(){return p.getByProps("selectChannel")},get PrivateChannelActions(){return p.getByProps("openPrivateChannel")},get ChannelSelector(){return p.getByProps("selectGuild","selectChannel")},get UserInfoStore(){return p.getByProps("getToken")},get UserSettingsStore(){return p.getByProps("guildPositions")},get AccountManager(){return p.getByProps("register","login")},get UserSettingsUpdater(){return p.getByProps("updateRemoteSettings")},get OnlineWatcher(){return p.getByProps("isOnline")},get CurrentUserIdle(){return p.getByProps("getIdleTime")},get RelationshipStore(){return p.getByProps("isBlocked","getFriendIDs")},get RelationshipManager(){return p.getByProps("addRelationship")},get MentionStore(){return p.getByProps("getMentions")},get UserStore(){return p.getByProps("getCurrentUser")},get UserStatusStore(){return p.getByProps("getStatus","getState")},get UserTypingStore(){return p.getByProps("isTyping")},get UserActivityStore(){return p.getByProps("getActivity")},get UserNameResolver(){return p.getByProps("getName")},get UserNoteStore(){return p.getByProps("getNote")},get UserNoteActions(){return p.getByProps("updateNote")},get EmojiInfo(){return p.getByProps("isEmojiDisabled")},get EmojiUtils(){return p.getByProps("getGuildEmoji")},get EmojiStore(){return p.getByProps("getByCategory","EMOJI_NAME_RE")},get InviteStore(){return p.getByProps("getInvites")},get InviteResolver(){return p.getByProps("findInvite")},get InviteActions(){return p.getByProps("acceptInvite")},get DiscordConstants(){return p.getByProps("Permissions","ActivityTypes","StatusTypes")},get DiscordPermissions(){return p.getByProps("Permissions","ActivityTypes","StatusTypes").Permissions},get PermissionUtils(){return p.getByProps("getHighestRole")},get ColorConverter(){return p.getByProps("hex2int")},get ColorShader(){return p.getByProps("darken")},get TinyColor(){return p.getByPrototypes("toRgb")},get ClassResolver(){return p.getByProps("getClass")},get ButtonData(){return p.getByProps("ButtonSizes")},get IconNames(){return p.getByProps("IconNames")},get NavigationUtils(){return p.getByProps("transitionTo","replaceWith","getHistory")},get MessageStore(){return p.getByProps("getMessages")},get MessageActions(){return p.getByProps("jumpToMessage","_sendMessage")},get MessageQueue(){return p.getByProps("enqueue")},get MessageParser(){return p.getByProps("createMessage","parse","unparse")},get hljs(){return p.getByProps("highlight","highlightBlock")},get SimpleMarkdown(){return p.getByProps("parseBlock","parseInline","defaultOutput")},get ExperimentStore(){return p.getByProps("getExperimentOverrides")},get ExperimentsManager(){return p.getByProps("isDeveloper")},get CurrentExperiment(){return p.getByProps("getExperimentId")},get ImageResolver(){return p.getByProps("getUserAvatarURL","getGuildIconURL")},get ImageUtils(){return p.getByProps("getSizedImageSrc")},get AvatarDefaults(){return p.getByProps("getUserAvatarURL","DEFAULT_AVATARS")},get WindowInfo(){return p.getByProps("isFocused","windowSize")},get TagInfo(){return p.getByProps("VALID_TAG_NAMES")},get DOMInfo(){return p.getByProps("canUseDOM")},get LocaleManager(){return p.getByProps("setLocale")},get Moment(){return p.getByProps("parseZone")},get LocationManager(){return p.getByProps("createLocation")},get Timestamps(){return p.getByProps("fromTimestamp")},get TimeFormatter(){return p.getByProps("dateFormat")},get Strings(){return p.getByProps("Messages").Messages},get StringFormats(){return p.getByProps("a","z")},get StringUtils(){return p.getByProps("toASCII")},get URLParser(){return p.getByProps("Url","parse")},get ExtraURLs(){return p.getByProps("getArticleURL")},get DNDActions(){return p.getByProps("beginDrag")},get DNDSources(){return p.getByProps("addTarget")},get DNDObjects(){return p.getByProps("DragSource")},get MediaDeviceInfo(){return p.getByProps("Codecs","SUPPORTED_BROWSERS")},get MediaInfo(){return p.getByProps("getOutputVolume")},get MediaEngineInfo(){return p.getByProps("MediaEngineFeatures")},get VoiceInfo(){return p.getByProps("EchoCancellation")},get VideoStream(){return p.getByProps("getVideoStream")},get SoundModule(){return p.getByProps("playSound")},get ElectronModule(){return p.getByProps("setBadge")},get Dispatcher(){return p.getByProps("dirtyDispatch")},get PathUtils(){return p.getByProps("hasBasename")},get NotificationModule(){return p.getByProps("showNotification")},get RouterModule(){return p.getByProps("Router")},get APIModule(){return p.getByProps("getAPIBaseURL")},get AnalyticEvents(){return p.getByProps("AnalyticEventConfigs")},get KeyGenerator(){return p.getByRegex(/"binary"/)},get Buffers(){return p.getByProps("Buffer","kMaxLength")},get DeviceStore(){return p.getByProps("getDevices")},get SoftwareInfo(){return p.getByProps("os")},get CurrentContext(){return p.getByProps("setTagsContext")}});class u{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 p{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 i in s){if(!s.hasOwnProperty(i))continue;const r=s[i],{exports:o}=r;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(h.hasOwnProperty(e))return h[e];if(!t)return;const s=this.getModule(t,!0);return s?h[e]=s:void 0}static getByDisplayName(e){return this.getModule(u.byDisplayName(e),!0)}static getByRegex(e,t=!0){return this.getModule(u.byCode(e),t)}static getByPrototypes(...e){return this.getModule(u.byPrototypeFields(e),!0)}static getAllByPrototypes(...e){return this.getModule(u.byPrototypeFields(e),!1)}static getByProps(...e){return this.getModule(u.byProperties(e),!0)}static getAllByProps(...e){return this.getModule(u.byProperties(e),!1)}static getByString(...e){return this.getModule(u.byString(...e),!0)}static getAllByString(...e){return this.getModule(u.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 m=s(0),g=s(2),f=DiscordNative.globals.releaseChannel;var b=new class{constructor(){this.data={misc:{}},this.pluginData={}}initialize(){m.existsSync(this.baseFolder)||m.mkdirSync(this.baseFolder),m.existsSync(this.dataFolder)||m.mkdirSync(this.dataFolder),m.existsSync(this.BDFile)||m.writeFileSync(this.BDFile,JSON.stringify(this.data.misc,null,4)),m.existsSync(this.customCSS)||m.writeFileSync(this.customCSS,"");const e=m.readdirSync(this.dataFolder).filter(e=>!m.statSync(g.resolve(this.dataFolder,e)).isDirectory()&&e.endsWith(".json"));for(const t of e)this.data[t.split(".")[0]]=require(g.resolve(this.dataFolder,t))}get customCSS(){return this._customCSS||(this._customCSS=g.resolve(this.dataFolder,"custom.css"))}get baseFolder(){return this._baseFolder||(this._baseFolder=g.resolve(i.dataPath,"data"))}get dataFolder(){return this._dataFolder||(this._dataFolder=g.resolve(this.baseFolder,`${f}`))}get BDFile(){return this._BDFile||(this._BDFile=g.resolve(i.dataPath,"data",`${f}.json`))}getPluginFile(e){return g.resolve(i.dataPath,"plugins",e+".config.json")}_getFile(e){return"settings"==e||"plugins"==e||"themes"==e?g.resolve(this.dataFolder,`${e}.json`):g.resolve(this.dataFolder,"misc.json")}getBDData(e){return this.data.misc[e]||""}setBDData(e,t){this.data.misc[e]=t,m.writeFileSync(g.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,m.writeFileSync(g.resolve(this.dataFolder,`${e}.json`),JSON.stringify(t,null,4))}loadCustomCSS(){return m.readFileSync(this.customCSS).toString()}saveCustomCSS(e){return m.writeFileSync(this.customCSS,e)}getPluginData(e,t){return void 0!==this.pluginData[e]?this.pluginData[e][t]||void 0:m.existsSync(this.getPluginFile(e))?(this.pluginData[e]=JSON.parse(m.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,m.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],m.writeFileSync(this.getPluginFile(e),JSON.stringify(this.pluginData[e],null,4))}};class y{static get bdHead(){return this.getElement("bd-head")}static get bdBody(){return this.getElement("bd-body")}static get bdScripts(){return this.getElement("bd-scripts")}static get bdStyles(){return this.getElement("bd-styles")}static get bdThemes(){return this.getElement("bd-themes")}static get bdCustomCSS(){return this.getElement("#customcss")}static initialize(){this.createElement("bd-head",{target:document.head}),this.createElement("bd-body",{target:document.body}),this.createElement("bd-scripts",{target:this.bdHead}),this.createElement("bd-styles",{target:this.bdHead}),this.createElement("bd-themes",{target:this.bdHead}),this.createElement("style",{id:"customcss",target:this.bdHead})}static escapeID(e){return e.replace(/^[^a-z]+|[^\w-]+/gi,"-")}static getElement(e,t=document){return e instanceof Node?e:t.querySelector(e)}static createElement(e,t={}){const{className:s,id:n,target:i}=t,r=document.createElement(e);return s&&(r.className=s),n&&(r.id=n),i&&this.getElement(i).append(r),r}static removeStyle(e){e=this.escapeID(e);const t=this.getElement(`#${e}`,this.bdStyles);t&&t.remove()}static injectStyle(e,t){e=this.escapeID(e);const s=this.getElement(`#${e}`,this.bdStyles)||this.createElement("style",{id:e});s.textContent=t,this.bdStyles.append(s)}static removeTheme(e){e=this.escapeID(e);const t=this.getElement(`#${e}`,this.bdThemes);t&&t.remove()}static injectTheme(e,t){e=this.escapeID(e);const s=this.getElement(`#${e}`,this.bdThemes)||this.createElement("style",{id:e});s.textContent=t,this.bdThemes.append(s)}static updateCustomCSS(e){this.bdCustomCSS.textContent=e}static removeScript(e){e=this.escapeID(e);const t=this.getElement(`#${e}`,this.bdScripts);t&&t.remove()}static injectScript(e,t){return e=this.escapeID(e),new Promise(s=>{const n=this.getElement(`#${e}`,this.bdScripts)||this.createElement("script",{id:e});n.src=t,n.onload=s,this.bdScripts.append(n)})}}const v=s(4);var w=new class extends v{constructor(){super(),this.setMaxListeners(20)}dispatch(e,...t){this.emit(e,...t)}},C=new class{constructor(){this.state={},this.collections=[],this.panels=[],this.registerCollection("settings","Settings",a)}initialize(){b.initialize(),this.loadSettings(),this.patchSections()}registerCollection(e,t,s,n=null){if(this.collections.find(t=>t.id==e))return c.error("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);if(!t<0)return c.error("Settings","No collection with id "+e);this.collections.splice(t,1)}registerPanel(e,t,s){if(this.panels.find(t=>t.id==e))return c.error("Settings","Already have a panel with id "+e);const{element:n,onClick:i,order:r=1}=s,o={id:e,order:r,label:t,section:t};i&&(o.clickListener=i),n&&(o.element=n instanceof h.React.Component?()=>h.React.createElement(n,{}):"function"==typeof n?n:()=>n),this.panels.push(o)}removePanel(e){const t=this.panels.findIndex(t=>t.id==e);if(!t<0)return c.error("Settings","No collection with id "+e);this.panels.splice(t,1)}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(s.disableWith){const e=this.getPath(s.disableWith.split("."),t.id,n.id);if(s.hasOwnProperty("disabled"))continue;Object.defineProperty(s,"disabled",{get:()=>this.state[e.collection][e.category][e.setting]})}}}}}}async patchSections(){d.monkeyPatch(p.getByDisplayName("FluxContainer(GuildSettings)").prototype,"render",{after:e=>{e.thisObject._reactInternalFiber.return.return.return.return.return.return.memoizedProps.id="guild-settings"}});const e=await this.getUserSettings();d.monkeyPatch(e.prototype,"render",{after:e=>{e.thisObject._reactInternalFiber.return.return.return.return.return.return.return.memoizedProps.id="user-settings"}}),d.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:()=>ce.buildSettingsPanel(e.name,e.settings,this.state[e.id],this.onSettingChange.bind(this,e.id),e.button?e.button:null)});for(const t of this.panels.sort((e,t)=>e.order>t.order))t.clickListener&&(t.onClick=s=>t.clickListener(e.thisObject,s,e.returnValue)),s(t);s({section:"CUSTOM",element:()=>ce.attribution})}}),this.forceUpdate()}forceUpdate(){const e=p.getByProps("standardSidebarView").standardSidebarView.split(" ")[0],t=document.querySelector(`.${e}`);d.getReactInstance(t).return.return.return.return.return.return.stateNode.forceUpdate()}getUserSettings(){return new Promise(e=>{const t=d.monkeyPatch(p.getByProps("getUserSettingsSections").default.prototype,"render",{after:s=>{e(s.returnValue.type),s.thisObject.forceUpdate(),t()}})})}saveSettings(){b.setData("settings",this.state)}loadSettings(){const e=b.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]: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 i=this.collections.length+this.panels.length;this.state[e][t][s]=n,w.dispatch("setting-updated",e,t,s,n);const r=this.collections.length+this.panels.length;this.saveSettings(),i!=r&&setTimeout(this.forceUpdate.bind(this),50)}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]}set(e,t,s,n){return 3==arguments.length&&(n=s,s=t,t=e,e="settings"),this.onSettingChange(e,t,s,n)}on(e,t,s,n){const i=(i,r,o,a)=>{i===e&&r===t&&o===s&&n(a)};return w.on("setting-updated",i),()=>{w.off("setting-updated",i)}}};class S extends Error{constructor(e,t,s,n){super(s),this.name=e,this.file=t,this.error=n}}class E extends Error{constructor(e){super(e),this.name="MetaError"}}const P=s(2),x=s(0),k=s(3).Module;k.globalPaths.push(P.resolve(s(1).remote.app.getAppPath(),"node_modules"));const D=/[^\S\r\n]*?\n[^\S\r\n]*?\*[^\S\r\n]?/,M=/^\\@/,B=function(e){return 65279===e.charCodeAt(0)&&(e=e.slice(1)),e};class N{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 w.emit(`${this.prefix}-${e}`,...t)}constructor(){this.timeCache={},this.contentList=[],this.state={},this.originalRequire=k._extensions[this.moduleExtension],k._extensions[this.moduleExtension]=this.getContentRequire(),C.on(this.collection,this.category,this.id,e=>{e?this.watchContent():this.unwatchContent()})}initializeContent(){}getContentModification(e,t){return t}startContent(){}stopContent(){}loadState(){const e=b.getData(`${this.prefix}s`);e&&Object.assign(this.state,e)}saveState(){b.setData(`${this.prefix}s`,this.state)}watchContent(){if(this.watcher)return c.error(this.name,"Already watching content.");c.log(this.name,"Starting to watch content."),this.watcher=x.watch(this.contentFolder,{persistent:!1},async(e,t)=>{if(!e||!t||!t.endsWith(this.extension))return;await new Promise(e=>setTimeout(e,50));try{x.statSync(P.resolve(this.contentFolder,t))}catch(e){if("ENOENT"!==e.code)return;delete this.timeCache[t],this.unloadContent(t,!0)}if(!x.statSync(P.resolve(this.contentFolder,t)).isFile())return;const s=x.statSync(P.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.error(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 E("META was not found.")}parseOldMeta(e){const t=e.split("\n")[0],s=t.substring(t.lastIndexOf("//META")+6,t.lastIndexOf("*//")),n=d.testJSON(s);if(!n)throw new E("META could not be parsed.");if(!n.name)throw new E("META missing name data.");return n}parseNewMeta(e){const t=e.split("/**",2)[1].split("*/",1)[0],s={};let n="",i="";for(const e of t.split(D))if(0!==e.length)if("@"===e.charAt(0)&&" "!==e.charAt(1)){s[n]=i;const t=e.indexOf(" ");n=e.substr(1,t-1),i=e.substr(t+1)}else i+=" "+e.replace("\\n","\n").replace(M,"@");return s[n]=i.trim(),delete s[""],s}getContentRequire(){const e=this,t=this.originalRequire;return function(s,n){const i=P.resolve(e.contentFolder,P.basename(n));if(!x.existsSync(i)||n!==x.realpathSync(i))return Reflect.apply(t,this,arguments);let r=x.readFileSync(n,"utf8");r=B(r);const o=e.extractMeta(r);o.id=o.name,o.filename=P.basename(n),r=e.getContentModification(s,r,o),s._compile(r,n)}}loadContent(e,t=!1){if(void 0===e)return;try{require(P.resolve(this.contentFolder,e))}catch(n){return new S(e,e,"Could not be compiled.",{message:n.message,stack:n.stack})}const s=require(P.resolve(this.contentFolder,e));if(this.contentList.find(e=>e.id==s.id))return new S(s.name,e,`There is already a plugin with name ${s.name}`);const n=this.initializeContent(s);return n||(this.contentList.push(s),t&&we.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(P.resolve(this.contentFolder,n.filename))],this.contentList.splice(this.contentList.indexOf(n),1),this.emit("unloaded",n.id),t&&we.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=x.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)&&x.statSync(P.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=x.readdirSync(this.contentFolder);for(const s of t){if(!x.statSync(P.resolve(this.contentFolder,s)).isFile()||!s.endsWith(this.extension))continue;const t=this.loadContent(s,!1);t instanceof S&&e.push(t)}return this.saveState(),C.get(this.collection,this.category,this.id)&&this.watchContent(),e}}const T=s(2),j=s(1).remote;var L=new class extends N{get name(){return"PluginManager"}get moduleExtension(){return".js"}get extension(){return".plugin.js"}get contentFolder(){return T.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&&Ce.showContentErrors({themes:[t]})}reloadPlugin(e){const t=this.reloadContent(e);return t&&Ce.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(),C.registerPanel("plugins","Plugins",{element:()=>ce.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 S(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 S(e.name,e.filename,"load() could not be fired.",{message:t.message,stack:t.stack})}}catch(t){return new S(e.name,e.filename,"Could not be constructed.",{message:t.message,stack:t.stack})}}getContentModification(e,t,s){return e._compile(t,e.filename),d.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),we.show(`${t.name} v${t.version} has started.`)}catch(e){return this.state[t.id]=!1,we.error(`${t.name} v${t.version} could not be started.`),c.stacktrace(this.name,t.name+" could not be started.",e),new S(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),we.show(`${t.name} v${t.version} has stopped.`)}catch(e){return this.state[t.id]=!1,we.error(`${t.name} v${t.version} could not be stopped.`),c.stacktrace(this.name,t.name+" could not be stopped.",e),new S(t.name,t.filename,"stop() could not be fired.",{message:e.message,stack:e.stack})}}setupFunctions(){j.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.stacktrace(this.name,"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.stacktrace(this.name,"Unable to fire observer for "+this.contentList[t].name+".",e)}}}};const F=s(2);var O=new class extends N{get name(){return"ThemeManager"}get moduleExtension(){return".css"}get extension(){return".theme.css"}get contentFolder(){return F.resolve(i.dataPath,"themes")}get prefix(){return"theme"}updateThemeList(){return this.updateList()}loadAllThemes(){return C.registerPanel("themes","Themes",{element:()=>ce.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&&Ce.showContentErrors({themes:[t]})}reloadTheme(e){const t=this.reloadContent(e);t&&Ce.showContentErrors({themes:[t]})}getContentModification(e,t,s){return s.css=t,`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;t&&y.injectTheme(t.id,t.css)}removeTheme(e){const t="string"==typeof e?this.contentList.find(t=>t.id==e):e;t&&y.removeTheme(t.id)}};class A{static get patches(){return this._patches||(this._patches=[])}static getPatchesByCaller(e){if(!e)return[];const t=[];for(const s of this.patches)for(const n of s.children)n.caller===e&&t.push(n);return t}static unpatchAll(e){"string"==typeof e&&(e=this.getPatchesByCaller(e));for(const t of e)t.unpatch()}static resolveModule(e){return e instanceof Function||e instanceof Object&&!(e instanceof Array)?e:"string"==typeof e?h[e]:e instanceof Array?p.findByUniqueProperties(e):null}static makeOverride(e){return function(){let t=void 0;if(!e.children||!e.children.length)return e.originalFunction.apply(this,arguments);for(const t of e.children.filter(e=>"before"===e.type))try{t.callback(this,arguments)}catch(s){c.err("Patcher",`Could not fire before callback of ${e.functionName} for ${t.caller}`,s)}const s=e.children.filter(e=>"instead"===e.type);if(s.length)for(const n of s)try{const s=n.callback(this,arguments,e.originalFunction.bind(this));void 0!==s&&(t=s)}catch(t){c.err("Patcher",`Could not fire instead callback of ${e.functionName} for ${n.caller}`,t)}else t=e.originalFunction.apply(this,arguments);for(const s of e.children.filter(e=>"after"===e.type))try{const n=s.callback(this,arguments,t);void 0!==n&&(t=n)}catch(t){c.err("Patcher",`Could not fire after callback of ${e.functionName} for ${s.caller}`,t)}return t}}static rePatch(e){e.proxyFunction=e.module[e.functionName]=this.makeOverride(e)}static makePatch(e,t,s){const n={name:s,module:e,functionName:t,originalFunction:e[t],proxyFunction:null,revert:()=>{n.module[n.functionName]=n.originalFunction,n.proxyFunction=null,n.children=[]},counter:0,children:[]};return n.proxyFunction=e[t]=this.makeOverride(n),this.patches.push(n),n}static before(e,t,s,n,i={}){return this.pushChildPatch(e,t,s,n,Object.assign(i,{type:"before"}))}static after(e,t,s,n,i={}){return this.pushChildPatch(e,t,s,n,Object.assign(i,{type:"after"}))}static instead(e,t,s,n,i={}){return this.pushChildPatch(e,t,s,n,Object.assign(i,{type:"instead"}))}static pushChildPatch(e,t,s,n,i={}){const{type:r="after",forcePatch:o=!0}=i,a=this.resolveModule(t);if(!a)return null;if(!a[s]&&o&&(a[s]=function(){}),!(a[s]instanceof Function))return null;"string"==typeof t&&(i.displayName=t);const l=`${i.displayName||a.displayName||a.name||a.constructor.displayName||a.constructor.name}.${s}`,c=this.patches.find(e=>e.module==a&&e.functionName==s)||this.makePatch(a,s,l);c.proxyFunction||this.rePatch(c);const d={caller:e,type:r,id:c.counter,callback:n,unpatch:()=>{if(c.children.splice(c.children.findIndex(e=>e.id===d.id&&e.type===r),1),c.children.length<=0){const e=this.patches.findIndex(e=>e.module==a&&e.functionName==s);this.patches[e].revert(),this.patches.splice(e,1)}}};return c.children.push(d),c.counter++,d.unpatch}}const z=h.React,I=(h.ReactDOM,"bd-settings-title h2-2gWE-o title-3sZWYQ size16-14cGz5 height20-mO2eIN weightSemiBold-NJexzi defaultColor-1_ajX0 defaultMarginh2-2LTaUL marginBottom20-32qID7"),R="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 _ extends z.Component{constructor(e){super(e)}render(){const e=this.props.isGroup?R:I,t=this.props.className?`${e} ${this.props.className}`:e;return z.createElement("h2",{className:t,onClick:()=>{this.props.onClick&&this.props.onClick()}},this.props.text,this.props.button&&z.createElement("button",{className:"bd-button bd-button-title",onClick:this.props.button.onClick},this.props.button.title),this.props.otherChildren)}}class U extends z.Component{render(){return z.createElement("svg",{viewBox:"0 0 12 12",style:{width:"18px",height:"18px"}},z.createElement("g",{className:"background",fill:"none",fillRule:"evenodd"},z.createElement("path",{d:"M0 0h12v12H0"}),z.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 q extends z.Component{render(){const e=this.props.size||"24px";return z.createElement("svg",{className:this.props.className||"",onClick:this.props.onClick,fill:"#dcddde",viewBox:"0 0 24 24",style:{width:e,height:e}},z.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"}),z.createElement("path",{fill:"none",d:"M0 0h24v24H0z"}))}}class V extends z.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=z.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,i=t.offsetTop,r=i+t.clientHeight;return i<s||r>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{content:e}=this.props,t=this.getString(e.name),s=this.getString(e.author),n=this.getString(e.description),i=this.getString(e.version),r=e.website,o=e.source;if(this.state.settingsOpen){try{this.settingsPanel=e.plugin.getSettingsPanel()}catch(t){c.stacktrace("Plugin Settings","Unable to get settings panel for "+e.name+".",t)}const s={id:`plugin-settings-${t}`,className:"plugin-settings",ref:this.panelRef};return"string"==typeof this.settingsPanel&&(s.dangerouslySetInnerHTML=this.settingsPanel),z.createElement("li",{className:"settings-open ui-switch-item"},z.createElement("div",{style:{float:"right",cursor:"pointer"},onClick:()=>{this.panelRef.current.innerHTML="",this.setState({settingsOpen:!1})}},z.createElement(U,null)),z.createElement("div",s,this.settingsPanel instanceof z.Component?this.settingsPanel:null))}return z.createElement("li",{"data-name":t,"data-version":i,className:"settings-closed ui-switch-item"},z.createElement("div",{className:"bda-header"},z.createElement("span",{className:"bda-header-title"},z.createElement("span",{className:"bda-name"},t)," v",z.createElement("span",{className:"bda-version"},i)," by ",z.createElement("span",{className:"bda-author"},s)),z.createElement("div",{className:"bda-controls"},!C.get("settings","content","autoReload")&&z.createElement(q,{className:"bd-reload bd-reload-card",onClick:this.reload}),z.createElement("label",{className:"ui-switch-wrapper ui-flex-child",style:{flex:"0 0 auto"}},z.createElement("input",{checked:this.state.checked,onChange:this.onChange,className:"ui-switch-checkbox",type:"checkbox"}),z.createElement("div",{className:this.state.checked?"ui-switch checked":"ui-switch"})))),z.createElement("div",{className:"bda-description-wrap scroller-wrap fade"},z.createElement("div",{className:"bda-description scroller"},n)),(r||o||this.hasSettings)&&z.createElement("div",{className:"bda-footer"},z.createElement("span",{className:"bda-links"},r&&z.createElement("a",{className:"bda-link bda-link-website",href:r,target:"_blank"},"Website"),r&&o&&" | ",o&&z.createElement("a",{className:"bda-link bda-link-source",href:o,target:"_blank"},"Source")),this.hasSettings&&z.createElement("button",{onClick:this.showSettings,className:"bd-button bd-button-plugin-settings",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 W extends z.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,i=e.author,r=e.website,o=e.source;return z.createElement("li",{"data-name":t,"data-version":n,className:"settings-closed ui-switch-item"},z.createElement("div",{className:"bda-header"},z.createElement("span",{className:"bda-header-title"},z.createElement("span",{className:"bda-name"},t)," v",z.createElement("span",{className:"bda-version"},n)," by ",z.createElement("span",{className:"bda-author"},i)),z.createElement("div",{className:"bda-controls"},!C.get("settings","content","autoReload")&&z.createElement(q,{className:"bd-reload bd-reload-card",onClick:this.reload}),z.createElement("label",{className:"ui-switch-wrapper ui-flex-child",style:{flex:"0 0 auto"}},z.createElement("input",{checked:this.state.checked,onChange:this.onChange,className:"ui-switch-checkbox",type:"checkbox"}),z.createElement("div",{className:this.state.checked?"ui-switch checked":"ui-switch"})))),z.createElement("div",{className:"bda-description-wrap scroller-wrap fade"},z.createElement("div",{className:"bda-description scroller"},s)),(r||o)&&z.createElement("div",{className:"bda-footer"},z.createElement("span",{className:"bda-links"},r&&z.createElement("a",{className:"bda-link",href:r,target:"_blank"},"Website"),r&&o&&" | ",o&&z.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 z.Component{reload(){this.props.refreshList&&this.props.refreshList(),this.forceUpdate()}render(){const{title:e,folder:t,contentList:n,contentState:i,onChange:r,reload:o}=this.props,a=!C.get("settings","content","autoReload"),l=t?{title:`Open ${e} Folder`,onClick:()=>{s(1).shell.openItem(t)}}:null;return[z.createElement(_,{key:"title",text:e,button:l,otherChildren:a&&z.createElement(q,{className:"bd-reload",onClick:this.reload.bind(this)})}),z.createElement("ul",{key:"ContentList",className:"bda-slist"},n.sort((e,t)=>e.name.toLowerCase().localeCompare(t.name.toLowerCase())).map(e=>{const t=e.type?V:W;return z.createElement(t,{showReloadIcon:a,key:e.id,enabled:i[e.id],content:e,onChange:r,reload:o})}))]}}class G extends z.Component{render(){return z.createElement("div",{className:"bd-divider divider-3573oO marginTop8-1DLZ1n marginBottom40-2vIwTv"})}}const J="flex-1xMQg5 flex-1O1GKY vertical-V37hAW flex-1O1GKY directionColumn-35P_nr justifyStart-2NDFzi alignStretch-DpGPf3 noWrap-3jynv6 switchItem-2hKKKK",Y="flex-1xMQg5 flex-1O1GKY horizontal-1ae9ci horizontal-2EEEnY flex-1O1GKY directionRow-3v3tfG justifyStart-2NDFzi alignStart-H-X2h- noWrap-3jynv6",Z="flexChild-faoVW3",K="titleDefault-a8-ZSr title-31JmR4 da-titleDefault da-title",X="flexChild-faoVW3 da-flexChild switchDisabled-3HsXAJ switch-3wwwcV da-switchDisabled da-switch valueUnchecked-2lU_20 value-2hFrkk sizeDefault-2YlOZr size-3rFEHg themeDefault-24hCdX",Q="flexChild-faoVW3 da-flexChild switchDisabled-3HsXAJ switch-3wwwcV da-switchDisabled da-switch valueChecked-m-4IJZ value-2hFrkk sizeDefault-2YlOZr size-3rFEHg themeDefault-24hCdX",ee="flexChild-faoVW3 da-flexChild switchEnabled-V2WDBB switch-3wwwcV da-switchEnabled da-switch valueUnchecked-2lU_20 value-2hFrkk sizeDefault-2YlOZr size-3rFEHg themeDefault-24hCdX",te="flexChild-faoVW3 da-flexChild switchEnabled-V2WDBB switch-3wwwcV da-switchEnabled da-switch valueChecked-m-4IJZ value-2hFrkk sizeDefault-2YlOZr size-3rFEHg themeDefault-24hCdX",se="checkboxEnabled-CtinEn checkbox-2tyjJg",ne="checkboxDisabled-1MA81A checkbox-2tyjJg",ie="description-3_Ncsb formText-3fs7AJ note-1V3kyJ modeDefault-3a2Ph1 primary-jw0I4K",re="divider-3573oO dividerDefault-3rvLe-";class oe extends z.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?Q:X:this.state.checked?te:ee;return z.createElement("div",{className:J,style:{flex:"1 1 auto"}},z.createElement("div",{className:Y,style:{flex:"1 1 auto"}},z.createElement("div",{className:Z,style:{flex:"1 1 auto"}},z.createElement("label",{htmlFor:this.props.id,className:K},this.props.name||this.props.data.text)),z.createElement("div",{className:e,tabIndex:"0",style:{flex:"0 0 auto"}},z.createElement("input",{id:this.props.id,className:this.props.disabled?ne:se,type:"checkbox",tabIndex:"-1",checked:this.state.checked,onChange:e=>this.onChange(e)}))),z.createElement("div",{className:ie,style:{flex:"1 1 auto"}},this.props.note||this.props.data.info),z.createElement("div",{className:re}))}}const ae="bd-settings-group";class le extends z.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=z.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=`${ae} ${t}`;return z.createElement("div",{className:s},z.createElement(_,{text:this.props.name,collapsible:this.props.collapsible,onClick:()=>this.toggleCollapse(),button:this.props.button,isGroup:!0}),z.createElement("div",{className:"bd-settings-container",ref:this.container},e.filter(e=>!e.hidden).map(e=>z.createElement(oe,{disabled:e.disabled,id:e.id,key:e.id,name:e.name,note:e.note,checked:e.value,onChange:this.onChange}))),this.props.showDivider&&z.createElement(G,null))}}class ce{static buildSettingsPanel(e,t,s,n,i=null){return t.forEach(e=>{e.settings.forEach(t=>t.value=s[e.id][t.id])}),this.getSettingsPanel(e,t,n,i)}static getSettingsPanel(e,t,s,n=null){return[z.createElement(_,{text:e,button:n}),t.map(e=>z.createElement(le,Object.assign({},e,{onChange:s})))]}static getContentPanel(e,t,s,n={}){return z.createElement(H,Object.assign({},{title:e,contentList:t,contentState:s},n))}static get attribution(){return z.createElement("div",{style:{fontSize:"12px",fontWeight:"600",color:"#72767d",padding:"2px 10px"}},`BBD v${i.bbdVersion} by `,z.createElement("a",{href:"https://github.com/rauenzi/",target:"_blank"},"Zerebos"))}}class de extends z.Component{constructor(e){super(e),this.props.server.iconUrl||(this.props.server.iconUrl=this.props.defaultAvatar()),this.state={imageError:!1,joined:this.props.joined}}render(){const{server:e}=this.props;return z.createElement("div",{className:`card-3Qj_Yx cardPrimary-1Hv-to marginBottom8-AtZOdT bd-server-card${e.pinned?" bd-server-card-pinned":""}`},z.createElement("img",{ref:"img",className:"bd-server-image",src:e.iconUrl,onError:this.handleError.bind(this)}),z.createElement("div",{className:"flexChild-faoVW3 bd-server-content"},z.createElement("div",{className:"flex-1xMQg5 flex-1O1GKY horizontal-1ae9ci horizontal-2EEEnY directionRow-3v3tfG noWrap-3jynv6 bd-server-header"},z.createElement("h5",{className:"h5-18_1nd defaultColor-1_ajX0 margin-reset bd-server-name"},e.name),z.createElement("h5",{className:"h5-18_1nd defaultColor-1_ajX0 margin-reset bd-server-member-count"},e.members," Members")),z.createElement("div",{className:"flex-1xMQg5 flex-1O1GKY horizontal-1ae9ci horizontal-2EEEnY directionRow-3v3tfG noWrap-3jynv6"},z.createElement("div",{className:"scrollerWrap-2lJEkd scrollerThemed-2oenus themeGhostHairline-DBD-2d scrollerFade-1Ijw5y bd-server-description-container"},z.createElement("div",{className:"scroller-2FKFPG scroller bd-server-description"},e.description))),z.createElement("div",{className:"flex-1xMQg5 flex-1O1GKY horizontal-1ae9ci horizontal-2EEEnY directionRow-3v3tfG noWrap-3jynv6 bd-server-footer"},z.createElement("div",{className:"flexChild-faoVW3 bd-server-tags",style:{flex:"1 1 auto"}},e.categories.join(", ")),this.state.joined&&z.createElement("button",{type:"button",className:"bd-button button-38aScr lookFilled-1Gx00P colorBrand-3pXr91 sizeMin-1mJd1x grow-q77ONN colorGreen-29iAKY",style:{minHeight:"12px",marginTop:"4px",backgroundColor:"#3ac15c"}},z.createElement("div",{className:"ui-button-contents"},"string"==typeof this.state.joined?"Joining...":"Joined")),e.error&&z.createElement("button",{type:"button",className:"bd-button button-38aScr lookFilled-1Gx00P colorBrand-3pXr91 sizeMin-1mJd1x grow-q77ONN disabled-9aF2ug",style:{minHeight:"12px",marginTop:"4px",backgroundColor:"#c13a3a"}},z.createElement("div",{className:"ui-button-contents"},"Error")),!e.error&&!this.state.joined&&z.createElement("button",{type:"button",className:"bd-button button-38aScr lookFilled-1Gx00P colorBrand-3pXr91 sizeMin-1mJd1x grow-q77ONN",style:{minHeight:"12px",marginTop:"4px"},onClick:()=>{this.join()}},z.createElement("div",{className:"ui-button-contents"},"Join")))))}handleError(){this.props.server.iconUrl=this.props.defaultAvatar(),this.setState({imageError:!0})}async join(){this.setState({joined:"joining"});const e=await this.props.join(this.props.server.identifier,this.props.server.nativejoin);this.setState({joined:e})}}const he=p.getByProps("getSortedGuilds"),ue=p.getByProps("getUserAvatarURL","DEFAULT_AVATARS"),pe=p.getByProps("acceptInvite"),me=s(1).remote.BrowserWindow;class ge{static get endPoint(){return"https://search.discordservers.com"}static get joinEndPoint(){return"https://j.discordservers.com"}static get connectEndPoint(){return"https://auth.discordservers.com/info"}static getDefaultAvatar(){return ue.DEFAULT_AVATARS[Math.floor(5*Math.random())]}static hasJoined(e){return he.guildPositions.includes(e)}static search({term:e="",category:t="",from:s=0}={}){return new Promise(n=>{const i=[];t&&i.push(`category=${t.replace(/ /g,"%20")}`),e&&i.push(`term=${e.replace(/ /g,"%20")}`),s&&i.push(`from=${s}`);const r=`?${i.join("&")}`;$.ajax({method:"GET",url:`${this.endPoint}${r}`,success:e=>{const t=e.size+e.from;n({servers:e.results,size:e.size,from:e.from,total:e.total,next:t>=e.total?null:t})},error:()=>n(null)})})}static join(e,t=!1){return new Promise(s=>{if(t)return pe.acceptInvite(e),s(!0);$.ajax({method:"GET",url:`${this.joinEndPoint}/${e}`,headers:{Accept:"application/json;","Content-Type":"application/json;","x-discord-token":this._accessToken},crossDomain:!0,xhrFields:{withCredentials:!0},success:()=>s(!0),error:()=>s(!1)})})}static checkConnection(){return new Promise(e=>{try{$.ajax({method:"GET",url:this.connectEndPoint,headers:{Accept:"application/json;","Content-Type":"application/json;"},crossDomain:!0,xhrFields:{withCredentials:!0},success:t=>{this._accessToken=t.access_token,e(t)},error:()=>e(!1)})}catch(t){e(!1)}})}static connect(){return new Promise(e=>{const t=new me(this.windowOptions),s=`https://auth.discordservers.com/connect?scopes=guilds.join&previousUrl=${this.connectEndPoint}`;t.webContents.on("did-navigate",(s,n)=>{n==this.connectEndPoint&&(t.close(),e())}),t.loadURL(s)})}static get windowOptions(){return{width:500,height:550,backgroundColor:"#282b30",show:!0,resizable:!0,maximizable:!1,minimizable:!1,alwaysOnTop:!0,frame:!1,center:!0,webPreferences:{nodeIntegration:!1}}}}const fe=p.getByDisplayName("SettingsView");class be extends z.Component{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"]}constructor(e){super(e),this.state={category:"All",query:"",loading:!0,user:null,results:{servers:[],size:0,from:0,total:0,next:null}},this.changeCategory=this.changeCategory.bind(this),this.searchKeyDown=this.searchKeyDown.bind(this),this.connect=this.connect.bind(this),this.loadNextPage=this.loadNextPage.bind(this)}componentDidMount(){this.checkConnection()}async checkConnection(){const e=await ge.checkConnection();if(!e)return this.setState({loading:!0,user:null});this.setState({user:e}),this.search()}async connect(){await ge.connect(),this.checkConnection()}searchKeyDown(e){this.state.loading||13!==e.which||this.search(e.target.value)}async search(e="",t=0){this.setState({query:e,loading:!0});const s=await ge.search({term:e,category:"All"==this.state.category?"":this.state.category,from:t});if(!s)return this.setState({results:{servers:[],size:0,from:0,total:0,next:null}});this.setState({loading:!1,results:s})}async changeCategory(e){this.state.loading||(await new Promise(t=>this.setState({category:e},t)),this.search())}loadNextPage(){this.state.loading||this.search(this.state.query,this.state.results.next)}async join(e,t=!1){return await ge.join(e,t)}get searchBox(){return z.createElement("input",{onKeyDown:this.searchKeyDown,type:"text",className:"bd-search",placeholder:"Search...",value:this.state.query,maxLength:"50"})}get title(){if(!this.state.user)return"Not connected to DiscordServers.com!";if(this.state.loading)return"Loading...";const e=this.state.results.from+1,t=this.state.results.total;let s=`Showing ${e}-${this.state.results.next?this.state.results.next:t} of ${t} results in ${this.state.category}`;return this.state.query&&(s+=` for ${this.state.query}`),s}get content(){const e=this.state.user?null:{title:"Connect",onClick:this.connect},t="All"!=this.state.category&&this.state.user?null:this.bdServer,s=this.state.results.servers.map(e=>z.createElement(de,{key:e.identifier,server:e,joined:ge.hasJoined(e.identifier),defaultAvatar:ge.getDefaultAvatar}));return[z.createElement(_,{text:this.title,button:e}),t,s,this.state.results.next?this.nextButton:null,this.state.results.servers.length>0&&z.createElement(_,{text:this.title})]}get nextButton(){return z.createElement("button",{type:"button",className:"bd-button bd-button-next",onClick:this.loadNextPage},this.state.loading?"Loading":"Load More")}get connection(){const{user:e}=this.state;return e?z.createElement("div",{id:"bd-connection"},z.createElement("div",{className:"bd-footnote"},"Connected as: ",`${e.username}#${e.discriminator}`),z.createElement("button",{type:"button",className:"bd-button bd-button-reconnect",onClick:this.connect},"Reconnect")):z.createElement("div",{id:"bd-connection"})}get bdServer(){const e={name:"BetterDiscord",online:"7500+",members:"20000+",categories:["community","programming","support"],description:"Official BetterDiscord server for plugins, themes, support, etc",identifier:"86004744966914048",iconUrl:"https://cdn.discordapp.com/icons/86004744966914048/292e7f6bfff2b71dfd13e508a859aedd.webp",nativejoin:!0,invite_code:"0Tmfo5ZbORCRqbAd",pinned:!0};return z.createElement(de,{server:e,pinned:!0,joined:ge.hasJoined(e.identifier),defaultAvatar:ge.getDefaultAvatar})}render(){const e=this.categoryButtons.map(e=>({section:e,label:e,element:()=>this.content}));return z.createElement(fe,{onClose:this.props.close,onSetSection:this.changeCategory,section:this.state.category,sections:[{section:"HEADER",label:"Search"},{section:"CUSTOM",element:()=>this.searchBox},{section:"HEADER",label:"Categories"},...e,{section:"DIVIDER"},{section:"HEADER",label:z.createElement("a",{href:"https://discordservers.com",target:"_blank"},"Discordservers.com")},{section:"DIVIDER"},{section:"CUSTOM",element:()=>this.connection}],theme:"dark"})}}const ye=p.getByProps("channels").channels.split(" ")[0],ve=p.getByProps("membersWrap").membersWrap.split(" ")[0];class we{static get shouldShowToasts(){return C.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:i=3e3,forceShow:r=!1}=t;if(!this.shouldShowToasts&&!r)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)},i)}static ensureContainer(){if(document.querySelector(".bd-toasts"))return;const e=document.querySelector(`.${ye} + div`),t=e.querySelector(`.${ve}`),s=e?e.querySelector("form"):null,n=e?e.getBoundingClientRect().left:310,i=t?t.getBoundingClientRect().left:0,r=i?i-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",r+"px"),a.style.setProperty("bottom",o+"px"),document.querySelector("#app-mount").appendChild(a)}}class Ce{static get shouldShowContentErrors(){return C.get("settings","content","contentErrors")}static get ModalStack(){return p.getByProps("push","update","pop","popWithKey")}static get AlertModal(){return p.getByPrototypes("handleCancel","handleSubmit","handleMinorConfirm")}static get TextElement(){return p.getByProps("Sizes","Weights")}static get ConfirmationModal(){return p.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 z.createElement(this.AlertModal,Object.assign({title:e,body:t},s))})}static showConfirmationModal(e,t,s={}){const n=this.TextElement,i=this.ConfirmationModal,r=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.default({color:n.Colors.PRIMARY,children:[t]}):Array.isArray(t)&&(t=n.default({color:n.Colors.PRIMARY,children:t})),t=[t];const h=()=>{};r.push(function(s){return z.createElement(i,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.stacktrace("ContentError",`Error details for ${s.name?s.name:s.file}.`,s.error)})}return t},i=[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(i[$(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 Se={get React(){return h.React},get ReactDOM(){return h.ReactDOM},get WindowConfigFile(){if(this._windowConfigFile)return this._windowConfigFile;const e=s(1).remote.app,t=s(2),n=e.getAppPath(),i=e.getPath("userData"),r=t.resolve(i,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(r)?r:null;return this._windowConfigFile=l||null},getAllWindowPreferences:function(){return this.WindowConfigFile?require(this.WindowConfigFile):{}},getWindowPreference:function(e){if(this.WindowConfigFile)return this.getAllWindowPreferences()[e]},setWindowPreference:function(e,t){if(!this.WindowConfigFile)return;const n=s(0),i=this.getAllWindowPreferences();i[e]=t,delete s.c[this.WindowConfigFile],n.writeFileSync(this.WindowConfigFile,JSON.stringify(i,null,4))},injectCSS:function(e,t){y.injectStyle(e,t)},clearCSS:function(e){y.removeStyle(e)},linkJS:function(e,t){return y.injectScript(e,t)},unlinkJS:function(e){y.removeScript(e)},alert:function(e,t){Ce.alert(e,t)},showConfirmationModal:function(e,t,s={}){return Ce.showConfirmationModal(e,t,s)},showToast:function(e,t={}){we.show(e,t)},findModule:function(e){return p.getModule(e)},findAllModules:function(e){return p.getModule(e,!1)},findModuleByProps:function(...e){return p.getByProps(...e)},findModuleByPrototypes:function(...e){return p.getByPrototypes(...e)},findModuleByDisplayName:function(e){return p.getByDisplayName(e)},getInternalInstance:function(e){if(e instanceof window.jQuery||e instanceof Element)return e instanceof jQuery&&(e=e[0]),d.getReactInstance(e)},loadData:function(e,t){return b.getPluginData(e,t)}};Se.getData=Se.loadData,Se.saveData=function(e,t,s){return b.setPluginData(e,t,s)},Se.setData=Se.saveData,Se.deleteData=function(e,t){return b.deletePluginData(e,t)},Se.monkeyPatch=function(e,t,s){return d.monkeyPatch(e,t,s)},Se.onRemoved=function(e,t){return d.onRemoved(e,t)},Se.suppressErrors=function(e,t){return d.suppressErrors(e,t)},Se.testJSON=function(e){return d.testJSON(e)},Se.getBDData=function(e){return b.getBDData(e)},Se.setBDData=function(e,t){return b.setBDData(e,t)};var Ee=Se;class Pe extends z.Component{render(){return z.createElement("svg",{className:"bd-logo "+this.props.className,height:"100%",width:this.props.size||"16px",viewBox:"0 0 2000 2000",style:{fillRule:"evenodd",clipRule:"evenodd",strokeLinecap:"round",strokeLinejoin:"round"}},z.createElement("metadata",null),z.createElement("defs",null,z.createElement("filter",{id:"shadow1"},z.createElement("feDropShadow",{dx:"20",dy:"0",stdDeviation:"20",floodColor:"rgba(0,0,0,0.35)"})),z.createElement("filter",{id:"shadow2"},z.createElement("feDropShadow",{dx:"15",dy:"0",stdDeviation:"20",floodColor:"rgba(255,255,255,0.15)"})),z.createElement("filter",{id:"shadow3"},z.createElement("feDropShadow",{dx:"10",dy:"0",stdDeviation:"20",floodColor:"rgba(0,0,0,0.35)"}))),z.createElement("g",null,z.createElement("path",{style:{filter:"url(#shadow3)"},fill:"#171717",opacity:"1",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"}),z.createElement("path",{style:{filter:"url(#shadow2)"},fill:"#3E82E5",opacity:"1",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"}),z.createElement("path",{style:{filter:"url(#shadow1)"},fill:"#FFFFFF",opacity:"1",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"})))}}var xe=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 p.getByProps("message","containerCozy")}get guildClasses(){const e=p.getByProps("wrapper","unreadMentionsBar"),t=p.getByProps("guildsError","selected"),s=p.getByProps("blobContainer");return Object.assign({},e,t,s)}get MessageContentComponent(){return p.getModule(e=>e.defaultProps&&e.defaultProps.hasOwnProperty("disableButtons"))}get TimeFormatter(){return p.getByProps("dateFormat")}get TooltipWrapper(){return p.getByDisplayName("TooltipDeprecated")}get NativeModule(){return p.getByProps("setBadge")}get Tooltips(){return p.getModule(e=>e.hide&&e.show&&!e.search&&!e.submit&&!e.search&&!e.activateRagingDemon&&!e.dismiss)}get KeyGenerator(){return p.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(Pe,{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 ke{get name(){return"Unnamed Builtin"}get collection(){return"settings"}get category(){return"general"}get id(){return"None"}async initialize(){C.get(this.collection,this.category,this.id)&&await this.enable(),w.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,i){return 4==arguments.length?(e=this.collection,t=arguments[0],s=arguments[1],n=arguments[2],i=arguments[3]):3==arguments.length&&(e=this.collection,t=this.category,s=arguments[0],n=arguments[1],i=arguments[2]),C.on(e,t,s,e=>{e?n():i()})}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]),C.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)}stacktrace(e,t){c.stacktrace(this.name,e,t)}after(e,t,s){return A.after(this.name,e,t,s)}unpatchAll(){return A.unpatchAll(this.name)}}var De=new class extends ke{get name(){return"VoiceMode"}get category(){return"appearance"}get id(){return"voiceMode"}enabled(){document.querySelector(".chat-3bRxxu").style.setProperty("visibility","hidden"),document.querySelector(".chat-3bRxxu").style.setProperty("min-width","0px"),document.querySelector(".channels-Ie2l6A").style.setProperty("flex-grow","100000")}disabled(){document.querySelector(".chat-3bRxxu").style.setProperty("visibility",""),document.querySelector(".chat-3bRxxu").style.setProperty("min-width",""),document.querySelector(".channels-Ie2l6A").style.setProperty("flex-grow","")}};const Me=new RegExp("^(?!da-)((?:[A-Za-z]|[0-9]|-)+)-(?:[A-Za-z]|[0-9]|-|_){6}$");var Be=new class extends ke{get id(){return"classNormalizer"}get category(){return"general"}get name(){return"ClassNormalizer"}enabled(){this.hasPatched||(this.patchClassModules(p.getModules(this.moduleFilter.bind(this))),this.normalizeElement(document.querySelector("#app-mount")),this.hasPatched=!0,this.patchDOMMethods())}disabled(){this.hasPatched&&(this.unpatchClassModules(p.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(!Me.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 i=n.split(" ");for(const n of i){const i=n.match(Me)[1];if(!i)continue;const r=i.split("-").map((e,t)=>t?e[0].toUpperCase()+e.slice(1):e).join("");t[s]+=` ${e}-${r}`}}}unpatchClassModule(e,t){for(const s in t){const n=t[s];if(this.shouldIgnore(n))continue;let i="";const r=n.split(" ");for(const t of r)t.startsWith(`${e}-`)||(i+=` ${t}`);t[s]=i.trim()}}normalizeElement(e){if(!(e instanceof Element))return;const t=e.classList;for(let s=0,n=t.length;s<n;s++){if(!Me.test(t[s]))continue;const n=t[s].match(Me)[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))}}},Ne=new class extends ke{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:()=>{h.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(".")}`}};const Te=p.getByProps("pushLayer");var je=new class extends ke{get name(){return"PublicServers"}get category(){return"general"}get id(){return"publicServers"}enabled(){const e=xe.guildClasses.wrapper.split(" ")[0];$(`.${e} .scroller-2FKFPG >:first-child`).after(this.button)}disabled(){$("#bd-pub-li").remove()}openPublicServers(){Te.pushLayer(()=>h.React.createElement(be,{close:Te.popLayer}))}get button(){return $("<div/>",{class:xe.guildClasses.listItem,id:"bd-pub-li"}).append($("<div/>",{class:"wrapper-25eVIn "+xe.guildClasses.circleButtonMask,text:"public",id:"bd-pub-button",click:()=>{this.openPublicServers()}}))}},Le=new class extends ke{get name(){return"DarkMode"}get category(){return"appearance"}get id(){return"darkMode"}enabled(){document.getElementById("app-mount").classList.add("bda-dark","bda-dark")}disabled(){document.getElementById("app-mount").classList.remove("bda-dark","bda-dark")}},Fe=new class extends ke{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(){document.body.classList.add("bd-minimal"),this.hideChannels&&this.enableHideChannels(),this.hideChannelCancel=this.registerSetting(this.hideChannelsID,this.enableHideChannels,this.disableHideChannels)}disabled(){document.body.classList.remove("bd-minimal"),this.hideChannels&&this.disableHideChannels(),this.hideChannelCancel&&this.hideChannelCancel()}enableHideChannels(){document.body.classList.add("bd-minimal-chan")}disableHideChannels(){document.body.classList.remove("bd-minimal-chan")}},Oe=new class extends ke{get name(){return"24Hour"}get category(){return"general"}get id(){return"twentyFourHour"}enabled(){this.inject24Hour()}disabled(){this.unpatchAll()}inject24Hour(){const e=new RegExp("([0-9]{1,2}):([0-9]{1,2})\\s(AM|PM)"),t=(t,s,n)=>{const i=n.match(e);if(i&&4===i.length)return"AM"===i[3]?n.replace(i[0],`${"12"===i[1]?"00":i[1].padStart(2,"0")}:${i[2]}`):n.replace(i[0],`${"12"===i[1]?"12":parseInt(i[1])+12}:${i[2]}`)};this.after(h.TimeFormatter,"calendarFormat",t),this.after(h.TimeFormatter,"dateFormat",t)}};const Ae=p.getModule(e=>e.defaultProps&&e.defaultProps.hasOwnProperty("disableButtons"));var $e=new class extends ke{get name(){return"ColoredText"}get category(){return"appearance"}get id(){return"coloredText"}enabled(){this.injectColoredText()}disabled(){this.unpatchAll()}injectColoredText(){this.after(Ae.prototype,"render",(e,t,s)=>{this.after(s.props,"children",{silent:!0,after:({returnValue:t})=>{const s=t.props.children[1],n=e.props.message.colorString;s&&n&&(s.props.style={color:n})}})})}removeColoredText(){document.querySelectorAll(".markup-2BOw-j").forEach(e=>{e.style.setProperty("color","")})}},ze=new class extends ke{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(){h.ChannelActions.selectVoiceChannel(null,null)}};class Ie extends z.Component{constructor(e){super(e);const t=!!(Ge&&Ge.favoriteEmotes&&Ge.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 C.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&&Ge.favoriteEmotes[this.label]?this.setState({isFavorite:!0}):this.state.isFavorite&&!Ge.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 z.createElement(xe.TooltipWrapper,{color:"black",position:"top",text:this.label,delay:750},z.createElement("div",{className:"emotewrapper"+(this.props.jumboable?" jumboable":""),onMouseEnter:this.onMouseEnter,onMouseLeave:this.onMouseLeave,onClick:this.onClick},z.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}),z.createElement("input",{className:"fav"+(this.state.isFavorite?" active":""),title:"Favorite!",type:"button",onClick:e=>{e.preventDefault(),e.stopPropagation(),this.state.isFavorite?(delete Ge.favoriteEmotes[this.label],Ge.updateFavorites()):Ge.favorite(this.label,this.props.url),this.setState({isFavorite:!this.state.isFavorite})}})))}}const Re={TwitchGlobal:{},TwitchSubscriber:{},BTTV:{},FrankerFaceZ:{},BTTV2:{}},_e={TwitchGlobal:"twitch",TwitchSubscriber:"twitch",BTTV:"bttv",FrankerFaceZ:"ffz",BTTV2:"bttv"},Ue=[],qe=["twitch","bttv","ffz"],Ve=["flip","spin","pulse","spin2","spin3","1spin","2spin","3spin","tr","bl","br","shake","shake2","shake3","flap"];var We=new class extends ke{get name(){return"Emotes"}get collection(){return"settings"}get category(){return"general"}get id(){return"emotes"}get categories(){return Object.keys(_e).filter(e=>this.isCategoryEnabled(_e[e]))}isCategoryEnabled(e){return super.get("emotes","categories",e)}get(e){return super.get("emotes","general",e)}get MessageContentComponent(){return p.getModule(e=>e.defaultProps&&e.defaultProps.hasOwnProperty("disableButtons"))}get Emotes(){return Re}get TwitchGlobal(){return Re.TwitchGlobal}get TwitchSubscriber(){return Re.TwitchSubscriber}get BTTV(){return Re.BTTV}get FrankerFaceZ(){return Re.FrankerFaceZ}get BTTV2(){return Re.BTTV2}get blacklist(){return Ue}getCategory(e){return Re[e]}initialize(){super.initialize()}async enabled(){C.registerCollection("emotes","Emotes",o,{title:"Clear Emote Cache",onClick:()=>{this.clearEmoteData(),this.loadEmoteData(r)}})}disabled(){C.removeCollection("emotes"),this.emptyEmotes(),this.cancelEmoteRender&&(this.cancelEmoteRender(),delete this.cancelEmoteRender)}emptyEmotes(){for(const e in Re)Object.assign(Re,{[e]:{}})}patchMessageContent(){this.cancelEmoteRender||(this.cancelEmoteRender=this.after(this.MessageContentComponent.prototype,"render",(e,t,s)=>{this.after(s.props,"children",(e,t,s)=>{if(0==this.categories.length)return;const n=s.props.children[1];if(!n.props.children)return;const i=n.props.children[1];if(i&&i.length){for(let e=0;e<i.length;e++){const t=i[e];if("string"!=typeof t)continue;const s=t.split(/([^\s]+)([\s]|$)/g);for(let t=0,n=this.categories.length;t<n;t++)for(let n=0,r=s.length;n<r;n++){const r=s[n].split(":"),o=r[0];let a=r[1]?r[1]:"",l=a.slice(0);if(o.length<4||Ue.includes(o))continue;Ve.includes(a)&&C.get(this.category,"general","modifiers")||(a=""),qe.includes(l)?a=l:l="";let c=this.categories[t];if("twitch"===l?Re.TwitchGlobal[o]?c="TwitchGlobal":Re.TwitchSubscriber[o]&&(c="TwitchSubscriber"):"bttv"===l?Re.BTTV[o]?c="BTTV":Re.BTTV2[o]&&(c="BTTV2"):"ffz"===l&&Re.FrankerFaceZ[o]&&(c="FrankerFaceZ"),!Re[c][o]||!C.get(this.category,"categories",_e[c]))continue;const u=i[e].match(new RegExp(`([\\s]|^)${d.escape(a?o+":"+a:o)}([\\s]|$)`));if(!u)continue;const p=i[e].substring(0,u.index+u[1].length),m=i[e].substring(u.index+u[0].length-u[2].length);i[e]=p;const g=h.React.createElement(Ie,{name:o,url:Re[c][o],modifier:a});i.splice(e+1,0,m),i.splice(e+1,0,g)}}if(i.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 i)"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()){we.show("Loading emotes from cache.",{type:"info"}),this.log("Loading emotes from local cache.");const s=await new Promise(e=>{t.readFile(n,"utf8",(t,s)=>{this.log("Emotes loaded from cache."),t&&(s={}),e(s)})}),i=d.testJSON(s);let r=!!i;r&&Object.assign(Re,i);for(const t in e)r=Object.keys(Re[e[t].variable]).length>0;if(r)return we.show("Emotes successfully loaded.",{type:"success"}),this.emotesLoaded=!0,void w.dispatch("emotes-loaded");this.log("Cache was corrupt, downloading..."),t.unlinkSync(n)}if(C.get(this.category,"general","download")){we.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]);Re[e[t].variable]=s}we.show("All emotes successfully downloaded.",{type:"success"});try{t.writeFileSync(n,JSON.stringify(Re),"utf8")}catch(e){this.stacktrace("Could not save emote data.",e)}this.emotesLoaded=!0,w.dispatch("emotes-loaded")}}downloadEmotes(e){const t=s(5),n={url:e.url,timeout:e.timeout?e.timeout:5e3,json:!0};return this.log(`Downloading: ${e.variable} (${e.url})`),new Promise((s,i)=>{t(n,(t,n,r)=>{if(t)return this.stacktrace("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))):i({});"function"==typeof e.parser&&(r=e.parser(r));for(const t in r)t.length<4||Ue.includes(t)?delete r[t]:r[t]=e.getEmoteURL(r[t]);s(r),this.log("Downloaded: "+e.variable)})})}getBlacklist(){return new Promise(e=>{$.getJSON("https://rauenzi.github.io/BetterDiscordApp/data/emotefilter.json",function(t){e(Ue.push(...t.blacklist))})})}isCacheValid(){const e=b.getBDData("emoteCacheDays")||b.setBDData("emoteCacheDays",7)||7,t=new Date(b.getBDData("emoteCacheDate")||null),s=new Date;return!(Math.round(Math.abs((s.getTime()-t.getTime())/864e5))>e)||(b.setBDData("emoteCacheDate",s.toJSON()),!1)}clearEmoteData(){const e=s(0),t=i.dataPath+"emote_data.json";e.existsSync(t)&&e.unlinkSync(t),b.setBDData("emoteCacheDate",(new Date).toJSON());for(const e in Re)Object.assign(Re,{[e]:{}})}};const He=(e,t,s={})=>{const{onContextMenu:n,onClick:i}=s,r=$(`<div class="emote-container">\n <img class="emote-icon" alt="${e}" src="${t}" title="${e}">\n </div>`)[0];return n&&r.addEventListener("contextmenu",n),r.addEventListener("click",i),r};var Ge=new class extends ke{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=b.getBDData("bdfavemotes");""!==e&&null!==e&&(this.favoriteEmotes=JSON.parse(window.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(),We.emotesLoaded&&this.updateTwitchEmotes(),w.on("emotes-loaded",this.updateTwitchEmotes)}disabled(){w.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=d.getTextArea();d.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"),i=$("#bda-qem-emojis");switch(s.removeClass("active"),n.removeClass("active"),i.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":i.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 We.getCategory("TwitchGlobal")){if(!We.getCategory("TwitchGlobal").hasOwnProperty(e))continue;const t=We.getCategory("TwitchGlobal")[e],s=He(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=He(e,t,{onClick:this.insertEmote.bind(this,e),onContextMenu:this.favContext.bind(this)});this.faContainerInner.append(s)}b.setBDData("bdfavemotes",window.btoa(JSON.stringify(this.favoriteEmotes)))}},Je=new class extends ke{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&&d.insertText(d.getTextArea()[0],e.replace(t,s))}})}disabled(){$("body").off(".bdac")}capitalize(e){const t=We.getCategory("TwitchGlobal");for(const s in t)if(t.hasOwnProperty(s)&&e==(s+"").toLowerCase())return s}};const Ye=s(0),Ze=s(2);var Ke=new class extends ke{get name(){return"WindowPrefs"}get category(){return"window"}get id(){return"transparency"}get WindowConfigFile(){if(this._windowConfigFile)return this._windowConfigFile;const e=s(1).remote.app,t=e.getAppPath(),n=e.getPath("userData"),i=Ze.resolve(n,e.getVersion(),"modules","discord_desktop_core","injector","config.json"),r=Ze.resolve(t,"..","app","config.json"),o=Ye.existsSync(r)?r:Ye.existsSync(i)?i:null;return this._windowConfigFile=o||null}enabled(){this.setWindowPreference("transparent",!0),this.setWindowPreference("backgroundColor",null)}disabled(){this.setWindowPreference("transparent",!1),this.setWindowPreference("backgroundColor","#2f3136")}getAllWindowPreferences(){return this.WindowConfigFile?require(this.WindowConfigFile):{}}getWindowPreference(e){if(this.WindowConfigFile)return this.getAllWindowPreferences()[e]}setWindowPreference(e,t){if(!this.WindowConfigFile)return;const n=this.getAllWindowPreferences();n[e]=t,delete s.c[this.WindowConfigFile],Ye.writeFileSync(this.WindowConfigFile,JSON.stringify(n,null,4))}};class Xe extends z.Component{constructor(e){super(e),this.onClick=this.onClick.bind(this),this.state={checked:this.props.checked||!1}}render(){return z.createElement("div",{className:"checkbox-item"},z.createElement("div",{className:"checkbox-label label-JWQiNe da-label"},this.props.text),z.createElement("div",{className:"checkbox-wrapper checkbox-3kaeSU da-checkbox checkbox-3EVISJ da-checkbox",onClick:this.onClick},z.createElement("div",{className:"checkbox-inner checkboxInner-3yjcPe da-checkboxInner"},z.createElement("input",{className:"checkbox checkboxElement-1qV33p da-checkboxElement",checked:this.state.checked,type:"checkbox"}),z.createElement("span",null)),z.createElement("span",null)))}onClick(){this.props.onChange(!this.state.checked),this.setState({checked:!this.state.checked})}}function Qe(){return(Qe=Object.assign||function(e){for(var t=1;t<arguments.length;t++){var s=arguments[t];for(var n in s)Object.prototype.hasOwnProperty.call(s,n)&&(e[n]=s[n])}return e}).apply(this,arguments)}const et=p.getByDisplayName("Tooltip"),tt=["abap","abc","actionscript","ada","apache_conf","asciidoc","assembly_x86","autohotkey","batchfile","bro","c_cpp","c9search","cirru","clojure","cobol","coffee","coldfusion","csharp","csound_document","csound_orchestra","csound_score","css","curly","d","dart","diff","dockerfile","dot","drools","dummy","dummysyntax","eiffel","ejs","elixir","elm","erlang","forth","fortran","ftl","gcode","gherkin","gitignore","glsl","gobstones","golang","graphqlschema","groovy","haml","handlebars","haskell","haskell_cabal","haxe","hjson","html","html_elixir","html_ruby","ini","io","jack","jade","java","javascript","json","jsoniq","jsp","jssm","jsx","julia","kotlin","latex","less","liquid","lisp","livescript","logiql","lsl","lua","luapage","lucene","makefile","markdown","mask","matlab","maze","mel","mushcode","mysql","nix","nsis","objectivec","ocaml","pascal","perl","pgsql","php","pig","powershell","praat","prolog","properties","protobuf","python","r","razor","rdoc","red","rhtml","rst","ruby","rust","sass","scad","scala","scheme","scss","sh","sjs","smarty","snippets","soy_template","space","sql","sqlserver","stylus","svg","swift","tcl","tex","text","textile","toml","tsx","twig","typescript","vala","vbscript","velocity","verilog","vhdl","wollok","xml","xquery","yaml","django"],st=["chrome","clouds","crimson_editor","dawn","dreamweaver","eclipse","github","iplastic","solarized_light","textmate","tomorrow","xcode","kuroir","katzenmilch","sqlserver","ambiance","chaos","clouds_midnight","cobalt","gruvbox","gob","idle_fingers","kr_theme","merbivore","merbivore_soft","mono_industrial","monokai","pastel_on_dark","solarized_dark","terminal","tomorrow_night","tomorrow_night_blue","tomorrow_night_bright","tomorrow_night_eighties","twilight","vibrant_ink"];class nt extends z.Component{static get defaultId(){return"bd-editor"}constructor(e){super(e);for(const e of this.props.controls)"checkbox"!=e.type&&"showSettings"==e.onClick&&(e.onClick=this.showSettings.bind(this));this.props.theme=this.props.theme.toLowerCase().replace(/ /g,"_"),st.includes(this.props.theme)||(this.props.theme=nt.defaultProps.theme),this.props.language=this.props.language.toLowerCase().replace(/ /g,"_"),tt.includes(this.props.language)||(this.props.language=nt.defaultProps.language),this.onChange=this.onChange.bind(this)}static get defaultProps(){return{controls:[],theme:"bd-monokai",language:"css",id:this.defaultId,fontSize:14}}static get themes(){return st}componentDidMount(){this.editor=ace.edit(this.props.id);const e=this.editor.keyBinding.$defaultHandler.commands.showSettingsMenu.exec;this.editor.keyBinding.$defaultHandler.commands.showSettingsMenu.exec=function(){e.apply(this,arguments);const t=new MutationObserver(e=>{for(const s of e){if(!(s.addedNodes.length&&s.addedNodes[0]instanceof Element))continue;const e=s.addedNodes[0];e.parentElement===document.body&&e.querySelector("#ace_settingsmenu")&&(e.id="ace_settingsmenu_container",t.disconnect())}});t.observe(document.body,{childList:!0})};const t=this.props.theme==nt.defaultProps.theme?this.props.theme.split("-")[1]:this.props.theme;this.editor.setTheme(`ace/theme/${t}`),this.editor.session.setMode(`ace/mode/${this.props.language}`),this.editor.setShowPrintMargin(!1),this.editor.setFontSize(this.props.fontSize),this.editor.on("change",this.onChange)}componentWillUnmount(){this.editor.destroy()}get value(){return this.editor.session.getValue()}set value(e){this.editor.setValue(e)}onChange(){this.props.onChange&&this.props.onChange(this.value)}showSettings(){return this.editor.keyBinding.$defaultHandler.commands.showSettingsMenu.exec(this.editor)}resize(){return this.editor.resize()}buildControl(e){return"checkbox"==e.type?this.makeCheckbox(e):this.makeButton(e)}makeCheckbox(e){return z.createElement(Xe,{text:e.label,onChange:e.onChange,checked:e.checked})}makeButton(e){return z.createElement(et,{color:"black",position:"top",text:e.tooltip},t=>z.createElement("button",Qe({},t,{className:"btn btn-primary",onClick:t=>{e.onClick(t,this.value)}}),e.label))}render(){this.editor&&this.editor.resize&&this.editor.resize();const e=this.props.controls.filter(e=>"right"!=e.side).map(this.buildControl.bind(this)),t=this.props.controls.filter(e=>"right"==e.side).map(this.buildControl.bind(this));return z.createElement("div",{id:"bd-editor-panel",className:this.props.theme},z.createElement("div",{id:"bd-editor-controls"},z.createElement("div",{className:"controls-section controls-left"},e),z.createElement("div",{className:"controls-section controls-right"},t)),z.createElement("div",{className:"editor-wrapper"},z.createElement("div",{id:this.props.id,className:"editor "+this.props.theme},this.props.value)))}}class it extends z.Component{render(){const e=this.props.size||"24px";return z.createElement("svg",{viewBox:"0 0 24 24",style:{width:e,height:e}},z.createElement("path",{fill:"none",d:"M0 0h24v24H0V0z"}),z.createElement("path",{d:"M17 3H5c-1.11 0-2 .9-2 2v14c0 1.1.89 2 2 2h14c1.1 0 2-.9 2-2V7l-4-4zm2 16H5V5h11.17L19 7.83V19zm-7-7c-1.66 0-3 1.34-3 3s1.34 3 3 3 3-1.34 3-3-1.34-3-3-3zM6 6h9v4H6z"}))}}class rt extends z.Component{render(){const e=this.props.size||"24px";return z.createElement("svg",{viewBox:"0 0 24 24",style:{width:e,height:e}},z.createElement("path",{d:"M3 17.25V21h3.75L17.81 9.94l-3.75-3.75L3 17.25zM20.71 7.04c.39-.39.39-1.02 0-1.41l-2.34-2.34c-.39-.39-1.02-.39-1.41 0l-1.83 1.83 3.75 3.75 1.83-1.83z"}),z.createElement("path",{d:"M0 0h24v24H0z",fill:"none"}))}}class ot extends z.Component{render(){const e=this.props.size||"20px";return z.createElement("svg",{viewBox:"0 0 20 20",style:{width:e,height:e}},z.createElement("path",{fill:"none",d:"M0 0h20v20H0V0z"}),z.createElement("path",{d:"M15.95 10.78c.03-.25.05-.51.05-.78s-.02-.53-.06-.78l1.69-1.32c.15-.12.19-.34.1-.51l-1.6-2.77c-.1-.18-.31-.24-.49-.18l-1.99.8c-.42-.32-.86-.58-1.35-.78L12 2.34c-.03-.2-.2-.34-.4-.34H8.4c-.2 0-.36.14-.39.34l-.3 2.12c-.49.2-.94.47-1.35.78l-1.99-.8c-.18-.07-.39 0-.49.18l-1.6 2.77c-.1.18-.06.39.1.51l1.69 1.32c-.04.25-.07.52-.07.78s.02.53.06.78L2.37 12.1c-.15.12-.19.34-.1.51l1.6 2.77c.1.18.31.24.49.18l1.99-.8c.42.32.86.58 1.35.78l.3 2.12c.04.2.2.34.4.34h3.2c.2 0 .37-.14.39-.34l.3-2.12c.49-.2.94-.47 1.35-.78l1.99.8c.18.07.39 0 .49-.18l1.6-2.77c.1-.18.06-.39-.1-.51l-1.67-1.32zM10 13c-1.65 0-3-1.35-3-3s1.35-3 3-3 3 1.35 3 3-1.35 3-3 3z"}))}}class at extends z.Component{render(){const e=this.props.size||"24px";return z.createElement("svg",{viewBox:"0 0 24 24",style:{width:e,height:e}},z.createElement("path",{d:"M0 0h24v24H0z",fill:"none"}),z.createElement("path",{d:"M19 19H5V5h7V3H5c-1.11 0-2 .9-2 2v14c0 1.1.89 2 2 2h14c1.1 0 2-.9 2-2v-7h-2v7zM14 3v2h3.59l-9.83 9.83 1.41 1.41L19 6.41V10h2V3h-7z"}))}}class lt extends z.Component{constructor(e){super(e),this.hasUnsavedChanges=!1,this.onChange=this.onChange.bind(this),this.toggleLiveUpdate=this.toggleLiveUpdate.bind(this),this.updateCss=this.updateCss.bind(this),this.saveCss=this.saveCss.bind(this),this.openDetached=this.props.openDetached?this.openDetached.bind(this):null,this.openNative=this.openNative.bind(this),this.updateEditor=this.updateEditor.bind(this),this.controls=[{label:z.createElement(q,{size:"18px"}),tooltip:"Update",onClick:this.updateCss},{label:z.createElement(it,{size:"18px"}),tooltip:"Save",onClick:this.saveCss},{label:z.createElement(rt,{size:"18px"}),tooltip:"Open in System Editor",onClick:this.openNative},{label:z.createElement(ot,{size:"18px"}),tooltip:"Editor Settings",onClick:"showSettings"},{label:"Live Update",type:"checkbox",onChange:this.toggleLiveUpdate,checked:C.get("settings","customcss","liveUpdate"),side:"right"}],this.openDetached&&this.controls.push({label:z.createElement(at,{size:"18px"}),tooltip:"Detach Editor",onClick:this.openDetached,side:"right"})}componentDidMount(){w.on("customcss-updated",this.updateEditor)}componentWillUnmount(){w.off("customcss-updated",this.updateEditor)}updateEditor(e){this.editor&&(this.editor.value=e)}get value(){return this.editor.session.getValue()}set value(e){this.editor.setValue(e)}showSettings(){return this.editor.keyBinding.$defaultHandler.commands.showSettingsMenu.exec(this.editor)}resize(){return this.editor.resize()}setEditorRef(e){this.editor=e,this.props.editorRef&&void 0!==this.props.editorRef.current?this.props.editorRef.current=e:this.props.editorRef&&(this.props.editorRef=e)}onChange(){this.hasUnsavedChanges=!0,this.props.onChange&&this.props.onChange(...arguments)}render(){return z.createElement(nt,{ref:this.setEditorRef.bind(this),readOnly:this.props.readOnly,id:this.props.id||"bd-customcss-editor",onChange:this.onChange,controls:this.controls,value:this.props.css})}toggleLiveUpdate(e){C.set("settings","customcss","liveUpdate",e)}updateCss(e,t){this.props.update&&this.props.update(t)}saveCss(e,t){this.hasUnsavedChanges=!1,this.props.save&&this.props.save(t)}openDetached(e,t){this.props.openDetached&&this.props.openDetached(t)}openNative(){this.props.openNative&&this.props.openNative()}}class ct{static get width(){return Math.max(document.documentElement.clientWidth,window.innerWidth||0)}static get height(){return Math.max(document.documentElement.clientHeight,window.innerHeight||0)}}class dt extends z.Component{constructor(e){super(e),this.state={modalOpen:!1},this.offX=0,this.offY=0,this.titlebar=z.createRef(),this.window=z.createRef(),this.close=this.close.bind(this),this.onDrag=this.onDrag.bind(this),this.onDragStart=this.onDragStart.bind(this),this.onDragStop=this.onDragStop.bind(this),this.onResizeStart=this.onResizeStart.bind(this)}componentDidMount(){this.window.current.addEventListener("mousedown",this.onResizeStart,!1),this.titlebar.current.addEventListener("mousedown",this.onDragStart,!1),document.addEventListener("mouseup",this.onDragStop,!1)}onResizeStart(){this.currentWidth=this.window.current.style.width,this.currentHeight=this.window.current.style.height}onDragStop(){if(document.removeEventListener("mousemove",this.onDrag,!0),this.props.onResize){const e=this.window.current.style.width,t=this.window.current.style.height;e==this.currentWidth&&t==this.currentHeight||this.props.onResize(),this.currentWidth=e,this.currentHeight=t}}onDragStart(e){const t=this.window.current;this.offY=e.clientY-parseInt(t.offsetTop),this.offX=e.clientX-parseInt(t.offsetLeft),document.addEventListener("mousemove",this.onDrag,!0)}onDrag(e){const t=this.window.current;t.style.position="fixed",t.style.top=e.clientY-this.offY+"px",t.style.left=e.clientX-this.offX+"px"}componentWillUnmount(){this.titlebar.current.removeEventListener("mousedown",this.onDragStart,!1),document.removeEventListener("mouseup",this.onDragStop,!1)}render(){const e=this.props.center?ct.height/2-this.props.height/2:this.props.top,t=this.props.center?ct.width/2-this.props.width/2:this.props.left,s=`floating-window${` ${this.props.className}`||""}${this.props.resizable?" resizable":""}${this.state.modalOpen?" modal-open":""}`,n={height:this.props.height,width:this.props.width,left:t||0,top:e||0};return z.createElement("div",{id:this.props.id,className:s,ref:this.window,style:n},z.createElement("div",{className:"floating-window-titlebar",ref:this.titlebar},z.createElement("span",{className:"title"},this.props.title),z.createElement("div",{className:"floating-window-buttons"},z.createElement("div",{className:"button close-button",onClick:this.close},z.createElement(U,null)))),z.createElement("div",{className:"floating-window-content"},this.props.children))}async close(){let e=!0;("function"==typeof this.props.confirmClose?this.props.confirmClose():this.props.confirmClose)&&(this.setState({modalOpen:!0}),e=await this.confirmClose(),this.setState({modalOpen:!1})),this.props.close&&e&&this.props.close()}confirmClose(){return new Promise(e=>{Ce.showConfirmationModal("Are You Sure?",this.props.confirmationText,{danger:!0,confirmText:"Close",onConfirm:()=>{e(!0)},onCancel:()=>{e(!1)}})})}}function ht(){return(ht=Object.assign||function(e){for(var t=1;t<arguments.length;t++){var s=arguments[t];for(var n in s)Object.prototype.hasOwnProperty.call(s,n)&&(e[n]=s[n])}return e}).apply(this,arguments)}const ut=z.createRef(),pt=z.createElement(class extends z.Component{constructor(e){super(e),this.state={windows:[]}}render(){return this.state.windows.map(e=>z.createElement(dt,ht({},e,{close:this.close.bind(this,e.id)}),e.children))}open(e){this.setState({windows:[...this.state.windows,e]})}close(e){this.setState({windows:this.state.windows.filter(t=>(t.id==e&&t.onClose&&t.onClose(),t.id!=e))})}static get id(){return"floating-windows"}static get root(){if(this._root)return this._root;const e=document.createElement("div");return e.id=this.id,document.body.append(e),this._root=e}},{ref:ut}),mt=d.findInReactTree(d.getReactInstance(document.querySelector(".app-19_DXt")),e=>e&&e.type&&e.type.displayName&&"App"==e.type.displayName);A.after("FloatingContainer",mt.type.prototype,"render",(e,t,s)=>{d.findInRenderTree(s,e=>e&&e[5]&&e[5].type&&"LayerContainer"==e[5].type.displayName,{walkable:["children","props"]}).push(pt)}),mt.stateNode.forceUpdate();var gt=ut.current;const ft=s(0),bt=s(1),yt=p.getByProps("updateAccount"),vt=p.getByProps("dirtyDispatch"),wt=p.getByProps("ActionTypes").ActionTypes;var Ct=new class extends ke{get name(){return"Custom CSS"}get category(){return"customcss"}get id(){return"customcss"}get startDetached(){return C.get(this.collection,this.category,"startDetached")}get nativeOpen(){return C.get(this.collection,this.category,"nativeOpen")}constructor(){super(),this.savedCss="",this.insertedCss="",this.isDetached=!1}async enabled(){window.ace||y.injectScript("ace-script","https://cdnjs.cloudflare.com/ajax/libs/ace/1.2.9/ace.js").then(()=>{window.require.original&&(window.require=window.require.original)}),C.registerPanel(this.id,this.name,{order:2,element:()=>[z.createElement(_,{text:"Custom CSS Editor"}),z.createElement(lt,{css:this.savedCss,save:this.saveCSS.bind(this),update:this.insertCSS.bind(this),openNative:this.openNative.bind(this),openDetached:this.openDetached.bind(this),onChange:this.onChange.bind(this)})],onClick:e=>{this.isDetached||(this.nativeOpen?this.openNative():this.startDetached?this.openDetached():e._reactInternalFiber.child.memoizedProps.children.props.onSetSection(this.name),this.setSection=e._reactInternalFiber.child.memoizedProps.children.props.onSetSection)}}),this.loadCSS(),this.insertCSS(this.savedCss),this.watchContent()}disabled(){C.removePanel(this.id),this.unwatchContent()}watchContent(){if(this.watcher)return this.error("Already watching content.");const e={};this.log("Starting to watch content."),this.watcher=ft.watch(b.customCSS,{persistent:!1},async(t,s)=>{if(!t||!s)return;await new Promise(e=>setTimeout(e,50));try{ft.statSync(b.customCSS)}catch(t){if("ENOENT"!==t.code)return;delete e[s],this.saveCSS("")}const n=ft.statSync(b.customCSS);if(n&&n.mtime&&n.mtime.getTime()&&"number"==typeof n.mtime.getTime()&&e[s]!=n.mtime.getTime()&&(e[s]=n.mtime.getTime(),"change"==t)){const e=b.loadCustomCSS();if(e==this.savedCss)return;this.savedCss=e,this.insertCSS(this.savedCss),w.emit("customcss-updated",this.savedCss)}})}unwatchContent(){if(!this.watcher)return this.error("Was not watching content.");this.watcher.close(),delete this.watcher,this.log("No longer watching content.")}onChange(e){C.get("settings","customcss","liveUpdate")&&(this.insertCSS(e),this.saveCSS(e))}loadCSS(){this.savedCss=b.loadCustomCSS()}insertCSS(e){void 0===e?e=this.insertedCss:this.insertedCss=e,y.updateCustomCSS(e)}saveCSS(e){void 0!==e&&(this.savedCss=e),b.saveCustomCSS(this.savedCss)}openNative(){bt.shell.openExternal(`file://${b.customCSS}`)}openDetached(e){const t=z.createRef(),s=z.createElement(lt,{id:"bd-floating-editor",ref:t,css:e,save:this.saveCSS.bind(this),update:this.insertCSS.bind(this),openNative:this.openNative.bind(this),onChange:this.onChange.bind(this)});gt.open({onClose:()=>{this.isDetached=!1},onResize:()=>{t&&t.current&&t.current.resize&&t.current.resize()},title:"Custom CSS Editor",id:"floating-editor-window",height:470,width:410,center:!0,resizable:!0,children:s,confirmClose:()=>!(!t||!t.current)&&t.current.hasUnsavedChanges,confirmationText:"You have unsaved changes to your Custom CSS. Closing this window will lose all those changes."}),this.isDetached=!0,yt.close(),vt.dirtyDispatch({type:wt.LAYER_POP})}};function St(){}St.prototype.setConfig=function(e){Object.assign(i,e)},St.prototype.init=async function(){if(i.version<i.minSupportedVersion)return void Ce.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&&Ce.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"),C.initialize(),c.log("Startup","Initializing EmoteModule"),y.initialize(),await this.checkForGuilds(),xe.initialize(),c.log("Startup","Updating Settings");for(const e in n)n[e].initialize();c.log("Startup","Loading Plugins");const t=L.loadAllPlugins();c.log("Startup","Loading Themes");const s=O.loadAllThemes();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"),Ce.showContentErrors({plugins:t,themes:s})},St.prototype.checkForGuilds=function(){return new Promise(e=>{const t=function(){"complete"!=document.readyState&&setTimeout(t,100);const s=xe.guildClasses.wrapper.split(" ")[0],n=xe.guildClasses.listItem.split(" ")[0],r=xe.guildClasses.blobContainer.split(" ")[0];if(document.querySelectorAll(`.${s} .${n} .${r}`).length>0)return e(i.deferLoaded=!0);setTimeout(t,100)};t()})},St.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 Et=new St;s.d(t,"default",function(){return xt});const Pt=document.createElement("div");Pt.className="bd-loaderv2",Pt.title="BandagedBD is loading...",document.body.appendChild(Pt),window.BdApi=Ee,window.pluginModule=L,window.themeModule=O,window.bdEmotes=We.Emotes,window.bemotes=We.blacklist,window.bdPluginStorage=class{static get(e,t){return d.warn("Deprecation Notice",`${e}, please use BdApi.loadData() or BdApi.getData(). bdPluginStorage may be removed in future versions.`),b.getPluginData(e,t)||null}static set(e,t,s){if(d.warn("Deprecation Notice",`${e}, please use BdApi.saveData() or BdApi.setData(). bdPluginStorage may be removed in future versions.`),void 0===s)return d.warn("Deprecation Notice","Trying to set undefined value in plugin "+e);b.setPluginData(e,t,s)}static delete(e,t){d.warn("Deprecation Notice",`${e}, please use BdApi.deleteData(). bdPluginStorage may be removed in future versions.`),b.deletePluginData(e,t)}},window.settingsModule=C,window.DataStore=b,window.DomManager=y,window.utils=d,window.BDEvents=w,window.bdConfig=i;class xt{constructor(e){Et.setConfig(e)}init(){Et.init()}}!function(){const e=s(3),t=e._load;e._load=function(e){return"betterdiscord"!==e&&!e.startsWith("betterdiscord/")||"api"!=e.substr("betterdiscord/".length)?t.apply(this,arguments):Ee}}()}]).default;