// ==UserScript==
// @name Agma Chat Command Settings
// @namespace agma-chat-command-settings
// @version 2.2.0
// @description Configure your settings using the chat.
// @author Nuke
// @match *://agma.io/
// @grant none
// ==/UserScript==
!function(){var e={};Object.defineProperty(e,"__esModule",{value:!0}),e.DEFAULT_COMMAND=e.DEFAULT_OPTIONS=e.DEFAULT_INFORMATION=void 0,e.DEFAULT_INFORMATION={name:void 0,version:"1.0.0",description:void 0,author:void 0},e.DEFAULT_OPTIONS={silent:!1,chatElementSelector:void 0,prefix:"/",exposeToWindowObject:!1},e.DEFAULT_COMMAND={disabled:!1,clearChat:!0};var n={};Object.defineProperty(n,"__esModule",{value:!0}),n.error=n.warn=n.log=void 0,n.log=function(e){return console.log("(@agmajs/core)[LOG]: "+e)},n.warn=function(e){return console.warn("(@agmajs/core)[WARN]: "+e)},n.error=function(e){return console.error("(@agmajs/core)[ERROR]: "+e)};var i={};Object.defineProperty(i,"__esModule",{value:!0}),i.isFunction=void 0,i.isFunction=function(e){return"function"==typeof e};var t={};Object.defineProperty(t,"__esModule",{value:!0}),t.ChatContext=t.createChatContext=void 0,t.createChatContext=function(e){return new o(e)};var o=function(){function e(e){this._chatElement=document.querySelector(e)}return e.prototype.value=function(e){if(void 0===e)return this._chatElement.value;this._chatElement.value=e},e.prototype.clear=function(){this.value("")},e}();t.ChatContext=o;var a={},r=this&&this.__assign||function(){return(r=Object.assign||function(e){for(var n,i=1,t=arguments.length;i<t;i++)for(var o in n=arguments[i])Object.prototype.hasOwnProperty.call(n,o)&&(e[o]=n[o]);return e}).apply(this,arguments)},s=this&&this.__createBinding||(Object.create?function(e,n,i,t){void 0===t&&(t=i),Object.defineProperty(e,t,{enumerable:!0,get:function(){return n[i]}})}:function(e,n,i,t){void 0===t&&(t=i),e[t]=n[i]}),d=this&&this.__setModuleDefault||(Object.create?function(e,n){Object.defineProperty(e,"default",{enumerable:!0,value:n})}:function(e,n){e.default=n}),l=this&&this.__importStar||function(e){if(e&&e.__esModule)return e;var n={};if(null!=e)for(var i in e)"default"!==i&&Object.prototype.hasOwnProperty.call(e,i)&&s(n,e,i);return d(n,e),n},c=this&&this.__spreadArray||function(e,n){for(var i=0,t=n.length,o=e.length;i<t;i++,o++)e[o]=n[i];return e};Object.defineProperty(a,"__esModule",{value:!0}),a.Script=a.createScript=void 0;var u=l(n);a.createScript=function(e,n){return new m(e,n)};var m=function(){function n(n,i){this._initialized=!1,this.information=Object.freeze(r(r({},e.DEFAULT_INFORMATION),n)),this.options=r(r({},e.DEFAULT_OPTIONS),i),this.plugins=new Set,this.commands=[],this.init(),this.options.exposeToWindowObject&&(window.$script?u.warn("There already is a script that's also using `@agmajs/script`.\n Cancelling exposing to window object.."):window.$script=this)}return n.prototype.command=function(n,i){if(i)this.commands.includes(i)?this.options.silent||u.warn('Command "'+i.name+'" has already been registered'):(i=r(r(r({},e.DEFAULT_COMMAND),i),{name:n}),this.commands.push(i));else{if(i=this.commands.find((function(e){return e.name==n})))return i;for(var t=0;t<this.commands.length;t++)if((i=this.commands[t]).aliases&&("string"==typeof i.aliases&&n==i.aliases||Array.isArray(i.aliases)&&i.aliases.includes(n)))return i}return this},n.prototype.use=function(e){for(var n=[],t=1;t<arguments.length;t++)n[t-1]=arguments[t];return this.plugins.has(e)?!this.options.silent&&u.warn("Plugin has already been applied."):e&&i.isFunction(e)?(this.plugins.add(e),e.apply(void 0,c([this],n))):this.options.silent||u.error("A plugin must be a function."),this},n.prototype.init=function(){var e=this;if(!this._initialized){var n=this.options,i=n.chatElementSelector,o=n.prefix;if(!i)return;var a=document.querySelector(i);a.onkeydown=function(n){if("Enter"==n.key){var r=a.value;if(!r.startsWith(o))return;var s=r.trim().slice(null==o?void 0:o.length).split(/ +/g),d=s[0],l=s.slice(1),c=e.command(d.toLowerCase());if(c){if(c.disabled)return;var u=t.createChatContext(i);c.clearChat&&u.clear(),c.run(e,u,l)}}},this._initialized=!0}},n}();a.Script=m;var f={};Object.defineProperty(f,"__esModule",{value:!0}),f.defineCommand=void 0,f.defineCommand=function(e){return e};var p={};Object.defineProperty(p,"__esModule",{value:!0});var h={};Object.defineProperty(h,"__esModule",{value:!0});var y={};Object.defineProperty(y,"__esModule",{value:!0}),y.Script=void 0,Object.defineProperty(y,"Script",{enumerable:!0,get:function(){return a.Script}});var w={},v=this&&this.__createBinding||(Object.create?function(e,n,i,t){void 0===t&&(t=i),Object.defineProperty(e,t,{enumerable:!0,get:function(){return n[i]}})}:function(e,n,i,t){void 0===t&&(t=i),e[t]=n[i]}),b=this&&this.__exportStar||function(e,n){for(var i in e)"default"===i||Object.prototype.hasOwnProperty.call(n,i)||v(n,e,i)};Object.defineProperty(w,"__esModule",{value:!0}),w.ChatContext=void 0,Object.defineProperty(w,"ChatContext",{enumerable:!0,get:function(){return t.ChatContext}}),b(p,w),b(h,w),b(y,w);var O={},g=this&&this.__createBinding||(Object.create?function(e,n,i,t){void 0===t&&(t=i),Object.defineProperty(e,t,{enumerable:!0,get:function(){return n[i]}})}:function(e,n,i,t){void 0===t&&(t=i),e[t]=n[i]}),C=this&&this.__exportStar||function(e,n){for(var i in e)"default"===i||Object.prototype.hasOwnProperty.call(n,i)||g(n,e,i)};Object.defineProperty(O,"__esModule",{value:!0}),O.defineCommand=O.createScript=void 0,Object.defineProperty(O,"createScript",{enumerable:!0,get:function(){return a.createScript}}),Object.defineProperty(O,"defineCommand",{enumerable:!0,get:function(){return f.defineCommand}}),C(w,O);var _={};Object.defineProperty(_,"__esModule",{value:!0}),_.Colors=_.DEFAULT_OPTIONS=void 0,_.DEFAULT_OPTIONS={textColor:"#ffffff",visibilityTime:5e3,alertElement:"#curser"},function(e){e.WHITE="#FFFFFF",e.SILVER="#C0C0C0",e.GRAY="#808080",e.GREY="#808080",e.BLACK="#000000",e.RED="#FF0000",e.MAROON="#800000",e.YELLOW="#FFF000",e.OLIVE="#808000",e.LIME="#00FF00",e.GREEN="#008000",e.AQUA="#00FFFF",e.TEAL="#008080",e.BLUE="#0000FF",e.NAVY="#000080",e.FUCHSIA="#FF00FF",e.PURPLE="#800080"}(_.Colors||(_.Colors={}));var N={},S=this&&this.__assign||function(){return(S=Object.assign||function(e){for(var n,i=1,t=arguments.length;i<t;i++)for(var o in n=arguments[i])Object.prototype.hasOwnProperty.call(n,o)&&(e[o]=n[o]);return e}).apply(this,arguments)};Object.defineProperty(N,"__esModule",{value:!0}),N.useAlert=void 0,N.useAlert=function(e,n){n=S(S({},_.DEFAULT_OPTIONS),n);var i=document.querySelector(n.alertElement);n.textColor&&(i.style.color=n.textColor),i.style.fontSize="24px",i.textContent=e,i.style.display="block",setTimeout((function(){i.style.display="none"}),n.visibilityTime)};var A={};Object.defineProperty(A,"__esModule",{value:!0});var F={},P=this&&this.__createBinding||(Object.create?function(e,n,i,t){void 0===t&&(t=i),Object.defineProperty(e,t,{enumerable:!0,get:function(){return n[i]}})}:function(e,n,i,t){void 0===t&&(t=i),e[t]=n[i]}),M=this&&this.__exportStar||function(e,n){for(var i in e)"default"===i||Object.prototype.hasOwnProperty.call(n,i)||P(n,e,i)};Object.defineProperty(F,"__esModule",{value:!0}),M(A,F);var j={},E=this&&this.__createBinding||(Object.create?function(e,n,i,t){void 0===t&&(t=i),Object.defineProperty(e,t,{enumerable:!0,get:function(){return n[i]}})}:function(e,n,i,t){void 0===t&&(t=i),e[t]=n[i]}),k=this&&this.__exportStar||function(e,n){for(var i in e)"default"===i||Object.prototype.hasOwnProperty.call(n,i)||E(n,e,i)};Object.defineProperty(j,"__esModule",{value:!0}),j.Colors=j.useAlert=void 0,Object.defineProperty(j,"useAlert",{enumerable:!0,get:function(){return N.useAlert}}),k(F,j),Object.defineProperty(j,"Colors",{enumerable:!0,get:function(){return _.Colors}});var L={};const T=[{displayName:"Dark Theme",name:"darktheme",function:window.setDark,id:"cDark"},{displayName:"Fancy Grid",name:"fancygrid",function:window.setFancyGrid,id:"cFancyGrid"},{displayName:"Section Grid",name:"sectiongrid",function:window.setSectionGrid,id:"cSectionGrid"},{displayName:"Gridlines",name:["gridline","gridlines"],function:window.setGrid,id:"cGrid"},{displayName:"Skins",name:["skin","skins"],function:window.setSkins,id:"cSkins"},{displayName:"Wearables",name:["wearable","wearables"],function:window.setWearables,id:"cWearables"},{displayName:"Show Names",name:["name","names"],function:window.setNames,id:"cNames"},{displayName:"Minion Names",name:["minionname","minionnames"],function:window.setMinionNames,id:"cMinionNames"},{displayName:"Large Names",name:["largename","largenames"],function:window.setLargeNames,id:"cLargeNames"},{displayName:"Name Outlines",name:["nameoutline","nameoutlines"],function:window.setNameOutlines,id:"cNameOutlines"},{displayName:"Show Mass",name:"mass",function:window.setMass,id:"cMass"},{displayName:"Show Food",name:"food",function:window.setFood,id:"cFood"},{displayName:"Cell Animations",name:["cellanimation","cellanimations"],function:window.setCellAnimations,id:"cCellAnimations"},{displayName:"Skin Animations",name:["skinanimation","skinanimations"],function:window.setSkinAnimations,id:"cSkinAnimations"},{displayName:"Map Border",name:"mapborder",function:window.setMapBorder,id:"cMapBorder"},{displayName:"Sounds",name:["sound","sounds"],function:window.setSounds,id:"cSounds"},{displayName:"Infinite Zoom",name:"infinitezoom",function:window.setZoom,id:"cZoom"},{displayName:"Fixed Zoom",name:"fixedzoom",function:window.setFixedZoom,id:"cFixedZoom"},{displayName:"Slow Motion",name:"slowmotion",function:window.setSlowMotion,id:"cSlowMotion"},{displayName:"Minion Panel",name:"minionpanel",function:window.setMinionUi,id:"cMinionUi"},{displayName:"Leaderboard",name:"leaderboard",function:window.setLeaderboard,id:"cLeaderboard"},{displayName:"Chat",name:"chat",function:window.setChat,id:"cChat"},{displayName:"Minimap",name:"minimap",function:window.setMinimap,id:"cMinimap"},{displayName:"FPS / Ping / Stats",name:["fps","ping","stats"],function:window.setFPS,id:"cFPS"},{displayName:"Cell Colors",name:"colors",function:window.setColors,id:"cColors"},{displayName:"Cell Borders",name:["cellborder","cellborders"],function:window.setCellBorders,id:"cCellBorders"},{displayName:"Cell Spikes",name:["cellspike","cellspikes"],function:window.setCellSpikes,id:"cCellSpikes"},{displayName:"Classic Virus Look",name:"classicvirus",function:window.setClassicViruses,id:"cClassicViruses"},{displayName:"Polygon Shapes",name:["polygonshape","polygonshapes"],function:window.setPolygonShapes,id:"cPolygonShapes"},{displayName:"Line Shapes",name:["lineshape","lineshapes"],function:window.setLineShapes,id:"cLineShapes"},{displayName:"Bubble Cells",name:["bubblecell","bubblecells"],function:window.setBubbleCells,id:"cBubbleCells"}],x=[{displayName:"Online Status",name:"onlinestatus",function:window.setFriendlistOnline,id:"cVisibilityStatus"},{displayName:"Allow Party Invitations",name:"partyinvite",function:window.showPartyInvite,id:"cAllowPartyInvite"},{displayName:"Allow Party Animations",name:["partyanimation","partyanimations"],function:window.setPartyAnimations,id:"cAllowPartyAnimations"},{displayName:"Auto Feed",name:"autofeed",function:window.setAutoFeedEnabled,id:"cAutoFeed"},{displayName:"Gold Nickname",name:["goldnick","goldnickname"],function:window.setGoldNickname,id:"cGoldName"},{displayName:"Gold Crown in Chat",name:"goldcrown",function:window.setGoldCrownChat,id:"cGoldCrownChat"},{displayName:"Set Skins on Minions",name:["minionskin","minionskins"],function:window.setMinionSkins,id:"cMinionSkinStatus"},{displayName:"Video Ads",name:["videoad","videoads"],function:window.setVideoAds,id:"cVideoAds"}];L.availableSettings=[...T,...x];const{defineCommand:I}=O,{useAlert:D,Colors:G}=j,{availableSettings:B}=L;var R=[I({name:"setting",aliases:["s"],run:(e,n,i)=>{if(1==i.length){const e=B.find(e=>!!e&&(Array.isArray(e.name)?e.name.find(e=>e==i[0]):e.name==i[0]));if(!e)return void D(`No setting found with name "${i[0]}"`,{textColor:G.RED});const{displayName:n,id:t}=e,o=document.getElementById(t);D(`The setting "${n}" is turned ${o.checked?"on":"off"}`,{textColor:o.checked?G.LIME:G.RED})}if(2==i.length&&("on"==i[1]||"off"==i[1])){const e="on"===i[1],n=B.find(e=>!!e&&(Array.isArray(e.name)?e.name.find(e=>e==i[0]):e.name==i[0]));if(!n)return void D(`No setting found with name "${i[0]}"`,{textColor:G.RED});const{displayName:t,function:o,id:a}=n,r=document.getElementById(a);o(e),r.checked=e,D(`The setting "${t}" has been turned ${e?"on":"off"}`,{textColor:e?G.LIME:G.RED})}}})];const{createScript:U}=O,{name:V,version:W,description:$,author:z}={name:"agma-chat-command-settings",version:"2.2.0",description:"Configure your settings using the chat.",author:"CodingWithNuke"},Z=U({name:V,version:W,description:$,author:z},{chatElementSelector:"#chtbox",silent:!0});R.forEach(e=>Z.command(e.name,e))}();