(function() { /* axios v0.25.0 | (c) 2022 by Matt Zabriskie */ /* axios v0.24.0 | (c) 2022 by Matt Zabriskie */ !function(e,t){"object"==typeof exports&&"object"==typeof module?module.exports=t():"function"==typeof define&&define.amd?define([],t):"object"==typeof exports?exports.axios=t():e.axios=t()}(this,(function(){return function(e){var t={};function n(r){if(t[r])return t[r].exports;var o=t[r]={i:r,l:!1,exports:{}};return e[r].call(o.exports,o,o.exports,n),o.l=!0,o.exports}return n.m=e,n.c=t,n.d=function(e,t,r){n.o(e,t)||Object.defineProperty(e,t,{enumerable:!0,get:r})},n.r=function(e){"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(e,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(e,"__esModule",{value:!0})},n.t=function(e,t){if(1&t&&(e=n(e)),8&t)return e;if(4&t&&"object"==typeof e&&e&&e.__esModule)return e;var r=Object.create(null);if(n.r(r),Object.defineProperty(r,"default",{enumerable:!0,value:e}),2&t&&"string"!=typeof e)for(var o in e)n.d(r,o,function(t){return e[t]}.bind(null,o));return r},n.n=function(e){var t=e&&e.__esModule?function(){return e.default}:function(){return e};return n.d(t,"a",t),t},n.o=function(e,t){return Object.prototype.hasOwnProperty.call(e,t)},n.p="",n(n.s=11)}([function(e,t,n){"use strict";var r=n(3),o=Object.prototype.toString;function i(e){return"[object Array]"===o.call(e)}function s(e){return void 0===e}function a(e){return null!==e&&"object"==typeof e}function u(e){if("[object Object]"!==o.call(e))return!1;var t=Object.getPrototypeOf(e);return null===t||t===Object.prototype}function c(e){return"[object Function]"===o.call(e)}function f(e,t){if(null!=e)if("object"!=typeof e&&(e=[e]),i(e))for(var n=0,r=e.length;n=200&&e<300},headers:{common:{Accept:"application/json, text/plain, */*"}}};r.forEach(["delete","get","head"],(function(e){c.headers[e]={}})),r.forEach(["post","put","patch"],(function(e){c.headers[e]=r.merge(s)})),e.exports=c},function(e,t,n){"use strict";function r(e){this.message=e}r.prototype.toString=function(){return"Cancel"+(this.message?": "+this.message:"")},r.prototype.__CANCEL__=!0,e.exports=r},function(e,t,n){"use strict";e.exports=function(e,t){return function(){for(var n=new Array(arguments.length),r=0;r=0)return;s[t]="set-cookie"===t?(s[t]?s[t]:[]).concat([n]):s[t]?s[t]+", "+n:n}})),s):s}},function(e,t,n){"use strict";var r=n(0);e.exports=r.isStandardBrowserEnv()?function(){var e,t=/(msie|trident)/i.test(navigator.userAgent),n=document.createElement("a");function o(e){var r=e;return t&&(n.setAttribute("href",r),r=n.href),n.setAttribute("href",r),{href:n.href,protocol:n.protocol?n.protocol.replace(/:$/,""):"",host:n.host,search:n.search?n.search.replace(/^\?/,""):"",hash:n.hash?n.hash.replace(/^#/,""):"",hostname:n.hostname,port:n.port,pathname:"/"===n.pathname.charAt(0)?n.pathname:"/"+n.pathname}}return e=o(window.location.href),function(t){var n=r.isString(t)?o(t):t;return n.protocol===e.protocol&&n.host===e.host}}():function(){return!0}},function(e,t,n){"use strict";var r=n(10).version,o={};["object","boolean","number","function","string","symbol"].forEach((function(e,t){o[e]=function(n){return typeof n===e||"a"+(t<1?"n ":" ")+e}}));var i={};o.transitional=function(e,t,n){function o(e,t){return"[Axios v"+r+"] Transitional option '"+e+"'"+t+(n?". "+n:"")}return function(n,r,s){if(!1===e)throw new Error(o(r," has been removed"+(t?" in "+t:"")));return t&&!i[r]&&(i[r]=!0,console.warn(o(r," has been deprecated since v"+t+" and will be removed in the near future"))),!e||e(n,r,s)}},e.exports={assertOptions:function(e,t,n){if("object"!=typeof e)throw new TypeError("options must be an object");for(var r=Object.keys(e),o=r.length;o-- >0;){var i=r[o],s=t[i];if(s){var a=e[i],u=void 0===a||s(a,i,e);if(!0!==u)throw new TypeError("option "+i+" must be "+u)}else if(!0!==n)throw Error("Unknown option "+i)}},validators:o}},function(e,t,n){"use strict";var r=n(2);function o(e){if("function"!=typeof e)throw new TypeError("executor must be a function.");var t;this.promise=new Promise((function(e){t=e}));var n=this;this.promise.then((function(e){if(n._listeners){var t,r=n._listeners.length;for(t=0;t res.data) .catch((error) => console.log(error)); }; async function getCountryBDC(location) { return axios .get(`https://api.bigdatacloud.net/data/reverse-geocode?latitude=${location.lat}&longitude=${location.lng}&key=${BDC_KEY}`) .then((res) => countryCodes[res.data.countryCode]) .catch((error) => error); }; function getSurroundings (location) { const meters = 100; const R_EARTH = 6378.137; const M = 1 / (((2 * Math.PI) / 360) * R_EARTH) / 1000; function moveFrom(coords, angle, distance) { let radianAngle = (angle * Math.PI) / 180; let x = 0 + distance * Math.cos(radianAngle); let y = 0 + distance * Math.sin(radianAngle); let newLat = coords.lat + y * M; let newLng = coords.lng + (x * M) / Math.cos(coords.lat * (Math.PI / 180)); return { lat: newLat, lng: newLng }; } let coordinates = [location]; for (let angle = 0; angle < 360; angle += 45) { coordinates.push(moveFrom({ lat: location.lat, lng: location.lng }, angle, meters)); } return coordinates; }; function isCoordinates (coordinates) { const regex = /^[-+]?([1-8]?\d(\.\d+)?|90(\.0+)?),\s*[-+]?(180(\.0+)?|((1[0-7]\d)|([1-9]?\d))(\.\d+)?)$/g; return regex.test(coordinates); }; function calculateScale(bounds){ return haversineDistance({ lat: bounds.min.lat, lng: bounds.min.lng }, { lat: bounds.max.lat, lng: bounds.max.lng }) / 7.458421; } function haversineDistance(mk1, mk2){ const R = 6371.071; const rlat1 = mk1.lat * (Math.PI / 180); const rlat2 = mk2.lat * (Math.PI / 180); const difflat = rlat2 - rlat1; const difflon = (mk2.lng - mk1.lng) * (Math.PI / 180); const km = 2 * R * Math.asin(Math.sqrt(Math.sin(difflat / 2) * Math.sin(difflat / 2) + Math.cos(rlat1) * Math.cos(rlat2) * Math.sin(difflon / 2) * Math.sin(difflon / 2))); return km; }; function calculateScore(distance, scale){ return Math.round(5000 * Math.pow(0.99866017, (distance * 1000) / scale)); } function normalize(val){ return val.normalize("NFD").replace(/[\u0300-\u036f]/g, ""); } function isMatch(input, key){ return input.length >= 3 && key.includes(input) && input.length <= key.length; } function findCountry(input){ const normalized = GameHelper.normalize(input); return countryCodesNames.find((country) => country.code === normalized || GameHelper.isMatch(normalized, country.names.toLowerCase())); }; var isOpen = $.getSetIniDbBoolean('chatguessr', 'isOpen', false), seed = {}, guesses = { '1':[ {user:'Alpha',location:'0,0',distance:5,score:2,streak:0}, {user:'Beta',location:'5,0',distance:100,score:3,streak:0}, {user:'Charlie',location:'6,6',distance:1000,score:0,streak:0}, {user:'Delta',location:'42,6',distance:1,score:5,streak:1} ], '2':[ ], }; function dbSetSeed(id) { $.inidb.SetBoolean("chatguessr", "isOpen", "", open); isOpen = open; } function dbSetOpen(open) { $.inidb.SetBoolean("chatguessr", "isOpen", "", open); isOpen = open; sendData('status',open); } function dbClearGuesses() { guesses = {}; $.inidb.SetString("chatguessr", "guesses", JSON.stringify(guesses)); sendData('guesses',guesses); } function dbAddGuess(user,position) { if(guesses[user] && guesses[user].length > 0){ }else if(isCoordinates(position)){ guesses[user] = position; $.inidb.SetString("chatguessr", "guesses", JSON.stringify(guesses)); sendData('guesses',JSON.stringify(guesses)); } } function sendData(tpe, data) { $.panelsocketserver.sendJSONToAll(JSON.stringify({ 'eventFamily': 'chatguessr', 'eventType': tpe, 'data': data })); } function isCoordinates(coordinates) { const regex = /^[-+]?([1-8]?\d(\.\d+)?|90(\.0+)?),\s*[-+]?(180(\.0+)?|((1[0-7]\d)|([1-9]?\d))(\.\d+)?)$/g; return regex.test(coordinates); }; $.bind('command', function(event) { const sender = "" + event.getSender().toLowerCase(), command = event.getCommand(), args = event.getArgs(), action = args[0]; if (command.equalsIgnoreCase('g')) { if(isOpen) DBAddG(sender,args); }else if (command.equalsIgnoreCase('cg')) { //send url //$.say($.whisperPrefix(sender) + $.lang.get('chatguessr.help', ' Use "!cg [open | close | ...]" to open/close the feature.')); }else if(command.equalsIgnoreCase('cga')){ if(action.equalsIgnoreCase('open')){ isOpen = true; $.getSetIniDbBoolean('cgstatus', 'isOpen', true); }else if(action.equalsIgnoreCase('close')){ isOpen = false; $.getSetIniDbBoolean('cgstatus', 'isOpen', false) }else if(action.equalsIgnoreCase('start')){ seed = GameHelper.fetchSeed(args[1]); }else if(action.equalsIgnoreCase('end')){ isOpen = false; $.getSetIniDbBoolean('cgstatus', 'isOpen', false) }else if(action.equalsIgnoreCase('refresh')){ let newseed = GameHelper.fetchSeed(args[1]); }else if(action.equalsIgnoreCase('gg')){ sendData('guesses',JSON.stringify(guesses)); } } }); $.bind('initReady', function() { $.registerChatCommand('./custom/custom/chatguessr.js', 'cg',7); $.registerChatCommand('./custom/custom/chatguessr.js', 'g',7); $.registerChatCommand('./custom/custom/chatguessr.js', 'cga'); $.registerChatSubcommand('cga', 'open', 2); $.registerChatSubcommand('cga', 'close', 2); $.registerChatSubcommand('cga', 'start', 2); $.registerChatSubcommand('cga', 'end', 2); $.registerChatSubcommand('cga', 'refresh', 2); }); })();