From 4c23c27129805df17087084d3d001f2083c387e1 Mon Sep 17 00:00:00 2001 From: "Dr. Cleve" <76855369+David-Orangemoon@users.noreply.github.com> Date: Thu, 25 Sep 2025 22:09:23 -0400 Subject: [PATCH 01/16] Update --- extensions/obviousAlexC/newgroundsIO.js | 9127 +---------------------- 1 file changed, 104 insertions(+), 9023 deletions(-) diff --git a/extensions/obviousAlexC/newgroundsIO.js b/extensions/obviousAlexC/newgroundsIO.js index e47fe527e7..f646dd26d8 100644 --- a/extensions/obviousAlexC/newgroundsIO.js +++ b/extensions/obviousAlexC/newgroundsIO.js @@ -38,8992 +38,10 @@ //Newgrounds.io JS library taken from https://github.com/PsychoGoldfishNG/NewgroundsIO-JS/blob/main/dist/NewgroundsIO.js the official Github for Newgrounds.io - /* ====================== ./NewgroundsIO-JS/src/NGIO.js ====================== */ - - /** Start Class NGIO **/ - - /** - * NGIO singleton wrapper for NewgroundsIO Library. - */ - class NGIO { - /* ================================ Constants ================================= */ - - // preloading statuses - - /** - * @type {string} - */ - static get STATUS_INITIALIZED() { - return "initialized"; - } - - /** - * @type {string} - */ - static get STATUS_CHECKING_LOCAL_VERSION() { - return "checking-local-version"; - } - - /** - * @type {string} - */ - static get STATUS_LOCAL_VERSION_CHECKED() { - return "local-version-checked"; - } - - /** - * @type {string} - */ - static get STATUS_PRELOADING_ITEMS() { - return "preloading-items"; - } - - /** - * @type {string} - */ - static get STATUS_ITEMS_PRELOADED() { - return "items-preloaded"; - } - - /** - * @type {string} - */ - static get STATUS_READY() { - return "ready"; - } - - // aliases from SessionState - - /** - * @type {string} - */ - static get STATUS_SESSION_UNINITIALIZED() { - return NewgroundsIO.SessionState.SESSION_UNINITIALIZED; - } - - /** - * @type {string} - */ - static get STATUS_WAITING_FOR_SERVER() { - return NewgroundsIO.SessionState.WAITING_FOR_SERVER; - } - - /** - * @type {string} - */ - static get STATUS_LOGIN_REQUIRED() { - return NewgroundsIO.SessionState.LOGIN_REQUIRED; - } - - /** - * @type {string} - */ - static get STATUS_WAITING_FOR_USER() { - return NewgroundsIO.SessionState.WAITING_FOR_USER; - } - - /** - * @type {string} - */ - static get STATUS_LOGIN_CANCELLED() { - return NewgroundsIO.SessionState.LOGIN_CANCELLED; - } - - /** - * @type {string} - */ - static get STATUS_LOGIN_SUCCESSFUL() { - return NewgroundsIO.SessionState.LOGIN_SUCCESSFUL; - } - - /** - * @type {string} - */ - static get STATUS_LOGIN_FAILED() { - return NewgroundsIO.SessionState.LOGIN_FAILED; - } - - /** - * @type {string} - */ - static get STATUS_USER_LOGGED_OUT() { - return NewgroundsIO.SessionState.USER_LOGGED_OUT; - } - - /** - * @type {string} - */ - static get STATUS_SERVER_UNAVAILABLE() { - return NewgroundsIO.SessionState.SERVER_UNAVAILABLE; - } - - /** - * @type {string} - */ - static get STATUS_EXCEEDED_MAX_ATTEMPTS() { - return NewgroundsIO.SessionState.EXCEEDED_MAX_ATTEMPTS; - } - - /** - * Will be true if the current connection status is one requiring a 'please wait' message - * @type {boolean} - */ - static get isWaitingStatus() { - return ( - NewgroundsIO.SessionState.SESSION_WAITING.indexOf( - this.#lastConnectionStatus - ) >= 0 || - [ - this.STATUS_PRELOADING_ITEMS, - this.LOCAL_VERSION_CHECKED, - this.STATUS_CHECKING_LOCAL_VERSION, - ].indexOf(this.#lastConnectionStatus) >= 0 - ); - } - - // scoreboard periods - - /** - * @type {string} - */ - static get PERIOD_TODAY() { - return "D"; - } - - /** - * @type {string} - */ - static get PERIOD_CURRENT_WEEK() { - return "W"; - } - - /** - * @type {string} - */ - static get PERIOD_CURRENT_MONTH() { - return "M"; - } - - /** - * @type {string} - */ - static get PERIOD_CURRENT_YEAR() { - return "Y"; - } - - /** - * @type {string} - */ - static get PERIOD_ALL_TIME() { - return "A"; - } - - /** - * @type {Array.} - */ - static get PERIODS() { - return [ - NGIO.PERIOD_TODAY, - NGIO.PERIOD_CURRENT_WEEK, - NGIO.PERIOD_CURRENT_MONTH, - NGIO.PERIOD_CURRENT_YEAR, - NGIO.PERIOD_ALL_TIME, - ]; - } - - /* ============================= Public Properties ============================ */ - - /** - * A reference to the NewgroundsIO.Core instance created in Init(). - * @type {NewgroundsIO.Core} - */ - static get ngioCore() { - return this.#ngioCore; - } - static #ngioCore = null; - - /* - * The user's overall Newgrounds medal score - * @type {number} - */ - static get medalScore() { - return this.#medalScore; - } - static #medalScore = -1; - - /** - * An array of preloaded medals - * @type {Array.} - */ - static get medals() { - return this.#medals; - } - static #medals = null; - - /** - * An array of preloaded scoreBoards - * @type {Array.} - */ - static get scoreBoards() { - return this.#scoreBoards; - } - static #scoreBoards = null; - - /** - * An array of preloaded saveSlots - * @type {Array.} - */ - static get saveSlots() { - return this.#saveSlots; - } - static #saveSlots = null; - - /** - * The last time a component or queue was executed - * @type {Date} - */ - static get lastExecution() { - return this.#lastExecution; - } - static #lastExecution = new Date(); - - /** - * Contains the last connection status. Value will be one of the STATUS_XXXXX constants. - * @type {string} - */ - static get lastConnectionStatus() { - return this.#lastConnectionStatus; - } - static #lastConnectionStatus = new Date(); - - /** - * Will be null unless there was an error in our session. - * @type {NewgroundsIO.objects.Error} - */ - static get sessionError() { - return this.#sessionError; - } - static #sessionError = null; - - /** - * Will be set to false if the local copy of the game is being hosted illegally. - * @type {boolean} - */ - static get legalHost() { - return this.#legalHost; - } - static #legalHost = true; - - /** - * Will be set to true if this is an out-of-date copy of the game. - * @type {boolean} - */ - static get isDeprecated() { - return this.#isDeprecated; - } - static #isDeprecated = true; - - /** - * This is the version number(string) of the newest available copy of the game. - * @type {boolean} - */ - static get newestVersion() { - return this.#newestVersion; - } - static #newestVersion = true; - - /** - * Will be true if the user opened the login page via OpenLoginPage(). - * @type {boolean} - */ - static get loginPageOpen() { - return this.#loginPageOpen; - } - static #loginPageOpen = false; - - /** - * The current version of the Newgrounds.io gateway. - * @type {string} - */ - static get gatewayVersion() { - return this.#gatewayVersion; - } - static #gatewayVersion = true; - - /** - * Stores the last medal that was unlocked. - * @type {NewgroundsIO.objects.Medal} - */ - static get lastMedalUnlocked() { - return this.#lastMedalUnlocked; - } - static #lastMedalUnlocked = true; - - /** - * Stores the last scoreboard that was posted to. - * @type {NewgroundsIO.objects.ScoreBoard} - */ - static get lastBoardPosted() { - return this.#lastBoardPosted; - } - static #lastBoardPosted = true; - - /** - * Stores the last score that was posted to. - * @type {NewgroundsIO.objects.Score} - */ - static get lastScorePosted() { - return this.#lastScorePosted; - } - static #lastScorePosted = true; - - /** - * Stores the last scores that were loaded. - * @type {NewgroundsIO.results.ScoreBoard.getScores} - */ - static get lastGetScoresResult() { - return this.#lastGetScoresResult; - } - static #lastGetScoresResult = true; - - /** - * Stores the last saveSlot that had data loaded. - * @type {NewgroundsIO.objects.SaveSlot} - */ - static get lastSaveSlotLoaded() { - return this.#lastSaveSlotLoaded; - } - static #lastSaveSlotLoaded = true; - - /** - * Stores the last saveSlot that had data saved. - * @type {NewgroundsIO.objects.SaveSlot} - */ - static get lastSaveSlotSaved() { - return this.#lastSaveSlotSaved; - } - static #lastSaveSlotSaved = true; - - /** - * Stores the last DateTime that was loaded from the API. - * @type {string} - */ - static get lastDateTime() { - return this.#lastDateTime; - } - static #lastDateTime = "0000-00-00"; - - /** - * Stores the last event that was logged. - * @type {string} - */ - static get lastLoggedEvent() { - return this.#lastLoggedEvent; - } - static #lastLoggedEvent = null; - - /** - * Stores the last unix timestamp that was loaded API. - * @type {number} - */ - static get lastTimeStamp() { - return this.#lastTimeStamp; - } - static #lastTimeStamp = 0; - - /** - * Stores wether the last server ping succeeded. - * @type {boolean} - */ - static get lastPingSuccess() { - return this.#lastPingSuccess; - } - static #lastPingSuccess = true; - - /** - * Will be true if we've called Init(). - * @type {boolean} - */ - static get isInitialized() { - return this.ngioCore !== null; - } - - /** - * Contains all information about the current user session. - * @type {NewgroundsIO.objects.Session} - */ - static get session() { - return this.isInitialized ? this.ngioCore.session : null; - } - - /** - * Contains user information if the user is logged in. Otherwise null. - * @type {NewgroundsIO.objects.User} - */ - static get user() { - return this.session === null ? null : this.ngioCore.session.user; - } - - /** - * Returns true if we currently have a valid session ID. - * @type {boolean} - */ - static get hasSession() { - return this.session !== null; - } - - /** - * Returns true if we currently have a valid session ID. - * @type {boolean} - */ - static get hasUser() { - return this.user !== null; - } - - /** - * Will be true if we've finished logging in and preloading data. - * @type {boolean} - */ - static get isReady() { - return this.#lastConnectionStatus === this.STATUS_READY; - } - - /** - * The version number passed in Init()'s options - * @type {string} - */ - static get version() { - return this.#version; - } - static #version = "0.0.0"; - - /** - * Will be tue if using debugMode via Init() - * @type {boolean} - */ - static get debugMode() { - return this.#debugMode; - } - static #debugMode = false; - - /* ============================= Private Properties ============================ */ - - // Preloading flags - static #preloadFlags = { - autoLogNewView: false, - preloadMedals: false, - preloadScoreBoards: false, - preloadSaveSlots: false, - }; - - // Connection states - static #sessionReady = false; - static #skipLogin = false; - static #localVersionChecked = false; - static #checkingConnectionStatus = false; - - /* ============================= Misc Public Methods ============================ */ - - /** - * Initializes the NGIO wrapper. You must call this BEFORE using any other methods! - * @param {string} appID The App ID from your Newgrounds Project's "API Tools" page. - * @param {string} aesKey The AES-128 encryption key from your Newgrounds Project's "API Tools" page. - * @param {object} [options] An object of options to set up the API wrapper. - * @param {string} [options.version] A string in "X.X.X" format indicating the current version of this game. - * @param {boolean} [options.checkHostLicense] Set to true to check if the site hosting your game has been blocked. - * @param {boolean} [options.preloadMedals] Set to true to preload medals (will show if the player has any unlocked, and get their current medal score). - * @param {boolean} [options.preloadeScoreBoards] Set to true to preload Score Board information. - * @param {boolean} [options.preloadeSaveSlots] Set to true to preload Save Slot information. - * @param {boolean} [options.autoLogNewView] Set to true to automatcally log a new view to your stats. - * @param {boolean} [options.debugMode] Set to true to run in debug mode. - */ - static init(appID, aesKey, options) { - if (!this.isInitialized) { - this.#ngioCore = new NewgroundsIO.Core(appID, aesKey); - - this.#ngioCore.addEventListener("serverResponse", function (e) { - NGIO.#onServerResponse(e); - }); - - if (options && typeof options === "object") { - if (typeof options["version"] === "string") - this.#version = options["version"]; - - let preloadFlags = [ - "debugMode", - "checkHostLicense", - "autoLogNewView", - "preloadMedals", - "preloadScoreBoards", - "preloadSaveSlots", - ]; - - for (let i = 0; i < preloadFlags.length; i++) { - if (typeof options[preloadFlags[i]] !== "undefined") - this.#preloadFlags[preloadFlags[i]] = options[preloadFlags[i]] - ? true - : false; - } - } - - this.#ngioCore.debug = this.debugMode; - - this.#lastConnectionStatus = this.STATUS_INITIALIZED; - - // auto-ping the server every 30 seconds once connected - setTimeout(function () { - NGIO.keepSessionAlive(); - }, 30000); - } - } - - /* ======================== Public Login/Session Methods ======================== */ - - /** - * Call this if you want to skip logging the user in. - */ - static skipLogin() { - if (!this.#sessionReady) this.#skipLogin = true; - } - - /** - * Opens the Newgrounds login page in a new browser tab. - */ - static openLoginPage() { - if (!this.#loginPageOpen) { - this.#skipLogin = false; - this.#sessionReady = false; - this.#loginPageOpen = true; - this.session.openLoginPage(); - } else { - console.warn("loginPageOpen is true. Use CancelLogin to reset."); - } - } - - /** - * If the user opened the NG login page, you can call this to cancel the login attempt. - */ - static cancelLogin() { - if (!this.session) { - console.error("NGIO Error - Can't cancel non-existent session"); - return; - } - - this.session.cancelLogin(NewgroundsIO.SessionState.SESSION_UNINITIALIZED); - this.#resetConnectionStatus(); - this.skipLogin(); - } - - /** - * Logs the current use out of the game (locally and on the server) and resets the connection status. - */ - static logOut() { - if (!this.session) { - console.error("NGIO Error - Can't cancel non-existent session"); - return; - } - this.session.logOut(function () { - this.#resetConnectionStatus(); - this.skipLogin(); - }, this); - } - - /* ============================ Public Loader Methods =========================== */ - - /** - * Loads "Your Website URL", as defined on your App Settings page, in a new browser tab. - */ - static loadAuthorUrl() { - this.ngioCore.loadComponent( - this.ngioCore.getComponent("Loader.loadAuthorUrl") - ); - } - - /** - * Loads our "Official Version URL", as defined on your App Settings page, in a new browser tab. - */ - static loadOfficialUrl() { - this.ngioCore.loadComponent( - this.ngioCore.getComponent("Loader.loadOfficialUrl") - ); - } - - /** - * Loads the Games page on Newgrounds in a new browser tab. - */ - static loadMoreGames() { - this.ngioCore.loadComponent( - this.ngioCore.getComponent("Loader.loadMoreGames") - ); - } - - /** - * Loads the Newgrounds frontpage in a new browser tab. - */ - static loadNewgrounds() { - this.ngioCore.loadComponent( - this.ngioCore.getComponent("Loader.loadNewgrounds") - ); - } - - /** - * Loads the Newgrounds frontpage in a new browser tab. - * @param {string} referralName The name of your custom referral. - */ - static loadReferral(referralName) { - this.ngioCore.loadComponent( - this.ngioCore.getComponent("Loader.loadReferral", { - referral_name: referralName, - }) - ); - } - - /* ============================ Public Medal Methods ============================ */ - - /** - * Gets a preloaded Medal object. - * @param {number} medalID The ID of the medal - */ - static getMedal(medalID) { - if (this.medals === null) { - console.error( - "NGIO Error: Can't use getMedal without setting preloadMedals option to true" - ); - return null; - } - for (let i = 0; i < this.medals.length; i++) { - if (this.medals[i].id === medalID) return this.medals[i]; - } - } - - /** - * @callback unlockMedalCallback - * @param {NewgroundsIO.objects.Medal} medal - */ - - /** - * Attempts to unlock a medal and returns the medal to an optional callback function when complete. - * @param {number} medalID The id of the medal you are unlocking. - * @param {unlockMedalCallback} [callback] A function to run when the medal has unlocked. - * @param {object} [thisArg] An optional object to use as 'this' in your callback function. - */ - static unlockMedal(medalID, callback, thisArg) { - if (this.medals == null) { - console.error("unlockMedal called without any preloaded medals."); - if (typeof callback === "function") - thisArg ? callback.call(thisArg, null) : callback(null); - return; - } - - let medal = this.getMedal(medalID); - - if (medal == null) { - console.error("Medal #" + medalID + " does not exist."); - if (typeof callback === "function") - thisArg ? callback.call(thisArg, null) : callback(null); - return; - } - - medal.unlock(function () { - if (typeof callback === "function") - thisArg - ? callback.call(thisArg, this.lastMedalUnlocked) - : callback(this.lastMedalUnlocked); - }, this); - } - - /* ======================== Public getScoreBoard Methods ======================== */ - - /** - * Gets a preloaded ScoreBoard object. - * @param {number} scoreBoardID The ID of the score board - */ - static getScoreBoard(scoreBoardID) { - if (this.scoreBoards === null) { - console.error( - "NGIO Error: Can't use getScoreBoard without setting preloadScoreBoards option to true" - ); - return null; - } - for (let i = 0; i < this.scoreBoards.length; i++) { - if (this.scoreBoards[i].id === scoreBoardID) return this.scoreBoards[i]; - } - } - - /** - * @callback postScoreCallback - * @param {NewgroundsIO.objects.ScoreBoard} scoreBoard - * @param {NewgroundsIO.objects.Score} score - */ - - /** - * Posts a score and returns the score and scoreboard to an optional callback function when complete. - * @param {number} boardID The id of the scoreboard you are posting to. - * @param {number} value The integer value of your score. - * @param {string} [tag] An optional tag to attach to the score (use null for no tag). - * @param {postScoreCallback} [callback] A function to run when the score has posted. - * @param {object} [thisArg] An optional object to use as 'this' in your callback function. - */ - static postScore(boardID, value, tag, callback, thisArg) { - // if not using a tag, 3rd and 4th params can be callback and thisArg - if (typeof tag === "function") { - thisArg = callback; - callback = tag; - tag = ""; - } else if (typeof tag === "undefined") { - tag = ""; - } - - if (this.scoreBoards == null) { - console.error( - "NGIO Error - postScore called without any preloaded scoreboards." - ); - if (typeof callback === "function") - thisArg ? callback.call(thisArg, null, null) : callback(null, null); - return; - } - var board = this.getScoreBoard(boardID); - if (board == null) { - console.error( - "NGIO Error - ScoreBoard #" + boardID + " does not exist." - ); - if (typeof callback === "function") - thisArg ? callback.call(thisArg, null, null) : callback(null, null); - return; - } - - board.postScore( - value, - tag, - function () { - if (typeof callback === "function") - thisArg - ? callback.call( - thisArg, - this.lastBoardPosted, - this.lastScorePosted - ) - : callback(this.lastBoardPosted, this.lastScorePosted); - }, - this - ); - } - - /** - * @callback getScoresCallback - * @param {NewgroundsIO.objects.ScoreBoard} scoreBoard - * @param {NewgroundsIO.objects.Score} score - * @param {object} options - * @param {string} options.period - * @param {string} options.tag - * @param {boolean} options.social - * @param {Number} options.skip - * @param {Number} options.limit - */ - - /** - * Gets the best scores for a board and returns the board, score list, period, tag and social bool to an optional callback. - * @param {number} boardID The id of the scoreboard you loading from. - * @param {object} [options] Any optional lookup options you want to use. - * @param {string} [options.period=NGIO.PERIOD_TODAY] The time period to get scores from. Will match one of the PERIOD_XXXX constants. - * @param {boolean} [options.social=false] Set to true to only get scores from the user's friends. - * @param {Number} [options.skip=0] The number of scores to skip. - * @param {Number} [options.limit=10] The total number of scores to load. - * @param {string} [options.tag] An optional tag to filter results by (use null for no tag). - * @param {getScoresCallback} [callback] A function to run when the scores have been loaded. - * @param {object} [thisArg] An optional object to use as 'this' in your callback function. - */ - static getScores(boardID, options, callback, thisArg) { - let _options = { - period: - typeof options["period"] === "undefined" - ? NGIO.PERIOD_TODAY - : options["period"], - tag: typeof options["tag"] !== "string" ? "" : options["tag"], - social: - typeof options["social"] === "undefined" - ? false - : options["social"] - ? true - : false, - skip: typeof options["skip"] !== "number" ? 0 : options["skip"], - limit: typeof options["limit"] !== "number" ? 10 : options["limit"], - }; - - if (this.scoreBoards == null) { - console.error( - "NGIO Error - getScores called without any preloaded scoreboards." - ); - if (typeof callback === "function") - thisArg - ? callback.call(thisArg, null, null, _options) - : callback(null, null, _options); - return; - } - - var board = this.getScoreBoard(boardID); - - if (board == null) { - console.error( - "NGIO Error - ScoreBoard #" + boardID + " does not exist." - ); - if (typeof callback === "function") - thisArg - ? callback.call(thisArg, null, null, _options) - : callback(null, null, _options); - return; - } - - board.getScores( - _options, - function () { - if (typeof callback === "function") - thisArg - ? callback.call( - thisArg, - board, - this.lastGetScoresResult.scores, - _options - ) - : callback(board, this.lastGetScoresResult.scores, _options); - }, - this - ); - } - - /* ======================== Public getSaveSlot Methods ======================== */ - - /** - * Gets a preloaded SaveSlot object. (Use getSaveSlotData to get actual save file) - * @param {number} saveSlotID The desired slot number - */ - static getSaveSlot(saveSlotID) { - if (this.saveSlots === null) { - console.error( - "NGIO Error: Can't use getSaveSlot without setting preloadSaveSlots option to true" - ); - return null; - } - for (let i = 0; i < this.saveSlots.length; i++) { - if (this.saveSlots[i].id === saveSlotID) return this.saveSlots[i]; - } - } - - /** - * Gets the number of non-empty save slots. - */ - static getTotalSaveSlots() { - let total = 0; - this.saveSlots.forEach((slot) => { - if (slot.hasData) total++; - }); - return total; - } - - /** - * @callback getSaveSlotDataCallback - * @param {string} data - */ - - /** - * Loads the actual save file from a save slot, and passes the string result to a callback function. - * @param {number} slotID The slot number to load from - * @param {getSaveSlotDataCallback} [callback] A function to run when the file has been loaded - * @param {object} [thisArg] An optional object to use as 'this' in your callback function. - */ - static getSaveSlotData(slotID, callback, thisArg) { - if (this.saveSlots === null) { - console.error( - "getSaveSlotData data called without any preloaded save slots." - ); - thisArg ? callback.call(thisArg, null) : callback(null); - } - - let slot = this.getSaveSlot(slotID); - this.#lastSaveSlotLoaded = slot; - slot.getData(callback, thisArg); - } - - /** - * @callback setSaveSlotDataCallback - * @param {NewgroundsIO.objects.SaveSlot} saveSlot - */ - - /** - * Loads the actual save file from a save slot and returns the save slot to an optional callback function when complete. - * @param {number} slotID The slot number to save to. - * @param {string} data The (serialized) data you want to save. - * @param {setSaveSlotDataCallback} [callback] An optional function to run when the file finished saving. - * @param {object} [thisArg] An optional object to use as 'this' in your callback function. - */ - static setSaveSlotData(slotID, data, callback, thisArg) { - if (this.saveSlots == null) { - console.error( - "setSaveSlotData data called without any preloaded save slots." - ); - if (typeof callback === "function") - thisArg ? callback(thisArg, null) : callback(null); - return; - } - - var slot = this.getSaveSlot(slotID); - if (slot == null) { - console.error("Slot #" + slotID + " does not exist."); - if (typeof callback === "function") - thisArg ? callback(thisArg, null) : callback(null); - return; - } - - slot.setData( - data, - function () { - if (typeof callback === "function") - thisArg - ? callback(thisArg, this.lastSaveSlotSaved) - : callback(this.lastSaveSlotSaved); - }, - this - ); - } - - /* =========================== Public Event Methods ========================== */ - - /** - * @callback logEventCallback - * @param {string} eventName - */ - - /** - * Logs a custom event and returns the eventName to an optional callback function when complete. - * @param {string} eventName The name of the event to log. - * @param {logEventCallback} [callback] A function to run when the event has logged. - * @param {object} [thisArg] An optional object to use as 'this' in your callback function. - */ - static logEvent(eventName, callback, thisArg) { - this.ngioCore.executeComponent( - this.ngioCore.getComponent("Event.logEvent", { event_name: eventName }), - function () { - if (typeof callback === "function") - thisArg - ? callback(thisArg, this.lastLoggedEvent) - : callback(this.lastLoggedEvent); - }, - this - ); - } - - /* ========================== Public Gateway Methods ========================= */ - - /** - * @callback getDateTimeCallback - * @param {string} dateime - * @param {number} timestamp - */ - - /** - * Loads the current DateTime from the server and returns it to an optional callback function. - * @param {getDateTimeCallback} [callback] A function to run when the datetime has loaded. - * @param {object} [thisArg] An optional object to use as 'this' in your callback function. - */ - static getDateTime(callback, thisArg) { - this.ngioCore.executeComponent( - this.ngioCore.getComponent("Gateway.getDatetime"), - function () { - if (typeof callback === "function") - thisArg - ? callback(thisArg, this.lastDateTime, this.lastTimeStamp) - : callback(this.lastDateTime, this.lastTimeStamp); - }, - this - ); - } - - /* ========================= Public KeepAlive Methods ========================= */ - - /** - * Keeps your ssessions from expiring. Is called automatically. - * This will only hit the server once every 30 seconds, no matter how often you call it. - */ - static keepSessionAlive() { - if (!this.hasUser) return; - - let elapsed = new Date() - this.#lastExecution; - if (elapsed.Seconds >= 30000) { - this.#lastExecution = new Date(); - this.ngioCore.executeComponent( - this.ngioCore.getComponent("Gateway.ping") - ); - } - } - - /* ======================= Public Login/Preload Methods ====================== */ - - /** - * @callback getConnectionStatusCallback - * @param {string} connectionStatus - */ - - /** - * Intended to be called from your game loop, this does an entire process of things based on your Init() options: - * * Checks if the hosting site has a legal copy of this game - * * Checks for a newer version of the game - * * Makes sure you have a user session - * * Checks if the current user is logged in - * * Preloads Medals, Saveslots, etc - * * Logs a new view to your stats - * - * Whenever a new operation begins or ends, the current state will be passed to your callback function. - * @param {getConnectionStatusCallback} [callback] A function to be called when there's a change of status. Will match one of the STATUS_XXXX constants. - * @param {object} [thisArg] An optional object to use as 'this' in your callback function. - */ - static getConnectionStatus(callback, thisArg) { - let _this = this; - if ( - this.#checkingConnectionStatus || - this.#lastConnectionStatus === null || - this.session == null - ) - return; - this.#checkingConnectionStatus = true; - - if (this.#lastConnectionStatus === this.STATUS_INITIALIZED) { - this.#lastConnectionStatus = this.STATUS_CHECKING_LOCAL_VERSION; - this.#reportConnectionStatus(callback, thisArg); - - this.#checkLocalVersion(callback, thisArg); - } else if (!this.#sessionReady) { - if (this.#skipLogin) { - this.#updateSessionHandler(callback, thisArg); - } else if ( - this.#lastConnectionStatus !== this.STATUS_CHECKING_LOCAL_VERSION - ) { - this.session.update(function () { - this.#updateSessionHandler(callback, thisArg); - }, this); - } - } else if (this.#lastConnectionStatus === this.STATUS_LOGIN_SUCCESSFUL) { - this.#lastConnectionStatus = this.STATUS_PRELOADING_ITEMS; - this.#reportConnectionStatus(callback, thisArg); - - this.#PreloadItems(function () { - this.#reportConnectionStatus(callback, thisArg); - this.#skipLogin = false; - }, this); - } else if (this.#lastConnectionStatus === this.STATUS_ITEMS_PRELOADED) { - this.#loginPageOpen = false; - this.#lastConnectionStatus = this.STATUS_READY; - this.#reportConnectionStatus(callback, thisArg); - - this.#skipLogin = false; - } else { - this.keepSessionAlive(); - } - - this.#checkingConnectionStatus = false; - } - - /* ===================== Private Login/Preloader Methods ==================== */ - - static #updateSessionHandler(callback, thisArg) { - if (this.session.statusChanged || this.#skipLogin) { - this.#lastConnectionStatus = this.session.status; - - if ( - this.session.status == NewgroundsIO.SessionState.LOGIN_SUCCESSFUL || - this.#skipLogin - ) { - this.#lastConnectionStatus = - NewgroundsIO.SessionState.LOGIN_SUCCESSFUL; - this.#sessionReady = true; - } - - this.#reportConnectionStatus(callback, thisArg); - } - - this.#skipLogin = false; - } - - static #reportConnectionStatus(callback, thisArg) { - thisArg - ? callback.call(thisArg, this.#lastConnectionStatus) - : callback(this.#lastConnectionStatus); - } - - // Loads the latest version info, and will get the host license and log a view if those Init() options are enabled. - static #checkLocalVersion(callback, thisArg) { - // if a login fails, this may get called again. Catch it and avoid an extra lookup! - if (this.#localVersionChecked) { - this.#lastConnectionStatus = this.STATUS_LOCAL_VERSION_CHECKED; - this.#reportConnectionStatus(callback, thisArg); - return; - } - - this.ngioCore.queueComponent( - this.ngioCore.getComponent("App.getCurrentVersion", { - version: this.#version, - }) - ); - this.ngioCore.queueComponent( - this.ngioCore.getComponent("Gateway.getVersion") - ); - - if (this.#preloadFlags.autoLogNewView) { - this.ngioCore.queueComponent(this.ngioCore.getComponent("App.logView")); - } - if (this.#preloadFlags.checkHostLicense) { - this.ngioCore.queueComponent( - this.ngioCore.getComponent("App.getHostLicense") - ); - } - - this.ngioCore.executeQueue(function () { - this.#lastConnectionStatus = this.STATUS_LOCAL_VERSION_CHECKED; - this.#localVersionChecked = true; - this.#reportConnectionStatus(callback, thisArg); - - if (this.#isDeprecated) { - console.warn( - "NGIO - Version mistmatch! Published version is: " + - this.#newestVersion + - ", this version is: " + - this.version - ); - } - if (!this.#legalHost) { - console.warn( - "NGIO - This host has been blocked fom hosting this game!" - ); - this.#sessionReady = true; - this.#lastConnectionStatus = this.STATUS_ITEMS_PRELOADED; - this.#reportConnectionStatus(callback, thisArg); - } - }, this); - } - - // Preloads any items that were set in the Init() options. - static #PreloadItems() { - if (this.#preloadFlags.preloadMedals) { - this.ngioCore.queueComponent( - this.ngioCore.getComponent("Medal.getMedalScore") - ); - this.ngioCore.queueComponent( - this.ngioCore.getComponent("Medal.getList") - ); - } - if (this.#preloadFlags.preloadScoreBoards) { - this.ngioCore.queueComponent( - this.ngioCore.getComponent("ScoreBoard.getBoards") - ); - } - if (this.user !== null && this.#preloadFlags.preloadSaveSlots) - this.ngioCore.queueComponent( - this.ngioCore.getComponent("CloudSave.loadSlots") - ); - - if (this.ngioCore.hasQueue) { - this.ngioCore.executeQueue(function () { - this.#lastConnectionStatus = this.STATUS_ITEMS_PRELOADED; - }, this); - } else { - this.#lastConnectionStatus = this.STATUS_ITEMS_PRELOADED; - } - } - - /* =============================== Private Methods ============================== */ - - // Resets the connection state, typically after a user logs out or cancels a login. - static #resetConnectionStatus() { - this.#lastConnectionStatus = this.STATUS_INITIALIZED; - this.#loginPageOpen = false; - this.#skipLogin = false; - this.#sessionReady = false; - } - - static #replaceSaveSlot(slot) { - if (this.#saveSlots) { - let replace = this.#saveSlots.length; - for (let i = 0; i < this.#saveSlots.length; i++) { - if (this.#saveSlots[i].id === slot.id) { - replace = i; - break; - } - } - this.#saveSlots[replace] = slot.clone( - replace < this.#saveSlots.length ? this.#saveSlots[replace] : null - ); - } - } - - static #replaceScoreBoard(board) { - if (this.#scoreBoards) { - let replace = this.#scoreBoards.length; - for (let i = 0; i < this.#scoreBoards.length; i++) { - if (this.#scoreBoards[i].id === board.id) { - replace = i; - break; - } - } - this.#scoreBoards[replace] = board.clone( - replace < this.#scoreBoards.length ? this.#scoreBoards[replace] : null - ); - } - } - - static #replaceMedal(medal) { - if (this.#medals) { - let replace = this.#medals.length; - for (let i = 0; i < this.#medals.length; i++) { - if (this.#medals[i].id === medal.id) { - replace = i; - break; - } - } - this.#medals[replace] = medal.clone( - replace < this.#medals.length ? this.#medals[replace] : null - ); - } - } - - // Runs anytime the core gets a server response. Grabs individual result objects and runs them through #handleNewComponentResult(). - static #onServerResponse(e) { - let response = e.detail; - - if (response && response.success) { - // make a note of our last update time - this.#lastExecution = new Date(); - - if (Array.isArray(response.result)) { - for (let i = 0; i < response.result.length; i++) { - if (response.result[i]) - this.#handleNewComponentResult(response.result[i]); - } - } else { - if (response.result) this.#handleNewComponentResult(response.result); - } - } - } - - // Checks component results from every server response to see if they need any further handling. - static #handleNewComponentResult(result) { - // show any errors, but ignore the one about null sessions, that's bound to happen anytime the game is played outside of Newgrounds - if ( - !result.success && - result.error.code !== 104 && - result.error.code !== 110 - ) { - console.error( - result.error.message + " \ncode(" + result.error.code + ")" - ); - } - - switch (result.__object) { - /* ============================== App Info ============================== */ - - case "App.getCurrentVersion": - if (!result.success) return; - - // Save the latest version and note if this copy of the game is deprecated - this.#newestVersion = result.current_version; - this.#isDeprecated = result.client_deprecated; - - break; - - case "App.getHostLicense": - if (!result.success) return; - // Make a note of whether this game is being hosted legally or not - this.#legalHost = result.host_approved; - - break; - - case "App.endSession": - // reset the connection state if the user logged out - this.#resetConnectionStatus(); - - break; - - case "App.checkSession": - // if something fails with a session check, reset the connection status - if (!result.success) { - this.#resetConnectionStatus(); - } - - case "App.startSession": - // if something fails with a session check, reset the connection status - if (!result.success) { - this.#resetConnectionStatus(); - break; - } - - result.session.clone(this.session); - break; - - /* ============================ Cloud Saves ============================= */ - - case "CloudSave.loadSlots": - if (!result.success) return; - - // Store the loaded cloud saves in our dictionary so we can get them by slot number - this.#saveSlots = result.slots; - - break; - - case "CloudSave.loadSlot": - if (!result.success) return; - - // add or replace the slot - this.#replaceSaveSlot(result.slot); - - break; - - case "CloudSave.setData": - if (!result.success) { - this.#lastSaveSlotSaved = null; - return; - } - - // add or replace the slot - this.#replaceSaveSlot(result.slot); - - break; - - case "CloudSave.clearSlot": - if (!result.success) return; - - // add or replace the slot - this.#replaceSaveSlot(result.slot); - - break; - - /* ============================== Events ================================ */ - - case "Event.logEvent": - if (!result.success) { - this.#lastLoggedEvent = null; - return; - } - - this.#lastLoggedEvent = result.event_name; - - break; - - /* ============================== Gateway ================================ */ - - case "Gateway.getDatetime": - if (!result.success) { - this.#lastTimeStamp = 0; - this.#lastDateTime = "0000-00-00"; - return; - } - - this.#lastDateTime = result.datetime; - this.#lastTimeStamp = result.timestamp; - - break; - - case "Gateway.getVersion": - if (!result.success) { - this.#gatewayVersion = null; - return; - } - - this.#gatewayVersion = result.version; - - break; - - case "Gateway.ping": - this.#lastPingSuccess = result.success; - - break; - - /* ============================== Medals ================================ */ - - case "Medal.getList": - if (!result.success) return; - - // Store the loaded medals. - this.#medals = []; - for (let i = 0; i < result.medals.length; i++) { - this.#medals.push(result.medals[i].clone()); - } - - break; - - case "Medal.unlock": - if (!result.success) { - this.#lastMedalUnlocked = null; - return; - } - - if (this.#medals) { - // Save, or replace, the medal - this.#replaceMedal(result.medal); - - // record the last unlock - this.#lastMedalUnlocked = this.getMedal(result.medal.id); - } - - // Record the current user's medal score - this.#medalScore = result.medal_score; - window.top.postMessage( - JSON.stringify({ - ngioComponent: "Medal.unlock", - id: result.medal.id, - }), - "*" - ); - - break; - - case "Medal.getMedalScore": - if (!result.success) return; - - // Record the current user's medal score - this.#medalScore = result.medal_score; - - break; - - /* ============================= ScoreBoards ============================ */ - - case "ScoreBoard.getBoards": - if (!result.success) return; - - // store the loaded scoreboards - this.#scoreBoards = []; - for (let i = 0; i < result.scoreboards.length; i++) { - this.#scoreBoards.push(result.scoreboards[i].clone()); - } - - break; - - case "ScoreBoard.postScore": - if (!result.success) { - this.#lastScorePosted = null; - this.#lastBoardPosted = null; - return; - } - - if (this.#scoreBoards) { - this.#lastScorePosted = result.score; - this.#lastBoardPosted = this.getScoreBoard(result.scoreboard.id); - } - - window.top.postMessage( - JSON.stringify({ - ngioComponent: "ScoreBoard.postScore", - id: result.scoreboard.id, - }), - "*" - ); - - break; - - case "ScoreBoard.getScores": - if (!result.success) { - this.#lastGetScoresResult = null; - return; - } - this.#lastGetScoresResult = result; - - break; - } - } - } - /** End Class NGIO **/ - - /* ====================== ./NewgroundsIO-JS/src/include/aes.js ====================== */ - - /* - CryptoJS v3.1.2 - code.google.com/p/crypto-js - (c) 2009-2013 by Jeff Mott. All rights reserved. - code.google.com/p/crypto-js/wiki/License - */ - var CryptoJS = - CryptoJS || - (function (u, p) { - var d = {}, - l = (d.lib = {}), - s = function () {}, - t = (l.Base = { - extend: function (a) { - s.prototype = this; - var c = new s(); - a && c.mixIn(a); - c.hasOwnProperty("init") || - (c.init = function () { - c.$super.init.apply(this, arguments); - }); - c.init.prototype = c; - c.$super = this; - return c; - }, - create: function () { - var a = this.extend(); - a.init.apply(a, arguments); - return a; - }, - init: function () {}, - mixIn: function (a) { - for (var c in a) a.hasOwnProperty(c) && (this[c] = a[c]); - a.hasOwnProperty("toString") && (this.toString = a.toString); - }, - clone: function () { - return this.init.prototype.extend(this); - }, - }), - r = (l.WordArray = t.extend({ - init: function (a, c) { - a = this.words = a || []; - this.sigBytes = c != p ? c : 4 * a.length; - }, - toString: function (a) { - return (a || v).stringify(this); - }, - concat: function (a) { - var c = this.words, - e = a.words, - j = this.sigBytes; - a = a.sigBytes; - this.clamp(); - if (j % 4) - for (var k = 0; k < a; k++) - c[(j + k) >>> 2] |= - ((e[k >>> 2] >>> (24 - 8 * (k % 4))) & 255) << - (24 - 8 * ((j + k) % 4)); - else if (65535 < e.length) - for (k = 0; k < a; k += 4) c[(j + k) >>> 2] = e[k >>> 2]; - else c.push.apply(c, e); - this.sigBytes += a; - return this; - }, - clamp: function () { - var a = this.words, - c = this.sigBytes; - a[c >>> 2] &= 4294967295 << (32 - 8 * (c % 4)); - a.length = u.ceil(c / 4); - }, - clone: function () { - var a = t.clone.call(this); - a.words = this.words.slice(0); - return a; - }, - random: function (a) { - for (var c = [], e = 0; e < a; e += 4) - c.push((4294967296 * u.random()) | 0); - return new r.init(c, a); - }, - })), - w = (d.enc = {}), - v = (w.Hex = { - stringify: function (a) { - var c = a.words; - a = a.sigBytes; - for (var e = [], j = 0; j < a; j++) { - var k = (c[j >>> 2] >>> (24 - 8 * (j % 4))) & 255; - e.push((k >>> 4).toString(16)); - e.push((k & 15).toString(16)); - } - return e.join(""); - }, - parse: function (a) { - for (var c = a.length, e = [], j = 0; j < c; j += 2) - e[j >>> 3] |= parseInt(a.substr(j, 2), 16) << (24 - 4 * (j % 8)); - return new r.init(e, c / 2); - }, - }), - b = (w.Latin1 = { - stringify: function (a) { - var c = a.words; - a = a.sigBytes; - for (var e = [], j = 0; j < a; j++) - e.push( - String.fromCharCode((c[j >>> 2] >>> (24 - 8 * (j % 4))) & 255) - ); - return e.join(""); - }, - parse: function (a) { - for (var c = a.length, e = [], j = 0; j < c; j++) - e[j >>> 2] |= (a.charCodeAt(j) & 255) << (24 - 8 * (j % 4)); - return new r.init(e, c); - }, - }), - x = (w.Utf8 = { - stringify: function (a) { - try { - return decodeURIComponent(escape(b.stringify(a))); - } catch (c) { - throw Error("Malformed UTF-8 data"); - } - }, - parse: function (a) { - return b.parse(unescape(encodeURIComponent(a))); - }, - }), - q = (l.BufferedBlockAlgorithm = t.extend({ - reset: function () { - this._data = new r.init(); - this._nDataBytes = 0; - }, - _append: function (a) { - "string" == typeof a && (a = x.parse(a)); - this._data.concat(a); - this._nDataBytes += a.sigBytes; - }, - _process: function (a) { - var c = this._data, - e = c.words, - j = c.sigBytes, - k = this.blockSize, - b = j / (4 * k), - b = a ? u.ceil(b) : u.max((b | 0) - this._minBufferSize, 0); - a = b * k; - j = u.min(4 * a, j); - if (a) { - for (var q = 0; q < a; q += k) this._doProcessBlock(e, q); - q = e.splice(0, a); - c.sigBytes -= j; - } - return new r.init(q, j); - }, - clone: function () { - var a = t.clone.call(this); - a._data = this._data.clone(); - return a; - }, - _minBufferSize: 0, - })); - l.Hasher = q.extend({ - cfg: t.extend(), - init: function (a) { - this.cfg = this.cfg.extend(a); - this.reset(); - }, - reset: function () { - q.reset.call(this); - this._doReset(); - }, - update: function (a) { - this._append(a); - this._process(); - return this; - }, - finalize: function (a) { - a && this._append(a); - return this._doFinalize(); - }, - blockSize: 16, - _createHelper: function (a) { - return function (b, e) { - return new a.init(e).finalize(b); - }; - }, - _createHmacHelper: function (a) { - return function (b, e) { - return new n.HMAC.init(a, e).finalize(b); - }; - }, - }); - var n = (d.algo = {}); - return d; - })(Math); - (function () { - var u = CryptoJS, - p = u.lib.WordArray; - u.enc.Base64 = { - stringify: function (d) { - var l = d.words, - p = d.sigBytes, - t = this._map; - d.clamp(); - d = []; - for (var r = 0; r < p; r += 3) - for ( - var w = - (((l[r >>> 2] >>> (24 - 8 * (r % 4))) & 255) << 16) | - (((l[(r + 1) >>> 2] >>> (24 - 8 * ((r + 1) % 4))) & 255) << 8) | - ((l[(r + 2) >>> 2] >>> (24 - 8 * ((r + 2) % 4))) & 255), - v = 0; - 4 > v && r + 0.75 * v < p; - v++ - ) - d.push(t.charAt((w >>> (6 * (3 - v))) & 63)); - if ((l = t.charAt(64))) for (; d.length % 4; ) d.push(l); - return d.join(""); - }, - parse: function (d) { - var l = d.length, - s = this._map, - t = s.charAt(64); - t && ((t = d.indexOf(t)), -1 != t && (l = t)); - for (var t = [], r = 0, w = 0; w < l; w++) - if (w % 4) { - var v = s.indexOf(d.charAt(w - 1)) << (2 * (w % 4)), - b = s.indexOf(d.charAt(w)) >>> (6 - 2 * (w % 4)); - t[r >>> 2] |= (v | b) << (24 - 8 * (r % 4)); - r++; - } - return p.create(t, r); - }, - _map: "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=", - }; - })(); - (function (u) { - function p(b, n, a, c, e, j, k) { - b = b + ((n & a) | (~n & c)) + e + k; - return ((b << j) | (b >>> (32 - j))) + n; - } - function d(b, n, a, c, e, j, k) { - b = b + ((n & c) | (a & ~c)) + e + k; - return ((b << j) | (b >>> (32 - j))) + n; - } - function l(b, n, a, c, e, j, k) { - b = b + (n ^ a ^ c) + e + k; - return ((b << j) | (b >>> (32 - j))) + n; - } - function s(b, n, a, c, e, j, k) { - b = b + (a ^ (n | ~c)) + e + k; - return ((b << j) | (b >>> (32 - j))) + n; - } - for ( - var t = CryptoJS, - r = t.lib, - w = r.WordArray, - v = r.Hasher, - r = t.algo, - b = [], - x = 0; - 64 > x; - x++ - ) - b[x] = (4294967296 * u.abs(u.sin(x + 1))) | 0; - r = r.MD5 = v.extend({ - _doReset: function () { - this._hash = new w.init([ - 1732584193, 4023233417, 2562383102, 271733878, - ]); - }, - _doProcessBlock: function (q, n) { - for (var a = 0; 16 > a; a++) { - var c = n + a, - e = q[c]; - q[c] = - (((e << 8) | (e >>> 24)) & 16711935) | - (((e << 24) | (e >>> 8)) & 4278255360); - } - var a = this._hash.words, - c = q[n + 0], - e = q[n + 1], - j = q[n + 2], - k = q[n + 3], - z = q[n + 4], - r = q[n + 5], - t = q[n + 6], - w = q[n + 7], - v = q[n + 8], - A = q[n + 9], - B = q[n + 10], - C = q[n + 11], - u = q[n + 12], - D = q[n + 13], - E = q[n + 14], - x = q[n + 15], - f = a[0], - m = a[1], - g = a[2], - h = a[3], - f = p(f, m, g, h, c, 7, b[0]), - h = p(h, f, m, g, e, 12, b[1]), - g = p(g, h, f, m, j, 17, b[2]), - m = p(m, g, h, f, k, 22, b[3]), - f = p(f, m, g, h, z, 7, b[4]), - h = p(h, f, m, g, r, 12, b[5]), - g = p(g, h, f, m, t, 17, b[6]), - m = p(m, g, h, f, w, 22, b[7]), - f = p(f, m, g, h, v, 7, b[8]), - h = p(h, f, m, g, A, 12, b[9]), - g = p(g, h, f, m, B, 17, b[10]), - m = p(m, g, h, f, C, 22, b[11]), - f = p(f, m, g, h, u, 7, b[12]), - h = p(h, f, m, g, D, 12, b[13]), - g = p(g, h, f, m, E, 17, b[14]), - m = p(m, g, h, f, x, 22, b[15]), - f = d(f, m, g, h, e, 5, b[16]), - h = d(h, f, m, g, t, 9, b[17]), - g = d(g, h, f, m, C, 14, b[18]), - m = d(m, g, h, f, c, 20, b[19]), - f = d(f, m, g, h, r, 5, b[20]), - h = d(h, f, m, g, B, 9, b[21]), - g = d(g, h, f, m, x, 14, b[22]), - m = d(m, g, h, f, z, 20, b[23]), - f = d(f, m, g, h, A, 5, b[24]), - h = d(h, f, m, g, E, 9, b[25]), - g = d(g, h, f, m, k, 14, b[26]), - m = d(m, g, h, f, v, 20, b[27]), - f = d(f, m, g, h, D, 5, b[28]), - h = d(h, f, m, g, j, 9, b[29]), - g = d(g, h, f, m, w, 14, b[30]), - m = d(m, g, h, f, u, 20, b[31]), - f = l(f, m, g, h, r, 4, b[32]), - h = l(h, f, m, g, v, 11, b[33]), - g = l(g, h, f, m, C, 16, b[34]), - m = l(m, g, h, f, E, 23, b[35]), - f = l(f, m, g, h, e, 4, b[36]), - h = l(h, f, m, g, z, 11, b[37]), - g = l(g, h, f, m, w, 16, b[38]), - m = l(m, g, h, f, B, 23, b[39]), - f = l(f, m, g, h, D, 4, b[40]), - h = l(h, f, m, g, c, 11, b[41]), - g = l(g, h, f, m, k, 16, b[42]), - m = l(m, g, h, f, t, 23, b[43]), - f = l(f, m, g, h, A, 4, b[44]), - h = l(h, f, m, g, u, 11, b[45]), - g = l(g, h, f, m, x, 16, b[46]), - m = l(m, g, h, f, j, 23, b[47]), - f = s(f, m, g, h, c, 6, b[48]), - h = s(h, f, m, g, w, 10, b[49]), - g = s(g, h, f, m, E, 15, b[50]), - m = s(m, g, h, f, r, 21, b[51]), - f = s(f, m, g, h, u, 6, b[52]), - h = s(h, f, m, g, k, 10, b[53]), - g = s(g, h, f, m, B, 15, b[54]), - m = s(m, g, h, f, e, 21, b[55]), - f = s(f, m, g, h, v, 6, b[56]), - h = s(h, f, m, g, x, 10, b[57]), - g = s(g, h, f, m, t, 15, b[58]), - m = s(m, g, h, f, D, 21, b[59]), - f = s(f, m, g, h, z, 6, b[60]), - h = s(h, f, m, g, C, 10, b[61]), - g = s(g, h, f, m, j, 15, b[62]), - m = s(m, g, h, f, A, 21, b[63]); - a[0] = (a[0] + f) | 0; - a[1] = (a[1] + m) | 0; - a[2] = (a[2] + g) | 0; - a[3] = (a[3] + h) | 0; - }, - _doFinalize: function () { - var b = this._data, - n = b.words, - a = 8 * this._nDataBytes, - c = 8 * b.sigBytes; - n[c >>> 5] |= 128 << (24 - (c % 32)); - var e = u.floor(a / 4294967296); - n[(((c + 64) >>> 9) << 4) + 15] = - (((e << 8) | (e >>> 24)) & 16711935) | - (((e << 24) | (e >>> 8)) & 4278255360); - n[(((c + 64) >>> 9) << 4) + 14] = - (((a << 8) | (a >>> 24)) & 16711935) | - (((a << 24) | (a >>> 8)) & 4278255360); - b.sigBytes = 4 * (n.length + 1); - this._process(); - b = this._hash; - n = b.words; - for (a = 0; 4 > a; a++) - ((c = n[a]), - (n[a] = - (((c << 8) | (c >>> 24)) & 16711935) | - (((c << 24) | (c >>> 8)) & 4278255360))); - return b; - }, - clone: function () { - var b = v.clone.call(this); - b._hash = this._hash.clone(); - return b; - }, - }); - t.MD5 = v._createHelper(r); - t.HmacMD5 = v._createHmacHelper(r); - })(Math); - (function () { - var u = CryptoJS, - p = u.lib, - d = p.Base, - l = p.WordArray, - p = u.algo, - s = (p.EvpKDF = d.extend({ - cfg: d.extend({ keySize: 4, hasher: p.MD5, iterations: 1 }), - init: function (d) { - this.cfg = this.cfg.extend(d); - }, - compute: function (d, r) { - for ( - var p = this.cfg, - s = p.hasher.create(), - b = l.create(), - u = b.words, - q = p.keySize, - p = p.iterations; - u.length < q; - - ) { - n && s.update(n); - var n = s.update(d).finalize(r); - s.reset(); - for (var a = 1; a < p; a++) ((n = s.finalize(n)), s.reset()); - b.concat(n); - } - b.sigBytes = 4 * q; - return b; - }, - })); - u.EvpKDF = function (d, l, p) { - return s.create(p).compute(d, l); - }; - })(); - CryptoJS.lib.Cipher || - (function (u) { - var p = CryptoJS, - d = p.lib, - l = d.Base, - s = d.WordArray, - t = d.BufferedBlockAlgorithm, - r = p.enc.Base64, - w = p.algo.EvpKDF, - v = (d.Cipher = t.extend({ - cfg: l.extend(), - createEncryptor: function (e, a) { - return this.create(this._ENC_XFORM_MODE, e, a); - }, - createDecryptor: function (e, a) { - return this.create(this._DEC_XFORM_MODE, e, a); - }, - init: function (e, a, b) { - this.cfg = this.cfg.extend(b); - this._xformMode = e; - this._key = a; - this.reset(); - }, - reset: function () { - t.reset.call(this); - this._doReset(); - }, - process: function (e) { - this._append(e); - return this._process(); - }, - finalize: function (e) { - e && this._append(e); - return this._doFinalize(); - }, - keySize: 4, - ivSize: 4, - _ENC_XFORM_MODE: 1, - _DEC_XFORM_MODE: 2, - _createHelper: function (e) { - return { - encrypt: function (b, k, d) { - return ("string" == typeof k ? c : a).encrypt(e, b, k, d); - }, - decrypt: function (b, k, d) { - return ("string" == typeof k ? c : a).decrypt(e, b, k, d); - }, - }; - }, - })); - d.StreamCipher = v.extend({ - _doFinalize: function () { - return this._process(!0); - }, - blockSize: 1, - }); - var b = (p.mode = {}), - x = function (e, a, b) { - var c = this._iv; - c ? (this._iv = u) : (c = this._prevBlock); - for (var d = 0; d < b; d++) e[a + d] ^= c[d]; - }, - q = (d.BlockCipherMode = l.extend({ - createEncryptor: function (e, a) { - return this.Encryptor.create(e, a); - }, - createDecryptor: function (e, a) { - return this.Decryptor.create(e, a); - }, - init: function (e, a) { - this._cipher = e; - this._iv = a; - }, - })).extend(); - q.Encryptor = q.extend({ - processBlock: function (e, a) { - var b = this._cipher, - c = b.blockSize; - x.call(this, e, a, c); - b.encryptBlock(e, a); - this._prevBlock = e.slice(a, a + c); - }, - }); - q.Decryptor = q.extend({ - processBlock: function (e, a) { - var b = this._cipher, - c = b.blockSize, - d = e.slice(a, a + c); - b.decryptBlock(e, a); - x.call(this, e, a, c); - this._prevBlock = d; - }, - }); - b = b.CBC = q; - q = (p.pad = {}).Pkcs7 = { - pad: function (a, b) { - for ( - var c = 4 * b, - c = c - (a.sigBytes % c), - d = (c << 24) | (c << 16) | (c << 8) | c, - l = [], - n = 0; - n < c; - n += 4 - ) - l.push(d); - c = s.create(l, c); - a.concat(c); - }, - unpad: function (a) { - a.sigBytes -= a.words[(a.sigBytes - 1) >>> 2] & 255; - }, - }; - d.BlockCipher = v.extend({ - cfg: v.cfg.extend({ mode: b, padding: q }), - reset: function () { - v.reset.call(this); - var a = this.cfg, - b = a.iv, - a = a.mode; - if (this._xformMode == this._ENC_XFORM_MODE) - var c = a.createEncryptor; - else ((c = a.createDecryptor), (this._minBufferSize = 1)); - this._mode = c.call(a, this, b && b.words); - }, - _doProcessBlock: function (a, b) { - this._mode.processBlock(a, b); - }, - _doFinalize: function () { - var a = this.cfg.padding; - if (this._xformMode == this._ENC_XFORM_MODE) { - a.pad(this._data, this.blockSize); - var b = this._process(!0); - } else ((b = this._process(!0)), a.unpad(b)); - return b; - }, - blockSize: 4, - }); - var n = (d.CipherParams = l.extend({ - init: function (a) { - this.mixIn(a); - }, - toString: function (a) { - return (a || this.formatter).stringify(this); - }, - })), - b = ((p.format = {}).OpenSSL = { - stringify: function (a) { - var b = a.ciphertext; - a = a.salt; - return ( - a ? s.create([1398893684, 1701076831]).concat(a).concat(b) : b - ).toString(r); - }, - parse: function (a) { - a = r.parse(a); - var b = a.words; - if (1398893684 == b[0] && 1701076831 == b[1]) { - var c = s.create(b.slice(2, 4)); - b.splice(0, 4); - a.sigBytes -= 16; - } - return n.create({ ciphertext: a, salt: c }); - }, - }), - a = (d.SerializableCipher = l.extend({ - cfg: l.extend({ format: b }), - encrypt: function (a, b, c, d) { - d = this.cfg.extend(d); - var l = a.createEncryptor(c, d); - b = l.finalize(b); - l = l.cfg; - return n.create({ - ciphertext: b, - key: c, - iv: l.iv, - algorithm: a, - mode: l.mode, - padding: l.padding, - blockSize: a.blockSize, - formatter: d.format, - }); - }, - decrypt: function (a, b, c, d) { - d = this.cfg.extend(d); - b = this._parse(b, d.format); - return a.createDecryptor(c, d).finalize(b.ciphertext); - }, - _parse: function (a, b) { - return "string" == typeof a ? b.parse(a, this) : a; - }, - })), - p = ((p.kdf = {}).OpenSSL = { - execute: function (a, b, c, d) { - d || (d = s.random(8)); - a = w.create({ keySize: b + c }).compute(a, d); - c = s.create(a.words.slice(b), 4 * c); - a.sigBytes = 4 * b; - return n.create({ key: a, iv: c, salt: d }); - }, - }), - c = (d.PasswordBasedCipher = a.extend({ - cfg: a.cfg.extend({ kdf: p }), - encrypt: function (b, c, d, l) { - l = this.cfg.extend(l); - d = l.kdf.execute(d, b.keySize, b.ivSize); - l.iv = d.iv; - b = a.encrypt.call(this, b, c, d.key, l); - b.mixIn(d); - return b; - }, - decrypt: function (b, c, d, l) { - l = this.cfg.extend(l); - c = this._parse(c, l.format); - d = l.kdf.execute(d, b.keySize, b.ivSize, c.salt); - l.iv = d.iv; - return a.decrypt.call(this, b, c, d.key, l); - }, - })); - })(); - (function () { - for ( - var u = CryptoJS, - p = u.lib.BlockCipher, - d = u.algo, - l = [], - s = [], - t = [], - r = [], - w = [], - v = [], - b = [], - x = [], - q = [], - n = [], - a = [], - c = 0; - 256 > c; - c++ - ) - a[c] = 128 > c ? c << 1 : (c << 1) ^ 283; - for (var e = 0, j = 0, c = 0; 256 > c; c++) { - var k = j ^ (j << 1) ^ (j << 2) ^ (j << 3) ^ (j << 4), - k = (k >>> 8) ^ (k & 255) ^ 99; - l[e] = k; - s[k] = e; - var z = a[e], - F = a[z], - G = a[F], - y = (257 * a[k]) ^ (16843008 * k); - t[e] = (y << 24) | (y >>> 8); - r[e] = (y << 16) | (y >>> 16); - w[e] = (y << 8) | (y >>> 24); - v[e] = y; - y = (16843009 * G) ^ (65537 * F) ^ (257 * z) ^ (16843008 * e); - b[k] = (y << 24) | (y >>> 8); - x[k] = (y << 16) | (y >>> 16); - q[k] = (y << 8) | (y >>> 24); - n[k] = y; - e ? ((e = z ^ a[a[a[G ^ z]]]), (j ^= a[a[j]])) : (e = j = 1); - } - var H = [0, 1, 2, 4, 8, 16, 32, 64, 128, 27, 54], - d = (d.AES = p.extend({ - _doReset: function () { - for ( - var a = this._key, - c = a.words, - d = a.sigBytes / 4, - a = 4 * ((this._nRounds = d + 6) + 1), - e = (this._keySchedule = []), - j = 0; - j < a; - j++ - ) - if (j < d) e[j] = c[j]; - else { - var k = e[j - 1]; - j % d - ? 6 < d && - 4 == j % d && - (k = - (l[k >>> 24] << 24) | - (l[(k >>> 16) & 255] << 16) | - (l[(k >>> 8) & 255] << 8) | - l[k & 255]) - : ((k = (k << 8) | (k >>> 24)), - (k = - (l[k >>> 24] << 24) | - (l[(k >>> 16) & 255] << 16) | - (l[(k >>> 8) & 255] << 8) | - l[k & 255]), - (k ^= H[(j / d) | 0] << 24)); - e[j] = e[j - d] ^ k; - } - c = this._invKeySchedule = []; - for (d = 0; d < a; d++) - ((j = a - d), - (k = d % 4 ? e[j] : e[j - 4]), - (c[d] = - 4 > d || 4 >= j - ? k - : b[l[k >>> 24]] ^ - x[l[(k >>> 16) & 255]] ^ - q[l[(k >>> 8) & 255]] ^ - n[l[k & 255]])); - }, - encryptBlock: function (a, b) { - this._doCryptBlock(a, b, this._keySchedule, t, r, w, v, l); - }, - decryptBlock: function (a, c) { - var d = a[c + 1]; - a[c + 1] = a[c + 3]; - a[c + 3] = d; - this._doCryptBlock(a, c, this._invKeySchedule, b, x, q, n, s); - d = a[c + 1]; - a[c + 1] = a[c + 3]; - a[c + 3] = d; - }, - _doCryptBlock: function (a, b, c, d, e, j, l, f) { - for ( - var m = this._nRounds, - g = a[b] ^ c[0], - h = a[b + 1] ^ c[1], - k = a[b + 2] ^ c[2], - n = a[b + 3] ^ c[3], - p = 4, - r = 1; - r < m; - r++ - ) - var q = - d[g >>> 24] ^ - e[(h >>> 16) & 255] ^ - j[(k >>> 8) & 255] ^ - l[n & 255] ^ - c[p++], - s = - d[h >>> 24] ^ - e[(k >>> 16) & 255] ^ - j[(n >>> 8) & 255] ^ - l[g & 255] ^ - c[p++], - t = - d[k >>> 24] ^ - e[(n >>> 16) & 255] ^ - j[(g >>> 8) & 255] ^ - l[h & 255] ^ - c[p++], - n = - d[n >>> 24] ^ - e[(g >>> 16) & 255] ^ - j[(h >>> 8) & 255] ^ - l[k & 255] ^ - c[p++], - g = q, - h = s, - k = t; - q = - ((f[g >>> 24] << 24) | - (f[(h >>> 16) & 255] << 16) | - (f[(k >>> 8) & 255] << 8) | - f[n & 255]) ^ - c[p++]; - s = - ((f[h >>> 24] << 24) | - (f[(k >>> 16) & 255] << 16) | - (f[(n >>> 8) & 255] << 8) | - f[g & 255]) ^ - c[p++]; - t = - ((f[k >>> 24] << 24) | - (f[(n >>> 16) & 255] << 16) | - (f[(g >>> 8) & 255] << 8) | - f[h & 255]) ^ - c[p++]; - n = - ((f[n >>> 24] << 24) | - (f[(g >>> 16) & 255] << 16) | - (f[(h >>> 8) & 255] << 8) | - f[k & 255]) ^ - c[p++]; - a[b] = q; - a[b + 1] = s; - a[b + 2] = t; - a[b + 3] = n; - }, - keySize: 8, - })); - u.AES = p._createHelper(d); - })(); - - /* ====================== ./NewgroundsIO-JS/src/NewgroundsIO/Core.js ====================== */ - - /** - * NewgroundsIO Namespace - * @namespace - */ - var NewgroundsIO = NewgroundsIO ? NewgroundsIO : {}; - - /** - * NewgroundsIO Objecs Namespace - * @namespace - */ - NewgroundsIO.objects = NewgroundsIO.objects ? NewgroundsIO.objects : {}; - - /** - * NewgroundsIO Results Namespace - * @namespace - */ - NewgroundsIO.results = NewgroundsIO.results ? NewgroundsIO.results : {}; - - /** - * NewgroundsIO Components Namespace - * @namespace - */ - NewgroundsIO.components = NewgroundsIO.components - ? NewgroundsIO.components - : {}; - - (() => { - /** Start Class NewgroundsIO.Core **/ - - /** - * @callback responseCallback - * @param {NewgroundsIO.objects.Response} serverResponse - */ - - /** Class for communicating with the Newgrounds.io API **/ - class Core extends EventTarget { - /** - * @private - */ - #GATEWAY_URI = "https://www.newgrounds.io/gateway_v3.php"; - - /** - * @private - */ - #debug = false; - - /** - * @private - */ - #appID = null; - - /** - * @private - */ - #aesKey = null; - - /** - * @private - */ - #componentQueue = []; - - /** - * @private - */ - #host = null; - - /** - * @private - */ - #session = null; - - /** - * @private - */ - #uriParams = {}; - - /** - * The URI to v3 of the Newgrounds.io gateway. - * @type {string} - */ - get GATEWAY_URI() { - return this.#GATEWAY_URI; - } - - /** - * Set to true to enable debug mode. - * @type {boolean} - */ - get debug() { - return this.#debug; - } - set debug(d) { - this.#debug = d ? true : false; - } - - /** - * The App ID from your App Settings page. - * @type {string} - */ - get appID() { - return this.#appID; - } - - /** - * An array of pending components to be called via executeQueue. - * @type {array} An array of NewgroundsIO.components.XXXX objects - */ - get componentQueue() { - return this.#componentQueue; - } - - /** - * Returns true if any components are in the execute queue. - * @type {boolean} - */ - get hasQueue() { - return this.#componentQueue.length > 0; - } - - /** - * Returns the host domain in web builds. - * @type {boolean} - */ - get host() { - return this.#host; - } - - /** - * The user session object. - * @type {NewgroundsIO.objects.Session} - */ - get session() { - return this.#session; - } - - /** - * The active user object. - * @type {NewgroundsIO.objects.User} - */ - get user() { - return this.#session ? this.#session.user : null; - } - - /** - * An index of any parameters set in the current URL's query string. - * @type {object} - */ - get uriParams() { - return this.#uriParams; - } - - /** - * Create a Core. - * @param {string} appID The app id from your newgrounds project 'API Tools' page - * @param {string} aesKey The AES-128 emcryption key from your newgrounds project 'API Tools' page - */ - constructor(appID, aesKey) { - super(); - if (typeof appID === "undefined") throw "Missing required appID!"; - if (typeof aesKey === "undefined") throw "Missing required aesKey!"; - - this.#appID = appID; - this.#aesKey = CryptoJS.enc.Base64.parse(aesKey); - - this.#componentQueue = []; - - // look for query string in any URL hosting this app - this.#uriParams = {}; - - if (window && window.location && window.location.href) { - if (window.location.hostname) { - this.#host = window.location.hostname.toLowerCase(); - } else if ( - window.location.href.toLowerCase().substr(0, 5) == "file:" - ) { - this.#host = ""; - } else { - this.#host = ""; - } - } else { - this.#host = ""; - } - - if (typeof window !== "undefined" && window.location) { - var uri = window.location.href; - var query = uri.split("?").pop(); - - if (query) { - var pairs = query.split("&"); - var key_value; - for (var i = 0; i < pairs.length; i++) { - key_value = pairs[i].split("="); - this.#uriParams[key_value[0]] = key_value[1]; - } - } - } - - this.#session = this.getObject("Session"); - this.#session._uri_id = this.getUriParam("ngio_session_id", null); - } - - /** - * Gets a query parameter value from the URI hosting this game. - * @param {string} param The parameter you want to get a value for. - * @param {string} defaultValue A value to use if the param isn't set. - * @returns {string} - */ - getUriParam(param, defaultValue) { - return typeof this.#uriParams[param] === "undefined" - ? defaultValue - : this.#uriParams[param]; - } - - /** - * Encrypts a JSON-encoded string and encodes it to a base64 string. - * @param {string} jsonString The encoded JSON string to encrypt. - * @returns {string} - */ - encrypt(jsonString) { - let iv = CryptoJS.lib.WordArray.random(16); - let encrypted = CryptoJS.AES.encrypt(jsonString, this.#aesKey, { - iv: iv, - }); - return CryptoJS.enc.Base64.stringify(iv.concat(encrypted.ciphertext)); - } - - getObject(name, params) { - if (typeof NewgroundsIO.objects[name] === "undefined") { - console.error("NewgroundsIO - Invalid object name: " + name); - return null; - } - - var object = new NewgroundsIO.objects[name](params); - object.setCore(this); - return object; - } - - getComponent(name, params) { - var parts = name.split("."); - var error = false; - if (parts.length !== 2) { - error = "Invalid component name: " + name; - } else if (typeof NewgroundsIO.components[parts[0]] === "undefined") { - error = "Invalid component name: " + name; - } else if ( - typeof NewgroundsIO.components[parts[0]][parts[1]] === "undefined" - ) { - error = "Invalid component name: " + name; - } - - if (error) { - console.error("NewgroundsIO - " + error); - return null; - } - - var component = new NewgroundsIO.components[parts[0]][parts[1]](params); - component.setCore(this); - return component; - } - - /** - * Adds a component to the Queue. Queued components are executed in a single call via executeQueue. - * @param {NewgroundsIO.BaseComponent} component Any NewgroundsIO.components.XXXXX object - */ - queueComponent(component) { - if (!this._verifyComponent(component)) { - return; - } - component.setCore(this); - this.#componentQueue.push(component); - } - - /** - * Executes any components in the queue. - * @param {responseCallback} callback A function to fire when the queue has finished executing on the server. - * @param {object} thisArg An optional object to use as 'this' in your callback function. - */ - executeQueue(callback, thisArg) { - if (this.#componentQueue.length < 1) return; - - this.executeComponent(this.#componentQueue, callback, thisArg); - this.#componentQueue = []; - } - - /** - * Executes any components in the queue. - * @param {NewgroundsIO.BaseComponent} component Any NewgroundsIO.components.XXXXX object - * @param {responseCallback} callback A function to fire when the queue has finished executing on the server. - * @param {object} thisArg An optional object to use as 'this' in your callback function. - */ - executeComponent(component, callback, thisArg) { - if (Array.isArray(component)) { - let valid = true; - let _this = this; - component.forEach((_c) => { - if (!(_c instanceof NewgroundsIO.BaseComponent)) { - if (!_this._verifyComponent(component)) valid = false; - _c.setCore(_this); - } - }); - if (!valid) return; - } else { - if (!this._verifyComponent(component)) return; - component.setCore(this); - } - - let core = this; - let request = this._getRequest(component); - let response = new NewgroundsIO.objects.Response(); - - Scratch.canFetch(this.GATEWAY_URI).then((allowed) => { - if (!allowed) return callback(null); - var xhr = new XMLHttpRequest(); - xhr.onreadystatechange = function () { - if (xhr.readyState == 4) { - var o_return; - try { - o_return = JSON.parse(xhr.responseText); - } catch (e) { - o_return = { success: false, app_id: core.app_id }; - o_return.error = { message: String(e), code: 8002 }; - } - - let response = core._populateResponse(o_return); - - core.dispatchEvent( - new CustomEvent("serverResponse", { detail: response }) - ); - - if (callback) { - if (thisArg) callback.call(thisArg, response); - else callback(response); - } - } - }; - - // jhax is a hack to get around JS frameworks that add a toJSON method to Array (wich breaks the native implementation). - var jhax = - typeof Array.prototype.toJSON != "undefined" - ? Array.prototype.toJSON - : null; - if (jhax) delete Array.prototype.toJSON; - - let formData = new FormData(); - formData.append("request", JSON.stringify(request)); - if (jhax) Array.prototype.toJSON = jhax; - - xhr.open("POST", this.GATEWAY_URI, true); - - xhr.send(formData); - }); - } - - /** - * Executes a component in a new browser tab. Intended for redirects, such as - * those used in Loader components. - * @param {NewgroundsIO.BaseComponent} component Any NewgroundsIO.components.XXXXX object - */ - loadComponent(component) { - if (!this._verifyComponent(component)) return; - - component.setCore(this); - - let request = this._getRequest(component); - - let url = - this.GATEWAY_URI + - "?request=" + - encodeURIComponent(JSON.stringify(request)); - Scratch.openWindow(url); - } - - /** - * Override this if you need to catch responses before they are dispatched to a callback. - * @param {NewgroundsIO.objects.Response} - */ - onServerResponse(response) {} - - /** - * populates a response object with decoded server response data - * @private - */ - _populateResponse(response) { - if (response.success) { - if (Array.isArray(response.result)) { - for (let i = 0; i < response.result.length; i++) { - response.result[i] = this._populateResult(response.result[i]); - } - } else { - response.result = this._populateResult(response.result); - } - } else { - if (response.result) delete response.result; - - if (response.error) - response.error = new NewgroundsIO.objects.Error(response.error); - } - - response = new NewgroundsIO.objects.Response(response); - response.setCore(this); - return response; - } - - /** - * populates a result object with decoded server result data - * @private - */ - _populateResult(result) { - let path = result.component.split("."); - let _class = NewgroundsIO.results[path[0]][path[1]]; - if (!_class) return null; - - result.data.component = result.component; - let res = new _class(); - res.fromJSON(result.data, this); - - return res; - } - - /** - * wraps a component object in an execute object - * @private - */ - _getExecute(component) { - var execute = new NewgroundsIO.objects.Execute(); - execute.setComponent(component); - execute.setCore(this); - return execute; - } - - /** - * wraps a component object in request/execute objects - * @private - */ - _getRequest(component) { - let execute; - let _this = this; - if (Array.isArray(component)) { - execute = []; - component.forEach((_c) => { - let _ex = _this._getExecute(_c); - execute.push(_ex); - }); - } else { - execute = this._getExecute(component); - } - - let request = new NewgroundsIO.objects.Request({ - execute: execute, - }); - - if (this.debug) request.debug = true; - - request.setCore(this); - return request; - } - - _verifyComponent(component) { - if (!(component instanceof NewgroundsIO.BaseComponent)) { - console.error( - "NewgroundsIO Type Mismatch: Expecting a NewgroundsIO.components.XXXX instance, got", - component - ); - return false; - } else if (!component.isValid()) { - return false; - } - - return true; - } - } - - /** End Class NewgroundsIO.Core **/ - NewgroundsIO.Core = Core; - })(); - - (() => { - /** Start Class NewgroundsIO.BaseObject **/ - - /** The base object all models will use **/ - class BaseObject { - /** - * Used to tell serialization that this is an object model. - * @type {string} - */ - get type() { - return this.__type; - } - - /** - * @private - */ - __type = "object"; - - /** - * @private - */ - __object = "BaseObject"; - - /** - * @private - */ - __properties = []; - - /** - * @private - */ - __required = []; - - /** - * @private - */ - __ngioCore = null; - - /** - * Returns true if all required properties are set. - * @returns {boolean} - */ - isValid() { - if (this.__required.length === 0) return true; - - let valid = true; - - this.__required.forEach(function (property) { - if (this[property] === null) { - console.error( - "NewgroundsIO Error: " + - this.__object + - " " + - this.__type + - " is invalid, missing value for '" + - property + - "'" - ); - valid = false; - } else if (this[property] instanceof NewgroundsIO.BaseObject) { - if (!this[property].isValid()) valid = false; - } - }, this); - - return valid; - } - - /** - * Recursively links a core instance. - * @param {NewgroundsIO} core - */ - setCore(core) { - this._doSetCore(core, []); - } - - objectMap = {}; - arrayMap = {}; - - fromJSON(obj, core) { - var newobj = {}; - var i, j; - - this.setCore(core); - - for (i = 0; i < this.__properties.length; i++) { - let prop = this.__properties[i]; - - if (typeof obj[prop] !== "undefined" && obj[prop] !== null) { - newobj[prop] = obj[prop]; - - if ( - typeof this.arrayMap[prop] !== "undefined" && - Array.isArray(newobj[prop]) - ) { - newobj[prop] = []; - for (j = 0; j < obj[prop].length; j++) { - let _class = NewgroundsIO.objects[this.arrayMap[prop]]; - newobj[prop][j] = new _class(); - newobj[prop][j].fromJSON(obj[prop][j], core); - } - } else if (typeof this.objectMap[prop] !== "undefined") { - let _class = NewgroundsIO.objects[this.objectMap[prop]]; - newobj[prop] = new _class(); - newobj[prop].fromJSON(obj[prop], core); - } - - this[prop] = newobj[prop]; - } - } - } - - /** - * sets the core on all children, and prevents infinite recursion - * @private - */ - _doSetCore(core, updatedList) { - if (!Array.isArray(updatedList)) updatedList = []; - - if (!(core instanceof NewgroundsIO.Core)) { - console.error( - "NewgroundsIO Error: Expecting NewgroundsIO.Core instance, got", - core - ); - } else { - this.__ngioCore = core; - updatedList.push(this); - - this.__properties.forEach(function (prop) { - if ( - this[prop] instanceof NewgroundsIO.BaseObject && - updatedList.indexOf(this[prop]) === -1 - ) { - this[prop]._doSetCore(core, updatedList); - } else if (Array.isArray(this[prop])) { - this[prop].forEach((child) => { - if ( - child instanceof NewgroundsIO.BaseObject && - updatedList.indexOf(child) === -1 - ) { - child._doSetCore(core, updatedList); - } - }, this); - } - - if (prop === "host" && !this.host) this.host = core.host; - }, this); - } - } - - /** - * Returns an object suitable for serializing to a JSON string. - * @returns {object} - */ - toJSON() { - return this.__doToJSON(); - } - - /** - * Does the actual serialization - * @private - */ - __doToJSON() { - if (typeof this.__properties === "undefined") return {}; - - let json = {}; - - this.__properties.forEach(function (prop) { - if (this[prop] !== null) { - json[prop] = - typeof this[prop].toJSON === "function" - ? this[prop].toJSON() - : this[prop]; - } - }, this); - - return json; - } - - /** - * Serializes this object to an encrypted JSON string - * @returns {string} - */ - toSecureJSON() { - if ( - !this.__ngioCore || - !(this.__ngioCore instanceof NewgroundsIO.Core) - ) { - console.error( - "NewgroundsIO Error: Unable to create secure JSON object without calling setCore() first." - ); - return this.__doToJSON(); - } - - return { - secure: this.__ngioCore.encrypt(JSON.stringify(this.__doToJSON())), - }; - } - - toString() { - return this.__type; - } - - clone(cloneTo) { - if (typeof cloneTo === "undefined") cloneTo = new this.constructor(); - this.__properties.forEach((prop) => { - cloneTo[prop] = this[prop]; - }); - cloneTo.__ngioCore = this.__ngioCore; - return cloneTo; - } - } - - /** End Class NewgroundsIO.BaseObject **/ - NewgroundsIO.BaseObject = BaseObject; - - /** Start Class NewgroundsIO.BaseComponent **/ - - /** The base object all models will use **/ - class BaseComponent extends BaseObject { - /** Creates a new BaseComponent **/ - constructor() { - super(); - this.__type = "component"; - this.__object = "BaseComponent"; - - this.__properties = ["host", "echo"]; - - this._echo = null; - } - - /** - * Many components need to pass the hosting website (or indicator this is a standalone app). - * @type {string} - */ - get host() { - return this.__ngioCore ? this.__ngioCore.host : null; - } - - /** - * All components have an optional echo property that will return the same value in a server response. - * @type {string} - */ - get echo() { - return this._echo; - } - - set echo(value) { - this.echo = "" + value; - } - } - - /** End Class NewgroundsIO.BaseComponent **/ - NewgroundsIO.BaseComponent = BaseComponent; - - /** Start Class NewgroundsIO.BaseResult **/ - - /** The base object all models will use **/ - class BaseResult extends BaseObject { - /** Creates a new BaseResult **/ - constructor() { - super(); - this.__type = "result"; - this.__object = "BaseResult"; - - this.__properties = ["echo", "error", "success"]; - - this._echo = null; - this._error = null; - this._success = null; - } - - /** - * The name of the component that was called to yield this result. - * @type {string} - */ - get component() { - return this.__object; - } - - /** - * All components can send an echo string. They will be returned in this property. - * @type {string} - */ - get echo() { - return this._echo; - } - - /** - * If there was an error with the component, this will be an Error object. - * @type {NewgroundsIO.objects.Error} - */ - get error() { - return this._error; - } - - set error(value) { - this._error = value; - } - - /** - * If the component was successful, this will be true. If not, you can check the error property for details. - * @type {boolean} - */ - get success() { - return this._success ? true : false; - } - - set success(value) { - this._success = value ? true : false; - } - } - - /** End Class NewgroundsIO.BaseResult **/ - NewgroundsIO.BaseResult = BaseResult; - })(); - - /** Start Class NewgroundsIO.SessionState **/ - /** - * Contains a bunch of constants representing the different states a user session can be in. - * This is used by the NewgroundsIO.objects.Session object - */ - NewgroundsIO.SessionState = { - SESSION_UNINITIALIZED: "session-uninitialized", // We have never checked this session - WAITING_FOR_SERVER: "waiting-for-server", // We are waiting for the server to send information - LOGIN_REQUIRED: "login-required", // We have a session, but the user isn't logged in - WAITING_FOR_USER: "waiting-for-user", // The user has opened the login page - LOGIN_CANCELLED: "login-cancelled", // The user cancelled the login - LOGIN_SUCCESSFUL: "login-successful", // The user is logged in, session is valid! - LOGIN_FAILED: "login-failed", // The user failed their login attempt - USER_LOGGED_OUT: "user-logged-out", // The user logged out - SERVER_UNAVAILABLE: "server-unavailable", // The server is currently unavailable - EXCEEDED_MAX_ATTEMPTS: "exceeded-max-attempts", // We've failed trying to connect too many times - }; - - /** - * States in this list are considered "waiting". You don't need to make any API calls during these. - */ - NewgroundsIO.SessionState.SESSION_WAITING = [ - NewgroundsIO.SessionState.SESSION_UNINITIALIZED, - NewgroundsIO.SessionState.WAITING_FOR_SERVER, - NewgroundsIO.SessionState.WAITING_FOR_USER, - NewgroundsIO.SessionState.LOGIN_CANCELLED, - NewgroundsIO.SessionStateLOGIN_FAILED, - ]; - /** End Class NewgroundsIO.SessionState **/ - - /* ====================== ./NewgroundsIO-JS/src/NewgroundsIO/components/App/checkSession.js ====================== */ - - (() => { - /** Start NewgroundsIO.components.App.checkSession **/ - - class checkSession extends NewgroundsIO.BaseComponent { - /** - * Constructor - */ - constructor() { - super(); - let _this = this; - - this.__object = "App.checkSession"; - this.__requireSession = true; - } - } - - /** End Class NewgroundsIO.components.App.checkSession **/ - if (typeof NewgroundsIO.components.App === "undefined") - NewgroundsIO.components.App = {}; - NewgroundsIO.components.App.checkSession = checkSession; - })(); - - /* ====================== ./NewgroundsIO-JS/src/NewgroundsIO/components/App/endSession.js ====================== */ - - (() => { - /** Start NewgroundsIO.components.App.endSession **/ - - class endSession extends NewgroundsIO.BaseComponent { - /** - * Constructor - */ - constructor() { - super(); - let _this = this; - - this.__object = "App.endSession"; - this.__requireSession = true; - } - } - - /** End Class NewgroundsIO.components.App.endSession **/ - if (typeof NewgroundsIO.components.App === "undefined") - NewgroundsIO.components.App = {}; - NewgroundsIO.components.App.endSession = endSession; - })(); - - /* ====================== ./NewgroundsIO-JS/src/NewgroundsIO/components/App/getCurrentVersion.js ====================== */ - - (() => { - /** Start NewgroundsIO.components.App.getCurrentVersion **/ - - class getCurrentVersion extends NewgroundsIO.BaseComponent { - /** - * Constructor - * @param {object} props An object of initial properties for this instance - * @param {String} props.version The version number (in "X.Y.Z" format) of the client-side app. (default = "0.0.0") - */ - constructor(props) { - super(); - let _this = this; - - this.__object = "App.getCurrentVersion"; - ["version"].forEach((prop) => { - if (_this.__properties.indexOf(prop) < 0) - _this.__properties.push(prop); - }); - if (props && typeof props === "object") { - for (var i = 0; i < this.__properties.length; i++) { - if (typeof props[this.__properties[i]] !== "undefined") - this[this.__properties[i]] = props[this.__properties[i]]; - } - } - } - - /** - * @private - */ - #version = null; - - /** - * The version number (in "X.Y.Z" format) of the client-side app. (default = "0.0.0") - * @type {String} - */ - get version() { - return this.#version; - } - - set version(_version) { - if (typeof _version !== "string" && _version !== null) - console.warn( - "NewgroundsIO Type Mismatch: Value should be a string, got", - _version - ); - this.#version = String(_version); - } - } - - /** End Class NewgroundsIO.components.App.getCurrentVersion **/ - if (typeof NewgroundsIO.components.App === "undefined") - NewgroundsIO.components.App = {}; - NewgroundsIO.components.App.getCurrentVersion = getCurrentVersion; - })(); - - /* ====================== ./NewgroundsIO-JS/src/NewgroundsIO/components/App/getHostLicense.js ====================== */ - - (() => { - /** Start NewgroundsIO.components.App.getHostLicense **/ - - class getHostLicense extends NewgroundsIO.BaseComponent { - /** - * Constructor - * @param {object} props An object of initial properties for this instance - * @param {String} props.host The host domain to check (ei, somesite.com). - */ - constructor(props) { - super(); - let _this = this; - - this.__object = "App.getHostLicense"; - ["host"].forEach((prop) => { - if (_this.__properties.indexOf(prop) < 0) - _this.__properties.push(prop); - }); - if (props && typeof props === "object") { - for (var i = 0; i < this.__properties.length; i++) { - if (typeof props[this.__properties[i]] !== "undefined") - this[this.__properties[i]] = props[this.__properties[i]]; - } - } - } - } - - /** End Class NewgroundsIO.components.App.getHostLicense **/ - if (typeof NewgroundsIO.components.App === "undefined") - NewgroundsIO.components.App = {}; - NewgroundsIO.components.App.getHostLicense = getHostLicense; - })(); - - /* ====================== ./NewgroundsIO-JS/src/NewgroundsIO/components/App/logView.js ====================== */ - - (() => { - /** Start NewgroundsIO.components.App.logView **/ - - class logView extends NewgroundsIO.BaseComponent { - /** - * Constructor - * @param {object} props An object of initial properties for this instance - * @param {String} props.host The domain hosting your app. Examples: "www.somesite.com", "localHost" - */ - constructor(props) { - super(); - let _this = this; - - this.__object = "App.logView"; - ["host"].forEach((prop) => { - if (_this.__properties.indexOf(prop) < 0) - _this.__properties.push(prop); - }); - if (props && typeof props === "object") { - for (var i = 0; i < this.__properties.length; i++) { - if (typeof props[this.__properties[i]] !== "undefined") - this[this.__properties[i]] = props[this.__properties[i]]; - } - } - } - } - - /** End Class NewgroundsIO.components.App.logView **/ - if (typeof NewgroundsIO.components.App === "undefined") - NewgroundsIO.components.App = {}; - NewgroundsIO.components.App.logView = logView; - })(); - - /* ====================== ./NewgroundsIO-JS/src/NewgroundsIO/components/App/startSession.js ====================== */ - - (() => { - /** Start NewgroundsIO.components.App.startSession **/ - - class startSession extends NewgroundsIO.BaseComponent { - /** - * Constructor - * @param {object} props An object of initial properties for this instance - * @param {Boolean} props.force If true, will create a new session even if the user already has an existing one. - undefined * Note: Any previous session ids will no longer be valid if this is used. - */ - constructor(props) { - super(); - let _this = this; - - this.__object = "App.startSession"; - ["force"].forEach((prop) => { - if (_this.__properties.indexOf(prop) < 0) - _this.__properties.push(prop); - }); - if (props && typeof props === "object") { - for (var i = 0; i < this.__properties.length; i++) { - if (typeof props[this.__properties[i]] !== "undefined") - this[this.__properties[i]] = props[this.__properties[i]]; - } - } - } - - /** - * @private - */ - #force = null; - - /** - * If true, will create a new session even if the user already has an existing one. - * Note: Any previous session ids will no longer be valid if this is used. - * @type {Boolean} - */ - get force() { - return this.#force; - } - - set force(_force) { - if ( - typeof _force !== "boolean" && - typeof _force !== "number" && - _force !== null - ) - console.warn( - "NewgroundsIO Type Mismatch: Value should be a boolean, got", - _force - ); - this.#force = _force ? true : false; - } - } - - /** End Class NewgroundsIO.components.App.startSession **/ - if (typeof NewgroundsIO.components.App === "undefined") - NewgroundsIO.components.App = {}; - NewgroundsIO.components.App.startSession = startSession; - })(); - - /* ====================== ./NewgroundsIO-JS/src/NewgroundsIO/components/CloudSave/clearSlot.js ====================== */ - - (() => { - /** Start NewgroundsIO.components.CloudSave.clearSlot **/ - - class clearSlot extends NewgroundsIO.BaseComponent { - /** - * Constructor - * @param {object} props An object of initial properties for this instance - * @param {Number} props.id The slot number. - */ - constructor(props) { - super(); - let _this = this; - - this.__object = "CloudSave.clearSlot"; - this.__requireSession = true; - ["id"].forEach((prop) => { - if (_this.__properties.indexOf(prop) < 0) - _this.__properties.push(prop); - }); - if (props && typeof props === "object") { - for (var i = 0; i < this.__properties.length; i++) { - if (typeof props[this.__properties[i]] !== "undefined") - this[this.__properties[i]] = props[this.__properties[i]]; - } - } - } - - /** - * @private - */ - #id = null; - - /** - * The slot number. - * @type {Number} - */ - get id() { - return this.#id; - } - - set id(_id) { - if (typeof _id !== "number" && _id !== null) - console.warn( - "NewgroundsIO Type Mismatch: Value should be a number, got", - _id - ); - else if (!Number.isInteger(_id) && _id !== null) - console.warn( - "NewgroundsIO Type Mismatch: Value should be an integer, got a float" - ); - this.#id = Number(_id); - if (isNaN(this.#id)) this.#id = null; - } - } - - /** End Class NewgroundsIO.components.CloudSave.clearSlot **/ - if (typeof NewgroundsIO.components.CloudSave === "undefined") - NewgroundsIO.components.CloudSave = {}; - NewgroundsIO.components.CloudSave.clearSlot = clearSlot; - })(); - - /* ====================== ./NewgroundsIO-JS/src/NewgroundsIO/components/CloudSave/loadSlot.js ====================== */ - - (() => { - /** Start NewgroundsIO.components.CloudSave.loadSlot **/ - - class loadSlot extends NewgroundsIO.BaseComponent { - /** - * Constructor - * @param {object} props An object of initial properties for this instance - * @param {Number} props.id The slot number. - * @param {String} props.app_id The App ID of another, approved app to load slot data from. - */ - constructor(props) { - super(); - let _this = this; - - this.__object = "CloudSave.loadSlot"; - this.__requireSession = true; - ["id", "app_id"].forEach((prop) => { - if (_this.__properties.indexOf(prop) < 0) - _this.__properties.push(prop); - }); - if (props && typeof props === "object") { - for (var i = 0; i < this.__properties.length; i++) { - if (typeof props[this.__properties[i]] !== "undefined") - this[this.__properties[i]] = props[this.__properties[i]]; - } - } - } - - /** - * @private - */ - #id = null; - - /** - * The slot number. - * @type {Number} - */ - get id() { - return this.#id; - } - - set id(_id) { - if (typeof _id !== "number" && _id !== null) - console.warn( - "NewgroundsIO Type Mismatch: Value should be a number, got", - _id - ); - else if (!Number.isInteger(_id) && _id !== null) - console.warn( - "NewgroundsIO Type Mismatch: Value should be an integer, got a float" - ); - this.#id = Number(_id); - if (isNaN(this.#id)) this.#id = null; - } - - /** - * @private - */ - #app_id = null; - - /** - * The App ID of another, approved app to load slot data from. - * @type {String} - */ - get app_id() { - return this.#app_id; - } - - set app_id(_app_id) { - if (typeof _app_id !== "string" && _app_id !== null) - console.warn( - "NewgroundsIO Type Mismatch: Value should be a string, got", - _app_id - ); - this.#app_id = String(_app_id); - } - } - - /** End Class NewgroundsIO.components.CloudSave.loadSlot **/ - if (typeof NewgroundsIO.components.CloudSave === "undefined") - NewgroundsIO.components.CloudSave = {}; - NewgroundsIO.components.CloudSave.loadSlot = loadSlot; - })(); - - /* ====================== ./NewgroundsIO-JS/src/NewgroundsIO/components/CloudSave/loadSlots.js ====================== */ - - (() => { - /** Start NewgroundsIO.components.CloudSave.loadSlots **/ - - class loadSlots extends NewgroundsIO.BaseComponent { - /** - * Constructor - * @param {object} props An object of initial properties for this instance - * @param {String} props.app_id The App ID of another, approved app to load slot data from. - */ - constructor(props) { - super(); - let _this = this; - - this.__object = "CloudSave.loadSlots"; - this.__requireSession = true; - ["app_id"].forEach((prop) => { - if (_this.__properties.indexOf(prop) < 0) - _this.__properties.push(prop); - }); - if (props && typeof props === "object") { - for (var i = 0; i < this.__properties.length; i++) { - if (typeof props[this.__properties[i]] !== "undefined") - this[this.__properties[i]] = props[this.__properties[i]]; - } - } - } - - /** - * @private - */ - #app_id = null; - - /** - * The App ID of another, approved app to load slot data from. - * @type {String} - */ - get app_id() { - return this.#app_id; - } - - set app_id(_app_id) { - if (typeof _app_id !== "string" && _app_id !== null) - console.warn( - "NewgroundsIO Type Mismatch: Value should be a string, got", - _app_id - ); - this.#app_id = String(_app_id); - } - } - - /** End Class NewgroundsIO.components.CloudSave.loadSlots **/ - if (typeof NewgroundsIO.components.CloudSave === "undefined") - NewgroundsIO.components.CloudSave = {}; - NewgroundsIO.components.CloudSave.loadSlots = loadSlots; - })(); - - /* ====================== ./NewgroundsIO-JS/src/NewgroundsIO/components/CloudSave/setData.js ====================== */ - - (() => { - /** Start NewgroundsIO.components.CloudSave.setData **/ - - class setData extends NewgroundsIO.BaseComponent { - /** - * Constructor - * @param {object} props An object of initial properties for this instance - * @param {Number} props.id The slot number. - * @param {String} props.data The data you want to save. - */ - constructor(props) { - super(); - let _this = this; - - this.__object = "CloudSave.setData"; - this.__requireSession = true; - ["id", "data"].forEach((prop) => { - if (_this.__properties.indexOf(prop) < 0) - _this.__properties.push(prop); - }); - if (props && typeof props === "object") { - for (var i = 0; i < this.__properties.length; i++) { - if (typeof props[this.__properties[i]] !== "undefined") - this[this.__properties[i]] = props[this.__properties[i]]; - } - } - } - - /** - * @private - */ - #id = null; - - /** - * The slot number. - * @type {Number} - */ - get id() { - return this.#id; - } - - set id(_id) { - if (typeof _id !== "number" && _id !== null) - console.warn( - "NewgroundsIO Type Mismatch: Value should be a number, got", - _id - ); - else if (!Number.isInteger(_id) && _id !== null) - console.warn( - "NewgroundsIO Type Mismatch: Value should be an integer, got a float" - ); - this.#id = Number(_id); - if (isNaN(this.#id)) this.#id = null; - } - - /** - * @private - */ - #data = null; - - /** - * The data you want to save. - * @type {String} - */ - get data() { - return this.#data; - } - - set data(_data) { - if (typeof _data !== "string" && _data !== null) - console.warn( - "NewgroundsIO Type Mismatch: Value should be a string, got", - _data - ); - this.#data = String(_data); - } - } - - /** End Class NewgroundsIO.components.CloudSave.setData **/ - if (typeof NewgroundsIO.components.CloudSave === "undefined") - NewgroundsIO.components.CloudSave = {}; - NewgroundsIO.components.CloudSave.setData = setData; - })(); - - /* ====================== ./NewgroundsIO-JS/src/NewgroundsIO/components/Event/logEvent.js ====================== */ - - (() => { - /** Start NewgroundsIO.components.Event.logEvent **/ - - class logEvent extends NewgroundsIO.BaseComponent { - /** - * Constructor - * @param {object} props An object of initial properties for this instance - * @param {String} props.host The domain hosting your app. Example: "newgrounds.com", "localHost" - * @param {String} props.event_name The name of your custom event as defined in your Referrals & Events settings. - */ - constructor(props) { - super(); - let _this = this; - - this.__object = "Event.logEvent"; - ["host", "event_name"].forEach((prop) => { - if (_this.__properties.indexOf(prop) < 0) - _this.__properties.push(prop); - }); - if (props && typeof props === "object") { - for (var i = 0; i < this.__properties.length; i++) { - if (typeof props[this.__properties[i]] !== "undefined") - this[this.__properties[i]] = props[this.__properties[i]]; - } - } - } - - /** - * @private - */ - #event_name = null; - - /** - * The name of your custom event as defined in your Referrals & Events settings. - * @type {String} - */ - get event_name() { - return this.#event_name; - } - - set event_name(_event_name) { - if (typeof _event_name !== "string" && _event_name !== null) - console.warn( - "NewgroundsIO Type Mismatch: Value should be a string, got", - _event_name - ); - this.#event_name = String(_event_name); - } - } - - /** End Class NewgroundsIO.components.Event.logEvent **/ - if (typeof NewgroundsIO.components.Event === "undefined") - NewgroundsIO.components.Event = {}; - NewgroundsIO.components.Event.logEvent = logEvent; - })(); - - /* ====================== ./NewgroundsIO-JS/src/NewgroundsIO/components/Gateway/getDatetime.js ====================== */ - - (() => { - /** Start NewgroundsIO.components.Gateway.getDatetime **/ - - class getDatetime extends NewgroundsIO.BaseComponent { - /** - * Constructor - */ - constructor() { - super(); - let _this = this; - - this.__object = "Gateway.getDatetime"; - } - } - - /** End Class NewgroundsIO.components.Gateway.getDatetime **/ - if (typeof NewgroundsIO.components.Gateway === "undefined") - NewgroundsIO.components.Gateway = {}; - NewgroundsIO.components.Gateway.getDatetime = getDatetime; - })(); - - /* ====================== ./NewgroundsIO-JS/src/NewgroundsIO/components/Gateway/getVersion.js ====================== */ - - (() => { - /** Start NewgroundsIO.components.Gateway.getVersion **/ - - class getVersion extends NewgroundsIO.BaseComponent { - /** - * Constructor - */ - constructor() { - super(); - let _this = this; - - this.__object = "Gateway.getVersion"; - } - } - - /** End Class NewgroundsIO.components.Gateway.getVersion **/ - if (typeof NewgroundsIO.components.Gateway === "undefined") - NewgroundsIO.components.Gateway = {}; - NewgroundsIO.components.Gateway.getVersion = getVersion; - })(); - - /* ====================== ./NewgroundsIO-JS/src/NewgroundsIO/components/Gateway/ping.js ====================== */ - - (() => { - /** Start NewgroundsIO.components.Gateway.ping **/ - - class ping extends NewgroundsIO.BaseComponent { - /** - * Constructor - */ - constructor() { - super(); - let _this = this; - - this.__object = "Gateway.ping"; - } - } - - /** End Class NewgroundsIO.components.Gateway.ping **/ - if (typeof NewgroundsIO.components.Gateway === "undefined") - NewgroundsIO.components.Gateway = {}; - NewgroundsIO.components.Gateway.ping = ping; - })(); - - /* ====================== ./NewgroundsIO-JS/src/NewgroundsIO/components/Loader/loadAuthorUrl.js ====================== */ - - (() => { - /** Start NewgroundsIO.components.Loader.loadAuthorUrl **/ - - class loadAuthorUrl extends NewgroundsIO.BaseComponent { - /** - * Constructor - * @param {object} props An object of initial properties for this instance - * @param {String} props.host The domain hosting your app. Example: "www.somesite.com", "localHost" - * @param {Boolean} props.redirect Set this to false to get a JSON response containing the URL instead of doing an actual redirect. - * @param {Boolean} props.log_stat Set this to false to skip logging this as a referral event. - */ - constructor(props) { - super(); - let _this = this; - - this.__object = "Loader.loadAuthorUrl"; - ["host", "redirect", "log_stat"].forEach((prop) => { - if (_this.__properties.indexOf(prop) < 0) - _this.__properties.push(prop); - }); - if (props && typeof props === "object") { - for (var i = 0; i < this.__properties.length; i++) { - if (typeof props[this.__properties[i]] !== "undefined") - this[this.__properties[i]] = props[this.__properties[i]]; - } - } - } - - /** - * @private - */ - #redirect = null; - - /** - * Set this to false to get a JSON response containing the URL instead of doing an actual redirect. - * @type {Boolean} - */ - get redirect() { - return this.#redirect; - } - - set redirect(_redirect) { - if ( - typeof _redirect !== "boolean" && - typeof _redirect !== "number" && - _redirect !== null - ) - console.warn( - "NewgroundsIO Type Mismatch: Value should be a boolean, got", - _redirect - ); - this.#redirect = _redirect ? true : false; - } - - /** - * @private - */ - #log_stat = null; - - /** - * Set this to false to skip logging this as a referral event. - * @type {Boolean} - */ - get log_stat() { - return this.#log_stat; - } - - set log_stat(_log_stat) { - if ( - typeof _log_stat !== "boolean" && - typeof _log_stat !== "number" && - _log_stat !== null - ) - console.warn( - "NewgroundsIO Type Mismatch: Value should be a boolean, got", - _log_stat - ); - this.#log_stat = _log_stat ? true : false; - } - } - - /** End Class NewgroundsIO.components.Loader.loadAuthorUrl **/ - if (typeof NewgroundsIO.components.Loader === "undefined") - NewgroundsIO.components.Loader = {}; - NewgroundsIO.components.Loader.loadAuthorUrl = loadAuthorUrl; - })(); - - /* ====================== ./NewgroundsIO-JS/src/NewgroundsIO/components/Loader/loadMoreGames.js ====================== */ - - (() => { - /** Start NewgroundsIO.components.Loader.loadMoreGames **/ - - class loadMoreGames extends NewgroundsIO.BaseComponent { - /** - * Constructor - * @param {object} props An object of initial properties for this instance - * @param {String} props.host The domain hosting your app. Example: "www.somesite.com", "localHost" - * @param {Boolean} props.redirect Set this to false to get a JSON response containing the URL instead of doing an actual redirect. - * @param {Boolean} props.log_stat Set this to false to skip logging this as a referral event. - */ - constructor(props) { - super(); - let _this = this; - - this.__object = "Loader.loadMoreGames"; - ["host", "redirect", "log_stat"].forEach((prop) => { - if (_this.__properties.indexOf(prop) < 0) - _this.__properties.push(prop); - }); - if (props && typeof props === "object") { - for (var i = 0; i < this.__properties.length; i++) { - if (typeof props[this.__properties[i]] !== "undefined") - this[this.__properties[i]] = props[this.__properties[i]]; - } - } - } - - /** - * @private - */ - #redirect = null; - - /** - * Set this to false to get a JSON response containing the URL instead of doing an actual redirect. - * @type {Boolean} - */ - get redirect() { - return this.#redirect; - } - - set redirect(_redirect) { - if ( - typeof _redirect !== "boolean" && - typeof _redirect !== "number" && - _redirect !== null - ) - console.warn( - "NewgroundsIO Type Mismatch: Value should be a boolean, got", - _redirect - ); - this.#redirect = _redirect ? true : false; - } - - /** - * @private - */ - #log_stat = null; - - /** - * Set this to false to skip logging this as a referral event. - * @type {Boolean} - */ - get log_stat() { - return this.#log_stat; - } - - set log_stat(_log_stat) { - if ( - typeof _log_stat !== "boolean" && - typeof _log_stat !== "number" && - _log_stat !== null - ) - console.warn( - "NewgroundsIO Type Mismatch: Value should be a boolean, got", - _log_stat - ); - this.#log_stat = _log_stat ? true : false; - } - } - - /** End Class NewgroundsIO.components.Loader.loadMoreGames **/ - if (typeof NewgroundsIO.components.Loader === "undefined") - NewgroundsIO.components.Loader = {}; - NewgroundsIO.components.Loader.loadMoreGames = loadMoreGames; - })(); - - /* ====================== ./NewgroundsIO-JS/src/NewgroundsIO/components/Loader/loadNewgrounds.js ====================== */ - - (() => { - /** Start NewgroundsIO.components.Loader.loadNewgrounds **/ - - class loadNewgrounds extends NewgroundsIO.BaseComponent { - /** - * Constructor - * @param {object} props An object of initial properties for this instance - * @param {String} props.host The domain hosting your app. Example: "www.somesite.com", "localHost" - * @param {Boolean} props.redirect Set this to false to get a JSON response containing the URL instead of doing an actual redirect. - * @param {Boolean} props.log_stat Set this to false to skip logging this as a referral event. - */ - constructor(props) { - super(); - let _this = this; - - this.__object = "Loader.loadNewgrounds"; - ["host", "redirect", "log_stat"].forEach((prop) => { - if (_this.__properties.indexOf(prop) < 0) - _this.__properties.push(prop); - }); - if (props && typeof props === "object") { - for (var i = 0; i < this.__properties.length; i++) { - if (typeof props[this.__properties[i]] !== "undefined") - this[this.__properties[i]] = props[this.__properties[i]]; - } - } - } - - /** - * @private - */ - #redirect = null; - - /** - * Set this to false to get a JSON response containing the URL instead of doing an actual redirect. - * @type {Boolean} - */ - get redirect() { - return this.#redirect; - } - - set redirect(_redirect) { - if ( - typeof _redirect !== "boolean" && - typeof _redirect !== "number" && - _redirect !== null - ) - console.warn( - "NewgroundsIO Type Mismatch: Value should be a boolean, got", - _redirect - ); - this.#redirect = _redirect ? true : false; - } - - /** - * @private - */ - #log_stat = null; - - /** - * Set this to false to skip logging this as a referral event. - * @type {Boolean} - */ - get log_stat() { - return this.#log_stat; - } - - set log_stat(_log_stat) { - if ( - typeof _log_stat !== "boolean" && - typeof _log_stat !== "number" && - _log_stat !== null - ) - console.warn( - "NewgroundsIO Type Mismatch: Value should be a boolean, got", - _log_stat - ); - this.#log_stat = _log_stat ? true : false; - } - } - - /** End Class NewgroundsIO.components.Loader.loadNewgrounds **/ - if (typeof NewgroundsIO.components.Loader === "undefined") - NewgroundsIO.components.Loader = {}; - NewgroundsIO.components.Loader.loadNewgrounds = loadNewgrounds; - })(); - - /* ====================== ./NewgroundsIO-JS/src/NewgroundsIO/components/Loader/loadOfficialUrl.js ====================== */ - - (() => { - /** Start NewgroundsIO.components.Loader.loadOfficialUrl **/ - - class loadOfficialUrl extends NewgroundsIO.BaseComponent { - /** - * Constructor - * @param {object} props An object of initial properties for this instance - * @param {String} props.host The domain hosting your app. Example: "www.somesite.com", "localHost" - * @param {Boolean} props.redirect Set this to false to get a JSON response containing the URL instead of doing an actual redirect. - * @param {Boolean} props.log_stat Set this to false to skip logging this as a referral event. - */ - constructor(props) { - super(); - let _this = this; - - this.__object = "Loader.loadOfficialUrl"; - ["host", "redirect", "log_stat"].forEach((prop) => { - if (_this.__properties.indexOf(prop) < 0) - _this.__properties.push(prop); - }); - if (props && typeof props === "object") { - for (var i = 0; i < this.__properties.length; i++) { - if (typeof props[this.__properties[i]] !== "undefined") - this[this.__properties[i]] = props[this.__properties[i]]; - } - } - } - - /** - * @private - */ - #redirect = null; - - /** - * Set this to false to get a JSON response containing the URL instead of doing an actual redirect. - * @type {Boolean} - */ - get redirect() { - return this.#redirect; - } - - set redirect(_redirect) { - if ( - typeof _redirect !== "boolean" && - typeof _redirect !== "number" && - _redirect !== null - ) - console.warn( - "NewgroundsIO Type Mismatch: Value should be a boolean, got", - _redirect - ); - this.#redirect = _redirect ? true : false; - } - - /** - * @private - */ - #log_stat = null; - - /** - * Set this to false to skip logging this as a referral event. - * @type {Boolean} - */ - get log_stat() { - return this.#log_stat; - } - - set log_stat(_log_stat) { - if ( - typeof _log_stat !== "boolean" && - typeof _log_stat !== "number" && - _log_stat !== null - ) - console.warn( - "NewgroundsIO Type Mismatch: Value should be a boolean, got", - _log_stat - ); - this.#log_stat = _log_stat ? true : false; - } - } - - /** End Class NewgroundsIO.components.Loader.loadOfficialUrl **/ - if (typeof NewgroundsIO.components.Loader === "undefined") - NewgroundsIO.components.Loader = {}; - NewgroundsIO.components.Loader.loadOfficialUrl = loadOfficialUrl; - })(); - - /* ====================== ./NewgroundsIO-JS/src/NewgroundsIO/components/Loader/loadReferral.js ====================== */ - - (() => { - /** Start NewgroundsIO.components.Loader.loadReferral **/ - - class loadReferral extends NewgroundsIO.BaseComponent { - /** - * Constructor - * @param {object} props An object of initial properties for this instance - * @param {String} props.host The domain hosting your app. Example: "www.somesite.com", "localHost" - * @param {String} props.referral_name The name of the referral (as defined in your "Referrals & Events" settings). - * @param {Boolean} props.redirect Set this to false to get a JSON response containing the URL instead of doing an actual redirect. - * @param {Boolean} props.log_stat Set this to false to skip logging this as a referral event. - */ - constructor(props) { - super(); - let _this = this; - - this.__object = "Loader.loadReferral"; - ["host", "referral_name", "redirect", "log_stat"].forEach((prop) => { - if (_this.__properties.indexOf(prop) < 0) - _this.__properties.push(prop); - }); - if (props && typeof props === "object") { - for (var i = 0; i < this.__properties.length; i++) { - if (typeof props[this.__properties[i]] !== "undefined") - this[this.__properties[i]] = props[this.__properties[i]]; - } - } - } - - /** - * @private - */ - #referral_name = null; - - /** - * The name of the referral (as defined in your "Referrals & Events" settings). - * @type {String} - */ - get referral_name() { - return this.#referral_name; - } - - set referral_name(_referral_name) { - if (typeof _referral_name !== "string" && _referral_name !== null) - console.warn( - "NewgroundsIO Type Mismatch: Value should be a string, got", - _referral_name - ); - this.#referral_name = String(_referral_name); - } - - /** - * @private - */ - #redirect = null; - - /** - * Set this to false to get a JSON response containing the URL instead of doing an actual redirect. - * @type {Boolean} - */ - get redirect() { - return this.#redirect; - } - - set redirect(_redirect) { - if ( - typeof _redirect !== "boolean" && - typeof _redirect !== "number" && - _redirect !== null - ) - console.warn( - "NewgroundsIO Type Mismatch: Value should be a boolean, got", - _redirect - ); - this.#redirect = _redirect ? true : false; - } - - /** - * @private - */ - #log_stat = null; - - /** - * Set this to false to skip logging this as a referral event. - * @type {Boolean} - */ - get log_stat() { - return this.#log_stat; - } - - set log_stat(_log_stat) { - if ( - typeof _log_stat !== "boolean" && - typeof _log_stat !== "number" && - _log_stat !== null - ) - console.warn( - "NewgroundsIO Type Mismatch: Value should be a boolean, got", - _log_stat - ); - this.#log_stat = _log_stat ? true : false; - } - } - - /** End Class NewgroundsIO.components.Loader.loadReferral **/ - if (typeof NewgroundsIO.components.Loader === "undefined") - NewgroundsIO.components.Loader = {}; - NewgroundsIO.components.Loader.loadReferral = loadReferral; - })(); - - /* ====================== ./NewgroundsIO-JS/src/NewgroundsIO/components/Medal/getList.js ====================== */ - - (() => { - /** Start NewgroundsIO.components.Medal.getList **/ - - class getList extends NewgroundsIO.BaseComponent { - /** - * Constructor - * @param {object} props An object of initial properties for this instance - * @param {String} props.app_id The App ID of another, approved app to load medals from. - */ - constructor(props) { - super(); - let _this = this; - - this.__object = "Medal.getList"; - ["app_id"].forEach((prop) => { - if (_this.__properties.indexOf(prop) < 0) - _this.__properties.push(prop); - }); - if (props && typeof props === "object") { - for (var i = 0; i < this.__properties.length; i++) { - if (typeof props[this.__properties[i]] !== "undefined") - this[this.__properties[i]] = props[this.__properties[i]]; - } - } - } - - /** - * @private - */ - #app_id = null; - - /** - * The App ID of another, approved app to load medals from. - * @type {String} - */ - get app_id() { - return this.#app_id; - } - - set app_id(_app_id) { - if (typeof _app_id !== "string" && _app_id !== null) - console.warn( - "NewgroundsIO Type Mismatch: Value should be a string, got", - _app_id - ); - this.#app_id = String(_app_id); - } - } - - /** End Class NewgroundsIO.components.Medal.getList **/ - if (typeof NewgroundsIO.components.Medal === "undefined") - NewgroundsIO.components.Medal = {}; - NewgroundsIO.components.Medal.getList = getList; - })(); - - /* ====================== ./NewgroundsIO-JS/src/NewgroundsIO/components/Medal/getMedalScore.js ====================== */ - - (() => { - /** Start NewgroundsIO.components.Medal.getMedalScore **/ - - class getMedalScore extends NewgroundsIO.BaseComponent { - /** - * Constructor - */ - constructor() { - super(); - let _this = this; - - this.__object = "Medal.getMedalScore"; - this.__requireSession = true; - } - } - - /** End Class NewgroundsIO.components.Medal.getMedalScore **/ - if (typeof NewgroundsIO.components.Medal === "undefined") - NewgroundsIO.components.Medal = {}; - NewgroundsIO.components.Medal.getMedalScore = getMedalScore; - })(); - - /* ====================== ./NewgroundsIO-JS/src/NewgroundsIO/components/Medal/unlock.js ====================== */ - - (() => { - /** Start NewgroundsIO.components.Medal.unlock **/ - - class unlock extends NewgroundsIO.BaseComponent { - /** - * Constructor - * @param {object} props An object of initial properties for this instance - * @param {Number} props.id The numeric ID of the medal to unlock. - */ - constructor(props) { - super(); - let _this = this; - - this.__object = "Medal.unlock"; - this.__isSecure = true; - this.__requireSession = true; - ["id"].forEach((prop) => { - if (_this.__properties.indexOf(prop) < 0) - _this.__properties.push(prop); - }); - if (props && typeof props === "object") { - for (var i = 0; i < this.__properties.length; i++) { - if (typeof props[this.__properties[i]] !== "undefined") - this[this.__properties[i]] = props[this.__properties[i]]; - } - } - } - - /** - * @private - */ - #id = null; - - /** - * The numeric ID of the medal to unlock. - * @type {Number} - */ - get id() { - return this.#id; - } - - set id(_id) { - if (typeof _id !== "number" && _id !== null) - console.warn( - "NewgroundsIO Type Mismatch: Value should be a number, got", - _id - ); - else if (!Number.isInteger(_id) && _id !== null) - console.warn( - "NewgroundsIO Type Mismatch: Value should be an integer, got a float" - ); - this.#id = Number(_id); - if (isNaN(this.#id)) this.#id = null; - } - } - - /** End Class NewgroundsIO.components.Medal.unlock **/ - if (typeof NewgroundsIO.components.Medal === "undefined") - NewgroundsIO.components.Medal = {}; - NewgroundsIO.components.Medal.unlock = unlock; - })(); - - /* ====================== ./NewgroundsIO-JS/src/NewgroundsIO/components/ScoreBoard/getBoards.js ====================== */ - - (() => { - /** Start NewgroundsIO.components.ScoreBoard.getBoards **/ - - class getBoards extends NewgroundsIO.BaseComponent { - /** - * Constructor - */ - constructor() { - super(); - let _this = this; - - this.__object = "ScoreBoard.getBoards"; - } - } - - /** End Class NewgroundsIO.components.ScoreBoard.getBoards **/ - if (typeof NewgroundsIO.components.ScoreBoard === "undefined") - NewgroundsIO.components.ScoreBoard = {}; - NewgroundsIO.components.ScoreBoard.getBoards = getBoards; - })(); - - /* ====================== ./NewgroundsIO-JS/src/NewgroundsIO/components/ScoreBoard/getScores.js ====================== */ - - (() => { - /** Start NewgroundsIO.components.ScoreBoard.getScores **/ - - class getScores extends NewgroundsIO.BaseComponent { - /** - * Constructor - * @param {object} props An object of initial properties for this instance - * @param {Number} props.id The numeric ID of the scoreboard. - * @param {String} props.period The time-frame to pull scores from (see notes for acceptable values). - * @param {String} props.tag A tag to filter results by. - * @param {Boolean} props.social If set to true, only social scores will be loaded (scores by the user and their friends). This param will be ignored if there is no valid session id and the 'user' param is absent. - * @param {mixed} props.user A user's ID or name. If 'social' is true, this user and their friends will be included. Otherwise, only scores for this user will be loaded. If this param is missing and there is a valid session id, that user will be used by default. - * @param {Number} props.skip An integer indicating the number of scores to skip before starting the list. Default = 0. - * @param {Number} props.limit An integer indicating the number of scores to include in the list. Default = 10. - * @param {String} props.app_id The App ID of another, approved app to load scores from. - */ - constructor(props) { - super(); - let _this = this; - - this.__object = "ScoreBoard.getScores"; - [ - "id", - "period", - "tag", - "social", - "user", - "skip", - "limit", - "app_id", - ].forEach((prop) => { - if (_this.__properties.indexOf(prop) < 0) - _this.__properties.push(prop); - }); - if (props && typeof props === "object") { - for (var i = 0; i < this.__properties.length; i++) { - if (typeof props[this.__properties[i]] !== "undefined") - this[this.__properties[i]] = props[this.__properties[i]]; - } - } - } - - /** - * @private - */ - #id = null; - - /** - * The numeric ID of the scoreboard. - * @type {Number} - */ - get id() { - return this.#id; - } - - set id(_id) { - if (typeof _id !== "number" && _id !== null) - console.warn( - "NewgroundsIO Type Mismatch: Value should be a number, got", - _id - ); - else if (!Number.isInteger(_id) && _id !== null) - console.warn( - "NewgroundsIO Type Mismatch: Value should be an integer, got a float" - ); - this.#id = Number(_id); - if (isNaN(this.#id)) this.#id = null; - } - - /** - * @private - */ - #period = null; - - /** - * The time-frame to pull scores from (see notes for acceptable values). - * @type {String} - */ - get period() { - return this.#period; - } - - set period(_period) { - if (typeof _period !== "string" && _period !== null) - console.warn( - "NewgroundsIO Type Mismatch: Value should be a string, got", - _period - ); - this.#period = String(_period); - } - - /** - * @private - */ - #tag = null; - - /** - * A tag to filter results by. - * @type {String} - */ - get tag() { - return this.#tag; - } - - set tag(_tag) { - if (typeof _tag !== "string" && _tag !== null) - console.warn( - "NewgroundsIO Type Mismatch: Value should be a string, got", - _tag - ); - this.#tag = String(_tag); - } - - /** - * @private - */ - #social = null; - - /** - * If set to true, only social scores will be loaded (scores by the user and their friends). This param will be ignored if there is no valid session id and the 'user' param is absent. - * @type {Boolean} - */ - get social() { - return this.#social; - } - - set social(_social) { - if ( - typeof _social !== "boolean" && - typeof _social !== "number" && - _social !== null - ) - console.warn( - "NewgroundsIO Type Mismatch: Value should be a boolean, got", - _social - ); - this.#social = _social ? true : false; - } - - /** - * @private - */ - #user = null; - - /** - * A user's ID or name. If 'social' is true, this user and their friends will be included. Otherwise, only scores for this user will be loaded. If this param is missing and there is a valid session id, that user will be used by default. - * @type {mixed} - */ - get user() { - return this.#user; - } - - set user(_user) { - this.#user = _user; // mixed - } - - /** - * @private - */ - #skip = null; - - /** - * An integer indicating the number of scores to skip before starting the list. Default = 0. - * @type {Number} - */ - get skip() { - return this.#skip; - } - - set skip(_skip) { - if (typeof _skip !== "number" && _skip !== null) - console.warn( - "NewgroundsIO Type Mismatch: Value should be a number, got", - _skip - ); - else if (!Number.isInteger(_skip) && _skip !== null) - console.warn( - "NewgroundsIO Type Mismatch: Value should be an integer, got a float" - ); - this.#skip = Number(_skip); - if (isNaN(this.#skip)) this.#skip = null; - } - - /** - * @private - */ - #limit = null; - - /** - * An integer indicating the number of scores to include in the list. Default = 10. - * @type {Number} - */ - get limit() { - return this.#limit; - } - - set limit(_limit) { - if (typeof _limit !== "number" && _limit !== null) - console.warn( - "NewgroundsIO Type Mismatch: Value should be a number, got", - _limit - ); - else if (!Number.isInteger(_limit) && _limit !== null) - console.warn( - "NewgroundsIO Type Mismatch: Value should be an integer, got a float" - ); - this.#limit = Number(_limit); - if (isNaN(this.#limit)) this.#limit = null; - } - - /** - * @private - */ - #app_id = null; - - /** - * The App ID of another, approved app to load scores from. - * @type {String} - */ - get app_id() { - return this.#app_id; - } - - set app_id(_app_id) { - if (typeof _app_id !== "string" && _app_id !== null) - console.warn( - "NewgroundsIO Type Mismatch: Value should be a string, got", - _app_id - ); - this.#app_id = String(_app_id); - } - } - - /** End Class NewgroundsIO.components.ScoreBoard.getScores **/ - if (typeof NewgroundsIO.components.ScoreBoard === "undefined") - NewgroundsIO.components.ScoreBoard = {}; - NewgroundsIO.components.ScoreBoard.getScores = getScores; - })(); - - /* ====================== ./NewgroundsIO-JS/src/NewgroundsIO/components/ScoreBoard/postScore.js ====================== */ - - (() => { - /** Start NewgroundsIO.components.ScoreBoard.postScore **/ - - class postScore extends NewgroundsIO.BaseComponent { - /** - * Constructor - * @param {object} props An object of initial properties for this instance - * @param {Number} props.id The numeric ID of the scoreboard. - * @param {Number} props.value The int value of the score. - * @param {String} props.tag An optional tag that can be used to filter scores via ScoreBoard.getScores - */ - constructor(props) { - super(); - let _this = this; - - this.__object = "ScoreBoard.postScore"; - this.__isSecure = true; - this.__requireSession = true; - ["id", "value", "tag"].forEach((prop) => { - if (_this.__properties.indexOf(prop) < 0) - _this.__properties.push(prop); - }); - if (props && typeof props === "object") { - for (var i = 0; i < this.__properties.length; i++) { - if (typeof props[this.__properties[i]] !== "undefined") - this[this.__properties[i]] = props[this.__properties[i]]; - } - } - } - - /** - * @private - */ - #id = null; - - /** - * The numeric ID of the scoreboard. - * @type {Number} - */ - get id() { - return this.#id; - } - - set id(_id) { - if (typeof _id !== "number" && _id !== null) - console.warn( - "NewgroundsIO Type Mismatch: Value should be a number, got", - _id - ); - else if (!Number.isInteger(_id) && _id !== null) - console.warn( - "NewgroundsIO Type Mismatch: Value should be an integer, got a float" - ); - this.#id = Number(_id); - if (isNaN(this.#id)) this.#id = null; - } - - /** - * @private - */ - #value = null; - - /** - * The int value of the score. - * @type {Number} - */ - get value() { - return this.#value; - } - - set value(_value) { - if (typeof _value !== "number" && _value !== null) - console.warn( - "NewgroundsIO Type Mismatch: Value should be a number, got", - _value - ); - else if (!Number.isInteger(_value) && _value !== null) - console.warn( - "NewgroundsIO Type Mismatch: Value should be an integer, got a float" - ); - this.#value = Number(_value); - if (isNaN(this.#value)) this.#value = null; - } - - /** - * @private - */ - #tag = null; - - /** - * An optional tag that can be used to filter scores via ScoreBoard.getScores - * @type {String} - */ - get tag() { - return this.#tag; - } - - set tag(_tag) { - if (typeof _tag !== "string" && _tag !== null) - console.warn( - "NewgroundsIO Type Mismatch: Value should be a string, got", - _tag - ); - this.#tag = String(_tag); - } - } - - /** End Class NewgroundsIO.components.ScoreBoard.postScore **/ - if (typeof NewgroundsIO.components.ScoreBoard === "undefined") - NewgroundsIO.components.ScoreBoard = {}; - NewgroundsIO.components.ScoreBoard.postScore = postScore; - })(); - - /* ====================== ./NewgroundsIO-JS/src/NewgroundsIO/objects/Debug.js ====================== */ - - (() => { - /** Start NewgroundsIO.objects.Debug **/ - - class Debug extends NewgroundsIO.BaseObject { - /** - * Constructor - * @param {object} props An object of initial properties for this instance - * @param {String} props.exec_time The time, in milliseconds, that it took to execute a request. - * @param {NewgroundsIO.objects.Request} props.request A copy of the request object that was posted to the server. - */ - constructor(props) { - super(); - let _this = this; - - this.__object = "Debug"; - ["exec_time", "request"].forEach((prop) => { - if (_this.__properties.indexOf(prop) < 0) - _this.__properties.push(prop); - }); - if (props && typeof props === "object") { - for (var i = 0; i < this.__properties.length; i++) { - if (typeof props[this.__properties[i]] !== "undefined") - this[this.__properties[i]] = props[this.__properties[i]]; - } - } - } - - /** - * @private - */ - #exec_time = null; - - /** - * The time, in milliseconds, that it took to execute a request. - * @type {String} - */ - get exec_time() { - return this.#exec_time; - } - - set exec_time(_exec_time) { - if (typeof _exec_time !== "string" && _exec_time !== null) - console.warn( - "NewgroundsIO Type Mismatch: Value should be a string, got", - _exec_time - ); - this.#exec_time = String(_exec_time); - } - - /** - * @private - */ - #request = null; - - /** - * A copy of the request object that was posted to the server. - * @type {NewgroundsIO.objects.Request} - */ - get request() { - return this.#request; - } - - set request(_request) { - if ( - !(_request instanceof NewgroundsIO.objects.Request) && - typeof _request === "object" - ) - _request = new NewgroundsIO.objects.Request(_request); - - if ( - _request !== null && - !(_request instanceof NewgroundsIO.objects.Request) - ) - console.warn( - "Type Mismatch: expecting NewgroundsIO.objects.Request, got ", - _request - ); - - this.#request = _request; - } - - objectMap = { request: "Request" }; - } - - /** End Class NewgroundsIO.objects.Debug **/ - if (typeof NewgroundsIO.objects === "undefined") NewgroundsIO.objects = {}; - NewgroundsIO.objects.Debug = Debug; - })(); - - /* ====================== ./NewgroundsIO-JS/src/NewgroundsIO/objects/Error.js ====================== */ - - (() => { - /** Start NewgroundsIO.objects.Error **/ - - class Error extends NewgroundsIO.BaseObject { - /** - * Constructor - * @param {object} props An object of initial properties for this instance - * @param {String} props.message Contains details about the error. - * @param {Number} props.code A code indication the error type. - */ - constructor(props) { - super(); - let _this = this; - - this.__object = "Error"; - ["message", "code"].forEach((prop) => { - if (_this.__properties.indexOf(prop) < 0) - _this.__properties.push(prop); - }); - if (props && typeof props === "object") { - for (var i = 0; i < this.__properties.length; i++) { - if (typeof props[this.__properties[i]] !== "undefined") - this[this.__properties[i]] = props[this.__properties[i]]; - } - } - } - - /** - * @private - */ - #message = null; - - /** - * Contains details about the error. - * @type {String} - */ - get message() { - return this.#message; - } - - set message(_message) { - if (typeof _message !== "string" && _message !== null) - console.warn( - "NewgroundsIO Type Mismatch: Value should be a string, got", - _message - ); - this.#message = String(_message); - } - - /** - * @private - */ - #code = null; - - /** - * A code indication the error type. - * @type {Number} - */ - get code() { - return this.#code; - } - - set code(_code) { - if (typeof _code !== "number" && _code !== null) - console.warn( - "NewgroundsIO Type Mismatch: Value should be a number, got", - _code - ); - else if (!Number.isInteger(_code) && _code !== null) - console.warn( - "NewgroundsIO Type Mismatch: Value should be an integer, got a float" - ); - this.#code = Number(_code); - if (isNaN(this.#code)) this.#code = null; - } - } - - /** End Class NewgroundsIO.objects.Error **/ - if (typeof NewgroundsIO.objects === "undefined") NewgroundsIO.objects = {}; - NewgroundsIO.objects.Error = Error; - })(); - - /* ====================== ./NewgroundsIO-JS/src/NewgroundsIO/objects/Execute.js ====================== */ - - (() => { - /** Start NewgroundsIO.objects.Execute **/ - - class Execute extends NewgroundsIO.BaseObject { - /** - * Constructor - * @param {object} props An object of initial properties for this instance - * @param {String} props.component The name of the component you want to call, ie 'App.connect'. - * @param {(Object|Array.)} props.parameters An object of parameters you want to pass to the component. - * @param {String} props.secure A an encrypted NewgroundsIO.objects.Execute object or array of NewgroundsIO.objects.Execute objects. - * @param {mixed} props.echo An optional value that will be returned, verbatim, in the NewgroundsIO.objects.Result object. - */ - constructor(props) { - super(); - let _this = this; - - this.__object = "Execute"; - ["component", "parameters", "secure"].forEach((prop) => { - if (_this.__properties.indexOf(prop) < 0) - _this.__properties.push(prop); - }); - if (props && typeof props === "object") { - for (var i = 0; i < this.__properties.length; i++) { - if (typeof props[this.__properties[i]] !== "undefined") - this[this.__properties[i]] = props[this.__properties[i]]; - } - } - } - - /** - * @private - */ - #component = null; - - /** - * The name of the component you want to call, ie 'App.connect'. - * @type {String} - */ - get component() { - return this.#component; - } - - set component(_component) { - if (typeof _component !== "string" && _component !== null) - console.warn( - "NewgroundsIO Type Mismatch: Value should be a string, got", - _component - ); - this.#component = String(_component); - } - - /** - * @private - */ - #parameters = null; - - /** - * An object of parameters you want to pass to the component. - * @type {(Object|Array.)} - */ - get parameters() { - return this.#parameters; - } - - set parameters(_parameters) { - if (Array.isArray(_parameters)) { - let newArr = []; - _parameters.forEach(function (val, index) { - if (typeof val !== "object" && val !== null) - console.warn( - "NewgroundsIO Type Mismatch: Value should be a object, got", - val - ); - newArr[index] = val; - }); - this.#parameters = newArr; - return; - } - - if (typeof _parameters !== "object" && _parameters !== null) - console.warn( - "NewgroundsIO Type Mismatch: Value should be a object, got", - _parameters - ); - this.#parameters = _parameters; - } - - /** - * @private - */ - #secure = null; - - /** - * A an encrypted NewgroundsIO.objects.Execute object or array of NewgroundsIO.objects.Execute objects. - * @type {String} - */ - get secure() { - return this.#secure; - } - - set secure(_secure) { - if (typeof _secure !== "string" && _secure !== null) - console.warn( - "NewgroundsIO Type Mismatch: Value should be a string, got", - _secure - ); - this.#secure = String(_secure); - } - - /** - * @private - */ - #componentObject = null; - - /** - * Set a component object to execute - * @param {NewgroundsIO.BaseComponent} component Any NGIO component object - */ - setComponent(component) { - if (!(component instanceof NewgroundsIO.BaseComponent)) - console.error( - "NewgroundsIO Error: Expecting NewgroundsIO component, got " + - typeof component - ); - - this.#componentObject = component; - - // set the string name of the component; - this.component = component.__object; - this.parameters = component.toJSON(); - } - - /** - * Validate this object (overrides default valdator) - * @return {Boolean} - */ - isValid() { - // must have a component set - if (!this.component) { - console.error("NewgroundsIO Error: Missing required component!"); - } - - // must be linked to a core NewgroundsIO instance - if (!this.__ngioCore) { - console.error( - "NewgroundsIO Error: Must call setCore() before validating!" - ); - return false; - } - - // SHOULD have an actual component object. Validate that as well, if it exists - if (this.#componentObject) { - if ( - this.#componentObject.__requireSession && - !this.__ngioCore.session.isActive() - ) { - console.warn( - "NewgroundsIO Warning: " + - this.component + - " can only be used with a valid user session." - ); - this.__ngioCore.session.logProblems(); - return false; - } - - return ( - this.#componentObject instanceof NewgroundsIO.BaseComponent && - this.#componentObject.isValid() - ); - } - - return true; - } - - /** - * Override the default toJSON handler and use encryption on components that require it - * @return {object} A native JS object that can be converted to a JSON string - */ - toJSON() { - if (this.#componentObject && this.#componentObject.__isSecure) - return this.toSecureJSON(); - return super.toJSON(); - } - } - - /** End Class NewgroundsIO.objects.Execute **/ - if (typeof NewgroundsIO.objects === "undefined") NewgroundsIO.objects = {}; - NewgroundsIO.objects.Execute = Execute; - })(); - - /* ====================== ./NewgroundsIO-JS/src/NewgroundsIO/objects/Medal.js ====================== */ - - (() => { - /** Start NewgroundsIO.objects.Medal **/ - - class Medal extends NewgroundsIO.BaseObject { - /** - * Constructor - * @param {object} props An object of initial properties for this instance - * @param {Number} props.id The numeric ID of the medal. - * @param {String} props.name The name of the medal. - * @param {String} props.description A short description of the medal. - * @param {String} props.icon The URL for the medal's icon. - * @param {Number} props.value The medal's point value. - * @param {Number} props.difficulty The difficulty id of the medal. - * @param {Boolean} props.secret - * @param {Boolean} props.unlocked This will only be set if a valid user session exists. - */ - constructor(props) { - super(); - let _this = this; - - this.__object = "Medal"; - [ - "id", - "name", - "description", - "icon", - "value", - "difficulty", - "secret", - "unlocked", - ].forEach((prop) => { - if (_this.__properties.indexOf(prop) < 0) - _this.__properties.push(prop); - }); - if (props && typeof props === "object") { - for (var i = 0; i < this.__properties.length; i++) { - if (typeof props[this.__properties[i]] !== "undefined") - this[this.__properties[i]] = props[this.__properties[i]]; - } - } - } - - /** - * @private - */ - #id = null; - - /** - * The numeric ID of the medal. - * @type {Number} - */ - get id() { - return this.#id; - } - - set id(_id) { - if (typeof _id !== "number" && _id !== null) - console.warn( - "NewgroundsIO Type Mismatch: Value should be a number, got", - _id - ); - else if (!Number.isInteger(_id) && _id !== null) - console.warn( - "NewgroundsIO Type Mismatch: Value should be an integer, got a float" - ); - this.#id = Number(_id); - if (isNaN(this.#id)) this.#id = null; - } - - /** - * @private - */ - #name = null; - - /** - * The name of the medal. - * @type {String} - */ - get name() { - return this.#name; - } - - set name(_name) { - if (typeof _name !== "string" && _name !== null) - console.warn( - "NewgroundsIO Type Mismatch: Value should be a string, got", - _name - ); - this.#name = String(_name); - } - - /** - * @private - */ - #description = null; - - /** - * A short description of the medal. - * @type {String} - */ - get description() { - return this.#description; - } - - set description(_description) { - if (typeof _description !== "string" && _description !== null) - console.warn( - "NewgroundsIO Type Mismatch: Value should be a string, got", - _description - ); - this.#description = String(_description); - } - - /** - * @private - */ - #icon = null; - - /** - * The URL for the medal's icon. - * @type {String} - */ - get icon() { - return this.#icon; - } - - set icon(_icon) { - if (typeof _icon !== "string" && _icon !== null) - console.warn( - "NewgroundsIO Type Mismatch: Value should be a string, got", - _icon - ); - this.#icon = String(_icon); - } - - /** - * @private - */ - #value = null; - - /** - * The medal's point value. - * @type {Number} - */ - get value() { - return this.#value; - } - - set value(_value) { - if (typeof _value !== "number" && _value !== null) - console.warn( - "NewgroundsIO Type Mismatch: Value should be a number, got", - _value - ); - else if (!Number.isInteger(_value) && _value !== null) - console.warn( - "NewgroundsIO Type Mismatch: Value should be an integer, got a float" - ); - this.#value = Number(_value); - if (isNaN(this.#value)) this.#value = null; - } - - /** - * @private - */ - #difficulty = null; - - /** - * The difficulty id of the medal. - * @type {Number} - */ - get difficulty() { - return this.#difficulty; - } - - set difficulty(_difficulty) { - if (typeof _difficulty !== "number" && _difficulty !== null) - console.warn( - "NewgroundsIO Type Mismatch: Value should be a number, got", - _difficulty - ); - else if (!Number.isInteger(_difficulty) && _difficulty !== null) - console.warn( - "NewgroundsIO Type Mismatch: Value should be an integer, got a float" - ); - this.#difficulty = Number(_difficulty); - if (isNaN(this.#difficulty)) this.#difficulty = null; - } - - /** - * @private - */ - #secret = null; - - /** - * @type {Boolean} - */ - get secret() { - return this.#secret; - } - - set secret(_secret) { - if ( - typeof _secret !== "boolean" && - typeof _secret !== "number" && - _secret !== null - ) - console.warn( - "NewgroundsIO Type Mismatch: Value should be a boolean, got", - _secret - ); - this.#secret = _secret ? true : false; - } - - /** - * @private - */ - #unlocked = null; - - /** - * This will only be set if a valid user session exists. - * @type {Boolean} - */ - get unlocked() { - return this.#unlocked; - } - - set unlocked(_unlocked) { - if ( - typeof _unlocked !== "boolean" && - typeof _unlocked !== "number" && - _unlocked !== null - ) - console.warn( - "NewgroundsIO Type Mismatch: Value should be a boolean, got", - _unlocked - ); - this.#unlocked = _unlocked ? true : false; - } - - /** - * @callback responseCallback - * @param {NewgroundsIO.objects.Response} serverResponse - */ - - /** - * Unlocks this medal, then fires a callback. - * @param {responseCallback} callback An optional function to call when the medal is unlocked on the server. - * @param {object} thisArg An optional object to use as 'this' in your callback function. - */ - unlock(callback, thisArg) { - if (!this.__ngioCore) { - console.error( - "NewgroundsIO - Can not unlock medal object without attaching a NewgroundsIO.Core instance." - ); - return; - } - - var component = this.__ngioCore.getComponent("Medal.unlock", { - id: this.id, - }); - this.__ngioCore.executeComponent(component, callback, thisArg); - } - } - - /** End Class NewgroundsIO.objects.Medal **/ - if (typeof NewgroundsIO.objects === "undefined") NewgroundsIO.objects = {}; - NewgroundsIO.objects.Medal = Medal; - })(); - - /* ====================== ./NewgroundsIO-JS/src/NewgroundsIO/objects/Request.js ====================== */ - - (() => { - /** Start NewgroundsIO.objects.Request **/ - - class Request extends NewgroundsIO.BaseObject { - /** - * Constructor - * @param {object} props An object of initial properties for this instance - * @param {String} props.app_id Your application's unique ID. - * @param {(NewgroundsIO.objects.Execute|Array.)} props.execute A NewgroundsIO.objects.Execute object, or array of one-or-more NewgroundsIO.objects.Execute objects. - * @param {String} props.session_id An optional login session id. - * @param {Boolean} props.debug If set to true, calls will be executed in debug mode. - * @param {mixed} props.echo An optional value that will be returned, verbatim, in the NewgroundsIO.objects.Response object. - */ - constructor(props) { - super(); - let _this = this; - - this.__object = "Request"; - ["app_id", "execute", "session_id", "debug"].forEach((prop) => { - if (_this.__properties.indexOf(prop) < 0) - _this.__properties.push(prop); - }); - if (props && typeof props === "object") { - for (var i = 0; i < this.__properties.length; i++) { - if (typeof props[this.__properties[i]] !== "undefined") - this[this.__properties[i]] = props[this.__properties[i]]; - } - } - } - - /** - * @private - */ - #execute = null; - - /** - * A NewgroundsIO.objects.Execute object, or array of one-or-more NewgroundsIO.objects.Execute objects. - * @type {(NewgroundsIO.objects.Execute|Array.)} - */ - get execute() { - return this.#execute; - } - - set execute(_execute) { - if ( - !Array.isArray(_execute) && - !(_execute instanceof NewgroundsIO.objects.Execute) && - typeof _execute === "object" - ) - _execute = new NewgroundsIO.objects.Execute(_execute); - - if (Array.isArray(_execute)) { - let newArr = []; - _execute.forEach(function (val, index) { - if (val !== null && !(val instanceof NewgroundsIO.objects.Execute)) - console.warn( - "Type Mismatch: expecting NewgroundsIO.objects.Execute, got ", - val - ); - - newArr[index] = val; - }); - this.#execute = newArr; - return; - } - - if ( - _execute !== null && - !(_execute instanceof NewgroundsIO.objects.Execute) - ) - console.warn( - "Type Mismatch: expecting NewgroundsIO.objects.Execute, got ", - _execute - ); - - this.#execute = _execute; - } - - /** - * @private - */ - #debug = null; - - /** - * If set to true, calls will be executed in debug mode. - * @type {Boolean} - */ - get debug() { - return this.#debug; - } - - set debug(_debug) { - if ( - typeof _debug !== "boolean" && - typeof _debug !== "number" && - _debug !== null - ) - console.warn( - "NewgroundsIO Type Mismatch: Value should be a boolean, got", - _debug - ); - this.#debug = _debug ? true : false; - } - - objectMap = { execute: "Execute" }; - - arrayMap = { execute: "Execute" }; - - /** - * Gets the appID from a core object - * @returns {string} - */ - get app_id() { - return this.__ngioCore ? this.__ngioCore.appID : null; - } - - /** - * Gets the Session ID from a core object - * @returns {string} - */ - get session_id() { - return this.__ngioCore && this.__ngioCore.session - ? this.__ngioCore.session.id - : null; - } - } - - /** End Class NewgroundsIO.objects.Request **/ - if (typeof NewgroundsIO.objects === "undefined") NewgroundsIO.objects = {}; - NewgroundsIO.objects.Request = Request; - })(); - - /* ====================== ./NewgroundsIO-JS/src/NewgroundsIO/objects/Response.js ====================== */ - - (() => { - /** Start NewgroundsIO.objects.Response **/ - - class Response extends NewgroundsIO.BaseObject { - /** - * Constructor - * @param {object} props An object of initial properties for this instance - * @param {String} props.app_id Your application's unique ID - * @param {Boolean} props.success If false, there was a problem with your 'request' object. Details will be in the error property. - * @param {NewgroundsIO.objects.Debug} props.debug Contains extra information you may need when debugging (debug mode only). - * @param {(NewgroundsIO.BaseResult|Array.)} props.result This will be a NewgroundsIO.results.XXXXXX object, or an array containing one-or-more NewgroundsIO.results.XXXXXX objects. - * @param {NewgroundsIO.objects.Error} props.error This will contain any error info if the success property is false. - * @param {String} props.api_version If there was an error, this will contain the current version number of the API gateway. - * @param {String} props.help_url If there was an error, this will contain the URL for our help docs. - * @param {mixed} props.echo If you passed an 'echo' value in your request object, it will be echoed here. - */ - constructor(props) { - super(); - let _this = this; - - this.__object = "Response"; - [ - "app_id", - "success", - "debug", - "result", - "error", - "api_version", - "help_url", - ].forEach((prop) => { - if (_this.__properties.indexOf(prop) < 0) - _this.__properties.push(prop); - }); - if (props && typeof props === "object") { - for (var i = 0; i < this.__properties.length; i++) { - if (typeof props[this.__properties[i]] !== "undefined") - this[this.__properties[i]] = props[this.__properties[i]]; - } - } - } - - /** - * @private - */ - #app_id = null; - - /** - * Your application's unique ID - * @type {String} - */ - get app_id() { - return this.#app_id; - } - - set app_id(_app_id) { - if (typeof _app_id !== "string" && _app_id !== null) - console.warn( - "NewgroundsIO Type Mismatch: Value should be a string, got", - _app_id - ); - this.#app_id = String(_app_id); - } - - /** - * @private - */ - #success = null; - - /** - * If false, there was a problem with your 'request' object. Details will be in the error property. - * @type {Boolean} - */ - get success() { - return this.#success; - } - - set success(_success) { - if ( - typeof _success !== "boolean" && - typeof _success !== "number" && - _success !== null - ) - console.warn( - "NewgroundsIO Type Mismatch: Value should be a boolean, got", - _success - ); - this.#success = _success ? true : false; - } - - /** - * @private - */ - #debug = null; - - /** - * Contains extra information you may need when debugging (debug mode only). - * @type {NewgroundsIO.objects.Debug} - */ - get debug() { - return this.#debug; - } - - set debug(_debug) { - if ( - !(_debug instanceof NewgroundsIO.objects.Debug) && - typeof _debug === "object" - ) - _debug = new NewgroundsIO.objects.Debug(_debug); - - if (_debug !== null && !(_debug instanceof NewgroundsIO.objects.Debug)) - console.warn( - "Type Mismatch: expecting NewgroundsIO.objects.Debug, got ", - _debug - ); - - this.#debug = _debug; - } - - /** - * @private - */ - #result = null; - - /** - * This will be a NewgroundsIO.results.XXXXXX object, or an array containing one-or-more NewgroundsIO.results.XXXXXX objects. - * @type {(NewgroundsIO.BaseResult|Array.)} - */ - get result() { - return this.#result; - } - - set result(_result) { - if (Array.isArray(_result)) { - let newArr = []; - _result.forEach(function (val, index) { - if (!(val instanceof NewgroundsIO.BaseResult) && val !== null) - console.warn( - "NewgroundsIO Type Mismatch: Value should be a NewgroundsIO.results.XXXX instance, got", - val - ); - newArr[index] = val; - }); - this.#result = newArr; - return; - } - - if (!(_result instanceof NewgroundsIO.BaseResult) && _result !== null) - console.warn( - "NewgroundsIO Type Mismatch: Value should be a NewgroundsIO.results.XXXX instance, got", - _result - ); - this.#result = _result; - } - - /** - * @private - */ - #error = null; - - /** - * This will contain any error info if the success property is false. - * @type {NewgroundsIO.objects.Error} - */ - get error() { - return this.#error; - } - - set error(_error) { - if ( - !(_error instanceof NewgroundsIO.objects.Error) && - typeof _error === "object" - ) - _error = new NewgroundsIO.objects.Error(_error); - - if (_error !== null && !(_error instanceof NewgroundsIO.objects.Error)) - console.warn( - "Type Mismatch: expecting NewgroundsIO.objects.Error, got ", - _error - ); - - this.#error = _error; - } - - /** - * @private - */ - #api_version = null; - - /** - * If there was an error, this will contain the current version number of the API gateway. - * @type {String} - */ - get api_version() { - return this.#api_version; - } - - set api_version(_api_version) { - if (typeof _api_version !== "string" && _api_version !== null) - console.warn( - "NewgroundsIO Type Mismatch: Value should be a string, got", - _api_version - ); - this.#api_version = String(_api_version); - } - - /** - * @private - */ - #help_url = null; - - /** - * If there was an error, this will contain the URL for our help docs. - * @type {String} - */ - get help_url() { - return this.#help_url; - } - - set help_url(_help_url) { - if (typeof _help_url !== "string" && _help_url !== null) - console.warn( - "NewgroundsIO Type Mismatch: Value should be a string, got", - _help_url - ); - this.#help_url = String(_help_url); - } - - objectMap = { debug: "Debug", error: "Error" }; - } - - /** End Class NewgroundsIO.objects.Response **/ - if (typeof NewgroundsIO.objects === "undefined") NewgroundsIO.objects = {}; - NewgroundsIO.objects.Response = Response; - })(); - - /* ====================== ./NewgroundsIO-JS/src/NewgroundsIO/objects/SaveSlot.js ====================== */ - - (() => { - /** Start NewgroundsIO.objects.SaveSlot **/ - - class SaveSlot extends NewgroundsIO.BaseObject { - /** - * Constructor - * @param {object} props An object of initial properties for this instance - * @param {Number} props.id The slot number. - * @param {Number} props.size The size of the save data in bytes. - * @param {String} props.datetime A date and time (in ISO 8601 format) representing when this slot was last saved. - * @param {Number} props.timestamp A unix timestamp representing when this slot was last saved. - * @param {String} props.url The URL containing the actual save data for this slot, or null if this slot has no data. - */ - constructor(props) { - super(); - let _this = this; - - this.__object = "SaveSlot"; - ["id", "size", "datetime", "timestamp", "url"].forEach((prop) => { - if (_this.__properties.indexOf(prop) < 0) - _this.__properties.push(prop); - }); - if (props && typeof props === "object") { - for (var i = 0; i < this.__properties.length; i++) { - if (typeof props[this.__properties[i]] !== "undefined") - this[this.__properties[i]] = props[this.__properties[i]]; - } - } - } - - /** - * @private - */ - #id = null; - - /** - * The slot number. - * @type {Number} - */ - get id() { - return this.#id; - } - - set id(_id) { - if (typeof _id !== "number" && _id !== null) - console.warn( - "NewgroundsIO Type Mismatch: Value should be a number, got", - _id - ); - else if (!Number.isInteger(_id) && _id !== null) - console.warn( - "NewgroundsIO Type Mismatch: Value should be an integer, got a float" - ); - this.#id = Number(_id); - if (isNaN(this.#id)) this.#id = null; - } - - /** - * @private - */ - #size = null; - - /** - * The size of the save data in bytes. - * @type {Number} - */ - get size() { - return this.#size; - } - - set size(_size) { - if (typeof _size !== "number" && _size !== null) - console.warn( - "NewgroundsIO Type Mismatch: Value should be a number, got", - _size - ); - else if (!Number.isInteger(_size) && _size !== null) - console.warn( - "NewgroundsIO Type Mismatch: Value should be an integer, got a float" - ); - this.#size = Number(_size); - if (isNaN(this.#size)) this.#size = null; - } - - /** - * @private - */ - #datetime = null; - - /** - * A date and time (in ISO 8601 format) representing when this slot was last saved. - * @type {String} - */ - get datetime() { - return this.#datetime; - } - - set datetime(_datetime) { - if (typeof _datetime !== "string" && _datetime !== null) - console.warn( - "NewgroundsIO Type Mismatch: Value should be a string, got", - _datetime - ); - this.#datetime = String(_datetime); - } - - /** - * @private - */ - #timestamp = null; - - /** - * A unix timestamp representing when this slot was last saved. - * @type {Number} - */ - get timestamp() { - return this.#timestamp; - } - - set timestamp(_timestamp) { - if (typeof _timestamp !== "number" && _timestamp !== null) - console.warn( - "NewgroundsIO Type Mismatch: Value should be a number, got", - _timestamp - ); - else if (!Number.isInteger(_timestamp) && _timestamp !== null) - console.warn( - "NewgroundsIO Type Mismatch: Value should be an integer, got a float" - ); - this.#timestamp = Number(_timestamp); - if (isNaN(this.#timestamp)) this.#timestamp = null; - } - - /** - * @private - */ - #url = null; - - /** - * The URL containing the actual save data for this slot, or null if this slot has no data. - * @type {String} - */ - get url() { - return this.#url; - } - - set url(_url) { - if (typeof _url !== "string" && _url !== null) - console.warn( - "NewgroundsIO Type Mismatch: Value should be a string, got", - _url - ); - this.#url = String(_url); - } - - /** - * @callback getDataCallback - * @param {string} data The data loaded from the server - */ - - /** - * @callback responseCallback - * @param {NewgroundsIO.objects.Response} serverResponse - */ - - /** - * This will be true if this save slot has any saved data. - */ - get hasData() { - return this.url !== null; - } - - /** - * Loads the save file for this slot then passes its contents to a callback function. - * @param {getDataCallback} callback A function to call when your data is loaded. - * @param {object} thisArg An optional object to use as 'this' in your callback function. - */ - getData(callback, thisArg) { - if (typeof callback !== "function") { - console.error("NewgroundsIO - Missing required callback function"); - return; - } - - Scratch.canFetch(this.url).then((allowed) => { - if (!allowed) return callback(null); - var xhr = new XMLHttpRequest(); - xhr.onreadystatechange = function () { - if (xhr.readyState == 4) { - if (thisArg) callback.call(thisArg, xhr.responseText); - else callback(xhr.responseText); - } - }; - xhr.open("GET", this.url, true); - xhr.send(); - }); - } - - /** - * Unlocks this medal, then fires a callback. - * @param {string} data The data, in a serialized string, you want to save. - * @param {responseCallback} callback An optional function to call when the data is saved on the server. - * @param {object} thisArg An optional object to use as 'this' in your callback function. - */ - setData(data, callback, thisArg) { - if (!this.__ngioCore) { - console.error( - "NewgroundsIO - Can not save data without attaching a NewgroundsIO.Core instance." - ); - return; - } - - var component = this.__ngioCore.getComponent("CloudSave.setData", { - id: this.id, - data: data, - }); - this.__ngioCore.executeComponent(component, callback, thisArg); - } - - /** - * Clears all data from this slot, then fires a callback - * @param {responseCallback} callback An optional function to call when the data is cleared from the server. - * @param {object} thisArg An optional object to use as 'this' in your callback function. - */ - clearData(callback, thisArg) { - if (!this.__ngioCore) { - console.error( - "NewgroundsIO - Can not clear data without attaching a NewgroundsIO.Core instance." - ); - return; - } - this.#url = null; - var component = this.__ngioCore.getComponent("CloudSave.clearSlot", { - id: this.id, - }); - this.__ngioCore.executeComponent(component, callback, thisArg); - } - - /** - * Gets the date this slot was last updated. - * @return {Date} - */ - getDate() { - if (this.hasData) return new Date(this.datetime); - return null; - } - } - - /** End Class NewgroundsIO.objects.SaveSlot **/ - if (typeof NewgroundsIO.objects === "undefined") NewgroundsIO.objects = {}; - NewgroundsIO.objects.SaveSlot = SaveSlot; - })(); - - /* ====================== ./NewgroundsIO-JS/src/NewgroundsIO/objects/Score.js ====================== */ - - (() => { - /** Start NewgroundsIO.objects.Score **/ - - class Score extends NewgroundsIO.BaseObject { - /** - * Constructor - * @param {object} props An object of initial properties for this instance - * @param {NewgroundsIO.objects.User} props.user The user who earned score. If this property is absent, the score belongs to the active user. - * @param {Number} props.value The integer value of the score. - * @param {String} props.formatted_value The score value in the format selected in your scoreboard settings. - * @param {String} props.tag The tag attached to this score (if any). - */ - constructor(props) { - super(); - let _this = this; - - this.__object = "Score"; - ["user", "value", "formatted_value", "tag"].forEach((prop) => { - if (_this.__properties.indexOf(prop) < 0) - _this.__properties.push(prop); - }); - if (props && typeof props === "object") { - for (var i = 0; i < this.__properties.length; i++) { - if (typeof props[this.__properties[i]] !== "undefined") - this[this.__properties[i]] = props[this.__properties[i]]; - } - } - } - - /** - * @private - */ - #user = null; - - /** - * The user who earned score. If this property is absent, the score belongs to the active user. - * @type {NewgroundsIO.objects.User} - */ - get user() { - return this.#user; - } - - set user(_user) { - if ( - !(_user instanceof NewgroundsIO.objects.User) && - typeof _user === "object" - ) - _user = new NewgroundsIO.objects.User(_user); - - if (_user !== null && !(_user instanceof NewgroundsIO.objects.User)) - console.warn( - "Type Mismatch: expecting NewgroundsIO.objects.User, got ", - _user - ); - - this.#user = _user; - } - - /** - * @private - */ - #value = null; - - /** - * The integer value of the score. - * @type {Number} - */ - get value() { - return this.#value; - } - - set value(_value) { - if (typeof _value !== "number" && _value !== null) - console.warn( - "NewgroundsIO Type Mismatch: Value should be a number, got", - _value - ); - else if (!Number.isInteger(_value) && _value !== null) - console.warn( - "NewgroundsIO Type Mismatch: Value should be an integer, got a float" - ); - this.#value = Number(_value); - if (isNaN(this.#value)) this.#value = null; - } - - /** - * @private - */ - #formatted_value = null; - - /** - * The score value in the format selected in your scoreboard settings. - * @type {String} - */ - get formatted_value() { - return this.#formatted_value; - } - - set formatted_value(_formatted_value) { - if (typeof _formatted_value !== "string" && _formatted_value !== null) - console.warn( - "NewgroundsIO Type Mismatch: Value should be a string, got", - _formatted_value - ); - this.#formatted_value = String(_formatted_value); - } - - /** - * @private - */ - #tag = null; - - /** - * The tag attached to this score (if any). - * @type {String} - */ - get tag() { - return this.#tag; - } - - set tag(_tag) { - if (typeof _tag !== "string" && _tag !== null) - console.warn( - "NewgroundsIO Type Mismatch: Value should be a string, got", - _tag - ); - this.#tag = String(_tag); - } - - objectMap = { user: "User" }; - } - - /** End Class NewgroundsIO.objects.Score **/ - if (typeof NewgroundsIO.objects === "undefined") NewgroundsIO.objects = {}; - NewgroundsIO.objects.Score = Score; - })(); - - /* ====================== ./NewgroundsIO-JS/src/NewgroundsIO/objects/ScoreBoard.js ====================== */ - - (() => { - /** Start NewgroundsIO.objects.ScoreBoard **/ - - class ScoreBoard extends NewgroundsIO.BaseObject { - /** - * Constructor - * @param {object} props An object of initial properties for this instance - * @param {Number} props.id The numeric ID of the scoreboard. - * @param {String} props.name The name of the scoreboard. - */ - constructor(props) { - super(); - let _this = this; - - this.__object = "ScoreBoard"; - ["id", "name"].forEach((prop) => { - if (_this.__properties.indexOf(prop) < 0) - _this.__properties.push(prop); - }); - if (props && typeof props === "object") { - for (var i = 0; i < this.__properties.length; i++) { - if (typeof props[this.__properties[i]] !== "undefined") - this[this.__properties[i]] = props[this.__properties[i]]; - } - } - } - - /** - * @private - */ - #id = null; - - /** - * The numeric ID of the scoreboard. - * @type {Number} - */ - get id() { - return this.#id; - } - - set id(_id) { - if (typeof _id !== "number" && _id !== null) - console.warn( - "NewgroundsIO Type Mismatch: Value should be a number, got", - _id - ); - else if (!Number.isInteger(_id) && _id !== null) - console.warn( - "NewgroundsIO Type Mismatch: Value should be an integer, got a float" - ); - this.#id = Number(_id); - if (isNaN(this.#id)) this.#id = null; - } - - /** - * @private - */ - #name = null; - - /** - * The name of the scoreboard. - * @type {String} - */ - get name() { - return this.#name; - } - - set name(_name) { - if (typeof _name !== "string" && _name !== null) - console.warn( - "NewgroundsIO Type Mismatch: Value should be a string, got", - _name - ); - this.#name = String(_name); - } - - /** - * @callback responseCallback - * @param {NewgroundsIO.objects.Response} serverResponse - */ - - /** - * Unlocks this medal, then fires a callback. - * @param {object} options Options for what scores to look up. - * @param {string} options.period The overall period to retrieve from. Can be D, W, M, Y or A. - * @param {string} options.tag An optional tag to filter on. - * @param {boolean} options.social Set to true to only see scores from friends. - * @param {Number} options.skip The number of scores to skip. - * @param {Number} options.limit The total number of scores to load. - * @param {responseCallback} callback An function to call when the scores have been loaded. - * @param {object} thisArg An optional object to use as 'this' in your callback function. - */ - getScores(options, callback, thisArg) { - if (!this.__ngioCore) { - console.error( - "NewgroundsIO - Can not get scores without attaching a NewgroundsIO.Core instance." - ); - return; - } - - // if not using options, 2nd and 3rd params can be used for callback and thisArg - if (typeof options === "function") { - thisArg = callback; - callback = options; - options = {}; - } - - if (!options) options = {}; - options.id = this.id; - - var component = this.__ngioCore.getComponent( - "ScoreBoard.getScores", - options - ); - this.__ngioCore.executeComponent(component, callback, thisArg); - } - - /** - * Posts a score to the scoreboard. - * @param {number} value The value to post. - * @param {string} tag An optional tag to filter on. - * @param {responseCallback} callback An optional function to call when the score is posted to the server. - * @param {object} thisArg An optional object to use as 'this' in your callback function. - */ - postScore(value, tag, callback, thisArg) { - if (!this.__ngioCore) { - console.error( - "NewgroundsIO - Can not post scores without attaching a NewgroundsIO.Core instance." - ); - return; - } - - // if not using a tag, 2nd and 3rd params can be used for callback and thisArg - if (typeof tag == "function") { - thisArg = callback; - callback = tag; - tag = null; - } - - var component = this.__ngioCore.getComponent("ScoreBoard.postScore", { - id: this.id, - value: value, - tag: tag, - }); - this.__ngioCore.executeComponent(component, callback, thisArg); - } - } - - /** End Class NewgroundsIO.objects.ScoreBoard **/ - if (typeof NewgroundsIO.objects === "undefined") NewgroundsIO.objects = {}; - NewgroundsIO.objects.ScoreBoard = ScoreBoard; - })(); - - /* ====================== ./NewgroundsIO-JS/src/NewgroundsIO/objects/Session.js ====================== */ - - (() => { - /** Start NewgroundsIO.objects.Session **/ - - class Session extends NewgroundsIO.BaseObject { - /** - * Constructor - * @param {object} props An object of initial properties for this instance - * @param {String} props.id A unique session identifier - * @param {NewgroundsIO.objects.User} props.user If the user has not signed in, or granted access to your app, this will be null - * @param {Boolean} props.expired If true, the session_id is expired. Use App.startSession to get a new one. - * @param {Boolean} props.remember If true, the user would like you to remember their session id. - * @param {String} props.passport_url If the session has no associated user but is not expired, this property will provide a URL that can be used to sign the user in. - */ - constructor(props) { - super(); - let _this = this; - - this.__object = "Session"; - ["id", "user", "expired", "remember", "passport_url"].forEach( - (prop) => { - if (_this.__properties.indexOf(prop) < 0) - _this.__properties.push(prop); - } - ); - if (props && typeof props === "object") { - for (var i = 0; i < this.__properties.length; i++) { - if (typeof props[this.__properties[i]] !== "undefined") - this[this.__properties[i]] = props[this.__properties[i]]; - } - } - } - - /** - * @private - */ - #id = null; - - /** - * A unique session identifier - * @type {String} - */ - get id() { - return this.#id; - } - - set id(_id) { - if (typeof _id !== "string" && _id !== null) - console.warn( - "NewgroundsIO Type Mismatch: Value should be a string, got", - _id - ); - this.#id = String(_id); - } - - /** - * @private - */ - #user = null; - - /** - * If the user has not signed in, or granted access to your app, this will be null - * @type {NewgroundsIO.objects.User} - */ - get user() { - return this.#user; - } - - set user(_user) { - if ( - !(_user instanceof NewgroundsIO.objects.User) && - typeof _user === "object" - ) - _user = new NewgroundsIO.objects.User(_user); - - if (_user !== null && !(_user instanceof NewgroundsIO.objects.User)) - console.warn( - "Type Mismatch: expecting NewgroundsIO.objects.User, got ", - _user - ); - - this.#user = _user; - } - - /** - * @private - */ - #expired = null; - - /** - * If true, the session_id is expired. Use App.startSession to get a new one. - * @type {Boolean} - */ - get expired() { - return this.#expired; - } - - set expired(_expired) { - if ( - typeof _expired !== "boolean" && - typeof _expired !== "number" && - _expired !== null - ) - console.warn( - "NewgroundsIO Type Mismatch: Value should be a boolean, got", - _expired - ); - this.#expired = _expired ? true : false; - } - - /** - * @private - */ - #remember = null; - - /** - * If true, the user would like you to remember their session id. - * @type {Boolean} - */ - get remember() { - return this.#remember; - } - - set remember(_remember) { - if ( - typeof _remember !== "boolean" && - typeof _remember !== "number" && - _remember !== null - ) - console.warn( - "NewgroundsIO Type Mismatch: Value should be a boolean, got", - _remember - ); - this.#remember = _remember ? true : false; - } - - /** - * @private - */ - #passport_url = null; - - /** - * If the session has no associated user but is not expired, this property will provide a URL that can be used to sign the user in. - * @type {String} - */ - get passport_url() { - return this.#passport_url; - } - - set passport_url(_passport_url) { - if (typeof _passport_url !== "string" && _passport_url !== null) - console.warn( - "NewgroundsIO Type Mismatch: Value should be a string, got", - _passport_url - ); - this.#passport_url = String(_passport_url); - } - - objectMap = { user: "User" }; - - /** - * The current state of this session. - * @private - */ - #status = NewgroundsIO.SessionState.SESSION_UNINITIALIZED; - - /** - * The status from the last time update() was called. - * @private - */ - #lastStatus = null; - - /** - * Will be true if the status was changed on an update call. - * @private - */ - #statusChanged = false; - - /** - * The last time update() was called. (Start in the past so update() will work immediately.) - * @private - */ - #lastUpdate = new Date(new Date().getTime() - 30000); - - /** - * If false, update() will end immediately when called. - * @private - */ - #canUpdate = true; - - /** - * The mode we'll use to check the status of this session. - * @private - */ - #mode = "expired"; - - /** - * The total number of attempts we've tried to contact the server without success. - * @private - */ - #totalAttempts = 0; - - /** - * TThe max number of attempts we can make to the server without success before we give up. - * @private - */ - #maxAttempts = 5; - - /** - * Stores a session ID from the game's URI if hosted on Newgrounds. - * @private - */ - #uri_id = null; - - /** - * Stores a session ID that was saved from a Passport login. - * @private - */ - #saved_id = null; - - /** - * @callback responseCallback - * @param {NewgroundsIO.objects.Response} serverResponse - */ - - /** - * The current state of this session. - * @type {string} - */ - get status() { - return this.#status; - } - - /** - * Will be true if the session state changed the last time update() was called. - * @type {boolean} - */ - get statusChanged() { - return this.#statusChanged; - } - - /** - * Will be true if the current state is one where we are waiting for something to happen. - * @type {boolean} - */ - get waiting() { - return this.#lastStatus != this.status; - } - - /** - * The localStorage key used to save a session id. - * @type {boolean} - */ - get storageKey() { - return this.__ngioCore - ? "_ngio_" + this.__ngioCore.appID + "_session_" - : null; - } - - /** - * resets everything except the session id. - * @private - */ - resetSession() { - this.#uri_id = null; - this.#saved_id = null; - this.remember = false; - this.user = null; - this.expired = false; - - localStorage.setItem(this.storageKey, null); - } - - /** - * Opens the Newgrounds Passport login page in a new browser tab. - */ - openLoginPage() { - if (!this.passport_url) { - console.warn( - "Can't open passport without getting a valis session first." - ); - return; - } - - this.#status = NewgroundsIO.SessionState.WAITING_FOR_USER; - this.mode = "check"; - - Scratch.openWindow(this.passport_url); - } - - /** - * Logs the user out of their current session, locally and on the server, then calls a function when complete. - * @param {responseCallback} callback The callback function. - * @param {object} thisArg An optional object to use as 'this' in your callback function. - */ - logOut(callback, thisArg) { - this.mode = "wait"; - this.endSession(callback, thisArg); - } - - /** - * Cancels a pending login attempt. - * @param {function} newStatus An optional status code to use if LOGIN_CANCELLED is insufficient. - */ - cancelLogin(newStatus) { - this.endSession(); - if (typeof newStatus === "undefined") - newStatus = NewgroundsIO.SessionState.LOGIN_CANCELLED; - - // clear the current session data, and set the appropriate cancel status - this.resetSession(); - this.id = null; - this.#status = newStatus; - - // this was a manual cancel, so we can reset the retry counter - this.#totalAttempts = 0; - - // this was a manual cancel, so we can reset the retry counter - this.#mode = "new"; - this.#lastUpdate = new Date(new Date().getTime() - 30000); - } - - /** - * @callback updateCallback - * @param {string} status - */ - - /** - * Call this to update the session process and call a function if there are any changes. - * @param {updateCallback} callback The callback function. - * @param {object} thisArg An optional object to use as 'this' in your callback function. - */ - update(callback, thisArg) { - this.#statusChanged = false; - - if (this.#lastStatus != this.status) { - this.#statusChanged = true; - this.#lastStatus = this.status; - if (typeof callback === "function") { - if (thisArg) callback.call(thisArg, this); - else callback(this); - } - } - - // we can skip this whole routine if we're in the middle of checking things - if (!this.#canUpdate || this.mode == "wait") return; - if (!this.__ngioCore) { - console.error( - "NewgroundsIO - Can't update session without attaching a NewgroundsIO.Core instance." - ); - this.#canUpdate = false; - return; - } - - // Server is not responding as expected, it may be down... We'll set the session back to unintialized and try again - if (this.status == NewgroundsIO.SessionState.SERVER_UNAVAILABLE) { - // we've had too many failed attempts, time to stop retrying - if (this.#totalAttempts >= this.#maxAttempts) { - this.#status = NewgroundsIO.SessionState.EXCEEDED_MAX_ATTEMPTS; - - // next time our delay time has passed, we'll reset this, and try our sessions again - } else { - this.#status = NewgroundsIO.SessionState.SESSION_UNINITIALIZED; - this.#totalAttempts++; - } - } - - // first time getting here (probably). We need to see if we have any existing session data to try... - if (this.status == NewgroundsIO.SessionState.SESSION_UNINITIALIZED) { - this.#saved_id = localStorage.getItem(this.storageKey); - - // check if we have a session id from our URL params (hosted on Newgrounds) - if (this.#uri_id) { - this.id = this.#uri_id; - - // check if we have a saved session (hosted elsewhere or standalone app) - } else if (this.#saved_id) { - this.id = this.#saved_id; - } - - // If we have an existing session, we'll use "check" mode to varify it, otherwise we'll nequest a "new" one. - this.mode = this.id && this.id !== "null" ? "check" : "new"; - } - - // make sure at least 5 seconds pass between each API call so we don't get blocked by DDOS protection. - var _now = new Date(); - var wait = _now - this.#lastUpdate; - if (wait < 5000) return; - - this.#lastUpdate = _now; - - switch (this.mode) { - // we don't have an existing session, so we're requesting a new one - case "new": - // change our mode to wait so the coroutine can finish before we make ny other API calls - this.mode = "wait"; - this.startSession(); - break; - - // we have a session, we just need to check and see if there's a valid login attached to it - case "check": - // change our mode to wait so the coroutine can finish before we make ny other API calls - this.mode = "wait"; - this.checkSession(); - break; - } - } - - // =================================== API CALLS/HANDLERS =================================== // - - /* App.startSession */ - - /** - * This will reset our current session object, then make the API call to get a new session. - */ - startSession() { - // don't check for any new updates while we're starting the new session - this.#canUpdate = false; - - // clear out any pre-existing session data - this.resetSession(); - - this.#status = NewgroundsIO.SessionState.WAITING_FOR_SERVER; - - var startSession = this.__ngioCore.getComponent("App.startSession"); - this.__ngioCore.executeComponent( - startSession, - this._onStartSession, - this - ); - } - - /** - * Handles the acquisition of a new session id from the server. - * @private - */ - _onStartSession(response) { - // The start session request was successful! - if (response.success === true) { - let result = response.result; - - if (Array.isArray(result)) { - for (let i = 0; i < result.length; i++) { - if ( - result[i] && - result[i].__object && - result[i].__object == "App.startSession" - ) { - result = result[i]; - break; - } - } - } - - // save the new session data to this session object - this.id = result.session.id; - this.passport_url = result.session.passport_url; - - // update our session status. This will trigger the callback in our update loop. - this.#status = NewgroundsIO.SessionState.LOGIN_REQUIRED; - - // The update loop needs to wait until the user clicks a login button - this.mode = "wait"; - - // Something went wrong! (Good chance the servers are down) - } else { - this.#status = NewgroundsIO.SessionState.SERVER_UNAVAILABLE; - } - - // Let our update loop know it can actually do stuff again - this.#canUpdate = true; - } - - /* App.checkSession */ - - /** - * This will call the API to see what the status of our current session is - */ - checkSession() { - // don't check for any new updates while we're checking session - this.#canUpdate = false; - - var checkSession = this.__ngioCore.getComponent("App.checkSession"); - this.__ngioCore.executeComponent( - checkSession, - this._onCheckSession, - this - ); - } - - /** - * Handles the response to checkSession. This may lead to a change in status if the user has signed in, - * cancelled, or the session has expired. - * @private - */ - _onCheckSession(response) { - // The API request was successful - if (response.success === true) { - // Our session either failed, or the user cancelled the login on the server. - if (!response.result.success) { - // clear our id, and cancel the login attempt - this.id = null; - this.cancelLogin( - response.result.error.code === 111 - ? NewgroundsIO.SessionState.LOGIN_CANCELLED - : NewgroundsIO.SessionState.LOGIN_FAILED - ); - } else { - // The session is expired - if (response.result.session.expired) { - // reset the session so it's like we never had one - this.resetSession(); - this.id = null; - this.#status = NewgroundsIO.SessionState.SESSION_UNINITIALIZED; - - // we have a valid user login attached! - } else if (response.result.session.user !== null) { - // store the user info, and update status - this.user = response.result.session.user; - this.#status = NewgroundsIO.SessionState.LOGIN_SUCCESSFUL; - this.mode = "valid"; - - // if the user selected to remember the login, save it now! - if (response.result.session.remember) { - this.#saved_id = this.id; - this.remember = true; - localStorage.setItem(this.storageKey, this.id); - } - - // Nothing has changed, we'll have to check again in the next loop. - } else { - this.mode = "check"; - } - } - } else { - // Something went wrong! Servers may be down, or you got blocked for sending too many requests - this.#status = NewgroundsIO.SessionState.SERVER_UNAVAILABLE; - } - - // Let our update loop know it can actually do stuff again - this.#canUpdate = true; - } - - /* App.endSession */ - - /** - * This will end the current session on the server - * @param {responseCallback} callback The callback function. - * @param {object} thisArg An optional object to use as 'this' in your callback function. - */ - endSession(callback, thisArg) { - // don't check for any new updates while we're ending session - this.#canUpdate = false; - - var endSession = this.__ngioCore.getComponent("App.endSession"); - var startSession = this.__ngioCore.getComponent("App.startSession"); - - this.__ngioCore.queueComponent(endSession); - this.__ngioCore.queueComponent(startSession); - - this.__ngioCore.executeQueue(function (response) { - this._onEndSession(response); - this._onStartSession(response); - if (typeof callback === "function") { - if (thisArg) callback.call(thisArg, this); - else callback(this); - } - }, this); - - /* - this.__ngioCore.executeComponent(endSession, function(response) { - this._onEndSession(response); - if (typeof(callback) === "function") { - if (thisArg) callback.call(thisArg, this); - else callback(this); - } - }, this); - */ - } - - /** - * Handler for endSession. Resets the session locally - * @private - */ - _onEndSession(response) { - // We'll just clear out the whole session, even if something failed. - this.resetSession(); - this.id = null; - this.user = null; - this.passport_url = null; - this.mode = "new"; - this.#status = NewgroundsIO.SessionState.USER_LOGGED_OUT; - - // Let our update loop know it can actually do stuff again - this.#canUpdate = true; - } - } - - /** End Class NewgroundsIO.objects.Session **/ - if (typeof NewgroundsIO.objects === "undefined") NewgroundsIO.objects = {}; - NewgroundsIO.objects.Session = Session; - })(); - - /* ====================== ./NewgroundsIO-JS/src/NewgroundsIO/objects/User.js ====================== */ - - (() => { - /** Start NewgroundsIO.objects.User **/ - - class User extends NewgroundsIO.BaseObject { - /** - * Constructor - * @param {object} props An object of initial properties for this instance - * @param {Number} props.id The user's numeric ID. - * @param {String} props.name The user's textual name. - * @param {NewgroundsIO.objects.UserIcons} props.icons The user's icon images. - * @param {Boolean} props.supporter Returns true if the user has a Newgrounds Supporter upgrade. - */ - constructor(props) { - super(); - let _this = this; - - this.__object = "User"; - ["id", "name", "icons", "supporter"].forEach((prop) => { - if (_this.__properties.indexOf(prop) < 0) - _this.__properties.push(prop); - }); - if (props && typeof props === "object") { - for (var i = 0; i < this.__properties.length; i++) { - if (typeof props[this.__properties[i]] !== "undefined") - this[this.__properties[i]] = props[this.__properties[i]]; - } - } - } - - /** - * @private - */ - #id = null; - - /** - * The user's numeric ID. - * @type {Number} - */ - get id() { - return this.#id; - } - - set id(_id) { - if (typeof _id !== "number" && _id !== null) - console.warn( - "NewgroundsIO Type Mismatch: Value should be a number, got", - _id - ); - else if (!Number.isInteger(_id) && _id !== null) - console.warn( - "NewgroundsIO Type Mismatch: Value should be an integer, got a float" - ); - this.#id = Number(_id); - if (isNaN(this.#id)) this.#id = null; - } - - /** - * @private - */ - #name = null; - - /** - * The user's textual name. - * @type {String} - */ - get name() { - return this.#name; - } - - set name(_name) { - if (typeof _name !== "string" && _name !== null) - console.warn( - "NewgroundsIO Type Mismatch: Value should be a string, got", - _name - ); - this.#name = String(_name); - } - - /** - * @private - */ - #icons = null; - - /** - * The user's icon images. - * @type {NewgroundsIO.objects.UserIcons} - */ - get icons() { - return this.#icons; - } - - set icons(_icons) { - if ( - !(_icons instanceof NewgroundsIO.objects.UserIcons) && - typeof _icons === "object" - ) - _icons = new NewgroundsIO.objects.UserIcons(_icons); - - if ( - _icons !== null && - !(_icons instanceof NewgroundsIO.objects.UserIcons) - ) - console.warn( - "Type Mismatch: expecting NewgroundsIO.objects.UserIcons, got ", - _icons - ); - - this.#icons = _icons; - } - - /** - * @private - */ - #supporter = null; - - /** - * Returns true if the user has a Newgrounds Supporter upgrade. - * @type {Boolean} - */ - get supporter() { - return this.#supporter; - } - - set supporter(_supporter) { - if ( - typeof _supporter !== "boolean" && - typeof _supporter !== "number" && - _supporter !== null - ) - console.warn( - "NewgroundsIO Type Mismatch: Value should be a boolean, got", - _supporter - ); - this.#supporter = _supporter ? true : false; - } - - objectMap = { icons: "UserIcons" }; - } - - /** End Class NewgroundsIO.objects.User **/ - if (typeof NewgroundsIO.objects === "undefined") NewgroundsIO.objects = {}; - NewgroundsIO.objects.User = User; - })(); - - /* ====================== ./NewgroundsIO-JS/src/NewgroundsIO/objects/UserIcons.js ====================== */ - - (() => { - /** Start NewgroundsIO.objects.UserIcons **/ - - class UserIcons extends NewgroundsIO.BaseObject { - /** - * Constructor - * @param {object} props An object of initial properties for this instance - * @param {String} props.small The URL of the user's small icon - * @param {String} props.medium The URL of the user's medium icon - * @param {String} props.large The URL of the user's large icon - */ - constructor(props) { - super(); - let _this = this; - - this.__object = "UserIcons"; - ["small", "medium", "large"].forEach((prop) => { - if (_this.__properties.indexOf(prop) < 0) - _this.__properties.push(prop); - }); - if (props && typeof props === "object") { - for (var i = 0; i < this.__properties.length; i++) { - if (typeof props[this.__properties[i]] !== "undefined") - this[this.__properties[i]] = props[this.__properties[i]]; - } - } - } - - /** - * @private - */ - #small = null; - - /** - * The URL of the user's small icon - * @type {String} - */ - get small() { - return this.#small; - } - - set small(_small) { - if (typeof _small !== "string" && _small !== null) - console.warn( - "NewgroundsIO Type Mismatch: Value should be a string, got", - _small - ); - this.#small = String(_small); - } - - /** - * @private - */ - #medium = null; - - /** - * The URL of the user's medium icon - * @type {String} - */ - get medium() { - return this.#medium; - } - - set medium(_medium) { - if (typeof _medium !== "string" && _medium !== null) - console.warn( - "NewgroundsIO Type Mismatch: Value should be a string, got", - _medium - ); - this.#medium = String(_medium); - } - - /** - * @private - */ - #large = null; - - /** - * The URL of the user's large icon - * @type {String} - */ - get large() { - return this.#large; - } - - set large(_large) { - if (typeof _large !== "string" && _large !== null) - console.warn( - "NewgroundsIO Type Mismatch: Value should be a string, got", - _large - ); - this.#large = String(_large); - } - } - - /** End Class NewgroundsIO.objects.UserIcons **/ - if (typeof NewgroundsIO.objects === "undefined") NewgroundsIO.objects = {}; - NewgroundsIO.objects.UserIcons = UserIcons; - })(); - - /* ====================== ./NewgroundsIO-JS/src/NewgroundsIO/results/App/checkSession.js ====================== */ - - (() => { - /** Start NewgroundsIO.results.App.checkSession **/ - - class checkSession extends NewgroundsIO.BaseResult { - /** - * Constructor - * @param {object} props An object of initial properties for this instance - * @param {NewgroundsIO.objects.Session} props.session - */ - constructor(props) { - super(); - let _this = this; - - this.__object = "App.checkSession"; - ["session"].forEach((prop) => { - if (_this.__properties.indexOf(prop) < 0) - _this.__properties.push(prop); - }); - if (props && typeof props === "object") { - for (var i = 0; i < this.__properties.length; i++) { - if (typeof props[this.__properties[i]] !== "undefined") - this[this.__properties[i]] = props[this.__properties[i]]; - } - } - } - - /** - * @private - */ - #session = null; - - /** - * @type {NewgroundsIO.objects.Session} - */ - get session() { - return this.#session; - } - - set session(_session) { - if ( - !(_session instanceof NewgroundsIO.objects.Session) && - typeof _session === "object" - ) - _session = new NewgroundsIO.objects.Session(_session); - - if ( - _session !== null && - !(_session instanceof NewgroundsIO.objects.Session) - ) - console.warn( - "Type Mismatch: expecting NewgroundsIO.objects.Session, got ", - _session - ); - - this.#session = _session; - } - - objectMap = { session: "Session" }; - } - - /** End Class NewgroundsIO.results.App.checkSession **/ - if (typeof NewgroundsIO.results.App === "undefined") - NewgroundsIO.results.App = {}; - NewgroundsIO.results.App.checkSession = checkSession; - })(); - - /* ====================== ./NewgroundsIO-JS/src/NewgroundsIO/results/App/getCurrentVersion.js ====================== */ - - (() => { - /** Start NewgroundsIO.results.App.getCurrentVersion **/ - - class getCurrentVersion extends NewgroundsIO.BaseResult { - /** - * Constructor - * @param {object} props An object of initial properties for this instance - * @param {String} props.current_version The version number of the app as defined in your "Version Control" settings. - * @param {Boolean} props.client_deprecated Notes whether the client-side app is using a lower version number. - */ - constructor(props) { - super(); - let _this = this; - - this.__object = "App.getCurrentVersion"; - ["current_version", "client_deprecated"].forEach((prop) => { - if (_this.__properties.indexOf(prop) < 0) - _this.__properties.push(prop); - }); - if (props && typeof props === "object") { - for (var i = 0; i < this.__properties.length; i++) { - if (typeof props[this.__properties[i]] !== "undefined") - this[this.__properties[i]] = props[this.__properties[i]]; - } - } - } - - /** - * @private - */ - #current_version = null; - - /** - * The version number of the app as defined in your "Version Control" settings. - * @type {String} - */ - get current_version() { - return this.#current_version; - } - - set current_version(_current_version) { - if (typeof _current_version !== "string" && _current_version !== null) - console.warn( - "NewgroundsIO Type Mismatch: Value should be a string, got", - _current_version - ); - this.#current_version = String(_current_version); - } - - /** - * @private - */ - #client_deprecated = null; - - /** - * Notes whether the client-side app is using a lower version number. - * @type {Boolean} - */ - get client_deprecated() { - return this.#client_deprecated; - } - - set client_deprecated(_client_deprecated) { - if ( - typeof _client_deprecated !== "boolean" && - typeof _client_deprecated !== "number" && - _client_deprecated !== null - ) - console.warn( - "NewgroundsIO Type Mismatch: Value should be a boolean, got", - _client_deprecated - ); - this.#client_deprecated = _client_deprecated ? true : false; - } - } - - /** End Class NewgroundsIO.results.App.getCurrentVersion **/ - if (typeof NewgroundsIO.results.App === "undefined") - NewgroundsIO.results.App = {}; - NewgroundsIO.results.App.getCurrentVersion = getCurrentVersion; - })(); - - /* ====================== ./NewgroundsIO-JS/src/NewgroundsIO/results/App/getHostLicense.js ====================== */ - - (() => { - /** Start NewgroundsIO.results.App.getHostLicense **/ - - class getHostLicense extends NewgroundsIO.BaseResult { - /** - * Constructor - * @param {object} props An object of initial properties for this instance - * @param {Boolean} props.host_approved - */ - constructor(props) { - super(); - let _this = this; - - this.__object = "App.getHostLicense"; - ["host_approved"].forEach((prop) => { - if (_this.__properties.indexOf(prop) < 0) - _this.__properties.push(prop); - }); - if (props && typeof props === "object") { - for (var i = 0; i < this.__properties.length; i++) { - if (typeof props[this.__properties[i]] !== "undefined") - this[this.__properties[i]] = props[this.__properties[i]]; - } - } - } - - /** - * @private - */ - #host_approved = null; - - /** - * @type {Boolean} - */ - get host_approved() { - return this.#host_approved; - } - - set host_approved(_host_approved) { - if ( - typeof _host_approved !== "boolean" && - typeof _host_approved !== "number" && - _host_approved !== null - ) - console.warn( - "NewgroundsIO Type Mismatch: Value should be a boolean, got", - _host_approved - ); - this.#host_approved = _host_approved ? true : false; - } - } - - /** End Class NewgroundsIO.results.App.getHostLicense **/ - if (typeof NewgroundsIO.results.App === "undefined") - NewgroundsIO.results.App = {}; - NewgroundsIO.results.App.getHostLicense = getHostLicense; - })(); - - /* ====================== ./NewgroundsIO-JS/src/NewgroundsIO/results/App/startSession.js ====================== */ - - (() => { - /** Start NewgroundsIO.results.App.startSession **/ - - class startSession extends NewgroundsIO.BaseResult { - /** - * Constructor - * @param {object} props An object of initial properties for this instance - * @param {NewgroundsIO.objects.Session} props.session - */ - constructor(props) { - super(); - let _this = this; - - this.__object = "App.startSession"; - ["session"].forEach((prop) => { - if (_this.__properties.indexOf(prop) < 0) - _this.__properties.push(prop); - }); - if (props && typeof props === "object") { - for (var i = 0; i < this.__properties.length; i++) { - if (typeof props[this.__properties[i]] !== "undefined") - this[this.__properties[i]] = props[this.__properties[i]]; - } - } - } - - /** - * @private - */ - #session = null; - - /** - * @type {NewgroundsIO.objects.Session} - */ - get session() { - return this.#session; - } - - set session(_session) { - if ( - !(_session instanceof NewgroundsIO.objects.Session) && - typeof _session === "object" - ) - _session = new NewgroundsIO.objects.Session(_session); - - if ( - _session !== null && - !(_session instanceof NewgroundsIO.objects.Session) - ) - console.warn( - "Type Mismatch: expecting NewgroundsIO.objects.Session, got ", - _session - ); - - this.#session = _session; - } - - objectMap = { session: "Session" }; - } - - /** End Class NewgroundsIO.results.App.startSession **/ - if (typeof NewgroundsIO.results.App === "undefined") - NewgroundsIO.results.App = {}; - NewgroundsIO.results.App.startSession = startSession; - })(); - - /* ====================== ./NewgroundsIO-JS/src/NewgroundsIO/results/CloudSave/clearSlot.js ====================== */ - - (() => { - /** Start NewgroundsIO.results.CloudSave.clearSlot **/ - - class clearSlot extends NewgroundsIO.BaseResult { - /** - * Constructor - * @param {object} props An object of initial properties for this instance - * @param {NewgroundsIO.objects.SaveSlot} props.slot A NewgroundsIO.objects.SaveSlot object. - */ - constructor(props) { - super(); - let _this = this; - - this.__object = "CloudSave.clearSlot"; - ["slot"].forEach((prop) => { - if (_this.__properties.indexOf(prop) < 0) - _this.__properties.push(prop); - }); - if (props && typeof props === "object") { - for (var i = 0; i < this.__properties.length; i++) { - if (typeof props[this.__properties[i]] !== "undefined") - this[this.__properties[i]] = props[this.__properties[i]]; - } - } - } - - /** - * @private - */ - #slot = null; - - /** - * A NewgroundsIO.objects.SaveSlot object. - * @type {NewgroundsIO.objects.SaveSlot} - */ - get slot() { - return this.#slot; - } - - set slot(_slot) { - if ( - !(_slot instanceof NewgroundsIO.objects.SaveSlot) && - typeof _slot === "object" - ) - _slot = new NewgroundsIO.objects.SaveSlot(_slot); - - if (_slot !== null && !(_slot instanceof NewgroundsIO.objects.SaveSlot)) - console.warn( - "Type Mismatch: expecting NewgroundsIO.objects.SaveSlot, got ", - _slot - ); - - this.#slot = _slot; - } - - objectMap = { slot: "SaveSlot" }; - } - - /** End Class NewgroundsIO.results.CloudSave.clearSlot **/ - if (typeof NewgroundsIO.results.CloudSave === "undefined") - NewgroundsIO.results.CloudSave = {}; - NewgroundsIO.results.CloudSave.clearSlot = clearSlot; - })(); - - /* ====================== ./NewgroundsIO-JS/src/NewgroundsIO/results/CloudSave/loadSlot.js ====================== */ - - (() => { - /** Start NewgroundsIO.results.CloudSave.loadSlot **/ - - class loadSlot extends NewgroundsIO.BaseResult { - /** - * Constructor - * @param {object} props An object of initial properties for this instance - * @param {NewgroundsIO.objects.SaveSlot} props.slot A NewgroundsIO.objects.SaveSlot object. - * @param {String} props.app_id The App ID of another, approved app to load scores from. - */ - constructor(props) { - super(); - let _this = this; - - this.__object = "CloudSave.loadSlot"; - ["slot", "app_id"].forEach((prop) => { - if (_this.__properties.indexOf(prop) < 0) - _this.__properties.push(prop); - }); - if (props && typeof props === "object") { - for (var i = 0; i < this.__properties.length; i++) { - if (typeof props[this.__properties[i]] !== "undefined") - this[this.__properties[i]] = props[this.__properties[i]]; - } - } - } - - /** - * @private - */ - #slot = null; - - /** - * A NewgroundsIO.objects.SaveSlot object. - * @type {NewgroundsIO.objects.SaveSlot} - */ - get slot() { - return this.#slot; - } - - set slot(_slot) { - if ( - !(_slot instanceof NewgroundsIO.objects.SaveSlot) && - typeof _slot === "object" - ) - _slot = new NewgroundsIO.objects.SaveSlot(_slot); - - if (_slot !== null && !(_slot instanceof NewgroundsIO.objects.SaveSlot)) - console.warn( - "Type Mismatch: expecting NewgroundsIO.objects.SaveSlot, got ", - _slot - ); - - this.#slot = _slot; - } - - /** - * @private - */ - #app_id = null; - - /** - * The App ID of another, approved app to load scores from. - * @type {String} - */ - get app_id() { - return this.#app_id; - } - - set app_id(_app_id) { - if (typeof _app_id !== "string" && _app_id !== null) - console.warn( - "NewgroundsIO Type Mismatch: Value should be a string, got", - _app_id - ); - this.#app_id = String(_app_id); - } - - objectMap = { slot: "SaveSlot" }; - } - - /** End Class NewgroundsIO.results.CloudSave.loadSlot **/ - if (typeof NewgroundsIO.results.CloudSave === "undefined") - NewgroundsIO.results.CloudSave = {}; - NewgroundsIO.results.CloudSave.loadSlot = loadSlot; - })(); - - /* ====================== ./NewgroundsIO-JS/src/NewgroundsIO/results/CloudSave/loadSlots.js ====================== */ - - (() => { - /** Start NewgroundsIO.results.CloudSave.loadSlots **/ - - class loadSlots extends NewgroundsIO.BaseResult { - /** - * Constructor - * @param {object} props An object of initial properties for this instance - * @param {Array.} props.slots An array of NewgroundsIO.objects.SaveSlot objects. - * @param {String} props.app_id The App ID of another, approved app to load scores from. - */ - constructor(props) { - super(); - let _this = this; - - this.__object = "CloudSave.loadSlots"; - ["slots", "app_id"].forEach((prop) => { - if (_this.__properties.indexOf(prop) < 0) - _this.__properties.push(prop); - }); - if (props && typeof props === "object") { - for (var i = 0; i < this.__properties.length; i++) { - if (typeof props[this.__properties[i]] !== "undefined") - this[this.__properties[i]] = props[this.__properties[i]]; - } - } - } - - /** - * @private - */ - #slots = null; - - /** - * An array of NewgroundsIO.objects.SaveSlot objects. - * @type {Array.} - */ - get slots() { - return this.#slots; - } - - set slots(_slots) { - if (Array.isArray(_slots)) { - let newArr = []; - _slots.forEach(function (val, index) { - if (val !== null && !(val instanceof NewgroundsIO.objects.SaveSlot)) - console.warn( - "Type Mismatch: expecting NewgroundsIO.objects.SaveSlot, got ", - val - ); - - newArr[index] = val; - }); - this.#slots = newArr; - return; - } - } - - /** - * @private - */ - #app_id = null; - - /** - * The App ID of another, approved app to load scores from. - * @type {String} - */ - get app_id() { - return this.#app_id; - } - - set app_id(_app_id) { - if (typeof _app_id !== "string" && _app_id !== null) - console.warn( - "NewgroundsIO Type Mismatch: Value should be a string, got", - _app_id - ); - this.#app_id = String(_app_id); - } - - arrayMap = { slots: "SaveSlot" }; - } - - /** End Class NewgroundsIO.results.CloudSave.loadSlots **/ - if (typeof NewgroundsIO.results.CloudSave === "undefined") - NewgroundsIO.results.CloudSave = {}; - NewgroundsIO.results.CloudSave.loadSlots = loadSlots; - })(); - - /* ====================== ./NewgroundsIO-JS/src/NewgroundsIO/results/CloudSave/setData.js ====================== */ - - (() => { - /** Start NewgroundsIO.results.CloudSave.setData **/ - - class setData extends NewgroundsIO.BaseResult { - /** - * Constructor - * @param {object} props An object of initial properties for this instance - * @param {NewgroundsIO.objects.SaveSlot} props.slot - */ - constructor(props) { - super(); - let _this = this; - - this.__object = "CloudSave.setData"; - ["slot"].forEach((prop) => { - if (_this.__properties.indexOf(prop) < 0) - _this.__properties.push(prop); - }); - if (props && typeof props === "object") { - for (var i = 0; i < this.__properties.length; i++) { - if (typeof props[this.__properties[i]] !== "undefined") - this[this.__properties[i]] = props[this.__properties[i]]; - } - } - } - - /** - * @private - */ - #slot = null; - - /** - * @type {NewgroundsIO.objects.SaveSlot} - */ - get slot() { - return this.#slot; - } - - set slot(_slot) { - if ( - !(_slot instanceof NewgroundsIO.objects.SaveSlot) && - typeof _slot === "object" - ) - _slot = new NewgroundsIO.objects.SaveSlot(_slot); - - if (_slot !== null && !(_slot instanceof NewgroundsIO.objects.SaveSlot)) - console.warn( - "Type Mismatch: expecting NewgroundsIO.objects.SaveSlot, got ", - _slot - ); - - this.#slot = _slot; - } - - objectMap = { slot: "SaveSlot" }; - } - - /** End Class NewgroundsIO.results.CloudSave.setData **/ - if (typeof NewgroundsIO.results.CloudSave === "undefined") - NewgroundsIO.results.CloudSave = {}; - NewgroundsIO.results.CloudSave.setData = setData; - })(); - - /* ====================== ./NewgroundsIO-JS/src/NewgroundsIO/results/Event/logEvent.js ====================== */ - - (() => { - /** Start NewgroundsIO.results.Event.logEvent **/ - - class logEvent extends NewgroundsIO.BaseResult { - /** - * Constructor - * @param {object} props An object of initial properties for this instance - * @param {String} props.event_name - */ - constructor(props) { - super(); - let _this = this; - - this.__object = "Event.logEvent"; - ["event_name"].forEach((prop) => { - if (_this.__properties.indexOf(prop) < 0) - _this.__properties.push(prop); - }); - if (props && typeof props === "object") { - for (var i = 0; i < this.__properties.length; i++) { - if (typeof props[this.__properties[i]] !== "undefined") - this[this.__properties[i]] = props[this.__properties[i]]; - } - } - } - - /** - * @private - */ - #event_name = null; - - /** - * @type {String} - */ - get event_name() { - return this.#event_name; - } - - set event_name(_event_name) { - if (typeof _event_name !== "string" && _event_name !== null) - console.warn( - "NewgroundsIO Type Mismatch: Value should be a string, got", - _event_name - ); - this.#event_name = String(_event_name); - } - } - - /** End Class NewgroundsIO.results.Event.logEvent **/ - if (typeof NewgroundsIO.results.Event === "undefined") - NewgroundsIO.results.Event = {}; - NewgroundsIO.results.Event.logEvent = logEvent; - })(); - - /* ====================== ./NewgroundsIO-JS/src/NewgroundsIO/results/Gateway/getDatetime.js ====================== */ - - (() => { - /** Start NewgroundsIO.results.Gateway.getDatetime **/ - - class getDatetime extends NewgroundsIO.BaseResult { - /** - * Constructor - * @param {object} props An object of initial properties for this instance - * @param {String} props.datetime The server's date and time in ISO 8601 format. - * @param {Number} props.timestamp The current UNIX timestamp on the server. - */ - constructor(props) { - super(); - let _this = this; - - this.__object = "Gateway.getDatetime"; - ["datetime", "timestamp"].forEach((prop) => { - if (_this.__properties.indexOf(prop) < 0) - _this.__properties.push(prop); - }); - if (props && typeof props === "object") { - for (var i = 0; i < this.__properties.length; i++) { - if (typeof props[this.__properties[i]] !== "undefined") - this[this.__properties[i]] = props[this.__properties[i]]; - } - } - } - - /** - * @private - */ - #datetime = null; - - /** - * The server's date and time in ISO 8601 format. - * @type {String} - */ - get datetime() { - return this.#datetime; - } - - set datetime(_datetime) { - if (typeof _datetime !== "string" && _datetime !== null) - console.warn( - "NewgroundsIO Type Mismatch: Value should be a string, got", - _datetime - ); - this.#datetime = String(_datetime); - } - - /** - * @private - */ - #timestamp = null; - - /** - * The current UNIX timestamp on the server. - * @type {Number} - */ - get timestamp() { - return this.#timestamp; - } - - set timestamp(_timestamp) { - if (typeof _timestamp !== "number" && _timestamp !== null) - console.warn( - "NewgroundsIO Type Mismatch: Value should be a number, got", - _timestamp - ); - else if (!Number.isInteger(_timestamp) && _timestamp !== null) - console.warn( - "NewgroundsIO Type Mismatch: Value should be an integer, got a float" - ); - this.#timestamp = Number(_timestamp); - if (isNaN(this.#timestamp)) this.#timestamp = null; - } - } - - /** End Class NewgroundsIO.results.Gateway.getDatetime **/ - if (typeof NewgroundsIO.results.Gateway === "undefined") - NewgroundsIO.results.Gateway = {}; - NewgroundsIO.results.Gateway.getDatetime = getDatetime; - })(); - - /* ====================== ./NewgroundsIO-JS/src/NewgroundsIO/results/Gateway/getVersion.js ====================== */ - - (() => { - /** Start NewgroundsIO.results.Gateway.getVersion **/ - - class getVersion extends NewgroundsIO.BaseResult { - /** - * Constructor - * @param {object} props An object of initial properties for this instance - * @param {String} props.version The version number (in X.Y.Z format). - */ - constructor(props) { - super(); - let _this = this; - - this.__object = "Gateway.getVersion"; - ["version"].forEach((prop) => { - if (_this.__properties.indexOf(prop) < 0) - _this.__properties.push(prop); - }); - if (props && typeof props === "object") { - for (var i = 0; i < this.__properties.length; i++) { - if (typeof props[this.__properties[i]] !== "undefined") - this[this.__properties[i]] = props[this.__properties[i]]; - } - } - } - - /** - * @private - */ - #version = null; - - /** - * The version number (in X.Y.Z format). - * @type {String} - */ - get version() { - return this.#version; - } - - set version(_version) { - if (typeof _version !== "string" && _version !== null) - console.warn( - "NewgroundsIO Type Mismatch: Value should be a string, got", - _version - ); - this.#version = String(_version); - } - } - - /** End Class NewgroundsIO.results.Gateway.getVersion **/ - if (typeof NewgroundsIO.results.Gateway === "undefined") - NewgroundsIO.results.Gateway = {}; - NewgroundsIO.results.Gateway.getVersion = getVersion; - })(); - - /* ====================== ./NewgroundsIO-JS/src/NewgroundsIO/results/Gateway/ping.js ====================== */ - - (() => { - /** Start NewgroundsIO.results.Gateway.ping **/ - - class ping extends NewgroundsIO.BaseResult { - /** - * Constructor - * @param {object} props An object of initial properties for this instance - * @param {String} props.pong Will always return a value of 'pong' - */ - constructor(props) { - super(); - let _this = this; - - this.__object = "Gateway.ping"; - ["pong"].forEach((prop) => { - if (_this.__properties.indexOf(prop) < 0) - _this.__properties.push(prop); - }); - if (props && typeof props === "object") { - for (var i = 0; i < this.__properties.length; i++) { - if (typeof props[this.__properties[i]] !== "undefined") - this[this.__properties[i]] = props[this.__properties[i]]; - } - } - } - - /** - * @private - */ - #pong = null; - - /** - * Will always return a value of 'pong' - * @type {String} - */ - get pong() { - return this.#pong; - } - - set pong(_pong) { - if (typeof _pong !== "string" && _pong !== null) - console.warn( - "NewgroundsIO Type Mismatch: Value should be a string, got", - _pong - ); - this.#pong = String(_pong); - } - } - - /** End Class NewgroundsIO.results.Gateway.ping **/ - if (typeof NewgroundsIO.results.Gateway === "undefined") - NewgroundsIO.results.Gateway = {}; - NewgroundsIO.results.Gateway.ping = ping; - })(); - - /* ====================== ./NewgroundsIO-JS/src/NewgroundsIO/results/Loader/loadAuthorUrl.js ====================== */ - - (() => { - /** Start NewgroundsIO.results.Loader.loadAuthorUrl **/ - - class loadAuthorUrl extends NewgroundsIO.BaseResult { - /** - * Constructor - * @param {object} props An object of initial properties for this instance - * @param {String} props.url - */ - constructor(props) { - super(); - let _this = this; - - this.__object = "Loader.loadAuthorUrl"; - ["url"].forEach((prop) => { - if (_this.__properties.indexOf(prop) < 0) - _this.__properties.push(prop); - }); - if (props && typeof props === "object") { - for (var i = 0; i < this.__properties.length; i++) { - if (typeof props[this.__properties[i]] !== "undefined") - this[this.__properties[i]] = props[this.__properties[i]]; - } - } - } - - /** - * @private - */ - #url = null; - - /** - * @type {String} - */ - get url() { - return this.#url; - } - - set url(_url) { - if (typeof _url !== "string" && _url !== null) - console.warn( - "NewgroundsIO Type Mismatch: Value should be a string, got", - _url - ); - this.#url = String(_url); - } - } - - /** End Class NewgroundsIO.results.Loader.loadAuthorUrl **/ - if (typeof NewgroundsIO.results.Loader === "undefined") - NewgroundsIO.results.Loader = {}; - NewgroundsIO.results.Loader.loadAuthorUrl = loadAuthorUrl; - })(); - - /* ====================== ./NewgroundsIO-JS/src/NewgroundsIO/results/Loader/loadMoreGames.js ====================== */ - - (() => { - /** Start NewgroundsIO.results.Loader.loadMoreGames **/ - - class loadMoreGames extends NewgroundsIO.BaseResult { - /** - * Constructor - * @param {object} props An object of initial properties for this instance - * @param {String} props.url - */ - constructor(props) { - super(); - let _this = this; - - this.__object = "Loader.loadMoreGames"; - ["url"].forEach((prop) => { - if (_this.__properties.indexOf(prop) < 0) - _this.__properties.push(prop); - }); - if (props && typeof props === "object") { - for (var i = 0; i < this.__properties.length; i++) { - if (typeof props[this.__properties[i]] !== "undefined") - this[this.__properties[i]] = props[this.__properties[i]]; - } - } - } - - /** - * @private - */ - #url = null; - - /** - * @type {String} - */ - get url() { - return this.#url; - } - - set url(_url) { - if (typeof _url !== "string" && _url !== null) - console.warn( - "NewgroundsIO Type Mismatch: Value should be a string, got", - _url - ); - this.#url = String(_url); - } - } - - /** End Class NewgroundsIO.results.Loader.loadMoreGames **/ - if (typeof NewgroundsIO.results.Loader === "undefined") - NewgroundsIO.results.Loader = {}; - NewgroundsIO.results.Loader.loadMoreGames = loadMoreGames; - })(); - - /* ====================== ./NewgroundsIO-JS/src/NewgroundsIO/results/Loader/loadNewgrounds.js ====================== */ - - (() => { - /** Start NewgroundsIO.results.Loader.loadNewgrounds **/ - - class loadNewgrounds extends NewgroundsIO.BaseResult { - /** - * Constructor - * @param {object} props An object of initial properties for this instance - * @param {String} props.url - */ - constructor(props) { - super(); - let _this = this; - - this.__object = "Loader.loadNewgrounds"; - ["url"].forEach((prop) => { - if (_this.__properties.indexOf(prop) < 0) - _this.__properties.push(prop); - }); - if (props && typeof props === "object") { - for (var i = 0; i < this.__properties.length; i++) { - if (typeof props[this.__properties[i]] !== "undefined") - this[this.__properties[i]] = props[this.__properties[i]]; - } - } - } - - /** - * @private - */ - #url = null; - - /** - * @type {String} - */ - get url() { - return this.#url; - } - - set url(_url) { - if (typeof _url !== "string" && _url !== null) - console.warn( - "NewgroundsIO Type Mismatch: Value should be a string, got", - _url - ); - this.#url = String(_url); - } - } - - /** End Class NewgroundsIO.results.Loader.loadNewgrounds **/ - if (typeof NewgroundsIO.results.Loader === "undefined") - NewgroundsIO.results.Loader = {}; - NewgroundsIO.results.Loader.loadNewgrounds = loadNewgrounds; - })(); - - /* ====================== ./NewgroundsIO-JS/src/NewgroundsIO/results/Loader/loadOfficialUrl.js ====================== */ - - (() => { - /** Start NewgroundsIO.results.Loader.loadOfficialUrl **/ - - class loadOfficialUrl extends NewgroundsIO.BaseResult { - /** - * Constructor - * @param {object} props An object of initial properties for this instance - * @param {String} props.url - */ - constructor(props) { - super(); - let _this = this; - - this.__object = "Loader.loadOfficialUrl"; - ["url"].forEach((prop) => { - if (_this.__properties.indexOf(prop) < 0) - _this.__properties.push(prop); - }); - if (props && typeof props === "object") { - for (var i = 0; i < this.__properties.length; i++) { - if (typeof props[this.__properties[i]] !== "undefined") - this[this.__properties[i]] = props[this.__properties[i]]; - } - } - } - - /** - * @private - */ - #url = null; - - /** - * @type {String} - */ - get url() { - return this.#url; - } - - set url(_url) { - if (typeof _url !== "string" && _url !== null) - console.warn( - "NewgroundsIO Type Mismatch: Value should be a string, got", - _url - ); - this.#url = String(_url); - } - } - - /** End Class NewgroundsIO.results.Loader.loadOfficialUrl **/ - if (typeof NewgroundsIO.results.Loader === "undefined") - NewgroundsIO.results.Loader = {}; - NewgroundsIO.results.Loader.loadOfficialUrl = loadOfficialUrl; - })(); - - /* ====================== ./NewgroundsIO-JS/src/NewgroundsIO/results/Loader/loadReferral.js ====================== */ - - (() => { - /** Start NewgroundsIO.results.Loader.loadReferral **/ - - class loadReferral extends NewgroundsIO.BaseResult { - /** - * Constructor - * @param {object} props An object of initial properties for this instance - * @param {String} props.url - */ - constructor(props) { - super(); - let _this = this; - - this.__object = "Loader.loadReferral"; - ["url"].forEach((prop) => { - if (_this.__properties.indexOf(prop) < 0) - _this.__properties.push(prop); - }); - if (props && typeof props === "object") { - for (var i = 0; i < this.__properties.length; i++) { - if (typeof props[this.__properties[i]] !== "undefined") - this[this.__properties[i]] = props[this.__properties[i]]; - } - } - } - - /** - * @private - */ - #url = null; - - /** - * @type {String} - */ - get url() { - return this.#url; - } - - set url(_url) { - if (typeof _url !== "string" && _url !== null) - console.warn( - "NewgroundsIO Type Mismatch: Value should be a string, got", - _url - ); - this.#url = String(_url); - } - } - - /** End Class NewgroundsIO.results.Loader.loadReferral **/ - if (typeof NewgroundsIO.results.Loader === "undefined") - NewgroundsIO.results.Loader = {}; - NewgroundsIO.results.Loader.loadReferral = loadReferral; - })(); - - /* ====================== ./NewgroundsIO-JS/src/NewgroundsIO/results/Medal/getList.js ====================== */ - - (() => { - /** Start NewgroundsIO.results.Medal.getList **/ - - class getList extends NewgroundsIO.BaseResult { - /** - * Constructor - * @param {object} props An object of initial properties for this instance - * @param {Array.} props.medals An array of medal objects. - * @param {String} props.app_id The App ID of any external app these medals were loaded from. - */ - constructor(props) { - super(); - let _this = this; - - this.__object = "Medal.getList"; - ["medals", "app_id"].forEach((prop) => { - if (_this.__properties.indexOf(prop) < 0) - _this.__properties.push(prop); - }); - if (props && typeof props === "object") { - for (var i = 0; i < this.__properties.length; i++) { - if (typeof props[this.__properties[i]] !== "undefined") - this[this.__properties[i]] = props[this.__properties[i]]; - } - } - } - - /** - * @private - */ - #medals = null; - - /** - * An array of medal objects. - * @type {Array.} - */ - get medals() { - return this.#medals; - } - - set medals(_medals) { - if (Array.isArray(_medals)) { - let newArr = []; - _medals.forEach(function (val, index) { - if (val !== null && !(val instanceof NewgroundsIO.objects.Medal)) - console.warn( - "Type Mismatch: expecting NewgroundsIO.objects.Medal, got ", - val - ); - - newArr[index] = val; - }); - this.#medals = newArr; - return; - } - } - - /** - * @private - */ - #app_id = null; - - /** - * The App ID of any external app these medals were loaded from. - * @type {String} - */ - get app_id() { - return this.#app_id; - } - - set app_id(_app_id) { - if (typeof _app_id !== "string" && _app_id !== null) - console.warn( - "NewgroundsIO Type Mismatch: Value should be a string, got", - _app_id - ); - this.#app_id = String(_app_id); - } - - arrayMap = { medals: "Medal" }; - } - - /** End Class NewgroundsIO.results.Medal.getList **/ - if (typeof NewgroundsIO.results.Medal === "undefined") - NewgroundsIO.results.Medal = {}; - NewgroundsIO.results.Medal.getList = getList; - })(); - - /* ====================== ./NewgroundsIO-JS/src/NewgroundsIO/results/Medal/getMedalScore.js ====================== */ - - (() => { - /** Start NewgroundsIO.results.Medal.getMedalScore **/ - - class getMedalScore extends NewgroundsIO.BaseResult { - /** - * Constructor - * @param {object} props An object of initial properties for this instance - * @param {Number} props.medal_score The user's medal score. - */ - constructor(props) { - super(); - let _this = this; - - this.__object = "Medal.getMedalScore"; - ["medal_score"].forEach((prop) => { - if (_this.__properties.indexOf(prop) < 0) - _this.__properties.push(prop); - }); - if (props && typeof props === "object") { - for (var i = 0; i < this.__properties.length; i++) { - if (typeof props[this.__properties[i]] !== "undefined") - this[this.__properties[i]] = props[this.__properties[i]]; - } - } - } - - /** - * @private - */ - #medal_score = null; - - /** - * The user's medal score. - * @type {Number} - */ - get medal_score() { - return this.#medal_score; - } - - set medal_score(_medal_score) { - if (typeof _medal_score !== "number" && _medal_score !== null) - console.warn( - "NewgroundsIO Type Mismatch: Value should be a number, got", - _medal_score - ); - else if (!Number.isInteger(_medal_score) && _medal_score !== null) - console.warn( - "NewgroundsIO Type Mismatch: Value should be an integer, got a float" - ); - this.#medal_score = Number(_medal_score); - if (isNaN(this.#medal_score)) this.#medal_score = null; - } - } - - /** End Class NewgroundsIO.results.Medal.getMedalScore **/ - if (typeof NewgroundsIO.results.Medal === "undefined") - NewgroundsIO.results.Medal = {}; - NewgroundsIO.results.Medal.getMedalScore = getMedalScore; - })(); - - /* ====================== ./NewgroundsIO-JS/src/NewgroundsIO/results/Medal/unlock.js ====================== */ - - (() => { - /** Start NewgroundsIO.results.Medal.unlock **/ - - class unlock extends NewgroundsIO.BaseResult { - /** - * Constructor - * @param {object} props An object of initial properties for this instance - * @param {NewgroundsIO.objects.Medal} props.medal The NewgroundsIO.objects.Medal that was unlocked. - * @param {Number} props.medal_score The user's new medal score. - */ - constructor(props) { - super(); - let _this = this; - - this.__object = "Medal.unlock"; - ["medal", "medal_score"].forEach((prop) => { - if (_this.__properties.indexOf(prop) < 0) - _this.__properties.push(prop); - }); - if (props && typeof props === "object") { - for (var i = 0; i < this.__properties.length; i++) { - if (typeof props[this.__properties[i]] !== "undefined") - this[this.__properties[i]] = props[this.__properties[i]]; - } - } - } - - /** - * @private - */ - #medal = null; - - /** - * The NewgroundsIO.objects.Medal that was unlocked. - * @type {NewgroundsIO.objects.Medal} - */ - get medal() { - return this.#medal; - } - - set medal(_medal) { - if ( - !(_medal instanceof NewgroundsIO.objects.Medal) && - typeof _medal === "object" - ) - _medal = new NewgroundsIO.objects.Medal(_medal); - - if (_medal !== null && !(_medal instanceof NewgroundsIO.objects.Medal)) - console.warn( - "Type Mismatch: expecting NewgroundsIO.objects.Medal, got ", - _medal - ); - - this.#medal = _medal; - } - - /** - * @private - */ - #medal_score = null; - - /** - * The user's new medal score. - * @type {Number} - */ - get medal_score() { - return this.#medal_score; - } - - set medal_score(_medal_score) { - if (typeof _medal_score !== "number" && _medal_score !== null) - console.warn( - "NewgroundsIO Type Mismatch: Value should be a number, got", - _medal_score - ); - else if (!Number.isInteger(_medal_score) && _medal_score !== null) - console.warn( - "NewgroundsIO Type Mismatch: Value should be an integer, got a float" - ); - this.#medal_score = Number(_medal_score); - if (isNaN(this.#medal_score)) this.#medal_score = null; - } - - objectMap = { medal: "Medal" }; - } - - /** End Class NewgroundsIO.results.Medal.unlock **/ - if (typeof NewgroundsIO.results.Medal === "undefined") - NewgroundsIO.results.Medal = {}; - NewgroundsIO.results.Medal.unlock = unlock; - })(); - - /* ====================== ./NewgroundsIO-JS/src/NewgroundsIO/results/ScoreBoard/getBoards.js ====================== */ - - (() => { - /** Start NewgroundsIO.results.ScoreBoard.getBoards **/ - - class getBoards extends NewgroundsIO.BaseResult { - /** - * Constructor - * @param {object} props An object of initial properties for this instance - * @param {Array.} props.scoreboards An array of NewgroundsIO.objects.ScoreBoard objects. - */ - constructor(props) { - super(); - let _this = this; - - this.__object = "ScoreBoard.getBoards"; - ["scoreboards"].forEach((prop) => { - if (_this.__properties.indexOf(prop) < 0) - _this.__properties.push(prop); - }); - if (props && typeof props === "object") { - for (var i = 0; i < this.__properties.length; i++) { - if (typeof props[this.__properties[i]] !== "undefined") - this[this.__properties[i]] = props[this.__properties[i]]; - } - } - } - - /** - * @private - */ - #scoreboards = null; - - /** - * An array of NewgroundsIO.objects.ScoreBoard objects. - * @type {Array.} - */ - get scoreboards() { - return this.#scoreboards; - } - - set scoreboards(_scoreboards) { - if (Array.isArray(_scoreboards)) { - let newArr = []; - _scoreboards.forEach(function (val, index) { - if ( - val !== null && - !(val instanceof NewgroundsIO.objects.ScoreBoard) - ) - console.warn( - "Type Mismatch: expecting NewgroundsIO.objects.ScoreBoard, got ", - val - ); - - newArr[index] = val; - }); - this.#scoreboards = newArr; - return; - } - } - - arrayMap = { scoreboards: "ScoreBoard" }; - } - - /** End Class NewgroundsIO.results.ScoreBoard.getBoards **/ - if (typeof NewgroundsIO.results.ScoreBoard === "undefined") - NewgroundsIO.results.ScoreBoard = {}; - NewgroundsIO.results.ScoreBoard.getBoards = getBoards; - })(); - - /* ====================== ./NewgroundsIO-JS/src/NewgroundsIO/results/ScoreBoard/getScores.js ====================== */ - - (() => { - /** Start NewgroundsIO.results.ScoreBoard.getScores **/ - - class getScores extends NewgroundsIO.BaseResult { - /** - * Constructor - * @param {object} props An object of initial properties for this instance - * @param {String} props.period The time-frame the scores belong to. See notes for acceptable values. - * @param {Boolean} props.social Will return true if scores were loaded in social context ('social' set to true and a session or 'user' were provided). - * @param {Number} props.limit The query skip that was used. - * @param {NewgroundsIO.objects.ScoreBoard} props.scoreboard The NewgroundsIO.objects.ScoreBoard being queried. - * @param {Array.} props.scores An array of NewgroundsIO.objects.Score objects. - * @param {NewgroundsIO.objects.User} props.user The NewgroundsIO.objects.User the score list is associated with (either as defined in the 'user' param, or extracted from the current session when 'social' is set to true) - * @param {String} props.app_id The App ID of any external app these scores were loaded from. - */ - constructor(props) { - super(); - let _this = this; - - this.__object = "ScoreBoard.getScores"; - [ - "period", - "social", - "limit", - "scoreboard", - "scores", - "user", - "app_id", - ].forEach((prop) => { - if (_this.__properties.indexOf(prop) < 0) - _this.__properties.push(prop); - }); - if (props && typeof props === "object") { - for (var i = 0; i < this.__properties.length; i++) { - if (typeof props[this.__properties[i]] !== "undefined") - this[this.__properties[i]] = props[this.__properties[i]]; - } - } - } - - /** - * @private - */ - #period = null; - - /** - * The time-frame the scores belong to. See notes for acceptable values. - * @type {String} - */ - get period() { - return this.#period; - } - - set period(_period) { - if (typeof _period !== "string" && _period !== null) - console.warn( - "NewgroundsIO Type Mismatch: Value should be a string, got", - _period - ); - this.#period = String(_period); - } - - /** - * @private - */ - #social = null; - - /** - * Will return true if scores were loaded in social context ('social' set to true and a session or 'user' were provided). - * @type {Boolean} - */ - get social() { - return this.#social; - } - - set social(_social) { - if ( - typeof _social !== "boolean" && - typeof _social !== "number" && - _social !== null - ) - console.warn( - "NewgroundsIO Type Mismatch: Value should be a boolean, got", - _social - ); - this.#social = _social ? true : false; - } - - /** - * @private - */ - #limit = null; - - /** - * The query skip that was used. - * @type {Number} - */ - get limit() { - return this.#limit; - } - - set limit(_limit) { - if (typeof _limit !== "number" && _limit !== null) - console.warn( - "NewgroundsIO Type Mismatch: Value should be a number, got", - _limit - ); - else if (!Number.isInteger(_limit) && _limit !== null) - console.warn( - "NewgroundsIO Type Mismatch: Value should be an integer, got a float" - ); - this.#limit = Number(_limit); - if (isNaN(this.#limit)) this.#limit = null; - } - - /** - * @private - */ - #scoreboard = null; - - /** - * The NewgroundsIO.objects.ScoreBoard being queried. - * @type {NewgroundsIO.objects.ScoreBoard} - */ - get scoreboard() { - return this.#scoreboard; - } - - set scoreboard(_scoreboard) { - if ( - !(_scoreboard instanceof NewgroundsIO.objects.ScoreBoard) && - typeof _scoreboard === "object" - ) - _scoreboard = new NewgroundsIO.objects.ScoreBoard(_scoreboard); - - if ( - _scoreboard !== null && - !(_scoreboard instanceof NewgroundsIO.objects.ScoreBoard) - ) - console.warn( - "Type Mismatch: expecting NewgroundsIO.objects.ScoreBoard, got ", - _scoreboard - ); - - this.#scoreboard = _scoreboard; - } - - /** - * @private - */ - #scores = null; - - /** - * An array of NewgroundsIO.objects.Score objects. - * @type {Array.} - */ - get scores() { - return this.#scores; - } - - set scores(_scores) { - if (Array.isArray(_scores)) { - let newArr = []; - _scores.forEach(function (val, index) { - if (val !== null && !(val instanceof NewgroundsIO.objects.Score)) - console.warn( - "Type Mismatch: expecting NewgroundsIO.objects.Score, got ", - val - ); - - newArr[index] = val; - }); - this.#scores = newArr; - return; - } - } - - /** - * @private - */ - #user = null; - - /** - * The NewgroundsIO.objects.User the score list is associated with (either as defined in the 'user' param, or extracted from the current session when 'social' is set to true) - * @type {NewgroundsIO.objects.User} - */ - get user() { - return this.#user; - } - - set user(_user) { - if ( - !(_user instanceof NewgroundsIO.objects.User) && - typeof _user === "object" - ) - _user = new NewgroundsIO.objects.User(_user); - - if (_user !== null && !(_user instanceof NewgroundsIO.objects.User)) - console.warn( - "Type Mismatch: expecting NewgroundsIO.objects.User, got ", - _user - ); - - this.#user = _user; - } - - /** - * @private - */ - #app_id = null; - - /** - * The App ID of any external app these scores were loaded from. - * @type {String} - */ - get app_id() { - return this.#app_id; - } - - set app_id(_app_id) { - if (typeof _app_id !== "string" && _app_id !== null) - console.warn( - "NewgroundsIO Type Mismatch: Value should be a string, got", - _app_id - ); - this.#app_id = String(_app_id); - } - - objectMap = { scoreboard: "ScoreBoard", user: "User" }; - - arrayMap = { scores: "Score" }; - } - - /** End Class NewgroundsIO.results.ScoreBoard.getScores **/ - if (typeof NewgroundsIO.results.ScoreBoard === "undefined") - NewgroundsIO.results.ScoreBoard = {}; - NewgroundsIO.results.ScoreBoard.getScores = getScores; - })(); - - /* ====================== ./NewgroundsIO-JS/src/NewgroundsIO/results/ScoreBoard/postScore.js ====================== */ - - (() => { - /** Start NewgroundsIO.results.ScoreBoard.postScore **/ - - class postScore extends NewgroundsIO.BaseResult { - /** - * Constructor - * @param {object} props An object of initial properties for this instance - * @param {NewgroundsIO.objects.ScoreBoard} props.scoreboard The NewgroundsIO.objects.ScoreBoard that was posted to. - * @param {NewgroundsIO.objects.Score} props.score The NewgroundsIO.objects.Score that was posted to the board. - */ - constructor(props) { - super(); - let _this = this; - - this.__object = "ScoreBoard.postScore"; - ["scoreboard", "score"].forEach((prop) => { - if (_this.__properties.indexOf(prop) < 0) - _this.__properties.push(prop); - }); - if (props && typeof props === "object") { - for (var i = 0; i < this.__properties.length; i++) { - if (typeof props[this.__properties[i]] !== "undefined") - this[this.__properties[i]] = props[this.__properties[i]]; - } - } - } - - /** - * @private - */ - #scoreboard = null; - - /** - * The NewgroundsIO.objects.ScoreBoard that was posted to. - * @type {NewgroundsIO.objects.ScoreBoard} - */ - get scoreboard() { - return this.#scoreboard; - } - - set scoreboard(_scoreboard) { - if ( - !(_scoreboard instanceof NewgroundsIO.objects.ScoreBoard) && - typeof _scoreboard === "object" - ) - _scoreboard = new NewgroundsIO.objects.ScoreBoard(_scoreboard); - - if ( - _scoreboard !== null && - !(_scoreboard instanceof NewgroundsIO.objects.ScoreBoard) - ) - console.warn( - "Type Mismatch: expecting NewgroundsIO.objects.ScoreBoard, got ", - _scoreboard - ); - - this.#scoreboard = _scoreboard; - } - - /** - * @private - */ - #score = null; - - /** - * The NewgroundsIO.objects.Score that was posted to the board. - * @type {NewgroundsIO.objects.Score} - */ - get score() { - return this.#score; - } - - set score(_score) { - if ( - !(_score instanceof NewgroundsIO.objects.Score) && - typeof _score === "object" - ) - _score = new NewgroundsIO.objects.Score(_score); - - if (_score !== null && !(_score instanceof NewgroundsIO.objects.Score)) - console.warn( - "Type Mismatch: expecting NewgroundsIO.objects.Score, got ", - _score - ); - - this.#score = _score; - } - - objectMap = { scoreboard: "ScoreBoard", score: "Score" }; - } - - /** End Class NewgroundsIO.results.ScoreBoard.postScore **/ - if (typeof NewgroundsIO.results.ScoreBoard === "undefined") - NewgroundsIO.results.ScoreBoard = {}; - NewgroundsIO.results.ScoreBoard.postScore = postScore; - })(); + //Updated to the latest + // prettier-ignore + class NGIO{static get STATUS_INITIALIZED(){return"initialized"}static get STATUS_CHECKING_LOCAL_VERSION(){return"checking-local-version"}static get STATUS_LOCAL_VERSION_CHECKED(){return"local-version-checked"}static get STATUS_PRELOADING_ITEMS(){return"preloading-items"}static get STATUS_ITEMS_PRELOADED(){return"items-preloaded"}static get STATUS_READY(){return"ready"}static get STATUS_SESSION_UNINITIALIZED(){return NewgroundsIO.SessionState.SESSION_UNINITIALIZED}static get STATUS_WAITING_FOR_SERVER(){return NewgroundsIO.SessionState.WAITING_FOR_SERVER}static get STATUS_LOGIN_REQUIRED(){return NewgroundsIO.SessionState.LOGIN_REQUIRED}static get STATUS_WAITING_FOR_USER(){return NewgroundsIO.SessionState.WAITING_FOR_USER}static get STATUS_LOGIN_CANCELLED(){return NewgroundsIO.SessionState.LOGIN_CANCELLED}static get STATUS_LOGIN_SUCCESSFUL(){return NewgroundsIO.SessionState.LOGIN_SUCCESSFUL}static get STATUS_LOGIN_FAILED(){return NewgroundsIO.SessionState.LOGIN_FAILED}static get STATUS_USER_LOGGED_OUT(){return NewgroundsIO.SessionState.USER_LOGGED_OUT}static get STATUS_SERVER_UNAVAILABLE(){return NewgroundsIO.SessionState.SERVER_UNAVAILABLE}static get STATUS_EXCEEDED_MAX_ATTEMPTS(){return NewgroundsIO.SessionState.EXCEEDED_MAX_ATTEMPTS}static get isWaitingStatus(){return NewgroundsIO.SessionState.SESSION_WAITING.indexOf(this.#a)>=0||[this.STATUS_PRELOADING_ITEMS,this.LOCAL_VERSION_CHECKED,this.STATUS_CHECKING_LOCAL_VERSION].indexOf(this.#a)>=0}static get PERIOD_TODAY(){return"D"}static get PERIOD_CURRENT_WEEK(){return"W"}static get PERIOD_CURRENT_MONTH(){return"M"}static get PERIOD_CURRENT_YEAR(){return"Y"}static get PERIOD_ALL_TIME(){return"A"}static get PERIODS(){return[NGIO.PERIOD_TODAY,NGIO.PERIOD_CURRENT_WEEK,NGIO.PERIOD_CURRENT_MONTH,NGIO.PERIOD_CURRENT_YEAR,NGIO.PERIOD_ALL_TIME]}static get ngioCore(){return this.#b}static #b=null;static get medalScore(){return this.#c}static #c=-1;static get medals(){return this.#d}static #d=null;static get scoreBoards(){return this.#e}static #e=null;static get saveSlots(){return this.#f}static #f=null;static get lastExecution(){return this.#g}static #g=new Date;static get lastConnectionStatus(){return this.#a}static #a=new Date;static get sessionError(){return this.#h}static #h=null;static get legalHost(){return this.#i}static #i=!0;static get isDeprecated(){return this.#j}static #j=!0;static get newestVersion(){return this.#k}static #k=!0;static get loginPageOpen(){return this.#l}static #l=!1;static get gatewayVersion(){return this.#m}static #m=!0;static get lastMedalUnlocked(){return this.#n}static #n=!0;static get lastBoardPosted(){return this.#o}static #o=!0;static get lastScorePosted(){return this.#p}static #p=!0;static get lastGetScoresResult(){return this.#q}static #q=!0;static get lastSaveSlotLoaded(){return this.#r}static #r=!0;static get lastSaveSlotSaved(){return this.#s}static #s=!0;static get lastDateTime(){return this.#t}static #t="0000-00-00";static get lastLoggedEvent(){return this.#u}static #u=null;static get lastTimeStamp(){return this.#v}static #v=0;static get lastPingSuccess(){return this.#w}static #w=!0;static get isInitialized(){return null!==this.ngioCore}static get session(){return this.isInitialized?this.ngioCore.session:null}static get user(){return null===this.session?null:this.ngioCore.session.user}static get hasSession(){return null!==this.session}static get hasUser(){return null!==this.user}static get isReady(){return this.#a===this.STATUS_READY}static get version(){return this.#x}static #x="0.0.0";static get debugMode(){return this.#y}static #y=!1;static #z={autoLogNewView:!1,preloadMedals:!1,preloadScoreBoards:!1,preloadSaveSlots:!1};static #A=!1;static #B=!1;static #C=!1;static #D=!1;static init(e,t,s){if(!this.isInitialized){if(this.#b=new NewgroundsIO.Core(e,t),this.#b.addEventListener("serverResponse",function(e){NGIO.#E(e)}),s&&"object"==typeof s){"string"==typeof s.version&&(this.#x=s.version);let o=["debugMode","checkHostLicense","autoLogNewView","preloadMedals","preloadScoreBoards","preloadSaveSlots"];for(let r=0;r{t.hasData&&e++}),e}static getSaveSlotData(e,t,s){null===this.saveSlots&&(console.error("getSaveSlotData data called without any preloaded save slots."),s?t.call(s,null):t(null));let o=this.getSaveSlot(e);this.#r=o,o.getData(t,s)}static setSaveSlotData(e,t,s,o){if(null==this.saveSlots){console.error("setSaveSlotData data called without any preloaded save slots."),"function"==typeof s&&(o?s(o,null):s(null));return}var r=this.getSaveSlot(e);if(null==r){console.error("Slot #"+e+" does not exist."),"function"==typeof s&&(o?s(o,null):s(null));return}r.setData(t,function(){"function"==typeof s&&(o?s(o,this.lastSaveSlotSaved):s(this.lastSaveSlotSaved))},this)}static logEvent(e,t,s){this.ngioCore.executeComponent(this.ngioCore.getComponent("Event.logEvent",{event_name:e}),function(){"function"==typeof t&&(s?t(s,this.lastLoggedEvent):t(this.lastLoggedEvent))},this)}static getDateTime(e,t){this.ngioCore.executeComponent(this.ngioCore.getComponent("Gateway.getDatetime"),function(){"function"==typeof e&&(t?e(t,this.lastDateTime,this.lastTimeStamp):e(this.lastDateTime,this.lastTimeStamp))},this)}static keepSessionAlive(){if(this.hasUser)(new Date-this.#g).Seconds>=3e4&&(this.#g=new Date,this.ngioCore.executeComponent(this.ngioCore.getComponent("Gateway.ping")))}static getConnectionStatus(e,t){this.#D||null===this.#a||null==this.session||(this.#D=!0,this.#a===this.STATUS_INITIALIZED?(this.#a=this.STATUS_CHECKING_LOCAL_VERSION,this.#G(e,t),this.#H(e,t)):this.#A?this.#a===this.STATUS_LOGIN_SUCCESSFUL?(this.#a=this.STATUS_PRELOADING_ITEMS,this.#G(e,t),this.#I(function(){this.#G(e,t),this.#B=!1},this)):this.#a===this.STATUS_ITEMS_PRELOADED?(this.#l=!1,this.#a=this.STATUS_READY,this.#G(e,t),this.#B=!1):this.keepSessionAlive():this.#B?this.#J(e,t):this.#a!==this.STATUS_CHECKING_LOCAL_VERSION&&this.session.update(function(){this.#J(e,t)},this),this.#D=!1)}static #J(e,t){(this.session.statusChanged||this.#B)&&(this.#a=this.session.status,(this.session.status==NewgroundsIO.SessionState.LOGIN_SUCCESSFUL||this.#B)&&(this.#a=NewgroundsIO.SessionState.LOGIN_SUCCESSFUL,this.#A=!0),this.#G(e,t)),this.#B=!1}static #G(s,o){o?s.call(o,this.#a):s(this.#a)}static #H(r,i){if(this.#C){this.#a=this.STATUS_LOCAL_VERSION_CHECKED,this.#G(r,i);return}this.ngioCore.queueComponent(this.ngioCore.getComponent("App.getCurrentVersion",{version:this.#x})),this.ngioCore.queueComponent(this.ngioCore.getComponent("Gateway.getVersion")),this.#z.autoLogNewView&&this.ngioCore.queueComponent(this.ngioCore.getComponent("App.logView")),this.#z.checkHostLicense&&this.ngioCore.queueComponent(this.ngioCore.getComponent("App.getHostLicense")),this.ngioCore.executeQueue(function(){this.#a=this.STATUS_LOCAL_VERSION_CHECKED,this.#C=!0,this.#G(r,i),this.#j&&console.warn("NGIO - Version mistmatch! Published version is: "+this.#k+", this version is: "+this.version),this.#i||(console.warn("NGIO - This host has been blocked fom hosting this game!"),this.#A=!0,this.#a=this.STATUS_ITEMS_PRELOADED,this.#G(r,i))},this)}static #I(){this.#z.preloadMedals&&(this.ngioCore.queueComponent(this.ngioCore.getComponent("Medal.getMedalScore")),this.ngioCore.queueComponent(this.ngioCore.getComponent("Medal.getList"))),this.#z.preloadScoreBoards&&this.ngioCore.queueComponent(this.ngioCore.getComponent("ScoreBoard.getBoards")),null!==this.user&&this.#z.preloadSaveSlots&&this.ngioCore.queueComponent(this.ngioCore.getComponent("CloudSave.loadSlots")),this.ngioCore.hasQueue?this.ngioCore.executeQueue(function(){this.#a=this.STATUS_ITEMS_PRELOADED},this):this.#a=this.STATUS_ITEMS_PRELOADED}static #F(){this.#a=this.STATUS_INITIALIZED,this.#l=!1,this.#B=!1,this.#A=!1}static #K(n){if(this.#f){let a=this.#f.length;for(let u=0;u>>2]|=(s[r>>>2]>>>24-8*(r%4)&255)<<24-8*((o+r)%4);else if(65535>>2]=s[r>>>2];else t.push.apply(t,s);return this.sigBytes+=e,this},clamp:function(){var t=this.words,s=this.sigBytes;t[s>>>2]&=4294967295<<32-8*(s%4),t.length=e.ceil(s/4)},clone:function(){var e=i.clone.call(this);return e.words=this.words.slice(0),e},random:function(t){for(var s=[],o=0;o>>2]>>>24-8*(o%4)&255;s.push((r>>>4).toString(16)),s.push((15&r).toString(16))}return s.join("")},parse:function(e){for(var t=e.length,s=[],o=0;o>>3]|=parseInt(e.substr(o,2),16)<<24-4*(o%8);return new n.init(s,t/2)}},l=a.Latin1={stringify:function(e){var t=e.words;e=e.sigBytes;for(var s=[],o=0;o>>2]>>>24-8*(o%4)&255));return s.join("")},parse:function(e){for(var t=e.length,s=[],o=0;o>>2]|=(255&e.charCodeAt(o))<<24-8*(o%4);return new n.init(s,t)}},p=a.Utf8={stringify:function(e){try{return decodeURIComponent(escape(l.stringify(e)))}catch(t){throw Error("Malformed UTF-8 data")}},parse:function(e){return l.parse(unescape(encodeURIComponent(e)))}},c=o.BufferedBlockAlgorithm=i.extend({reset:function(){this._data=new n.init,this._nDataBytes=0},_append:function(e){"string"==typeof e&&(e=p.parse(e)),this._data.concat(e),this._nDataBytes+=e.sigBytes},_process:function(t){var s=this._data,o=s.words,r=s.sigBytes,i=this.blockSize,a=r/(4*i),a=t?e.ceil(a):e.max((0|a)-this._minBufferSize,0);if(t=a*i,r=e.min(4*t,r),t){for(var u=0;u>>2]>>>24-8*(r%4)&255)<<16|(t[r+1>>>2]>>>24-8*((r+1)%4)&255)<<8|t[r+2>>>2]>>>24-8*((r+2)%4)&255,n=0;4>n&&r+.75*n>>6*(3-n)&63));if(t=o.charAt(64))for(;e.length%4;)e.push(t);return e.join("")},parse:function(e){var s=e.length,o=this._map,r=o.charAt(64);r&&-1!=(r=e.indexOf(r))&&(s=r);for(var r=[],i=0,n=0;n>>6-2*(n%4);r[i>>>2]|=(a|u)<<24-8*(i%4),i++}return t.create(r,i)},_map:"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/="}}(),function(e){function t(e,t,s,o,r,i,n){return((e=e+(t&s|~t&o)+r+n)<>>32-i)+t}function s(e,t,s,o,r,i,n){return((e=e+(t&o|s&~o)+r+n)<>>32-i)+t}function o(e,t,s,o,r,i,n){return((e=e+(t^s^o)+r+n)<>>32-i)+t}function r(e,t,s,o,r,i,n){return((e=e+(s^(t|~o))+r+n)<>>32-i)+t}for(var i=CryptoJS,n=i.lib,a=n.WordArray,u=n.Hasher,n=i.algo,l=[],p=0;64>p;p++)l[p]=4294967296*e.abs(e.sin(p+1))|0;n=n.MD5=u.extend({_doReset:function(){this._hash=new a.init([1732584193,4023233417,2562383102,271733878])},_doProcessBlock:function(e,i){for(var n=0;16>n;n++){var a=i+n,u=e[a];e[a]=(u<<8|u>>>24)&16711935|(u<<24|u>>>8)&4278255360}var n=this._hash.words,a=e[i+0],u=e[i+1],p=e[i+2],c=e[i+3],h=e[i+4],d=e[i+5],g=e[i+6],f=e[i+7],w=e[i+8],O=e[i+9],I=e[i+10],m=e[i+11],S=e[i+12],N=e[i+13],b=e[i+14],y=e[i+15],v=n[0],$=n[1],C=n[2],E=n[3],v=t(v,$,C,E,a,7,l[0]),E=t(E,v,$,C,u,12,l[1]),C=t(C,E,v,$,p,17,l[2]),$=t($,C,E,v,c,22,l[3]),v=t(v,$,C,E,h,7,l[4]),E=t(E,v,$,C,d,12,l[5]),C=t(C,E,v,$,g,17,l[6]),$=t($,C,E,v,f,22,l[7]),v=t(v,$,C,E,w,7,l[8]),E=t(E,v,$,C,O,12,l[9]),C=t(C,E,v,$,I,17,l[10]),$=t($,C,E,v,m,22,l[11]),v=t(v,$,C,E,S,7,l[12]),E=t(E,v,$,C,N,12,l[13]),C=t(C,E,v,$,b,17,l[14]),$=t($,C,E,v,y,22,l[15]),v=s(v,$,C,E,u,5,l[16]),E=s(E,v,$,C,g,9,l[17]),C=s(C,E,v,$,m,14,l[18]),$=s($,C,E,v,a,20,l[19]),v=s(v,$,C,E,d,5,l[20]),E=s(E,v,$,C,I,9,l[21]),C=s(C,E,v,$,y,14,l[22]),$=s($,C,E,v,h,20,l[23]),v=s(v,$,C,E,O,5,l[24]),E=s(E,v,$,C,b,9,l[25]),C=s(C,E,v,$,c,14,l[26]),$=s($,C,E,v,w,20,l[27]),v=s(v,$,C,E,N,5,l[28]),E=s(E,v,$,C,p,9,l[29]),C=s(C,E,v,$,f,14,l[30]),$=s($,C,E,v,S,20,l[31]),v=o(v,$,C,E,d,4,l[32]),E=o(E,v,$,C,w,11,l[33]),C=o(C,E,v,$,m,16,l[34]),$=o($,C,E,v,b,23,l[35]),v=o(v,$,C,E,u,4,l[36]),E=o(E,v,$,C,h,11,l[37]),C=o(C,E,v,$,f,16,l[38]),$=o($,C,E,v,I,23,l[39]),v=o(v,$,C,E,N,4,l[40]),E=o(E,v,$,C,a,11,l[41]),C=o(C,E,v,$,c,16,l[42]),$=o($,C,E,v,g,23,l[43]),v=o(v,$,C,E,O,4,l[44]),E=o(E,v,$,C,S,11,l[45]),C=o(C,E,v,$,y,16,l[46]),$=o($,C,E,v,p,23,l[47]),v=r(v,$,C,E,a,6,l[48]),E=r(E,v,$,C,f,10,l[49]),C=r(C,E,v,$,b,15,l[50]),$=r($,C,E,v,d,21,l[51]),v=r(v,$,C,E,S,6,l[52]),E=r(E,v,$,C,c,10,l[53]),C=r(C,E,v,$,I,15,l[54]),$=r($,C,E,v,u,21,l[55]),v=r(v,$,C,E,w,6,l[56]),E=r(E,v,$,C,y,10,l[57]),C=r(C,E,v,$,g,15,l[58]),$=r($,C,E,v,N,21,l[59]),v=r(v,$,C,E,h,6,l[60]),E=r(E,v,$,C,m,10,l[61]),C=r(C,E,v,$,p,15,l[62]),$=r($,C,E,v,O,21,l[63]);n[0]=n[0]+v|0,n[1]=n[1]+$|0,n[2]=n[2]+C|0,n[3]=n[3]+E|0},_doFinalize:function(){var t=this._data,s=t.words,o=8*this._nDataBytes,r=8*t.sigBytes;s[r>>>5]|=128<<24-r%32;var i=e.floor(o/4294967296);for(s[(r+64>>>9<<4)+15]=(i<<8|i>>>24)&16711935|(i<<24|i>>>8)&4278255360,s[(r+64>>>9<<4)+14]=(o<<8|o>>>24)&16711935|(o<<24|o>>>8)&4278255360,t.sigBytes=4*(s.length+1),this._process(),s=(t=this._hash).words,o=0;4>o;o++)r=s[o],s[o]=(r<<8|r>>>24)&16711935|(r<<24|r>>>8)&4278255360;return t},clone:function(){var e=u.clone.call(this);return e._hash=this._hash.clone(),e}}),i.MD5=u._createHelper(n),i.HmacMD5=u._createHmacHelper(n)}(Math),function(){var e=CryptoJS,t=e.lib,s=t.Base,o=t.WordArray,t=e.algo,r=t.EvpKDF=s.extend({cfg:s.extend({keySize:4,hasher:t.MD5,iterations:1}),init:function(e){this.cfg=this.cfg.extend(e)},compute:function(e,t){for(var s=this.cfg,r=s.hasher.create(),i=o.create(),n=i.words,a=s.keySize,s=s.iterations;n.length>>2]}},s.BlockCipher=u.extend({cfg:u.cfg.extend({mode:l,padding:c}),reset:function(){u.reset.call(this);var e=this.cfg,t=e.iv,e=e.mode;if(this._xformMode==this._ENC_XFORM_MODE)var s=e.createEncryptor;else s=e.createDecryptor,this._minBufferSize=1;this._mode=s.call(e,this,t&&t.words)},_doProcessBlock:function(e,t){this._mode.processBlock(e,t)},_doFinalize:function(){var e=this.cfg.padding;if(this._xformMode==this._ENC_XFORM_MODE){e.pad(this._data,this.blockSize);var t=this._process(!0)}else t=this._process(!0),e.unpad(t);return t},blockSize:4});var h=s.CipherParams=o.extend({init:function(e){this.mixIn(e)},toString:function(e){return(e||this.formatter).stringify(this)}}),l=(t.format={}).OpenSSL={stringify:function(e){var t=e.ciphertext;return((e=e.salt)?r.create([1398893684,1701076831]).concat(e).concat(t):t).toString(n)},parse:function(e){var t=(e=n.parse(e)).words;if(1398893684==t[0]&&1701076831==t[1]){var s=r.create(t.slice(2,4));t.splice(0,4),e.sigBytes-=16}return h.create({ciphertext:e,salt:s})}},d=s.SerializableCipher=o.extend({cfg:o.extend({format:l}),encrypt:function(e,t,s,o){o=this.cfg.extend(o);var r=e.createEncryptor(s,o);return t=r.finalize(t),r=r.cfg,h.create({ciphertext:t,key:s,iv:r.iv,algorithm:e,mode:r.mode,padding:r.padding,blockSize:e.blockSize,formatter:o.format})},decrypt:function(e,t,s,o){return o=this.cfg.extend(o),t=this._parse(t,o.format),e.createDecryptor(s,o).finalize(t.ciphertext)},_parse:function(e,t){return"string"==typeof e?t.parse(e,this):e}}),t=(t.kdf={}).OpenSSL={execute:function(e,t,s,o){return o||(o=r.random(8)),e=a.create({keySize:t+s}).compute(e,o),s=r.create(e.words.slice(t),4*s),e.sigBytes=4*t,h.create({key:e,iv:s,salt:o})}},g=s.PasswordBasedCipher=d.extend({cfg:d.cfg.extend({kdf:t}),encrypt:function(e,t,s,o){return s=(o=this.cfg.extend(o)).kdf.execute(s,e.keySize,e.ivSize),o.iv=s.iv,(e=d.encrypt.call(this,e,t,s.key,o)).mixIn(s),e},decrypt:function(e,t,s,o){return o=this.cfg.extend(o),t=this._parse(t,o.format),s=o.kdf.execute(s,e.keySize,e.ivSize,t.salt),o.iv=s.iv,d.decrypt.call(this,e,t,s.key,o)}})}(),function(){for(var e=CryptoJS,t=e.lib.BlockCipher,s=e.algo,o=[],r=[],i=[],n=[],a=[],u=[],l=[],p=[],c=[],h=[],d=[],g=0;256>g;g++)d[g]=128>g?g<<1:g<<1^283;for(var f=0,w=0,g=0;256>g;g++){var O=w^w<<1^w<<2^w<<3^w<<4,O=O>>>8^255&O^99;o[f]=O,r[O]=f;var I=d[f],m=d[I],S=d[m],N=257*d[O]^16843008*O;i[f]=N<<24|N>>>8,n[f]=N<<16|N>>>16,a[f]=N<<8|N>>>24,u[f]=N,N=16843009*S^65537*m^257*I^16843008*f,l[O]=N<<24|N>>>8,p[O]=N<<16|N>>>16,c[O]=N<<8|N>>>24,h[O]=N,f?(f=I^d[d[d[S^I]]],w^=d[d[w]]):f=w=1}var b=[0,1,2,4,8,16,32,64,128,27,54],s=s.AES=t.extend({_doReset:function(){for(var e=this._key,t=e.words,s=e.sigBytes/4,e=4*((this._nRounds=s+6)+1),r=this._keySchedule=[],i=0;i>>24]<<24|o[n>>>16&255]<<16|o[n>>>8&255]<<8|o[255&n]):(n=o[(n=n<<8|n>>>24)>>>24]<<24|o[n>>>16&255]<<16|o[n>>>8&255]<<8|o[255&n],n^=b[i/s|0]<<24),r[i]=r[i-s]^n}for(s=0,t=this._invKeySchedule=[];ss||4>=i?n:l[o[n>>>24]]^p[o[n>>>16&255]]^c[o[n>>>8&255]]^h[o[255&n]]},encryptBlock:function(e,t){this._doCryptBlock(e,t,this._keySchedule,i,n,a,u,o)},decryptBlock:function(e,t){var s=e[t+1];e[t+1]=e[t+3],e[t+3]=s,this._doCryptBlock(e,t,this._invKeySchedule,l,p,c,h,r),s=e[t+1],e[t+1]=e[t+3],e[t+3]=s},_doCryptBlock:function(e,t,s,o,r,i,n,a){for(var u=this._nRounds,l=e[t]^s[0],p=e[t+1]^s[1],c=e[t+2]^s[2],h=e[t+3]^s[3],d=4,g=1;g>>24]^r[p>>>16&255]^i[c>>>8&255]^n[255&h]^s[d++],w=o[p>>>24]^r[c>>>16&255]^i[h>>>8&255]^n[255&l]^s[d++],O=o[c>>>24]^r[h>>>16&255]^i[l>>>8&255]^n[255&p]^s[d++],h=o[h>>>24]^r[l>>>16&255]^i[p>>>8&255]^n[255&c]^s[d++],l=f,p=w,c=O;f=(a[l>>>24]<<24|a[p>>>16&255]<<16|a[c>>>8&255]<<8|a[255&h])^s[d++],w=(a[p>>>24]<<24|a[c>>>16&255]<<16|a[h>>>8&255]<<8|a[255&l])^s[d++],O=(a[c>>>24]<<24|a[h>>>16&255]<<16|a[l>>>8&255]<<8|a[255&p])^s[d++],h=(a[h>>>24]<<24|a[l>>>16&255]<<16|a[p>>>8&255]<<8|a[255&c])^s[d++],e[t]=f,e[t+1]=w,e[t+2]=O,e[t+3]=h},keySize:8});e.AES=t._createHelper(s)}();var NewgroundsIO=NewgroundsIO||{};NewgroundsIO.objects=NewgroundsIO.objects?NewgroundsIO.objects:{},NewgroundsIO.results=NewgroundsIO.results?NewgroundsIO.results:{},NewgroundsIO.components=NewgroundsIO.components?NewgroundsIO.components:{},(()=>{class e extends EventTarget{#O="https://www.newgrounds.io/gateway_v3.php";#P=!1;#Q=null;#R=null;#S=[];#T=null;#U=null;#V={};get GATEWAY_URI(){return this.#O}get debug(){return this.#P}set debug(e){this.#P=!!e}get appID(){return this.#Q}get componentQueue(){return this.#S}get hasQueue(){return this.#S.length>0}get host(){return this.#T}get session(){return this.#U}get user(){return this.#U?this.#U.user:null}get uriParams(){return this.#V}constructor(e,t){if(super(),void 0===e)throw"Missing required appID!";if(void 0===t)throw"Missing required aesKey!";if(this.#Q=e,this.#R=CryptoJS.enc.Base64.parse(t),this.#S=[],this.#V={},window&&window.location&&window.location.href?window.location.hostname?this.#T=window.location.hostname.toLowerCase():"file:"==window.location.href.toLowerCase().substr(0,5)?this.#T="":this.#T="":this.#T="","undefined"!=typeof window&&window.location){var s,o=window.location.href.split("?").pop();if(o)for(var r,i=o.split("&"),n=0;n{t instanceof NewgroundsIO.BaseComponent||(r._verifyComponent(e)||(o=!1),t.setCore(r))}),!o)return}else{if(!this._verifyComponent(e))return;e.setCore(this)}let i=this,n=this._getRequest(e);new NewgroundsIO.objects.Response;var a=new XMLHttpRequest;a.onreadystatechange=function(){if(4==a.readyState){var e;try{e=JSON.parse(a.responseText)}catch(o){(e={success:!1,app_id:i.app_id}).error={message:String(o),code:8002}}let r=i._populateResponse(e);i.dispatchEvent(new CustomEvent("serverResponse",{detail:r})),t&&(s?t.call(s,r):t(r))}};var u=void 0!==Array.prototype.toJSON?Array.prototype.toJSON:null;u&&delete Array.prototype.toJSON;let l=new FormData;l.append("request",JSON.stringify(n)),u&&(Array.prototype.toJSON=u),a.open("POST",this.GATEWAY_URI,!0),a.send(l)}loadComponent(e){if(!this._verifyComponent(e))return;e.setCore(this);let t=this._getRequest(e),s=this.GATEWAY_URI+"?request="+encodeURIComponent(JSON.stringify(t));window.open(s,"_blank")}onServerResponse(e){}_populateResponse(e){if(e.success){if(Array.isArray(e.result))for(let t=0;t{let o=s._getExecute(e);t.push(o)})):t=this._getExecute(e);let o=new NewgroundsIO.objects.Request({execute:t});return this.debug&&(o.debug=!0),o.setCore(this),o}_verifyComponent(e){return e instanceof NewgroundsIO.BaseComponent?!!e.isValid():(console.error("NewgroundsIO Type Mismatch: Expecting a NewgroundsIO.components.XXXX instance, got",e),!1)}}NewgroundsIO.Core=e})(),(()=>{class e{get type(){return this.__type}__type="object";__object="BaseObject";__properties=[];__required=[];__ngioCore=null;isValid(){if(0===this.__required.length)return!0;let e=!0;return this.__required.forEach(function(t){null===this[t]?(console.error("NewgroundsIO Error: "+this.__object+" "+this.__type+" is invalid, missing value for '"+t+"'"),e=!1):this[t]instanceof NewgroundsIO.BaseObject&&!this[t].isValid()&&(e=!1)},this),e}setCore(e){this._doSetCore(e,[])}objectMap={};arrayMap={};fromJSON(e,t){var s,o,r={};for(this.setCore(t),s=0;s{s instanceof NewgroundsIO.BaseObject&&-1===t.indexOf(s)&&s._doSetCore(e,t)},this),"host"!==s||this.host||(this.host=e.host)},this)):console.error("NewgroundsIO Error: Expecting NewgroundsIO.Core instance, got",e)}toJSON(){return this.__doToJSON()}__doToJSON(){if(void 0===this.__properties)return{};let e={};return this.__properties.forEach(function(t){null!==this[t]&&(e[t]="function"==typeof this[t].toJSON?this[t].toJSON():this[t])},this),e}toSecureJSON(){return this.__ngioCore&&this.__ngioCore instanceof NewgroundsIO.Core?{secure:this.__ngioCore.encrypt(JSON.stringify(this.__doToJSON()))}:(console.error("NewgroundsIO Error: Unable to create secure JSON object without calling setCore() first."),this.__doToJSON())}toString(){return this.__type}clone(e){return void 0===e&&(e=new this.constructor),this.__properties.forEach(t=>{e[t]=this[t]}),e.__ngioCore=this.__ngioCore,e}}NewgroundsIO.BaseObject=e;class t extends e{constructor(){super(),this.__type="component",this.__object="BaseComponent",this.__properties=["host","echo"],this._echo=null}get host(){return this.__ngioCore?this.__ngioCore.host:null}get echo(){return this._echo}set echo(e){this.echo=""+e}}NewgroundsIO.BaseComponent=t;class s extends e{constructor(){super(),this.__type="result",this.__object="BaseResult",this.__properties=["echo","error","success"],this._echo=null,this._error=null,this._success=null}get component(){return this.__object}get echo(){return this._echo}get error(){return this._error}set error(e){this._error=e}get success(){return!!this._success}set success(e){this._success=!!e}}NewgroundsIO.BaseResult=s})(),NewgroundsIO.SessionState={SESSION_UNINITIALIZED:"session-uninitialized",WAITING_FOR_SERVER:"waiting-for-server",LOGIN_REQUIRED:"login-required",WAITING_FOR_USER:"waiting-for-user",LOGIN_CANCELLED:"login-cancelled",LOGIN_SUCCESSFUL:"login-successful",LOGIN_FAILED:"login-failed",USER_LOGGED_OUT:"user-logged-out",SERVER_UNAVAILABLE:"server-unavailable",EXCEEDED_MAX_ATTEMPTS:"exceeded-max-attempts"},NewgroundsIO.SessionState.SESSION_WAITING=[NewgroundsIO.SessionState.SESSION_UNINITIALIZED,NewgroundsIO.SessionState.WAITING_FOR_SERVER,NewgroundsIO.SessionState.WAITING_FOR_USER,NewgroundsIO.SessionState.LOGIN_CANCELLED,NewgroundsIO.SessionStateLOGIN_FAILED],(()=>{class e extends NewgroundsIO.BaseComponent{constructor(){super(),this.__object="App.checkSession",this.__requireSession=!0}}void 0===NewgroundsIO.components.App&&(NewgroundsIO.components.App={}),NewgroundsIO.components.App.checkSession=e})(),(()=>{class e extends NewgroundsIO.BaseComponent{constructor(){super(),this.__object="App.endSession",this.__requireSession=!0}}void 0===NewgroundsIO.components.App&&(NewgroundsIO.components.App={}),NewgroundsIO.components.App.endSession=e})(),(()=>{class e extends NewgroundsIO.BaseComponent{constructor(e){super();let t=this;if(this.__object="App.getCurrentVersion",["version"].forEach(e=>{0>t.__properties.indexOf(e)&&t.__properties.push(e)}),e&&"object"==typeof e)for(var s=0;s{class e extends NewgroundsIO.BaseComponent{constructor(e){super();let t=this;if(this.__object="App.getHostLicense",["host"].forEach(e=>{0>t.__properties.indexOf(e)&&t.__properties.push(e)}),e&&"object"==typeof e)for(var s=0;s{class e extends NewgroundsIO.BaseComponent{constructor(e){super();let t=this;if(this.__object="App.logView",["host"].forEach(e=>{0>t.__properties.indexOf(e)&&t.__properties.push(e)}),e&&"object"==typeof e)for(var s=0;s{class e extends NewgroundsIO.BaseComponent{constructor(e){super();let t=this;if(this.__object="App.startSession",["force"].forEach(e=>{0>t.__properties.indexOf(e)&&t.__properties.push(e)}),e&&"object"==typeof e)for(var s=0;s{class e extends NewgroundsIO.BaseComponent{constructor(e){super();let t=this;if(this.__object="CloudSave.clearSlot",this.__requireSession=!0,["id"].forEach(e=>{0>t.__properties.indexOf(e)&&t.__properties.push(e)}),e&&"object"==typeof e)for(var s=0;s{class e extends NewgroundsIO.BaseComponent{constructor(e){super();let t=this;if(this.__object="CloudSave.loadSlot",this.__requireSession=!0,["id","app_id"].forEach(e=>{0>t.__properties.indexOf(e)&&t.__properties.push(e)}),e&&"object"==typeof e)for(var s=0;s{class e extends NewgroundsIO.BaseComponent{constructor(e){super();let t=this;if(this.__object="CloudSave.loadSlots",this.__requireSession=!0,["app_id"].forEach(e=>{0>t.__properties.indexOf(e)&&t.__properties.push(e)}),e&&"object"==typeof e)for(var s=0;s{class e extends NewgroundsIO.BaseComponent{constructor(e){super();let t=this;if(this.__object="CloudSave.setData",this.__requireSession=!0,["id","data"].forEach(e=>{0>t.__properties.indexOf(e)&&t.__properties.push(e)}),e&&"object"==typeof e)for(var s=0;s{class e extends NewgroundsIO.BaseComponent{constructor(e){super();let t=this;if(this.__object="Event.logEvent",["host","event_name"].forEach(e=>{0>t.__properties.indexOf(e)&&t.__properties.push(e)}),e&&"object"==typeof e)for(var s=0;s{class e extends NewgroundsIO.BaseComponent{constructor(){super(),this.__object="Gateway.getDatetime"}}void 0===NewgroundsIO.components.Gateway&&(NewgroundsIO.components.Gateway={}),NewgroundsIO.components.Gateway.getDatetime=e})(),(()=>{class e extends NewgroundsIO.BaseComponent{constructor(){super(),this.__object="Gateway.getVersion"}}void 0===NewgroundsIO.components.Gateway&&(NewgroundsIO.components.Gateway={}),NewgroundsIO.components.Gateway.getVersion=e})(),(()=>{class e extends NewgroundsIO.BaseComponent{constructor(){super(),this.__object="Gateway.ping"}}void 0===NewgroundsIO.components.Gateway&&(NewgroundsIO.components.Gateway={}),NewgroundsIO.components.Gateway.ping=e})(),(()=>{class e extends NewgroundsIO.BaseComponent{constructor(e){super();let t=this;if(this.__object="Loader.loadAuthorUrl",["host","redirect","log_stat"].forEach(e=>{0>t.__properties.indexOf(e)&&t.__properties.push(e)}),e&&"object"==typeof e)for(var s=0;s{class e extends NewgroundsIO.BaseComponent{constructor(e){super();let t=this;if(this.__object="Loader.loadMoreGames",["host","redirect","log_stat"].forEach(e=>{0>t.__properties.indexOf(e)&&t.__properties.push(e)}),e&&"object"==typeof e)for(var s=0;s{class e extends NewgroundsIO.BaseComponent{constructor(e){super();let t=this;if(this.__object="Loader.loadNewgrounds",["host","redirect","log_stat"].forEach(e=>{0>t.__properties.indexOf(e)&&t.__properties.push(e)}),e&&"object"==typeof e)for(var s=0;s{class e extends NewgroundsIO.BaseComponent{constructor(e){super();let t=this;if(this.__object="Loader.loadOfficialUrl",["host","redirect","log_stat"].forEach(e=>{0>t.__properties.indexOf(e)&&t.__properties.push(e)}),e&&"object"==typeof e)for(var s=0;s{class e extends NewgroundsIO.BaseComponent{constructor(e){super();let t=this;if(this.__object="Loader.loadReferral",["host","referral_name","redirect","log_stat"].forEach(e=>{0>t.__properties.indexOf(e)&&t.__properties.push(e)}),e&&"object"==typeof e)for(var s=0;s{class e extends NewgroundsIO.BaseComponent{constructor(e){super();let t=this;if(this.__object="Medal.getList",["app_id"].forEach(e=>{0>t.__properties.indexOf(e)&&t.__properties.push(e)}),e&&"object"==typeof e)for(var s=0;s{class e extends NewgroundsIO.BaseComponent{constructor(){super(),this.__object="Medal.getMedalScore",this.__requireSession=!0}}void 0===NewgroundsIO.components.Medal&&(NewgroundsIO.components.Medal={}),NewgroundsIO.components.Medal.getMedalScore=e})(),(()=>{class e extends NewgroundsIO.BaseComponent{constructor(e){super();let t=this;if(this.__object="Medal.unlock",this.__isSecure=!0,this.__requireSession=!0,["id"].forEach(e=>{0>t.__properties.indexOf(e)&&t.__properties.push(e)}),e&&"object"==typeof e)for(var s=0;s{class e extends NewgroundsIO.BaseComponent{constructor(){super(),this.__object="ScoreBoard.getBoards"}}void 0===NewgroundsIO.components.ScoreBoard&&(NewgroundsIO.components.ScoreBoard={}),NewgroundsIO.components.ScoreBoard.getBoards=e})(),(()=>{class e extends NewgroundsIO.BaseComponent{constructor(e){super();let t=this;if(this.__object="ScoreBoard.getScores",["id","period","tag","social","user","skip","limit","app_id"].forEach(e=>{0>t.__properties.indexOf(e)&&t.__properties.push(e)}),e&&"object"==typeof e)for(var s=0;s{class e extends NewgroundsIO.BaseComponent{constructor(e){super();let t=this;if(this.__object="ScoreBoard.postScore",this.__isSecure=!0,this.__requireSession=!0,["id","value","tag"].forEach(e=>{0>t.__properties.indexOf(e)&&t.__properties.push(e)}),e&&"object"==typeof e)for(var s=0;s{class e extends NewgroundsIO.BaseObject{constructor(e){super();let t=this;if(this.__object="Debug",["exec_time","request"].forEach(e=>{0>t.__properties.indexOf(e)&&t.__properties.push(e)}),e&&"object"==typeof e)for(var s=0;s{class e extends NewgroundsIO.BaseObject{constructor(e){super();let t=this;if(this.__object="Error",["message","code"].forEach(e=>{0>t.__properties.indexOf(e)&&t.__properties.push(e)}),e&&"object"==typeof e)for(var s=0;s{class e extends NewgroundsIO.BaseObject{constructor(e){super();let t=this;if(this.__object="Execute",["component","parameters","secure"].forEach(e=>{0>t.__properties.indexOf(e)&&t.__properties.push(e)}),e&&"object"==typeof e)for(var s=0;s{class e extends NewgroundsIO.BaseObject{constructor(e){super();let t=this;if(this.__object="Medal",["id","name","description","icon","value","difficulty","secret","unlocked"].forEach(e=>{0>t.__properties.indexOf(e)&&t.__properties.push(e)}),e&&"object"==typeof e)for(var s=0;s{class e extends NewgroundsIO.BaseObject{constructor(e){super();let t=this;if(this.__object="Request",["app_id","execute","session_id","debug"].forEach(e=>{0>t.__properties.indexOf(e)&&t.__properties.push(e)}),e&&"object"==typeof e)for(var s=0;s{class e extends NewgroundsIO.BaseObject{constructor(e){super();let t=this;if(this.__object="Response",["app_id","success","debug","result","error","api_version","help_url"].forEach(e=>{0>t.__properties.indexOf(e)&&t.__properties.push(e)}),e&&"object"==typeof e)for(var s=0;s{class e extends NewgroundsIO.BaseObject{constructor(e){super();let t=this;if(this.__object="SaveSlot",["id","size","datetime","timestamp","url"].forEach(e=>{0>t.__properties.indexOf(e)&&t.__properties.push(e)}),e&&"object"==typeof e)for(var s=0;s{class e extends NewgroundsIO.BaseObject{constructor(e){super();let t=this;if(this.__object="Score",["user","value","formatted_value","tag"].forEach(e=>{0>t.__properties.indexOf(e)&&t.__properties.push(e)}),e&&"object"==typeof e)for(var s=0;s{class e extends NewgroundsIO.BaseObject{constructor(e){super();let t=this;if(this.__object="ScoreBoard",["id","name"].forEach(e=>{0>t.__properties.indexOf(e)&&t.__properties.push(e)}),e&&"object"==typeof e)for(var s=0;s{class e extends NewgroundsIO.BaseObject{constructor(e){super();let t=this;if(this.__object="Session",["id","user","expired","remember","passport_url"].forEach(e=>{0>t.__properties.indexOf(e)&&t.__properties.push(e)}),e&&"object"==typeof e)for(var s=0;s=this.#aS?this.#aL=NewgroundsIO.SessionState.EXCEEDED_MAX_ATTEMPTS:(this.#aL=NewgroundsIO.SessionState.SESSION_UNINITIALIZED,this.#aR++)),this.status==NewgroundsIO.SessionState.SESSION_UNINITIALIZED&&(this.#aU=localStorage.getItem(this.storageKey),this.#aT?this.id=this.#aT:this.#aU&&(this.id=this.#aU),this.mode=this.id&&"null"!==this.id?"check":"new");var s=new Date;if(!(s-this.#aO<5e3))switch(this.#aO=s,this.mode){case"new":this.mode="wait",this.startSession();break;case"check":this.mode="wait",this.checkSession()}}}startSession(){this.#aP=!1,this.resetSession(),this.#aL=NewgroundsIO.SessionState.WAITING_FOR_SERVER;var e=this.__ngioCore.getComponent("App.startSession");this.__ngioCore.executeComponent(e,this._onStartSession,this)}_onStartSession(e){if(!0===e.success){let t=e.result;if(Array.isArray(t)){for(let s=0;s{class e extends NewgroundsIO.BaseObject{constructor(e){super();let t=this;if(this.__object="User",["id","name","icons","supporter"].forEach(e=>{0>t.__properties.indexOf(e)&&t.__properties.push(e)}),e&&"object"==typeof e)for(var s=0;s{class e extends NewgroundsIO.BaseObject{constructor(e){super();let t=this;if(this.__object="UserIcons",["small","medium","large"].forEach(e=>{0>t.__properties.indexOf(e)&&t.__properties.push(e)}),e&&"object"==typeof e)for(var s=0;s{class e extends NewgroundsIO.BaseResult{constructor(e){super();let t=this;if(this.__object="App.checkSession",["session"].forEach(e=>{0>t.__properties.indexOf(e)&&t.__properties.push(e)}),e&&"object"==typeof e)for(var s=0;s{class e extends NewgroundsIO.BaseResult{constructor(e){super();let t=this;if(this.__object="App.getCurrentVersion",["current_version","client_deprecated"].forEach(e=>{0>t.__properties.indexOf(e)&&t.__properties.push(e)}),e&&"object"==typeof e)for(var s=0;s{class e extends NewgroundsIO.BaseResult{constructor(e){super();let t=this;if(this.__object="App.getHostLicense",["host_approved"].forEach(e=>{0>t.__properties.indexOf(e)&&t.__properties.push(e)}),e&&"object"==typeof e)for(var s=0;s{class e extends NewgroundsIO.BaseResult{constructor(e){super();let t=this;if(this.__object="App.startSession",["session"].forEach(e=>{0>t.__properties.indexOf(e)&&t.__properties.push(e)}),e&&"object"==typeof e)for(var s=0;s{class e extends NewgroundsIO.BaseResult{constructor(e){super();let t=this;if(this.__object="CloudSave.clearSlot",["slot"].forEach(e=>{0>t.__properties.indexOf(e)&&t.__properties.push(e)}),e&&"object"==typeof e)for(var s=0;s{class e extends NewgroundsIO.BaseResult{constructor(e){super();let t=this;if(this.__object="CloudSave.loadSlot",["slot","app_id"].forEach(e=>{0>t.__properties.indexOf(e)&&t.__properties.push(e)}),e&&"object"==typeof e)for(var s=0;s{class e extends NewgroundsIO.BaseResult{constructor(e){super();let t=this;if(this.__object="CloudSave.loadSlots",["slots","app_id"].forEach(e=>{0>t.__properties.indexOf(e)&&t.__properties.push(e)}),e&&"object"==typeof e)for(var s=0;s{class e extends NewgroundsIO.BaseResult{constructor(e){super();let t=this;if(this.__object="CloudSave.setData",["slot"].forEach(e=>{0>t.__properties.indexOf(e)&&t.__properties.push(e)}),e&&"object"==typeof e)for(var s=0;s{class e extends NewgroundsIO.BaseResult{constructor(e){super();let t=this;if(this.__object="Event.logEvent",["event_name"].forEach(e=>{0>t.__properties.indexOf(e)&&t.__properties.push(e)}),e&&"object"==typeof e)for(var s=0;s{class e extends NewgroundsIO.BaseResult{constructor(e){super();let t=this;if(this.__object="Gateway.getDatetime",["datetime","timestamp"].forEach(e=>{0>t.__properties.indexOf(e)&&t.__properties.push(e)}),e&&"object"==typeof e)for(var s=0;s{class e extends NewgroundsIO.BaseResult{constructor(e){super();let t=this;if(this.__object="Gateway.getVersion",["version"].forEach(e=>{0>t.__properties.indexOf(e)&&t.__properties.push(e)}),e&&"object"==typeof e)for(var s=0;s{class e extends NewgroundsIO.BaseResult{constructor(e){super();let t=this;if(this.__object="Gateway.ping",["pong"].forEach(e=>{0>t.__properties.indexOf(e)&&t.__properties.push(e)}),e&&"object"==typeof e)for(var s=0;s{class e extends NewgroundsIO.BaseResult{constructor(e){super();let t=this;if(this.__object="Loader.loadAuthorUrl",["url"].forEach(e=>{0>t.__properties.indexOf(e)&&t.__properties.push(e)}),e&&"object"==typeof e)for(var s=0;s{class e extends NewgroundsIO.BaseResult{constructor(e){super();let t=this;if(this.__object="Loader.loadMoreGames",["url"].forEach(e=>{0>t.__properties.indexOf(e)&&t.__properties.push(e)}),e&&"object"==typeof e)for(var s=0;s{class e extends NewgroundsIO.BaseResult{constructor(e){super();let t=this;if(this.__object="Loader.loadNewgrounds",["url"].forEach(e=>{0>t.__properties.indexOf(e)&&t.__properties.push(e)}),e&&"object"==typeof e)for(var s=0;s{class e extends NewgroundsIO.BaseResult{constructor(e){super();let t=this;if(this.__object="Loader.loadOfficialUrl",["url"].forEach(e=>{0>t.__properties.indexOf(e)&&t.__properties.push(e)}),e&&"object"==typeof e)for(var s=0;s{class e extends NewgroundsIO.BaseResult{constructor(e){super();let t=this;if(this.__object="Loader.loadReferral",["url"].forEach(e=>{0>t.__properties.indexOf(e)&&t.__properties.push(e)}),e&&"object"==typeof e)for(var s=0;s{class e extends NewgroundsIO.BaseResult{constructor(e){super();let t=this;if(this.__object="Medal.getList",["medals","app_id"].forEach(e=>{0>t.__properties.indexOf(e)&&t.__properties.push(e)}),e&&"object"==typeof e)for(var s=0;s{class e extends NewgroundsIO.BaseResult{constructor(e){super();let t=this;if(this.__object="Medal.getMedalScore",["medal_score"].forEach(e=>{0>t.__properties.indexOf(e)&&t.__properties.push(e)}),e&&"object"==typeof e)for(var s=0;s{class e extends NewgroundsIO.BaseResult{constructor(e){super();let t=this;if(this.__object="Medal.unlock",["medal","medal_score"].forEach(e=>{0>t.__properties.indexOf(e)&&t.__properties.push(e)}),e&&"object"==typeof e)for(var s=0;s{class e extends NewgroundsIO.BaseResult{constructor(e){super();let t=this;if(this.__object="ScoreBoard.getBoards",["scoreboards"].forEach(e=>{0>t.__properties.indexOf(e)&&t.__properties.push(e)}),e&&"object"==typeof e)for(var s=0;s{class e extends NewgroundsIO.BaseResult{constructor(e){super();let t=this;if(this.__object="ScoreBoard.getScores",["period","social","limit","scoreboard","scores","user","app_id"].forEach(e=>{0>t.__properties.indexOf(e)&&t.__properties.push(e)}),e&&"object"==typeof e)for(var s=0;s{class e extends NewgroundsIO.BaseResult{constructor(e){super();let t=this;if(this.__object="ScoreBoard.postScore",["scoreboard","score"].forEach(e=>{0>t.__properties.indexOf(e)&&t.__properties.push(e)}),e&&"object"==typeof e)for(var s=0;s { scorePosted = true; }); @@ -9552,14 +591,14 @@ } promptLogin() { - if (isNG) { + if (NGIO.session) { NGIO.openLoginPage(); NGIO.getConnectionStatus(statusReport); } } skipLogin() { - if (isNG) { + if (NGIO.session) { NGIO.skipLogin(); NGIO.getConnectionStatus(statusReport); } @@ -9571,13 +610,41 @@ connect({ gameID, code }) { NGIO.init(gameID, code, NGOptions); + //Add a hook for the connection status to Newgrounds. NGIO.getConnectionStatus(statusReport); } + setConnectionData({ gameID, code, version }) { + return new Promise((resolve, reject) => { + NGOptions.version = version; + NGIO.init(gameID, code, NGOptions); + + //Add a hook for the connection status to Newgrounds. + const intervalID = setInterval(() => { + NGIO.getConnectionStatus(statusReport); + + //Wait for finish + switch (ConnectionStatus) { + //In case we aren't awaiting + case "Awaiting": + break; + + default: + clearInterval(intervalID); + resolve(); + break; + } + + }, 100); + }); + } + //Connection Stuff loggedIn() { + if (!NGIO.session) return false; + NGIO.getConnectionStatus(statusReport); return NGIO.hasUser; } @@ -9597,22 +664,22 @@ //User Stuff getIfSupporter() { - return userDat.supporter; + return userDat.supporter || false; } getUserDat({ datType }) { - if (isNG && loggedIn == true) { + if (NGIO.session && loggedIn) { if (datType == "MedalScore") { - return NGIO.medalScore; + return NGIO.medalScore || 0; } else { - return userDat[datType]; + return userDat[datType] || ""; } } else { if (datType == "MedalScore") { return 0; } else { if (datType == "icon") { - return userDat.icon; + return userDat.icon || ""; } return "unknown"; } @@ -9622,7 +689,7 @@ // Save Blocks onSaveCompletedHat() { - if (isNG) { + if (NGIO.session) { if (saveCompleted == true) { saveCompleted = false; return true; @@ -9633,33 +700,42 @@ } saveData({ Data, Slot }) { - if (isNG) { - NGIO.setSaveSlotData(Slot, Data, onSaveComplete); + if (NGIO.session && loggedIn) { + NGIO.setSaveSlotData(Scratch.Cast.toString(Slot), Scratch.Cast.toString(Data), onSaveComplete); } } getData({ Slot }) { - if (isNG) { + if (NGIO.session && loggedIn) { let saveDat = "Nothing in Slot"; return new Promise((resolve, reject) => { + //When the slot is loaded parse our data function onSaveDataLoaded(data) { - if (data) { - saveDat = data; - } - resolve(); + if (Scratch.Cast.toString(data).includes("404 Not Found")) saveDat = ""; + else if (data) saveDat = Scratch.Cast.toString(data); + else saveDat = ""; + + resolve(saveDat); } - NGIO.getSaveSlotData(Slot, onSaveDataLoaded); - }).then(() => { - return saveDat; - }); + + //Try to get the data + NGIO.getSaveSlotData(Scratch.Cast.toNumber(Slot), onSaveDataLoaded); + }) } else { - return "Not Newgrounds can't return Data!"; + if (NGIO.session && !loggedIn) return "Not logged in!"; + return "Can't get data from NewGrounds!"; } } doesSlotHaveData({ Slot }) { - if (isNG) { - return NGIO.getSaveSlot(Slot).hasData; + if (NGIO.session && loggedIn) { + this.revitalizeSession(); + + //get and verify save slot! + const saveSlot = NGIO.getSaveSlot(Slot); + if (!saveSlot) return; + + return saveSlot.hasData; } else { return false; } @@ -9668,26 +744,31 @@ //Medals unlockMedal({ medalID }) { - if (isNG && loggedIn == true) { - NGIO.getConnectionStatus(statusReport); - if (loggedIn) { - NGIO.keepSessionAlive(); - } + if (NGIO.session && loggedIn) { + this.revitalizeSession(); + NGIO.unlockMedal(Scratch.Cast.toNumber(medalID)); } } isMedalUnlocked({ medalID }) { - if (isNG && loggedIn == true) { - NGIO.getConnectionStatus(statusReport); - if (loggedIn) { - NGIO.keepSessionAlive(); - } - return NGIO.getMedal(Scratch.Cast.toNumber(medalID)).unlocked; + if (NGIO.session && loggedIn) { + this.revitalizeSession(); + const medal = NGIO.getMedal(Scratch.Cast.toNumber(medalID)); + + //Make sure the medal exists + if (!medal) return; + return medal.unlocked; } else { return false; } } + + revitalizeSession() { + //Get and keep the session alive + NGIO.getConnectionStatus(statusReport); + if (loggedIn) NGIO.keepSessionAlive(); + } } //Keep Session alive if game is connected. From ac84e64997371772961809b5e8d9b0e1a92a6e3a Mon Sep 17 00:00:00 2001 From: "DangoCat[bot]" Date: Fri, 26 Sep 2025 02:13:14 +0000 Subject: [PATCH 02/16] [Automated] Format code --- extensions/obviousAlexC/newgroundsIO.js | 4610 ++++++++++++++++++++++- 1 file changed, 4579 insertions(+), 31 deletions(-) diff --git a/extensions/obviousAlexC/newgroundsIO.js b/extensions/obviousAlexC/newgroundsIO.js index f646dd26d8..0a74cc1d92 100644 --- a/extensions/obviousAlexC/newgroundsIO.js +++ b/extensions/obviousAlexC/newgroundsIO.js @@ -40,8 +40,4544 @@ //Updated to the latest // prettier-ignore - class NGIO{static get STATUS_INITIALIZED(){return"initialized"}static get STATUS_CHECKING_LOCAL_VERSION(){return"checking-local-version"}static get STATUS_LOCAL_VERSION_CHECKED(){return"local-version-checked"}static get STATUS_PRELOADING_ITEMS(){return"preloading-items"}static get STATUS_ITEMS_PRELOADED(){return"items-preloaded"}static get STATUS_READY(){return"ready"}static get STATUS_SESSION_UNINITIALIZED(){return NewgroundsIO.SessionState.SESSION_UNINITIALIZED}static get STATUS_WAITING_FOR_SERVER(){return NewgroundsIO.SessionState.WAITING_FOR_SERVER}static get STATUS_LOGIN_REQUIRED(){return NewgroundsIO.SessionState.LOGIN_REQUIRED}static get STATUS_WAITING_FOR_USER(){return NewgroundsIO.SessionState.WAITING_FOR_USER}static get STATUS_LOGIN_CANCELLED(){return NewgroundsIO.SessionState.LOGIN_CANCELLED}static get STATUS_LOGIN_SUCCESSFUL(){return NewgroundsIO.SessionState.LOGIN_SUCCESSFUL}static get STATUS_LOGIN_FAILED(){return NewgroundsIO.SessionState.LOGIN_FAILED}static get STATUS_USER_LOGGED_OUT(){return NewgroundsIO.SessionState.USER_LOGGED_OUT}static get STATUS_SERVER_UNAVAILABLE(){return NewgroundsIO.SessionState.SERVER_UNAVAILABLE}static get STATUS_EXCEEDED_MAX_ATTEMPTS(){return NewgroundsIO.SessionState.EXCEEDED_MAX_ATTEMPTS}static get isWaitingStatus(){return NewgroundsIO.SessionState.SESSION_WAITING.indexOf(this.#a)>=0||[this.STATUS_PRELOADING_ITEMS,this.LOCAL_VERSION_CHECKED,this.STATUS_CHECKING_LOCAL_VERSION].indexOf(this.#a)>=0}static get PERIOD_TODAY(){return"D"}static get PERIOD_CURRENT_WEEK(){return"W"}static get PERIOD_CURRENT_MONTH(){return"M"}static get PERIOD_CURRENT_YEAR(){return"Y"}static get PERIOD_ALL_TIME(){return"A"}static get PERIODS(){return[NGIO.PERIOD_TODAY,NGIO.PERIOD_CURRENT_WEEK,NGIO.PERIOD_CURRENT_MONTH,NGIO.PERIOD_CURRENT_YEAR,NGIO.PERIOD_ALL_TIME]}static get ngioCore(){return this.#b}static #b=null;static get medalScore(){return this.#c}static #c=-1;static get medals(){return this.#d}static #d=null;static get scoreBoards(){return this.#e}static #e=null;static get saveSlots(){return this.#f}static #f=null;static get lastExecution(){return this.#g}static #g=new Date;static get lastConnectionStatus(){return this.#a}static #a=new Date;static get sessionError(){return this.#h}static #h=null;static get legalHost(){return this.#i}static #i=!0;static get isDeprecated(){return this.#j}static #j=!0;static get newestVersion(){return this.#k}static #k=!0;static get loginPageOpen(){return this.#l}static #l=!1;static get gatewayVersion(){return this.#m}static #m=!0;static get lastMedalUnlocked(){return this.#n}static #n=!0;static get lastBoardPosted(){return this.#o}static #o=!0;static get lastScorePosted(){return this.#p}static #p=!0;static get lastGetScoresResult(){return this.#q}static #q=!0;static get lastSaveSlotLoaded(){return this.#r}static #r=!0;static get lastSaveSlotSaved(){return this.#s}static #s=!0;static get lastDateTime(){return this.#t}static #t="0000-00-00";static get lastLoggedEvent(){return this.#u}static #u=null;static get lastTimeStamp(){return this.#v}static #v=0;static get lastPingSuccess(){return this.#w}static #w=!0;static get isInitialized(){return null!==this.ngioCore}static get session(){return this.isInitialized?this.ngioCore.session:null}static get user(){return null===this.session?null:this.ngioCore.session.user}static get hasSession(){return null!==this.session}static get hasUser(){return null!==this.user}static get isReady(){return this.#a===this.STATUS_READY}static get version(){return this.#x}static #x="0.0.0";static get debugMode(){return this.#y}static #y=!1;static #z={autoLogNewView:!1,preloadMedals:!1,preloadScoreBoards:!1,preloadSaveSlots:!1};static #A=!1;static #B=!1;static #C=!1;static #D=!1;static init(e,t,s){if(!this.isInitialized){if(this.#b=new NewgroundsIO.Core(e,t),this.#b.addEventListener("serverResponse",function(e){NGIO.#E(e)}),s&&"object"==typeof s){"string"==typeof s.version&&(this.#x=s.version);let o=["debugMode","checkHostLicense","autoLogNewView","preloadMedals","preloadScoreBoards","preloadSaveSlots"];for(let r=0;r{t.hasData&&e++}),e}static getSaveSlotData(e,t,s){null===this.saveSlots&&(console.error("getSaveSlotData data called without any preloaded save slots."),s?t.call(s,null):t(null));let o=this.getSaveSlot(e);this.#r=o,o.getData(t,s)}static setSaveSlotData(e,t,s,o){if(null==this.saveSlots){console.error("setSaveSlotData data called without any preloaded save slots."),"function"==typeof s&&(o?s(o,null):s(null));return}var r=this.getSaveSlot(e);if(null==r){console.error("Slot #"+e+" does not exist."),"function"==typeof s&&(o?s(o,null):s(null));return}r.setData(t,function(){"function"==typeof s&&(o?s(o,this.lastSaveSlotSaved):s(this.lastSaveSlotSaved))},this)}static logEvent(e,t,s){this.ngioCore.executeComponent(this.ngioCore.getComponent("Event.logEvent",{event_name:e}),function(){"function"==typeof t&&(s?t(s,this.lastLoggedEvent):t(this.lastLoggedEvent))},this)}static getDateTime(e,t){this.ngioCore.executeComponent(this.ngioCore.getComponent("Gateway.getDatetime"),function(){"function"==typeof e&&(t?e(t,this.lastDateTime,this.lastTimeStamp):e(this.lastDateTime,this.lastTimeStamp))},this)}static keepSessionAlive(){if(this.hasUser)(new Date-this.#g).Seconds>=3e4&&(this.#g=new Date,this.ngioCore.executeComponent(this.ngioCore.getComponent("Gateway.ping")))}static getConnectionStatus(e,t){this.#D||null===this.#a||null==this.session||(this.#D=!0,this.#a===this.STATUS_INITIALIZED?(this.#a=this.STATUS_CHECKING_LOCAL_VERSION,this.#G(e,t),this.#H(e,t)):this.#A?this.#a===this.STATUS_LOGIN_SUCCESSFUL?(this.#a=this.STATUS_PRELOADING_ITEMS,this.#G(e,t),this.#I(function(){this.#G(e,t),this.#B=!1},this)):this.#a===this.STATUS_ITEMS_PRELOADED?(this.#l=!1,this.#a=this.STATUS_READY,this.#G(e,t),this.#B=!1):this.keepSessionAlive():this.#B?this.#J(e,t):this.#a!==this.STATUS_CHECKING_LOCAL_VERSION&&this.session.update(function(){this.#J(e,t)},this),this.#D=!1)}static #J(e,t){(this.session.statusChanged||this.#B)&&(this.#a=this.session.status,(this.session.status==NewgroundsIO.SessionState.LOGIN_SUCCESSFUL||this.#B)&&(this.#a=NewgroundsIO.SessionState.LOGIN_SUCCESSFUL,this.#A=!0),this.#G(e,t)),this.#B=!1}static #G(s,o){o?s.call(o,this.#a):s(this.#a)}static #H(r,i){if(this.#C){this.#a=this.STATUS_LOCAL_VERSION_CHECKED,this.#G(r,i);return}this.ngioCore.queueComponent(this.ngioCore.getComponent("App.getCurrentVersion",{version:this.#x})),this.ngioCore.queueComponent(this.ngioCore.getComponent("Gateway.getVersion")),this.#z.autoLogNewView&&this.ngioCore.queueComponent(this.ngioCore.getComponent("App.logView")),this.#z.checkHostLicense&&this.ngioCore.queueComponent(this.ngioCore.getComponent("App.getHostLicense")),this.ngioCore.executeQueue(function(){this.#a=this.STATUS_LOCAL_VERSION_CHECKED,this.#C=!0,this.#G(r,i),this.#j&&console.warn("NGIO - Version mistmatch! Published version is: "+this.#k+", this version is: "+this.version),this.#i||(console.warn("NGIO - This host has been blocked fom hosting this game!"),this.#A=!0,this.#a=this.STATUS_ITEMS_PRELOADED,this.#G(r,i))},this)}static #I(){this.#z.preloadMedals&&(this.ngioCore.queueComponent(this.ngioCore.getComponent("Medal.getMedalScore")),this.ngioCore.queueComponent(this.ngioCore.getComponent("Medal.getList"))),this.#z.preloadScoreBoards&&this.ngioCore.queueComponent(this.ngioCore.getComponent("ScoreBoard.getBoards")),null!==this.user&&this.#z.preloadSaveSlots&&this.ngioCore.queueComponent(this.ngioCore.getComponent("CloudSave.loadSlots")),this.ngioCore.hasQueue?this.ngioCore.executeQueue(function(){this.#a=this.STATUS_ITEMS_PRELOADED},this):this.#a=this.STATUS_ITEMS_PRELOADED}static #F(){this.#a=this.STATUS_INITIALIZED,this.#l=!1,this.#B=!1,this.#A=!1}static #K(n){if(this.#f){let a=this.#f.length;for(let u=0;u>>2]|=(s[r>>>2]>>>24-8*(r%4)&255)<<24-8*((o+r)%4);else if(65535>>2]=s[r>>>2];else t.push.apply(t,s);return this.sigBytes+=e,this},clamp:function(){var t=this.words,s=this.sigBytes;t[s>>>2]&=4294967295<<32-8*(s%4),t.length=e.ceil(s/4)},clone:function(){var e=i.clone.call(this);return e.words=this.words.slice(0),e},random:function(t){for(var s=[],o=0;o>>2]>>>24-8*(o%4)&255;s.push((r>>>4).toString(16)),s.push((15&r).toString(16))}return s.join("")},parse:function(e){for(var t=e.length,s=[],o=0;o>>3]|=parseInt(e.substr(o,2),16)<<24-4*(o%8);return new n.init(s,t/2)}},l=a.Latin1={stringify:function(e){var t=e.words;e=e.sigBytes;for(var s=[],o=0;o>>2]>>>24-8*(o%4)&255));return s.join("")},parse:function(e){for(var t=e.length,s=[],o=0;o>>2]|=(255&e.charCodeAt(o))<<24-8*(o%4);return new n.init(s,t)}},p=a.Utf8={stringify:function(e){try{return decodeURIComponent(escape(l.stringify(e)))}catch(t){throw Error("Malformed UTF-8 data")}},parse:function(e){return l.parse(unescape(encodeURIComponent(e)))}},c=o.BufferedBlockAlgorithm=i.extend({reset:function(){this._data=new n.init,this._nDataBytes=0},_append:function(e){"string"==typeof e&&(e=p.parse(e)),this._data.concat(e),this._nDataBytes+=e.sigBytes},_process:function(t){var s=this._data,o=s.words,r=s.sigBytes,i=this.blockSize,a=r/(4*i),a=t?e.ceil(a):e.max((0|a)-this._minBufferSize,0);if(t=a*i,r=e.min(4*t,r),t){for(var u=0;u>>2]>>>24-8*(r%4)&255)<<16|(t[r+1>>>2]>>>24-8*((r+1)%4)&255)<<8|t[r+2>>>2]>>>24-8*((r+2)%4)&255,n=0;4>n&&r+.75*n>>6*(3-n)&63));if(t=o.charAt(64))for(;e.length%4;)e.push(t);return e.join("")},parse:function(e){var s=e.length,o=this._map,r=o.charAt(64);r&&-1!=(r=e.indexOf(r))&&(s=r);for(var r=[],i=0,n=0;n>>6-2*(n%4);r[i>>>2]|=(a|u)<<24-8*(i%4),i++}return t.create(r,i)},_map:"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/="}}(),function(e){function t(e,t,s,o,r,i,n){return((e=e+(t&s|~t&o)+r+n)<>>32-i)+t}function s(e,t,s,o,r,i,n){return((e=e+(t&o|s&~o)+r+n)<>>32-i)+t}function o(e,t,s,o,r,i,n){return((e=e+(t^s^o)+r+n)<>>32-i)+t}function r(e,t,s,o,r,i,n){return((e=e+(s^(t|~o))+r+n)<>>32-i)+t}for(var i=CryptoJS,n=i.lib,a=n.WordArray,u=n.Hasher,n=i.algo,l=[],p=0;64>p;p++)l[p]=4294967296*e.abs(e.sin(p+1))|0;n=n.MD5=u.extend({_doReset:function(){this._hash=new a.init([1732584193,4023233417,2562383102,271733878])},_doProcessBlock:function(e,i){for(var n=0;16>n;n++){var a=i+n,u=e[a];e[a]=(u<<8|u>>>24)&16711935|(u<<24|u>>>8)&4278255360}var n=this._hash.words,a=e[i+0],u=e[i+1],p=e[i+2],c=e[i+3],h=e[i+4],d=e[i+5],g=e[i+6],f=e[i+7],w=e[i+8],O=e[i+9],I=e[i+10],m=e[i+11],S=e[i+12],N=e[i+13],b=e[i+14],y=e[i+15],v=n[0],$=n[1],C=n[2],E=n[3],v=t(v,$,C,E,a,7,l[0]),E=t(E,v,$,C,u,12,l[1]),C=t(C,E,v,$,p,17,l[2]),$=t($,C,E,v,c,22,l[3]),v=t(v,$,C,E,h,7,l[4]),E=t(E,v,$,C,d,12,l[5]),C=t(C,E,v,$,g,17,l[6]),$=t($,C,E,v,f,22,l[7]),v=t(v,$,C,E,w,7,l[8]),E=t(E,v,$,C,O,12,l[9]),C=t(C,E,v,$,I,17,l[10]),$=t($,C,E,v,m,22,l[11]),v=t(v,$,C,E,S,7,l[12]),E=t(E,v,$,C,N,12,l[13]),C=t(C,E,v,$,b,17,l[14]),$=t($,C,E,v,y,22,l[15]),v=s(v,$,C,E,u,5,l[16]),E=s(E,v,$,C,g,9,l[17]),C=s(C,E,v,$,m,14,l[18]),$=s($,C,E,v,a,20,l[19]),v=s(v,$,C,E,d,5,l[20]),E=s(E,v,$,C,I,9,l[21]),C=s(C,E,v,$,y,14,l[22]),$=s($,C,E,v,h,20,l[23]),v=s(v,$,C,E,O,5,l[24]),E=s(E,v,$,C,b,9,l[25]),C=s(C,E,v,$,c,14,l[26]),$=s($,C,E,v,w,20,l[27]),v=s(v,$,C,E,N,5,l[28]),E=s(E,v,$,C,p,9,l[29]),C=s(C,E,v,$,f,14,l[30]),$=s($,C,E,v,S,20,l[31]),v=o(v,$,C,E,d,4,l[32]),E=o(E,v,$,C,w,11,l[33]),C=o(C,E,v,$,m,16,l[34]),$=o($,C,E,v,b,23,l[35]),v=o(v,$,C,E,u,4,l[36]),E=o(E,v,$,C,h,11,l[37]),C=o(C,E,v,$,f,16,l[38]),$=o($,C,E,v,I,23,l[39]),v=o(v,$,C,E,N,4,l[40]),E=o(E,v,$,C,a,11,l[41]),C=o(C,E,v,$,c,16,l[42]),$=o($,C,E,v,g,23,l[43]),v=o(v,$,C,E,O,4,l[44]),E=o(E,v,$,C,S,11,l[45]),C=o(C,E,v,$,y,16,l[46]),$=o($,C,E,v,p,23,l[47]),v=r(v,$,C,E,a,6,l[48]),E=r(E,v,$,C,f,10,l[49]),C=r(C,E,v,$,b,15,l[50]),$=r($,C,E,v,d,21,l[51]),v=r(v,$,C,E,S,6,l[52]),E=r(E,v,$,C,c,10,l[53]),C=r(C,E,v,$,I,15,l[54]),$=r($,C,E,v,u,21,l[55]),v=r(v,$,C,E,w,6,l[56]),E=r(E,v,$,C,y,10,l[57]),C=r(C,E,v,$,g,15,l[58]),$=r($,C,E,v,N,21,l[59]),v=r(v,$,C,E,h,6,l[60]),E=r(E,v,$,C,m,10,l[61]),C=r(C,E,v,$,p,15,l[62]),$=r($,C,E,v,O,21,l[63]);n[0]=n[0]+v|0,n[1]=n[1]+$|0,n[2]=n[2]+C|0,n[3]=n[3]+E|0},_doFinalize:function(){var t=this._data,s=t.words,o=8*this._nDataBytes,r=8*t.sigBytes;s[r>>>5]|=128<<24-r%32;var i=e.floor(o/4294967296);for(s[(r+64>>>9<<4)+15]=(i<<8|i>>>24)&16711935|(i<<24|i>>>8)&4278255360,s[(r+64>>>9<<4)+14]=(o<<8|o>>>24)&16711935|(o<<24|o>>>8)&4278255360,t.sigBytes=4*(s.length+1),this._process(),s=(t=this._hash).words,o=0;4>o;o++)r=s[o],s[o]=(r<<8|r>>>24)&16711935|(r<<24|r>>>8)&4278255360;return t},clone:function(){var e=u.clone.call(this);return e._hash=this._hash.clone(),e}}),i.MD5=u._createHelper(n),i.HmacMD5=u._createHmacHelper(n)}(Math),function(){var e=CryptoJS,t=e.lib,s=t.Base,o=t.WordArray,t=e.algo,r=t.EvpKDF=s.extend({cfg:s.extend({keySize:4,hasher:t.MD5,iterations:1}),init:function(e){this.cfg=this.cfg.extend(e)},compute:function(e,t){for(var s=this.cfg,r=s.hasher.create(),i=o.create(),n=i.words,a=s.keySize,s=s.iterations;n.length>>2]}},s.BlockCipher=u.extend({cfg:u.cfg.extend({mode:l,padding:c}),reset:function(){u.reset.call(this);var e=this.cfg,t=e.iv,e=e.mode;if(this._xformMode==this._ENC_XFORM_MODE)var s=e.createEncryptor;else s=e.createDecryptor,this._minBufferSize=1;this._mode=s.call(e,this,t&&t.words)},_doProcessBlock:function(e,t){this._mode.processBlock(e,t)},_doFinalize:function(){var e=this.cfg.padding;if(this._xformMode==this._ENC_XFORM_MODE){e.pad(this._data,this.blockSize);var t=this._process(!0)}else t=this._process(!0),e.unpad(t);return t},blockSize:4});var h=s.CipherParams=o.extend({init:function(e){this.mixIn(e)},toString:function(e){return(e||this.formatter).stringify(this)}}),l=(t.format={}).OpenSSL={stringify:function(e){var t=e.ciphertext;return((e=e.salt)?r.create([1398893684,1701076831]).concat(e).concat(t):t).toString(n)},parse:function(e){var t=(e=n.parse(e)).words;if(1398893684==t[0]&&1701076831==t[1]){var s=r.create(t.slice(2,4));t.splice(0,4),e.sigBytes-=16}return h.create({ciphertext:e,salt:s})}},d=s.SerializableCipher=o.extend({cfg:o.extend({format:l}),encrypt:function(e,t,s,o){o=this.cfg.extend(o);var r=e.createEncryptor(s,o);return t=r.finalize(t),r=r.cfg,h.create({ciphertext:t,key:s,iv:r.iv,algorithm:e,mode:r.mode,padding:r.padding,blockSize:e.blockSize,formatter:o.format})},decrypt:function(e,t,s,o){return o=this.cfg.extend(o),t=this._parse(t,o.format),e.createDecryptor(s,o).finalize(t.ciphertext)},_parse:function(e,t){return"string"==typeof e?t.parse(e,this):e}}),t=(t.kdf={}).OpenSSL={execute:function(e,t,s,o){return o||(o=r.random(8)),e=a.create({keySize:t+s}).compute(e,o),s=r.create(e.words.slice(t),4*s),e.sigBytes=4*t,h.create({key:e,iv:s,salt:o})}},g=s.PasswordBasedCipher=d.extend({cfg:d.cfg.extend({kdf:t}),encrypt:function(e,t,s,o){return s=(o=this.cfg.extend(o)).kdf.execute(s,e.keySize,e.ivSize),o.iv=s.iv,(e=d.encrypt.call(this,e,t,s.key,o)).mixIn(s),e},decrypt:function(e,t,s,o){return o=this.cfg.extend(o),t=this._parse(t,o.format),s=o.kdf.execute(s,e.keySize,e.ivSize,t.salt),o.iv=s.iv,d.decrypt.call(this,e,t,s.key,o)}})}(),function(){for(var e=CryptoJS,t=e.lib.BlockCipher,s=e.algo,o=[],r=[],i=[],n=[],a=[],u=[],l=[],p=[],c=[],h=[],d=[],g=0;256>g;g++)d[g]=128>g?g<<1:g<<1^283;for(var f=0,w=0,g=0;256>g;g++){var O=w^w<<1^w<<2^w<<3^w<<4,O=O>>>8^255&O^99;o[f]=O,r[O]=f;var I=d[f],m=d[I],S=d[m],N=257*d[O]^16843008*O;i[f]=N<<24|N>>>8,n[f]=N<<16|N>>>16,a[f]=N<<8|N>>>24,u[f]=N,N=16843009*S^65537*m^257*I^16843008*f,l[O]=N<<24|N>>>8,p[O]=N<<16|N>>>16,c[O]=N<<8|N>>>24,h[O]=N,f?(f=I^d[d[d[S^I]]],w^=d[d[w]]):f=w=1}var b=[0,1,2,4,8,16,32,64,128,27,54],s=s.AES=t.extend({_doReset:function(){for(var e=this._key,t=e.words,s=e.sigBytes/4,e=4*((this._nRounds=s+6)+1),r=this._keySchedule=[],i=0;i>>24]<<24|o[n>>>16&255]<<16|o[n>>>8&255]<<8|o[255&n]):(n=o[(n=n<<8|n>>>24)>>>24]<<24|o[n>>>16&255]<<16|o[n>>>8&255]<<8|o[255&n],n^=b[i/s|0]<<24),r[i]=r[i-s]^n}for(s=0,t=this._invKeySchedule=[];ss||4>=i?n:l[o[n>>>24]]^p[o[n>>>16&255]]^c[o[n>>>8&255]]^h[o[255&n]]},encryptBlock:function(e,t){this._doCryptBlock(e,t,this._keySchedule,i,n,a,u,o)},decryptBlock:function(e,t){var s=e[t+1];e[t+1]=e[t+3],e[t+3]=s,this._doCryptBlock(e,t,this._invKeySchedule,l,p,c,h,r),s=e[t+1],e[t+1]=e[t+3],e[t+3]=s},_doCryptBlock:function(e,t,s,o,r,i,n,a){for(var u=this._nRounds,l=e[t]^s[0],p=e[t+1]^s[1],c=e[t+2]^s[2],h=e[t+3]^s[3],d=4,g=1;g>>24]^r[p>>>16&255]^i[c>>>8&255]^n[255&h]^s[d++],w=o[p>>>24]^r[c>>>16&255]^i[h>>>8&255]^n[255&l]^s[d++],O=o[c>>>24]^r[h>>>16&255]^i[l>>>8&255]^n[255&p]^s[d++],h=o[h>>>24]^r[l>>>16&255]^i[p>>>8&255]^n[255&c]^s[d++],l=f,p=w,c=O;f=(a[l>>>24]<<24|a[p>>>16&255]<<16|a[c>>>8&255]<<8|a[255&h])^s[d++],w=(a[p>>>24]<<24|a[c>>>16&255]<<16|a[h>>>8&255]<<8|a[255&l])^s[d++],O=(a[c>>>24]<<24|a[h>>>16&255]<<16|a[l>>>8&255]<<8|a[255&p])^s[d++],h=(a[h>>>24]<<24|a[l>>>16&255]<<16|a[p>>>8&255]<<8|a[255&c])^s[d++],e[t]=f,e[t+1]=w,e[t+2]=O,e[t+3]=h},keySize:8});e.AES=t._createHelper(s)}();var NewgroundsIO=NewgroundsIO||{};NewgroundsIO.objects=NewgroundsIO.objects?NewgroundsIO.objects:{},NewgroundsIO.results=NewgroundsIO.results?NewgroundsIO.results:{},NewgroundsIO.components=NewgroundsIO.components?NewgroundsIO.components:{},(()=>{class e extends EventTarget{#O="https://www.newgrounds.io/gateway_v3.php";#P=!1;#Q=null;#R=null;#S=[];#T=null;#U=null;#V={};get GATEWAY_URI(){return this.#O}get debug(){return this.#P}set debug(e){this.#P=!!e}get appID(){return this.#Q}get componentQueue(){return this.#S}get hasQueue(){return this.#S.length>0}get host(){return this.#T}get session(){return this.#U}get user(){return this.#U?this.#U.user:null}get uriParams(){return this.#V}constructor(e,t){if(super(),void 0===e)throw"Missing required appID!";if(void 0===t)throw"Missing required aesKey!";if(this.#Q=e,this.#R=CryptoJS.enc.Base64.parse(t),this.#S=[],this.#V={},window&&window.location&&window.location.href?window.location.hostname?this.#T=window.location.hostname.toLowerCase():"file:"==window.location.href.toLowerCase().substr(0,5)?this.#T="":this.#T="":this.#T="","undefined"!=typeof window&&window.location){var s,o=window.location.href.split("?").pop();if(o)for(var r,i=o.split("&"),n=0;n{t instanceof NewgroundsIO.BaseComponent||(r._verifyComponent(e)||(o=!1),t.setCore(r))}),!o)return}else{if(!this._verifyComponent(e))return;e.setCore(this)}let i=this,n=this._getRequest(e);new NewgroundsIO.objects.Response;var a=new XMLHttpRequest;a.onreadystatechange=function(){if(4==a.readyState){var e;try{e=JSON.parse(a.responseText)}catch(o){(e={success:!1,app_id:i.app_id}).error={message:String(o),code:8002}}let r=i._populateResponse(e);i.dispatchEvent(new CustomEvent("serverResponse",{detail:r})),t&&(s?t.call(s,r):t(r))}};var u=void 0!==Array.prototype.toJSON?Array.prototype.toJSON:null;u&&delete Array.prototype.toJSON;let l=new FormData;l.append("request",JSON.stringify(n)),u&&(Array.prototype.toJSON=u),a.open("POST",this.GATEWAY_URI,!0),a.send(l)}loadComponent(e){if(!this._verifyComponent(e))return;e.setCore(this);let t=this._getRequest(e),s=this.GATEWAY_URI+"?request="+encodeURIComponent(JSON.stringify(t));window.open(s,"_blank")}onServerResponse(e){}_populateResponse(e){if(e.success){if(Array.isArray(e.result))for(let t=0;t{let o=s._getExecute(e);t.push(o)})):t=this._getExecute(e);let o=new NewgroundsIO.objects.Request({execute:t});return this.debug&&(o.debug=!0),o.setCore(this),o}_verifyComponent(e){return e instanceof NewgroundsIO.BaseComponent?!!e.isValid():(console.error("NewgroundsIO Type Mismatch: Expecting a NewgroundsIO.components.XXXX instance, got",e),!1)}}NewgroundsIO.Core=e})(),(()=>{class e{get type(){return this.__type}__type="object";__object="BaseObject";__properties=[];__required=[];__ngioCore=null;isValid(){if(0===this.__required.length)return!0;let e=!0;return this.__required.forEach(function(t){null===this[t]?(console.error("NewgroundsIO Error: "+this.__object+" "+this.__type+" is invalid, missing value for '"+t+"'"),e=!1):this[t]instanceof NewgroundsIO.BaseObject&&!this[t].isValid()&&(e=!1)},this),e}setCore(e){this._doSetCore(e,[])}objectMap={};arrayMap={};fromJSON(e,t){var s,o,r={};for(this.setCore(t),s=0;s{s instanceof NewgroundsIO.BaseObject&&-1===t.indexOf(s)&&s._doSetCore(e,t)},this),"host"!==s||this.host||(this.host=e.host)},this)):console.error("NewgroundsIO Error: Expecting NewgroundsIO.Core instance, got",e)}toJSON(){return this.__doToJSON()}__doToJSON(){if(void 0===this.__properties)return{};let e={};return this.__properties.forEach(function(t){null!==this[t]&&(e[t]="function"==typeof this[t].toJSON?this[t].toJSON():this[t])},this),e}toSecureJSON(){return this.__ngioCore&&this.__ngioCore instanceof NewgroundsIO.Core?{secure:this.__ngioCore.encrypt(JSON.stringify(this.__doToJSON()))}:(console.error("NewgroundsIO Error: Unable to create secure JSON object without calling setCore() first."),this.__doToJSON())}toString(){return this.__type}clone(e){return void 0===e&&(e=new this.constructor),this.__properties.forEach(t=>{e[t]=this[t]}),e.__ngioCore=this.__ngioCore,e}}NewgroundsIO.BaseObject=e;class t extends e{constructor(){super(),this.__type="component",this.__object="BaseComponent",this.__properties=["host","echo"],this._echo=null}get host(){return this.__ngioCore?this.__ngioCore.host:null}get echo(){return this._echo}set echo(e){this.echo=""+e}}NewgroundsIO.BaseComponent=t;class s extends e{constructor(){super(),this.__type="result",this.__object="BaseResult",this.__properties=["echo","error","success"],this._echo=null,this._error=null,this._success=null}get component(){return this.__object}get echo(){return this._echo}get error(){return this._error}set error(e){this._error=e}get success(){return!!this._success}set success(e){this._success=!!e}}NewgroundsIO.BaseResult=s})(),NewgroundsIO.SessionState={SESSION_UNINITIALIZED:"session-uninitialized",WAITING_FOR_SERVER:"waiting-for-server",LOGIN_REQUIRED:"login-required",WAITING_FOR_USER:"waiting-for-user",LOGIN_CANCELLED:"login-cancelled",LOGIN_SUCCESSFUL:"login-successful",LOGIN_FAILED:"login-failed",USER_LOGGED_OUT:"user-logged-out",SERVER_UNAVAILABLE:"server-unavailable",EXCEEDED_MAX_ATTEMPTS:"exceeded-max-attempts"},NewgroundsIO.SessionState.SESSION_WAITING=[NewgroundsIO.SessionState.SESSION_UNINITIALIZED,NewgroundsIO.SessionState.WAITING_FOR_SERVER,NewgroundsIO.SessionState.WAITING_FOR_USER,NewgroundsIO.SessionState.LOGIN_CANCELLED,NewgroundsIO.SessionStateLOGIN_FAILED],(()=>{class e extends NewgroundsIO.BaseComponent{constructor(){super(),this.__object="App.checkSession",this.__requireSession=!0}}void 0===NewgroundsIO.components.App&&(NewgroundsIO.components.App={}),NewgroundsIO.components.App.checkSession=e})(),(()=>{class e extends NewgroundsIO.BaseComponent{constructor(){super(),this.__object="App.endSession",this.__requireSession=!0}}void 0===NewgroundsIO.components.App&&(NewgroundsIO.components.App={}),NewgroundsIO.components.App.endSession=e})(),(()=>{class e extends NewgroundsIO.BaseComponent{constructor(e){super();let t=this;if(this.__object="App.getCurrentVersion",["version"].forEach(e=>{0>t.__properties.indexOf(e)&&t.__properties.push(e)}),e&&"object"==typeof e)for(var s=0;s{class e extends NewgroundsIO.BaseComponent{constructor(e){super();let t=this;if(this.__object="App.getHostLicense",["host"].forEach(e=>{0>t.__properties.indexOf(e)&&t.__properties.push(e)}),e&&"object"==typeof e)for(var s=0;s{class e extends NewgroundsIO.BaseComponent{constructor(e){super();let t=this;if(this.__object="App.logView",["host"].forEach(e=>{0>t.__properties.indexOf(e)&&t.__properties.push(e)}),e&&"object"==typeof e)for(var s=0;s{class e extends NewgroundsIO.BaseComponent{constructor(e){super();let t=this;if(this.__object="App.startSession",["force"].forEach(e=>{0>t.__properties.indexOf(e)&&t.__properties.push(e)}),e&&"object"==typeof e)for(var s=0;s{class e extends NewgroundsIO.BaseComponent{constructor(e){super();let t=this;if(this.__object="CloudSave.clearSlot",this.__requireSession=!0,["id"].forEach(e=>{0>t.__properties.indexOf(e)&&t.__properties.push(e)}),e&&"object"==typeof e)for(var s=0;s{class e extends NewgroundsIO.BaseComponent{constructor(e){super();let t=this;if(this.__object="CloudSave.loadSlot",this.__requireSession=!0,["id","app_id"].forEach(e=>{0>t.__properties.indexOf(e)&&t.__properties.push(e)}),e&&"object"==typeof e)for(var s=0;s{class e extends NewgroundsIO.BaseComponent{constructor(e){super();let t=this;if(this.__object="CloudSave.loadSlots",this.__requireSession=!0,["app_id"].forEach(e=>{0>t.__properties.indexOf(e)&&t.__properties.push(e)}),e&&"object"==typeof e)for(var s=0;s{class e extends NewgroundsIO.BaseComponent{constructor(e){super();let t=this;if(this.__object="CloudSave.setData",this.__requireSession=!0,["id","data"].forEach(e=>{0>t.__properties.indexOf(e)&&t.__properties.push(e)}),e&&"object"==typeof e)for(var s=0;s{class e extends NewgroundsIO.BaseComponent{constructor(e){super();let t=this;if(this.__object="Event.logEvent",["host","event_name"].forEach(e=>{0>t.__properties.indexOf(e)&&t.__properties.push(e)}),e&&"object"==typeof e)for(var s=0;s{class e extends NewgroundsIO.BaseComponent{constructor(){super(),this.__object="Gateway.getDatetime"}}void 0===NewgroundsIO.components.Gateway&&(NewgroundsIO.components.Gateway={}),NewgroundsIO.components.Gateway.getDatetime=e})(),(()=>{class e extends NewgroundsIO.BaseComponent{constructor(){super(),this.__object="Gateway.getVersion"}}void 0===NewgroundsIO.components.Gateway&&(NewgroundsIO.components.Gateway={}),NewgroundsIO.components.Gateway.getVersion=e})(),(()=>{class e extends NewgroundsIO.BaseComponent{constructor(){super(),this.__object="Gateway.ping"}}void 0===NewgroundsIO.components.Gateway&&(NewgroundsIO.components.Gateway={}),NewgroundsIO.components.Gateway.ping=e})(),(()=>{class e extends NewgroundsIO.BaseComponent{constructor(e){super();let t=this;if(this.__object="Loader.loadAuthorUrl",["host","redirect","log_stat"].forEach(e=>{0>t.__properties.indexOf(e)&&t.__properties.push(e)}),e&&"object"==typeof e)for(var s=0;s{class e extends NewgroundsIO.BaseComponent{constructor(e){super();let t=this;if(this.__object="Loader.loadMoreGames",["host","redirect","log_stat"].forEach(e=>{0>t.__properties.indexOf(e)&&t.__properties.push(e)}),e&&"object"==typeof e)for(var s=0;s{class e extends NewgroundsIO.BaseComponent{constructor(e){super();let t=this;if(this.__object="Loader.loadNewgrounds",["host","redirect","log_stat"].forEach(e=>{0>t.__properties.indexOf(e)&&t.__properties.push(e)}),e&&"object"==typeof e)for(var s=0;s{class e extends NewgroundsIO.BaseComponent{constructor(e){super();let t=this;if(this.__object="Loader.loadOfficialUrl",["host","redirect","log_stat"].forEach(e=>{0>t.__properties.indexOf(e)&&t.__properties.push(e)}),e&&"object"==typeof e)for(var s=0;s{class e extends NewgroundsIO.BaseComponent{constructor(e){super();let t=this;if(this.__object="Loader.loadReferral",["host","referral_name","redirect","log_stat"].forEach(e=>{0>t.__properties.indexOf(e)&&t.__properties.push(e)}),e&&"object"==typeof e)for(var s=0;s{class e extends NewgroundsIO.BaseComponent{constructor(e){super();let t=this;if(this.__object="Medal.getList",["app_id"].forEach(e=>{0>t.__properties.indexOf(e)&&t.__properties.push(e)}),e&&"object"==typeof e)for(var s=0;s{class e extends NewgroundsIO.BaseComponent{constructor(){super(),this.__object="Medal.getMedalScore",this.__requireSession=!0}}void 0===NewgroundsIO.components.Medal&&(NewgroundsIO.components.Medal={}),NewgroundsIO.components.Medal.getMedalScore=e})(),(()=>{class e extends NewgroundsIO.BaseComponent{constructor(e){super();let t=this;if(this.__object="Medal.unlock",this.__isSecure=!0,this.__requireSession=!0,["id"].forEach(e=>{0>t.__properties.indexOf(e)&&t.__properties.push(e)}),e&&"object"==typeof e)for(var s=0;s{class e extends NewgroundsIO.BaseComponent{constructor(){super(),this.__object="ScoreBoard.getBoards"}}void 0===NewgroundsIO.components.ScoreBoard&&(NewgroundsIO.components.ScoreBoard={}),NewgroundsIO.components.ScoreBoard.getBoards=e})(),(()=>{class e extends NewgroundsIO.BaseComponent{constructor(e){super();let t=this;if(this.__object="ScoreBoard.getScores",["id","period","tag","social","user","skip","limit","app_id"].forEach(e=>{0>t.__properties.indexOf(e)&&t.__properties.push(e)}),e&&"object"==typeof e)for(var s=0;s{class e extends NewgroundsIO.BaseComponent{constructor(e){super();let t=this;if(this.__object="ScoreBoard.postScore",this.__isSecure=!0,this.__requireSession=!0,["id","value","tag"].forEach(e=>{0>t.__properties.indexOf(e)&&t.__properties.push(e)}),e&&"object"==typeof e)for(var s=0;s{class e extends NewgroundsIO.BaseObject{constructor(e){super();let t=this;if(this.__object="Debug",["exec_time","request"].forEach(e=>{0>t.__properties.indexOf(e)&&t.__properties.push(e)}),e&&"object"==typeof e)for(var s=0;s{class e extends NewgroundsIO.BaseObject{constructor(e){super();let t=this;if(this.__object="Error",["message","code"].forEach(e=>{0>t.__properties.indexOf(e)&&t.__properties.push(e)}),e&&"object"==typeof e)for(var s=0;s{class e extends NewgroundsIO.BaseObject{constructor(e){super();let t=this;if(this.__object="Execute",["component","parameters","secure"].forEach(e=>{0>t.__properties.indexOf(e)&&t.__properties.push(e)}),e&&"object"==typeof e)for(var s=0;s{class e extends NewgroundsIO.BaseObject{constructor(e){super();let t=this;if(this.__object="Medal",["id","name","description","icon","value","difficulty","secret","unlocked"].forEach(e=>{0>t.__properties.indexOf(e)&&t.__properties.push(e)}),e&&"object"==typeof e)for(var s=0;s{class e extends NewgroundsIO.BaseObject{constructor(e){super();let t=this;if(this.__object="Request",["app_id","execute","session_id","debug"].forEach(e=>{0>t.__properties.indexOf(e)&&t.__properties.push(e)}),e&&"object"==typeof e)for(var s=0;s{class e extends NewgroundsIO.BaseObject{constructor(e){super();let t=this;if(this.__object="Response",["app_id","success","debug","result","error","api_version","help_url"].forEach(e=>{0>t.__properties.indexOf(e)&&t.__properties.push(e)}),e&&"object"==typeof e)for(var s=0;s{class e extends NewgroundsIO.BaseObject{constructor(e){super();let t=this;if(this.__object="SaveSlot",["id","size","datetime","timestamp","url"].forEach(e=>{0>t.__properties.indexOf(e)&&t.__properties.push(e)}),e&&"object"==typeof e)for(var s=0;s{class e extends NewgroundsIO.BaseObject{constructor(e){super();let t=this;if(this.__object="Score",["user","value","formatted_value","tag"].forEach(e=>{0>t.__properties.indexOf(e)&&t.__properties.push(e)}),e&&"object"==typeof e)for(var s=0;s{class e extends NewgroundsIO.BaseObject{constructor(e){super();let t=this;if(this.__object="ScoreBoard",["id","name"].forEach(e=>{0>t.__properties.indexOf(e)&&t.__properties.push(e)}),e&&"object"==typeof e)for(var s=0;s{class e extends NewgroundsIO.BaseObject{constructor(e){super();let t=this;if(this.__object="Session",["id","user","expired","remember","passport_url"].forEach(e=>{0>t.__properties.indexOf(e)&&t.__properties.push(e)}),e&&"object"==typeof e)for(var s=0;s=this.#aS?this.#aL=NewgroundsIO.SessionState.EXCEEDED_MAX_ATTEMPTS:(this.#aL=NewgroundsIO.SessionState.SESSION_UNINITIALIZED,this.#aR++)),this.status==NewgroundsIO.SessionState.SESSION_UNINITIALIZED&&(this.#aU=localStorage.getItem(this.storageKey),this.#aT?this.id=this.#aT:this.#aU&&(this.id=this.#aU),this.mode=this.id&&"null"!==this.id?"check":"new");var s=new Date;if(!(s-this.#aO<5e3))switch(this.#aO=s,this.mode){case"new":this.mode="wait",this.startSession();break;case"check":this.mode="wait",this.checkSession()}}}startSession(){this.#aP=!1,this.resetSession(),this.#aL=NewgroundsIO.SessionState.WAITING_FOR_SERVER;var e=this.__ngioCore.getComponent("App.startSession");this.__ngioCore.executeComponent(e,this._onStartSession,this)}_onStartSession(e){if(!0===e.success){let t=e.result;if(Array.isArray(t)){for(let s=0;s{class e extends NewgroundsIO.BaseObject{constructor(e){super();let t=this;if(this.__object="User",["id","name","icons","supporter"].forEach(e=>{0>t.__properties.indexOf(e)&&t.__properties.push(e)}),e&&"object"==typeof e)for(var s=0;s{class e extends NewgroundsIO.BaseObject{constructor(e){super();let t=this;if(this.__object="UserIcons",["small","medium","large"].forEach(e=>{0>t.__properties.indexOf(e)&&t.__properties.push(e)}),e&&"object"==typeof e)for(var s=0;s{class e extends NewgroundsIO.BaseResult{constructor(e){super();let t=this;if(this.__object="App.checkSession",["session"].forEach(e=>{0>t.__properties.indexOf(e)&&t.__properties.push(e)}),e&&"object"==typeof e)for(var s=0;s{class e extends NewgroundsIO.BaseResult{constructor(e){super();let t=this;if(this.__object="App.getCurrentVersion",["current_version","client_deprecated"].forEach(e=>{0>t.__properties.indexOf(e)&&t.__properties.push(e)}),e&&"object"==typeof e)for(var s=0;s{class e extends NewgroundsIO.BaseResult{constructor(e){super();let t=this;if(this.__object="App.getHostLicense",["host_approved"].forEach(e=>{0>t.__properties.indexOf(e)&&t.__properties.push(e)}),e&&"object"==typeof e)for(var s=0;s{class e extends NewgroundsIO.BaseResult{constructor(e){super();let t=this;if(this.__object="App.startSession",["session"].forEach(e=>{0>t.__properties.indexOf(e)&&t.__properties.push(e)}),e&&"object"==typeof e)for(var s=0;s{class e extends NewgroundsIO.BaseResult{constructor(e){super();let t=this;if(this.__object="CloudSave.clearSlot",["slot"].forEach(e=>{0>t.__properties.indexOf(e)&&t.__properties.push(e)}),e&&"object"==typeof e)for(var s=0;s{class e extends NewgroundsIO.BaseResult{constructor(e){super();let t=this;if(this.__object="CloudSave.loadSlot",["slot","app_id"].forEach(e=>{0>t.__properties.indexOf(e)&&t.__properties.push(e)}),e&&"object"==typeof e)for(var s=0;s{class e extends NewgroundsIO.BaseResult{constructor(e){super();let t=this;if(this.__object="CloudSave.loadSlots",["slots","app_id"].forEach(e=>{0>t.__properties.indexOf(e)&&t.__properties.push(e)}),e&&"object"==typeof e)for(var s=0;s{class e extends NewgroundsIO.BaseResult{constructor(e){super();let t=this;if(this.__object="CloudSave.setData",["slot"].forEach(e=>{0>t.__properties.indexOf(e)&&t.__properties.push(e)}),e&&"object"==typeof e)for(var s=0;s{class e extends NewgroundsIO.BaseResult{constructor(e){super();let t=this;if(this.__object="Event.logEvent",["event_name"].forEach(e=>{0>t.__properties.indexOf(e)&&t.__properties.push(e)}),e&&"object"==typeof e)for(var s=0;s{class e extends NewgroundsIO.BaseResult{constructor(e){super();let t=this;if(this.__object="Gateway.getDatetime",["datetime","timestamp"].forEach(e=>{0>t.__properties.indexOf(e)&&t.__properties.push(e)}),e&&"object"==typeof e)for(var s=0;s{class e extends NewgroundsIO.BaseResult{constructor(e){super();let t=this;if(this.__object="Gateway.getVersion",["version"].forEach(e=>{0>t.__properties.indexOf(e)&&t.__properties.push(e)}),e&&"object"==typeof e)for(var s=0;s{class e extends NewgroundsIO.BaseResult{constructor(e){super();let t=this;if(this.__object="Gateway.ping",["pong"].forEach(e=>{0>t.__properties.indexOf(e)&&t.__properties.push(e)}),e&&"object"==typeof e)for(var s=0;s{class e extends NewgroundsIO.BaseResult{constructor(e){super();let t=this;if(this.__object="Loader.loadAuthorUrl",["url"].forEach(e=>{0>t.__properties.indexOf(e)&&t.__properties.push(e)}),e&&"object"==typeof e)for(var s=0;s{class e extends NewgroundsIO.BaseResult{constructor(e){super();let t=this;if(this.__object="Loader.loadMoreGames",["url"].forEach(e=>{0>t.__properties.indexOf(e)&&t.__properties.push(e)}),e&&"object"==typeof e)for(var s=0;s{class e extends NewgroundsIO.BaseResult{constructor(e){super();let t=this;if(this.__object="Loader.loadNewgrounds",["url"].forEach(e=>{0>t.__properties.indexOf(e)&&t.__properties.push(e)}),e&&"object"==typeof e)for(var s=0;s{class e extends NewgroundsIO.BaseResult{constructor(e){super();let t=this;if(this.__object="Loader.loadOfficialUrl",["url"].forEach(e=>{0>t.__properties.indexOf(e)&&t.__properties.push(e)}),e&&"object"==typeof e)for(var s=0;s{class e extends NewgroundsIO.BaseResult{constructor(e){super();let t=this;if(this.__object="Loader.loadReferral",["url"].forEach(e=>{0>t.__properties.indexOf(e)&&t.__properties.push(e)}),e&&"object"==typeof e)for(var s=0;s{class e extends NewgroundsIO.BaseResult{constructor(e){super();let t=this;if(this.__object="Medal.getList",["medals","app_id"].forEach(e=>{0>t.__properties.indexOf(e)&&t.__properties.push(e)}),e&&"object"==typeof e)for(var s=0;s{class e extends NewgroundsIO.BaseResult{constructor(e){super();let t=this;if(this.__object="Medal.getMedalScore",["medal_score"].forEach(e=>{0>t.__properties.indexOf(e)&&t.__properties.push(e)}),e&&"object"==typeof e)for(var s=0;s{class e extends NewgroundsIO.BaseResult{constructor(e){super();let t=this;if(this.__object="Medal.unlock",["medal","medal_score"].forEach(e=>{0>t.__properties.indexOf(e)&&t.__properties.push(e)}),e&&"object"==typeof e)for(var s=0;s{class e extends NewgroundsIO.BaseResult{constructor(e){super();let t=this;if(this.__object="ScoreBoard.getBoards",["scoreboards"].forEach(e=>{0>t.__properties.indexOf(e)&&t.__properties.push(e)}),e&&"object"==typeof e)for(var s=0;s{class e extends NewgroundsIO.BaseResult{constructor(e){super();let t=this;if(this.__object="ScoreBoard.getScores",["period","social","limit","scoreboard","scores","user","app_id"].forEach(e=>{0>t.__properties.indexOf(e)&&t.__properties.push(e)}),e&&"object"==typeof e)for(var s=0;s{class e extends NewgroundsIO.BaseResult{constructor(e){super();let t=this;if(this.__object="ScoreBoard.postScore",["scoreboard","score"].forEach(e=>{0>t.__properties.indexOf(e)&&t.__properties.push(e)}),e&&"object"==typeof e)for(var s=0;s=0||[this.STATUS_PRELOADING_ITEMS,this.LOCAL_VERSION_CHECKED,this.STATUS_CHECKING_LOCAL_VERSION].indexOf(this.#a)>=0}static get PERIOD_TODAY(){return"D"}static get PERIOD_CURRENT_WEEK(){return"W"}static get PERIOD_CURRENT_MONTH(){return"M"}static get PERIOD_CURRENT_YEAR(){return"Y"}static get PERIOD_ALL_TIME(){return"A"}static get PERIODS(){return[NGIO.PERIOD_TODAY,NGIO.PERIOD_CURRENT_WEEK,NGIO.PERIOD_CURRENT_MONTH,NGIO.PERIOD_CURRENT_YEAR,NGIO.PERIOD_ALL_TIME]}static get ngioCore(){return this.#b}static #b=null;static get medalScore(){return this.#c}static #c=-1;static get medals(){return this.#d}static #d=null;static get scoreBoards(){return this.#e}static #e=null;static get saveSlots(){return this.#f}static #f=null;static get lastExecution(){return this.#g}static #g=new Date;static get lastConnectionStatus(){return this.#a}static #a=new Date;static get sessionError(){return this.#h}static #h=null;static get legalHost(){return this.#i}static #i=!0;static get isDeprecated(){return this.#j}static #j=!0;static get newestVersion(){return this.#k}static #k=!0;static get loginPageOpen(){return this.#l}static #l=!1;static get gatewayVersion(){return this.#m}static #m=!0;static get lastMedalUnlocked(){return this.#n}static #n=!0;static get lastBoardPosted(){return this.#o}static #o=!0;static get lastScorePosted(){return this.#p}static #p=!0;static get lastGetScoresResult(){return this.#q}static #q=!0;static get lastSaveSlotLoaded(){return this.#r}static #r=!0;static get lastSaveSlotSaved(){return this.#s}static #s=!0;static get lastDateTime(){return this.#t}static #t="0000-00-00";static get lastLoggedEvent(){return this.#u}static #u=null;static get lastTimeStamp(){return this.#v}static #v=0;static get lastPingSuccess(){return this.#w}static #w=!0;static get isInitialized(){return null!==this.ngioCore}static get session(){return this.isInitialized?this.ngioCore.session:null}static get user(){return null===this.session?null:this.ngioCore.session.user}static get hasSession(){return null!==this.session}static get hasUser(){return null!==this.user}static get isReady(){return this.#a===this.STATUS_READY}static get version(){return this.#x}static #x="0.0.0";static get debugMode(){return this.#y}static #y=!1;static #z={autoLogNewView:!1,preloadMedals:!1,preloadScoreBoards:!1,preloadSaveSlots:!1};static #A=!1;static #B=!1;static #C=!1;static #D=!1;static init(e,t,s){if(!this.isInitialized){if(this.#b=new NewgroundsIO.Core(e,t),this.#b.addEventListener("serverResponse",function(e){NGIO.#E(e)}),s&&"object"==typeof s){"string"==typeof s.version&&(this.#x=s.version);let o=["debugMode","checkHostLicense","autoLogNewView","preloadMedals","preloadScoreBoards","preloadSaveSlots"];for(let r=0;r{t.hasData&&e++}),e}static getSaveSlotData(e,t,s){null===this.saveSlots&&(console.error("getSaveSlotData data called without any preloaded save slots."),s?t.call(s,null):t(null));let o=this.getSaveSlot(e);this.#r=o,o.getData(t,s)}static setSaveSlotData(e,t,s,o){if(null==this.saveSlots){console.error("setSaveSlotData data called without any preloaded save slots."),"function"==typeof s&&(o?s(o,null):s(null));return}var r=this.getSaveSlot(e);if(null==r){console.error("Slot #"+e+" does not exist."),"function"==typeof s&&(o?s(o,null):s(null));return}r.setData(t,function(){"function"==typeof s&&(o?s(o,this.lastSaveSlotSaved):s(this.lastSaveSlotSaved))},this)}static logEvent(e,t,s){this.ngioCore.executeComponent(this.ngioCore.getComponent("Event.logEvent",{event_name:e}),function(){"function"==typeof t&&(s?t(s,this.lastLoggedEvent):t(this.lastLoggedEvent))},this)}static getDateTime(e,t){this.ngioCore.executeComponent(this.ngioCore.getComponent("Gateway.getDatetime"),function(){"function"==typeof e&&(t?e(t,this.lastDateTime,this.lastTimeStamp):e(this.lastDateTime,this.lastTimeStamp))},this)}static keepSessionAlive(){if(this.hasUser)(new Date-this.#g).Seconds>=3e4&&(this.#g=new Date,this.ngioCore.executeComponent(this.ngioCore.getComponent("Gateway.ping")))}static getConnectionStatus(e,t){this.#D||null===this.#a||null==this.session||(this.#D=!0,this.#a===this.STATUS_INITIALIZED?(this.#a=this.STATUS_CHECKING_LOCAL_VERSION,this.#G(e,t),this.#H(e,t)):this.#A?this.#a===this.STATUS_LOGIN_SUCCESSFUL?(this.#a=this.STATUS_PRELOADING_ITEMS,this.#G(e,t),this.#I(function(){this.#G(e,t),this.#B=!1},this)):this.#a===this.STATUS_ITEMS_PRELOADED?(this.#l=!1,this.#a=this.STATUS_READY,this.#G(e,t),this.#B=!1):this.keepSessionAlive():this.#B?this.#J(e,t):this.#a!==this.STATUS_CHECKING_LOCAL_VERSION&&this.session.update(function(){this.#J(e,t)},this),this.#D=!1)}static #J(e,t){(this.session.statusChanged||this.#B)&&(this.#a=this.session.status,(this.session.status==NewgroundsIO.SessionState.LOGIN_SUCCESSFUL||this.#B)&&(this.#a=NewgroundsIO.SessionState.LOGIN_SUCCESSFUL,this.#A=!0),this.#G(e,t)),this.#B=!1}static #G(s,o){o?s.call(o,this.#a):s(this.#a)}static #H(r,i){if(this.#C){this.#a=this.STATUS_LOCAL_VERSION_CHECKED,this.#G(r,i);return}this.ngioCore.queueComponent(this.ngioCore.getComponent("App.getCurrentVersion",{version:this.#x})),this.ngioCore.queueComponent(this.ngioCore.getComponent("Gateway.getVersion")),this.#z.autoLogNewView&&this.ngioCore.queueComponent(this.ngioCore.getComponent("App.logView")),this.#z.checkHostLicense&&this.ngioCore.queueComponent(this.ngioCore.getComponent("App.getHostLicense")),this.ngioCore.executeQueue(function(){this.#a=this.STATUS_LOCAL_VERSION_CHECKED,this.#C=!0,this.#G(r,i),this.#j&&console.warn("NGIO - Version mistmatch! Published version is: "+this.#k+", this version is: "+this.version),this.#i||(console.warn("NGIO - This host has been blocked fom hosting this game!"),this.#A=!0,this.#a=this.STATUS_ITEMS_PRELOADED,this.#G(r,i))},this)}static #I(){this.#z.preloadMedals&&(this.ngioCore.queueComponent(this.ngioCore.getComponent("Medal.getMedalScore")),this.ngioCore.queueComponent(this.ngioCore.getComponent("Medal.getList"))),this.#z.preloadScoreBoards&&this.ngioCore.queueComponent(this.ngioCore.getComponent("ScoreBoard.getBoards")),null!==this.user&&this.#z.preloadSaveSlots&&this.ngioCore.queueComponent(this.ngioCore.getComponent("CloudSave.loadSlots")),this.ngioCore.hasQueue?this.ngioCore.executeQueue(function(){this.#a=this.STATUS_ITEMS_PRELOADED},this):this.#a=this.STATUS_ITEMS_PRELOADED}static #F(){this.#a=this.STATUS_INITIALIZED,this.#l=!1,this.#B=!1,this.#A=!1}static #K(n){if(this.#f){let a=this.#f.length;for(let u=0;u>> 2] |= + ((s[r >>> 2] >>> (24 - 8 * (r % 4))) & 255) << + (24 - 8 * ((o + r) % 4)); + else if (65535 < s.length) + for (r = 0; r < e; r += 4) t[(o + r) >>> 2] = s[r >>> 2]; + else t.push.apply(t, s); + return ((this.sigBytes += e), this); + }, + clamp: function () { + var t = this.words, + s = this.sigBytes; + ((t[s >>> 2] &= 4294967295 << (32 - 8 * (s % 4))), + (t.length = e.ceil(s / 4))); + }, + clone: function () { + var e = i.clone.call(this); + return ((e.words = this.words.slice(0)), e); + }, + random: function (t) { + for (var s = [], o = 0; o < t; o += 4) + s.push((4294967296 * e.random()) | 0); + return new n.init(s, t); + }, + })), + a = (s.enc = {}), + u = (a.Hex = { + stringify: function (e) { + var t = e.words; + e = e.sigBytes; + for (var s = [], o = 0; o < e; o++) { + var r = (t[o >>> 2] >>> (24 - 8 * (o % 4))) & 255; + (s.push((r >>> 4).toString(16)), s.push((15 & r).toString(16))); + } + return s.join(""); + }, + parse: function (e) { + for (var t = e.length, s = [], o = 0; o < t; o += 2) + s[o >>> 3] |= parseInt(e.substr(o, 2), 16) << (24 - 4 * (o % 8)); + return new n.init(s, t / 2); + }, + }), + l = (a.Latin1 = { + stringify: function (e) { + var t = e.words; + e = e.sigBytes; + for (var s = [], o = 0; o < e; o++) + s.push( + String.fromCharCode((t[o >>> 2] >>> (24 - 8 * (o % 4))) & 255) + ); + return s.join(""); + }, + parse: function (e) { + for (var t = e.length, s = [], o = 0; o < t; o++) + s[o >>> 2] |= (255 & e.charCodeAt(o)) << (24 - 8 * (o % 4)); + return new n.init(s, t); + }, + }), + p = (a.Utf8 = { + stringify: function (e) { + try { + return decodeURIComponent(escape(l.stringify(e))); + } catch (t) { + throw Error("Malformed UTF-8 data"); + } + }, + parse: function (e) { + return l.parse(unescape(encodeURIComponent(e))); + }, + }), + c = (o.BufferedBlockAlgorithm = i.extend({ + reset: function () { + ((this._data = new n.init()), (this._nDataBytes = 0)); + }, + _append: function (e) { + ("string" == typeof e && (e = p.parse(e)), + this._data.concat(e), + (this._nDataBytes += e.sigBytes)); + }, + _process: function (t) { + var s = this._data, + o = s.words, + r = s.sigBytes, + i = this.blockSize, + a = r / (4 * i), + a = t ? e.ceil(a) : e.max((0 | a) - this._minBufferSize, 0); + if (((t = a * i), (r = e.min(4 * t, r)), t)) { + for (var u = 0; u < t; u += i) this._doProcessBlock(o, u); + ((u = o.splice(0, t)), (s.sigBytes -= r)); + } + return new n.init(u, r); + }, + clone: function () { + var e = i.clone.call(this); + return ((e._data = this._data.clone()), e); + }, + _minBufferSize: 0, + })); + o.Hasher = c.extend({ + cfg: i.extend(), + init: function (e) { + ((this.cfg = this.cfg.extend(e)), this.reset()); + }, + reset: function () { + (c.reset.call(this), this._doReset()); + }, + update: function (e) { + return (this._append(e), this._process(), this); + }, + finalize: function (e) { + return (e && this._append(e), this._doFinalize()); + }, + blockSize: 16, + _createHelper: function (e) { + return function (t, s) { + return new e.init(s).finalize(t); + }; + }, + _createHmacHelper: function (e) { + return function (t, s) { + return new h.HMAC.init(e, s).finalize(t); + }; + }, + }); + var h = (s.algo = {}); + return s; + })(Math); + (!(function () { + var e = CryptoJS, + t = e.lib.WordArray; + e.enc.Base64 = { + stringify: function (e) { + var t = e.words, + s = e.sigBytes, + o = this._map; + (e.clamp(), (e = [])); + for (var r = 0; r < s; r += 3) + for ( + var i = + (((t[r >>> 2] >>> (24 - 8 * (r % 4))) & 255) << 16) | + (((t[(r + 1) >>> 2] >>> (24 - 8 * ((r + 1) % 4))) & 255) << 8) | + ((t[(r + 2) >>> 2] >>> (24 - 8 * ((r + 2) % 4))) & 255), + n = 0; + 4 > n && r + 0.75 * n < s; + n++ + ) + e.push(o.charAt((i >>> (6 * (3 - n))) & 63)); + if ((t = o.charAt(64))) for (; e.length % 4; ) e.push(t); + return e.join(""); + }, + parse: function (e) { + var s = e.length, + o = this._map, + r = o.charAt(64); + r && -1 != (r = e.indexOf(r)) && (s = r); + for (var r = [], i = 0, n = 0; n < s; n++) + if (n % 4) { + var a = o.indexOf(e.charAt(n - 1)) << (2 * (n % 4)), + u = o.indexOf(e.charAt(n)) >>> (6 - 2 * (n % 4)); + ((r[i >>> 2] |= (a | u) << (24 - 8 * (i % 4))), i++); + } + return t.create(r, i); + }, + _map: "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=", + }; + })(), + (function (e) { + function t(e, t, s, o, r, i, n) { + return ( + (((e = e + ((t & s) | (~t & o)) + r + n) << i) | (e >>> (32 - i))) + t + ); + } + function s(e, t, s, o, r, i, n) { + return ( + (((e = e + ((t & o) | (s & ~o)) + r + n) << i) | (e >>> (32 - i))) + t + ); + } + function o(e, t, s, o, r, i, n) { + return (((e = e + (t ^ s ^ o) + r + n) << i) | (e >>> (32 - i))) + t; + } + function r(e, t, s, o, r, i, n) { + return (((e = e + (s ^ (t | ~o)) + r + n) << i) | (e >>> (32 - i))) + t; + } + for ( + var i = CryptoJS, + n = i.lib, + a = n.WordArray, + u = n.Hasher, + n = i.algo, + l = [], + p = 0; + 64 > p; + p++ + ) + l[p] = (4294967296 * e.abs(e.sin(p + 1))) | 0; + ((n = n.MD5 = + u.extend({ + _doReset: function () { + this._hash = new a.init([ + 1732584193, 4023233417, 2562383102, 271733878, + ]); + }, + _doProcessBlock: function (e, i) { + for (var n = 0; 16 > n; n++) { + var a = i + n, + u = e[a]; + e[a] = + (((u << 8) | (u >>> 24)) & 16711935) | + (((u << 24) | (u >>> 8)) & 4278255360); + } + var n = this._hash.words, + a = e[i + 0], + u = e[i + 1], + p = e[i + 2], + c = e[i + 3], + h = e[i + 4], + d = e[i + 5], + g = e[i + 6], + f = e[i + 7], + w = e[i + 8], + O = e[i + 9], + I = e[i + 10], + m = e[i + 11], + S = e[i + 12], + N = e[i + 13], + b = e[i + 14], + y = e[i + 15], + v = n[0], + $ = n[1], + C = n[2], + E = n[3], + v = t(v, $, C, E, a, 7, l[0]), + E = t(E, v, $, C, u, 12, l[1]), + C = t(C, E, v, $, p, 17, l[2]), + $ = t($, C, E, v, c, 22, l[3]), + v = t(v, $, C, E, h, 7, l[4]), + E = t(E, v, $, C, d, 12, l[5]), + C = t(C, E, v, $, g, 17, l[6]), + $ = t($, C, E, v, f, 22, l[7]), + v = t(v, $, C, E, w, 7, l[8]), + E = t(E, v, $, C, O, 12, l[9]), + C = t(C, E, v, $, I, 17, l[10]), + $ = t($, C, E, v, m, 22, l[11]), + v = t(v, $, C, E, S, 7, l[12]), + E = t(E, v, $, C, N, 12, l[13]), + C = t(C, E, v, $, b, 17, l[14]), + $ = t($, C, E, v, y, 22, l[15]), + v = s(v, $, C, E, u, 5, l[16]), + E = s(E, v, $, C, g, 9, l[17]), + C = s(C, E, v, $, m, 14, l[18]), + $ = s($, C, E, v, a, 20, l[19]), + v = s(v, $, C, E, d, 5, l[20]), + E = s(E, v, $, C, I, 9, l[21]), + C = s(C, E, v, $, y, 14, l[22]), + $ = s($, C, E, v, h, 20, l[23]), + v = s(v, $, C, E, O, 5, l[24]), + E = s(E, v, $, C, b, 9, l[25]), + C = s(C, E, v, $, c, 14, l[26]), + $ = s($, C, E, v, w, 20, l[27]), + v = s(v, $, C, E, N, 5, l[28]), + E = s(E, v, $, C, p, 9, l[29]), + C = s(C, E, v, $, f, 14, l[30]), + $ = s($, C, E, v, S, 20, l[31]), + v = o(v, $, C, E, d, 4, l[32]), + E = o(E, v, $, C, w, 11, l[33]), + C = o(C, E, v, $, m, 16, l[34]), + $ = o($, C, E, v, b, 23, l[35]), + v = o(v, $, C, E, u, 4, l[36]), + E = o(E, v, $, C, h, 11, l[37]), + C = o(C, E, v, $, f, 16, l[38]), + $ = o($, C, E, v, I, 23, l[39]), + v = o(v, $, C, E, N, 4, l[40]), + E = o(E, v, $, C, a, 11, l[41]), + C = o(C, E, v, $, c, 16, l[42]), + $ = o($, C, E, v, g, 23, l[43]), + v = o(v, $, C, E, O, 4, l[44]), + E = o(E, v, $, C, S, 11, l[45]), + C = o(C, E, v, $, y, 16, l[46]), + $ = o($, C, E, v, p, 23, l[47]), + v = r(v, $, C, E, a, 6, l[48]), + E = r(E, v, $, C, f, 10, l[49]), + C = r(C, E, v, $, b, 15, l[50]), + $ = r($, C, E, v, d, 21, l[51]), + v = r(v, $, C, E, S, 6, l[52]), + E = r(E, v, $, C, c, 10, l[53]), + C = r(C, E, v, $, I, 15, l[54]), + $ = r($, C, E, v, u, 21, l[55]), + v = r(v, $, C, E, w, 6, l[56]), + E = r(E, v, $, C, y, 10, l[57]), + C = r(C, E, v, $, g, 15, l[58]), + $ = r($, C, E, v, N, 21, l[59]), + v = r(v, $, C, E, h, 6, l[60]), + E = r(E, v, $, C, m, 10, l[61]), + C = r(C, E, v, $, p, 15, l[62]), + $ = r($, C, E, v, O, 21, l[63]); + ((n[0] = (n[0] + v) | 0), + (n[1] = (n[1] + $) | 0), + (n[2] = (n[2] + C) | 0), + (n[3] = (n[3] + E) | 0)); + }, + _doFinalize: function () { + var t = this._data, + s = t.words, + o = 8 * this._nDataBytes, + r = 8 * t.sigBytes; + s[r >>> 5] |= 128 << (24 - (r % 32)); + var i = e.floor(o / 4294967296); + for ( + s[(((r + 64) >>> 9) << 4) + 15] = + (((i << 8) | (i >>> 24)) & 16711935) | + (((i << 24) | (i >>> 8)) & 4278255360), + s[(((r + 64) >>> 9) << 4) + 14] = + (((o << 8) | (o >>> 24)) & 16711935) | + (((o << 24) | (o >>> 8)) & 4278255360), + t.sigBytes = 4 * (s.length + 1), + this._process(), + s = (t = this._hash).words, + o = 0; + 4 > o; + o++ + ) + ((r = s[o]), + (s[o] = + (((r << 8) | (r >>> 24)) & 16711935) | + (((r << 24) | (r >>> 8)) & 4278255360))); + return t; + }, + clone: function () { + var e = u.clone.call(this); + return ((e._hash = this._hash.clone()), e); + }, + })), + (i.MD5 = u._createHelper(n)), + (i.HmacMD5 = u._createHmacHelper(n))); + })(Math), + (function () { + var e = CryptoJS, + t = e.lib, + s = t.Base, + o = t.WordArray, + t = e.algo, + r = (t.EvpKDF = s.extend({ + cfg: s.extend({ keySize: 4, hasher: t.MD5, iterations: 1 }), + init: function (e) { + this.cfg = this.cfg.extend(e); + }, + compute: function (e, t) { + for ( + var s = this.cfg, + r = s.hasher.create(), + i = o.create(), + n = i.words, + a = s.keySize, + s = s.iterations; + n.length < a; + + ) { + u && r.update(u); + var u = r.update(e).finalize(t); + r.reset(); + for (var l = 1; l < s; l++) ((u = r.finalize(u)), r.reset()); + i.concat(u); + } + return ((i.sigBytes = 4 * a), i); + }, + })); + e.EvpKDF = function (e, t, s) { + return r.create(s).compute(e, t); + }; + })(), + CryptoJS.lib.Cipher || + (function (e) { + var t = CryptoJS, + s = t.lib, + o = s.Base, + r = s.WordArray, + i = s.BufferedBlockAlgorithm, + n = t.enc.Base64, + a = t.algo.EvpKDF, + u = (s.Cipher = i.extend({ + cfg: o.extend(), + createEncryptor: function (e, t) { + return this.create(this._ENC_XFORM_MODE, e, t); + }, + createDecryptor: function (e, t) { + return this.create(this._DEC_XFORM_MODE, e, t); + }, + init: function (e, t, s) { + ((this.cfg = this.cfg.extend(s)), + (this._xformMode = e), + (this._key = t), + this.reset()); + }, + reset: function () { + (i.reset.call(this), this._doReset()); + }, + process: function (e) { + return (this._append(e), this._process()); + }, + finalize: function (e) { + return (e && this._append(e), this._doFinalize()); + }, + keySize: 4, + ivSize: 4, + _ENC_XFORM_MODE: 1, + _DEC_XFORM_MODE: 2, + _createHelper: function (e) { + return { + encrypt: function (t, s, o) { + return ("string" == typeof s ? g : d).encrypt(e, t, s, o); + }, + decrypt: function (t, s, o) { + return ("string" == typeof s ? g : d).decrypt(e, t, s, o); + }, + }; + }, + })); + s.StreamCipher = u.extend({ + _doFinalize: function () { + return this._process(!0); + }, + blockSize: 1, + }); + var l = (t.mode = {}), + p = function (e, t, s) { + var o = this._iv; + o ? (this._iv = void 0) : (o = this._prevBlock); + for (var r = 0; r < s; r++) e[t + r] ^= o[r]; + }, + c = (s.BlockCipherMode = o.extend({ + createEncryptor: function (e, t) { + return this.Encryptor.create(e, t); + }, + createDecryptor: function (e, t) { + return this.Decryptor.create(e, t); + }, + init: function (e, t) { + ((this._cipher = e), (this._iv = t)); + }, + })).extend(); + ((c.Encryptor = c.extend({ + processBlock: function (e, t) { + var s = this._cipher, + o = s.blockSize; + (p.call(this, e, t, o), + s.encryptBlock(e, t), + (this._prevBlock = e.slice(t, t + o))); + }, + })), + (c.Decryptor = c.extend({ + processBlock: function (e, t) { + var s = this._cipher, + o = s.blockSize, + r = e.slice(t, t + o); + (s.decryptBlock(e, t), + p.call(this, e, t, o), + (this._prevBlock = r)); + }, + })), + (l = l.CBC = c), + (c = (t.pad = {}).Pkcs7 = + { + pad: function (e, t) { + for ( + var s = 4 * t, + s = s - (e.sigBytes % s), + o = (s << 24) | (s << 16) | (s << 8) | s, + i = [], + n = 0; + n < s; + n += 4 + ) + i.push(o); + ((s = r.create(i, s)), e.concat(s)); + }, + unpad: function (e) { + e.sigBytes -= 255 & e.words[(e.sigBytes - 1) >>> 2]; + }, + }), + (s.BlockCipher = u.extend({ + cfg: u.cfg.extend({ mode: l, padding: c }), + reset: function () { + u.reset.call(this); + var e = this.cfg, + t = e.iv, + e = e.mode; + if (this._xformMode == this._ENC_XFORM_MODE) + var s = e.createEncryptor; + else ((s = e.createDecryptor), (this._minBufferSize = 1)); + this._mode = s.call(e, this, t && t.words); + }, + _doProcessBlock: function (e, t) { + this._mode.processBlock(e, t); + }, + _doFinalize: function () { + var e = this.cfg.padding; + if (this._xformMode == this._ENC_XFORM_MODE) { + e.pad(this._data, this.blockSize); + var t = this._process(!0); + } else ((t = this._process(!0)), e.unpad(t)); + return t; + }, + blockSize: 4, + }))); + var h = (s.CipherParams = o.extend({ + init: function (e) { + this.mixIn(e); + }, + toString: function (e) { + return (e || this.formatter).stringify(this); + }, + })), + l = ((t.format = {}).OpenSSL = { + stringify: function (e) { + var t = e.ciphertext; + return ( + (e = e.salt) + ? r.create([1398893684, 1701076831]).concat(e).concat(t) + : t + ).toString(n); + }, + parse: function (e) { + var t = (e = n.parse(e)).words; + if (1398893684 == t[0] && 1701076831 == t[1]) { + var s = r.create(t.slice(2, 4)); + (t.splice(0, 4), (e.sigBytes -= 16)); + } + return h.create({ ciphertext: e, salt: s }); + }, + }), + d = (s.SerializableCipher = o.extend({ + cfg: o.extend({ format: l }), + encrypt: function (e, t, s, o) { + o = this.cfg.extend(o); + var r = e.createEncryptor(s, o); + return ( + (t = r.finalize(t)), + (r = r.cfg), + h.create({ + ciphertext: t, + key: s, + iv: r.iv, + algorithm: e, + mode: r.mode, + padding: r.padding, + blockSize: e.blockSize, + formatter: o.format, + }) + ); + }, + decrypt: function (e, t, s, o) { + return ( + (o = this.cfg.extend(o)), + (t = this._parse(t, o.format)), + e.createDecryptor(s, o).finalize(t.ciphertext) + ); + }, + _parse: function (e, t) { + return "string" == typeof e ? t.parse(e, this) : e; + }, + })), + t = ((t.kdf = {}).OpenSSL = { + execute: function (e, t, s, o) { + return ( + o || (o = r.random(8)), + (e = a.create({ keySize: t + s }).compute(e, o)), + (s = r.create(e.words.slice(t), 4 * s)), + (e.sigBytes = 4 * t), + h.create({ key: e, iv: s, salt: o }) + ); + }, + }), + g = (s.PasswordBasedCipher = d.extend({ + cfg: d.cfg.extend({ kdf: t }), + encrypt: function (e, t, s, o) { + return ( + (s = (o = this.cfg.extend(o)).kdf.execute( + s, + e.keySize, + e.ivSize + )), + (o.iv = s.iv), + (e = d.encrypt.call(this, e, t, s.key, o)).mixIn(s), + e + ); + }, + decrypt: function (e, t, s, o) { + return ( + (o = this.cfg.extend(o)), + (t = this._parse(t, o.format)), + (s = o.kdf.execute(s, e.keySize, e.ivSize, t.salt)), + (o.iv = s.iv), + d.decrypt.call(this, e, t, s.key, o) + ); + }, + })); + })(), + (function () { + for ( + var e = CryptoJS, + t = e.lib.BlockCipher, + s = e.algo, + o = [], + r = [], + i = [], + n = [], + a = [], + u = [], + l = [], + p = [], + c = [], + h = [], + d = [], + g = 0; + 256 > g; + g++ + ) + d[g] = 128 > g ? g << 1 : (g << 1) ^ 283; + for (var f = 0, w = 0, g = 0; 256 > g; g++) { + var O = w ^ (w << 1) ^ (w << 2) ^ (w << 3) ^ (w << 4), + O = (O >>> 8) ^ (255 & O) ^ 99; + ((o[f] = O), (r[O] = f)); + var I = d[f], + m = d[I], + S = d[m], + N = (257 * d[O]) ^ (16843008 * O); + ((i[f] = (N << 24) | (N >>> 8)), + (n[f] = (N << 16) | (N >>> 16)), + (a[f] = (N << 8) | (N >>> 24)), + (u[f] = N), + (N = (16843009 * S) ^ (65537 * m) ^ (257 * I) ^ (16843008 * f)), + (l[O] = (N << 24) | (N >>> 8)), + (p[O] = (N << 16) | (N >>> 16)), + (c[O] = (N << 8) | (N >>> 24)), + (h[O] = N), + f ? ((f = I ^ d[d[d[S ^ I]]]), (w ^= d[d[w]])) : (f = w = 1)); + } + var b = [0, 1, 2, 4, 8, 16, 32, 64, 128, 27, 54], + s = (s.AES = t.extend({ + _doReset: function () { + for ( + var e = this._key, + t = e.words, + s = e.sigBytes / 4, + e = 4 * ((this._nRounds = s + 6) + 1), + r = (this._keySchedule = []), + i = 0; + i < e; + i++ + ) + if (i < s) r[i] = t[i]; + else { + var n = r[i - 1]; + (i % s + ? 6 < s && + 4 == i % s && + (n = + (o[n >>> 24] << 24) | + (o[(n >>> 16) & 255] << 16) | + (o[(n >>> 8) & 255] << 8) | + o[255 & n]) + : ((n = + (o[(n = (n << 8) | (n >>> 24)) >>> 24] << 24) | + (o[(n >>> 16) & 255] << 16) | + (o[(n >>> 8) & 255] << 8) | + o[255 & n]), + (n ^= b[(i / s) | 0] << 24)), + (r[i] = r[i - s] ^ n)); + } + for (s = 0, t = this._invKeySchedule = []; s < e; s++) + ((i = e - s), + (n = s % 4 ? r[i] : r[i - 4]), + (t[s] = + 4 > s || 4 >= i + ? n + : l[o[n >>> 24]] ^ + p[o[(n >>> 16) & 255]] ^ + c[o[(n >>> 8) & 255]] ^ + h[o[255 & n]])); + }, + encryptBlock: function (e, t) { + this._doCryptBlock(e, t, this._keySchedule, i, n, a, u, o); + }, + decryptBlock: function (e, t) { + var s = e[t + 1]; + ((e[t + 1] = e[t + 3]), + (e[t + 3] = s), + this._doCryptBlock(e, t, this._invKeySchedule, l, p, c, h, r), + (s = e[t + 1]), + (e[t + 1] = e[t + 3]), + (e[t + 3] = s)); + }, + _doCryptBlock: function (e, t, s, o, r, i, n, a) { + for ( + var u = this._nRounds, + l = e[t] ^ s[0], + p = e[t + 1] ^ s[1], + c = e[t + 2] ^ s[2], + h = e[t + 3] ^ s[3], + d = 4, + g = 1; + g < u; + g++ + ) + var f = + o[l >>> 24] ^ + r[(p >>> 16) & 255] ^ + i[(c >>> 8) & 255] ^ + n[255 & h] ^ + s[d++], + w = + o[p >>> 24] ^ + r[(c >>> 16) & 255] ^ + i[(h >>> 8) & 255] ^ + n[255 & l] ^ + s[d++], + O = + o[c >>> 24] ^ + r[(h >>> 16) & 255] ^ + i[(l >>> 8) & 255] ^ + n[255 & p] ^ + s[d++], + h = + o[h >>> 24] ^ + r[(l >>> 16) & 255] ^ + i[(p >>> 8) & 255] ^ + n[255 & c] ^ + s[d++], + l = f, + p = w, + c = O; + ((f = + ((a[l >>> 24] << 24) | + (a[(p >>> 16) & 255] << 16) | + (a[(c >>> 8) & 255] << 8) | + a[255 & h]) ^ + s[d++]), + (w = + ((a[p >>> 24] << 24) | + (a[(c >>> 16) & 255] << 16) | + (a[(h >>> 8) & 255] << 8) | + a[255 & l]) ^ + s[d++]), + (O = + ((a[c >>> 24] << 24) | + (a[(h >>> 16) & 255] << 16) | + (a[(l >>> 8) & 255] << 8) | + a[255 & p]) ^ + s[d++]), + (h = + ((a[h >>> 24] << 24) | + (a[(l >>> 16) & 255] << 16) | + (a[(p >>> 8) & 255] << 8) | + a[255 & c]) ^ + s[d++]), + (e[t] = f), + (e[t + 1] = w), + (e[t + 2] = O), + (e[t + 3] = h)); + }, + keySize: 8, + })); + e.AES = t._createHelper(s); + })()); + var NewgroundsIO = NewgroundsIO || {}; + ((NewgroundsIO.objects = NewgroundsIO.objects ? NewgroundsIO.objects : {}), + (NewgroundsIO.results = NewgroundsIO.results ? NewgroundsIO.results : {}), + (NewgroundsIO.components = NewgroundsIO.components + ? NewgroundsIO.components + : {}), + (() => { + class e extends EventTarget { + #O = "https://www.newgrounds.io/gateway_v3.php"; + #P = !1; + #Q = null; + #R = null; + #S = []; + #T = null; + #U = null; + #V = {}; + get GATEWAY_URI() { + return this.#O; + } + get debug() { + return this.#P; + } + set debug(e) { + this.#P = !!e; + } + get appID() { + return this.#Q; + } + get componentQueue() { + return this.#S; + } + get hasQueue() { + return this.#S.length > 0; + } + get host() { + return this.#T; + } + get session() { + return this.#U; + } + get user() { + return this.#U ? this.#U.user : null; + } + get uriParams() { + return this.#V; + } + constructor(e, t) { + if ((super(), void 0 === e)) throw "Missing required appID!"; + if (void 0 === t) throw "Missing required aesKey!"; + if ( + ((this.#Q = e), + (this.#R = CryptoJS.enc.Base64.parse(t)), + (this.#S = []), + (this.#V = {}), + window && window.location && window.location.href + ? window.location.hostname + ? (this.#T = window.location.hostname.toLowerCase()) + : "file:" == window.location.href.toLowerCase().substr(0, 5) + ? (this.#T = "") + : (this.#T = "") + : (this.#T = ""), + "undefined" != typeof window && window.location) + ) { + var s, + o = window.location.href.split("?").pop(); + if (o) + for (var r, i = o.split("&"), n = 0; n < i.length; n++) + ((r = i[n].split("=")), (this.#V[r[0]] = r[1])); + } + ((this.#U = this.getObject("Session")), + (this.#U.uri_id = this.getUriParam("ngio_session_id", null))); + } + getUriParam(e, t) { + return void 0 === this.#V[e] ? t : this.#V[e]; + } + encrypt(e) { + let t = CryptoJS.lib.WordArray.random(16), + s = CryptoJS.AES.encrypt(e, this.#R, { iv: t }); + return CryptoJS.enc.Base64.stringify(t.concat(s.ciphertext)); + } + getObject(e, t) { + if (void 0 === NewgroundsIO.objects[e]) + return ( + console.error("NewgroundsIO - Invalid object name: " + e), + null + ); + var s = new NewgroundsIO.objects[e](t); + return (s.setCore(this), s); + } + getComponent(e, t) { + var s = e.split("."), + o = !1; + if ( + (2 !== s.length + ? (o = "Invalid component name: " + e) + : void 0 === NewgroundsIO.components[s[0]] + ? (o = "Invalid component name: " + e) + : void 0 === NewgroundsIO.components[s[0]][s[1]] && + (o = "Invalid component name: " + e), + o) + ) + return (console.error("NewgroundsIO - " + o), null); + var r = new NewgroundsIO.components[s[0]][s[1]](t); + return (r.setCore(this), r); + } + queueComponent(e) { + this._verifyComponent(e) && (e.setCore(this), this.#S.push(e)); + } + executeQueue(e, t) { + this.#S.length < 1 || + (this.executeComponent(this.#S, e, t), (this.#S = [])); + } + executeComponent(e, t, s) { + if (Array.isArray(e)) { + let o = !0, + r = this; + if ( + (e.forEach((t) => { + t instanceof NewgroundsIO.BaseComponent || + (r._verifyComponent(e) || (o = !1), t.setCore(r)); + }), + !o) + ) + return; + } else { + if (!this._verifyComponent(e)) return; + e.setCore(this); + } + let i = this, + n = this._getRequest(e); + new NewgroundsIO.objects.Response(); + var a = new XMLHttpRequest(); + a.onreadystatechange = function () { + if (4 == a.readyState) { + var e; + try { + e = JSON.parse(a.responseText); + } catch (o) { + (e = { success: !1, app_id: i.app_id }).error = { + message: String(o), + code: 8002, + }; + } + let r = i._populateResponse(e); + (i.dispatchEvent( + new CustomEvent("serverResponse", { detail: r }) + ), + t && (s ? t.call(s, r) : t(r))); + } + }; + var u = + void 0 !== Array.prototype.toJSON ? Array.prototype.toJSON : null; + u && delete Array.prototype.toJSON; + let l = new FormData(); + (l.append("request", JSON.stringify(n)), + u && (Array.prototype.toJSON = u), + a.open("POST", this.GATEWAY_URI, !0), + a.send(l)); + } + loadComponent(e) { + if (!this._verifyComponent(e)) return; + e.setCore(this); + let t = this._getRequest(e), + s = + this.GATEWAY_URI + + "?request=" + + encodeURIComponent(JSON.stringify(t)); + window.open(s, "_blank"); + } + onServerResponse(e) {} + _populateResponse(e) { + if (e.success) { + if (Array.isArray(e.result)) + for (let t = 0; t < e.result.length; t++) + e.result[t] = this._populateResult(e.result[t]); + else e.result = this._populateResult(e.result); + } else + (e.result && delete e.result, + e.error && (e.error = new NewgroundsIO.objects.Error(e.error))); + return ((e = new NewgroundsIO.objects.Response(e)).setCore(this), e); + } + _populateResult(e) { + let t = e.component.split("."), + s = NewgroundsIO.results[t[0]][t[1]]; + if (!s) return null; + e.data.component = e.component; + let o = new s(); + return (o.fromJSON(e.data, this), o); + } + _getExecute(e) { + var t = new NewgroundsIO.objects.Execute(); + return (t.setComponent(e), t.setCore(this), t); + } + _getRequest(e) { + let t, + s = this; + Array.isArray(e) + ? ((t = []), + e.forEach((e) => { + let o = s._getExecute(e); + t.push(o); + })) + : (t = this._getExecute(e)); + let o = new NewgroundsIO.objects.Request({ execute: t }); + return (this.debug && (o.debug = !0), o.setCore(this), o); + } + _verifyComponent(e) { + return e instanceof NewgroundsIO.BaseComponent + ? !!e.isValid() + : (console.error( + "NewgroundsIO Type Mismatch: Expecting a NewgroundsIO.components.XXXX instance, got", + e + ), + !1); + } + } + NewgroundsIO.Core = e; + })(), + (() => { + class e { + get type() { + return this.__type; + } + __type = "object"; + __object = "BaseObject"; + __properties = []; + __required = []; + __ngioCore = null; + isValid() { + if (0 === this.__required.length) return !0; + let e = !0; + return ( + this.__required.forEach(function (t) { + null === this[t] + ? (console.error( + "NewgroundsIO Error: " + + this.__object + + " " + + this.__type + + " is invalid, missing value for '" + + t + + "'" + ), + (e = !1)) + : this[t] instanceof NewgroundsIO.BaseObject && + !this[t].isValid() && + (e = !1); + }, this), + e + ); + } + setCore(e) { + this._doSetCore(e, []); + } + objectMap = {}; + arrayMap = {}; + fromJSON(e, t) { + var s, + o, + r = {}; + for (this.setCore(t), s = 0; s < this.__properties.length; s++) { + let i = this.__properties[s]; + if (void 0 !== e[i] && null !== e[i]) { + if ( + ((r[i] = e[i]), + void 0 !== this.arrayMap[i] && Array.isArray(r[i])) + ) + for (o = 0, r[i] = []; o < e[i].length; o++) { + let n = NewgroundsIO.objects[this.arrayMap[i]]; + ((r[i][o] = new n()), r[i][o].fromJSON(e[i][o], t)); + } + else if (void 0 !== this.objectMap[i]) { + let a = NewgroundsIO.objects[this.objectMap[i]]; + ((r[i] = new a()), r[i].fromJSON(e[i], t)); + } + this[i] = r[i]; + } + } + } + _doSetCore(e, t) { + (Array.isArray(t) || (t = []), + e instanceof NewgroundsIO.Core + ? ((this.__ngioCore = e), + t.push(this), + this.__properties.forEach(function (s) { + (this[s] instanceof NewgroundsIO.BaseObject && + -1 === t.indexOf(this[s]) + ? this[s]._doSetCore(e, t) + : Array.isArray(this[s]) && + this[s].forEach((s) => { + s instanceof NewgroundsIO.BaseObject && + -1 === t.indexOf(s) && + s._doSetCore(e, t); + }, this), + "host" !== s || this.host || (this.host = e.host)); + }, this)) + : console.error( + "NewgroundsIO Error: Expecting NewgroundsIO.Core instance, got", + e + )); + } + toJSON() { + return this.__doToJSON(); + } + __doToJSON() { + if (void 0 === this.__properties) return {}; + let e = {}; + return ( + this.__properties.forEach(function (t) { + null !== this[t] && + (e[t] = + "function" == typeof this[t].toJSON + ? this[t].toJSON() + : this[t]); + }, this), + e + ); + } + toSecureJSON() { + return this.__ngioCore && this.__ngioCore instanceof NewgroundsIO.Core + ? { + secure: this.__ngioCore.encrypt( + JSON.stringify(this.__doToJSON()) + ), + } + : (console.error( + "NewgroundsIO Error: Unable to create secure JSON object without calling setCore() first." + ), + this.__doToJSON()); + } + toString() { + return this.__type; + } + clone(e) { + return ( + void 0 === e && (e = new this.constructor()), + this.__properties.forEach((t) => { + e[t] = this[t]; + }), + (e.__ngioCore = this.__ngioCore), + e + ); + } + } + NewgroundsIO.BaseObject = e; + class t extends e { + constructor() { + (super(), + (this.__type = "component"), + (this.__object = "BaseComponent"), + (this.__properties = ["host", "echo"]), + (this._echo = null)); + } + get host() { + return this.__ngioCore ? this.__ngioCore.host : null; + } + get echo() { + return this._echo; + } + set echo(e) { + this.echo = "" + e; + } + } + NewgroundsIO.BaseComponent = t; + class s extends e { + constructor() { + (super(), + (this.__type = "result"), + (this.__object = "BaseResult"), + (this.__properties = ["echo", "error", "success"]), + (this._echo = null), + (this._error = null), + (this._success = null)); + } + get component() { + return this.__object; + } + get echo() { + return this._echo; + } + get error() { + return this._error; + } + set error(e) { + this._error = e; + } + get success() { + return !!this._success; + } + set success(e) { + this._success = !!e; + } + } + NewgroundsIO.BaseResult = s; + })(), + (NewgroundsIO.SessionState = { + SESSION_UNINITIALIZED: "session-uninitialized", + WAITING_FOR_SERVER: "waiting-for-server", + LOGIN_REQUIRED: "login-required", + WAITING_FOR_USER: "waiting-for-user", + LOGIN_CANCELLED: "login-cancelled", + LOGIN_SUCCESSFUL: "login-successful", + LOGIN_FAILED: "login-failed", + USER_LOGGED_OUT: "user-logged-out", + SERVER_UNAVAILABLE: "server-unavailable", + EXCEEDED_MAX_ATTEMPTS: "exceeded-max-attempts", + }), + (NewgroundsIO.SessionState.SESSION_WAITING = [ + NewgroundsIO.SessionState.SESSION_UNINITIALIZED, + NewgroundsIO.SessionState.WAITING_FOR_SERVER, + NewgroundsIO.SessionState.WAITING_FOR_USER, + NewgroundsIO.SessionState.LOGIN_CANCELLED, + NewgroundsIO.SessionStateLOGIN_FAILED, + ]), + (() => { + class e extends NewgroundsIO.BaseComponent { + constructor() { + (super(), + (this.__object = "App.checkSession"), + (this.__requireSession = !0)); + } + } + (void 0 === NewgroundsIO.components.App && + (NewgroundsIO.components.App = {}), + (NewgroundsIO.components.App.checkSession = e)); + })(), + (() => { + class e extends NewgroundsIO.BaseComponent { + constructor() { + (super(), + (this.__object = "App.endSession"), + (this.__requireSession = !0)); + } + } + (void 0 === NewgroundsIO.components.App && + (NewgroundsIO.components.App = {}), + (NewgroundsIO.components.App.endSession = e)); + })(), + (() => { + class e extends NewgroundsIO.BaseComponent { + constructor(e) { + super(); + let t = this; + if ( + ((this.__object = "App.getCurrentVersion"), + ["version"].forEach((e) => { + 0 > t.__properties.indexOf(e) && t.__properties.push(e); + }), + e && "object" == typeof e) + ) + for (var s = 0; s < this.__properties.length; s++) + void 0 !== e[this.__properties[s]] && + (this[this.__properties[s]] = e[this.__properties[s]]); + } + #x = null; + get version() { + return this.#x; + } + set version(e) { + ("string" != typeof e && + null !== e && + console.warn( + "NewgroundsIO Type Mismatch: Value should be a string, got", + e + ), + (this.#x = String(e))); + } + } + (void 0 === NewgroundsIO.components.App && + (NewgroundsIO.components.App = {}), + (NewgroundsIO.components.App.getCurrentVersion = e)); + })(), + (() => { + class e extends NewgroundsIO.BaseComponent { + constructor(e) { + super(); + let t = this; + if ( + ((this.__object = "App.getHostLicense"), + ["host"].forEach((e) => { + 0 > t.__properties.indexOf(e) && t.__properties.push(e); + }), + e && "object" == typeof e) + ) + for (var s = 0; s < this.__properties.length; s++) + void 0 !== e[this.__properties[s]] && + (this[this.__properties[s]] = e[this.__properties[s]]); + } + } + (void 0 === NewgroundsIO.components.App && + (NewgroundsIO.components.App = {}), + (NewgroundsIO.components.App.getHostLicense = e)); + })(), + (() => { + class e extends NewgroundsIO.BaseComponent { + constructor(e) { + super(); + let t = this; + if ( + ((this.__object = "App.logView"), + ["host"].forEach((e) => { + 0 > t.__properties.indexOf(e) && t.__properties.push(e); + }), + e && "object" == typeof e) + ) + for (var s = 0; s < this.__properties.length; s++) + void 0 !== e[this.__properties[s]] && + (this[this.__properties[s]] = e[this.__properties[s]]); + } + } + (void 0 === NewgroundsIO.components.App && + (NewgroundsIO.components.App = {}), + (NewgroundsIO.components.App.logView = e)); + })(), + (() => { + class e extends NewgroundsIO.BaseComponent { + constructor(e) { + super(); + let t = this; + if ( + ((this.__object = "App.startSession"), + ["force"].forEach((e) => { + 0 > t.__properties.indexOf(e) && t.__properties.push(e); + }), + e && "object" == typeof e) + ) + for (var s = 0; s < this.__properties.length; s++) + void 0 !== e[this.__properties[s]] && + (this[this.__properties[s]] = e[this.__properties[s]]); + } + #W = null; + get force() { + return this.#W; + } + set force(e) { + ("boolean" != typeof e && + "number" != typeof e && + null !== e && + console.warn( + "NewgroundsIO Type Mismatch: Value should be a boolean, got", + e + ), + (this.#W = !!e)); + } + } + (void 0 === NewgroundsIO.components.App && + (NewgroundsIO.components.App = {}), + (NewgroundsIO.components.App.startSession = e)); + })(), + (() => { + class e extends NewgroundsIO.BaseComponent { + constructor(e) { + super(); + let t = this; + if ( + ((this.__object = "CloudSave.clearSlot"), + (this.__requireSession = !0), + ["id"].forEach((e) => { + 0 > t.__properties.indexOf(e) && t.__properties.push(e); + }), + e && "object" == typeof e) + ) + for (var s = 0; s < this.__properties.length; s++) + void 0 !== e[this.__properties[s]] && + (this[this.__properties[s]] = e[this.__properties[s]]); + } + #X = null; + get id() { + return this.#X; + } + set id(e) { + ("number" != typeof e && null !== e + ? console.warn( + "NewgroundsIO Type Mismatch: Value should be a number, got", + e + ) + : Number.isInteger(e) || + null === e || + console.warn( + "NewgroundsIO Type Mismatch: Value should be an integer, got a float" + ), + (this.#X = Number(e)), + isNaN(this.#X) && (this.#X = null)); + } + } + (void 0 === NewgroundsIO.components.CloudSave && + (NewgroundsIO.components.CloudSave = {}), + (NewgroundsIO.components.CloudSave.clearSlot = e)); + })(), + (() => { + class e extends NewgroundsIO.BaseComponent { + constructor(e) { + super(); + let t = this; + if ( + ((this.__object = "CloudSave.loadSlot"), + (this.__requireSession = !0), + ["id", "app_id"].forEach((e) => { + 0 > t.__properties.indexOf(e) && t.__properties.push(e); + }), + e && "object" == typeof e) + ) + for (var s = 0; s < this.__properties.length; s++) + void 0 !== e[this.__properties[s]] && + (this[this.__properties[s]] = e[this.__properties[s]]); + } + #X = null; + get id() { + return this.#X; + } + set id(e) { + ("number" != typeof e && null !== e + ? console.warn( + "NewgroundsIO Type Mismatch: Value should be a number, got", + e + ) + : Number.isInteger(e) || + null === e || + console.warn( + "NewgroundsIO Type Mismatch: Value should be an integer, got a float" + ), + (this.#X = Number(e)), + isNaN(this.#X) && (this.#X = null)); + } + #Y = null; + get app_id() { + return this.#Y; + } + set app_id(e) { + ("string" != typeof e && + null !== e && + console.warn( + "NewgroundsIO Type Mismatch: Value should be a string, got", + e + ), + (this.#Y = String(e))); + } + } + (void 0 === NewgroundsIO.components.CloudSave && + (NewgroundsIO.components.CloudSave = {}), + (NewgroundsIO.components.CloudSave.loadSlot = e)); + })(), + (() => { + class e extends NewgroundsIO.BaseComponent { + constructor(e) { + super(); + let t = this; + if ( + ((this.__object = "CloudSave.loadSlots"), + (this.__requireSession = !0), + ["app_id"].forEach((e) => { + 0 > t.__properties.indexOf(e) && t.__properties.push(e); + }), + e && "object" == typeof e) + ) + for (var s = 0; s < this.__properties.length; s++) + void 0 !== e[this.__properties[s]] && + (this[this.__properties[s]] = e[this.__properties[s]]); + } + #Y = null; + get app_id() { + return this.#Y; + } + set app_id(e) { + ("string" != typeof e && + null !== e && + console.warn( + "NewgroundsIO Type Mismatch: Value should be a string, got", + e + ), + (this.#Y = String(e))); + } + } + (void 0 === NewgroundsIO.components.CloudSave && + (NewgroundsIO.components.CloudSave = {}), + (NewgroundsIO.components.CloudSave.loadSlots = e)); + })(), + (() => { + class e extends NewgroundsIO.BaseComponent { + constructor(e) { + super(); + let t = this; + if ( + ((this.__object = "CloudSave.setData"), + (this.__requireSession = !0), + ["id", "data"].forEach((e) => { + 0 > t.__properties.indexOf(e) && t.__properties.push(e); + }), + e && "object" == typeof e) + ) + for (var s = 0; s < this.__properties.length; s++) + void 0 !== e[this.__properties[s]] && + (this[this.__properties[s]] = e[this.__properties[s]]); + } + #X = null; + get id() { + return this.#X; + } + set id(e) { + ("number" != typeof e && null !== e + ? console.warn( + "NewgroundsIO Type Mismatch: Value should be a number, got", + e + ) + : Number.isInteger(e) || + null === e || + console.warn( + "NewgroundsIO Type Mismatch: Value should be an integer, got a float" + ), + (this.#X = Number(e)), + isNaN(this.#X) && (this.#X = null)); + } + #Z = null; + get data() { + return this.#Z; + } + set data(e) { + ("string" != typeof e && + null !== e && + console.warn( + "NewgroundsIO Type Mismatch: Value should be a string, got", + e + ), + (this.#Z = String(e))); + } + } + (void 0 === NewgroundsIO.components.CloudSave && + (NewgroundsIO.components.CloudSave = {}), + (NewgroundsIO.components.CloudSave.setData = e)); + })(), + (() => { + class e extends NewgroundsIO.BaseComponent { + constructor(e) { + super(); + let t = this; + if ( + ((this.__object = "Event.logEvent"), + ["host", "event_name"].forEach((e) => { + 0 > t.__properties.indexOf(e) && t.__properties.push(e); + }), + e && "object" == typeof e) + ) + for (var s = 0; s < this.__properties.length; s++) + void 0 !== e[this.__properties[s]] && + (this[this.__properties[s]] = e[this.__properties[s]]); + } + #$ = null; + get event_name() { + return this.#$; + } + set event_name(e) { + ("string" != typeof e && + null !== e && + console.warn( + "NewgroundsIO Type Mismatch: Value should be a string, got", + e + ), + (this.#$ = String(e))); + } + } + (void 0 === NewgroundsIO.components.Event && + (NewgroundsIO.components.Event = {}), + (NewgroundsIO.components.Event.logEvent = e)); + })(), + (() => { + class e extends NewgroundsIO.BaseComponent { + constructor() { + (super(), (this.__object = "Gateway.getDatetime")); + } + } + (void 0 === NewgroundsIO.components.Gateway && + (NewgroundsIO.components.Gateway = {}), + (NewgroundsIO.components.Gateway.getDatetime = e)); + })(), + (() => { + class e extends NewgroundsIO.BaseComponent { + constructor() { + (super(), (this.__object = "Gateway.getVersion")); + } + } + (void 0 === NewgroundsIO.components.Gateway && + (NewgroundsIO.components.Gateway = {}), + (NewgroundsIO.components.Gateway.getVersion = e)); + })(), + (() => { + class e extends NewgroundsIO.BaseComponent { + constructor() { + (super(), (this.__object = "Gateway.ping")); + } + } + (void 0 === NewgroundsIO.components.Gateway && + (NewgroundsIO.components.Gateway = {}), + (NewgroundsIO.components.Gateway.ping = e)); + })(), + (() => { + class e extends NewgroundsIO.BaseComponent { + constructor(e) { + super(); + let t = this; + if ( + ((this.__object = "Loader.loadAuthorUrl"), + ["host", "redirect", "log_stat"].forEach((e) => { + 0 > t.__properties.indexOf(e) && t.__properties.push(e); + }), + e && "object" == typeof e) + ) + for (var s = 0; s < this.__properties.length; s++) + void 0 !== e[this.__properties[s]] && + (this[this.__properties[s]] = e[this.__properties[s]]); + } + #_ = null; + get redirect() { + return this.#_; + } + set redirect(e) { + ("boolean" != typeof e && + "number" != typeof e && + null !== e && + console.warn( + "NewgroundsIO Type Mismatch: Value should be a boolean, got", + e + ), + (this.#_ = !!e)); + } + #aa = null; + get log_stat() { + return this.#aa; + } + set log_stat(e) { + ("boolean" != typeof e && + "number" != typeof e && + null !== e && + console.warn( + "NewgroundsIO Type Mismatch: Value should be a boolean, got", + e + ), + (this.#aa = !!e)); + } + } + (void 0 === NewgroundsIO.components.Loader && + (NewgroundsIO.components.Loader = {}), + (NewgroundsIO.components.Loader.loadAuthorUrl = e)); + })(), + (() => { + class e extends NewgroundsIO.BaseComponent { + constructor(e) { + super(); + let t = this; + if ( + ((this.__object = "Loader.loadMoreGames"), + ["host", "redirect", "log_stat"].forEach((e) => { + 0 > t.__properties.indexOf(e) && t.__properties.push(e); + }), + e && "object" == typeof e) + ) + for (var s = 0; s < this.__properties.length; s++) + void 0 !== e[this.__properties[s]] && + (this[this.__properties[s]] = e[this.__properties[s]]); + } + #_ = null; + get redirect() { + return this.#_; + } + set redirect(e) { + ("boolean" != typeof e && + "number" != typeof e && + null !== e && + console.warn( + "NewgroundsIO Type Mismatch: Value should be a boolean, got", + e + ), + (this.#_ = !!e)); + } + #aa = null; + get log_stat() { + return this.#aa; + } + set log_stat(e) { + ("boolean" != typeof e && + "number" != typeof e && + null !== e && + console.warn( + "NewgroundsIO Type Mismatch: Value should be a boolean, got", + e + ), + (this.#aa = !!e)); + } + } + (void 0 === NewgroundsIO.components.Loader && + (NewgroundsIO.components.Loader = {}), + (NewgroundsIO.components.Loader.loadMoreGames = e)); + })(), + (() => { + class e extends NewgroundsIO.BaseComponent { + constructor(e) { + super(); + let t = this; + if ( + ((this.__object = "Loader.loadNewgrounds"), + ["host", "redirect", "log_stat"].forEach((e) => { + 0 > t.__properties.indexOf(e) && t.__properties.push(e); + }), + e && "object" == typeof e) + ) + for (var s = 0; s < this.__properties.length; s++) + void 0 !== e[this.__properties[s]] && + (this[this.__properties[s]] = e[this.__properties[s]]); + } + #_ = null; + get redirect() { + return this.#_; + } + set redirect(e) { + ("boolean" != typeof e && + "number" != typeof e && + null !== e && + console.warn( + "NewgroundsIO Type Mismatch: Value should be a boolean, got", + e + ), + (this.#_ = !!e)); + } + #aa = null; + get log_stat() { + return this.#aa; + } + set log_stat(e) { + ("boolean" != typeof e && + "number" != typeof e && + null !== e && + console.warn( + "NewgroundsIO Type Mismatch: Value should be a boolean, got", + e + ), + (this.#aa = !!e)); + } + } + (void 0 === NewgroundsIO.components.Loader && + (NewgroundsIO.components.Loader = {}), + (NewgroundsIO.components.Loader.loadNewgrounds = e)); + })(), + (() => { + class e extends NewgroundsIO.BaseComponent { + constructor(e) { + super(); + let t = this; + if ( + ((this.__object = "Loader.loadOfficialUrl"), + ["host", "redirect", "log_stat"].forEach((e) => { + 0 > t.__properties.indexOf(e) && t.__properties.push(e); + }), + e && "object" == typeof e) + ) + for (var s = 0; s < this.__properties.length; s++) + void 0 !== e[this.__properties[s]] && + (this[this.__properties[s]] = e[this.__properties[s]]); + } + #_ = null; + get redirect() { + return this.#_; + } + set redirect(e) { + ("boolean" != typeof e && + "number" != typeof e && + null !== e && + console.warn( + "NewgroundsIO Type Mismatch: Value should be a boolean, got", + e + ), + (this.#_ = !!e)); + } + #aa = null; + get log_stat() { + return this.#aa; + } + set log_stat(e) { + ("boolean" != typeof e && + "number" != typeof e && + null !== e && + console.warn( + "NewgroundsIO Type Mismatch: Value should be a boolean, got", + e + ), + (this.#aa = !!e)); + } + } + (void 0 === NewgroundsIO.components.Loader && + (NewgroundsIO.components.Loader = {}), + (NewgroundsIO.components.Loader.loadOfficialUrl = e)); + })(), + (() => { + class e extends NewgroundsIO.BaseComponent { + constructor(e) { + super(); + let t = this; + if ( + ((this.__object = "Loader.loadReferral"), + ["host", "referral_name", "redirect", "log_stat"].forEach((e) => { + 0 > t.__properties.indexOf(e) && t.__properties.push(e); + }), + e && "object" == typeof e) + ) + for (var s = 0; s < this.__properties.length; s++) + void 0 !== e[this.__properties[s]] && + (this[this.__properties[s]] = e[this.__properties[s]]); + } + #ab = null; + get referral_name() { + return this.#ab; + } + set referral_name(e) { + ("string" != typeof e && + null !== e && + console.warn( + "NewgroundsIO Type Mismatch: Value should be a string, got", + e + ), + (this.#ab = String(e))); + } + #_ = null; + get redirect() { + return this.#_; + } + set redirect(e) { + ("boolean" != typeof e && + "number" != typeof e && + null !== e && + console.warn( + "NewgroundsIO Type Mismatch: Value should be a boolean, got", + e + ), + (this.#_ = !!e)); + } + #aa = null; + get log_stat() { + return this.#aa; + } + set log_stat(e) { + ("boolean" != typeof e && + "number" != typeof e && + null !== e && + console.warn( + "NewgroundsIO Type Mismatch: Value should be a boolean, got", + e + ), + (this.#aa = !!e)); + } + } + (void 0 === NewgroundsIO.components.Loader && + (NewgroundsIO.components.Loader = {}), + (NewgroundsIO.components.Loader.loadReferral = e)); + })(), + (() => { + class e extends NewgroundsIO.BaseComponent { + constructor(e) { + super(); + let t = this; + if ( + ((this.__object = "Medal.getList"), + ["app_id"].forEach((e) => { + 0 > t.__properties.indexOf(e) && t.__properties.push(e); + }), + e && "object" == typeof e) + ) + for (var s = 0; s < this.__properties.length; s++) + void 0 !== e[this.__properties[s]] && + (this[this.__properties[s]] = e[this.__properties[s]]); + } + #Y = null; + get app_id() { + return this.#Y; + } + set app_id(e) { + ("string" != typeof e && + null !== e && + console.warn( + "NewgroundsIO Type Mismatch: Value should be a string, got", + e + ), + (this.#Y = String(e))); + } + } + (void 0 === NewgroundsIO.components.Medal && + (NewgroundsIO.components.Medal = {}), + (NewgroundsIO.components.Medal.getList = e)); + })(), + (() => { + class e extends NewgroundsIO.BaseComponent { + constructor() { + (super(), + (this.__object = "Medal.getMedalScore"), + (this.__requireSession = !0)); + } + } + (void 0 === NewgroundsIO.components.Medal && + (NewgroundsIO.components.Medal = {}), + (NewgroundsIO.components.Medal.getMedalScore = e)); + })(), + (() => { + class e extends NewgroundsIO.BaseComponent { + constructor(e) { + super(); + let t = this; + if ( + ((this.__object = "Medal.unlock"), + (this.__isSecure = !0), + (this.__requireSession = !0), + ["id"].forEach((e) => { + 0 > t.__properties.indexOf(e) && t.__properties.push(e); + }), + e && "object" == typeof e) + ) + for (var s = 0; s < this.__properties.length; s++) + void 0 !== e[this.__properties[s]] && + (this[this.__properties[s]] = e[this.__properties[s]]); + } + #X = null; + get id() { + return this.#X; + } + set id(e) { + ("number" != typeof e && null !== e + ? console.warn( + "NewgroundsIO Type Mismatch: Value should be a number, got", + e + ) + : Number.isInteger(e) || + null === e || + console.warn( + "NewgroundsIO Type Mismatch: Value should be an integer, got a float" + ), + (this.#X = Number(e)), + isNaN(this.#X) && (this.#X = null)); + } + } + (void 0 === NewgroundsIO.components.Medal && + (NewgroundsIO.components.Medal = {}), + (NewgroundsIO.components.Medal.unlock = e)); + })(), + (() => { + class e extends NewgroundsIO.BaseComponent { + constructor() { + (super(), (this.__object = "ScoreBoard.getBoards")); + } + } + (void 0 === NewgroundsIO.components.ScoreBoard && + (NewgroundsIO.components.ScoreBoard = {}), + (NewgroundsIO.components.ScoreBoard.getBoards = e)); + })(), + (() => { + class e extends NewgroundsIO.BaseComponent { + constructor(e) { + super(); + let t = this; + if ( + ((this.__object = "ScoreBoard.getScores"), + [ + "id", + "period", + "tag", + "social", + "user", + "skip", + "limit", + "app_id", + ].forEach((e) => { + 0 > t.__properties.indexOf(e) && t.__properties.push(e); + }), + e && "object" == typeof e) + ) + for (var s = 0; s < this.__properties.length; s++) + void 0 !== e[this.__properties[s]] && + (this[this.__properties[s]] = e[this.__properties[s]]); + } + #X = null; + get id() { + return this.#X; + } + set id(e) { + ("number" != typeof e && null !== e + ? console.warn( + "NewgroundsIO Type Mismatch: Value should be a number, got", + e + ) + : Number.isInteger(e) || + null === e || + console.warn( + "NewgroundsIO Type Mismatch: Value should be an integer, got a float" + ), + (this.#X = Number(e)), + isNaN(this.#X) && (this.#X = null)); + } + #ac = null; + get period() { + return this.#ac; + } + set period(e) { + ("string" != typeof e && + null !== e && + console.warn( + "NewgroundsIO Type Mismatch: Value should be a string, got", + e + ), + (this.#ac = String(e))); + } + #ad = null; + get tag() { + return this.#ad; + } + set tag(e) { + ("string" != typeof e && + null !== e && + console.warn( + "NewgroundsIO Type Mismatch: Value should be a string, got", + e + ), + (this.#ad = String(e))); + } + #ae = null; + get social() { + return this.#ae; + } + set social(e) { + ("boolean" != typeof e && + "number" != typeof e && + null !== e && + console.warn( + "NewgroundsIO Type Mismatch: Value should be a boolean, got", + e + ), + (this.#ae = !!e)); + } + #af = null; + get user() { + return this.#af; + } + set user(e) { + this.#af = e; + } + #ag = null; + get skip() { + return this.#ag; + } + set skip(e) { + ("number" != typeof e && null !== e + ? console.warn( + "NewgroundsIO Type Mismatch: Value should be a number, got", + e + ) + : Number.isInteger(e) || + null === e || + console.warn( + "NewgroundsIO Type Mismatch: Value should be an integer, got a float" + ), + (this.#ag = Number(e)), + isNaN(this.#ag) && (this.#ag = null)); + } + #ah = null; + get limit() { + return this.#ah; + } + set limit(e) { + ("number" != typeof e && null !== e + ? console.warn( + "NewgroundsIO Type Mismatch: Value should be a number, got", + e + ) + : Number.isInteger(e) || + null === e || + console.warn( + "NewgroundsIO Type Mismatch: Value should be an integer, got a float" + ), + (this.#ah = Number(e)), + isNaN(this.#ah) && (this.#ah = null)); + } + #Y = null; + get app_id() { + return this.#Y; + } + set app_id(e) { + ("string" != typeof e && + null !== e && + console.warn( + "NewgroundsIO Type Mismatch: Value should be a string, got", + e + ), + (this.#Y = String(e))); + } + } + (void 0 === NewgroundsIO.components.ScoreBoard && + (NewgroundsIO.components.ScoreBoard = {}), + (NewgroundsIO.components.ScoreBoard.getScores = e)); + })(), + (() => { + class e extends NewgroundsIO.BaseComponent { + constructor(e) { + super(); + let t = this; + if ( + ((this.__object = "ScoreBoard.postScore"), + (this.__isSecure = !0), + (this.__requireSession = !0), + ["id", "value", "tag"].forEach((e) => { + 0 > t.__properties.indexOf(e) && t.__properties.push(e); + }), + e && "object" == typeof e) + ) + for (var s = 0; s < this.__properties.length; s++) + void 0 !== e[this.__properties[s]] && + (this[this.__properties[s]] = e[this.__properties[s]]); + } + #X = null; + get id() { + return this.#X; + } + set id(e) { + ("number" != typeof e && null !== e + ? console.warn( + "NewgroundsIO Type Mismatch: Value should be a number, got", + e + ) + : Number.isInteger(e) || + null === e || + console.warn( + "NewgroundsIO Type Mismatch: Value should be an integer, got a float" + ), + (this.#X = Number(e)), + isNaN(this.#X) && (this.#X = null)); + } + #ai = null; + get value() { + return this.#ai; + } + set value(e) { + ("number" != typeof e && null !== e + ? console.warn( + "NewgroundsIO Type Mismatch: Value should be a number, got", + e + ) + : Number.isInteger(e) || + null === e || + console.warn( + "NewgroundsIO Type Mismatch: Value should be an integer, got a float" + ), + (this.#ai = Number(e)), + isNaN(this.#ai) && (this.#ai = null)); + } + #ad = null; + get tag() { + return this.#ad; + } + set tag(e) { + ("string" != typeof e && + null !== e && + console.warn( + "NewgroundsIO Type Mismatch: Value should be a string, got", + e + ), + (this.#ad = String(e))); + } + } + (void 0 === NewgroundsIO.components.ScoreBoard && + (NewgroundsIO.components.ScoreBoard = {}), + (NewgroundsIO.components.ScoreBoard.postScore = e)); + })(), + (() => { + class e extends NewgroundsIO.BaseObject { + constructor(e) { + super(); + let t = this; + if ( + ((this.__object = "Debug"), + ["exec_time", "request"].forEach((e) => { + 0 > t.__properties.indexOf(e) && t.__properties.push(e); + }), + e && "object" == typeof e) + ) + for (var s = 0; s < this.__properties.length; s++) + void 0 !== e[this.__properties[s]] && + (this[this.__properties[s]] = e[this.__properties[s]]); + } + #aj = null; + get exec_time() { + return this.#aj; + } + set exec_time(e) { + ("string" != typeof e && + null !== e && + console.warn( + "NewgroundsIO Type Mismatch: Value should be a string, got", + e + ), + (this.#aj = String(e))); + } + #ak = null; + get request() { + return this.#ak; + } + set request(e) { + (e instanceof NewgroundsIO.objects.Request || + "object" != typeof e || + (e = new NewgroundsIO.objects.Request(e)), + null === e || + e instanceof NewgroundsIO.objects.Request || + console.warn( + "Type Mismatch: expecting NewgroundsIO.objects.Request, got ", + e + ), + (this.#ak = e)); + } + objectMap = { request: "Request" }; + } + (void 0 === NewgroundsIO.objects && (NewgroundsIO.objects = {}), + (NewgroundsIO.objects.Debug = e)); + })(), + (() => { + class e extends NewgroundsIO.BaseObject { + constructor(e) { + super(); + let t = this; + if ( + ((this.__object = "Error"), + ["message", "code"].forEach((e) => { + 0 > t.__properties.indexOf(e) && t.__properties.push(e); + }), + e && "object" == typeof e) + ) + for (var s = 0; s < this.__properties.length; s++) + void 0 !== e[this.__properties[s]] && + (this[this.__properties[s]] = e[this.__properties[s]]); + } + #al = null; + get message() { + return this.#al; + } + set message(e) { + ("string" != typeof e && + null !== e && + console.warn( + "NewgroundsIO Type Mismatch: Value should be a string, got", + e + ), + (this.#al = String(e))); + } + #am = null; + get code() { + return this.#am; + } + set code(e) { + ("number" != typeof e && null !== e + ? console.warn( + "NewgroundsIO Type Mismatch: Value should be a number, got", + e + ) + : Number.isInteger(e) || + null === e || + console.warn( + "NewgroundsIO Type Mismatch: Value should be an integer, got a float" + ), + (this.#am = Number(e)), + isNaN(this.#am) && (this.#am = null)); + } + } + (void 0 === NewgroundsIO.objects && (NewgroundsIO.objects = {}), + (NewgroundsIO.objects.Error = e)); + })(), + (() => { + class e extends NewgroundsIO.BaseObject { + constructor(e) { + super(); + let t = this; + if ( + ((this.__object = "Execute"), + ["component", "parameters", "secure"].forEach((e) => { + 0 > t.__properties.indexOf(e) && t.__properties.push(e); + }), + e && "object" == typeof e) + ) + for (var s = 0; s < this.__properties.length; s++) + void 0 !== e[this.__properties[s]] && + (this[this.__properties[s]] = e[this.__properties[s]]); + } + #an = null; + get component() { + return this.#an; + } + set component(e) { + ("string" != typeof e && + null !== e && + console.warn( + "NewgroundsIO Type Mismatch: Value should be a string, got", + e + ), + (this.#an = String(e))); + } + #ao = null; + get parameters() { + return this.#ao; + } + set parameters(e) { + if (Array.isArray(e)) { + let t = []; + (e.forEach(function (e, s) { + ("object" != typeof e && + null !== e && + console.warn( + "NewgroundsIO Type Mismatch: Value should be a object, got", + e + ), + (t[s] = e)); + }), + (this.#ao = t)); + return; + } + ("object" != typeof e && + null !== e && + console.warn( + "NewgroundsIO Type Mismatch: Value should be a object, got", + e + ), + (this.#ao = e)); + } + #ap = null; + get secure() { + return this.#ap; + } + set secure(e) { + ("string" != typeof e && + null !== e && + console.warn( + "NewgroundsIO Type Mismatch: Value should be a string, got", + e + ), + (this.#ap = String(e))); + } + #aq = null; + setComponent(e) { + (e instanceof NewgroundsIO.BaseComponent || + console.error( + "NewgroundsIO Error: Expecting NewgroundsIO component, got " + + typeof e + ), + (this.#aq = e), + (this.component = e.__object), + (this.parameters = e.toJSON())); + } + isValid() { + return (this.component || + console.error("NewgroundsIO Error: Missing required component!"), + this.__ngioCore) + ? !this.#aq || + (this.#aq.__requireSession && + !this.__ngioCore.session.isActive() + ? (console.warn( + "NewgroundsIO Warning: " + + this.component + + " can only be used with a valid user session." + ), + this.__ngioCore.session.logProblems(), + !1) + : this.#aq instanceof NewgroundsIO.BaseComponent && + this.#aq.isValid()) + : (console.error( + "NewgroundsIO Error: Must call setCore() before validating!" + ), + !1); + } + toJSON() { + return this.#aq && this.#aq.__isSecure + ? this.toSecureJSON() + : super.toJSON(); + } + } + (void 0 === NewgroundsIO.objects && (NewgroundsIO.objects = {}), + (NewgroundsIO.objects.Execute = e)); + })(), + (() => { + class e extends NewgroundsIO.BaseObject { + constructor(e) { + super(); + let t = this; + if ( + ((this.__object = "Medal"), + [ + "id", + "name", + "description", + "icon", + "value", + "difficulty", + "secret", + "unlocked", + ].forEach((e) => { + 0 > t.__properties.indexOf(e) && t.__properties.push(e); + }), + e && "object" == typeof e) + ) + for (var s = 0; s < this.__properties.length; s++) + void 0 !== e[this.__properties[s]] && + (this[this.__properties[s]] = e[this.__properties[s]]); + } + #X = null; + get id() { + return this.#X; + } + set id(e) { + ("number" != typeof e && null !== e + ? console.warn( + "NewgroundsIO Type Mismatch: Value should be a number, got", + e + ) + : Number.isInteger(e) || + null === e || + console.warn( + "NewgroundsIO Type Mismatch: Value should be an integer, got a float" + ), + (this.#X = Number(e)), + isNaN(this.#X) && (this.#X = null)); + } + #ar = null; + get name() { + return this.#ar; + } + set name(e) { + ("string" != typeof e && + null !== e && + console.warn( + "NewgroundsIO Type Mismatch: Value should be a string, got", + e + ), + (this.#ar = String(e))); + } + #as = null; + get description() { + return this.#as; + } + set description(e) { + ("string" != typeof e && + null !== e && + console.warn( + "NewgroundsIO Type Mismatch: Value should be a string, got", + e + ), + (this.#as = String(e))); + } + #at = null; + get icon() { + return this.#at; + } + set icon(e) { + ("string" != typeof e && + null !== e && + console.warn( + "NewgroundsIO Type Mismatch: Value should be a string, got", + e + ), + (this.#at = String(e))); + } + #ai = null; + get value() { + return this.#ai; + } + set value(e) { + ("number" != typeof e && null !== e + ? console.warn( + "NewgroundsIO Type Mismatch: Value should be a number, got", + e + ) + : Number.isInteger(e) || + null === e || + console.warn( + "NewgroundsIO Type Mismatch: Value should be an integer, got a float" + ), + (this.#ai = Number(e)), + isNaN(this.#ai) && (this.#ai = null)); + } + #au = null; + get difficulty() { + return this.#au; + } + set difficulty(e) { + ("number" != typeof e && null !== e + ? console.warn( + "NewgroundsIO Type Mismatch: Value should be a number, got", + e + ) + : Number.isInteger(e) || + null === e || + console.warn( + "NewgroundsIO Type Mismatch: Value should be an integer, got a float" + ), + (this.#au = Number(e)), + isNaN(this.#au) && (this.#au = null)); + } + #av = null; + get secret() { + return this.#av; + } + set secret(e) { + ("boolean" != typeof e && + "number" != typeof e && + null !== e && + console.warn( + "NewgroundsIO Type Mismatch: Value should be a boolean, got", + e + ), + (this.#av = !!e)); + } + #aw = null; + get unlocked() { + return this.#aw; + } + set unlocked(e) { + ("boolean" != typeof e && + "number" != typeof e && + null !== e && + console.warn( + "NewgroundsIO Type Mismatch: Value should be a boolean, got", + e + ), + (this.#aw = !!e)); + } + unlock(e, t) { + if (!this.__ngioCore) { + console.error( + "NewgroundsIO - Can not unlock medal object without attaching a NewgroundsIO.Core instance." + ); + return; + } + var s = this.__ngioCore.getComponent("Medal.unlock", { id: this.id }); + this.__ngioCore.executeComponent(s, e, t); + } + } + (void 0 === NewgroundsIO.objects && (NewgroundsIO.objects = {}), + (NewgroundsIO.objects.Medal = e)); + })(), + (() => { + class e extends NewgroundsIO.BaseObject { + constructor(e) { + super(); + let t = this; + if ( + ((this.__object = "Request"), + ["app_id", "execute", "session_id", "debug"].forEach((e) => { + 0 > t.__properties.indexOf(e) && t.__properties.push(e); + }), + e && "object" == typeof e) + ) + for (var s = 0; s < this.__properties.length; s++) + void 0 !== e[this.__properties[s]] && + (this[this.__properties[s]] = e[this.__properties[s]]); + } + #ax = null; + get execute() { + return this.#ax; + } + set execute(e) { + if ( + (Array.isArray(e) || + e instanceof NewgroundsIO.objects.Execute || + "object" != typeof e || + (e = new NewgroundsIO.objects.Execute(e)), + Array.isArray(e)) + ) { + let t = []; + (e.forEach(function (e, s) { + (null === e || + e instanceof NewgroundsIO.objects.Execute || + console.warn( + "Type Mismatch: expecting NewgroundsIO.objects.Execute, got ", + e + ), + (t[s] = e)); + }), + (this.#ax = t)); + return; + } + (null === e || + e instanceof NewgroundsIO.objects.Execute || + console.warn( + "Type Mismatch: expecting NewgroundsIO.objects.Execute, got ", + e + ), + (this.#ax = e)); + } + #P = null; + get debug() { + return this.#P; + } + set debug(e) { + ("boolean" != typeof e && + "number" != typeof e && + null !== e && + console.warn( + "NewgroundsIO Type Mismatch: Value should be a boolean, got", + e + ), + (this.#P = !!e)); + } + objectMap = { execute: "Execute" }; + arrayMap = { execute: "Execute" }; + get app_id() { + return this.__ngioCore ? this.__ngioCore.appID : null; + } + get session_id() { + return this.__ngioCore && this.__ngioCore.session + ? this.__ngioCore.session.id + : null; + } + } + (void 0 === NewgroundsIO.objects && (NewgroundsIO.objects = {}), + (NewgroundsIO.objects.Request = e)); + })(), + (() => { + class e extends NewgroundsIO.BaseObject { + constructor(e) { + super(); + let t = this; + if ( + ((this.__object = "Response"), + [ + "app_id", + "success", + "debug", + "result", + "error", + "api_version", + "help_url", + ].forEach((e) => { + 0 > t.__properties.indexOf(e) && t.__properties.push(e); + }), + e && "object" == typeof e) + ) + for (var s = 0; s < this.__properties.length; s++) + void 0 !== e[this.__properties[s]] && + (this[this.__properties[s]] = e[this.__properties[s]]); + } + #Y = null; + get app_id() { + return this.#Y; + } + set app_id(e) { + ("string" != typeof e && + null !== e && + console.warn( + "NewgroundsIO Type Mismatch: Value should be a string, got", + e + ), + (this.#Y = String(e))); + } + #ay = null; + get success() { + return this.#ay; + } + set success(e) { + ("boolean" != typeof e && + "number" != typeof e && + null !== e && + console.warn( + "NewgroundsIO Type Mismatch: Value should be a boolean, got", + e + ), + (this.#ay = !!e)); + } + #P = null; + get debug() { + return this.#P; + } + set debug(e) { + (e instanceof NewgroundsIO.objects.Debug || + "object" != typeof e || + (e = new NewgroundsIO.objects.Debug(e)), + null === e || + e instanceof NewgroundsIO.objects.Debug || + console.warn( + "Type Mismatch: expecting NewgroundsIO.objects.Debug, got ", + e + ), + (this.#P = e)); + } + #az = null; + get result() { + return this.#az; + } + set result(e) { + if (Array.isArray(e)) { + let t = []; + (e.forEach(function (e, s) { + (e instanceof NewgroundsIO.BaseResult || + null === e || + console.warn( + "NewgroundsIO Type Mismatch: Value should be a NewgroundsIO.results.XXXX instance, got", + e + ), + (t[s] = e)); + }), + (this.#az = t)); + return; + } + (e instanceof NewgroundsIO.BaseResult || + null === e || + console.warn( + "NewgroundsIO Type Mismatch: Value should be a NewgroundsIO.results.XXXX instance, got", + e + ), + (this.#az = e)); + } + #aA = null; + get error() { + return this.#aA; + } + set error(e) { + (e instanceof NewgroundsIO.objects.Error || + "object" != typeof e || + (e = new NewgroundsIO.objects.Error(e)), + null === e || + e instanceof NewgroundsIO.objects.Error || + console.warn( + "Type Mismatch: expecting NewgroundsIO.objects.Error, got ", + e + ), + (this.#aA = e)); + } + #aB = null; + get api_version() { + return this.#aB; + } + set api_version(e) { + ("string" != typeof e && + null !== e && + console.warn( + "NewgroundsIO Type Mismatch: Value should be a string, got", + e + ), + (this.#aB = String(e))); + } + #aC = null; + get help_url() { + return this.#aC; + } + set help_url(e) { + ("string" != typeof e && + null !== e && + console.warn( + "NewgroundsIO Type Mismatch: Value should be a string, got", + e + ), + (this.#aC = String(e))); + } + objectMap = { debug: "Debug", error: "Error" }; + } + (void 0 === NewgroundsIO.objects && (NewgroundsIO.objects = {}), + (NewgroundsIO.objects.Response = e)); + })(), + (() => { + class e extends NewgroundsIO.BaseObject { + constructor(e) { + super(); + let t = this; + if ( + ((this.__object = "SaveSlot"), + ["id", "size", "datetime", "timestamp", "url"].forEach((e) => { + 0 > t.__properties.indexOf(e) && t.__properties.push(e); + }), + e && "object" == typeof e) + ) + for (var s = 0; s < this.__properties.length; s++) + void 0 !== e[this.__properties[s]] && + (this[this.__properties[s]] = e[this.__properties[s]]); + } + #X = null; + get id() { + return this.#X; + } + set id(e) { + ("number" != typeof e && null !== e + ? console.warn( + "NewgroundsIO Type Mismatch: Value should be a number, got", + e + ) + : Number.isInteger(e) || + null === e || + console.warn( + "NewgroundsIO Type Mismatch: Value should be an integer, got a float" + ), + (this.#X = Number(e)), + isNaN(this.#X) && (this.#X = null)); + } + #aD = null; + get size() { + return this.#aD; + } + set size(e) { + ("number" != typeof e && null !== e + ? console.warn( + "NewgroundsIO Type Mismatch: Value should be a number, got", + e + ) + : Number.isInteger(e) || + null === e || + console.warn( + "NewgroundsIO Type Mismatch: Value should be an integer, got a float" + ), + (this.#aD = Number(e)), + isNaN(this.#aD) && (this.#aD = null)); + } + #aE = null; + get datetime() { + return this.#aE; + } + set datetime(e) { + ("string" != typeof e && + null !== e && + console.warn( + "NewgroundsIO Type Mismatch: Value should be a string, got", + e + ), + (this.#aE = String(e))); + } + #aF = null; + get timestamp() { + return this.#aF; + } + set timestamp(e) { + ("number" != typeof e && null !== e + ? console.warn( + "NewgroundsIO Type Mismatch: Value should be a number, got", + e + ) + : Number.isInteger(e) || + null === e || + console.warn( + "NewgroundsIO Type Mismatch: Value should be an integer, got a float" + ), + (this.#aF = Number(e)), + isNaN(this.#aF) && (this.#aF = null)); + } + #aG = null; + get url() { + return this.#aG; + } + set url(e) { + ("string" != typeof e && + null !== e && + console.warn( + "NewgroundsIO Type Mismatch: Value should be a string, got", + e + ), + (this.#aG = String(e))); + } + get hasData() { + return null !== this.url; + } + getData(e, t) { + if ("function" != typeof e) { + debug.error("NewgroundsIO - Missing required callback function"); + return; + } + var s = new XMLHttpRequest(); + ((s.onreadystatechange = function () { + 4 == s.readyState && + (t ? e.call(t, s.responseText) : e(s.responseText)); + }), + s.open("GET", this.url, !0), + s.send()); + } + setData(e, t, s) { + if (!this.__ngioCore) { + console.error( + "NewgroundsIO - Can not save data without attaching a NewgroundsIO.Core instance." + ); + return; + } + var o = this.__ngioCore.getComponent("CloudSave.setData", { + id: this.id, + data: e, + }); + this.__ngioCore.executeComponent(o, t, s); + } + clearData(e, t) { + if (!this.__ngioCore) { + console.error( + "NewgroundsIO - Can not clear data without attaching a NewgroundsIO.Core instance." + ); + return; + } + this.#aG = null; + var s = this.__ngioCore.getComponent("CloudSave.clearSlot", { + id: this.id, + }); + this.__ngioCore.executeComponent(s, e, t); + } + getDate() { + return this.hasData ? new Date(this.datetime) : null; + } + } + (void 0 === NewgroundsIO.objects && (NewgroundsIO.objects = {}), + (NewgroundsIO.objects.SaveSlot = e)); + })(), + (() => { + class e extends NewgroundsIO.BaseObject { + constructor(e) { + super(); + let t = this; + if ( + ((this.__object = "Score"), + ["user", "value", "formatted_value", "tag"].forEach((e) => { + 0 > t.__properties.indexOf(e) && t.__properties.push(e); + }), + e && "object" == typeof e) + ) + for (var s = 0; s < this.__properties.length; s++) + void 0 !== e[this.__properties[s]] && + (this[this.__properties[s]] = e[this.__properties[s]]); + } + #af = null; + get user() { + return this.#af; + } + set user(e) { + (e instanceof NewgroundsIO.objects.User || + "object" != typeof e || + (e = new NewgroundsIO.objects.User(e)), + null === e || + e instanceof NewgroundsIO.objects.User || + console.warn( + "Type Mismatch: expecting NewgroundsIO.objects.User, got ", + e + ), + (this.#af = e)); + } + #ai = null; + get value() { + return this.#ai; + } + set value(e) { + ("number" != typeof e && null !== e + ? console.warn( + "NewgroundsIO Type Mismatch: Value should be a number, got", + e + ) + : Number.isInteger(e) || + null === e || + console.warn( + "NewgroundsIO Type Mismatch: Value should be an integer, got a float" + ), + (this.#ai = Number(e)), + isNaN(this.#ai) && (this.#ai = null)); + } + #aH = null; + get formatted_value() { + return this.#aH; + } + set formatted_value(e) { + ("string" != typeof e && + null !== e && + console.warn( + "NewgroundsIO Type Mismatch: Value should be a string, got", + e + ), + (this.#aH = String(e))); + } + #ad = null; + get tag() { + return this.#ad; + } + set tag(e) { + ("string" != typeof e && + null !== e && + console.warn( + "NewgroundsIO Type Mismatch: Value should be a string, got", + e + ), + (this.#ad = String(e))); + } + objectMap = { user: "User" }; + } + (void 0 === NewgroundsIO.objects && (NewgroundsIO.objects = {}), + (NewgroundsIO.objects.Score = e)); + })(), + (() => { + class e extends NewgroundsIO.BaseObject { + constructor(e) { + super(); + let t = this; + if ( + ((this.__object = "ScoreBoard"), + ["id", "name"].forEach((e) => { + 0 > t.__properties.indexOf(e) && t.__properties.push(e); + }), + e && "object" == typeof e) + ) + for (var s = 0; s < this.__properties.length; s++) + void 0 !== e[this.__properties[s]] && + (this[this.__properties[s]] = e[this.__properties[s]]); + } + #X = null; + get id() { + return this.#X; + } + set id(e) { + ("number" != typeof e && null !== e + ? console.warn( + "NewgroundsIO Type Mismatch: Value should be a number, got", + e + ) + : Number.isInteger(e) || + null === e || + console.warn( + "NewgroundsIO Type Mismatch: Value should be an integer, got a float" + ), + (this.#X = Number(e)), + isNaN(this.#X) && (this.#X = null)); + } + #ar = null; + get name() { + return this.#ar; + } + set name(e) { + ("string" != typeof e && + null !== e && + console.warn( + "NewgroundsIO Type Mismatch: Value should be a string, got", + e + ), + (this.#ar = String(e))); + } + getScores(e, t, s) { + if (!this.__ngioCore) { + console.error( + "NewgroundsIO - Can not get scores without attaching a NewgroundsIO.Core instance." + ); + return; + } + ("function" == typeof e && ((s = t), (t = e), (e = {})), + e || (e = {}), + (e.id = this.id)); + var o = this.__ngioCore.getComponent("ScoreBoard.getScores", e); + this.__ngioCore.executeComponent(o, t, s); + } + postScore(e, t, s, o) { + if (!this.__ngioCore) { + console.error( + "NewgroundsIO - Can not post scores without attaching a NewgroundsIO.Core instance." + ); + return; + } + "function" == typeof t && ((o = s), (s = t), (t = null)); + var r = this.__ngioCore.getComponent("ScoreBoard.postScore", { + id: this.id, + value: e, + tag: t, + }); + this.__ngioCore.executeComponent(r, s, o); + } + } + (void 0 === NewgroundsIO.objects && (NewgroundsIO.objects = {}), + (NewgroundsIO.objects.ScoreBoard = e)); + })(), + (() => { + class e extends NewgroundsIO.BaseObject { + constructor(e) { + super(); + let t = this; + if ( + ((this.__object = "Session"), + ["id", "user", "expired", "remember", "passport_url"].forEach( + (e) => { + 0 > t.__properties.indexOf(e) && t.__properties.push(e); + } + ), + e && "object" == typeof e) + ) + for (var s = 0; s < this.__properties.length; s++) + void 0 !== e[this.__properties[s]] && + (this[this.__properties[s]] = e[this.__properties[s]]); + } + #X = null; + get id() { + return this.#X; + } + set id(e) { + ("string" != typeof e && + null !== e && + console.warn( + "NewgroundsIO Type Mismatch: Value should be a string, got", + e + ), + (this.#X = String(e))); + } + #af = null; + get user() { + return this.#af; + } + set user(e) { + (e instanceof NewgroundsIO.objects.User || + "object" != typeof e || + (e = new NewgroundsIO.objects.User(e)), + null === e || + e instanceof NewgroundsIO.objects.User || + console.warn( + "Type Mismatch: expecting NewgroundsIO.objects.User, got ", + e + ), + (this.#af = e)); + } + #aI = null; + get expired() { + return this.#aI; + } + set expired(e) { + ("boolean" != typeof e && + "number" != typeof e && + null !== e && + console.warn( + "NewgroundsIO Type Mismatch: Value should be a boolean, got", + e + ), + (this.#aI = !!e)); + } + #aJ = null; + get remember() { + return this.#aJ; + } + set remember(e) { + ("boolean" != typeof e && + "number" != typeof e && + null !== e && + console.warn( + "NewgroundsIO Type Mismatch: Value should be a boolean, got", + e + ), + (this.#aJ = !!e)); + } + #aK = null; + get passport_url() { + return this.#aK; + } + set passport_url(e) { + ("string" != typeof e && + null !== e && + console.warn( + "NewgroundsIO Type Mismatch: Value should be a string, got", + e + ), + (this.#aK = String(e))); + } + objectMap = { user: "User" }; + #aL = NewgroundsIO.SessionState.SESSION_UNINITIALIZED; + #aM = null; + #aN = !1; + #aO = new Date(new Date().getTime() - 3e4); + #aP = !0; + #aQ = "expired"; + #aR = 0; + #aS = 5; + #aT = null; + get uri_id() { + return this.#aT; + } + set uri_id(e) { + ("string" != typeof e && + null !== e && + console.warn( + "NewgroundsIO Type Mismatch: Value should be a string, got", + e + ), + (this.#aT = String(e))); + } + #aU = null; + get status() { + return this.#aL; + } + get statusChanged() { + return this.#aN; + } + get waiting() { + return this.#aM != this.status; + } + get storageKey() { + return this.__ngioCore + ? "_ngio_" + this.__ngioCore.appID + "_session_" + : null; + } + resetSession() { + ((this.#aT = null), + (this.#aU = null), + (this.remember = !1), + (this.user = null), + (this.expired = !1), + localStorage.setItem(this.storageKey, null)); + } + openLoginPage() { + if (!this.passport_url) { + console.warn( + "Can't open passport without getting a valis session first." + ); + return; + } + ((this.#aL = NewgroundsIO.SessionState.WAITING_FOR_USER), + (this.mode = "check"), + window.open(this.passport_url, "_blank")); + } + logOut(e, t) { + ((this.mode = "wait"), this.endSession(e, t)); + } + cancelLogin(e) { + (this.endSession(), + void 0 === e && (e = NewgroundsIO.SessionState.LOGIN_CANCELLED), + this.resetSession(), + (this.id = null), + (this.#aL = e), + (this.#aR = 0), + (this.#aQ = "new"), + (this.#aO = new Date(new Date().getTime() - 3e4))); + } + update(e, t) { + if ( + ((this.#aN = !1), + this.#aM != this.status && + ((this.#aN = !0), + (this.#aM = this.status), + "function" == typeof e && (t ? e.call(t, this) : e(this))), + this.#aP && "wait" != this.mode) + ) { + if (!this.__ngioCore) { + (console.error( + "NewgroundsIO - Can't update session without attaching a NewgroundsIO.Core instance." + ), + (this.#aP = !1)); + return; + } + (this.status == NewgroundsIO.SessionState.SERVER_UNAVAILABLE && + (this.#aR >= this.#aS + ? (this.#aL = NewgroundsIO.SessionState.EXCEEDED_MAX_ATTEMPTS) + : ((this.#aL = NewgroundsIO.SessionState.SESSION_UNINITIALIZED), + this.#aR++)), + this.status == NewgroundsIO.SessionState.SESSION_UNINITIALIZED && + ((this.#aU = localStorage.getItem(this.storageKey)), + this.#aT + ? (this.id = this.#aT) + : this.#aU && (this.id = this.#aU), + (this.mode = this.id && "null" !== this.id ? "check" : "new"))); + var s = new Date(); + if (!(s - this.#aO < 5e3)) + switch (((this.#aO = s), this.mode)) { + case "new": + ((this.mode = "wait"), this.startSession()); + break; + case "check": + ((this.mode = "wait"), this.checkSession()); + } + } + } + startSession() { + ((this.#aP = !1), + this.resetSession(), + (this.#aL = NewgroundsIO.SessionState.WAITING_FOR_SERVER)); + var e = this.__ngioCore.getComponent("App.startSession"); + this.__ngioCore.executeComponent(e, this._onStartSession, this); + } + _onStartSession(e) { + if (!0 === e.success) { + let t = e.result; + if (Array.isArray(t)) { + for (let s = 0; s < t.length; s++) + if ( + t[s] && + t[s].__object && + "App.startSession" == t[s].__object + ) { + t = t[s]; + break; + } + } + ((this.id = t.session.id), + (this.passport_url = t.session.passport_url), + (this.#aL = NewgroundsIO.SessionState.LOGIN_REQUIRED), + (this.mode = "wait")); + } else this.#aL = NewgroundsIO.SessionState.SERVER_UNAVAILABLE; + this.#aP = !0; + } + checkSession() { + this.#aP = !1; + var e = this.__ngioCore.getComponent("App.checkSession"); + this.__ngioCore.executeComponent(e, this._onCheckSession, this); + } + _onCheckSession(e) { + (!0 === e.success + ? e.result.success + ? e.result.session.expired + ? (this.resetSession(), + (this.id = null), + (this.#aL = NewgroundsIO.SessionState.SESSION_UNINITIALIZED)) + : null !== e.result.session.user + ? ((this.user = e.result.session.user), + (this.#aL = NewgroundsIO.SessionState.LOGIN_SUCCESSFUL), + (this.mode = "valid"), + e.result.session.remember && + ((this.#aU = this.id), + (this.remember = !0), + localStorage.setItem(this.storageKey, this.id))) + : (this.mode = "check") + : ((this.id = null), + this.cancelLogin( + 111 === e.result.error.code + ? NewgroundsIO.SessionState.LOGIN_CANCELLED + : NewgroundsIO.SessionState.LOGIN_FAILED + )) + : (this.#aL = NewgroundsIO.SessionState.SERVER_UNAVAILABLE), + (this.#aP = !0)); + } + endSession(e, t) { + this.#aP = !1; + var s = this.__ngioCore.getComponent("App.endSession"), + o = this.__ngioCore.getComponent("App.startSession"); + (this.__ngioCore.queueComponent(s), + this.__ngioCore.queueComponent(o), + this.__ngioCore.executeQueue(function (s) { + (this._onEndSession(s), + this._onStartSession(s), + "function" == typeof e && (t ? e.call(t, this) : e(this))); + }, this)); + } + _onEndSession(e) { + (this.resetSession(), + (this.id = null), + (this.user = null), + (this.passport_url = null), + (this.mode = "new"), + (this.#aL = NewgroundsIO.SessionState.USER_LOGGED_OUT), + (this.#aP = !0)); + } + } + (void 0 === NewgroundsIO.objects && (NewgroundsIO.objects = {}), + (NewgroundsIO.objects.Session = e)); + })(), + (() => { + class e extends NewgroundsIO.BaseObject { + constructor(e) { + super(); + let t = this; + if ( + ((this.__object = "User"), + ["id", "name", "icons", "supporter"].forEach((e) => { + 0 > t.__properties.indexOf(e) && t.__properties.push(e); + }), + e && "object" == typeof e) + ) + for (var s = 0; s < this.__properties.length; s++) + void 0 !== e[this.__properties[s]] && + (this[this.__properties[s]] = e[this.__properties[s]]); + } + #X = null; + get id() { + return this.#X; + } + set id(e) { + ("number" != typeof e && null !== e + ? console.warn( + "NewgroundsIO Type Mismatch: Value should be a number, got", + e + ) + : Number.isInteger(e) || + null === e || + console.warn( + "NewgroundsIO Type Mismatch: Value should be an integer, got a float" + ), + (this.#X = Number(e)), + isNaN(this.#X) && (this.#X = null)); + } + #ar = null; + get name() { + return this.#ar; + } + set name(e) { + ("string" != typeof e && + null !== e && + console.warn( + "NewgroundsIO Type Mismatch: Value should be a string, got", + e + ), + (this.#ar = String(e))); + } + #aV = null; + get icons() { + return this.#aV; + } + set icons(e) { + (e instanceof NewgroundsIO.objects.UserIcons || + "object" != typeof e || + (e = new NewgroundsIO.objects.UserIcons(e)), + null === e || + e instanceof NewgroundsIO.objects.UserIcons || + console.warn( + "Type Mismatch: expecting NewgroundsIO.objects.UserIcons, got ", + e + ), + (this.#aV = e)); + } + #aW = null; + get supporter() { + return this.#aW; + } + set supporter(e) { + ("boolean" != typeof e && + "number" != typeof e && + null !== e && + console.warn( + "NewgroundsIO Type Mismatch: Value should be a boolean, got", + e + ), + (this.#aW = !!e)); + } + objectMap = { icons: "UserIcons" }; + } + (void 0 === NewgroundsIO.objects && (NewgroundsIO.objects = {}), + (NewgroundsIO.objects.User = e)); + })(), + (() => { + class e extends NewgroundsIO.BaseObject { + constructor(e) { + super(); + let t = this; + if ( + ((this.__object = "UserIcons"), + ["small", "medium", "large"].forEach((e) => { + 0 > t.__properties.indexOf(e) && t.__properties.push(e); + }), + e && "object" == typeof e) + ) + for (var s = 0; s < this.__properties.length; s++) + void 0 !== e[this.__properties[s]] && + (this[this.__properties[s]] = e[this.__properties[s]]); + } + #aX = null; + get small() { + return this.#aX; + } + set small(e) { + ("string" != typeof e && + null !== e && + console.warn( + "NewgroundsIO Type Mismatch: Value should be a string, got", + e + ), + (this.#aX = String(e))); + } + #aY = null; + get medium() { + return this.#aY; + } + set medium(e) { + ("string" != typeof e && + null !== e && + console.warn( + "NewgroundsIO Type Mismatch: Value should be a string, got", + e + ), + (this.#aY = String(e))); + } + #aZ = null; + get large() { + return this.#aZ; + } + set large(e) { + ("string" != typeof e && + null !== e && + console.warn( + "NewgroundsIO Type Mismatch: Value should be a string, got", + e + ), + (this.#aZ = String(e))); + } + } + (void 0 === NewgroundsIO.objects && (NewgroundsIO.objects = {}), + (NewgroundsIO.objects.UserIcons = e)); + })(), + (() => { + class e extends NewgroundsIO.BaseResult { + constructor(e) { + super(); + let t = this; + if ( + ((this.__object = "App.checkSession"), + ["session"].forEach((e) => { + 0 > t.__properties.indexOf(e) && t.__properties.push(e); + }), + e && "object" == typeof e) + ) + for (var s = 0; s < this.__properties.length; s++) + void 0 !== e[this.__properties[s]] && + (this[this.__properties[s]] = e[this.__properties[s]]); + } + #U = null; + get session() { + return this.#U; + } + set session(e) { + (e instanceof NewgroundsIO.objects.Session || + "object" != typeof e || + (e = new NewgroundsIO.objects.Session(e)), + null === e || + e instanceof NewgroundsIO.objects.Session || + console.warn( + "Type Mismatch: expecting NewgroundsIO.objects.Session, got ", + e + ), + (this.#U = e)); + } + objectMap = { session: "Session" }; + } + (void 0 === NewgroundsIO.results.App && (NewgroundsIO.results.App = {}), + (NewgroundsIO.results.App.checkSession = e)); + })(), + (() => { + class e extends NewgroundsIO.BaseResult { + constructor(e) { + super(); + let t = this; + if ( + ((this.__object = "App.getCurrentVersion"), + ["current_version", "client_deprecated"].forEach((e) => { + 0 > t.__properties.indexOf(e) && t.__properties.push(e); + }), + e && "object" == typeof e) + ) + for (var s = 0; s < this.__properties.length; s++) + void 0 !== e[this.__properties[s]] && + (this[this.__properties[s]] = e[this.__properties[s]]); + } + #a$ = null; + get current_version() { + return this.#a$; + } + set current_version(e) { + ("string" != typeof e && + null !== e && + console.warn( + "NewgroundsIO Type Mismatch: Value should be a string, got", + e + ), + (this.#a$ = String(e))); + } + #a_ = null; + get client_deprecated() { + return this.#a_; + } + set client_deprecated(e) { + ("boolean" != typeof e && + "number" != typeof e && + null !== e && + console.warn( + "NewgroundsIO Type Mismatch: Value should be a boolean, got", + e + ), + (this.#a_ = !!e)); + } + } + (void 0 === NewgroundsIO.results.App && (NewgroundsIO.results.App = {}), + (NewgroundsIO.results.App.getCurrentVersion = e)); + })(), + (() => { + class e extends NewgroundsIO.BaseResult { + constructor(e) { + super(); + let t = this; + if ( + ((this.__object = "App.getHostLicense"), + ["host_approved"].forEach((e) => { + 0 > t.__properties.indexOf(e) && t.__properties.push(e); + }), + e && "object" == typeof e) + ) + for (var s = 0; s < this.__properties.length; s++) + void 0 !== e[this.__properties[s]] && + (this[this.__properties[s]] = e[this.__properties[s]]); + } + #a0 = null; + get host_approved() { + return this.#a0; + } + set host_approved(e) { + ("boolean" != typeof e && + "number" != typeof e && + null !== e && + console.warn( + "NewgroundsIO Type Mismatch: Value should be a boolean, got", + e + ), + (this.#a0 = !!e)); + } + } + (void 0 === NewgroundsIO.results.App && (NewgroundsIO.results.App = {}), + (NewgroundsIO.results.App.getHostLicense = e)); + })(), + (() => { + class e extends NewgroundsIO.BaseResult { + constructor(e) { + super(); + let t = this; + if ( + ((this.__object = "App.startSession"), + ["session"].forEach((e) => { + 0 > t.__properties.indexOf(e) && t.__properties.push(e); + }), + e && "object" == typeof e) + ) + for (var s = 0; s < this.__properties.length; s++) + void 0 !== e[this.__properties[s]] && + (this[this.__properties[s]] = e[this.__properties[s]]); + } + #U = null; + get session() { + return this.#U; + } + set session(e) { + (e instanceof NewgroundsIO.objects.Session || + "object" != typeof e || + (e = new NewgroundsIO.objects.Session(e)), + null === e || + e instanceof NewgroundsIO.objects.Session || + console.warn( + "Type Mismatch: expecting NewgroundsIO.objects.Session, got ", + e + ), + (this.#U = e)); + } + objectMap = { session: "Session" }; + } + (void 0 === NewgroundsIO.results.App && (NewgroundsIO.results.App = {}), + (NewgroundsIO.results.App.startSession = e)); + })(), + (() => { + class e extends NewgroundsIO.BaseResult { + constructor(e) { + super(); + let t = this; + if ( + ((this.__object = "CloudSave.clearSlot"), + ["slot"].forEach((e) => { + 0 > t.__properties.indexOf(e) && t.__properties.push(e); + }), + e && "object" == typeof e) + ) + for (var s = 0; s < this.__properties.length; s++) + void 0 !== e[this.__properties[s]] && + (this[this.__properties[s]] = e[this.__properties[s]]); + } + #a1 = null; + get slot() { + return this.#a1; + } + set slot(e) { + (e instanceof NewgroundsIO.objects.SaveSlot || + "object" != typeof e || + (e = new NewgroundsIO.objects.SaveSlot(e)), + null === e || + e instanceof NewgroundsIO.objects.SaveSlot || + console.warn( + "Type Mismatch: expecting NewgroundsIO.objects.SaveSlot, got ", + e + ), + (this.#a1 = e)); + } + objectMap = { slot: "SaveSlot" }; + } + (void 0 === NewgroundsIO.results.CloudSave && + (NewgroundsIO.results.CloudSave = {}), + (NewgroundsIO.results.CloudSave.clearSlot = e)); + })(), + (() => { + class e extends NewgroundsIO.BaseResult { + constructor(e) { + super(); + let t = this; + if ( + ((this.__object = "CloudSave.loadSlot"), + ["slot", "app_id"].forEach((e) => { + 0 > t.__properties.indexOf(e) && t.__properties.push(e); + }), + e && "object" == typeof e) + ) + for (var s = 0; s < this.__properties.length; s++) + void 0 !== e[this.__properties[s]] && + (this[this.__properties[s]] = e[this.__properties[s]]); + } + #a1 = null; + get slot() { + return this.#a1; + } + set slot(e) { + (e instanceof NewgroundsIO.objects.SaveSlot || + "object" != typeof e || + (e = new NewgroundsIO.objects.SaveSlot(e)), + null === e || + e instanceof NewgroundsIO.objects.SaveSlot || + console.warn( + "Type Mismatch: expecting NewgroundsIO.objects.SaveSlot, got ", + e + ), + (this.#a1 = e)); + } + #Y = null; + get app_id() { + return this.#Y; + } + set app_id(e) { + ("string" != typeof e && + null !== e && + console.warn( + "NewgroundsIO Type Mismatch: Value should be a string, got", + e + ), + (this.#Y = String(e))); + } + objectMap = { slot: "SaveSlot" }; + } + (void 0 === NewgroundsIO.results.CloudSave && + (NewgroundsIO.results.CloudSave = {}), + (NewgroundsIO.results.CloudSave.loadSlot = e)); + })(), + (() => { + class e extends NewgroundsIO.BaseResult { + constructor(e) { + super(); + let t = this; + if ( + ((this.__object = "CloudSave.loadSlots"), + ["slots", "app_id"].forEach((e) => { + 0 > t.__properties.indexOf(e) && t.__properties.push(e); + }), + e && "object" == typeof e) + ) + for (var s = 0; s < this.__properties.length; s++) + void 0 !== e[this.__properties[s]] && + (this[this.__properties[s]] = e[this.__properties[s]]); + } + #a2 = null; + get slots() { + return this.#a2; + } + set slots(e) { + if (Array.isArray(e)) { + let t = []; + (e.forEach(function (e, s) { + (null === e || + e instanceof NewgroundsIO.objects.SaveSlot || + console.warn( + "Type Mismatch: expecting NewgroundsIO.objects.SaveSlot, got ", + e + ), + (t[s] = e)); + }), + (this.#a2 = t)); + return; + } + } + #Y = null; + get app_id() { + return this.#Y; + } + set app_id(e) { + ("string" != typeof e && + null !== e && + console.warn( + "NewgroundsIO Type Mismatch: Value should be a string, got", + e + ), + (this.#Y = String(e))); + } + arrayMap = { slots: "SaveSlot" }; + } + (void 0 === NewgroundsIO.results.CloudSave && + (NewgroundsIO.results.CloudSave = {}), + (NewgroundsIO.results.CloudSave.loadSlots = e)); + })(), + (() => { + class e extends NewgroundsIO.BaseResult { + constructor(e) { + super(); + let t = this; + if ( + ((this.__object = "CloudSave.setData"), + ["slot"].forEach((e) => { + 0 > t.__properties.indexOf(e) && t.__properties.push(e); + }), + e && "object" == typeof e) + ) + for (var s = 0; s < this.__properties.length; s++) + void 0 !== e[this.__properties[s]] && + (this[this.__properties[s]] = e[this.__properties[s]]); + } + #a1 = null; + get slot() { + return this.#a1; + } + set slot(e) { + (e instanceof NewgroundsIO.objects.SaveSlot || + "object" != typeof e || + (e = new NewgroundsIO.objects.SaveSlot(e)), + null === e || + e instanceof NewgroundsIO.objects.SaveSlot || + console.warn( + "Type Mismatch: expecting NewgroundsIO.objects.SaveSlot, got ", + e + ), + (this.#a1 = e)); + } + objectMap = { slot: "SaveSlot" }; + } + (void 0 === NewgroundsIO.results.CloudSave && + (NewgroundsIO.results.CloudSave = {}), + (NewgroundsIO.results.CloudSave.setData = e)); + })(), + (() => { + class e extends NewgroundsIO.BaseResult { + constructor(e) { + super(); + let t = this; + if ( + ((this.__object = "Event.logEvent"), + ["event_name"].forEach((e) => { + 0 > t.__properties.indexOf(e) && t.__properties.push(e); + }), + e && "object" == typeof e) + ) + for (var s = 0; s < this.__properties.length; s++) + void 0 !== e[this.__properties[s]] && + (this[this.__properties[s]] = e[this.__properties[s]]); + } + #$ = null; + get event_name() { + return this.#$; + } + set event_name(e) { + ("string" != typeof e && + null !== e && + console.warn( + "NewgroundsIO Type Mismatch: Value should be a string, got", + e + ), + (this.#$ = String(e))); + } + } + (void 0 === NewgroundsIO.results.Event && + (NewgroundsIO.results.Event = {}), + (NewgroundsIO.results.Event.logEvent = e)); + })(), + (() => { + class e extends NewgroundsIO.BaseResult { + constructor(e) { + super(); + let t = this; + if ( + ((this.__object = "Gateway.getDatetime"), + ["datetime", "timestamp"].forEach((e) => { + 0 > t.__properties.indexOf(e) && t.__properties.push(e); + }), + e && "object" == typeof e) + ) + for (var s = 0; s < this.__properties.length; s++) + void 0 !== e[this.__properties[s]] && + (this[this.__properties[s]] = e[this.__properties[s]]); + } + #aE = null; + get datetime() { + return this.#aE; + } + set datetime(e) { + ("string" != typeof e && + null !== e && + console.warn( + "NewgroundsIO Type Mismatch: Value should be a string, got", + e + ), + (this.#aE = String(e))); + } + #aF = null; + get timestamp() { + return this.#aF; + } + set timestamp(e) { + ("number" != typeof e && null !== e + ? console.warn( + "NewgroundsIO Type Mismatch: Value should be a number, got", + e + ) + : Number.isInteger(e) || + null === e || + console.warn( + "NewgroundsIO Type Mismatch: Value should be an integer, got a float" + ), + (this.#aF = Number(e)), + isNaN(this.#aF) && (this.#aF = null)); + } + } + (void 0 === NewgroundsIO.results.Gateway && + (NewgroundsIO.results.Gateway = {}), + (NewgroundsIO.results.Gateway.getDatetime = e)); + })(), + (() => { + class e extends NewgroundsIO.BaseResult { + constructor(e) { + super(); + let t = this; + if ( + ((this.__object = "Gateway.getVersion"), + ["version"].forEach((e) => { + 0 > t.__properties.indexOf(e) && t.__properties.push(e); + }), + e && "object" == typeof e) + ) + for (var s = 0; s < this.__properties.length; s++) + void 0 !== e[this.__properties[s]] && + (this[this.__properties[s]] = e[this.__properties[s]]); + } + #x = null; + get version() { + return this.#x; + } + set version(e) { + ("string" != typeof e && + null !== e && + console.warn( + "NewgroundsIO Type Mismatch: Value should be a string, got", + e + ), + (this.#x = String(e))); + } + } + (void 0 === NewgroundsIO.results.Gateway && + (NewgroundsIO.results.Gateway = {}), + (NewgroundsIO.results.Gateway.getVersion = e)); + })(), + (() => { + class e extends NewgroundsIO.BaseResult { + constructor(e) { + super(); + let t = this; + if ( + ((this.__object = "Gateway.ping"), + ["pong"].forEach((e) => { + 0 > t.__properties.indexOf(e) && t.__properties.push(e); + }), + e && "object" == typeof e) + ) + for (var s = 0; s < this.__properties.length; s++) + void 0 !== e[this.__properties[s]] && + (this[this.__properties[s]] = e[this.__properties[s]]); + } + #a3 = null; + get pong() { + return this.#a3; + } + set pong(e) { + ("string" != typeof e && + null !== e && + console.warn( + "NewgroundsIO Type Mismatch: Value should be a string, got", + e + ), + (this.#a3 = String(e))); + } + } + (void 0 === NewgroundsIO.results.Gateway && + (NewgroundsIO.results.Gateway = {}), + (NewgroundsIO.results.Gateway.ping = e)); + })(), + (() => { + class e extends NewgroundsIO.BaseResult { + constructor(e) { + super(); + let t = this; + if ( + ((this.__object = "Loader.loadAuthorUrl"), + ["url"].forEach((e) => { + 0 > t.__properties.indexOf(e) && t.__properties.push(e); + }), + e && "object" == typeof e) + ) + for (var s = 0; s < this.__properties.length; s++) + void 0 !== e[this.__properties[s]] && + (this[this.__properties[s]] = e[this.__properties[s]]); + } + #aG = null; + get url() { + return this.#aG; + } + set url(e) { + ("string" != typeof e && + null !== e && + console.warn( + "NewgroundsIO Type Mismatch: Value should be a string, got", + e + ), + (this.#aG = String(e))); + } + } + (void 0 === NewgroundsIO.results.Loader && + (NewgroundsIO.results.Loader = {}), + (NewgroundsIO.results.Loader.loadAuthorUrl = e)); + })(), + (() => { + class e extends NewgroundsIO.BaseResult { + constructor(e) { + super(); + let t = this; + if ( + ((this.__object = "Loader.loadMoreGames"), + ["url"].forEach((e) => { + 0 > t.__properties.indexOf(e) && t.__properties.push(e); + }), + e && "object" == typeof e) + ) + for (var s = 0; s < this.__properties.length; s++) + void 0 !== e[this.__properties[s]] && + (this[this.__properties[s]] = e[this.__properties[s]]); + } + #aG = null; + get url() { + return this.#aG; + } + set url(e) { + ("string" != typeof e && + null !== e && + console.warn( + "NewgroundsIO Type Mismatch: Value should be a string, got", + e + ), + (this.#aG = String(e))); + } + } + (void 0 === NewgroundsIO.results.Loader && + (NewgroundsIO.results.Loader = {}), + (NewgroundsIO.results.Loader.loadMoreGames = e)); + })(), + (() => { + class e extends NewgroundsIO.BaseResult { + constructor(e) { + super(); + let t = this; + if ( + ((this.__object = "Loader.loadNewgrounds"), + ["url"].forEach((e) => { + 0 > t.__properties.indexOf(e) && t.__properties.push(e); + }), + e && "object" == typeof e) + ) + for (var s = 0; s < this.__properties.length; s++) + void 0 !== e[this.__properties[s]] && + (this[this.__properties[s]] = e[this.__properties[s]]); + } + #aG = null; + get url() { + return this.#aG; + } + set url(e) { + ("string" != typeof e && + null !== e && + console.warn( + "NewgroundsIO Type Mismatch: Value should be a string, got", + e + ), + (this.#aG = String(e))); + } + } + (void 0 === NewgroundsIO.results.Loader && + (NewgroundsIO.results.Loader = {}), + (NewgroundsIO.results.Loader.loadNewgrounds = e)); + })(), + (() => { + class e extends NewgroundsIO.BaseResult { + constructor(e) { + super(); + let t = this; + if ( + ((this.__object = "Loader.loadOfficialUrl"), + ["url"].forEach((e) => { + 0 > t.__properties.indexOf(e) && t.__properties.push(e); + }), + e && "object" == typeof e) + ) + for (var s = 0; s < this.__properties.length; s++) + void 0 !== e[this.__properties[s]] && + (this[this.__properties[s]] = e[this.__properties[s]]); + } + #aG = null; + get url() { + return this.#aG; + } + set url(e) { + ("string" != typeof e && + null !== e && + console.warn( + "NewgroundsIO Type Mismatch: Value should be a string, got", + e + ), + (this.#aG = String(e))); + } + } + (void 0 === NewgroundsIO.results.Loader && + (NewgroundsIO.results.Loader = {}), + (NewgroundsIO.results.Loader.loadOfficialUrl = e)); + })(), + (() => { + class e extends NewgroundsIO.BaseResult { + constructor(e) { + super(); + let t = this; + if ( + ((this.__object = "Loader.loadReferral"), + ["url"].forEach((e) => { + 0 > t.__properties.indexOf(e) && t.__properties.push(e); + }), + e && "object" == typeof e) + ) + for (var s = 0; s < this.__properties.length; s++) + void 0 !== e[this.__properties[s]] && + (this[this.__properties[s]] = e[this.__properties[s]]); + } + #aG = null; + get url() { + return this.#aG; + } + set url(e) { + ("string" != typeof e && + null !== e && + console.warn( + "NewgroundsIO Type Mismatch: Value should be a string, got", + e + ), + (this.#aG = String(e))); + } + } + (void 0 === NewgroundsIO.results.Loader && + (NewgroundsIO.results.Loader = {}), + (NewgroundsIO.results.Loader.loadReferral = e)); + })(), + (() => { + class e extends NewgroundsIO.BaseResult { + constructor(e) { + super(); + let t = this; + if ( + ((this.__object = "Medal.getList"), + ["medals", "app_id"].forEach((e) => { + 0 > t.__properties.indexOf(e) && t.__properties.push(e); + }), + e && "object" == typeof e) + ) + for (var s = 0; s < this.__properties.length; s++) + void 0 !== e[this.__properties[s]] && + (this[this.__properties[s]] = e[this.__properties[s]]); + } + #d = null; + get medals() { + return this.#d; + } + set medals(e) { + if (Array.isArray(e)) { + let t = []; + (e.forEach(function (e, s) { + (null === e || + e instanceof NewgroundsIO.objects.Medal || + console.warn( + "Type Mismatch: expecting NewgroundsIO.objects.Medal, got ", + e + ), + (t[s] = e)); + }), + (this.#d = t)); + return; + } + } + #Y = null; + get app_id() { + return this.#Y; + } + set app_id(e) { + ("string" != typeof e && + null !== e && + console.warn( + "NewgroundsIO Type Mismatch: Value should be a string, got", + e + ), + (this.#Y = String(e))); + } + arrayMap = { medals: "Medal" }; + } + (void 0 === NewgroundsIO.results.Medal && + (NewgroundsIO.results.Medal = {}), + (NewgroundsIO.results.Medal.getList = e)); + })(), + (() => { + class e extends NewgroundsIO.BaseResult { + constructor(e) { + super(); + let t = this; + if ( + ((this.__object = "Medal.getMedalScore"), + ["medal_score"].forEach((e) => { + 0 > t.__properties.indexOf(e) && t.__properties.push(e); + }), + e && "object" == typeof e) + ) + for (var s = 0; s < this.__properties.length; s++) + void 0 !== e[this.__properties[s]] && + (this[this.__properties[s]] = e[this.__properties[s]]); + } + #a4 = null; + get medal_score() { + return this.#a4; + } + set medal_score(e) { + ("number" != typeof e && null !== e + ? console.warn( + "NewgroundsIO Type Mismatch: Value should be a number, got", + e + ) + : Number.isInteger(e) || + null === e || + console.warn( + "NewgroundsIO Type Mismatch: Value should be an integer, got a float" + ), + (this.#a4 = Number(e)), + isNaN(this.#a4) && (this.#a4 = null)); + } + } + (void 0 === NewgroundsIO.results.Medal && + (NewgroundsIO.results.Medal = {}), + (NewgroundsIO.results.Medal.getMedalScore = e)); + })(), + (() => { + class e extends NewgroundsIO.BaseResult { + constructor(e) { + super(); + let t = this; + if ( + ((this.__object = "Medal.unlock"), + ["medal", "medal_score"].forEach((e) => { + 0 > t.__properties.indexOf(e) && t.__properties.push(e); + }), + e && "object" == typeof e) + ) + for (var s = 0; s < this.__properties.length; s++) + void 0 !== e[this.__properties[s]] && + (this[this.__properties[s]] = e[this.__properties[s]]); + } + #a5 = null; + get medal() { + return this.#a5; + } + set medal(e) { + (e instanceof NewgroundsIO.objects.Medal || + "object" != typeof e || + (e = new NewgroundsIO.objects.Medal(e)), + null === e || + e instanceof NewgroundsIO.objects.Medal || + console.warn( + "Type Mismatch: expecting NewgroundsIO.objects.Medal, got ", + e + ), + (this.#a5 = e)); + } + #a4 = null; + get medal_score() { + return this.#a4; + } + set medal_score(e) { + ("number" != typeof e && null !== e + ? console.warn( + "NewgroundsIO Type Mismatch: Value should be a number, got", + e + ) + : Number.isInteger(e) || + null === e || + console.warn( + "NewgroundsIO Type Mismatch: Value should be an integer, got a float" + ), + (this.#a4 = Number(e)), + isNaN(this.#a4) && (this.#a4 = null)); + } + objectMap = { medal: "Medal" }; + } + (void 0 === NewgroundsIO.results.Medal && + (NewgroundsIO.results.Medal = {}), + (NewgroundsIO.results.Medal.unlock = e)); + })(), + (() => { + class e extends NewgroundsIO.BaseResult { + constructor(e) { + super(); + let t = this; + if ( + ((this.__object = "ScoreBoard.getBoards"), + ["scoreboards"].forEach((e) => { + 0 > t.__properties.indexOf(e) && t.__properties.push(e); + }), + e && "object" == typeof e) + ) + for (var s = 0; s < this.__properties.length; s++) + void 0 !== e[this.__properties[s]] && + (this[this.__properties[s]] = e[this.__properties[s]]); + } + #a6 = null; + get scoreboards() { + return this.#a6; + } + set scoreboards(e) { + if (Array.isArray(e)) { + let t = []; + (e.forEach(function (e, s) { + (null === e || + e instanceof NewgroundsIO.objects.ScoreBoard || + console.warn( + "Type Mismatch: expecting NewgroundsIO.objects.ScoreBoard, got ", + e + ), + (t[s] = e)); + }), + (this.#a6 = t)); + return; + } + } + arrayMap = { scoreboards: "ScoreBoard" }; + } + (void 0 === NewgroundsIO.results.ScoreBoard && + (NewgroundsIO.results.ScoreBoard = {}), + (NewgroundsIO.results.ScoreBoard.getBoards = e)); + })(), + (() => { + class e extends NewgroundsIO.BaseResult { + constructor(e) { + super(); + let t = this; + if ( + ((this.__object = "ScoreBoard.getScores"), + [ + "period", + "social", + "limit", + "scoreboard", + "scores", + "user", + "app_id", + ].forEach((e) => { + 0 > t.__properties.indexOf(e) && t.__properties.push(e); + }), + e && "object" == typeof e) + ) + for (var s = 0; s < this.__properties.length; s++) + void 0 !== e[this.__properties[s]] && + (this[this.__properties[s]] = e[this.__properties[s]]); + } + #ac = null; + get period() { + return this.#ac; + } + set period(e) { + ("string" != typeof e && + null !== e && + console.warn( + "NewgroundsIO Type Mismatch: Value should be a string, got", + e + ), + (this.#ac = String(e))); + } + #ae = null; + get social() { + return this.#ae; + } + set social(e) { + ("boolean" != typeof e && + "number" != typeof e && + null !== e && + console.warn( + "NewgroundsIO Type Mismatch: Value should be a boolean, got", + e + ), + (this.#ae = !!e)); + } + #ah = null; + get limit() { + return this.#ah; + } + set limit(e) { + ("number" != typeof e && null !== e + ? console.warn( + "NewgroundsIO Type Mismatch: Value should be a number, got", + e + ) + : Number.isInteger(e) || + null === e || + console.warn( + "NewgroundsIO Type Mismatch: Value should be an integer, got a float" + ), + (this.#ah = Number(e)), + isNaN(this.#ah) && (this.#ah = null)); + } + #a7 = null; + get scoreboard() { + return this.#a7; + } + set scoreboard(e) { + (e instanceof NewgroundsIO.objects.ScoreBoard || + "object" != typeof e || + (e = new NewgroundsIO.objects.ScoreBoard(e)), + null === e || + e instanceof NewgroundsIO.objects.ScoreBoard || + console.warn( + "Type Mismatch: expecting NewgroundsIO.objects.ScoreBoard, got ", + e + ), + (this.#a7 = e)); + } + #a8 = null; + get scores() { + return this.#a8; + } + set scores(e) { + if (Array.isArray(e)) { + let t = []; + (e.forEach(function (e, s) { + (null === e || + e instanceof NewgroundsIO.objects.Score || + console.warn( + "Type Mismatch: expecting NewgroundsIO.objects.Score, got ", + e + ), + (t[s] = e)); + }), + (this.#a8 = t)); + return; + } + } + #af = null; + get user() { + return this.#af; + } + set user(e) { + (e instanceof NewgroundsIO.objects.User || + "object" != typeof e || + (e = new NewgroundsIO.objects.User(e)), + null === e || + e instanceof NewgroundsIO.objects.User || + console.warn( + "Type Mismatch: expecting NewgroundsIO.objects.User, got ", + e + ), + (this.#af = e)); + } + #Y = null; + get app_id() { + return this.#Y; + } + set app_id(e) { + ("string" != typeof e && + null !== e && + console.warn( + "NewgroundsIO Type Mismatch: Value should be a string, got", + e + ), + (this.#Y = String(e))); + } + objectMap = { scoreboard: "ScoreBoard", user: "User" }; + arrayMap = { scores: "Score" }; + } + (void 0 === NewgroundsIO.results.ScoreBoard && + (NewgroundsIO.results.ScoreBoard = {}), + (NewgroundsIO.results.ScoreBoard.getScores = e)); + })(), + (() => { + class e extends NewgroundsIO.BaseResult { + constructor(e) { + super(); + let t = this; + if ( + ((this.__object = "ScoreBoard.postScore"), + ["scoreboard", "score"].forEach((e) => { + 0 > t.__properties.indexOf(e) && t.__properties.push(e); + }), + e && "object" == typeof e) + ) + for (var s = 0; s < this.__properties.length; s++) + void 0 !== e[this.__properties[s]] && + (this[this.__properties[s]] = e[this.__properties[s]]); + } + #a7 = null; + get scoreboard() { + return this.#a7; + } + set scoreboard(e) { + (e instanceof NewgroundsIO.objects.ScoreBoard || + "object" != typeof e || + (e = new NewgroundsIO.objects.ScoreBoard(e)), + null === e || + e instanceof NewgroundsIO.objects.ScoreBoard || + console.warn( + "Type Mismatch: expecting NewgroundsIO.objects.ScoreBoard, got ", + e + ), + (this.#a7 = e)); + } + #a9 = null; + get score() { + return this.#a9; + } + set score(e) { + (e instanceof NewgroundsIO.objects.Score || + "object" != typeof e || + (e = new NewgroundsIO.objects.Score(e)), + null === e || + e instanceof NewgroundsIO.objects.Score || + console.warn( + "Type Mismatch: expecting NewgroundsIO.objects.Score, got ", + e + ), + (this.#a9 = e)); + } + objectMap = { scoreboard: "ScoreBoard", score: "Score" }; + } + (void 0 === NewgroundsIO.results.ScoreBoard && + (NewgroundsIO.results.ScoreBoard = {}), + (NewgroundsIO.results.ScoreBoard.postScore = e)); + })()); /* eslint-enable */ @@ -197,7 +4733,9 @@ { opcode: "connect", blockType: Scratch.BlockType.COMMAND, - text: Scratch.translate("connect to game: [gameID] with code: [code]"), + text: Scratch.translate( + "connect to game: [gameID] with code: [code]" + ), hideFromPalette: true, arguments: { gameID: { @@ -214,7 +4752,9 @@ { opcode: "setConnectionData", blockType: Scratch.BlockType.COMMAND, - text: Scratch.translate("connect to game: [gameID] with code: [code] and version: [version]"), + text: Scratch.translate( + "connect to game: [gameID] with code: [code] and version: [version]" + ), arguments: { gameID: { type: Scratch.ArgumentType.STRING, @@ -617,26 +5157,25 @@ setConnectionData({ gameID, code, version }) { return new Promise((resolve, reject) => { - NGOptions.version = version; - NGIO.init(gameID, code, NGOptions); - - //Add a hook for the connection status to Newgrounds. - const intervalID = setInterval(() => { - NGIO.getConnectionStatus(statusReport); - - //Wait for finish - switch (ConnectionStatus) { - //In case we aren't awaiting - case "Awaiting": - break; - - default: - clearInterval(intervalID); - resolve(); - break; - } + NGOptions.version = version; + NGIO.init(gameID, code, NGOptions); + + //Add a hook for the connection status to Newgrounds. + const intervalID = setInterval(() => { + NGIO.getConnectionStatus(statusReport); + + //Wait for finish + switch (ConnectionStatus) { + //In case we aren't awaiting + case "Awaiting": + break; - }, 100); + default: + clearInterval(intervalID); + resolve(); + break; + } + }, 100); }); } @@ -701,7 +5240,11 @@ saveData({ Data, Slot }) { if (NGIO.session && loggedIn) { - NGIO.setSaveSlotData(Scratch.Cast.toString(Slot), Scratch.Cast.toString(Data), onSaveComplete); + NGIO.setSaveSlotData( + Scratch.Cast.toString(Slot), + Scratch.Cast.toString(Data), + onSaveComplete + ); } } @@ -711,7 +5254,12 @@ return new Promise((resolve, reject) => { //When the slot is loaded parse our data function onSaveDataLoaded(data) { - if (Scratch.Cast.toString(data).includes("404 Not Found")) saveDat = ""; + if ( + Scratch.Cast.toString(data).includes( + "404 Not Found" + ) + ) + saveDat = ""; else if (data) saveDat = Scratch.Cast.toString(data); else saveDat = ""; @@ -720,7 +5268,7 @@ //Try to get the data NGIO.getSaveSlotData(Scratch.Cast.toNumber(Slot), onSaveDataLoaded); - }) + }); } else { if (NGIO.session && !loggedIn) return "Not logged in!"; return "Can't get data from NewGrounds!"; @@ -730,7 +5278,7 @@ doesSlotHaveData({ Slot }) { if (NGIO.session && loggedIn) { this.revitalizeSession(); - + //get and verify save slot! const saveSlot = NGIO.getSaveSlot(Slot); if (!saveSlot) return; @@ -755,7 +5303,7 @@ if (NGIO.session && loggedIn) { this.revitalizeSession(); const medal = NGIO.getMedal(Scratch.Cast.toNumber(medalID)); - + //Make sure the medal exists if (!medal) return; return medal.unlocked; @@ -765,9 +5313,9 @@ } revitalizeSession() { - //Get and keep the session alive - NGIO.getConnectionStatus(statusReport); - if (loggedIn) NGIO.keepSessionAlive(); + //Get and keep the session alive + NGIO.getConnectionStatus(statusReport); + if (loggedIn) NGIO.keepSessionAlive(); } } From e55ffc1bf7d2e8438f57a985f50d9a19e669c2f9 Mon Sep 17 00:00:00 2001 From: "Dr. Cleve" <76855369+David-Orangemoon@users.noreply.github.com> Date: Thu, 25 Sep 2025 22:16:37 -0400 Subject: [PATCH 03/16] fix spelling --- extensions/obviousAlexC/newgroundsIO.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/extensions/obviousAlexC/newgroundsIO.js b/extensions/obviousAlexC/newgroundsIO.js index 0a74cc1d92..9dc240b7a9 100644 --- a/extensions/obviousAlexC/newgroundsIO.js +++ b/extensions/obviousAlexC/newgroundsIO.js @@ -5271,7 +5271,7 @@ }); } else { if (NGIO.session && !loggedIn) return "Not logged in!"; - return "Can't get data from NewGrounds!"; + return "Can't get data from Newgrounds!"; } } From 89ad4fc5e24ca0ae6c43536555f105345b0611fa Mon Sep 17 00:00:00 2001 From: "Dr. Cleve" <76855369+David-Orangemoon@users.noreply.github.com> Date: Fri, 26 Sep 2025 22:52:24 -0400 Subject: [PATCH 04/16] Major updates --- extensions/obviousAlexC/newgroundsIO.js | 4777 +---------------------- 1 file changed, 179 insertions(+), 4598 deletions(-) diff --git a/extensions/obviousAlexC/newgroundsIO.js b/extensions/obviousAlexC/newgroundsIO.js index 9dc240b7a9..fe29f811cd 100644 --- a/extensions/obviousAlexC/newgroundsIO.js +++ b/extensions/obviousAlexC/newgroundsIO.js @@ -39,4546 +39,19 @@ //Newgrounds.io JS library taken from https://github.com/PsychoGoldfishNG/NewgroundsIO-JS/blob/main/dist/NewgroundsIO.js the official Github for Newgrounds.io //Updated to the latest + //Put this in here since there are 3 objects + let NewgroundsIO = null; + let NGIO = null; + let CryptoJS = null; // prettier-ignore - class NGIO{static get STATUS_INITIALIZED(){return"initialized"}static get STATUS_CHECKING_LOCAL_VERSION(){return"checking-local-version"}static get STATUS_LOCAL_VERSION_CHECKED(){return"local-version-checked"}static get STATUS_PRELOADING_ITEMS(){return"preloading-items"}static get STATUS_ITEMS_PRELOADED(){return"items-preloaded"}static get STATUS_READY(){return"ready"}static get STATUS_SESSION_UNINITIALIZED(){return NewgroundsIO.SessionState.SESSION_UNINITIALIZED}static get STATUS_WAITING_FOR_SERVER(){return NewgroundsIO.SessionState.WAITING_FOR_SERVER}static get STATUS_LOGIN_REQUIRED(){return NewgroundsIO.SessionState.LOGIN_REQUIRED}static get STATUS_WAITING_FOR_USER(){return NewgroundsIO.SessionState.WAITING_FOR_USER}static get STATUS_LOGIN_CANCELLED(){return NewgroundsIO.SessionState.LOGIN_CANCELLED}static get STATUS_LOGIN_SUCCESSFUL(){return NewgroundsIO.SessionState.LOGIN_SUCCESSFUL}static get STATUS_LOGIN_FAILED(){return NewgroundsIO.SessionState.LOGIN_FAILED}static get STATUS_USER_LOGGED_OUT(){return NewgroundsIO.SessionState.USER_LOGGED_OUT}static get STATUS_SERVER_UNAVAILABLE(){return NewgroundsIO.SessionState.SERVER_UNAVAILABLE}static get STATUS_EXCEEDED_MAX_ATTEMPTS(){return NewgroundsIO.SessionState.EXCEEDED_MAX_ATTEMPTS}static get isWaitingStatus(){return NewgroundsIO.SessionState.SESSION_WAITING.indexOf(this.#a)>=0||[this.STATUS_PRELOADING_ITEMS,this.LOCAL_VERSION_CHECKED,this.STATUS_CHECKING_LOCAL_VERSION].indexOf(this.#a)>=0}static get PERIOD_TODAY(){return"D"}static get PERIOD_CURRENT_WEEK(){return"W"}static get PERIOD_CURRENT_MONTH(){return"M"}static get PERIOD_CURRENT_YEAR(){return"Y"}static get PERIOD_ALL_TIME(){return"A"}static get PERIODS(){return[NGIO.PERIOD_TODAY,NGIO.PERIOD_CURRENT_WEEK,NGIO.PERIOD_CURRENT_MONTH,NGIO.PERIOD_CURRENT_YEAR,NGIO.PERIOD_ALL_TIME]}static get ngioCore(){return this.#b}static #b=null;static get medalScore(){return this.#c}static #c=-1;static get medals(){return this.#d}static #d=null;static get scoreBoards(){return this.#e}static #e=null;static get saveSlots(){return this.#f}static #f=null;static get lastExecution(){return this.#g}static #g=new Date;static get lastConnectionStatus(){return this.#a}static #a=new Date;static get sessionError(){return this.#h}static #h=null;static get legalHost(){return this.#i}static #i=!0;static get isDeprecated(){return this.#j}static #j=!0;static get newestVersion(){return this.#k}static #k=!0;static get loginPageOpen(){return this.#l}static #l=!1;static get gatewayVersion(){return this.#m}static #m=!0;static get lastMedalUnlocked(){return this.#n}static #n=!0;static get lastBoardPosted(){return this.#o}static #o=!0;static get lastScorePosted(){return this.#p}static #p=!0;static get lastGetScoresResult(){return this.#q}static #q=!0;static get lastSaveSlotLoaded(){return this.#r}static #r=!0;static get lastSaveSlotSaved(){return this.#s}static #s=!0;static get lastDateTime(){return this.#t}static #t="0000-00-00";static get lastLoggedEvent(){return this.#u}static #u=null;static get lastTimeStamp(){return this.#v}static #v=0;static get lastPingSuccess(){return this.#w}static #w=!0;static get isInitialized(){return null!==this.ngioCore}static get session(){return this.isInitialized?this.ngioCore.session:null}static get user(){return null===this.session?null:this.ngioCore.session.user}static get hasSession(){return null!==this.session}static get hasUser(){return null!==this.user}static get isReady(){return this.#a===this.STATUS_READY}static get version(){return this.#x}static #x="0.0.0";static get debugMode(){return this.#y}static #y=!1;static #z={autoLogNewView:!1,preloadMedals:!1,preloadScoreBoards:!1,preloadSaveSlots:!1};static #A=!1;static #B=!1;static #C=!1;static #D=!1;static init(e,t,s){if(!this.isInitialized){if(this.#b=new NewgroundsIO.Core(e,t),this.#b.addEventListener("serverResponse",function(e){NGIO.#E(e)}),s&&"object"==typeof s){"string"==typeof s.version&&(this.#x=s.version);let o=["debugMode","checkHostLicense","autoLogNewView","preloadMedals","preloadScoreBoards","preloadSaveSlots"];for(let r=0;r{t.hasData&&e++}),e}static getSaveSlotData(e,t,s){null===this.saveSlots&&(console.error("getSaveSlotData data called without any preloaded save slots."),s?t.call(s,null):t(null));let o=this.getSaveSlot(e);this.#r=o,o.getData(t,s)}static setSaveSlotData(e,t,s,o){if(null==this.saveSlots){console.error("setSaveSlotData data called without any preloaded save slots."),"function"==typeof s&&(o?s(o,null):s(null));return}var r=this.getSaveSlot(e);if(null==r){console.error("Slot #"+e+" does not exist."),"function"==typeof s&&(o?s(o,null):s(null));return}r.setData(t,function(){"function"==typeof s&&(o?s(o,this.lastSaveSlotSaved):s(this.lastSaveSlotSaved))},this)}static logEvent(e,t,s){this.ngioCore.executeComponent(this.ngioCore.getComponent("Event.logEvent",{event_name:e}),function(){"function"==typeof t&&(s?t(s,this.lastLoggedEvent):t(this.lastLoggedEvent))},this)}static getDateTime(e,t){this.ngioCore.executeComponent(this.ngioCore.getComponent("Gateway.getDatetime"),function(){"function"==typeof e&&(t?e(t,this.lastDateTime,this.lastTimeStamp):e(this.lastDateTime,this.lastTimeStamp))},this)}static keepSessionAlive(){if(this.hasUser)(new Date-this.#g).Seconds>=3e4&&(this.#g=new Date,this.ngioCore.executeComponent(this.ngioCore.getComponent("Gateway.ping")))}static getConnectionStatus(e,t){this.#D||null===this.#a||null==this.session||(this.#D=!0,this.#a===this.STATUS_INITIALIZED?(this.#a=this.STATUS_CHECKING_LOCAL_VERSION,this.#G(e,t),this.#H(e,t)):this.#A?this.#a===this.STATUS_LOGIN_SUCCESSFUL?(this.#a=this.STATUS_PRELOADING_ITEMS,this.#G(e,t),this.#I(function(){this.#G(e,t),this.#B=!1},this)):this.#a===this.STATUS_ITEMS_PRELOADED?(this.#l=!1,this.#a=this.STATUS_READY,this.#G(e,t),this.#B=!1):this.keepSessionAlive():this.#B?this.#J(e,t):this.#a!==this.STATUS_CHECKING_LOCAL_VERSION&&this.session.update(function(){this.#J(e,t)},this),this.#D=!1)}static #J(e,t){(this.session.statusChanged||this.#B)&&(this.#a=this.session.status,(this.session.status==NewgroundsIO.SessionState.LOGIN_SUCCESSFUL||this.#B)&&(this.#a=NewgroundsIO.SessionState.LOGIN_SUCCESSFUL,this.#A=!0),this.#G(e,t)),this.#B=!1}static #G(s,o){o?s.call(o,this.#a):s(this.#a)}static #H(r,i){if(this.#C){this.#a=this.STATUS_LOCAL_VERSION_CHECKED,this.#G(r,i);return}this.ngioCore.queueComponent(this.ngioCore.getComponent("App.getCurrentVersion",{version:this.#x})),this.ngioCore.queueComponent(this.ngioCore.getComponent("Gateway.getVersion")),this.#z.autoLogNewView&&this.ngioCore.queueComponent(this.ngioCore.getComponent("App.logView")),this.#z.checkHostLicense&&this.ngioCore.queueComponent(this.ngioCore.getComponent("App.getHostLicense")),this.ngioCore.executeQueue(function(){this.#a=this.STATUS_LOCAL_VERSION_CHECKED,this.#C=!0,this.#G(r,i),this.#j&&console.warn("NGIO - Version mistmatch! Published version is: "+this.#k+", this version is: "+this.version),this.#i||(console.warn("NGIO - This host has been blocked fom hosting this game!"),this.#A=!0,this.#a=this.STATUS_ITEMS_PRELOADED,this.#G(r,i))},this)}static #I(){this.#z.preloadMedals&&(this.ngioCore.queueComponent(this.ngioCore.getComponent("Medal.getMedalScore")),this.ngioCore.queueComponent(this.ngioCore.getComponent("Medal.getList"))),this.#z.preloadScoreBoards&&this.ngioCore.queueComponent(this.ngioCore.getComponent("ScoreBoard.getBoards")),null!==this.user&&this.#z.preloadSaveSlots&&this.ngioCore.queueComponent(this.ngioCore.getComponent("CloudSave.loadSlots")),this.ngioCore.hasQueue?this.ngioCore.executeQueue(function(){this.#a=this.STATUS_ITEMS_PRELOADED},this):this.#a=this.STATUS_ITEMS_PRELOADED}static #F(){this.#a=this.STATUS_INITIALIZED,this.#l=!1,this.#B=!1,this.#A=!1}static #K(n){if(this.#f){let a=this.#f.length;for(let u=0;u>> 2] |= - ((s[r >>> 2] >>> (24 - 8 * (r % 4))) & 255) << - (24 - 8 * ((o + r) % 4)); - else if (65535 < s.length) - for (r = 0; r < e; r += 4) t[(o + r) >>> 2] = s[r >>> 2]; - else t.push.apply(t, s); - return ((this.sigBytes += e), this); - }, - clamp: function () { - var t = this.words, - s = this.sigBytes; - ((t[s >>> 2] &= 4294967295 << (32 - 8 * (s % 4))), - (t.length = e.ceil(s / 4))); - }, - clone: function () { - var e = i.clone.call(this); - return ((e.words = this.words.slice(0)), e); - }, - random: function (t) { - for (var s = [], o = 0; o < t; o += 4) - s.push((4294967296 * e.random()) | 0); - return new n.init(s, t); - }, - })), - a = (s.enc = {}), - u = (a.Hex = { - stringify: function (e) { - var t = e.words; - e = e.sigBytes; - for (var s = [], o = 0; o < e; o++) { - var r = (t[o >>> 2] >>> (24 - 8 * (o % 4))) & 255; - (s.push((r >>> 4).toString(16)), s.push((15 & r).toString(16))); - } - return s.join(""); - }, - parse: function (e) { - for (var t = e.length, s = [], o = 0; o < t; o += 2) - s[o >>> 3] |= parseInt(e.substr(o, 2), 16) << (24 - 4 * (o % 8)); - return new n.init(s, t / 2); - }, - }), - l = (a.Latin1 = { - stringify: function (e) { - var t = e.words; - e = e.sigBytes; - for (var s = [], o = 0; o < e; o++) - s.push( - String.fromCharCode((t[o >>> 2] >>> (24 - 8 * (o % 4))) & 255) - ); - return s.join(""); - }, - parse: function (e) { - for (var t = e.length, s = [], o = 0; o < t; o++) - s[o >>> 2] |= (255 & e.charCodeAt(o)) << (24 - 8 * (o % 4)); - return new n.init(s, t); - }, - }), - p = (a.Utf8 = { - stringify: function (e) { - try { - return decodeURIComponent(escape(l.stringify(e))); - } catch (t) { - throw Error("Malformed UTF-8 data"); - } - }, - parse: function (e) { - return l.parse(unescape(encodeURIComponent(e))); - }, - }), - c = (o.BufferedBlockAlgorithm = i.extend({ - reset: function () { - ((this._data = new n.init()), (this._nDataBytes = 0)); - }, - _append: function (e) { - ("string" == typeof e && (e = p.parse(e)), - this._data.concat(e), - (this._nDataBytes += e.sigBytes)); - }, - _process: function (t) { - var s = this._data, - o = s.words, - r = s.sigBytes, - i = this.blockSize, - a = r / (4 * i), - a = t ? e.ceil(a) : e.max((0 | a) - this._minBufferSize, 0); - if (((t = a * i), (r = e.min(4 * t, r)), t)) { - for (var u = 0; u < t; u += i) this._doProcessBlock(o, u); - ((u = o.splice(0, t)), (s.sigBytes -= r)); - } - return new n.init(u, r); - }, - clone: function () { - var e = i.clone.call(this); - return ((e._data = this._data.clone()), e); - }, - _minBufferSize: 0, - })); - o.Hasher = c.extend({ - cfg: i.extend(), - init: function (e) { - ((this.cfg = this.cfg.extend(e)), this.reset()); - }, - reset: function () { - (c.reset.call(this), this._doReset()); - }, - update: function (e) { - return (this._append(e), this._process(), this); - }, - finalize: function (e) { - return (e && this._append(e), this._doFinalize()); - }, - blockSize: 16, - _createHelper: function (e) { - return function (t, s) { - return new e.init(s).finalize(t); - }; - }, - _createHmacHelper: function (e) { - return function (t, s) { - return new h.HMAC.init(e, s).finalize(t); - }; - }, - }); - var h = (s.algo = {}); - return s; - })(Math); - (!(function () { - var e = CryptoJS, - t = e.lib.WordArray; - e.enc.Base64 = { - stringify: function (e) { - var t = e.words, - s = e.sigBytes, - o = this._map; - (e.clamp(), (e = [])); - for (var r = 0; r < s; r += 3) - for ( - var i = - (((t[r >>> 2] >>> (24 - 8 * (r % 4))) & 255) << 16) | - (((t[(r + 1) >>> 2] >>> (24 - 8 * ((r + 1) % 4))) & 255) << 8) | - ((t[(r + 2) >>> 2] >>> (24 - 8 * ((r + 2) % 4))) & 255), - n = 0; - 4 > n && r + 0.75 * n < s; - n++ - ) - e.push(o.charAt((i >>> (6 * (3 - n))) & 63)); - if ((t = o.charAt(64))) for (; e.length % 4; ) e.push(t); - return e.join(""); - }, - parse: function (e) { - var s = e.length, - o = this._map, - r = o.charAt(64); - r && -1 != (r = e.indexOf(r)) && (s = r); - for (var r = [], i = 0, n = 0; n < s; n++) - if (n % 4) { - var a = o.indexOf(e.charAt(n - 1)) << (2 * (n % 4)), - u = o.indexOf(e.charAt(n)) >>> (6 - 2 * (n % 4)); - ((r[i >>> 2] |= (a | u) << (24 - 8 * (i % 4))), i++); - } - return t.create(r, i); - }, - _map: "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=", - }; - })(), - (function (e) { - function t(e, t, s, o, r, i, n) { - return ( - (((e = e + ((t & s) | (~t & o)) + r + n) << i) | (e >>> (32 - i))) + t - ); - } - function s(e, t, s, o, r, i, n) { - return ( - (((e = e + ((t & o) | (s & ~o)) + r + n) << i) | (e >>> (32 - i))) + t - ); - } - function o(e, t, s, o, r, i, n) { - return (((e = e + (t ^ s ^ o) + r + n) << i) | (e >>> (32 - i))) + t; - } - function r(e, t, s, o, r, i, n) { - return (((e = e + (s ^ (t | ~o)) + r + n) << i) | (e >>> (32 - i))) + t; - } - for ( - var i = CryptoJS, - n = i.lib, - a = n.WordArray, - u = n.Hasher, - n = i.algo, - l = [], - p = 0; - 64 > p; - p++ - ) - l[p] = (4294967296 * e.abs(e.sin(p + 1))) | 0; - ((n = n.MD5 = - u.extend({ - _doReset: function () { - this._hash = new a.init([ - 1732584193, 4023233417, 2562383102, 271733878, - ]); - }, - _doProcessBlock: function (e, i) { - for (var n = 0; 16 > n; n++) { - var a = i + n, - u = e[a]; - e[a] = - (((u << 8) | (u >>> 24)) & 16711935) | - (((u << 24) | (u >>> 8)) & 4278255360); - } - var n = this._hash.words, - a = e[i + 0], - u = e[i + 1], - p = e[i + 2], - c = e[i + 3], - h = e[i + 4], - d = e[i + 5], - g = e[i + 6], - f = e[i + 7], - w = e[i + 8], - O = e[i + 9], - I = e[i + 10], - m = e[i + 11], - S = e[i + 12], - N = e[i + 13], - b = e[i + 14], - y = e[i + 15], - v = n[0], - $ = n[1], - C = n[2], - E = n[3], - v = t(v, $, C, E, a, 7, l[0]), - E = t(E, v, $, C, u, 12, l[1]), - C = t(C, E, v, $, p, 17, l[2]), - $ = t($, C, E, v, c, 22, l[3]), - v = t(v, $, C, E, h, 7, l[4]), - E = t(E, v, $, C, d, 12, l[5]), - C = t(C, E, v, $, g, 17, l[6]), - $ = t($, C, E, v, f, 22, l[7]), - v = t(v, $, C, E, w, 7, l[8]), - E = t(E, v, $, C, O, 12, l[9]), - C = t(C, E, v, $, I, 17, l[10]), - $ = t($, C, E, v, m, 22, l[11]), - v = t(v, $, C, E, S, 7, l[12]), - E = t(E, v, $, C, N, 12, l[13]), - C = t(C, E, v, $, b, 17, l[14]), - $ = t($, C, E, v, y, 22, l[15]), - v = s(v, $, C, E, u, 5, l[16]), - E = s(E, v, $, C, g, 9, l[17]), - C = s(C, E, v, $, m, 14, l[18]), - $ = s($, C, E, v, a, 20, l[19]), - v = s(v, $, C, E, d, 5, l[20]), - E = s(E, v, $, C, I, 9, l[21]), - C = s(C, E, v, $, y, 14, l[22]), - $ = s($, C, E, v, h, 20, l[23]), - v = s(v, $, C, E, O, 5, l[24]), - E = s(E, v, $, C, b, 9, l[25]), - C = s(C, E, v, $, c, 14, l[26]), - $ = s($, C, E, v, w, 20, l[27]), - v = s(v, $, C, E, N, 5, l[28]), - E = s(E, v, $, C, p, 9, l[29]), - C = s(C, E, v, $, f, 14, l[30]), - $ = s($, C, E, v, S, 20, l[31]), - v = o(v, $, C, E, d, 4, l[32]), - E = o(E, v, $, C, w, 11, l[33]), - C = o(C, E, v, $, m, 16, l[34]), - $ = o($, C, E, v, b, 23, l[35]), - v = o(v, $, C, E, u, 4, l[36]), - E = o(E, v, $, C, h, 11, l[37]), - C = o(C, E, v, $, f, 16, l[38]), - $ = o($, C, E, v, I, 23, l[39]), - v = o(v, $, C, E, N, 4, l[40]), - E = o(E, v, $, C, a, 11, l[41]), - C = o(C, E, v, $, c, 16, l[42]), - $ = o($, C, E, v, g, 23, l[43]), - v = o(v, $, C, E, O, 4, l[44]), - E = o(E, v, $, C, S, 11, l[45]), - C = o(C, E, v, $, y, 16, l[46]), - $ = o($, C, E, v, p, 23, l[47]), - v = r(v, $, C, E, a, 6, l[48]), - E = r(E, v, $, C, f, 10, l[49]), - C = r(C, E, v, $, b, 15, l[50]), - $ = r($, C, E, v, d, 21, l[51]), - v = r(v, $, C, E, S, 6, l[52]), - E = r(E, v, $, C, c, 10, l[53]), - C = r(C, E, v, $, I, 15, l[54]), - $ = r($, C, E, v, u, 21, l[55]), - v = r(v, $, C, E, w, 6, l[56]), - E = r(E, v, $, C, y, 10, l[57]), - C = r(C, E, v, $, g, 15, l[58]), - $ = r($, C, E, v, N, 21, l[59]), - v = r(v, $, C, E, h, 6, l[60]), - E = r(E, v, $, C, m, 10, l[61]), - C = r(C, E, v, $, p, 15, l[62]), - $ = r($, C, E, v, O, 21, l[63]); - ((n[0] = (n[0] + v) | 0), - (n[1] = (n[1] + $) | 0), - (n[2] = (n[2] + C) | 0), - (n[3] = (n[3] + E) | 0)); - }, - _doFinalize: function () { - var t = this._data, - s = t.words, - o = 8 * this._nDataBytes, - r = 8 * t.sigBytes; - s[r >>> 5] |= 128 << (24 - (r % 32)); - var i = e.floor(o / 4294967296); - for ( - s[(((r + 64) >>> 9) << 4) + 15] = - (((i << 8) | (i >>> 24)) & 16711935) | - (((i << 24) | (i >>> 8)) & 4278255360), - s[(((r + 64) >>> 9) << 4) + 14] = - (((o << 8) | (o >>> 24)) & 16711935) | - (((o << 24) | (o >>> 8)) & 4278255360), - t.sigBytes = 4 * (s.length + 1), - this._process(), - s = (t = this._hash).words, - o = 0; - 4 > o; - o++ - ) - ((r = s[o]), - (s[o] = - (((r << 8) | (r >>> 24)) & 16711935) | - (((r << 24) | (r >>> 8)) & 4278255360))); - return t; - }, - clone: function () { - var e = u.clone.call(this); - return ((e._hash = this._hash.clone()), e); - }, - })), - (i.MD5 = u._createHelper(n)), - (i.HmacMD5 = u._createHmacHelper(n))); - })(Math), - (function () { - var e = CryptoJS, - t = e.lib, - s = t.Base, - o = t.WordArray, - t = e.algo, - r = (t.EvpKDF = s.extend({ - cfg: s.extend({ keySize: 4, hasher: t.MD5, iterations: 1 }), - init: function (e) { - this.cfg = this.cfg.extend(e); - }, - compute: function (e, t) { - for ( - var s = this.cfg, - r = s.hasher.create(), - i = o.create(), - n = i.words, - a = s.keySize, - s = s.iterations; - n.length < a; - - ) { - u && r.update(u); - var u = r.update(e).finalize(t); - r.reset(); - for (var l = 1; l < s; l++) ((u = r.finalize(u)), r.reset()); - i.concat(u); - } - return ((i.sigBytes = 4 * a), i); - }, - })); - e.EvpKDF = function (e, t, s) { - return r.create(s).compute(e, t); - }; - })(), - CryptoJS.lib.Cipher || - (function (e) { - var t = CryptoJS, - s = t.lib, - o = s.Base, - r = s.WordArray, - i = s.BufferedBlockAlgorithm, - n = t.enc.Base64, - a = t.algo.EvpKDF, - u = (s.Cipher = i.extend({ - cfg: o.extend(), - createEncryptor: function (e, t) { - return this.create(this._ENC_XFORM_MODE, e, t); - }, - createDecryptor: function (e, t) { - return this.create(this._DEC_XFORM_MODE, e, t); - }, - init: function (e, t, s) { - ((this.cfg = this.cfg.extend(s)), - (this._xformMode = e), - (this._key = t), - this.reset()); - }, - reset: function () { - (i.reset.call(this), this._doReset()); - }, - process: function (e) { - return (this._append(e), this._process()); - }, - finalize: function (e) { - return (e && this._append(e), this._doFinalize()); - }, - keySize: 4, - ivSize: 4, - _ENC_XFORM_MODE: 1, - _DEC_XFORM_MODE: 2, - _createHelper: function (e) { - return { - encrypt: function (t, s, o) { - return ("string" == typeof s ? g : d).encrypt(e, t, s, o); - }, - decrypt: function (t, s, o) { - return ("string" == typeof s ? g : d).decrypt(e, t, s, o); - }, - }; - }, - })); - s.StreamCipher = u.extend({ - _doFinalize: function () { - return this._process(!0); - }, - blockSize: 1, - }); - var l = (t.mode = {}), - p = function (e, t, s) { - var o = this._iv; - o ? (this._iv = void 0) : (o = this._prevBlock); - for (var r = 0; r < s; r++) e[t + r] ^= o[r]; - }, - c = (s.BlockCipherMode = o.extend({ - createEncryptor: function (e, t) { - return this.Encryptor.create(e, t); - }, - createDecryptor: function (e, t) { - return this.Decryptor.create(e, t); - }, - init: function (e, t) { - ((this._cipher = e), (this._iv = t)); - }, - })).extend(); - ((c.Encryptor = c.extend({ - processBlock: function (e, t) { - var s = this._cipher, - o = s.blockSize; - (p.call(this, e, t, o), - s.encryptBlock(e, t), - (this._prevBlock = e.slice(t, t + o))); - }, - })), - (c.Decryptor = c.extend({ - processBlock: function (e, t) { - var s = this._cipher, - o = s.blockSize, - r = e.slice(t, t + o); - (s.decryptBlock(e, t), - p.call(this, e, t, o), - (this._prevBlock = r)); - }, - })), - (l = l.CBC = c), - (c = (t.pad = {}).Pkcs7 = - { - pad: function (e, t) { - for ( - var s = 4 * t, - s = s - (e.sigBytes % s), - o = (s << 24) | (s << 16) | (s << 8) | s, - i = [], - n = 0; - n < s; - n += 4 - ) - i.push(o); - ((s = r.create(i, s)), e.concat(s)); - }, - unpad: function (e) { - e.sigBytes -= 255 & e.words[(e.sigBytes - 1) >>> 2]; - }, - }), - (s.BlockCipher = u.extend({ - cfg: u.cfg.extend({ mode: l, padding: c }), - reset: function () { - u.reset.call(this); - var e = this.cfg, - t = e.iv, - e = e.mode; - if (this._xformMode == this._ENC_XFORM_MODE) - var s = e.createEncryptor; - else ((s = e.createDecryptor), (this._minBufferSize = 1)); - this._mode = s.call(e, this, t && t.words); - }, - _doProcessBlock: function (e, t) { - this._mode.processBlock(e, t); - }, - _doFinalize: function () { - var e = this.cfg.padding; - if (this._xformMode == this._ENC_XFORM_MODE) { - e.pad(this._data, this.blockSize); - var t = this._process(!0); - } else ((t = this._process(!0)), e.unpad(t)); - return t; - }, - blockSize: 4, - }))); - var h = (s.CipherParams = o.extend({ - init: function (e) { - this.mixIn(e); - }, - toString: function (e) { - return (e || this.formatter).stringify(this); - }, - })), - l = ((t.format = {}).OpenSSL = { - stringify: function (e) { - var t = e.ciphertext; - return ( - (e = e.salt) - ? r.create([1398893684, 1701076831]).concat(e).concat(t) - : t - ).toString(n); - }, - parse: function (e) { - var t = (e = n.parse(e)).words; - if (1398893684 == t[0] && 1701076831 == t[1]) { - var s = r.create(t.slice(2, 4)); - (t.splice(0, 4), (e.sigBytes -= 16)); - } - return h.create({ ciphertext: e, salt: s }); - }, - }), - d = (s.SerializableCipher = o.extend({ - cfg: o.extend({ format: l }), - encrypt: function (e, t, s, o) { - o = this.cfg.extend(o); - var r = e.createEncryptor(s, o); - return ( - (t = r.finalize(t)), - (r = r.cfg), - h.create({ - ciphertext: t, - key: s, - iv: r.iv, - algorithm: e, - mode: r.mode, - padding: r.padding, - blockSize: e.blockSize, - formatter: o.format, - }) - ); - }, - decrypt: function (e, t, s, o) { - return ( - (o = this.cfg.extend(o)), - (t = this._parse(t, o.format)), - e.createDecryptor(s, o).finalize(t.ciphertext) - ); - }, - _parse: function (e, t) { - return "string" == typeof e ? t.parse(e, this) : e; - }, - })), - t = ((t.kdf = {}).OpenSSL = { - execute: function (e, t, s, o) { - return ( - o || (o = r.random(8)), - (e = a.create({ keySize: t + s }).compute(e, o)), - (s = r.create(e.words.slice(t), 4 * s)), - (e.sigBytes = 4 * t), - h.create({ key: e, iv: s, salt: o }) - ); - }, - }), - g = (s.PasswordBasedCipher = d.extend({ - cfg: d.cfg.extend({ kdf: t }), - encrypt: function (e, t, s, o) { - return ( - (s = (o = this.cfg.extend(o)).kdf.execute( - s, - e.keySize, - e.ivSize - )), - (o.iv = s.iv), - (e = d.encrypt.call(this, e, t, s.key, o)).mixIn(s), - e - ); - }, - decrypt: function (e, t, s, o) { - return ( - (o = this.cfg.extend(o)), - (t = this._parse(t, o.format)), - (s = o.kdf.execute(s, e.keySize, e.ivSize, t.salt)), - (o.iv = s.iv), - d.decrypt.call(this, e, t, s.key, o) - ); - }, - })); - })(), - (function () { - for ( - var e = CryptoJS, - t = e.lib.BlockCipher, - s = e.algo, - o = [], - r = [], - i = [], - n = [], - a = [], - u = [], - l = [], - p = [], - c = [], - h = [], - d = [], - g = 0; - 256 > g; - g++ - ) - d[g] = 128 > g ? g << 1 : (g << 1) ^ 283; - for (var f = 0, w = 0, g = 0; 256 > g; g++) { - var O = w ^ (w << 1) ^ (w << 2) ^ (w << 3) ^ (w << 4), - O = (O >>> 8) ^ (255 & O) ^ 99; - ((o[f] = O), (r[O] = f)); - var I = d[f], - m = d[I], - S = d[m], - N = (257 * d[O]) ^ (16843008 * O); - ((i[f] = (N << 24) | (N >>> 8)), - (n[f] = (N << 16) | (N >>> 16)), - (a[f] = (N << 8) | (N >>> 24)), - (u[f] = N), - (N = (16843009 * S) ^ (65537 * m) ^ (257 * I) ^ (16843008 * f)), - (l[O] = (N << 24) | (N >>> 8)), - (p[O] = (N << 16) | (N >>> 16)), - (c[O] = (N << 8) | (N >>> 24)), - (h[O] = N), - f ? ((f = I ^ d[d[d[S ^ I]]]), (w ^= d[d[w]])) : (f = w = 1)); - } - var b = [0, 1, 2, 4, 8, 16, 32, 64, 128, 27, 54], - s = (s.AES = t.extend({ - _doReset: function () { - for ( - var e = this._key, - t = e.words, - s = e.sigBytes / 4, - e = 4 * ((this._nRounds = s + 6) + 1), - r = (this._keySchedule = []), - i = 0; - i < e; - i++ - ) - if (i < s) r[i] = t[i]; - else { - var n = r[i - 1]; - (i % s - ? 6 < s && - 4 == i % s && - (n = - (o[n >>> 24] << 24) | - (o[(n >>> 16) & 255] << 16) | - (o[(n >>> 8) & 255] << 8) | - o[255 & n]) - : ((n = - (o[(n = (n << 8) | (n >>> 24)) >>> 24] << 24) | - (o[(n >>> 16) & 255] << 16) | - (o[(n >>> 8) & 255] << 8) | - o[255 & n]), - (n ^= b[(i / s) | 0] << 24)), - (r[i] = r[i - s] ^ n)); - } - for (s = 0, t = this._invKeySchedule = []; s < e; s++) - ((i = e - s), - (n = s % 4 ? r[i] : r[i - 4]), - (t[s] = - 4 > s || 4 >= i - ? n - : l[o[n >>> 24]] ^ - p[o[(n >>> 16) & 255]] ^ - c[o[(n >>> 8) & 255]] ^ - h[o[255 & n]])); - }, - encryptBlock: function (e, t) { - this._doCryptBlock(e, t, this._keySchedule, i, n, a, u, o); - }, - decryptBlock: function (e, t) { - var s = e[t + 1]; - ((e[t + 1] = e[t + 3]), - (e[t + 3] = s), - this._doCryptBlock(e, t, this._invKeySchedule, l, p, c, h, r), - (s = e[t + 1]), - (e[t + 1] = e[t + 3]), - (e[t + 3] = s)); - }, - _doCryptBlock: function (e, t, s, o, r, i, n, a) { - for ( - var u = this._nRounds, - l = e[t] ^ s[0], - p = e[t + 1] ^ s[1], - c = e[t + 2] ^ s[2], - h = e[t + 3] ^ s[3], - d = 4, - g = 1; - g < u; - g++ - ) - var f = - o[l >>> 24] ^ - r[(p >>> 16) & 255] ^ - i[(c >>> 8) & 255] ^ - n[255 & h] ^ - s[d++], - w = - o[p >>> 24] ^ - r[(c >>> 16) & 255] ^ - i[(h >>> 8) & 255] ^ - n[255 & l] ^ - s[d++], - O = - o[c >>> 24] ^ - r[(h >>> 16) & 255] ^ - i[(l >>> 8) & 255] ^ - n[255 & p] ^ - s[d++], - h = - o[h >>> 24] ^ - r[(l >>> 16) & 255] ^ - i[(p >>> 8) & 255] ^ - n[255 & c] ^ - s[d++], - l = f, - p = w, - c = O; - ((f = - ((a[l >>> 24] << 24) | - (a[(p >>> 16) & 255] << 16) | - (a[(c >>> 8) & 255] << 8) | - a[255 & h]) ^ - s[d++]), - (w = - ((a[p >>> 24] << 24) | - (a[(c >>> 16) & 255] << 16) | - (a[(h >>> 8) & 255] << 8) | - a[255 & l]) ^ - s[d++]), - (O = - ((a[c >>> 24] << 24) | - (a[(h >>> 16) & 255] << 16) | - (a[(l >>> 8) & 255] << 8) | - a[255 & p]) ^ - s[d++]), - (h = - ((a[h >>> 24] << 24) | - (a[(l >>> 16) & 255] << 16) | - (a[(p >>> 8) & 255] << 8) | - a[255 & c]) ^ - s[d++]), - (e[t] = f), - (e[t + 1] = w), - (e[t + 2] = O), - (e[t + 3] = h)); - }, - keySize: 8, - })); - e.AES = t._createHelper(s); - })()); - var NewgroundsIO = NewgroundsIO || {}; - ((NewgroundsIO.objects = NewgroundsIO.objects ? NewgroundsIO.objects : {}), - (NewgroundsIO.results = NewgroundsIO.results ? NewgroundsIO.results : {}), - (NewgroundsIO.components = NewgroundsIO.components - ? NewgroundsIO.components - : {}), - (() => { - class e extends EventTarget { - #O = "https://www.newgrounds.io/gateway_v3.php"; - #P = !1; - #Q = null; - #R = null; - #S = []; - #T = null; - #U = null; - #V = {}; - get GATEWAY_URI() { - return this.#O; - } - get debug() { - return this.#P; - } - set debug(e) { - this.#P = !!e; - } - get appID() { - return this.#Q; - } - get componentQueue() { - return this.#S; - } - get hasQueue() { - return this.#S.length > 0; - } - get host() { - return this.#T; - } - get session() { - return this.#U; - } - get user() { - return this.#U ? this.#U.user : null; - } - get uriParams() { - return this.#V; - } - constructor(e, t) { - if ((super(), void 0 === e)) throw "Missing required appID!"; - if (void 0 === t) throw "Missing required aesKey!"; - if ( - ((this.#Q = e), - (this.#R = CryptoJS.enc.Base64.parse(t)), - (this.#S = []), - (this.#V = {}), - window && window.location && window.location.href - ? window.location.hostname - ? (this.#T = window.location.hostname.toLowerCase()) - : "file:" == window.location.href.toLowerCase().substr(0, 5) - ? (this.#T = "") - : (this.#T = "") - : (this.#T = ""), - "undefined" != typeof window && window.location) - ) { - var s, - o = window.location.href.split("?").pop(); - if (o) - for (var r, i = o.split("&"), n = 0; n < i.length; n++) - ((r = i[n].split("=")), (this.#V[r[0]] = r[1])); - } - ((this.#U = this.getObject("Session")), - (this.#U.uri_id = this.getUriParam("ngio_session_id", null))); - } - getUriParam(e, t) { - return void 0 === this.#V[e] ? t : this.#V[e]; - } - encrypt(e) { - let t = CryptoJS.lib.WordArray.random(16), - s = CryptoJS.AES.encrypt(e, this.#R, { iv: t }); - return CryptoJS.enc.Base64.stringify(t.concat(s.ciphertext)); - } - getObject(e, t) { - if (void 0 === NewgroundsIO.objects[e]) - return ( - console.error("NewgroundsIO - Invalid object name: " + e), - null - ); - var s = new NewgroundsIO.objects[e](t); - return (s.setCore(this), s); - } - getComponent(e, t) { - var s = e.split("."), - o = !1; - if ( - (2 !== s.length - ? (o = "Invalid component name: " + e) - : void 0 === NewgroundsIO.components[s[0]] - ? (o = "Invalid component name: " + e) - : void 0 === NewgroundsIO.components[s[0]][s[1]] && - (o = "Invalid component name: " + e), - o) - ) - return (console.error("NewgroundsIO - " + o), null); - var r = new NewgroundsIO.components[s[0]][s[1]](t); - return (r.setCore(this), r); - } - queueComponent(e) { - this._verifyComponent(e) && (e.setCore(this), this.#S.push(e)); - } - executeQueue(e, t) { - this.#S.length < 1 || - (this.executeComponent(this.#S, e, t), (this.#S = [])); - } - executeComponent(e, t, s) { - if (Array.isArray(e)) { - let o = !0, - r = this; - if ( - (e.forEach((t) => { - t instanceof NewgroundsIO.BaseComponent || - (r._verifyComponent(e) || (o = !1), t.setCore(r)); - }), - !o) - ) - return; - } else { - if (!this._verifyComponent(e)) return; - e.setCore(this); - } - let i = this, - n = this._getRequest(e); - new NewgroundsIO.objects.Response(); - var a = new XMLHttpRequest(); - a.onreadystatechange = function () { - if (4 == a.readyState) { - var e; - try { - e = JSON.parse(a.responseText); - } catch (o) { - (e = { success: !1, app_id: i.app_id }).error = { - message: String(o), - code: 8002, - }; - } - let r = i._populateResponse(e); - (i.dispatchEvent( - new CustomEvent("serverResponse", { detail: r }) - ), - t && (s ? t.call(s, r) : t(r))); - } - }; - var u = - void 0 !== Array.prototype.toJSON ? Array.prototype.toJSON : null; - u && delete Array.prototype.toJSON; - let l = new FormData(); - (l.append("request", JSON.stringify(n)), - u && (Array.prototype.toJSON = u), - a.open("POST", this.GATEWAY_URI, !0), - a.send(l)); - } - loadComponent(e) { - if (!this._verifyComponent(e)) return; - e.setCore(this); - let t = this._getRequest(e), - s = - this.GATEWAY_URI + - "?request=" + - encodeURIComponent(JSON.stringify(t)); - window.open(s, "_blank"); - } - onServerResponse(e) {} - _populateResponse(e) { - if (e.success) { - if (Array.isArray(e.result)) - for (let t = 0; t < e.result.length; t++) - e.result[t] = this._populateResult(e.result[t]); - else e.result = this._populateResult(e.result); - } else - (e.result && delete e.result, - e.error && (e.error = new NewgroundsIO.objects.Error(e.error))); - return ((e = new NewgroundsIO.objects.Response(e)).setCore(this), e); - } - _populateResult(e) { - let t = e.component.split("."), - s = NewgroundsIO.results[t[0]][t[1]]; - if (!s) return null; - e.data.component = e.component; - let o = new s(); - return (o.fromJSON(e.data, this), o); - } - _getExecute(e) { - var t = new NewgroundsIO.objects.Execute(); - return (t.setComponent(e), t.setCore(this), t); - } - _getRequest(e) { - let t, - s = this; - Array.isArray(e) - ? ((t = []), - e.forEach((e) => { - let o = s._getExecute(e); - t.push(o); - })) - : (t = this._getExecute(e)); - let o = new NewgroundsIO.objects.Request({ execute: t }); - return (this.debug && (o.debug = !0), o.setCore(this), o); - } - _verifyComponent(e) { - return e instanceof NewgroundsIO.BaseComponent - ? !!e.isValid() - : (console.error( - "NewgroundsIO Type Mismatch: Expecting a NewgroundsIO.components.XXXX instance, got", - e - ), - !1); - } - } - NewgroundsIO.Core = e; - })(), - (() => { - class e { - get type() { - return this.__type; - } - __type = "object"; - __object = "BaseObject"; - __properties = []; - __required = []; - __ngioCore = null; - isValid() { - if (0 === this.__required.length) return !0; - let e = !0; - return ( - this.__required.forEach(function (t) { - null === this[t] - ? (console.error( - "NewgroundsIO Error: " + - this.__object + - " " + - this.__type + - " is invalid, missing value for '" + - t + - "'" - ), - (e = !1)) - : this[t] instanceof NewgroundsIO.BaseObject && - !this[t].isValid() && - (e = !1); - }, this), - e - ); - } - setCore(e) { - this._doSetCore(e, []); - } - objectMap = {}; - arrayMap = {}; - fromJSON(e, t) { - var s, - o, - r = {}; - for (this.setCore(t), s = 0; s < this.__properties.length; s++) { - let i = this.__properties[s]; - if (void 0 !== e[i] && null !== e[i]) { - if ( - ((r[i] = e[i]), - void 0 !== this.arrayMap[i] && Array.isArray(r[i])) - ) - for (o = 0, r[i] = []; o < e[i].length; o++) { - let n = NewgroundsIO.objects[this.arrayMap[i]]; - ((r[i][o] = new n()), r[i][o].fromJSON(e[i][o], t)); - } - else if (void 0 !== this.objectMap[i]) { - let a = NewgroundsIO.objects[this.objectMap[i]]; - ((r[i] = new a()), r[i].fromJSON(e[i], t)); - } - this[i] = r[i]; - } - } - } - _doSetCore(e, t) { - (Array.isArray(t) || (t = []), - e instanceof NewgroundsIO.Core - ? ((this.__ngioCore = e), - t.push(this), - this.__properties.forEach(function (s) { - (this[s] instanceof NewgroundsIO.BaseObject && - -1 === t.indexOf(this[s]) - ? this[s]._doSetCore(e, t) - : Array.isArray(this[s]) && - this[s].forEach((s) => { - s instanceof NewgroundsIO.BaseObject && - -1 === t.indexOf(s) && - s._doSetCore(e, t); - }, this), - "host" !== s || this.host || (this.host = e.host)); - }, this)) - : console.error( - "NewgroundsIO Error: Expecting NewgroundsIO.Core instance, got", - e - )); - } - toJSON() { - return this.__doToJSON(); - } - __doToJSON() { - if (void 0 === this.__properties) return {}; - let e = {}; - return ( - this.__properties.forEach(function (t) { - null !== this[t] && - (e[t] = - "function" == typeof this[t].toJSON - ? this[t].toJSON() - : this[t]); - }, this), - e - ); - } - toSecureJSON() { - return this.__ngioCore && this.__ngioCore instanceof NewgroundsIO.Core - ? { - secure: this.__ngioCore.encrypt( - JSON.stringify(this.__doToJSON()) - ), - } - : (console.error( - "NewgroundsIO Error: Unable to create secure JSON object without calling setCore() first." - ), - this.__doToJSON()); - } - toString() { - return this.__type; - } - clone(e) { - return ( - void 0 === e && (e = new this.constructor()), - this.__properties.forEach((t) => { - e[t] = this[t]; - }), - (e.__ngioCore = this.__ngioCore), - e - ); - } - } - NewgroundsIO.BaseObject = e; - class t extends e { - constructor() { - (super(), - (this.__type = "component"), - (this.__object = "BaseComponent"), - (this.__properties = ["host", "echo"]), - (this._echo = null)); - } - get host() { - return this.__ngioCore ? this.__ngioCore.host : null; - } - get echo() { - return this._echo; - } - set echo(e) { - this.echo = "" + e; - } - } - NewgroundsIO.BaseComponent = t; - class s extends e { - constructor() { - (super(), - (this.__type = "result"), - (this.__object = "BaseResult"), - (this.__properties = ["echo", "error", "success"]), - (this._echo = null), - (this._error = null), - (this._success = null)); - } - get component() { - return this.__object; - } - get echo() { - return this._echo; - } - get error() { - return this._error; - } - set error(e) { - this._error = e; - } - get success() { - return !!this._success; - } - set success(e) { - this._success = !!e; - } - } - NewgroundsIO.BaseResult = s; - })(), - (NewgroundsIO.SessionState = { - SESSION_UNINITIALIZED: "session-uninitialized", - WAITING_FOR_SERVER: "waiting-for-server", - LOGIN_REQUIRED: "login-required", - WAITING_FOR_USER: "waiting-for-user", - LOGIN_CANCELLED: "login-cancelled", - LOGIN_SUCCESSFUL: "login-successful", - LOGIN_FAILED: "login-failed", - USER_LOGGED_OUT: "user-logged-out", - SERVER_UNAVAILABLE: "server-unavailable", - EXCEEDED_MAX_ATTEMPTS: "exceeded-max-attempts", - }), - (NewgroundsIO.SessionState.SESSION_WAITING = [ - NewgroundsIO.SessionState.SESSION_UNINITIALIZED, - NewgroundsIO.SessionState.WAITING_FOR_SERVER, - NewgroundsIO.SessionState.WAITING_FOR_USER, - NewgroundsIO.SessionState.LOGIN_CANCELLED, - NewgroundsIO.SessionStateLOGIN_FAILED, - ]), - (() => { - class e extends NewgroundsIO.BaseComponent { - constructor() { - (super(), - (this.__object = "App.checkSession"), - (this.__requireSession = !0)); - } - } - (void 0 === NewgroundsIO.components.App && - (NewgroundsIO.components.App = {}), - (NewgroundsIO.components.App.checkSession = e)); - })(), - (() => { - class e extends NewgroundsIO.BaseComponent { - constructor() { - (super(), - (this.__object = "App.endSession"), - (this.__requireSession = !0)); - } - } - (void 0 === NewgroundsIO.components.App && - (NewgroundsIO.components.App = {}), - (NewgroundsIO.components.App.endSession = e)); - })(), - (() => { - class e extends NewgroundsIO.BaseComponent { - constructor(e) { - super(); - let t = this; - if ( - ((this.__object = "App.getCurrentVersion"), - ["version"].forEach((e) => { - 0 > t.__properties.indexOf(e) && t.__properties.push(e); - }), - e && "object" == typeof e) - ) - for (var s = 0; s < this.__properties.length; s++) - void 0 !== e[this.__properties[s]] && - (this[this.__properties[s]] = e[this.__properties[s]]); - } - #x = null; - get version() { - return this.#x; - } - set version(e) { - ("string" != typeof e && - null !== e && - console.warn( - "NewgroundsIO Type Mismatch: Value should be a string, got", - e - ), - (this.#x = String(e))); - } - } - (void 0 === NewgroundsIO.components.App && - (NewgroundsIO.components.App = {}), - (NewgroundsIO.components.App.getCurrentVersion = e)); - })(), - (() => { - class e extends NewgroundsIO.BaseComponent { - constructor(e) { - super(); - let t = this; - if ( - ((this.__object = "App.getHostLicense"), - ["host"].forEach((e) => { - 0 > t.__properties.indexOf(e) && t.__properties.push(e); - }), - e && "object" == typeof e) - ) - for (var s = 0; s < this.__properties.length; s++) - void 0 !== e[this.__properties[s]] && - (this[this.__properties[s]] = e[this.__properties[s]]); - } - } - (void 0 === NewgroundsIO.components.App && - (NewgroundsIO.components.App = {}), - (NewgroundsIO.components.App.getHostLicense = e)); - })(), - (() => { - class e extends NewgroundsIO.BaseComponent { - constructor(e) { - super(); - let t = this; - if ( - ((this.__object = "App.logView"), - ["host"].forEach((e) => { - 0 > t.__properties.indexOf(e) && t.__properties.push(e); - }), - e && "object" == typeof e) - ) - for (var s = 0; s < this.__properties.length; s++) - void 0 !== e[this.__properties[s]] && - (this[this.__properties[s]] = e[this.__properties[s]]); - } - } - (void 0 === NewgroundsIO.components.App && - (NewgroundsIO.components.App = {}), - (NewgroundsIO.components.App.logView = e)); - })(), - (() => { - class e extends NewgroundsIO.BaseComponent { - constructor(e) { - super(); - let t = this; - if ( - ((this.__object = "App.startSession"), - ["force"].forEach((e) => { - 0 > t.__properties.indexOf(e) && t.__properties.push(e); - }), - e && "object" == typeof e) - ) - for (var s = 0; s < this.__properties.length; s++) - void 0 !== e[this.__properties[s]] && - (this[this.__properties[s]] = e[this.__properties[s]]); - } - #W = null; - get force() { - return this.#W; - } - set force(e) { - ("boolean" != typeof e && - "number" != typeof e && - null !== e && - console.warn( - "NewgroundsIO Type Mismatch: Value should be a boolean, got", - e - ), - (this.#W = !!e)); - } - } - (void 0 === NewgroundsIO.components.App && - (NewgroundsIO.components.App = {}), - (NewgroundsIO.components.App.startSession = e)); - })(), - (() => { - class e extends NewgroundsIO.BaseComponent { - constructor(e) { - super(); - let t = this; - if ( - ((this.__object = "CloudSave.clearSlot"), - (this.__requireSession = !0), - ["id"].forEach((e) => { - 0 > t.__properties.indexOf(e) && t.__properties.push(e); - }), - e && "object" == typeof e) - ) - for (var s = 0; s < this.__properties.length; s++) - void 0 !== e[this.__properties[s]] && - (this[this.__properties[s]] = e[this.__properties[s]]); - } - #X = null; - get id() { - return this.#X; - } - set id(e) { - ("number" != typeof e && null !== e - ? console.warn( - "NewgroundsIO Type Mismatch: Value should be a number, got", - e - ) - : Number.isInteger(e) || - null === e || - console.warn( - "NewgroundsIO Type Mismatch: Value should be an integer, got a float" - ), - (this.#X = Number(e)), - isNaN(this.#X) && (this.#X = null)); - } - } - (void 0 === NewgroundsIO.components.CloudSave && - (NewgroundsIO.components.CloudSave = {}), - (NewgroundsIO.components.CloudSave.clearSlot = e)); - })(), - (() => { - class e extends NewgroundsIO.BaseComponent { - constructor(e) { - super(); - let t = this; - if ( - ((this.__object = "CloudSave.loadSlot"), - (this.__requireSession = !0), - ["id", "app_id"].forEach((e) => { - 0 > t.__properties.indexOf(e) && t.__properties.push(e); - }), - e && "object" == typeof e) - ) - for (var s = 0; s < this.__properties.length; s++) - void 0 !== e[this.__properties[s]] && - (this[this.__properties[s]] = e[this.__properties[s]]); - } - #X = null; - get id() { - return this.#X; - } - set id(e) { - ("number" != typeof e && null !== e - ? console.warn( - "NewgroundsIO Type Mismatch: Value should be a number, got", - e - ) - : Number.isInteger(e) || - null === e || - console.warn( - "NewgroundsIO Type Mismatch: Value should be an integer, got a float" - ), - (this.#X = Number(e)), - isNaN(this.#X) && (this.#X = null)); - } - #Y = null; - get app_id() { - return this.#Y; - } - set app_id(e) { - ("string" != typeof e && - null !== e && - console.warn( - "NewgroundsIO Type Mismatch: Value should be a string, got", - e - ), - (this.#Y = String(e))); - } - } - (void 0 === NewgroundsIO.components.CloudSave && - (NewgroundsIO.components.CloudSave = {}), - (NewgroundsIO.components.CloudSave.loadSlot = e)); - })(), - (() => { - class e extends NewgroundsIO.BaseComponent { - constructor(e) { - super(); - let t = this; - if ( - ((this.__object = "CloudSave.loadSlots"), - (this.__requireSession = !0), - ["app_id"].forEach((e) => { - 0 > t.__properties.indexOf(e) && t.__properties.push(e); - }), - e && "object" == typeof e) - ) - for (var s = 0; s < this.__properties.length; s++) - void 0 !== e[this.__properties[s]] && - (this[this.__properties[s]] = e[this.__properties[s]]); - } - #Y = null; - get app_id() { - return this.#Y; - } - set app_id(e) { - ("string" != typeof e && - null !== e && - console.warn( - "NewgroundsIO Type Mismatch: Value should be a string, got", - e - ), - (this.#Y = String(e))); - } - } - (void 0 === NewgroundsIO.components.CloudSave && - (NewgroundsIO.components.CloudSave = {}), - (NewgroundsIO.components.CloudSave.loadSlots = e)); - })(), - (() => { - class e extends NewgroundsIO.BaseComponent { - constructor(e) { - super(); - let t = this; - if ( - ((this.__object = "CloudSave.setData"), - (this.__requireSession = !0), - ["id", "data"].forEach((e) => { - 0 > t.__properties.indexOf(e) && t.__properties.push(e); - }), - e && "object" == typeof e) - ) - for (var s = 0; s < this.__properties.length; s++) - void 0 !== e[this.__properties[s]] && - (this[this.__properties[s]] = e[this.__properties[s]]); - } - #X = null; - get id() { - return this.#X; - } - set id(e) { - ("number" != typeof e && null !== e - ? console.warn( - "NewgroundsIO Type Mismatch: Value should be a number, got", - e - ) - : Number.isInteger(e) || - null === e || - console.warn( - "NewgroundsIO Type Mismatch: Value should be an integer, got a float" - ), - (this.#X = Number(e)), - isNaN(this.#X) && (this.#X = null)); - } - #Z = null; - get data() { - return this.#Z; - } - set data(e) { - ("string" != typeof e && - null !== e && - console.warn( - "NewgroundsIO Type Mismatch: Value should be a string, got", - e - ), - (this.#Z = String(e))); - } - } - (void 0 === NewgroundsIO.components.CloudSave && - (NewgroundsIO.components.CloudSave = {}), - (NewgroundsIO.components.CloudSave.setData = e)); - })(), - (() => { - class e extends NewgroundsIO.BaseComponent { - constructor(e) { - super(); - let t = this; - if ( - ((this.__object = "Event.logEvent"), - ["host", "event_name"].forEach((e) => { - 0 > t.__properties.indexOf(e) && t.__properties.push(e); - }), - e && "object" == typeof e) - ) - for (var s = 0; s < this.__properties.length; s++) - void 0 !== e[this.__properties[s]] && - (this[this.__properties[s]] = e[this.__properties[s]]); - } - #$ = null; - get event_name() { - return this.#$; - } - set event_name(e) { - ("string" != typeof e && - null !== e && - console.warn( - "NewgroundsIO Type Mismatch: Value should be a string, got", - e - ), - (this.#$ = String(e))); - } - } - (void 0 === NewgroundsIO.components.Event && - (NewgroundsIO.components.Event = {}), - (NewgroundsIO.components.Event.logEvent = e)); - })(), - (() => { - class e extends NewgroundsIO.BaseComponent { - constructor() { - (super(), (this.__object = "Gateway.getDatetime")); - } - } - (void 0 === NewgroundsIO.components.Gateway && - (NewgroundsIO.components.Gateway = {}), - (NewgroundsIO.components.Gateway.getDatetime = e)); - })(), - (() => { - class e extends NewgroundsIO.BaseComponent { - constructor() { - (super(), (this.__object = "Gateway.getVersion")); - } - } - (void 0 === NewgroundsIO.components.Gateway && - (NewgroundsIO.components.Gateway = {}), - (NewgroundsIO.components.Gateway.getVersion = e)); - })(), - (() => { - class e extends NewgroundsIO.BaseComponent { - constructor() { - (super(), (this.__object = "Gateway.ping")); - } - } - (void 0 === NewgroundsIO.components.Gateway && - (NewgroundsIO.components.Gateway = {}), - (NewgroundsIO.components.Gateway.ping = e)); - })(), - (() => { - class e extends NewgroundsIO.BaseComponent { - constructor(e) { - super(); - let t = this; - if ( - ((this.__object = "Loader.loadAuthorUrl"), - ["host", "redirect", "log_stat"].forEach((e) => { - 0 > t.__properties.indexOf(e) && t.__properties.push(e); - }), - e && "object" == typeof e) - ) - for (var s = 0; s < this.__properties.length; s++) - void 0 !== e[this.__properties[s]] && - (this[this.__properties[s]] = e[this.__properties[s]]); - } - #_ = null; - get redirect() { - return this.#_; - } - set redirect(e) { - ("boolean" != typeof e && - "number" != typeof e && - null !== e && - console.warn( - "NewgroundsIO Type Mismatch: Value should be a boolean, got", - e - ), - (this.#_ = !!e)); - } - #aa = null; - get log_stat() { - return this.#aa; - } - set log_stat(e) { - ("boolean" != typeof e && - "number" != typeof e && - null !== e && - console.warn( - "NewgroundsIO Type Mismatch: Value should be a boolean, got", - e - ), - (this.#aa = !!e)); - } - } - (void 0 === NewgroundsIO.components.Loader && - (NewgroundsIO.components.Loader = {}), - (NewgroundsIO.components.Loader.loadAuthorUrl = e)); - })(), - (() => { - class e extends NewgroundsIO.BaseComponent { - constructor(e) { - super(); - let t = this; - if ( - ((this.__object = "Loader.loadMoreGames"), - ["host", "redirect", "log_stat"].forEach((e) => { - 0 > t.__properties.indexOf(e) && t.__properties.push(e); - }), - e && "object" == typeof e) - ) - for (var s = 0; s < this.__properties.length; s++) - void 0 !== e[this.__properties[s]] && - (this[this.__properties[s]] = e[this.__properties[s]]); - } - #_ = null; - get redirect() { - return this.#_; - } - set redirect(e) { - ("boolean" != typeof e && - "number" != typeof e && - null !== e && - console.warn( - "NewgroundsIO Type Mismatch: Value should be a boolean, got", - e - ), - (this.#_ = !!e)); - } - #aa = null; - get log_stat() { - return this.#aa; - } - set log_stat(e) { - ("boolean" != typeof e && - "number" != typeof e && - null !== e && - console.warn( - "NewgroundsIO Type Mismatch: Value should be a boolean, got", - e - ), - (this.#aa = !!e)); - } - } - (void 0 === NewgroundsIO.components.Loader && - (NewgroundsIO.components.Loader = {}), - (NewgroundsIO.components.Loader.loadMoreGames = e)); - })(), - (() => { - class e extends NewgroundsIO.BaseComponent { - constructor(e) { - super(); - let t = this; - if ( - ((this.__object = "Loader.loadNewgrounds"), - ["host", "redirect", "log_stat"].forEach((e) => { - 0 > t.__properties.indexOf(e) && t.__properties.push(e); - }), - e && "object" == typeof e) - ) - for (var s = 0; s < this.__properties.length; s++) - void 0 !== e[this.__properties[s]] && - (this[this.__properties[s]] = e[this.__properties[s]]); - } - #_ = null; - get redirect() { - return this.#_; - } - set redirect(e) { - ("boolean" != typeof e && - "number" != typeof e && - null !== e && - console.warn( - "NewgroundsIO Type Mismatch: Value should be a boolean, got", - e - ), - (this.#_ = !!e)); - } - #aa = null; - get log_stat() { - return this.#aa; - } - set log_stat(e) { - ("boolean" != typeof e && - "number" != typeof e && - null !== e && - console.warn( - "NewgroundsIO Type Mismatch: Value should be a boolean, got", - e - ), - (this.#aa = !!e)); - } - } - (void 0 === NewgroundsIO.components.Loader && - (NewgroundsIO.components.Loader = {}), - (NewgroundsIO.components.Loader.loadNewgrounds = e)); - })(), - (() => { - class e extends NewgroundsIO.BaseComponent { - constructor(e) { - super(); - let t = this; - if ( - ((this.__object = "Loader.loadOfficialUrl"), - ["host", "redirect", "log_stat"].forEach((e) => { - 0 > t.__properties.indexOf(e) && t.__properties.push(e); - }), - e && "object" == typeof e) - ) - for (var s = 0; s < this.__properties.length; s++) - void 0 !== e[this.__properties[s]] && - (this[this.__properties[s]] = e[this.__properties[s]]); - } - #_ = null; - get redirect() { - return this.#_; - } - set redirect(e) { - ("boolean" != typeof e && - "number" != typeof e && - null !== e && - console.warn( - "NewgroundsIO Type Mismatch: Value should be a boolean, got", - e - ), - (this.#_ = !!e)); - } - #aa = null; - get log_stat() { - return this.#aa; - } - set log_stat(e) { - ("boolean" != typeof e && - "number" != typeof e && - null !== e && - console.warn( - "NewgroundsIO Type Mismatch: Value should be a boolean, got", - e - ), - (this.#aa = !!e)); - } - } - (void 0 === NewgroundsIO.components.Loader && - (NewgroundsIO.components.Loader = {}), - (NewgroundsIO.components.Loader.loadOfficialUrl = e)); - })(), - (() => { - class e extends NewgroundsIO.BaseComponent { - constructor(e) { - super(); - let t = this; - if ( - ((this.__object = "Loader.loadReferral"), - ["host", "referral_name", "redirect", "log_stat"].forEach((e) => { - 0 > t.__properties.indexOf(e) && t.__properties.push(e); - }), - e && "object" == typeof e) - ) - for (var s = 0; s < this.__properties.length; s++) - void 0 !== e[this.__properties[s]] && - (this[this.__properties[s]] = e[this.__properties[s]]); - } - #ab = null; - get referral_name() { - return this.#ab; - } - set referral_name(e) { - ("string" != typeof e && - null !== e && - console.warn( - "NewgroundsIO Type Mismatch: Value should be a string, got", - e - ), - (this.#ab = String(e))); - } - #_ = null; - get redirect() { - return this.#_; - } - set redirect(e) { - ("boolean" != typeof e && - "number" != typeof e && - null !== e && - console.warn( - "NewgroundsIO Type Mismatch: Value should be a boolean, got", - e - ), - (this.#_ = !!e)); - } - #aa = null; - get log_stat() { - return this.#aa; - } - set log_stat(e) { - ("boolean" != typeof e && - "number" != typeof e && - null !== e && - console.warn( - "NewgroundsIO Type Mismatch: Value should be a boolean, got", - e - ), - (this.#aa = !!e)); - } - } - (void 0 === NewgroundsIO.components.Loader && - (NewgroundsIO.components.Loader = {}), - (NewgroundsIO.components.Loader.loadReferral = e)); - })(), - (() => { - class e extends NewgroundsIO.BaseComponent { - constructor(e) { - super(); - let t = this; - if ( - ((this.__object = "Medal.getList"), - ["app_id"].forEach((e) => { - 0 > t.__properties.indexOf(e) && t.__properties.push(e); - }), - e && "object" == typeof e) - ) - for (var s = 0; s < this.__properties.length; s++) - void 0 !== e[this.__properties[s]] && - (this[this.__properties[s]] = e[this.__properties[s]]); - } - #Y = null; - get app_id() { - return this.#Y; - } - set app_id(e) { - ("string" != typeof e && - null !== e && - console.warn( - "NewgroundsIO Type Mismatch: Value should be a string, got", - e - ), - (this.#Y = String(e))); - } - } - (void 0 === NewgroundsIO.components.Medal && - (NewgroundsIO.components.Medal = {}), - (NewgroundsIO.components.Medal.getList = e)); - })(), - (() => { - class e extends NewgroundsIO.BaseComponent { - constructor() { - (super(), - (this.__object = "Medal.getMedalScore"), - (this.__requireSession = !0)); - } - } - (void 0 === NewgroundsIO.components.Medal && - (NewgroundsIO.components.Medal = {}), - (NewgroundsIO.components.Medal.getMedalScore = e)); - })(), - (() => { - class e extends NewgroundsIO.BaseComponent { - constructor(e) { - super(); - let t = this; - if ( - ((this.__object = "Medal.unlock"), - (this.__isSecure = !0), - (this.__requireSession = !0), - ["id"].forEach((e) => { - 0 > t.__properties.indexOf(e) && t.__properties.push(e); - }), - e && "object" == typeof e) - ) - for (var s = 0; s < this.__properties.length; s++) - void 0 !== e[this.__properties[s]] && - (this[this.__properties[s]] = e[this.__properties[s]]); - } - #X = null; - get id() { - return this.#X; - } - set id(e) { - ("number" != typeof e && null !== e - ? console.warn( - "NewgroundsIO Type Mismatch: Value should be a number, got", - e - ) - : Number.isInteger(e) || - null === e || - console.warn( - "NewgroundsIO Type Mismatch: Value should be an integer, got a float" - ), - (this.#X = Number(e)), - isNaN(this.#X) && (this.#X = null)); - } - } - (void 0 === NewgroundsIO.components.Medal && - (NewgroundsIO.components.Medal = {}), - (NewgroundsIO.components.Medal.unlock = e)); - })(), - (() => { - class e extends NewgroundsIO.BaseComponent { - constructor() { - (super(), (this.__object = "ScoreBoard.getBoards")); - } - } - (void 0 === NewgroundsIO.components.ScoreBoard && - (NewgroundsIO.components.ScoreBoard = {}), - (NewgroundsIO.components.ScoreBoard.getBoards = e)); - })(), - (() => { - class e extends NewgroundsIO.BaseComponent { - constructor(e) { - super(); - let t = this; - if ( - ((this.__object = "ScoreBoard.getScores"), - [ - "id", - "period", - "tag", - "social", - "user", - "skip", - "limit", - "app_id", - ].forEach((e) => { - 0 > t.__properties.indexOf(e) && t.__properties.push(e); - }), - e && "object" == typeof e) - ) - for (var s = 0; s < this.__properties.length; s++) - void 0 !== e[this.__properties[s]] && - (this[this.__properties[s]] = e[this.__properties[s]]); - } - #X = null; - get id() { - return this.#X; - } - set id(e) { - ("number" != typeof e && null !== e - ? console.warn( - "NewgroundsIO Type Mismatch: Value should be a number, got", - e - ) - : Number.isInteger(e) || - null === e || - console.warn( - "NewgroundsIO Type Mismatch: Value should be an integer, got a float" - ), - (this.#X = Number(e)), - isNaN(this.#X) && (this.#X = null)); - } - #ac = null; - get period() { - return this.#ac; - } - set period(e) { - ("string" != typeof e && - null !== e && - console.warn( - "NewgroundsIO Type Mismatch: Value should be a string, got", - e - ), - (this.#ac = String(e))); - } - #ad = null; - get tag() { - return this.#ad; - } - set tag(e) { - ("string" != typeof e && - null !== e && - console.warn( - "NewgroundsIO Type Mismatch: Value should be a string, got", - e - ), - (this.#ad = String(e))); - } - #ae = null; - get social() { - return this.#ae; - } - set social(e) { - ("boolean" != typeof e && - "number" != typeof e && - null !== e && - console.warn( - "NewgroundsIO Type Mismatch: Value should be a boolean, got", - e - ), - (this.#ae = !!e)); - } - #af = null; - get user() { - return this.#af; - } - set user(e) { - this.#af = e; - } - #ag = null; - get skip() { - return this.#ag; - } - set skip(e) { - ("number" != typeof e && null !== e - ? console.warn( - "NewgroundsIO Type Mismatch: Value should be a number, got", - e - ) - : Number.isInteger(e) || - null === e || - console.warn( - "NewgroundsIO Type Mismatch: Value should be an integer, got a float" - ), - (this.#ag = Number(e)), - isNaN(this.#ag) && (this.#ag = null)); - } - #ah = null; - get limit() { - return this.#ah; - } - set limit(e) { - ("number" != typeof e && null !== e - ? console.warn( - "NewgroundsIO Type Mismatch: Value should be a number, got", - e - ) - : Number.isInteger(e) || - null === e || - console.warn( - "NewgroundsIO Type Mismatch: Value should be an integer, got a float" - ), - (this.#ah = Number(e)), - isNaN(this.#ah) && (this.#ah = null)); - } - #Y = null; - get app_id() { - return this.#Y; - } - set app_id(e) { - ("string" != typeof e && - null !== e && - console.warn( - "NewgroundsIO Type Mismatch: Value should be a string, got", - e - ), - (this.#Y = String(e))); - } - } - (void 0 === NewgroundsIO.components.ScoreBoard && - (NewgroundsIO.components.ScoreBoard = {}), - (NewgroundsIO.components.ScoreBoard.getScores = e)); - })(), - (() => { - class e extends NewgroundsIO.BaseComponent { - constructor(e) { - super(); - let t = this; - if ( - ((this.__object = "ScoreBoard.postScore"), - (this.__isSecure = !0), - (this.__requireSession = !0), - ["id", "value", "tag"].forEach((e) => { - 0 > t.__properties.indexOf(e) && t.__properties.push(e); - }), - e && "object" == typeof e) - ) - for (var s = 0; s < this.__properties.length; s++) - void 0 !== e[this.__properties[s]] && - (this[this.__properties[s]] = e[this.__properties[s]]); - } - #X = null; - get id() { - return this.#X; - } - set id(e) { - ("number" != typeof e && null !== e - ? console.warn( - "NewgroundsIO Type Mismatch: Value should be a number, got", - e - ) - : Number.isInteger(e) || - null === e || - console.warn( - "NewgroundsIO Type Mismatch: Value should be an integer, got a float" - ), - (this.#X = Number(e)), - isNaN(this.#X) && (this.#X = null)); - } - #ai = null; - get value() { - return this.#ai; - } - set value(e) { - ("number" != typeof e && null !== e - ? console.warn( - "NewgroundsIO Type Mismatch: Value should be a number, got", - e - ) - : Number.isInteger(e) || - null === e || - console.warn( - "NewgroundsIO Type Mismatch: Value should be an integer, got a float" - ), - (this.#ai = Number(e)), - isNaN(this.#ai) && (this.#ai = null)); - } - #ad = null; - get tag() { - return this.#ad; - } - set tag(e) { - ("string" != typeof e && - null !== e && - console.warn( - "NewgroundsIO Type Mismatch: Value should be a string, got", - e - ), - (this.#ad = String(e))); - } - } - (void 0 === NewgroundsIO.components.ScoreBoard && - (NewgroundsIO.components.ScoreBoard = {}), - (NewgroundsIO.components.ScoreBoard.postScore = e)); - })(), - (() => { - class e extends NewgroundsIO.BaseObject { - constructor(e) { - super(); - let t = this; - if ( - ((this.__object = "Debug"), - ["exec_time", "request"].forEach((e) => { - 0 > t.__properties.indexOf(e) && t.__properties.push(e); - }), - e && "object" == typeof e) - ) - for (var s = 0; s < this.__properties.length; s++) - void 0 !== e[this.__properties[s]] && - (this[this.__properties[s]] = e[this.__properties[s]]); - } - #aj = null; - get exec_time() { - return this.#aj; - } - set exec_time(e) { - ("string" != typeof e && - null !== e && - console.warn( - "NewgroundsIO Type Mismatch: Value should be a string, got", - e - ), - (this.#aj = String(e))); - } - #ak = null; - get request() { - return this.#ak; - } - set request(e) { - (e instanceof NewgroundsIO.objects.Request || - "object" != typeof e || - (e = new NewgroundsIO.objects.Request(e)), - null === e || - e instanceof NewgroundsIO.objects.Request || - console.warn( - "Type Mismatch: expecting NewgroundsIO.objects.Request, got ", - e - ), - (this.#ak = e)); - } - objectMap = { request: "Request" }; - } - (void 0 === NewgroundsIO.objects && (NewgroundsIO.objects = {}), - (NewgroundsIO.objects.Debug = e)); - })(), - (() => { - class e extends NewgroundsIO.BaseObject { - constructor(e) { - super(); - let t = this; - if ( - ((this.__object = "Error"), - ["message", "code"].forEach((e) => { - 0 > t.__properties.indexOf(e) && t.__properties.push(e); - }), - e && "object" == typeof e) - ) - for (var s = 0; s < this.__properties.length; s++) - void 0 !== e[this.__properties[s]] && - (this[this.__properties[s]] = e[this.__properties[s]]); - } - #al = null; - get message() { - return this.#al; - } - set message(e) { - ("string" != typeof e && - null !== e && - console.warn( - "NewgroundsIO Type Mismatch: Value should be a string, got", - e - ), - (this.#al = String(e))); - } - #am = null; - get code() { - return this.#am; - } - set code(e) { - ("number" != typeof e && null !== e - ? console.warn( - "NewgroundsIO Type Mismatch: Value should be a number, got", - e - ) - : Number.isInteger(e) || - null === e || - console.warn( - "NewgroundsIO Type Mismatch: Value should be an integer, got a float" - ), - (this.#am = Number(e)), - isNaN(this.#am) && (this.#am = null)); - } - } - (void 0 === NewgroundsIO.objects && (NewgroundsIO.objects = {}), - (NewgroundsIO.objects.Error = e)); - })(), - (() => { - class e extends NewgroundsIO.BaseObject { - constructor(e) { - super(); - let t = this; - if ( - ((this.__object = "Execute"), - ["component", "parameters", "secure"].forEach((e) => { - 0 > t.__properties.indexOf(e) && t.__properties.push(e); - }), - e && "object" == typeof e) - ) - for (var s = 0; s < this.__properties.length; s++) - void 0 !== e[this.__properties[s]] && - (this[this.__properties[s]] = e[this.__properties[s]]); - } - #an = null; - get component() { - return this.#an; - } - set component(e) { - ("string" != typeof e && - null !== e && - console.warn( - "NewgroundsIO Type Mismatch: Value should be a string, got", - e - ), - (this.#an = String(e))); - } - #ao = null; - get parameters() { - return this.#ao; - } - set parameters(e) { - if (Array.isArray(e)) { - let t = []; - (e.forEach(function (e, s) { - ("object" != typeof e && - null !== e && - console.warn( - "NewgroundsIO Type Mismatch: Value should be a object, got", - e - ), - (t[s] = e)); - }), - (this.#ao = t)); - return; - } - ("object" != typeof e && - null !== e && - console.warn( - "NewgroundsIO Type Mismatch: Value should be a object, got", - e - ), - (this.#ao = e)); - } - #ap = null; - get secure() { - return this.#ap; - } - set secure(e) { - ("string" != typeof e && - null !== e && - console.warn( - "NewgroundsIO Type Mismatch: Value should be a string, got", - e - ), - (this.#ap = String(e))); - } - #aq = null; - setComponent(e) { - (e instanceof NewgroundsIO.BaseComponent || - console.error( - "NewgroundsIO Error: Expecting NewgroundsIO component, got " + - typeof e - ), - (this.#aq = e), - (this.component = e.__object), - (this.parameters = e.toJSON())); - } - isValid() { - return (this.component || - console.error("NewgroundsIO Error: Missing required component!"), - this.__ngioCore) - ? !this.#aq || - (this.#aq.__requireSession && - !this.__ngioCore.session.isActive() - ? (console.warn( - "NewgroundsIO Warning: " + - this.component + - " can only be used with a valid user session." - ), - this.__ngioCore.session.logProblems(), - !1) - : this.#aq instanceof NewgroundsIO.BaseComponent && - this.#aq.isValid()) - : (console.error( - "NewgroundsIO Error: Must call setCore() before validating!" - ), - !1); - } - toJSON() { - return this.#aq && this.#aq.__isSecure - ? this.toSecureJSON() - : super.toJSON(); - } - } - (void 0 === NewgroundsIO.objects && (NewgroundsIO.objects = {}), - (NewgroundsIO.objects.Execute = e)); - })(), - (() => { - class e extends NewgroundsIO.BaseObject { - constructor(e) { - super(); - let t = this; - if ( - ((this.__object = "Medal"), - [ - "id", - "name", - "description", - "icon", - "value", - "difficulty", - "secret", - "unlocked", - ].forEach((e) => { - 0 > t.__properties.indexOf(e) && t.__properties.push(e); - }), - e && "object" == typeof e) - ) - for (var s = 0; s < this.__properties.length; s++) - void 0 !== e[this.__properties[s]] && - (this[this.__properties[s]] = e[this.__properties[s]]); - } - #X = null; - get id() { - return this.#X; - } - set id(e) { - ("number" != typeof e && null !== e - ? console.warn( - "NewgroundsIO Type Mismatch: Value should be a number, got", - e - ) - : Number.isInteger(e) || - null === e || - console.warn( - "NewgroundsIO Type Mismatch: Value should be an integer, got a float" - ), - (this.#X = Number(e)), - isNaN(this.#X) && (this.#X = null)); - } - #ar = null; - get name() { - return this.#ar; - } - set name(e) { - ("string" != typeof e && - null !== e && - console.warn( - "NewgroundsIO Type Mismatch: Value should be a string, got", - e - ), - (this.#ar = String(e))); - } - #as = null; - get description() { - return this.#as; - } - set description(e) { - ("string" != typeof e && - null !== e && - console.warn( - "NewgroundsIO Type Mismatch: Value should be a string, got", - e - ), - (this.#as = String(e))); - } - #at = null; - get icon() { - return this.#at; - } - set icon(e) { - ("string" != typeof e && - null !== e && - console.warn( - "NewgroundsIO Type Mismatch: Value should be a string, got", - e - ), - (this.#at = String(e))); - } - #ai = null; - get value() { - return this.#ai; - } - set value(e) { - ("number" != typeof e && null !== e - ? console.warn( - "NewgroundsIO Type Mismatch: Value should be a number, got", - e - ) - : Number.isInteger(e) || - null === e || - console.warn( - "NewgroundsIO Type Mismatch: Value should be an integer, got a float" - ), - (this.#ai = Number(e)), - isNaN(this.#ai) && (this.#ai = null)); - } - #au = null; - get difficulty() { - return this.#au; - } - set difficulty(e) { - ("number" != typeof e && null !== e - ? console.warn( - "NewgroundsIO Type Mismatch: Value should be a number, got", - e - ) - : Number.isInteger(e) || - null === e || - console.warn( - "NewgroundsIO Type Mismatch: Value should be an integer, got a float" - ), - (this.#au = Number(e)), - isNaN(this.#au) && (this.#au = null)); - } - #av = null; - get secret() { - return this.#av; - } - set secret(e) { - ("boolean" != typeof e && - "number" != typeof e && - null !== e && - console.warn( - "NewgroundsIO Type Mismatch: Value should be a boolean, got", - e - ), - (this.#av = !!e)); - } - #aw = null; - get unlocked() { - return this.#aw; - } - set unlocked(e) { - ("boolean" != typeof e && - "number" != typeof e && - null !== e && - console.warn( - "NewgroundsIO Type Mismatch: Value should be a boolean, got", - e - ), - (this.#aw = !!e)); - } - unlock(e, t) { - if (!this.__ngioCore) { - console.error( - "NewgroundsIO - Can not unlock medal object without attaching a NewgroundsIO.Core instance." - ); - return; - } - var s = this.__ngioCore.getComponent("Medal.unlock", { id: this.id }); - this.__ngioCore.executeComponent(s, e, t); - } - } - (void 0 === NewgroundsIO.objects && (NewgroundsIO.objects = {}), - (NewgroundsIO.objects.Medal = e)); - })(), - (() => { - class e extends NewgroundsIO.BaseObject { - constructor(e) { - super(); - let t = this; - if ( - ((this.__object = "Request"), - ["app_id", "execute", "session_id", "debug"].forEach((e) => { - 0 > t.__properties.indexOf(e) && t.__properties.push(e); - }), - e && "object" == typeof e) - ) - for (var s = 0; s < this.__properties.length; s++) - void 0 !== e[this.__properties[s]] && - (this[this.__properties[s]] = e[this.__properties[s]]); - } - #ax = null; - get execute() { - return this.#ax; - } - set execute(e) { - if ( - (Array.isArray(e) || - e instanceof NewgroundsIO.objects.Execute || - "object" != typeof e || - (e = new NewgroundsIO.objects.Execute(e)), - Array.isArray(e)) - ) { - let t = []; - (e.forEach(function (e, s) { - (null === e || - e instanceof NewgroundsIO.objects.Execute || - console.warn( - "Type Mismatch: expecting NewgroundsIO.objects.Execute, got ", - e - ), - (t[s] = e)); - }), - (this.#ax = t)); - return; - } - (null === e || - e instanceof NewgroundsIO.objects.Execute || - console.warn( - "Type Mismatch: expecting NewgroundsIO.objects.Execute, got ", - e - ), - (this.#ax = e)); - } - #P = null; - get debug() { - return this.#P; - } - set debug(e) { - ("boolean" != typeof e && - "number" != typeof e && - null !== e && - console.warn( - "NewgroundsIO Type Mismatch: Value should be a boolean, got", - e - ), - (this.#P = !!e)); - } - objectMap = { execute: "Execute" }; - arrayMap = { execute: "Execute" }; - get app_id() { - return this.__ngioCore ? this.__ngioCore.appID : null; - } - get session_id() { - return this.__ngioCore && this.__ngioCore.session - ? this.__ngioCore.session.id - : null; - } - } - (void 0 === NewgroundsIO.objects && (NewgroundsIO.objects = {}), - (NewgroundsIO.objects.Request = e)); - })(), - (() => { - class e extends NewgroundsIO.BaseObject { - constructor(e) { - super(); - let t = this; - if ( - ((this.__object = "Response"), - [ - "app_id", - "success", - "debug", - "result", - "error", - "api_version", - "help_url", - ].forEach((e) => { - 0 > t.__properties.indexOf(e) && t.__properties.push(e); - }), - e && "object" == typeof e) - ) - for (var s = 0; s < this.__properties.length; s++) - void 0 !== e[this.__properties[s]] && - (this[this.__properties[s]] = e[this.__properties[s]]); - } - #Y = null; - get app_id() { - return this.#Y; - } - set app_id(e) { - ("string" != typeof e && - null !== e && - console.warn( - "NewgroundsIO Type Mismatch: Value should be a string, got", - e - ), - (this.#Y = String(e))); - } - #ay = null; - get success() { - return this.#ay; - } - set success(e) { - ("boolean" != typeof e && - "number" != typeof e && - null !== e && - console.warn( - "NewgroundsIO Type Mismatch: Value should be a boolean, got", - e - ), - (this.#ay = !!e)); - } - #P = null; - get debug() { - return this.#P; - } - set debug(e) { - (e instanceof NewgroundsIO.objects.Debug || - "object" != typeof e || - (e = new NewgroundsIO.objects.Debug(e)), - null === e || - e instanceof NewgroundsIO.objects.Debug || - console.warn( - "Type Mismatch: expecting NewgroundsIO.objects.Debug, got ", - e - ), - (this.#P = e)); - } - #az = null; - get result() { - return this.#az; - } - set result(e) { - if (Array.isArray(e)) { - let t = []; - (e.forEach(function (e, s) { - (e instanceof NewgroundsIO.BaseResult || - null === e || - console.warn( - "NewgroundsIO Type Mismatch: Value should be a NewgroundsIO.results.XXXX instance, got", - e - ), - (t[s] = e)); - }), - (this.#az = t)); - return; - } - (e instanceof NewgroundsIO.BaseResult || - null === e || - console.warn( - "NewgroundsIO Type Mismatch: Value should be a NewgroundsIO.results.XXXX instance, got", - e - ), - (this.#az = e)); - } - #aA = null; - get error() { - return this.#aA; - } - set error(e) { - (e instanceof NewgroundsIO.objects.Error || - "object" != typeof e || - (e = new NewgroundsIO.objects.Error(e)), - null === e || - e instanceof NewgroundsIO.objects.Error || - console.warn( - "Type Mismatch: expecting NewgroundsIO.objects.Error, got ", - e - ), - (this.#aA = e)); - } - #aB = null; - get api_version() { - return this.#aB; - } - set api_version(e) { - ("string" != typeof e && - null !== e && - console.warn( - "NewgroundsIO Type Mismatch: Value should be a string, got", - e - ), - (this.#aB = String(e))); - } - #aC = null; - get help_url() { - return this.#aC; - } - set help_url(e) { - ("string" != typeof e && - null !== e && - console.warn( - "NewgroundsIO Type Mismatch: Value should be a string, got", - e - ), - (this.#aC = String(e))); - } - objectMap = { debug: "Debug", error: "Error" }; - } - (void 0 === NewgroundsIO.objects && (NewgroundsIO.objects = {}), - (NewgroundsIO.objects.Response = e)); - })(), - (() => { - class e extends NewgroundsIO.BaseObject { - constructor(e) { - super(); - let t = this; - if ( - ((this.__object = "SaveSlot"), - ["id", "size", "datetime", "timestamp", "url"].forEach((e) => { - 0 > t.__properties.indexOf(e) && t.__properties.push(e); - }), - e && "object" == typeof e) - ) - for (var s = 0; s < this.__properties.length; s++) - void 0 !== e[this.__properties[s]] && - (this[this.__properties[s]] = e[this.__properties[s]]); - } - #X = null; - get id() { - return this.#X; - } - set id(e) { - ("number" != typeof e && null !== e - ? console.warn( - "NewgroundsIO Type Mismatch: Value should be a number, got", - e - ) - : Number.isInteger(e) || - null === e || - console.warn( - "NewgroundsIO Type Mismatch: Value should be an integer, got a float" - ), - (this.#X = Number(e)), - isNaN(this.#X) && (this.#X = null)); - } - #aD = null; - get size() { - return this.#aD; - } - set size(e) { - ("number" != typeof e && null !== e - ? console.warn( - "NewgroundsIO Type Mismatch: Value should be a number, got", - e - ) - : Number.isInteger(e) || - null === e || - console.warn( - "NewgroundsIO Type Mismatch: Value should be an integer, got a float" - ), - (this.#aD = Number(e)), - isNaN(this.#aD) && (this.#aD = null)); - } - #aE = null; - get datetime() { - return this.#aE; - } - set datetime(e) { - ("string" != typeof e && - null !== e && - console.warn( - "NewgroundsIO Type Mismatch: Value should be a string, got", - e - ), - (this.#aE = String(e))); - } - #aF = null; - get timestamp() { - return this.#aF; - } - set timestamp(e) { - ("number" != typeof e && null !== e - ? console.warn( - "NewgroundsIO Type Mismatch: Value should be a number, got", - e - ) - : Number.isInteger(e) || - null === e || - console.warn( - "NewgroundsIO Type Mismatch: Value should be an integer, got a float" - ), - (this.#aF = Number(e)), - isNaN(this.#aF) && (this.#aF = null)); - } - #aG = null; - get url() { - return this.#aG; - } - set url(e) { - ("string" != typeof e && - null !== e && - console.warn( - "NewgroundsIO Type Mismatch: Value should be a string, got", - e - ), - (this.#aG = String(e))); - } - get hasData() { - return null !== this.url; - } - getData(e, t) { - if ("function" != typeof e) { - debug.error("NewgroundsIO - Missing required callback function"); - return; - } - var s = new XMLHttpRequest(); - ((s.onreadystatechange = function () { - 4 == s.readyState && - (t ? e.call(t, s.responseText) : e(s.responseText)); - }), - s.open("GET", this.url, !0), - s.send()); - } - setData(e, t, s) { - if (!this.__ngioCore) { - console.error( - "NewgroundsIO - Can not save data without attaching a NewgroundsIO.Core instance." - ); - return; - } - var o = this.__ngioCore.getComponent("CloudSave.setData", { - id: this.id, - data: e, - }); - this.__ngioCore.executeComponent(o, t, s); - } - clearData(e, t) { - if (!this.__ngioCore) { - console.error( - "NewgroundsIO - Can not clear data without attaching a NewgroundsIO.Core instance." - ); - return; - } - this.#aG = null; - var s = this.__ngioCore.getComponent("CloudSave.clearSlot", { - id: this.id, - }); - this.__ngioCore.executeComponent(s, e, t); - } - getDate() { - return this.hasData ? new Date(this.datetime) : null; - } - } - (void 0 === NewgroundsIO.objects && (NewgroundsIO.objects = {}), - (NewgroundsIO.objects.SaveSlot = e)); - })(), - (() => { - class e extends NewgroundsIO.BaseObject { - constructor(e) { - super(); - let t = this; - if ( - ((this.__object = "Score"), - ["user", "value", "formatted_value", "tag"].forEach((e) => { - 0 > t.__properties.indexOf(e) && t.__properties.push(e); - }), - e && "object" == typeof e) - ) - for (var s = 0; s < this.__properties.length; s++) - void 0 !== e[this.__properties[s]] && - (this[this.__properties[s]] = e[this.__properties[s]]); - } - #af = null; - get user() { - return this.#af; - } - set user(e) { - (e instanceof NewgroundsIO.objects.User || - "object" != typeof e || - (e = new NewgroundsIO.objects.User(e)), - null === e || - e instanceof NewgroundsIO.objects.User || - console.warn( - "Type Mismatch: expecting NewgroundsIO.objects.User, got ", - e - ), - (this.#af = e)); - } - #ai = null; - get value() { - return this.#ai; - } - set value(e) { - ("number" != typeof e && null !== e - ? console.warn( - "NewgroundsIO Type Mismatch: Value should be a number, got", - e - ) - : Number.isInteger(e) || - null === e || - console.warn( - "NewgroundsIO Type Mismatch: Value should be an integer, got a float" - ), - (this.#ai = Number(e)), - isNaN(this.#ai) && (this.#ai = null)); - } - #aH = null; - get formatted_value() { - return this.#aH; - } - set formatted_value(e) { - ("string" != typeof e && - null !== e && - console.warn( - "NewgroundsIO Type Mismatch: Value should be a string, got", - e - ), - (this.#aH = String(e))); - } - #ad = null; - get tag() { - return this.#ad; - } - set tag(e) { - ("string" != typeof e && - null !== e && - console.warn( - "NewgroundsIO Type Mismatch: Value should be a string, got", - e - ), - (this.#ad = String(e))); - } - objectMap = { user: "User" }; - } - (void 0 === NewgroundsIO.objects && (NewgroundsIO.objects = {}), - (NewgroundsIO.objects.Score = e)); - })(), - (() => { - class e extends NewgroundsIO.BaseObject { - constructor(e) { - super(); - let t = this; - if ( - ((this.__object = "ScoreBoard"), - ["id", "name"].forEach((e) => { - 0 > t.__properties.indexOf(e) && t.__properties.push(e); - }), - e && "object" == typeof e) - ) - for (var s = 0; s < this.__properties.length; s++) - void 0 !== e[this.__properties[s]] && - (this[this.__properties[s]] = e[this.__properties[s]]); - } - #X = null; - get id() { - return this.#X; - } - set id(e) { - ("number" != typeof e && null !== e - ? console.warn( - "NewgroundsIO Type Mismatch: Value should be a number, got", - e - ) - : Number.isInteger(e) || - null === e || - console.warn( - "NewgroundsIO Type Mismatch: Value should be an integer, got a float" - ), - (this.#X = Number(e)), - isNaN(this.#X) && (this.#X = null)); - } - #ar = null; - get name() { - return this.#ar; - } - set name(e) { - ("string" != typeof e && - null !== e && - console.warn( - "NewgroundsIO Type Mismatch: Value should be a string, got", - e - ), - (this.#ar = String(e))); - } - getScores(e, t, s) { - if (!this.__ngioCore) { - console.error( - "NewgroundsIO - Can not get scores without attaching a NewgroundsIO.Core instance." - ); - return; - } - ("function" == typeof e && ((s = t), (t = e), (e = {})), - e || (e = {}), - (e.id = this.id)); - var o = this.__ngioCore.getComponent("ScoreBoard.getScores", e); - this.__ngioCore.executeComponent(o, t, s); - } - postScore(e, t, s, o) { - if (!this.__ngioCore) { - console.error( - "NewgroundsIO - Can not post scores without attaching a NewgroundsIO.Core instance." - ); - return; - } - "function" == typeof t && ((o = s), (s = t), (t = null)); - var r = this.__ngioCore.getComponent("ScoreBoard.postScore", { - id: this.id, - value: e, - tag: t, - }); - this.__ngioCore.executeComponent(r, s, o); - } - } - (void 0 === NewgroundsIO.objects && (NewgroundsIO.objects = {}), - (NewgroundsIO.objects.ScoreBoard = e)); - })(), - (() => { - class e extends NewgroundsIO.BaseObject { - constructor(e) { - super(); - let t = this; - if ( - ((this.__object = "Session"), - ["id", "user", "expired", "remember", "passport_url"].forEach( - (e) => { - 0 > t.__properties.indexOf(e) && t.__properties.push(e); - } - ), - e && "object" == typeof e) - ) - for (var s = 0; s < this.__properties.length; s++) - void 0 !== e[this.__properties[s]] && - (this[this.__properties[s]] = e[this.__properties[s]]); - } - #X = null; - get id() { - return this.#X; - } - set id(e) { - ("string" != typeof e && - null !== e && - console.warn( - "NewgroundsIO Type Mismatch: Value should be a string, got", - e - ), - (this.#X = String(e))); - } - #af = null; - get user() { - return this.#af; - } - set user(e) { - (e instanceof NewgroundsIO.objects.User || - "object" != typeof e || - (e = new NewgroundsIO.objects.User(e)), - null === e || - e instanceof NewgroundsIO.objects.User || - console.warn( - "Type Mismatch: expecting NewgroundsIO.objects.User, got ", - e - ), - (this.#af = e)); - } - #aI = null; - get expired() { - return this.#aI; - } - set expired(e) { - ("boolean" != typeof e && - "number" != typeof e && - null !== e && - console.warn( - "NewgroundsIO Type Mismatch: Value should be a boolean, got", - e - ), - (this.#aI = !!e)); - } - #aJ = null; - get remember() { - return this.#aJ; - } - set remember(e) { - ("boolean" != typeof e && - "number" != typeof e && - null !== e && - console.warn( - "NewgroundsIO Type Mismatch: Value should be a boolean, got", - e - ), - (this.#aJ = !!e)); - } - #aK = null; - get passport_url() { - return this.#aK; - } - set passport_url(e) { - ("string" != typeof e && - null !== e && - console.warn( - "NewgroundsIO Type Mismatch: Value should be a string, got", - e - ), - (this.#aK = String(e))); - } - objectMap = { user: "User" }; - #aL = NewgroundsIO.SessionState.SESSION_UNINITIALIZED; - #aM = null; - #aN = !1; - #aO = new Date(new Date().getTime() - 3e4); - #aP = !0; - #aQ = "expired"; - #aR = 0; - #aS = 5; - #aT = null; - get uri_id() { - return this.#aT; - } - set uri_id(e) { - ("string" != typeof e && - null !== e && - console.warn( - "NewgroundsIO Type Mismatch: Value should be a string, got", - e - ), - (this.#aT = String(e))); - } - #aU = null; - get status() { - return this.#aL; - } - get statusChanged() { - return this.#aN; - } - get waiting() { - return this.#aM != this.status; - } - get storageKey() { - return this.__ngioCore - ? "_ngio_" + this.__ngioCore.appID + "_session_" - : null; - } - resetSession() { - ((this.#aT = null), - (this.#aU = null), - (this.remember = !1), - (this.user = null), - (this.expired = !1), - localStorage.setItem(this.storageKey, null)); - } - openLoginPage() { - if (!this.passport_url) { - console.warn( - "Can't open passport without getting a valis session first." - ); - return; - } - ((this.#aL = NewgroundsIO.SessionState.WAITING_FOR_USER), - (this.mode = "check"), - window.open(this.passport_url, "_blank")); - } - logOut(e, t) { - ((this.mode = "wait"), this.endSession(e, t)); - } - cancelLogin(e) { - (this.endSession(), - void 0 === e && (e = NewgroundsIO.SessionState.LOGIN_CANCELLED), - this.resetSession(), - (this.id = null), - (this.#aL = e), - (this.#aR = 0), - (this.#aQ = "new"), - (this.#aO = new Date(new Date().getTime() - 3e4))); - } - update(e, t) { - if ( - ((this.#aN = !1), - this.#aM != this.status && - ((this.#aN = !0), - (this.#aM = this.status), - "function" == typeof e && (t ? e.call(t, this) : e(this))), - this.#aP && "wait" != this.mode) - ) { - if (!this.__ngioCore) { - (console.error( - "NewgroundsIO - Can't update session without attaching a NewgroundsIO.Core instance." - ), - (this.#aP = !1)); - return; - } - (this.status == NewgroundsIO.SessionState.SERVER_UNAVAILABLE && - (this.#aR >= this.#aS - ? (this.#aL = NewgroundsIO.SessionState.EXCEEDED_MAX_ATTEMPTS) - : ((this.#aL = NewgroundsIO.SessionState.SESSION_UNINITIALIZED), - this.#aR++)), - this.status == NewgroundsIO.SessionState.SESSION_UNINITIALIZED && - ((this.#aU = localStorage.getItem(this.storageKey)), - this.#aT - ? (this.id = this.#aT) - : this.#aU && (this.id = this.#aU), - (this.mode = this.id && "null" !== this.id ? "check" : "new"))); - var s = new Date(); - if (!(s - this.#aO < 5e3)) - switch (((this.#aO = s), this.mode)) { - case "new": - ((this.mode = "wait"), this.startSession()); - break; - case "check": - ((this.mode = "wait"), this.checkSession()); - } - } - } - startSession() { - ((this.#aP = !1), - this.resetSession(), - (this.#aL = NewgroundsIO.SessionState.WAITING_FOR_SERVER)); - var e = this.__ngioCore.getComponent("App.startSession"); - this.__ngioCore.executeComponent(e, this._onStartSession, this); - } - _onStartSession(e) { - if (!0 === e.success) { - let t = e.result; - if (Array.isArray(t)) { - for (let s = 0; s < t.length; s++) - if ( - t[s] && - t[s].__object && - "App.startSession" == t[s].__object - ) { - t = t[s]; - break; - } - } - ((this.id = t.session.id), - (this.passport_url = t.session.passport_url), - (this.#aL = NewgroundsIO.SessionState.LOGIN_REQUIRED), - (this.mode = "wait")); - } else this.#aL = NewgroundsIO.SessionState.SERVER_UNAVAILABLE; - this.#aP = !0; - } - checkSession() { - this.#aP = !1; - var e = this.__ngioCore.getComponent("App.checkSession"); - this.__ngioCore.executeComponent(e, this._onCheckSession, this); - } - _onCheckSession(e) { - (!0 === e.success - ? e.result.success - ? e.result.session.expired - ? (this.resetSession(), - (this.id = null), - (this.#aL = NewgroundsIO.SessionState.SESSION_UNINITIALIZED)) - : null !== e.result.session.user - ? ((this.user = e.result.session.user), - (this.#aL = NewgroundsIO.SessionState.LOGIN_SUCCESSFUL), - (this.mode = "valid"), - e.result.session.remember && - ((this.#aU = this.id), - (this.remember = !0), - localStorage.setItem(this.storageKey, this.id))) - : (this.mode = "check") - : ((this.id = null), - this.cancelLogin( - 111 === e.result.error.code - ? NewgroundsIO.SessionState.LOGIN_CANCELLED - : NewgroundsIO.SessionState.LOGIN_FAILED - )) - : (this.#aL = NewgroundsIO.SessionState.SERVER_UNAVAILABLE), - (this.#aP = !0)); - } - endSession(e, t) { - this.#aP = !1; - var s = this.__ngioCore.getComponent("App.endSession"), - o = this.__ngioCore.getComponent("App.startSession"); - (this.__ngioCore.queueComponent(s), - this.__ngioCore.queueComponent(o), - this.__ngioCore.executeQueue(function (s) { - (this._onEndSession(s), - this._onStartSession(s), - "function" == typeof e && (t ? e.call(t, this) : e(this))); - }, this)); - } - _onEndSession(e) { - (this.resetSession(), - (this.id = null), - (this.user = null), - (this.passport_url = null), - (this.mode = "new"), - (this.#aL = NewgroundsIO.SessionState.USER_LOGGED_OUT), - (this.#aP = !0)); - } - } - (void 0 === NewgroundsIO.objects && (NewgroundsIO.objects = {}), - (NewgroundsIO.objects.Session = e)); - })(), - (() => { - class e extends NewgroundsIO.BaseObject { - constructor(e) { - super(); - let t = this; - if ( - ((this.__object = "User"), - ["id", "name", "icons", "supporter"].forEach((e) => { - 0 > t.__properties.indexOf(e) && t.__properties.push(e); - }), - e && "object" == typeof e) - ) - for (var s = 0; s < this.__properties.length; s++) - void 0 !== e[this.__properties[s]] && - (this[this.__properties[s]] = e[this.__properties[s]]); - } - #X = null; - get id() { - return this.#X; - } - set id(e) { - ("number" != typeof e && null !== e - ? console.warn( - "NewgroundsIO Type Mismatch: Value should be a number, got", - e - ) - : Number.isInteger(e) || - null === e || - console.warn( - "NewgroundsIO Type Mismatch: Value should be an integer, got a float" - ), - (this.#X = Number(e)), - isNaN(this.#X) && (this.#X = null)); - } - #ar = null; - get name() { - return this.#ar; - } - set name(e) { - ("string" != typeof e && - null !== e && - console.warn( - "NewgroundsIO Type Mismatch: Value should be a string, got", - e - ), - (this.#ar = String(e))); - } - #aV = null; - get icons() { - return this.#aV; - } - set icons(e) { - (e instanceof NewgroundsIO.objects.UserIcons || - "object" != typeof e || - (e = new NewgroundsIO.objects.UserIcons(e)), - null === e || - e instanceof NewgroundsIO.objects.UserIcons || - console.warn( - "Type Mismatch: expecting NewgroundsIO.objects.UserIcons, got ", - e - ), - (this.#aV = e)); - } - #aW = null; - get supporter() { - return this.#aW; - } - set supporter(e) { - ("boolean" != typeof e && - "number" != typeof e && - null !== e && - console.warn( - "NewgroundsIO Type Mismatch: Value should be a boolean, got", - e - ), - (this.#aW = !!e)); - } - objectMap = { icons: "UserIcons" }; - } - (void 0 === NewgroundsIO.objects && (NewgroundsIO.objects = {}), - (NewgroundsIO.objects.User = e)); - })(), - (() => { - class e extends NewgroundsIO.BaseObject { - constructor(e) { - super(); - let t = this; - if ( - ((this.__object = "UserIcons"), - ["small", "medium", "large"].forEach((e) => { - 0 > t.__properties.indexOf(e) && t.__properties.push(e); - }), - e && "object" == typeof e) - ) - for (var s = 0; s < this.__properties.length; s++) - void 0 !== e[this.__properties[s]] && - (this[this.__properties[s]] = e[this.__properties[s]]); - } - #aX = null; - get small() { - return this.#aX; - } - set small(e) { - ("string" != typeof e && - null !== e && - console.warn( - "NewgroundsIO Type Mismatch: Value should be a string, got", - e - ), - (this.#aX = String(e))); - } - #aY = null; - get medium() { - return this.#aY; - } - set medium(e) { - ("string" != typeof e && - null !== e && - console.warn( - "NewgroundsIO Type Mismatch: Value should be a string, got", - e - ), - (this.#aY = String(e))); - } - #aZ = null; - get large() { - return this.#aZ; - } - set large(e) { - ("string" != typeof e && - null !== e && - console.warn( - "NewgroundsIO Type Mismatch: Value should be a string, got", - e - ), - (this.#aZ = String(e))); - } - } - (void 0 === NewgroundsIO.objects && (NewgroundsIO.objects = {}), - (NewgroundsIO.objects.UserIcons = e)); - })(), - (() => { - class e extends NewgroundsIO.BaseResult { - constructor(e) { - super(); - let t = this; - if ( - ((this.__object = "App.checkSession"), - ["session"].forEach((e) => { - 0 > t.__properties.indexOf(e) && t.__properties.push(e); - }), - e && "object" == typeof e) - ) - for (var s = 0; s < this.__properties.length; s++) - void 0 !== e[this.__properties[s]] && - (this[this.__properties[s]] = e[this.__properties[s]]); - } - #U = null; - get session() { - return this.#U; - } - set session(e) { - (e instanceof NewgroundsIO.objects.Session || - "object" != typeof e || - (e = new NewgroundsIO.objects.Session(e)), - null === e || - e instanceof NewgroundsIO.objects.Session || - console.warn( - "Type Mismatch: expecting NewgroundsIO.objects.Session, got ", - e - ), - (this.#U = e)); - } - objectMap = { session: "Session" }; - } - (void 0 === NewgroundsIO.results.App && (NewgroundsIO.results.App = {}), - (NewgroundsIO.results.App.checkSession = e)); - })(), - (() => { - class e extends NewgroundsIO.BaseResult { - constructor(e) { - super(); - let t = this; - if ( - ((this.__object = "App.getCurrentVersion"), - ["current_version", "client_deprecated"].forEach((e) => { - 0 > t.__properties.indexOf(e) && t.__properties.push(e); - }), - e && "object" == typeof e) - ) - for (var s = 0; s < this.__properties.length; s++) - void 0 !== e[this.__properties[s]] && - (this[this.__properties[s]] = e[this.__properties[s]]); - } - #a$ = null; - get current_version() { - return this.#a$; - } - set current_version(e) { - ("string" != typeof e && - null !== e && - console.warn( - "NewgroundsIO Type Mismatch: Value should be a string, got", - e - ), - (this.#a$ = String(e))); - } - #a_ = null; - get client_deprecated() { - return this.#a_; - } - set client_deprecated(e) { - ("boolean" != typeof e && - "number" != typeof e && - null !== e && - console.warn( - "NewgroundsIO Type Mismatch: Value should be a boolean, got", - e - ), - (this.#a_ = !!e)); - } - } - (void 0 === NewgroundsIO.results.App && (NewgroundsIO.results.App = {}), - (NewgroundsIO.results.App.getCurrentVersion = e)); - })(), - (() => { - class e extends NewgroundsIO.BaseResult { - constructor(e) { - super(); - let t = this; - if ( - ((this.__object = "App.getHostLicense"), - ["host_approved"].forEach((e) => { - 0 > t.__properties.indexOf(e) && t.__properties.push(e); - }), - e && "object" == typeof e) - ) - for (var s = 0; s < this.__properties.length; s++) - void 0 !== e[this.__properties[s]] && - (this[this.__properties[s]] = e[this.__properties[s]]); - } - #a0 = null; - get host_approved() { - return this.#a0; - } - set host_approved(e) { - ("boolean" != typeof e && - "number" != typeof e && - null !== e && - console.warn( - "NewgroundsIO Type Mismatch: Value should be a boolean, got", - e - ), - (this.#a0 = !!e)); - } - } - (void 0 === NewgroundsIO.results.App && (NewgroundsIO.results.App = {}), - (NewgroundsIO.results.App.getHostLicense = e)); - })(), - (() => { - class e extends NewgroundsIO.BaseResult { - constructor(e) { - super(); - let t = this; - if ( - ((this.__object = "App.startSession"), - ["session"].forEach((e) => { - 0 > t.__properties.indexOf(e) && t.__properties.push(e); - }), - e && "object" == typeof e) - ) - for (var s = 0; s < this.__properties.length; s++) - void 0 !== e[this.__properties[s]] && - (this[this.__properties[s]] = e[this.__properties[s]]); - } - #U = null; - get session() { - return this.#U; - } - set session(e) { - (e instanceof NewgroundsIO.objects.Session || - "object" != typeof e || - (e = new NewgroundsIO.objects.Session(e)), - null === e || - e instanceof NewgroundsIO.objects.Session || - console.warn( - "Type Mismatch: expecting NewgroundsIO.objects.Session, got ", - e - ), - (this.#U = e)); - } - objectMap = { session: "Session" }; - } - (void 0 === NewgroundsIO.results.App && (NewgroundsIO.results.App = {}), - (NewgroundsIO.results.App.startSession = e)); - })(), - (() => { - class e extends NewgroundsIO.BaseResult { - constructor(e) { - super(); - let t = this; - if ( - ((this.__object = "CloudSave.clearSlot"), - ["slot"].forEach((e) => { - 0 > t.__properties.indexOf(e) && t.__properties.push(e); - }), - e && "object" == typeof e) - ) - for (var s = 0; s < this.__properties.length; s++) - void 0 !== e[this.__properties[s]] && - (this[this.__properties[s]] = e[this.__properties[s]]); - } - #a1 = null; - get slot() { - return this.#a1; - } - set slot(e) { - (e instanceof NewgroundsIO.objects.SaveSlot || - "object" != typeof e || - (e = new NewgroundsIO.objects.SaveSlot(e)), - null === e || - e instanceof NewgroundsIO.objects.SaveSlot || - console.warn( - "Type Mismatch: expecting NewgroundsIO.objects.SaveSlot, got ", - e - ), - (this.#a1 = e)); - } - objectMap = { slot: "SaveSlot" }; - } - (void 0 === NewgroundsIO.results.CloudSave && - (NewgroundsIO.results.CloudSave = {}), - (NewgroundsIO.results.CloudSave.clearSlot = e)); - })(), - (() => { - class e extends NewgroundsIO.BaseResult { - constructor(e) { - super(); - let t = this; - if ( - ((this.__object = "CloudSave.loadSlot"), - ["slot", "app_id"].forEach((e) => { - 0 > t.__properties.indexOf(e) && t.__properties.push(e); - }), - e && "object" == typeof e) - ) - for (var s = 0; s < this.__properties.length; s++) - void 0 !== e[this.__properties[s]] && - (this[this.__properties[s]] = e[this.__properties[s]]); - } - #a1 = null; - get slot() { - return this.#a1; - } - set slot(e) { - (e instanceof NewgroundsIO.objects.SaveSlot || - "object" != typeof e || - (e = new NewgroundsIO.objects.SaveSlot(e)), - null === e || - e instanceof NewgroundsIO.objects.SaveSlot || - console.warn( - "Type Mismatch: expecting NewgroundsIO.objects.SaveSlot, got ", - e - ), - (this.#a1 = e)); - } - #Y = null; - get app_id() { - return this.#Y; - } - set app_id(e) { - ("string" != typeof e && - null !== e && - console.warn( - "NewgroundsIO Type Mismatch: Value should be a string, got", - e - ), - (this.#Y = String(e))); - } - objectMap = { slot: "SaveSlot" }; - } - (void 0 === NewgroundsIO.results.CloudSave && - (NewgroundsIO.results.CloudSave = {}), - (NewgroundsIO.results.CloudSave.loadSlot = e)); - })(), - (() => { - class e extends NewgroundsIO.BaseResult { - constructor(e) { - super(); - let t = this; - if ( - ((this.__object = "CloudSave.loadSlots"), - ["slots", "app_id"].forEach((e) => { - 0 > t.__properties.indexOf(e) && t.__properties.push(e); - }), - e && "object" == typeof e) - ) - for (var s = 0; s < this.__properties.length; s++) - void 0 !== e[this.__properties[s]] && - (this[this.__properties[s]] = e[this.__properties[s]]); - } - #a2 = null; - get slots() { - return this.#a2; - } - set slots(e) { - if (Array.isArray(e)) { - let t = []; - (e.forEach(function (e, s) { - (null === e || - e instanceof NewgroundsIO.objects.SaveSlot || - console.warn( - "Type Mismatch: expecting NewgroundsIO.objects.SaveSlot, got ", - e - ), - (t[s] = e)); - }), - (this.#a2 = t)); - return; - } - } - #Y = null; - get app_id() { - return this.#Y; - } - set app_id(e) { - ("string" != typeof e && - null !== e && - console.warn( - "NewgroundsIO Type Mismatch: Value should be a string, got", - e - ), - (this.#Y = String(e))); - } - arrayMap = { slots: "SaveSlot" }; - } - (void 0 === NewgroundsIO.results.CloudSave && - (NewgroundsIO.results.CloudSave = {}), - (NewgroundsIO.results.CloudSave.loadSlots = e)); - })(), - (() => { - class e extends NewgroundsIO.BaseResult { - constructor(e) { - super(); - let t = this; - if ( - ((this.__object = "CloudSave.setData"), - ["slot"].forEach((e) => { - 0 > t.__properties.indexOf(e) && t.__properties.push(e); - }), - e && "object" == typeof e) - ) - for (var s = 0; s < this.__properties.length; s++) - void 0 !== e[this.__properties[s]] && - (this[this.__properties[s]] = e[this.__properties[s]]); - } - #a1 = null; - get slot() { - return this.#a1; - } - set slot(e) { - (e instanceof NewgroundsIO.objects.SaveSlot || - "object" != typeof e || - (e = new NewgroundsIO.objects.SaveSlot(e)), - null === e || - e instanceof NewgroundsIO.objects.SaveSlot || - console.warn( - "Type Mismatch: expecting NewgroundsIO.objects.SaveSlot, got ", - e - ), - (this.#a1 = e)); - } - objectMap = { slot: "SaveSlot" }; - } - (void 0 === NewgroundsIO.results.CloudSave && - (NewgroundsIO.results.CloudSave = {}), - (NewgroundsIO.results.CloudSave.setData = e)); - })(), - (() => { - class e extends NewgroundsIO.BaseResult { - constructor(e) { - super(); - let t = this; - if ( - ((this.__object = "Event.logEvent"), - ["event_name"].forEach((e) => { - 0 > t.__properties.indexOf(e) && t.__properties.push(e); - }), - e && "object" == typeof e) - ) - for (var s = 0; s < this.__properties.length; s++) - void 0 !== e[this.__properties[s]] && - (this[this.__properties[s]] = e[this.__properties[s]]); - } - #$ = null; - get event_name() { - return this.#$; - } - set event_name(e) { - ("string" != typeof e && - null !== e && - console.warn( - "NewgroundsIO Type Mismatch: Value should be a string, got", - e - ), - (this.#$ = String(e))); - } - } - (void 0 === NewgroundsIO.results.Event && - (NewgroundsIO.results.Event = {}), - (NewgroundsIO.results.Event.logEvent = e)); - })(), - (() => { - class e extends NewgroundsIO.BaseResult { - constructor(e) { - super(); - let t = this; - if ( - ((this.__object = "Gateway.getDatetime"), - ["datetime", "timestamp"].forEach((e) => { - 0 > t.__properties.indexOf(e) && t.__properties.push(e); - }), - e && "object" == typeof e) - ) - for (var s = 0; s < this.__properties.length; s++) - void 0 !== e[this.__properties[s]] && - (this[this.__properties[s]] = e[this.__properties[s]]); - } - #aE = null; - get datetime() { - return this.#aE; - } - set datetime(e) { - ("string" != typeof e && - null !== e && - console.warn( - "NewgroundsIO Type Mismatch: Value should be a string, got", - e - ), - (this.#aE = String(e))); - } - #aF = null; - get timestamp() { - return this.#aF; - } - set timestamp(e) { - ("number" != typeof e && null !== e - ? console.warn( - "NewgroundsIO Type Mismatch: Value should be a number, got", - e - ) - : Number.isInteger(e) || - null === e || - console.warn( - "NewgroundsIO Type Mismatch: Value should be an integer, got a float" - ), - (this.#aF = Number(e)), - isNaN(this.#aF) && (this.#aF = null)); - } - } - (void 0 === NewgroundsIO.results.Gateway && - (NewgroundsIO.results.Gateway = {}), - (NewgroundsIO.results.Gateway.getDatetime = e)); - })(), - (() => { - class e extends NewgroundsIO.BaseResult { - constructor(e) { - super(); - let t = this; - if ( - ((this.__object = "Gateway.getVersion"), - ["version"].forEach((e) => { - 0 > t.__properties.indexOf(e) && t.__properties.push(e); - }), - e && "object" == typeof e) - ) - for (var s = 0; s < this.__properties.length; s++) - void 0 !== e[this.__properties[s]] && - (this[this.__properties[s]] = e[this.__properties[s]]); - } - #x = null; - get version() { - return this.#x; - } - set version(e) { - ("string" != typeof e && - null !== e && - console.warn( - "NewgroundsIO Type Mismatch: Value should be a string, got", - e - ), - (this.#x = String(e))); - } - } - (void 0 === NewgroundsIO.results.Gateway && - (NewgroundsIO.results.Gateway = {}), - (NewgroundsIO.results.Gateway.getVersion = e)); - })(), - (() => { - class e extends NewgroundsIO.BaseResult { - constructor(e) { - super(); - let t = this; - if ( - ((this.__object = "Gateway.ping"), - ["pong"].forEach((e) => { - 0 > t.__properties.indexOf(e) && t.__properties.push(e); - }), - e && "object" == typeof e) - ) - for (var s = 0; s < this.__properties.length; s++) - void 0 !== e[this.__properties[s]] && - (this[this.__properties[s]] = e[this.__properties[s]]); - } - #a3 = null; - get pong() { - return this.#a3; - } - set pong(e) { - ("string" != typeof e && - null !== e && - console.warn( - "NewgroundsIO Type Mismatch: Value should be a string, got", - e - ), - (this.#a3 = String(e))); - } - } - (void 0 === NewgroundsIO.results.Gateway && - (NewgroundsIO.results.Gateway = {}), - (NewgroundsIO.results.Gateway.ping = e)); - })(), - (() => { - class e extends NewgroundsIO.BaseResult { - constructor(e) { - super(); - let t = this; - if ( - ((this.__object = "Loader.loadAuthorUrl"), - ["url"].forEach((e) => { - 0 > t.__properties.indexOf(e) && t.__properties.push(e); - }), - e && "object" == typeof e) - ) - for (var s = 0; s < this.__properties.length; s++) - void 0 !== e[this.__properties[s]] && - (this[this.__properties[s]] = e[this.__properties[s]]); - } - #aG = null; - get url() { - return this.#aG; - } - set url(e) { - ("string" != typeof e && - null !== e && - console.warn( - "NewgroundsIO Type Mismatch: Value should be a string, got", - e - ), - (this.#aG = String(e))); - } - } - (void 0 === NewgroundsIO.results.Loader && - (NewgroundsIO.results.Loader = {}), - (NewgroundsIO.results.Loader.loadAuthorUrl = e)); - })(), - (() => { - class e extends NewgroundsIO.BaseResult { - constructor(e) { - super(); - let t = this; - if ( - ((this.__object = "Loader.loadMoreGames"), - ["url"].forEach((e) => { - 0 > t.__properties.indexOf(e) && t.__properties.push(e); - }), - e && "object" == typeof e) - ) - for (var s = 0; s < this.__properties.length; s++) - void 0 !== e[this.__properties[s]] && - (this[this.__properties[s]] = e[this.__properties[s]]); - } - #aG = null; - get url() { - return this.#aG; - } - set url(e) { - ("string" != typeof e && - null !== e && - console.warn( - "NewgroundsIO Type Mismatch: Value should be a string, got", - e - ), - (this.#aG = String(e))); - } - } - (void 0 === NewgroundsIO.results.Loader && - (NewgroundsIO.results.Loader = {}), - (NewgroundsIO.results.Loader.loadMoreGames = e)); - })(), - (() => { - class e extends NewgroundsIO.BaseResult { - constructor(e) { - super(); - let t = this; - if ( - ((this.__object = "Loader.loadNewgrounds"), - ["url"].forEach((e) => { - 0 > t.__properties.indexOf(e) && t.__properties.push(e); - }), - e && "object" == typeof e) - ) - for (var s = 0; s < this.__properties.length; s++) - void 0 !== e[this.__properties[s]] && - (this[this.__properties[s]] = e[this.__properties[s]]); - } - #aG = null; - get url() { - return this.#aG; - } - set url(e) { - ("string" != typeof e && - null !== e && - console.warn( - "NewgroundsIO Type Mismatch: Value should be a string, got", - e - ), - (this.#aG = String(e))); - } - } - (void 0 === NewgroundsIO.results.Loader && - (NewgroundsIO.results.Loader = {}), - (NewgroundsIO.results.Loader.loadNewgrounds = e)); - })(), - (() => { - class e extends NewgroundsIO.BaseResult { - constructor(e) { - super(); - let t = this; - if ( - ((this.__object = "Loader.loadOfficialUrl"), - ["url"].forEach((e) => { - 0 > t.__properties.indexOf(e) && t.__properties.push(e); - }), - e && "object" == typeof e) - ) - for (var s = 0; s < this.__properties.length; s++) - void 0 !== e[this.__properties[s]] && - (this[this.__properties[s]] = e[this.__properties[s]]); - } - #aG = null; - get url() { - return this.#aG; - } - set url(e) { - ("string" != typeof e && - null !== e && - console.warn( - "NewgroundsIO Type Mismatch: Value should be a string, got", - e - ), - (this.#aG = String(e))); - } - } - (void 0 === NewgroundsIO.results.Loader && - (NewgroundsIO.results.Loader = {}), - (NewgroundsIO.results.Loader.loadOfficialUrl = e)); - })(), - (() => { - class e extends NewgroundsIO.BaseResult { - constructor(e) { - super(); - let t = this; - if ( - ((this.__object = "Loader.loadReferral"), - ["url"].forEach((e) => { - 0 > t.__properties.indexOf(e) && t.__properties.push(e); - }), - e && "object" == typeof e) - ) - for (var s = 0; s < this.__properties.length; s++) - void 0 !== e[this.__properties[s]] && - (this[this.__properties[s]] = e[this.__properties[s]]); - } - #aG = null; - get url() { - return this.#aG; - } - set url(e) { - ("string" != typeof e && - null !== e && - console.warn( - "NewgroundsIO Type Mismatch: Value should be a string, got", - e - ), - (this.#aG = String(e))); - } - } - (void 0 === NewgroundsIO.results.Loader && - (NewgroundsIO.results.Loader = {}), - (NewgroundsIO.results.Loader.loadReferral = e)); - })(), - (() => { - class e extends NewgroundsIO.BaseResult { - constructor(e) { - super(); - let t = this; - if ( - ((this.__object = "Medal.getList"), - ["medals", "app_id"].forEach((e) => { - 0 > t.__properties.indexOf(e) && t.__properties.push(e); - }), - e && "object" == typeof e) - ) - for (var s = 0; s < this.__properties.length; s++) - void 0 !== e[this.__properties[s]] && - (this[this.__properties[s]] = e[this.__properties[s]]); - } - #d = null; - get medals() { - return this.#d; - } - set medals(e) { - if (Array.isArray(e)) { - let t = []; - (e.forEach(function (e, s) { - (null === e || - e instanceof NewgroundsIO.objects.Medal || - console.warn( - "Type Mismatch: expecting NewgroundsIO.objects.Medal, got ", - e - ), - (t[s] = e)); - }), - (this.#d = t)); - return; - } - } - #Y = null; - get app_id() { - return this.#Y; - } - set app_id(e) { - ("string" != typeof e && - null !== e && - console.warn( - "NewgroundsIO Type Mismatch: Value should be a string, got", - e - ), - (this.#Y = String(e))); - } - arrayMap = { medals: "Medal" }; - } - (void 0 === NewgroundsIO.results.Medal && - (NewgroundsIO.results.Medal = {}), - (NewgroundsIO.results.Medal.getList = e)); - })(), - (() => { - class e extends NewgroundsIO.BaseResult { - constructor(e) { - super(); - let t = this; - if ( - ((this.__object = "Medal.getMedalScore"), - ["medal_score"].forEach((e) => { - 0 > t.__properties.indexOf(e) && t.__properties.push(e); - }), - e && "object" == typeof e) - ) - for (var s = 0; s < this.__properties.length; s++) - void 0 !== e[this.__properties[s]] && - (this[this.__properties[s]] = e[this.__properties[s]]); - } - #a4 = null; - get medal_score() { - return this.#a4; - } - set medal_score(e) { - ("number" != typeof e && null !== e - ? console.warn( - "NewgroundsIO Type Mismatch: Value should be a number, got", - e - ) - : Number.isInteger(e) || - null === e || - console.warn( - "NewgroundsIO Type Mismatch: Value should be an integer, got a float" - ), - (this.#a4 = Number(e)), - isNaN(this.#a4) && (this.#a4 = null)); - } - } - (void 0 === NewgroundsIO.results.Medal && - (NewgroundsIO.results.Medal = {}), - (NewgroundsIO.results.Medal.getMedalScore = e)); - })(), - (() => { - class e extends NewgroundsIO.BaseResult { - constructor(e) { - super(); - let t = this; - if ( - ((this.__object = "Medal.unlock"), - ["medal", "medal_score"].forEach((e) => { - 0 > t.__properties.indexOf(e) && t.__properties.push(e); - }), - e && "object" == typeof e) - ) - for (var s = 0; s < this.__properties.length; s++) - void 0 !== e[this.__properties[s]] && - (this[this.__properties[s]] = e[this.__properties[s]]); - } - #a5 = null; - get medal() { - return this.#a5; - } - set medal(e) { - (e instanceof NewgroundsIO.objects.Medal || - "object" != typeof e || - (e = new NewgroundsIO.objects.Medal(e)), - null === e || - e instanceof NewgroundsIO.objects.Medal || - console.warn( - "Type Mismatch: expecting NewgroundsIO.objects.Medal, got ", - e - ), - (this.#a5 = e)); - } - #a4 = null; - get medal_score() { - return this.#a4; - } - set medal_score(e) { - ("number" != typeof e && null !== e - ? console.warn( - "NewgroundsIO Type Mismatch: Value should be a number, got", - e - ) - : Number.isInteger(e) || - null === e || - console.warn( - "NewgroundsIO Type Mismatch: Value should be an integer, got a float" - ), - (this.#a4 = Number(e)), - isNaN(this.#a4) && (this.#a4 = null)); - } - objectMap = { medal: "Medal" }; - } - (void 0 === NewgroundsIO.results.Medal && - (NewgroundsIO.results.Medal = {}), - (NewgroundsIO.results.Medal.unlock = e)); - })(), - (() => { - class e extends NewgroundsIO.BaseResult { - constructor(e) { - super(); - let t = this; - if ( - ((this.__object = "ScoreBoard.getBoards"), - ["scoreboards"].forEach((e) => { - 0 > t.__properties.indexOf(e) && t.__properties.push(e); - }), - e && "object" == typeof e) - ) - for (var s = 0; s < this.__properties.length; s++) - void 0 !== e[this.__properties[s]] && - (this[this.__properties[s]] = e[this.__properties[s]]); - } - #a6 = null; - get scoreboards() { - return this.#a6; - } - set scoreboards(e) { - if (Array.isArray(e)) { - let t = []; - (e.forEach(function (e, s) { - (null === e || - e instanceof NewgroundsIO.objects.ScoreBoard || - console.warn( - "Type Mismatch: expecting NewgroundsIO.objects.ScoreBoard, got ", - e - ), - (t[s] = e)); - }), - (this.#a6 = t)); - return; - } - } - arrayMap = { scoreboards: "ScoreBoard" }; - } - (void 0 === NewgroundsIO.results.ScoreBoard && - (NewgroundsIO.results.ScoreBoard = {}), - (NewgroundsIO.results.ScoreBoard.getBoards = e)); - })(), - (() => { - class e extends NewgroundsIO.BaseResult { - constructor(e) { - super(); - let t = this; - if ( - ((this.__object = "ScoreBoard.getScores"), - [ - "period", - "social", - "limit", - "scoreboard", - "scores", - "user", - "app_id", - ].forEach((e) => { - 0 > t.__properties.indexOf(e) && t.__properties.push(e); - }), - e && "object" == typeof e) - ) - for (var s = 0; s < this.__properties.length; s++) - void 0 !== e[this.__properties[s]] && - (this[this.__properties[s]] = e[this.__properties[s]]); - } - #ac = null; - get period() { - return this.#ac; - } - set period(e) { - ("string" != typeof e && - null !== e && - console.warn( - "NewgroundsIO Type Mismatch: Value should be a string, got", - e - ), - (this.#ac = String(e))); - } - #ae = null; - get social() { - return this.#ae; - } - set social(e) { - ("boolean" != typeof e && - "number" != typeof e && - null !== e && - console.warn( - "NewgroundsIO Type Mismatch: Value should be a boolean, got", - e - ), - (this.#ae = !!e)); - } - #ah = null; - get limit() { - return this.#ah; - } - set limit(e) { - ("number" != typeof e && null !== e - ? console.warn( - "NewgroundsIO Type Mismatch: Value should be a number, got", - e - ) - : Number.isInteger(e) || - null === e || - console.warn( - "NewgroundsIO Type Mismatch: Value should be an integer, got a float" - ), - (this.#ah = Number(e)), - isNaN(this.#ah) && (this.#ah = null)); - } - #a7 = null; - get scoreboard() { - return this.#a7; - } - set scoreboard(e) { - (e instanceof NewgroundsIO.objects.ScoreBoard || - "object" != typeof e || - (e = new NewgroundsIO.objects.ScoreBoard(e)), - null === e || - e instanceof NewgroundsIO.objects.ScoreBoard || - console.warn( - "Type Mismatch: expecting NewgroundsIO.objects.ScoreBoard, got ", - e - ), - (this.#a7 = e)); - } - #a8 = null; - get scores() { - return this.#a8; - } - set scores(e) { - if (Array.isArray(e)) { - let t = []; - (e.forEach(function (e, s) { - (null === e || - e instanceof NewgroundsIO.objects.Score || - console.warn( - "Type Mismatch: expecting NewgroundsIO.objects.Score, got ", - e - ), - (t[s] = e)); - }), - (this.#a8 = t)); - return; - } - } - #af = null; - get user() { - return this.#af; - } - set user(e) { - (e instanceof NewgroundsIO.objects.User || - "object" != typeof e || - (e = new NewgroundsIO.objects.User(e)), - null === e || - e instanceof NewgroundsIO.objects.User || - console.warn( - "Type Mismatch: expecting NewgroundsIO.objects.User, got ", - e - ), - (this.#af = e)); - } - #Y = null; - get app_id() { - return this.#Y; - } - set app_id(e) { - ("string" != typeof e && - null !== e && - console.warn( - "NewgroundsIO Type Mismatch: Value should be a string, got", - e - ), - (this.#Y = String(e))); - } - objectMap = { scoreboard: "ScoreBoard", user: "User" }; - arrayMap = { scores: "Score" }; - } - (void 0 === NewgroundsIO.results.ScoreBoard && - (NewgroundsIO.results.ScoreBoard = {}), - (NewgroundsIO.results.ScoreBoard.getScores = e)); - })(), - (() => { - class e extends NewgroundsIO.BaseResult { - constructor(e) { - super(); - let t = this; - if ( - ((this.__object = "ScoreBoard.postScore"), - ["scoreboard", "score"].forEach((e) => { - 0 > t.__properties.indexOf(e) && t.__properties.push(e); - }), - e && "object" == typeof e) - ) - for (var s = 0; s < this.__properties.length; s++) - void 0 !== e[this.__properties[s]] && - (this[this.__properties[s]] = e[this.__properties[s]]); - } - #a7 = null; - get scoreboard() { - return this.#a7; - } - set scoreboard(e) { - (e instanceof NewgroundsIO.objects.ScoreBoard || - "object" != typeof e || - (e = new NewgroundsIO.objects.ScoreBoard(e)), - null === e || - e instanceof NewgroundsIO.objects.ScoreBoard || - console.warn( - "Type Mismatch: expecting NewgroundsIO.objects.ScoreBoard, got ", - e - ), - (this.#a7 = e)); - } - #a9 = null; - get score() { - return this.#a9; - } - set score(e) { - (e instanceof NewgroundsIO.objects.Score || - "object" != typeof e || - (e = new NewgroundsIO.objects.Score(e)), - null === e || - e instanceof NewgroundsIO.objects.Score || - console.warn( - "Type Mismatch: expecting NewgroundsIO.objects.Score, got ", - e - ), - (this.#a9 = e)); - } - objectMap = { scoreboard: "ScoreBoard", score: "Score" }; - } - (void 0 === NewgroundsIO.results.ScoreBoard && - (NewgroundsIO.results.ScoreBoard = {}), - (NewgroundsIO.results.ScoreBoard.postScore = e)); - })()); + { + NGIO = class{static get STATUS_INITIALIZED(){return"initialized"}static get STATUS_CHECKING_LOCAL_VERSION(){return"checking-local-version"}static get STATUS_LOCAL_VERSION_CHECKED(){return"local-version-checked"}static get STATUS_PRELOADING_ITEMS(){return"preloading-items"}static get STATUS_ITEMS_PRELOADED(){return"items-preloaded"}static get STATUS_READY(){return"ready"}static get STATUS_SESSION_UNINITIALIZED(){return NewgroundsIO.SessionState.SESSION_UNINITIALIZED}static get STATUS_WAITING_FOR_SERVER(){return NewgroundsIO.SessionState.WAITING_FOR_SERVER}static get STATUS_LOGIN_REQUIRED(){return NewgroundsIO.SessionState.LOGIN_REQUIRED}static get STATUS_WAITING_FOR_USER(){return NewgroundsIO.SessionState.WAITING_FOR_USER}static get STATUS_LOGIN_CANCELLED(){return NewgroundsIO.SessionState.LOGIN_CANCELLED}static get STATUS_LOGIN_SUCCESSFUL(){return NewgroundsIO.SessionState.LOGIN_SUCCESSFUL}static get STATUS_LOGIN_FAILED(){return NewgroundsIO.SessionState.LOGIN_FAILED}static get STATUS_USER_LOGGED_OUT(){return NewgroundsIO.SessionState.USER_LOGGED_OUT}static get STATUS_SERVER_UNAVAILABLE(){return NewgroundsIO.SessionState.SERVER_UNAVAILABLE}static get STATUS_EXCEEDED_MAX_ATTEMPTS(){return NewgroundsIO.SessionState.EXCEEDED_MAX_ATTEMPTS}static get isWaitingStatus(){return NewgroundsIO.SessionState.SESSION_WAITING.indexOf(this.#a)>=0||[this.STATUS_PRELOADING_ITEMS,this.LOCAL_VERSION_CHECKED,this.STATUS_CHECKING_LOCAL_VERSION].indexOf(this.#a)>=0}static get PERIOD_TODAY(){return"D"}static get PERIOD_CURRENT_WEEK(){return"W"}static get PERIOD_CURRENT_MONTH(){return"M"}static get PERIOD_CURRENT_YEAR(){return"Y"}static get PERIOD_ALL_TIME(){return"A"}static get PERIODS(){return[NGIO.PERIOD_TODAY,NGIO.PERIOD_CURRENT_WEEK,NGIO.PERIOD_CURRENT_MONTH,NGIO.PERIOD_CURRENT_YEAR,NGIO.PERIOD_ALL_TIME]}static get ngioCore(){return this.#b}static #b=null;static get medalScore(){return this.#c}static #c=-1;static get medals(){return this.#d}static #d=null;static get scoreBoards(){return this.#e}static #e=null;static get saveSlots(){return this.#f}static #f=null;static get lastExecution(){return this.#g}static #g=new Date;static get lastConnectionStatus(){return this.#a}static #a=new Date;static get sessionError(){return this.#h}static #h=null;static get legalHost(){return this.#i}static #i=!0;static get isDeprecated(){return this.#j}static #j=!0;static get newestVersion(){return this.#k}static #k=!0;static get loginPageOpen(){return this.#l}static #l=!1;static get gatewayVersion(){return this.#m}static #m=!0;static get lastMedalUnlocked(){return this.#n}static #n=!0;static get lastBoardPosted(){return this.#o}static #o=!0;static get lastScorePosted(){return this.#p}static #p=!0;static get lastGetScoresResult(){return this.#q}static #q=!0;static get lastSaveSlotLoaded(){return this.#r}static #r=!0;static get lastSaveSlotSaved(){return this.#s}static #s=!0;static get lastDateTime(){return this.#t}static #t="0000-00-00";static get lastLoggedEvent(){return this.#u}static #u=null;static get lastTimeStamp(){return this.#v}static #v=0;static get lastPingSuccess(){return this.#w}static #w=!0;static get isInitialized(){return null!==this.ngioCore}static get session(){return this.isInitialized?this.ngioCore.session:null}static get user(){return null===this.session?null:this.ngioCore.session.user}static get hasSession(){return null!==this.session}static get hasUser(){return null!==this.user}static get isReady(){return this.#a===this.STATUS_READY}static get version(){return this.#x}static #x="0.0.0";static get debugMode(){return this.#y}static #y=!1;static #z={autoLogNewView:!1,preloadMedals:!1,preloadScoreBoards:!1,preloadSaveSlots:!1};static #A=!1;static #B=!1;static #C=!1;static #D=!1;static init(e,t,s){if(!this.isInitialized){if(this.#b=new NewgroundsIO.Core(e,t),this.#b.addEventListener("serverResponse",function(e){NGIO.#E(e)}),s&&"object"==typeof s){"string"==typeof s.version&&(this.#x=s.version);let o=["debugMode","checkHostLicense","autoLogNewView","preloadMedals","preloadScoreBoards","preloadSaveSlots"];for(let r=0;r{t.hasData&&e++}),e}static getSaveSlotData(e,t,s){null===this.saveSlots&&(console.error("getSaveSlotData data called without any preloaded save slots."),s?t.call(s,null):t(null));let o=this.getSaveSlot(e);this.#r=o,o.getData(t,s)}static setSaveSlotData(e,t,s,o){if(null==this.saveSlots){console.error("setSaveSlotData data called without any preloaded save slots."),"function"==typeof s&&(o?s(o,null):s(null));return}var r=this.getSaveSlot(e);if(null==r){console.error("Slot #"+e+" does not exist."),"function"==typeof s&&(o?s(o,null):s(null));return}r.setData(t,function(){"function"==typeof s&&(o?s(o,this.lastSaveSlotSaved):s(this.lastSaveSlotSaved))},this)}static logEvent(e,t,s){this.ngioCore.executeComponent(this.ngioCore.getComponent("Event.logEvent",{event_name:e}),function(){"function"==typeof t&&(s?t(s,this.lastLoggedEvent):t(this.lastLoggedEvent))},this)}static getDateTime(e,t){this.ngioCore.executeComponent(this.ngioCore.getComponent("Gateway.getDatetime"),function(){"function"==typeof e&&(t?e(t,this.lastDateTime,this.lastTimeStamp):e(this.lastDateTime,this.lastTimeStamp))},this)}static keepSessionAlive(){if(this.hasUser)(new Date-this.#g).Seconds>=3e4&&(this.#g=new Date,this.ngioCore.executeComponent(this.ngioCore.getComponent("Gateway.ping")))}static getConnectionStatus(e,t){this.#D||null===this.#a||null==this.session||(this.#D=!0,this.#a===this.STATUS_INITIALIZED?(this.#a=this.STATUS_CHECKING_LOCAL_VERSION,this.#G(e,t),this.#H(e,t)):this.#A?this.#a===this.STATUS_LOGIN_SUCCESSFUL?(this.#a=this.STATUS_PRELOADING_ITEMS,this.#G(e,t),this.#I(function(){this.#G(e,t),this.#B=!1},this)):this.#a===this.STATUS_ITEMS_PRELOADED?(this.#l=!1,this.#a=this.STATUS_READY,this.#G(e,t),this.#B=!1):this.keepSessionAlive():this.#B?this.#J(e,t):this.#a!==this.STATUS_CHECKING_LOCAL_VERSION&&this.session.update(function(){this.#J(e,t)},this),this.#D=!1)}static #J(e,t){(this.session.statusChanged||this.#B)&&(this.#a=this.session.status,(this.session.status==NewgroundsIO.SessionState.LOGIN_SUCCESSFUL||this.#B)&&(this.#a=NewgroundsIO.SessionState.LOGIN_SUCCESSFUL,this.#A=!0),this.#G(e,t)),this.#B=!1}static #G(s,o){o?s.call(o,this.#a):s(this.#a)}static #H(r,i){if(this.#C){this.#a=this.STATUS_LOCAL_VERSION_CHECKED,this.#G(r,i);return}this.ngioCore.queueComponent(this.ngioCore.getComponent("App.getCurrentVersion",{version:this.#x})),this.ngioCore.queueComponent(this.ngioCore.getComponent("Gateway.getVersion")),this.#z.autoLogNewView&&this.ngioCore.queueComponent(this.ngioCore.getComponent("App.logView")),this.#z.checkHostLicense&&this.ngioCore.queueComponent(this.ngioCore.getComponent("App.getHostLicense")),this.ngioCore.executeQueue(function(){this.#a=this.STATUS_LOCAL_VERSION_CHECKED,this.#C=!0,this.#G(r,i),this.#j&&console.warn("NGIO - Version mistmatch! Published version is: "+this.#k+", this version is: "+this.version),this.#i||(console.warn("NGIO - This host has been blocked fom hosting this game!"),this.#A=!0,this.#a=this.STATUS_ITEMS_PRELOADED,this.#G(r,i))},this)}static #I(){this.#z.preloadMedals&&(this.ngioCore.queueComponent(this.ngioCore.getComponent("Medal.getMedalScore")),this.ngioCore.queueComponent(this.ngioCore.getComponent("Medal.getList"))),this.#z.preloadScoreBoards&&this.ngioCore.queueComponent(this.ngioCore.getComponent("ScoreBoard.getBoards")),null!==this.user&&this.#z.preloadSaveSlots&&this.ngioCore.queueComponent(this.ngioCore.getComponent("CloudSave.loadSlots")),this.ngioCore.hasQueue?this.ngioCore.executeQueue(function(){this.#a=this.STATUS_ITEMS_PRELOADED},this):this.#a=this.STATUS_ITEMS_PRELOADED}static #F(){this.#a=this.STATUS_INITIALIZED,this.#l=!1,this.#B=!1,this.#A=!1}static #K(n){if(this.#f){let a=this.#f.length;for(let u=0;u>>2]|=(s[r>>>2]>>>24-8*(r%4)&255)<<24-8*((o+r)%4);else if(65535>>2]=s[r>>>2];else t.push.apply(t,s);return this.sigBytes+=e,this},clamp:function(){var t=this.words,s=this.sigBytes;t[s>>>2]&=4294967295<<32-8*(s%4),t.length=e.ceil(s/4)},clone:function(){var e=i.clone.call(this);return e.words=this.words.slice(0),e},random:function(t){for(var s=[],o=0;o>>2]>>>24-8*(o%4)&255;s.push((r>>>4).toString(16)),s.push((15&r).toString(16))}return s.join("")},parse:function(e){for(var t=e.length,s=[],o=0;o>>3]|=parseInt(e.substr(o,2),16)<<24-4*(o%8);return new n.init(s,t/2)}},l=a.Latin1={stringify:function(e){var t=e.words;e=e.sigBytes;for(var s=[],o=0;o>>2]>>>24-8*(o%4)&255));return s.join("")},parse:function(e){for(var t=e.length,s=[],o=0;o>>2]|=(255&e.charCodeAt(o))<<24-8*(o%4);return new n.init(s,t)}},p=a.Utf8={stringify:function(e){try{return decodeURIComponent(escape(l.stringify(e)))}catch(t){throw Error("Malformed UTF-8 data")}},parse:function(e){return l.parse(unescape(encodeURIComponent(e)))}},c=o.BufferedBlockAlgorithm=i.extend({reset:function(){this._data=new n.init,this._nDataBytes=0},_append:function(e){"string"==typeof e&&(e=p.parse(e)),this._data.concat(e),this._nDataBytes+=e.sigBytes},_process:function(t){var s=this._data,o=s.words,r=s.sigBytes,i=this.blockSize,a=r/(4*i),a=t?e.ceil(a):e.max((0|a)-this._minBufferSize,0);if(t=a*i,r=e.min(4*t,r),t){for(var u=0;u>>2]>>>24-8*(r%4)&255)<<16|(t[r+1>>>2]>>>24-8*((r+1)%4)&255)<<8|t[r+2>>>2]>>>24-8*((r+2)%4)&255,n=0;4>n&&r+.75*n>>6*(3-n)&63));if(t=o.charAt(64))for(;e.length%4;)e.push(t);return e.join("")},parse:function(e){var s=e.length,o=this._map,r=o.charAt(64);r&&-1!=(r=e.indexOf(r))&&(s=r);for(var r=[],i=0,n=0;n>>6-2*(n%4);r[i>>>2]|=(a|u)<<24-8*(i%4),i++}return t.create(r,i)},_map:"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/="}}(),function(e){function t(e,t,s,o,r,i,n){return((e=e+(t&s|~t&o)+r+n)<>>32-i)+t}function s(e,t,s,o,r,i,n){return((e=e+(t&o|s&~o)+r+n)<>>32-i)+t}function o(e,t,s,o,r,i,n){return((e=e+(t^s^o)+r+n)<>>32-i)+t}function r(e,t,s,o,r,i,n){return((e=e+(s^(t|~o))+r+n)<>>32-i)+t}for(var i=CryptoJS,n=i.lib,a=n.WordArray,u=n.Hasher,n=i.algo,l=[],p=0;64>p;p++)l[p]=4294967296*e.abs(e.sin(p+1))|0;n=n.MD5=u.extend({_doReset:function(){this._hash=new a.init([1732584193,4023233417,2562383102,271733878])},_doProcessBlock:function(e,i){for(var n=0;16>n;n++){var a=i+n,u=e[a];e[a]=(u<<8|u>>>24)&16711935|(u<<24|u>>>8)&4278255360}var n=this._hash.words,a=e[i+0],u=e[i+1],p=e[i+2],c=e[i+3],h=e[i+4],d=e[i+5],g=e[i+6],f=e[i+7],w=e[i+8],O=e[i+9],I=e[i+10],m=e[i+11],S=e[i+12],N=e[i+13],b=e[i+14],y=e[i+15],v=n[0],$=n[1],C=n[2],E=n[3],v=t(v,$,C,E,a,7,l[0]),E=t(E,v,$,C,u,12,l[1]),C=t(C,E,v,$,p,17,l[2]),$=t($,C,E,v,c,22,l[3]),v=t(v,$,C,E,h,7,l[4]),E=t(E,v,$,C,d,12,l[5]),C=t(C,E,v,$,g,17,l[6]),$=t($,C,E,v,f,22,l[7]),v=t(v,$,C,E,w,7,l[8]),E=t(E,v,$,C,O,12,l[9]),C=t(C,E,v,$,I,17,l[10]),$=t($,C,E,v,m,22,l[11]),v=t(v,$,C,E,S,7,l[12]),E=t(E,v,$,C,N,12,l[13]),C=t(C,E,v,$,b,17,l[14]),$=t($,C,E,v,y,22,l[15]),v=s(v,$,C,E,u,5,l[16]),E=s(E,v,$,C,g,9,l[17]),C=s(C,E,v,$,m,14,l[18]),$=s($,C,E,v,a,20,l[19]),v=s(v,$,C,E,d,5,l[20]),E=s(E,v,$,C,I,9,l[21]),C=s(C,E,v,$,y,14,l[22]),$=s($,C,E,v,h,20,l[23]),v=s(v,$,C,E,O,5,l[24]),E=s(E,v,$,C,b,9,l[25]),C=s(C,E,v,$,c,14,l[26]),$=s($,C,E,v,w,20,l[27]),v=s(v,$,C,E,N,5,l[28]),E=s(E,v,$,C,p,9,l[29]),C=s(C,E,v,$,f,14,l[30]),$=s($,C,E,v,S,20,l[31]),v=o(v,$,C,E,d,4,l[32]),E=o(E,v,$,C,w,11,l[33]),C=o(C,E,v,$,m,16,l[34]),$=o($,C,E,v,b,23,l[35]),v=o(v,$,C,E,u,4,l[36]),E=o(E,v,$,C,h,11,l[37]),C=o(C,E,v,$,f,16,l[38]),$=o($,C,E,v,I,23,l[39]),v=o(v,$,C,E,N,4,l[40]),E=o(E,v,$,C,a,11,l[41]),C=o(C,E,v,$,c,16,l[42]),$=o($,C,E,v,g,23,l[43]),v=o(v,$,C,E,O,4,l[44]),E=o(E,v,$,C,S,11,l[45]),C=o(C,E,v,$,y,16,l[46]),$=o($,C,E,v,p,23,l[47]),v=r(v,$,C,E,a,6,l[48]),E=r(E,v,$,C,f,10,l[49]),C=r(C,E,v,$,b,15,l[50]),$=r($,C,E,v,d,21,l[51]),v=r(v,$,C,E,S,6,l[52]),E=r(E,v,$,C,c,10,l[53]),C=r(C,E,v,$,I,15,l[54]),$=r($,C,E,v,u,21,l[55]),v=r(v,$,C,E,w,6,l[56]),E=r(E,v,$,C,y,10,l[57]),C=r(C,E,v,$,g,15,l[58]),$=r($,C,E,v,N,21,l[59]),v=r(v,$,C,E,h,6,l[60]),E=r(E,v,$,C,m,10,l[61]),C=r(C,E,v,$,p,15,l[62]),$=r($,C,E,v,O,21,l[63]);n[0]=n[0]+v|0,n[1]=n[1]+$|0,n[2]=n[2]+C|0,n[3]=n[3]+E|0},_doFinalize:function(){var t=this._data,s=t.words,o=8*this._nDataBytes,r=8*t.sigBytes;s[r>>>5]|=128<<24-r%32;var i=e.floor(o/4294967296);for(s[(r+64>>>9<<4)+15]=(i<<8|i>>>24)&16711935|(i<<24|i>>>8)&4278255360,s[(r+64>>>9<<4)+14]=(o<<8|o>>>24)&16711935|(o<<24|o>>>8)&4278255360,t.sigBytes=4*(s.length+1),this._process(),s=(t=this._hash).words,o=0;4>o;o++)r=s[o],s[o]=(r<<8|r>>>24)&16711935|(r<<24|r>>>8)&4278255360;return t},clone:function(){var e=u.clone.call(this);return e._hash=this._hash.clone(),e}}),i.MD5=u._createHelper(n),i.HmacMD5=u._createHmacHelper(n)}(Math),function(){var e=CryptoJS,t=e.lib,s=t.Base,o=t.WordArray,t=e.algo,r=t.EvpKDF=s.extend({cfg:s.extend({keySize:4,hasher:t.MD5,iterations:1}),init:function(e){this.cfg=this.cfg.extend(e)},compute:function(e,t){for(var s=this.cfg,r=s.hasher.create(),i=o.create(),n=i.words,a=s.keySize,s=s.iterations;n.length>>2]}},s.BlockCipher=u.extend({cfg:u.cfg.extend({mode:l,padding:c}),reset:function(){u.reset.call(this);var e=this.cfg,t=e.iv,e=e.mode;if(this._xformMode==this._ENC_XFORM_MODE)var s=e.createEncryptor;else s=e.createDecryptor,this._minBufferSize=1;this._mode=s.call(e,this,t&&t.words)},_doProcessBlock:function(e,t){this._mode.processBlock(e,t)},_doFinalize:function(){var e=this.cfg.padding;if(this._xformMode==this._ENC_XFORM_MODE){e.pad(this._data,this.blockSize);var t=this._process(!0)}else t=this._process(!0),e.unpad(t);return t},blockSize:4});var h=s.CipherParams=o.extend({init:function(e){this.mixIn(e)},toString:function(e){return(e||this.formatter).stringify(this)}}),l=(t.format={}).OpenSSL={stringify:function(e){var t=e.ciphertext;return((e=e.salt)?r.create([1398893684,1701076831]).concat(e).concat(t):t).toString(n)},parse:function(e){var t=(e=n.parse(e)).words;if(1398893684==t[0]&&1701076831==t[1]){var s=r.create(t.slice(2,4));t.splice(0,4),e.sigBytes-=16}return h.create({ciphertext:e,salt:s})}},d=s.SerializableCipher=o.extend({cfg:o.extend({format:l}),encrypt:function(e,t,s,o){o=this.cfg.extend(o);var r=e.createEncryptor(s,o);return t=r.finalize(t),r=r.cfg,h.create({ciphertext:t,key:s,iv:r.iv,algorithm:e,mode:r.mode,padding:r.padding,blockSize:e.blockSize,formatter:o.format})},decrypt:function(e,t,s,o){return o=this.cfg.extend(o),t=this._parse(t,o.format),e.createDecryptor(s,o).finalize(t.ciphertext)},_parse:function(e,t){return"string"==typeof e?t.parse(e,this):e}}),t=(t.kdf={}).OpenSSL={execute:function(e,t,s,o){return o||(o=r.random(8)),e=a.create({keySize:t+s}).compute(e,o),s=r.create(e.words.slice(t),4*s),e.sigBytes=4*t,h.create({key:e,iv:s,salt:o})}},g=s.PasswordBasedCipher=d.extend({cfg:d.cfg.extend({kdf:t}),encrypt:function(e,t,s,o){return s=(o=this.cfg.extend(o)).kdf.execute(s,e.keySize,e.ivSize),o.iv=s.iv,(e=d.encrypt.call(this,e,t,s.key,o)).mixIn(s),e},decrypt:function(e,t,s,o){return o=this.cfg.extend(o),t=this._parse(t,o.format),s=o.kdf.execute(s,e.keySize,e.ivSize,t.salt),o.iv=s.iv,d.decrypt.call(this,e,t,s.key,o)}})}(),function(){for(var e=CryptoJS,t=e.lib.BlockCipher,s=e.algo,o=[],r=[],i=[],n=[],a=[],u=[],l=[],p=[],c=[],h=[],d=[],g=0;256>g;g++)d[g]=128>g?g<<1:g<<1^283;for(var f=0,w=0,g=0;256>g;g++){var O=w^w<<1^w<<2^w<<3^w<<4,O=O>>>8^255&O^99;o[f]=O,r[O]=f;var I=d[f],m=d[I],S=d[m],N=257*d[O]^16843008*O;i[f]=N<<24|N>>>8,n[f]=N<<16|N>>>16,a[f]=N<<8|N>>>24,u[f]=N,N=16843009*S^65537*m^257*I^16843008*f,l[O]=N<<24|N>>>8,p[O]=N<<16|N>>>16,c[O]=N<<8|N>>>24,h[O]=N,f?(f=I^d[d[d[S^I]]],w^=d[d[w]]):f=w=1}var b=[0,1,2,4,8,16,32,64,128,27,54],s=s.AES=t.extend({_doReset:function(){for(var e=this._key,t=e.words,s=e.sigBytes/4,e=4*((this._nRounds=s+6)+1),r=this._keySchedule=[],i=0;i>>24]<<24|o[n>>>16&255]<<16|o[n>>>8&255]<<8|o[255&n]):(n=o[(n=n<<8|n>>>24)>>>24]<<24|o[n>>>16&255]<<16|o[n>>>8&255]<<8|o[255&n],n^=b[i/s|0]<<24),r[i]=r[i-s]^n}for(s=0,t=this._invKeySchedule=[];ss||4>=i?n:l[o[n>>>24]]^p[o[n>>>16&255]]^c[o[n>>>8&255]]^h[o[255&n]]},encryptBlock:function(e,t){this._doCryptBlock(e,t,this._keySchedule,i,n,a,u,o)},decryptBlock:function(e,t){var s=e[t+1];e[t+1]=e[t+3],e[t+3]=s,this._doCryptBlock(e,t,this._invKeySchedule,l,p,c,h,r),s=e[t+1],e[t+1]=e[t+3],e[t+3]=s},_doCryptBlock:function(e,t,s,o,r,i,n,a){for(var u=this._nRounds,l=e[t]^s[0],p=e[t+1]^s[1],c=e[t+2]^s[2],h=e[t+3]^s[3],d=4,g=1;g>>24]^r[p>>>16&255]^i[c>>>8&255]^n[255&h]^s[d++],w=o[p>>>24]^r[c>>>16&255]^i[h>>>8&255]^n[255&l]^s[d++],O=o[c>>>24]^r[h>>>16&255]^i[l>>>8&255]^n[255&p]^s[d++],h=o[h>>>24]^r[l>>>16&255]^i[p>>>8&255]^n[255&c]^s[d++],l=f,p=w,c=O;f=(a[l>>>24]<<24|a[p>>>16&255]<<16|a[c>>>8&255]<<8|a[255&h])^s[d++],w=(a[p>>>24]<<24|a[c>>>16&255]<<16|a[h>>>8&255]<<8|a[255&l])^s[d++],O=(a[c>>>24]<<24|a[h>>>16&255]<<16|a[l>>>8&255]<<8|a[255&p])^s[d++],h=(a[h>>>24]<<24|a[l>>>16&255]<<16|a[p>>>8&255]<<8|a[255&c])^s[d++],e[t]=f,e[t+1]=w,e[t+2]=O,e[t+3]=h},keySize:8});e.AES=t._createHelper(s)}();NewgroundsIO=NewgroundsIO||{};NewgroundsIO.objects=NewgroundsIO.objects?NewgroundsIO.objects:{},NewgroundsIO.results=NewgroundsIO.results?NewgroundsIO.results:{},NewgroundsIO.components=NewgroundsIO.components?NewgroundsIO.components:{},(()=>{class e extends EventTarget{#O="https://www.newgrounds.io/gateway_v3.php";#P=!1;#Q=null;#R=null;#S=[];#T=null;#U=null;#V={};get GATEWAY_URI(){return this.#O}get debug(){return this.#P}set debug(e){this.#P=!!e}get appID(){return this.#Q}get componentQueue(){return this.#S}get hasQueue(){return this.#S.length>0}get host(){return this.#T}get session(){return this.#U}get user(){return this.#U?this.#U.user:null}get uriParams(){return this.#V}constructor(e,t){if(super(),void 0===e)throw"Missing required appID!";if(void 0===t)throw"Missing required aesKey!";if(this.#Q=e,this.#R=CryptoJS.enc.Base64.parse(t),this.#S=[],this.#V={},window&&window.location&&window.location.href?window.location.hostname?this.#T=window.location.hostname.toLowerCase():"file:"==window.location.href.toLowerCase().substr(0,5)?this.#T="":this.#T="":this.#T="","undefined"!=typeof window&&window.location){var s,o=window.location.href.split("?").pop();if(o)for(var r,i=o.split("&"),n=0;n{t instanceof NewgroundsIO.BaseComponent||(r._verifyComponent(e)||(o=!1),t.setCore(r))}),!o)return}else{if(!this._verifyComponent(e))return;e.setCore(this)}let i=this,n=this._getRequest(e);new NewgroundsIO.objects.Response;var a=new XMLHttpRequest;a.onreadystatechange=function(){if(4==a.readyState){var e;try{e=JSON.parse(a.responseText)}catch(o){(e={success:!1,app_id:i.app_id}).error={message:String(o),code:8002}}let r=i._populateResponse(e);i.dispatchEvent(new CustomEvent("serverResponse",{detail:r})),t&&(s?t.call(s,r):t(r))}};var u=void 0!==Array.prototype.toJSON?Array.prototype.toJSON:null;u&&delete Array.prototype.toJSON;let l=new FormData;l.append("request",JSON.stringify(n)),u&&(Array.prototype.toJSON=u),a.open("POST",this.GATEWAY_URI,!0),a.send(l)}loadComponent(e){if(!this._verifyComponent(e))return;e.setCore(this);let t=this._getRequest(e),s=this.GATEWAY_URI+"?request="+encodeURIComponent(JSON.stringify(t));window.open(s,"_blank")}onServerResponse(e){}_populateResponse(e){if(e.success){if(Array.isArray(e.result))for(let t=0;t{let o=s._getExecute(e);t.push(o)})):t=this._getExecute(e);let o=new NewgroundsIO.objects.Request({execute:t});return this.debug&&(o.debug=!0),o.setCore(this),o}_verifyComponent(e){return e instanceof NewgroundsIO.BaseComponent?!!e.isValid():(console.error("NewgroundsIO Type Mismatch: Expecting a NewgroundsIO.components.XXXX instance, got",e),!1)}}NewgroundsIO.Core=e})(),(()=>{class e{get type(){return this.__type}__type="object";__object="BaseObject";__properties=[];__required=[];__ngioCore=null;isValid(){if(0===this.__required.length)return!0;let e=!0;return this.__required.forEach(function(t){null===this[t]?(console.error("NewgroundsIO Error: "+this.__object+" "+this.__type+" is invalid, missing value for '"+t+"'"),e=!1):this[t]instanceof NewgroundsIO.BaseObject&&!this[t].isValid()&&(e=!1)},this),e}setCore(e){this._doSetCore(e,[])}objectMap={};arrayMap={};fromJSON(e,t){var s,o,r={};for(this.setCore(t),s=0;s{s instanceof NewgroundsIO.BaseObject&&-1===t.indexOf(s)&&s._doSetCore(e,t)},this),"host"!==s||this.host||(this.host=e.host)},this)):console.error("NewgroundsIO Error: Expecting NewgroundsIO.Core instance, got",e)}toJSON(){return this.__doToJSON()}__doToJSON(){if(void 0===this.__properties)return{};let e={};return this.__properties.forEach(function(t){null!==this[t]&&(e[t]="function"==typeof this[t].toJSON?this[t].toJSON():this[t])},this),e}toSecureJSON(){return this.__ngioCore&&this.__ngioCore instanceof NewgroundsIO.Core?{secure:this.__ngioCore.encrypt(JSON.stringify(this.__doToJSON()))}:(console.error("NewgroundsIO Error: Unable to create secure JSON object without calling setCore() first."),this.__doToJSON())}toString(){return this.__type}clone(e){return void 0===e&&(e=new this.constructor),this.__properties.forEach(t=>{e[t]=this[t]}),e.__ngioCore=this.__ngioCore,e}}NewgroundsIO.BaseObject=e;class t extends e{constructor(){super(),this.__type="component",this.__object="BaseComponent",this.__properties=["host","echo"],this._echo=null}get host(){return this.__ngioCore?this.__ngioCore.host:null}get echo(){return this._echo}set echo(e){this.echo=""+e}}NewgroundsIO.BaseComponent=t;class s extends e{constructor(){super(),this.__type="result",this.__object="BaseResult",this.__properties=["echo","error","success"],this._echo=null,this._error=null,this._success=null}get component(){return this.__object}get echo(){return this._echo}get error(){return this._error}set error(e){this._error=e}get success(){return!!this._success}set success(e){this._success=!!e}}NewgroundsIO.BaseResult=s})(),NewgroundsIO.SessionState={SESSION_UNINITIALIZED:"session-uninitialized",WAITING_FOR_SERVER:"waiting-for-server",LOGIN_REQUIRED:"login-required",WAITING_FOR_USER:"waiting-for-user",LOGIN_CANCELLED:"login-cancelled",LOGIN_SUCCESSFUL:"login-successful",LOGIN_FAILED:"login-failed",USER_LOGGED_OUT:"user-logged-out",SERVER_UNAVAILABLE:"server-unavailable",EXCEEDED_MAX_ATTEMPTS:"exceeded-max-attempts"},NewgroundsIO.SessionState.SESSION_WAITING=[NewgroundsIO.SessionState.SESSION_UNINITIALIZED,NewgroundsIO.SessionState.WAITING_FOR_SERVER,NewgroundsIO.SessionState.WAITING_FOR_USER,NewgroundsIO.SessionState.LOGIN_CANCELLED,NewgroundsIO.SessionStateLOGIN_FAILED],(()=>{class e extends NewgroundsIO.BaseComponent{constructor(){super(),this.__object="App.checkSession",this.__requireSession=!0}}void 0===NewgroundsIO.components.App&&(NewgroundsIO.components.App={}),NewgroundsIO.components.App.checkSession=e})(),(()=>{class e extends NewgroundsIO.BaseComponent{constructor(){super(),this.__object="App.endSession",this.__requireSession=!0}}void 0===NewgroundsIO.components.App&&(NewgroundsIO.components.App={}),NewgroundsIO.components.App.endSession=e})(),(()=>{class e extends NewgroundsIO.BaseComponent{constructor(e){super();let t=this;if(this.__object="App.getCurrentVersion",["version"].forEach(e=>{0>t.__properties.indexOf(e)&&t.__properties.push(e)}),e&&"object"==typeof e)for(var s=0;s{class e extends NewgroundsIO.BaseComponent{constructor(e){super();let t=this;if(this.__object="App.getHostLicense",["host"].forEach(e=>{0>t.__properties.indexOf(e)&&t.__properties.push(e)}),e&&"object"==typeof e)for(var s=0;s{class e extends NewgroundsIO.BaseComponent{constructor(e){super();let t=this;if(this.__object="App.logView",["host"].forEach(e=>{0>t.__properties.indexOf(e)&&t.__properties.push(e)}),e&&"object"==typeof e)for(var s=0;s{class e extends NewgroundsIO.BaseComponent{constructor(e){super();let t=this;if(this.__object="App.startSession",["force"].forEach(e=>{0>t.__properties.indexOf(e)&&t.__properties.push(e)}),e&&"object"==typeof e)for(var s=0;s{class e extends NewgroundsIO.BaseComponent{constructor(e){super();let t=this;if(this.__object="CloudSave.clearSlot",this.__requireSession=!0,["id"].forEach(e=>{0>t.__properties.indexOf(e)&&t.__properties.push(e)}),e&&"object"==typeof e)for(var s=0;s{class e extends NewgroundsIO.BaseComponent{constructor(e){super();let t=this;if(this.__object="CloudSave.loadSlot",this.__requireSession=!0,["id","app_id"].forEach(e=>{0>t.__properties.indexOf(e)&&t.__properties.push(e)}),e&&"object"==typeof e)for(var s=0;s{class e extends NewgroundsIO.BaseComponent{constructor(e){super();let t=this;if(this.__object="CloudSave.loadSlots",this.__requireSession=!0,["app_id"].forEach(e=>{0>t.__properties.indexOf(e)&&t.__properties.push(e)}),e&&"object"==typeof e)for(var s=0;s{class e extends NewgroundsIO.BaseComponent{constructor(e){super();let t=this;if(this.__object="CloudSave.setData",this.__requireSession=!0,["id","data"].forEach(e=>{0>t.__properties.indexOf(e)&&t.__properties.push(e)}),e&&"object"==typeof e)for(var s=0;s{class e extends NewgroundsIO.BaseComponent{constructor(e){super();let t=this;if(this.__object="Event.logEvent",["host","event_name"].forEach(e=>{0>t.__properties.indexOf(e)&&t.__properties.push(e)}),e&&"object"==typeof e)for(var s=0;s{class e extends NewgroundsIO.BaseComponent{constructor(){super(),this.__object="Gateway.getDatetime"}}void 0===NewgroundsIO.components.Gateway&&(NewgroundsIO.components.Gateway={}),NewgroundsIO.components.Gateway.getDatetime=e})(),(()=>{class e extends NewgroundsIO.BaseComponent{constructor(){super(),this.__object="Gateway.getVersion"}}void 0===NewgroundsIO.components.Gateway&&(NewgroundsIO.components.Gateway={}),NewgroundsIO.components.Gateway.getVersion=e})(),(()=>{class e extends NewgroundsIO.BaseComponent{constructor(){super(),this.__object="Gateway.ping"}}void 0===NewgroundsIO.components.Gateway&&(NewgroundsIO.components.Gateway={}),NewgroundsIO.components.Gateway.ping=e})(),(()=>{class e extends NewgroundsIO.BaseComponent{constructor(e){super();let t=this;if(this.__object="Loader.loadAuthorUrl",["host","redirect","log_stat"].forEach(e=>{0>t.__properties.indexOf(e)&&t.__properties.push(e)}),e&&"object"==typeof e)for(var s=0;s{class e extends NewgroundsIO.BaseComponent{constructor(e){super();let t=this;if(this.__object="Loader.loadMoreGames",["host","redirect","log_stat"].forEach(e=>{0>t.__properties.indexOf(e)&&t.__properties.push(e)}),e&&"object"==typeof e)for(var s=0;s{class e extends NewgroundsIO.BaseComponent{constructor(e){super();let t=this;if(this.__object="Loader.loadNewgrounds",["host","redirect","log_stat"].forEach(e=>{0>t.__properties.indexOf(e)&&t.__properties.push(e)}),e&&"object"==typeof e)for(var s=0;s{class e extends NewgroundsIO.BaseComponent{constructor(e){super();let t=this;if(this.__object="Loader.loadOfficialUrl",["host","redirect","log_stat"].forEach(e=>{0>t.__properties.indexOf(e)&&t.__properties.push(e)}),e&&"object"==typeof e)for(var s=0;s{class e extends NewgroundsIO.BaseComponent{constructor(e){super();let t=this;if(this.__object="Loader.loadReferral",["host","referral_name","redirect","log_stat"].forEach(e=>{0>t.__properties.indexOf(e)&&t.__properties.push(e)}),e&&"object"==typeof e)for(var s=0;s{class e extends NewgroundsIO.BaseComponent{constructor(e){super();let t=this;if(this.__object="Medal.getList",["app_id"].forEach(e=>{0>t.__properties.indexOf(e)&&t.__properties.push(e)}),e&&"object"==typeof e)for(var s=0;s{class e extends NewgroundsIO.BaseComponent{constructor(){super(),this.__object="Medal.getMedalScore",this.__requireSession=!0}}void 0===NewgroundsIO.components.Medal&&(NewgroundsIO.components.Medal={}),NewgroundsIO.components.Medal.getMedalScore=e})(),(()=>{class e extends NewgroundsIO.BaseComponent{constructor(e){super();let t=this;if(this.__object="Medal.unlock",this.__isSecure=!0,this.__requireSession=!0,["id"].forEach(e=>{0>t.__properties.indexOf(e)&&t.__properties.push(e)}),e&&"object"==typeof e)for(var s=0;s{class e extends NewgroundsIO.BaseComponent{constructor(){super(),this.__object="ScoreBoard.getBoards"}}void 0===NewgroundsIO.components.ScoreBoard&&(NewgroundsIO.components.ScoreBoard={}),NewgroundsIO.components.ScoreBoard.getBoards=e})(),(()=>{class e extends NewgroundsIO.BaseComponent{constructor(e){super();let t=this;if(this.__object="ScoreBoard.getScores",["id","period","tag","social","user","skip","limit","app_id"].forEach(e=>{0>t.__properties.indexOf(e)&&t.__properties.push(e)}),e&&"object"==typeof e)for(var s=0;s{class e extends NewgroundsIO.BaseComponent{constructor(e){super();let t=this;if(this.__object="ScoreBoard.postScore",this.__isSecure=!0,this.__requireSession=!0,["id","value","tag"].forEach(e=>{0>t.__properties.indexOf(e)&&t.__properties.push(e)}),e&&"object"==typeof e)for(var s=0;s{class e extends NewgroundsIO.BaseObject{constructor(e){super();let t=this;if(this.__object="Debug",["exec_time","request"].forEach(e=>{0>t.__properties.indexOf(e)&&t.__properties.push(e)}),e&&"object"==typeof e)for(var s=0;s{class e extends NewgroundsIO.BaseObject{constructor(e){super();let t=this;if(this.__object="Error",["message","code"].forEach(e=>{0>t.__properties.indexOf(e)&&t.__properties.push(e)}),e&&"object"==typeof e)for(var s=0;s{class e extends NewgroundsIO.BaseObject{constructor(e){super();let t=this;if(this.__object="Execute",["component","parameters","secure"].forEach(e=>{0>t.__properties.indexOf(e)&&t.__properties.push(e)}),e&&"object"==typeof e)for(var s=0;s{class e extends NewgroundsIO.BaseObject{constructor(e){super();let t=this;if(this.__object="Medal",["id","name","description","icon","value","difficulty","secret","unlocked"].forEach(e=>{0>t.__properties.indexOf(e)&&t.__properties.push(e)}),e&&"object"==typeof e)for(var s=0;s{class e extends NewgroundsIO.BaseObject{constructor(e){super();let t=this;if(this.__object="Request",["app_id","execute","session_id","debug"].forEach(e=>{0>t.__properties.indexOf(e)&&t.__properties.push(e)}),e&&"object"==typeof e)for(var s=0;s{class e extends NewgroundsIO.BaseObject{constructor(e){super();let t=this;if(this.__object="Response",["app_id","success","debug","result","error","api_version","help_url"].forEach(e=>{0>t.__properties.indexOf(e)&&t.__properties.push(e)}),e&&"object"==typeof e)for(var s=0;s{class e extends NewgroundsIO.BaseObject{constructor(e){super();let t=this;if(this.__object="SaveSlot",["id","size","datetime","timestamp","url"].forEach(e=>{0>t.__properties.indexOf(e)&&t.__properties.push(e)}),e&&"object"==typeof e)for(var s=0;s{class e extends NewgroundsIO.BaseObject{constructor(e){super();let t=this;if(this.__object="Score",["user","value","formatted_value","tag"].forEach(e=>{0>t.__properties.indexOf(e)&&t.__properties.push(e)}),e&&"object"==typeof e)for(var s=0;s{class e extends NewgroundsIO.BaseObject{constructor(e){super();let t=this;if(this.__object="ScoreBoard",["id","name"].forEach(e=>{0>t.__properties.indexOf(e)&&t.__properties.push(e)}),e&&"object"==typeof e)for(var s=0;s{class e extends NewgroundsIO.BaseObject{constructor(e){super();let t=this;if(this.__object="Session",["id","user","expired","remember","passport_url"].forEach(e=>{0>t.__properties.indexOf(e)&&t.__properties.push(e)}),e&&"object"==typeof e)for(var s=0;s=this.#aS?this.#aL=NewgroundsIO.SessionState.EXCEEDED_MAX_ATTEMPTS:(this.#aL=NewgroundsIO.SessionState.SESSION_UNINITIALIZED,this.#aR++)),this.status==NewgroundsIO.SessionState.SESSION_UNINITIALIZED&&(this.#aU=localStorage.getItem(this.storageKey),this.#aT?this.id=this.#aT:this.#aU&&(this.id=this.#aU),this.mode=this.id&&"null"!==this.id?"check":"new");var s=new Date;if(!(s-this.#aO<5e3))switch(this.#aO=s,this.mode){case"new":this.mode="wait",this.startSession();break;case"check":this.mode="wait",this.checkSession()}}}startSession(){this.#aP=!1,this.resetSession(),this.#aL=NewgroundsIO.SessionState.WAITING_FOR_SERVER;var e=this.__ngioCore.getComponent("App.startSession");this.__ngioCore.executeComponent(e,this._onStartSession,this)}_onStartSession(e){if(!0===e.success){let t=e.result;if(Array.isArray(t)){for(let s=0;s{class e extends NewgroundsIO.BaseObject{constructor(e){super();let t=this;if(this.__object="User",["id","name","icons","supporter"].forEach(e=>{0>t.__properties.indexOf(e)&&t.__properties.push(e)}),e&&"object"==typeof e)for(var s=0;s{class e extends NewgroundsIO.BaseObject{constructor(e){super();let t=this;if(this.__object="UserIcons",["small","medium","large"].forEach(e=>{0>t.__properties.indexOf(e)&&t.__properties.push(e)}),e&&"object"==typeof e)for(var s=0;s{class e extends NewgroundsIO.BaseResult{constructor(e){super();let t=this;if(this.__object="App.checkSession",["session"].forEach(e=>{0>t.__properties.indexOf(e)&&t.__properties.push(e)}),e&&"object"==typeof e)for(var s=0;s{class e extends NewgroundsIO.BaseResult{constructor(e){super();let t=this;if(this.__object="App.getCurrentVersion",["current_version","client_deprecated"].forEach(e=>{0>t.__properties.indexOf(e)&&t.__properties.push(e)}),e&&"object"==typeof e)for(var s=0;s{class e extends NewgroundsIO.BaseResult{constructor(e){super();let t=this;if(this.__object="App.getHostLicense",["host_approved"].forEach(e=>{0>t.__properties.indexOf(e)&&t.__properties.push(e)}),e&&"object"==typeof e)for(var s=0;s{class e extends NewgroundsIO.BaseResult{constructor(e){super();let t=this;if(this.__object="App.startSession",["session"].forEach(e=>{0>t.__properties.indexOf(e)&&t.__properties.push(e)}),e&&"object"==typeof e)for(var s=0;s{class e extends NewgroundsIO.BaseResult{constructor(e){super();let t=this;if(this.__object="CloudSave.clearSlot",["slot"].forEach(e=>{0>t.__properties.indexOf(e)&&t.__properties.push(e)}),e&&"object"==typeof e)for(var s=0;s{class e extends NewgroundsIO.BaseResult{constructor(e){super();let t=this;if(this.__object="CloudSave.loadSlot",["slot","app_id"].forEach(e=>{0>t.__properties.indexOf(e)&&t.__properties.push(e)}),e&&"object"==typeof e)for(var s=0;s{class e extends NewgroundsIO.BaseResult{constructor(e){super();let t=this;if(this.__object="CloudSave.loadSlots",["slots","app_id"].forEach(e=>{0>t.__properties.indexOf(e)&&t.__properties.push(e)}),e&&"object"==typeof e)for(var s=0;s{class e extends NewgroundsIO.BaseResult{constructor(e){super();let t=this;if(this.__object="CloudSave.setData",["slot"].forEach(e=>{0>t.__properties.indexOf(e)&&t.__properties.push(e)}),e&&"object"==typeof e)for(var s=0;s{class e extends NewgroundsIO.BaseResult{constructor(e){super();let t=this;if(this.__object="Event.logEvent",["event_name"].forEach(e=>{0>t.__properties.indexOf(e)&&t.__properties.push(e)}),e&&"object"==typeof e)for(var s=0;s{class e extends NewgroundsIO.BaseResult{constructor(e){super();let t=this;if(this.__object="Gateway.getDatetime",["datetime","timestamp"].forEach(e=>{0>t.__properties.indexOf(e)&&t.__properties.push(e)}),e&&"object"==typeof e)for(var s=0;s{class e extends NewgroundsIO.BaseResult{constructor(e){super();let t=this;if(this.__object="Gateway.getVersion",["version"].forEach(e=>{0>t.__properties.indexOf(e)&&t.__properties.push(e)}),e&&"object"==typeof e)for(var s=0;s{class e extends NewgroundsIO.BaseResult{constructor(e){super();let t=this;if(this.__object="Gateway.ping",["pong"].forEach(e=>{0>t.__properties.indexOf(e)&&t.__properties.push(e)}),e&&"object"==typeof e)for(var s=0;s{class e extends NewgroundsIO.BaseResult{constructor(e){super();let t=this;if(this.__object="Loader.loadAuthorUrl",["url"].forEach(e=>{0>t.__properties.indexOf(e)&&t.__properties.push(e)}),e&&"object"==typeof e)for(var s=0;s{class e extends NewgroundsIO.BaseResult{constructor(e){super();let t=this;if(this.__object="Loader.loadMoreGames",["url"].forEach(e=>{0>t.__properties.indexOf(e)&&t.__properties.push(e)}),e&&"object"==typeof e)for(var s=0;s{class e extends NewgroundsIO.BaseResult{constructor(e){super();let t=this;if(this.__object="Loader.loadNewgrounds",["url"].forEach(e=>{0>t.__properties.indexOf(e)&&t.__properties.push(e)}),e&&"object"==typeof e)for(var s=0;s{class e extends NewgroundsIO.BaseResult{constructor(e){super();let t=this;if(this.__object="Loader.loadOfficialUrl",["url"].forEach(e=>{0>t.__properties.indexOf(e)&&t.__properties.push(e)}),e&&"object"==typeof e)for(var s=0;s{class e extends NewgroundsIO.BaseResult{constructor(e){super();let t=this;if(this.__object="Loader.loadReferral",["url"].forEach(e=>{0>t.__properties.indexOf(e)&&t.__properties.push(e)}),e&&"object"==typeof e)for(var s=0;s{class e extends NewgroundsIO.BaseResult{constructor(e){super();let t=this;if(this.__object="Medal.getList",["medals","app_id"].forEach(e=>{0>t.__properties.indexOf(e)&&t.__properties.push(e)}),e&&"object"==typeof e)for(var s=0;s{class e extends NewgroundsIO.BaseResult{constructor(e){super();let t=this;if(this.__object="Medal.getMedalScore",["medal_score"].forEach(e=>{0>t.__properties.indexOf(e)&&t.__properties.push(e)}),e&&"object"==typeof e)for(var s=0;s{class e extends NewgroundsIO.BaseResult{constructor(e){super();let t=this;if(this.__object="Medal.unlock",["medal","medal_score"].forEach(e=>{0>t.__properties.indexOf(e)&&t.__properties.push(e)}),e&&"object"==typeof e)for(var s=0;s{class e extends NewgroundsIO.BaseResult{constructor(e){super();let t=this;if(this.__object="ScoreBoard.getBoards",["scoreboards"].forEach(e=>{0>t.__properties.indexOf(e)&&t.__properties.push(e)}),e&&"object"==typeof e)for(var s=0;s{class e extends NewgroundsIO.BaseResult{constructor(e){super();let t=this;if(this.__object="ScoreBoard.getScores",["period","social","limit","scoreboard","scores","user","app_id"].forEach(e=>{0>t.__properties.indexOf(e)&&t.__properties.push(e)}),e&&"object"==typeof e)for(var s=0;s{class e extends NewgroundsIO.BaseResult{constructor(e){super();let t=this;if(this.__object="ScoreBoard.postScore",["scoreboard","score"].forEach(e=>{0>t.__properties.indexOf(e)&&t.__properties.push(e)}),e&&"object"==typeof e)for(var s=0;s { + const returned = {}; + + //assign each item to a place in the object; + for (let item in data) { + returned[data[item].id] = data; + } + + return returned; + } + + //Define our user data. let userDat = { logged: false, name: "unknown", @@ -4617,7 +109,8 @@ icon: "https://raw.githubusercontent.com/David-Orangemoon/DataHoldersRepo/main/newgroundsHolding/UnknownUser.png", }; - function statusReport(status) { + //Status functions and variable + const statusReport = (status) => { if (NGIO.isWaitingStatus) { ConnectionStatus = "Awaiting"; loggedIn = false; @@ -4656,10 +149,17 @@ userDat.name = NGIO.user.name; userDat.supporter = NGIO.user.supporter; userDat.id = NGIO.user.id; + + gameData.medals = quickParseData(NGIO.medals); + gameData.saveSlots = quickParseData(NGIO.saveSlots); + gameData.scoreBoards = quickParseData(NGIO.scoreBoards); + break; } else { ConnectionStatus = "Opted Out"; loggedIn = false; + + gameData.scoreBoards = quickParseData(NGIO.scoreBoards); break; } @@ -4671,13 +171,62 @@ break; } } - - function onSaveComplete(slot) { + const onSaveComplete = (slot) => { saveCompleted = true; + gameData.saveSlots = quickParseData(NGIO.saveSlots); } let scorePosted = false; + //css "classes" for our monitor for convience + const customCSS = { + sc_monitor_root: { + position: "absolute", + top: "0px", + left: "0px", + background: "hsla(215, 100%, 95%, 1)", + color: "#575e75", + border: "1px solid hsla(0, 0%, 0%, 0.15)", + borderRadius: "4px", + fontSize: "12px", + overflow: "hidden", + userSelect: "none", + webkitUserSelect: "none", + display: "flex", + flexDirection: "column", + pointerEvents: "all", + boxSizing: "border-box" + }, + sc_monitor_list_label: { + backgroundColor: "white", + textAlign: "center", + fontWeight: "bold", + borderBottom: "1px solid hsla(0, 0%, 0%, 0.15)", + padding: "3px", + boxSizing: "border-box" + }, + sc_monitor_rows_outer: { + flex_grow: "1", + boxSizing: "border-box" + }, + sc_monitor_list_footer: { + display: "flex", + backgroundColor: "white", + textAlign: "center", + fontWeight: "bold", + padding: "3px", + boxSizing: "border-box" + } + } + + const setElementCSS = (element, cssObject) => { + if (element instanceof HTMLElement && typeof cssObject == "object") { + for (let key in cssObject) { + element.style[key] = cssObject[key]; + } + } + } + ("use strict"); class NewgroundsAPI { getInfo() { @@ -4698,11 +247,13 @@ opcode: "onLoginSuccess", blockType: Scratch.BlockType.HAT, text: Scratch.translate("when login success"), + isEdgeActivated: false }, { opcode: "onLoginRequired", blockType: Scratch.BlockType.HAT, text: Scratch.translate("when login required"), + isEdgeActivated: false }, { opcode: "promptLogin", @@ -4819,6 +370,7 @@ opcode: "onSaveCompletedHat", blockType: Scratch.BlockType.HAT, text: Scratch.translate("when save completed"), + isEdgeActivated: false }, { opcode: "saveData", @@ -4889,6 +441,7 @@ opcode: "onScorePosted", blockType: Scratch.BlockType.HAT, text: Scratch.translate("when score posted"), + isEdgeActivated: false }, { opcode: "postScore", @@ -5024,8 +577,12 @@ }; } - //Referrals + //Monitors + _createMonitorFor(scoreBoardID, x, y, width, height) { + if (true) {} + } + //Referrals loadNewgrounds() { NGIO.loadNewgrounds(); } @@ -5041,6 +598,8 @@ //score getScore({ rank, scoreBoardID, timeSpan, scoreDataType }) { + if (!(NGIO.session && gameData.scoreBoards[scoreBoardID])) return 0; + const searchOptions = { period: timeSpan, social: true, @@ -5087,32 +646,20 @@ } postScore({ score, scoreBoardID }) { - if (NGIO.session) { + if (NGIO.session && gameData.scoreBoards[scoreBoardID]) { NGIO.postScore(scoreBoardID, score, () => { - scorePosted = true; + Scratch.vm.runtime.startHats("NGIO_onScorePosted"); }); } } - onScorePosted() { - if (scorePosted) { - scorePosted = false; - return true; - } - return false; - } + onScorePosted() {} //Other Stuff onLoginSuccess() { if (!userDat.logged) { - userDat.logged = NGIO.hasUser; - if (userDat.logged == true) { - userDat.icon = NGIO.user.icons.large; - userDat.name = NGIO.user.name; - userDat.supporter = NGIO.user.supporter; - userDat.id = NGIO.user.id; - } + NGIO.getConnectionStatus(statusReport); return NGIO.hasUser; } else { @@ -5130,10 +677,51 @@ } } + waitForValid() { + return new Promise((resolve, reject) => { + const intervalID = setInterval(() => { + NGIO.getConnectionStatus(statusReport); + + //Wait for finish + switch (ConnectionStatus) { + //In case we aren't awaiting + case "Awaiting": + break; + + case "Login Required": + Scratch.vm.runtime.startHats("NGIO_onLoginRequired"); + clearInterval(intervalID); + resolve(); + break; + + case "Logged In": + Scratch.vm.runtime.startHats("NGIO_onLoginSuccess"); + clearInterval(intervalID); + + //Set userDat object data + userDat.logged = NGIO.hasUser; + if (userDat.logged == true) { + userDat.icon = NGIO.user.icons.large; + userDat.name = NGIO.user.name; + userDat.supporter = NGIO.user.supporter; + userDat.id = NGIO.user.id; + } + resolve(); + break; + + default: + clearInterval(intervalID); + resolve(); + break; + } + }); + }); + } + promptLogin() { if (NGIO.session) { NGIO.openLoginPage(); - NGIO.getConnectionStatus(statusReport); + return this.waitForValid(); } } @@ -5161,21 +749,9 @@ NGIO.init(gameID, code, NGOptions); //Add a hook for the connection status to Newgrounds. - const intervalID = setInterval(() => { - NGIO.getConnectionStatus(statusReport); - - //Wait for finish - switch (ConnectionStatus) { - //In case we aren't awaiting - case "Awaiting": - break; - - default: - clearInterval(intervalID); - resolve(); - break; - } - }, 100); + this.waitForValid().then(() => { + resolve(); + }); }); } @@ -5227,47 +803,44 @@ // Save Blocks - onSaveCompletedHat() { - if (NGIO.session) { - if (saveCompleted == true) { - saveCompleted = false; - return true; - } - return false; - } - return false; - } + onSaveCompletedHat() {} saveData({ Data, Slot }) { if (NGIO.session && loggedIn) { + //Configure our slot to be in a good range! + Slot = Math.max(1, Math.floor(Scratch.Cast.toNumber(Slot))); + NGIO.setSaveSlotData( Scratch.Cast.toString(Slot), Scratch.Cast.toString(Data), - onSaveComplete + () => { + Scratch.vm.runtime.startHats("NGIO_onSaveCompletedHat"); + //Create dummy slot. + gameData.saveSlots[Slot] = {}; + } ); } } getData({ Slot }) { if (NGIO.session && loggedIn) { + //Configure our slot to be in a good range! + Slot = Math.max(1, Math.floor(Scratch.Cast.toNumber(Slot))); let saveDat = "Nothing in Slot"; + + return new Promise((resolve, reject) => { //When the slot is loaded parse our data function onSaveDataLoaded(data) { - if ( - Scratch.Cast.toString(data).includes( - "404 Not Found" - ) - ) - saveDat = ""; - else if (data) saveDat = Scratch.Cast.toString(data); + if (data) saveDat = Scratch.Cast.toString(data); else saveDat = ""; resolve(saveDat); } //Try to get the data - NGIO.getSaveSlotData(Scratch.Cast.toNumber(Slot), onSaveDataLoaded); + if (!gameData.saveSlots[Slot]) resolve(""); + else NGIO.getSaveSlotData(Scratch.Cast.toNumber(Slot), onSaveDataLoaded); }); } else { if (NGIO.session && !loggedIn) return "Not logged in!"; @@ -5278,10 +851,13 @@ doesSlotHaveData({ Slot }) { if (NGIO.session && loggedIn) { this.revitalizeSession(); + + //Configure our slot to be in a good range! + Slot = Math.max(1, Math.floor(Scratch.Cast.toNumber(Slot))); //get and verify save slot! + if (!gameData.saveSlots[Slot]) return false; const saveSlot = NGIO.getSaveSlot(Slot); - if (!saveSlot) return; return saveSlot.hasData; } else { @@ -5290,22 +866,27 @@ } //Medals - unlockMedal({ medalID }) { if (NGIO.session && loggedIn) { this.revitalizeSession(); - NGIO.unlockMedal(Scratch.Cast.toNumber(medalID)); + medalID = Scratch.Cast.toNumber(medalID); + + if (!(NGIO.session && gameData.medals[medalID])) return; + NGIO.unlockMedal(medalID); } } isMedalUnlocked({ medalID }) { if (NGIO.session && loggedIn) { this.revitalizeSession(); - const medal = NGIO.getMedal(Scratch.Cast.toNumber(medalID)); + + medalID = Scratch.Cast.toNumber(medalID); + + if (!(NGIO.session && gameData.medals[medalID])) return false; + const medal = NGIO.getMedal(medalID); //Make sure the medal exists - if (!medal) return; return medal.unlocked; } else { return false; From d1dd6ed8189eaebe69e9d65de0e033e6ef8cab57 Mon Sep 17 00:00:00 2001 From: "Dr. Cleve" <76855369+David-Orangemoon@users.noreply.github.com> Date: Sat, 27 Sep 2025 00:23:39 -0400 Subject: [PATCH 05/16] wipLeaderboards --- extensions/obviousAlexC/newgroundsIO.js | 280 ++++++++++++++++++++++-- 1 file changed, 267 insertions(+), 13 deletions(-) diff --git a/extensions/obviousAlexC/newgroundsIO.js b/extensions/obviousAlexC/newgroundsIO.js index fe29f811cd..69f00b4ba0 100644 --- a/extensions/obviousAlexC/newgroundsIO.js +++ b/extensions/obviousAlexC/newgroundsIO.js @@ -93,7 +93,7 @@ //assign each item to a place in the object; for (let item in data) { - returned[data[item].id] = data; + returned[data[item].id] = data[item]; } return returned; @@ -153,7 +153,8 @@ gameData.medals = quickParseData(NGIO.medals); gameData.saveSlots = quickParseData(NGIO.saveSlots); gameData.scoreBoards = quickParseData(NGIO.scoreBoards); - + + console.log(gameData); break; } else { ConnectionStatus = "Opted Out"; @@ -171,10 +172,6 @@ break; } } - const onSaveComplete = (slot) => { - saveCompleted = true; - gameData.saveSlots = quickParseData(NGIO.saveSlots); - } let scorePosted = false; @@ -206,8 +203,9 @@ boxSizing: "border-box" }, sc_monitor_rows_outer: { - flex_grow: "1", - boxSizing: "border-box" + flexGrow: "1", + boxSizing: "border-box", + overflowY: "scroll" }, sc_monitor_list_footer: { display: "flex", @@ -216,6 +214,51 @@ fontWeight: "bold", padding: "3px", boxSizing: "border-box" + }, + + sc_monitor_row_root: { + position: "relative", + top: "0", + left: "0", + display: "flex", + justifyContent: "space-around", + alignItems: "center", + padding: "2px", + width: "100%", + boxSizing: "border-box" + }, + sc_monitor_row_index: { + fontWeight: "bold", + color: "hsla(225, 15%, 40%, 1)", + margin: "0 3px", + boxSizing: "border-box" + }, + sc_monitor_row_value_outer: { + display: "flex", + alignItems: "center", + minWidth: "40px", + height: "22px", + border: "1px solid hsla(0, 0%, 0%, 0.15)", + backgroundColor: "#fc662c", + color: "white", + margin: "0 3px", + borderRadius: "calc(0.5rem / 2)", + flexGrow: "1", + boxSizing: "border-box" + }, + sc_monitor_row_value_inner: { + padding: "3px 5px", + width: "100%", + color: "inherit", + background: "none", + border: "none", + font: "inherit", + outline: "none", + overflow: "hidden", + textOverflow: "ellipsis", + userSelect: "text", + webkitUserSelect: "text", + whiteSpace: "pre", } } @@ -423,6 +466,20 @@ }, }, }, + { + opcode: "getMedalData", + blockType: Scratch.BlockType.REPORTER, + text: Scratch.translate("get [data] of medal [medalID]"), + arguments: { + data: { + menu: "medalDatType", + }, + medalID: { + type: Scratch.ArgumentType.NUMBER, + defaultValue: Scratch.translate("MedalID"), + }, + }, + }, { opcode: "isMedalUnlocked", blockType: Scratch.BlockType.BOOLEAN, @@ -434,6 +491,17 @@ }, }, }, + { + opcode: "isMedalSecret", + blockType: Scratch.BlockType.BOOLEAN, + text: Scratch.translate("is medal [medalID] secret?"), + arguments: { + medalID: { + type: Scratch.ArgumentType.NUMBER, + defaultValue: Scratch.translate("MedalID"), + }, + }, + }, "---", //Scoreboard Blocks @@ -460,6 +528,19 @@ }, }, }, + { + opcode: "scoreboardName", + blockType: Scratch.BlockType.REPORTER, + text: Scratch.translate( + "name of scoreboard [scoreBoardID]" + ), + arguments: { + scoreBoardID: { + type: Scratch.ArgumentType.NUMBER, + defaultValue: "000000", + } + }, + }, { opcode: "getScore", blockType: Scratch.BlockType.REPORTER, @@ -485,6 +566,23 @@ }, }, }, + { + opcode: "setScoreboardVisibility", + blockType: Scratch.BlockType.COMMAND, + text: Scratch.translate( + "[visibilityType] scoreboard [scoreBoardID]" + ), + arguments: { + visibilityType: { + type: Scratch.ArgumentType.STRING, + menu: "visibilityTypes", + }, + scoreBoardID: { + type: Scratch.ArgumentType.NUMBER, + defaultValue: "000000", + }, + } + }, "---", //Referrals @@ -527,6 +625,31 @@ }, ], }, + medalDatType: { + acceptReporters: true, + items: [ + { + text: Scratch.translate("name"), + value: "name", + }, + { + text: Scratch.translate("description"), + value: "description", + }, + { + text: Scratch.translate("icon"), + value: "icon", + }, + { + text: Scratch.translate("difficulty"), + value: "difficulty", + }, + { + text: Scratch.translate("value"), + value: "value", + }, + ], + }, periodTypes: { acceptReporters: true, items: [ @@ -573,13 +696,94 @@ }, ], }, + visibilityTypes: { + acceptReporters: true, + items: [ + { + text: Scratch.translate("show"), + value: "show", + }, + { + text: Scratch.translate("hide"), + value: "hide", + } + ], + } }, }; } //Monitors _createMonitorFor(scoreBoardID, x, y, width, height) { - if (true) {} + if (!gameData.scoreBoards[scoreBoardID]) return; + + const scoreboard = gameData.scoreBoards[scoreBoardID]; + + if (true) { + //Create elements and set up css + const monitorRoot = document.createElement("div"); + setElementCSS(monitorRoot, customCSS.sc_monitor_root); + + monitorRoot.style.width = "100px"; + monitorRoot.style.height = "200px"; + + const monitorHeader = document.createElement("div"); + setElementCSS(monitorHeader, customCSS.sc_monitor_list_label); + monitorHeader.innerText = scoreboard.name; + + const monitorInner = document.createElement("div"); + setElementCSS(monitorInner, customCSS.sc_monitor_rows_outer); + + const monitorFooter = document.createElement("div"); + setElementCSS(monitorFooter, customCSS.sc_monitor_list_footer); + + monitorRoot.appendChild(monitorHeader); + monitorRoot.appendChild(monitorInner); + monitorRoot.appendChild(monitorFooter); + + const searchOptions = { + period: NGIO.PERIOD_ALL_TIME, + social: true, + skip: 0, + limit: 20, + }; + + NGIO.getScores(scoreBoardID, searchOptions, (board, scores) => { + monitorInner.innerHTML = ""; + + console.log(scores); + + for (let scoreID in scores) { + const score = scores[0]; + console.log(score, score.user.name); + + const rowOuter = document.createElement("label"); + setElementCSS(rowOuter, customCSS.sc_monitor_row_root); + + const rowIndex = document.createElement("img"); + setElementCSS(rowIndex, customCSS.sc_monitor_row_index); + rowIndex.src = score.user.icons.small; + + const rowValue = document.createElement("div"); + setElementCSS(rowValue, customCSS.sc_monitor_row_value_outer); + + const rowValueText = document.createElement("div"); + setElementCSS(rowValueText, customCSS.sc_monitor_row_value_inner); + rowValueText.innerText = score.formatted_value; + + rowOuter.appendChild(rowIndex); + rowOuter.appendChild(rowValue); + rowValue.appendChild(rowValueText); + + rowIndex.onmouseover = () => { rowValueText.innerText = score.user.name; } + rowIndex.onmouseout = () => { rowValueText.innerText = score.formatted_value; } + + monitorInner.appendChild(rowOuter); + } + }) + + Scratch.renderer.addOverlay(monitorRoot); + } } //Referrals @@ -606,6 +810,7 @@ skip: rank - 1, limit: 1, }; + return new Promise((resolve, reject) => { NGIO.getScores(scoreBoardID, searchOptions, (board, scores) => { // <= declaring the board before scores so that we can retrieve the scores. @@ -653,6 +858,20 @@ } } + scoreboardName({ scoreBoardID }) { + if (NGIO.session && gameData.scoreBoards[scoreBoardID]) { + console.log(gameData.scoreBoards[scoreBoardID]); + return gameData.scoreBoards[scoreBoardID].name; + } + else { + return ""; + } + } + + setScoreboardVisibility({ visibilityType, scoreBoardID }) { + if (visibilityType == "show") this._createMonitorFor(scoreBoardID); + } + onScorePosted() {} //Other Stuff @@ -851,7 +1070,7 @@ doesSlotHaveData({ Slot }) { if (NGIO.session && loggedIn) { this.revitalizeSession(); - + //Configure our slot to be in a good range! Slot = Math.max(1, Math.floor(Scratch.Cast.toNumber(Slot))); @@ -884,15 +1103,50 @@ medalID = Scratch.Cast.toNumber(medalID); if (!(NGIO.session && gameData.medals[medalID])) return false; - const medal = NGIO.getMedal(medalID); + return gameData.medals[medalID].unlocked; + } else { + return false; + } + } - //Make sure the medal exists - return medal.unlocked; + isMedalSecret({ medalID }) { + if (NGIO.session && loggedIn) { + this.revitalizeSession(); + + medalID = Scratch.Cast.toNumber(medalID); + + if (!(NGIO.session && gameData.medals[medalID])) return false; + return gameData.medals[medalID].secret; } else { return false; } } + + getMedalData({ data, medalID }) { + if (NGIO.session && loggedIn) { + this.revitalizeSession(); + + medalID = Scratch.Cast.toNumber(medalID); + + if (!(NGIO.session && gameData.medals[medalID])) return ""; + + const medal = gameData.medals[medalID]; + switch (data) { + case "name": return medal.name; + case "description": return medal.description; + //Make sure we get a url + case "icon": return (medal.icon.startsWith("https:")) ? medal.icon : "https:" + medal.icon; + case "difficulty": return medal.difficulty; + case "value": return medal.value; + + default: return ""; + } + } else { + return ""; + } + } + //To keep the session alive! revitalizeSession() { //Get and keep the session alive NGIO.getConnectionStatus(statusReport); From cd8c5c6fe63cb10d8798c6505dc4ecdff35013c6 Mon Sep 17 00:00:00 2001 From: "Dr. Cleve" <76855369+David-Orangemoon@users.noreply.github.com> Date: Sat, 27 Sep 2025 21:41:45 -0400 Subject: [PATCH 06/16] Finish scoreboard monitor --- extensions/obviousAlexC/newgroundsIO.js | 534 +++++++++++++++++++++--- 1 file changed, 486 insertions(+), 48 deletions(-) diff --git a/extensions/obviousAlexC/newgroundsIO.js b/extensions/obviousAlexC/newgroundsIO.js index 69f00b4ba0..7270165ab5 100644 --- a/extensions/obviousAlexC/newgroundsIO.js +++ b/extensions/obviousAlexC/newgroundsIO.js @@ -109,6 +109,10 @@ icon: "https://raw.githubusercontent.com/David-Orangemoon/DataHoldersRepo/main/newgroundsHolding/UnknownUser.png", }; + let monitorDisplayData = { + itemCount: 20, + } + //Status functions and variable const statusReport = (status) => { if (NGIO.isWaitingStatus) { @@ -153,8 +157,6 @@ gameData.medals = quickParseData(NGIO.medals); gameData.saveSlots = quickParseData(NGIO.saveSlots); gameData.scoreBoards = quickParseData(NGIO.scoreBoards); - - console.log(gameData); break; } else { ConnectionStatus = "Opted Out"; @@ -192,7 +194,10 @@ display: "flex", flexDirection: "column", pointerEvents: "all", - boxSizing: "border-box" + boxSizing: "border-box", + //Picked up is drop-shadow(rgba(0, 0, 0, 0.6) 2px 2px 4px) + filter: "drop-shadow(rgba(0, 0, 0, 0.0) 0px 0px 0px)", + transition: "filter 300ms" }, sc_monitor_list_label: { backgroundColor: "white", @@ -200,7 +205,8 @@ fontWeight: "bold", borderBottom: "1px solid hsla(0, 0%, 0%, 0.15)", padding: "3px", - boxSizing: "border-box" + boxSizing: "border-box", + display: "flex" }, sc_monitor_rows_outer: { flexGrow: "1", @@ -231,7 +237,10 @@ fontWeight: "bold", color: "hsla(225, 15%, 40%, 1)", margin: "0 3px", - boxSizing: "border-box" + boxSizing: "border-box", + width: "25px", + height: "25px", + borderRadius: "4px" }, sc_monitor_row_value_outer: { display: "flex", @@ -239,7 +248,7 @@ minWidth: "40px", height: "22px", border: "1px solid hsla(0, 0%, 0%, 0.15)", - backgroundColor: "#fc662c", + backgroundColor: "#EB7522", color: "white", margin: "0 3px", borderRadius: "calc(0.5rem / 2)", @@ -259,6 +268,24 @@ userSelect: "text", webkitUserSelect: "text", whiteSpace: "pre", + }, + + + sc_monitor_page_text: { + flexGrow: "1", + boxSizing: "border-box", + }, + sc_monitor_page_button: { + border: "1px solid", + borderRadius: "4px", + borderColor: "rgba(0, 0, 0, 0.15)", + background: "white" + }, + sc_monitor_page_button_disabled: { + border: "1px solid", + borderRadius: "4px", + borderColor: "rgba(0, 0, 0, 0.15)", + background: "hsla(215, 100%, 95%, 1)" } } @@ -270,8 +297,60 @@ } } + //Finally our scratch stuff + const runtime = Scratch.vm.runtime; + const renderer = Scratch.vm.renderer; + const isPackaged = (typeof scaffolding !== "undefined"); + + const originifyJson = (inObject) => { + return JSON.parse(JSON.stringify(inObject)); + } + ("use strict"); class NewgroundsAPI { + constructor() { + this.monitors = {}; + this.serializedMonitors = {}; + + this.setupSaving(); + vm.runtime.on("PROJECT_LOADED", () => {this.setupSaving.call(this)}); + } + + setupSaving() { + if (Scratch.extensions.isPenguinMod) { + this.serialize = () => { + return JSON.stringify({ + monitors: this.serializedMonitors, + }); + }; + + this.deserialize = (serialized) => { + let deserializedData = JSON.parse(serialized); + this.monitors = deserializedData.monitors; + this.serializedMonitors = deserializedData.monitors; + }; + } + else { + //Storage flip flop + if (!runtime.extensionStorage["NGIO"]) runtime.extensionStorage["NGIO"] = new Object({ monitors: {} }); + + this.serializedMonitors = originifyJson(runtime.extensionStorage["NGIO"].monitors); + this.monitors = originifyJson(runtime.extensionStorage["NGIO"].monitors); + } + } + + serializeMonitor(monitorData) { + this.serializedMonitors[monitorData.id] = { + x: monitorData.x, + y: monitorData.y, + width: monitorData.width, + height: monitorData.height, + id: monitorData.id, + }; + + if (!Scratch.extensions.isPenguinMod) runtime.extensionStorage["NGIO"].monitors = this.serializedMonitors; + } + getInfo() { return { id: "NGIO", @@ -454,7 +533,13 @@ }, "---", //Medal Blocks - + + { + opcode: "onMedalUnlockedHat", + blockType: Scratch.BlockType.HAT, + text: Scratch.translate("when medal unlocked"), + isEdgeActivated: false + }, { opcode: "unlockMedal", blockType: Scratch.BlockType.COMMAND, @@ -566,6 +651,31 @@ }, }, }, + { + opcode: "getScoresBulk", + blockType: Scratch.BlockType.REPORTER, + text: Scratch.translate( + "get the first [count] ranks starting from rank [rank] in scoreboard [scoreBoardID] from the timespan of [timeSpan]" + ), + arguments: { + scoreBoardID: { + type: Scratch.ArgumentType.NUMBER, + defaultValue: "000000", + }, + rank: { + type: Scratch.ArgumentType.NUMBER, + defaultValue: "1", + }, + timeSpan: { + type: Scratch.ArgumentType.STRING, + menu: "periodTypes", + }, + count: { + type: Scratch.ArgumentType.NUMBER, + defaultValue: "20", + }, + }, + }, { opcode: "setScoreboardVisibility", blockType: Scratch.BlockType.COMMAND, @@ -584,6 +694,26 @@ } }, + "---", //Settings/changability + + { + opcode: "setMonitorDisplayData", + blockType: Scratch.BlockType.COMMAND, + text: Scratch.translate( + "set [property] to [value]" + ), + arguments: { + property: { + type: Scratch.ArgumentType.STRING, + menu: "displayPropertyTypes", + }, + value: { + type: Scratch.ArgumentType.STRING, + defaultValue: "20", + }, + } + }, + "---", //Referrals { @@ -706,30 +836,65 @@ { text: Scratch.translate("hide"), value: "hide", + }, + { + text: Scratch.translate("refresh"), + value: "refresh", } ], + }, + displayPropertyTypes: { + acceptReporters: true, + items: [ + { + text: Scratch.translate("itemCount"), + value: "itemCount", + }, + ], } }, }; } //Monitors - _createMonitorFor(scoreBoardID, x, y, width, height) { + _createMonitorFor(scoreBoardID) { if (!gameData.scoreBoards[scoreBoardID]) return; const scoreboard = gameData.scoreBoards[scoreBoardID]; + + let monitorExists = true; + + //Create data if it doesn't exist + if (!this.monitors[scoreBoardID]) { + monitorExists = false; + this.monitors[scoreBoardID] = { + x: (runtime.stageWidth / 2) - 62.5, + y: (runtime.stageHeight / 2) - 100, + width: 125, + height: 200, + id: scoreBoardID + } + + this.serializeMonitor(this.monitors[scoreBoardID]); + } + else if (!this.monitors[scoreBoardID].element) monitorExists = false; + + //Now we decide if we need to create or just ignore the monitor + const monitorData = this.monitors[scoreBoardID]; - if (true) { + if (!monitorExists) { //Create elements and set up css const monitorRoot = document.createElement("div"); setElementCSS(monitorRoot, customCSS.sc_monitor_root); - monitorRoot.style.width = "100px"; - monitorRoot.style.height = "200px"; + //Position the root + monitorRoot.style.width = `${monitorData.width}px`; + monitorRoot.style.height = `${monitorData.height}px`; + monitorRoot.style.top = `${monitorData.y}px`; + monitorRoot.style.left = `${monitorData.x}px`; const monitorHeader = document.createElement("div"); setElementCSS(monitorHeader, customCSS.sc_monitor_list_label); - monitorHeader.innerText = scoreboard.name; const monitorInner = document.createElement("div"); setElementCSS(monitorInner, customCSS.sc_monitor_rows_outer); @@ -741,28 +906,84 @@ monitorRoot.appendChild(monitorInner); monitorRoot.appendChild(monitorFooter); + //Data + let page = 0; + + //Contents const searchOptions = { period: NGIO.PERIOD_ALL_TIME, - social: true, - skip: 0, - limit: 20, + social: false, + skip: page * monitorDisplayData.itemCount, + limit: monitorDisplayData.itemCount + 1, }; - NGIO.getScores(scoreBoardID, searchOptions, (board, scores) => { - monitorInner.innerHTML = ""; + //Header elements of the monitor + const monitorLabel = document.createElement("div"); + setElementCSS(monitorLabel, { flexGrow: "1" }); + monitorLabel.innerText = scoreboard.name; - console.log(scores); + const buttonRefresh = document.createElement("div"); + buttonRefresh.innerText = "↻"; - for (let scoreID in scores) { - const score = scores[0]; - console.log(score, score.user.name); + monitorHeader.appendChild(buttonRefresh); + monitorHeader.appendChild(monitorLabel); + + //Footer elements of the monitor + const buttonPrevious = document.createElement("button"); + setElementCSS(buttonPrevious, customCSS.sc_monitor_page_button); + buttonPrevious.innerText = "Last"; + + const pageText = document.createElement("div"); + setElementCSS(pageText, customCSS.sc_monitor_page_text); + pageText.innerHTML = `Page
${page + 1}`; + + const buttonNext = document.createElement("button"); + setElementCSS(buttonNext, customCSS.sc_monitor_page_button); + buttonNext.innerText = "Next"; + + monitorFooter.appendChild(buttonPrevious); + monitorFooter.appendChild(pageText); + monitorFooter.appendChild(buttonNext); + + //Actually displaying the board + const displayBoard = (board, scores) => { + if (scores.length == 0) { + buttonPrevious.disabled = true; + buttonNext.disabled = true; + return; + } + + pageText.innerHTML = `Page
${page + 1}`; + + //Make sure buttons are valid + buttonPrevious.disabled = false; + buttonNext.disabled = false; + + if (page == 0) buttonPrevious.disabled = true; + if (scores.length != (monitorDisplayData.itemCount + 1)) buttonNext.disabled = true; + + //Make sure buttons reflect the options + if (buttonPrevious.disabled) setElementCSS(buttonPrevious, customCSS.sc_monitor_page_button_disabled); + else setElementCSS(buttonPrevious, customCSS.sc_monitor_page_button); + + if (buttonNext.disabled) setElementCSS(buttonNext, customCSS.sc_monitor_page_button_disabled); + else setElementCSS(buttonNext, customCSS.sc_monitor_page_button); + + //start displaying the monitor + let scoresToDisplay = scores.length; + if (scores.length == (monitorDisplayData.itemCount + 1)) scoresToDisplay--; + + monitorInner.innerHTML = ""; + + for (let scoreID = 0; scoreID < scoresToDisplay; scoreID++) { + const score = scores[scoreID]; const rowOuter = document.createElement("label"); setElementCSS(rowOuter, customCSS.sc_monitor_row_root); const rowIndex = document.createElement("img"); setElementCSS(rowIndex, customCSS.sc_monitor_row_index); - rowIndex.src = score.user.icons.small; + rowIndex.src = score.user.icons.large; const rowValue = document.createElement("div"); setElementCSS(rowValue, customCSS.sc_monitor_row_value_outer); @@ -780,9 +1001,160 @@ monitorInner.appendChild(rowOuter); } - }) + } + + buttonPrevious.onclick = () => { + page -= 1; + searchOptions.skip = page * monitorDisplayData.itemCount; + NGIO.getScores(scoreBoardID, searchOptions, displayBoard); + } + + buttonNext.onclick = () => { + page += 1; + searchOptions.skip = page * monitorDisplayData.itemCount; + NGIO.getScores(scoreBoardID, searchOptions, displayBoard); + } + + //For refreshing through the monitor, add a cooldown so we can do this easier; + const refreshClicked = (event) => { + event.stopImmediatePropagation(); + + buttonRefresh.removeEventListener("click", refreshClicked); + NGIO.getScores(scoreBoardID, searchOptions, displayBoard); + + setTimeout(() => { + buttonRefresh.addEventListener("click", refreshClicked); + }, 1000); + } + + buttonRefresh.addEventListener("click", refreshClicked); + + //Add dragging if we are in the editor + if (!isPackaged) { + //Create and add it down here for reasons + const resizeDiv = document.createElement("div"); + setElementCSS(resizeDiv, { cursor: "ne-resize" }); + resizeDiv.innerText = "="; + monitorHeader.appendChild(resizeDiv); + + //Now define the stuff we need for movement + let boundingRect = renderer.canvas.getBoundingClientRect(); + let offsetX = 0; + let offsetY = 0; + let originalX = 0; + let originalY = 0; + let yoffsetForResizing = 0; + + //Monitor movement code + const monitorDragMoveEvent = (event) => { + //Get position from a 0-1 scale + let placedPositionX = (event.clientX - offsetX - boundingRect.x) / boundingRect.width; + let placedPositionY = (event.clientY - offsetY - boundingRect.y) / boundingRect.height; + + //Clamp to stage + placedPositionX = Math.min(Math.max(0, placedPositionX), (1 - (monitorData.width / runtime.stageWidth))) * runtime.stageWidth; + placedPositionY = Math.min(Math.max(0, placedPositionY), (1 - (monitorData.height / runtime.stageHeight))) * runtime.stageHeight; + + monitorData.x = placedPositionX; + monitorData.y = placedPositionY; + + setElementCSS(monitorRoot, { + left: `${placedPositionX}px`, + top: `${placedPositionY}px` + }); + } + + const monitorDragReleaseEvent = () => { + setElementCSS(monitorRoot, { filter: "drop-shadow(rgba(0, 0, 0, 0.0) 0px 0px 0px)" }); + + this.serializeMonitor(this.monitors[scoreBoardID]); + + document.removeEventListener("mousemove", monitorDragMoveEvent); + + document.removeEventListener("mouseup", monitorDragReleaseEvent); + document.removeEventListener("mouseleave", monitorDragReleaseEvent); + } + + const monitorResizeMoveEvent = (event) => { + //Get position from a 0-1 scale + let placedSizeX = ((event.clientX - originalX) / boundingRect.width) + offsetX; + let placedSizeY = ((originalY - event.clientY) / boundingRect.height) + offsetY; + + //Clamp to stage + let placedPositionY = (yoffsetForResizing - (Math.max(125 / runtime.stageHeight, placedSizeY) - offsetY)) * runtime.stageHeight; + placedSizeX = Math.min(Math.max(125 / runtime.stageWidth, placedSizeX), 1) * runtime.stageWidth; + placedSizeY = Math.min(Math.max(125 / runtime.stageHeight, placedSizeY), 1) * runtime.stageHeight; + + monitorData.width = placedSizeX; + monitorData.height = placedSizeY; + monitorData.y = placedPositionY; + + setElementCSS(monitorRoot, { + width: `${placedSizeX}px`, + height: `${placedSizeY}px`, + top: `${placedPositionY}px` + }); + } + + const monitorResizeReleaseEvent = (event) => { + setElementCSS(monitorRoot, { filter: "drop-shadow(rgba(0, 0, 0, 0.0) 0px 0px 0px)" }); + + this.serializeMonitor(this.monitors[scoreBoardID]); + + document.removeEventListener("mousemove", monitorResizeMoveEvent); + + document.removeEventListener("mouseup", monitorResizeReleaseEvent); + document.removeEventListener("mouseleave", monitorResizeReleaseEvent); + } + + monitorHeader.onmousedown = (event) => { + event.stopImmediatePropagation(); + + boundingRect = renderer.canvas.getBoundingClientRect(); + const rootRect = monitorRoot.getBoundingClientRect(); + + offsetX = event.clientX - rootRect.x; + offsetY = event.clientY - rootRect.y; + originalX = event.clientX; + originalY = event.clientY; + + setElementCSS(monitorRoot, { filter: "drop-shadow(rgba(0, 0, 0, 0.6) 2px 2px 4px)" }); + + document.addEventListener("mousemove", monitorDragMoveEvent); + + document.addEventListener("mouseup", monitorDragReleaseEvent); + document.addEventListener("mouseleave", monitorDragReleaseEvent); + } + + resizeDiv.onmousedown = () => { + event.stopImmediatePropagation(); + + boundingRect = renderer.canvas.getBoundingClientRect(); + const rootRect = monitorRoot.getBoundingClientRect(); + + offsetX = monitorData.width / runtime.stageWidth; + offsetY = monitorData.height / runtime.stageHeight; + yoffsetForResizing = monitorData.y / runtime.stageHeight; + originalX = event.clientX; + originalY = event.clientY; + + document.addEventListener("mousemove", monitorResizeMoveEvent); + + document.addEventListener("mouseup", monitorResizeReleaseEvent); + document.addEventListener("mouseleave", monitorResizeReleaseEvent); + } + } + + //Display the first page + NGIO.getScores(scoreBoardID, searchOptions, displayBoard); Scratch.renderer.addOverlay(monitorRoot); + + //Finally store our new root element + monitorData.element = monitorRoot; + monitorData.refresh = () => { + NGIO.getScores(scoreBoardID, searchOptions, displayBoard); + } } } @@ -806,8 +1178,8 @@ const searchOptions = { period: timeSpan, - social: true, - skip: rank - 1, + social: false, + skip: Math.max(1, Scratch.Cast.toNumber(rank)) - 1, limit: 1, }; @@ -850,17 +1222,50 @@ }); } + getScoresBulk({ count, rank, scoreBoardID, timeSpan }) { + if (!(NGIO.session && gameData.scoreBoards[scoreBoardID])) return 0; + + const searchOptions = { + period: timeSpan, + social: false, + skip: Math.max(1, Scratch.Cast.toNumber(rank)) - 1, + limit: Math.min(Math.max(1, Scratch.Cast.toNumber(count)), 100), + }; + + return new Promise((resolve, reject) => { + NGIO.getScores(scoreBoardID, searchOptions, (board, scores) => { + const output = []; + + for (let scoreID in scores) { + output.push({ + name: scores[scoreID].user.name, + id: scores[scoreID].user.id, + isSupporting: scores[scoreID].user.supporter, + icon: scores[scoreID].user.icons.large, + score: scores[scoreID].value, + formattedScore: scores[scoreID].formatted_value + }); + } + + resolve(JSON.stringify(output)); + }); + }); + } + postScore({ score, scoreBoardID }) { if (NGIO.session && gameData.scoreBoards[scoreBoardID]) { - NGIO.postScore(scoreBoardID, score, () => { - Scratch.vm.runtime.startHats("NGIO_onScorePosted"); + //Wrap it in a promise to make sure the code is ran post score posting. + return new Promise((resolve, reject) => { + NGIO.postScore(scoreBoardID, Math.round(Scratch.Cast.toNumber(score)), () => { + runtime.startHats("NGIO_onScorePosted"); + resolve(); + }); }); } } scoreboardName({ scoreBoardID }) { if (NGIO.session && gameData.scoreBoards[scoreBoardID]) { - console.log(gameData.scoreBoards[scoreBoardID]); return gameData.scoreBoards[scoreBoardID].name; } else { @@ -870,10 +1275,38 @@ setScoreboardVisibility({ visibilityType, scoreBoardID }) { if (visibilityType == "show") this._createMonitorFor(scoreBoardID); + else if (visibilityType == "refresh") { + if (this.monitors[scoreBoardID] && this.monitors[scoreBoardID].refresh) { + this.monitors[scoreBoardID].refresh(); + } + } + else { + if (this.monitors[scoreBoardID] && this.monitors[scoreBoardID].element) { + const element = this.monitors[scoreBoardID].element; + element.parentElement.removeChild(element); + + //Clean up the scoreboard + delete this.monitors[scoreBoardID].element; + delete this.monitors[scoreBoardID].refresh; + } + } } onScorePosted() {} + //! V Completely necessary comment. + // :3 + setMonitorDisplayData({ property, value }) { + switch (property) { + case "itemCount": + monitorDisplayData.itemCount = Math.min(Math.max(1, Scratch.Cast.toNumber(value)), 100); + break; + + default: + break; + } + } + //Other Stuff onLoginSuccess() { @@ -908,13 +1341,13 @@ break; case "Login Required": - Scratch.vm.runtime.startHats("NGIO_onLoginRequired"); + runtime.startHats("NGIO_onLoginRequired"); clearInterval(intervalID); resolve(); break; case "Logged In": - Scratch.vm.runtime.startHats("NGIO_onLoginSuccess"); + runtime.startHats("NGIO_onLoginSuccess"); clearInterval(intervalID); //Set userDat object data @@ -1029,15 +1462,20 @@ //Configure our slot to be in a good range! Slot = Math.max(1, Math.floor(Scratch.Cast.toNumber(Slot))); - NGIO.setSaveSlotData( - Scratch.Cast.toString(Slot), - Scratch.Cast.toString(Data), - () => { - Scratch.vm.runtime.startHats("NGIO_onSaveCompletedHat"); - //Create dummy slot. - gameData.saveSlots[Slot] = {}; - } - ); + return new Promise((resolve, reject) => { + NGIO.setSaveSlotData( + Scratch.Cast.toString(Slot), + Scratch.Cast.toString(Data), + () => { + runtime.startHats("NGIO_onSaveCompletedHat"); + //Create dummy slot. + gameData.saveSlots[Slot] = { + hasData: true, + }; + + resolve(); + }); + }) } } @@ -1047,19 +1485,15 @@ Slot = Math.max(1, Math.floor(Scratch.Cast.toNumber(Slot))); let saveDat = "Nothing in Slot"; - return new Promise((resolve, reject) => { - //When the slot is loaded parse our data - function onSaveDataLoaded(data) { + //Try to get the data + if (!gameData.saveSlots[Slot]) resolve(""); + else NGIO.getSaveSlotData(Scratch.Cast.toNumber(Slot), () => { if (data) saveDat = Scratch.Cast.toString(data); else saveDat = ""; resolve(saveDat); - } - - //Try to get the data - if (!gameData.saveSlots[Slot]) resolve(""); - else NGIO.getSaveSlotData(Scratch.Cast.toNumber(Slot), onSaveDataLoaded); + }); }); } else { if (NGIO.session && !loggedIn) return "Not logged in!"; @@ -1085,6 +1519,8 @@ } //Medals + onMedalUnlockedHat() {} + unlockMedal({ medalID }) { if (NGIO.session && loggedIn) { this.revitalizeSession(); @@ -1092,7 +1528,9 @@ medalID = Scratch.Cast.toNumber(medalID); if (!(NGIO.session && gameData.medals[medalID])) return; - NGIO.unlockMedal(medalID); + NGIO.unlockMedal(medalID,() => { + runtime.startHats("NGIO_onMedalUnlockedHat"); + }); } } From a1f71c966dc50d73229429c4928fc81ca63ac466 Mon Sep 17 00:00:00 2001 From: "Dr. Cleve" <76855369+David-Orangemoon@users.noreply.github.com> Date: Sun, 28 Sep 2025 00:12:11 -0400 Subject: [PATCH 07/16] finalize --- extensions/obviousAlexC/newgroundsIO.js | 148 ++++++++++++++++-------- 1 file changed, 97 insertions(+), 51 deletions(-) diff --git a/extensions/obviousAlexC/newgroundsIO.js b/extensions/obviousAlexC/newgroundsIO.js index 7270165ab5..11dbbca08a 100644 --- a/extensions/obviousAlexC/newgroundsIO.js +++ b/extensions/obviousAlexC/newgroundsIO.js @@ -365,6 +365,10 @@ blocks: [ //Login Stuff + { + blockType: Scratch.BlockType.LABEL, + text: Scratch.translate("Connection") + }, { opcode: "onLoginSuccess", blockType: Scratch.BlockType.HAT, @@ -379,7 +383,7 @@ }, { opcode: "promptLogin", - blockType: Scratch.BlockType.COMMAND, //skipLogin + blockType: Scratch.BlockType.COMMAND, text: Scratch.translate("prompt user login"), }, { @@ -421,7 +425,7 @@ }, }, }, - + { opcode: "setConnectionData", blockType: Scratch.BlockType.COMMAND, @@ -431,7 +435,7 @@ arguments: { gameID: { type: Scratch.ArgumentType.STRING, - defaultValue: Scratch.translate("gameID"), + defaultValue: Scratch.translate("Game ID"), }, code: { type: Scratch.ArgumentType.STRING, @@ -446,6 +450,10 @@ "---", //Status Blocks + { + blockType: Scratch.BlockType.LABEL, + text: Scratch.translate("API data") + }, { opcode: "isNewgrounds", blockType: Scratch.BlockType.BOOLEAN, @@ -468,8 +476,27 @@ text: Scratch.translate("API status"), }, + { + blockType: Scratch.BlockType.LABEL, + text: Scratch.translate("Changes will occur post refresh.") + }, + { + opcode: "getMedals", + blockType: Scratch.BlockType.REPORTER, + text: Scratch.translate("game medals"), + }, + { + opcode: "getScoreboards", + blockType: Scratch.BlockType.REPORTER, + text: Scratch.translate("game scoreboards"), + }, + "---", //User Blocks + { + blockType: Scratch.BlockType.LABEL, + text: Scratch.translate("User data") + }, { opcode: "getIfSupporter", blockType: Scratch.BlockType.BOOLEAN, @@ -488,6 +515,10 @@ }, "---", //Save Blocks + { + blockType: Scratch.BlockType.LABEL, + text: Scratch.translate("Save data") + }, { opcode: "onSaveCompletedHat", blockType: Scratch.BlockType.HAT, @@ -534,6 +565,10 @@ "---", //Medal Blocks + { + blockType: Scratch.BlockType.LABEL, + text: Scratch.translate("Medals") + }, { opcode: "onMedalUnlockedHat", blockType: Scratch.BlockType.HAT, @@ -547,7 +582,7 @@ arguments: { medalID: { type: Scratch.ArgumentType.NUMBER, - defaultValue: Scratch.translate("MedalID"), + defaultValue: "000000", }, }, }, @@ -561,7 +596,7 @@ }, medalID: { type: Scratch.ArgumentType.NUMBER, - defaultValue: Scratch.translate("MedalID"), + defaultValue: "000000", }, }, }, @@ -572,7 +607,7 @@ arguments: { medalID: { type: Scratch.ArgumentType.NUMBER, - defaultValue: Scratch.translate("MedalID"), + defaultValue: "000000", }, }, }, @@ -583,13 +618,17 @@ arguments: { medalID: { type: Scratch.ArgumentType.NUMBER, - defaultValue: Scratch.translate("MedalID"), + defaultValue: "000000", }, }, }, "---", //Scoreboard Blocks + { + blockType: Scratch.BlockType.LABEL, + text: Scratch.translate("Scoreboards") + }, { opcode: "onScorePosted", blockType: Scratch.BlockType.HAT, @@ -676,6 +715,7 @@ }, }, }, + "---", { opcode: "setScoreboardVisibility", blockType: Scratch.BlockType.COMMAND, @@ -696,6 +736,10 @@ "---", //Settings/changability + { + blockType: Scratch.BlockType.LABEL, + text: Scratch.translate("Extra") + }, { opcode: "setMonitorDisplayData", blockType: Scratch.BlockType.COMMAND, @@ -847,7 +891,7 @@ acceptReporters: true, items: [ { - text: Scratch.translate("itemCount"), + text: Scratch.translate("Users per Page"), value: "itemCount", }, ], @@ -1223,7 +1267,7 @@ } getScoresBulk({ count, rank, scoreBoardID, timeSpan }) { - if (!(NGIO.session && gameData.scoreBoards[scoreBoardID])) return 0; + if (!(NGIO.session && gameData.scoreBoards[scoreBoardID])) return "{}"; const searchOptions = { period: timeSpan, @@ -1252,12 +1296,12 @@ }); } - postScore({ score, scoreBoardID }) { + postScore({ score, scoreBoardID }, util) { if (NGIO.session && gameData.scoreBoards[scoreBoardID]) { //Wrap it in a promise to make sure the code is ran post score posting. return new Promise((resolve, reject) => { NGIO.postScore(scoreBoardID, Math.round(Scratch.Cast.toNumber(score)), () => { - runtime.startHats("NGIO_onScorePosted"); + util.startHats("NGIO_onScorePosted"); resolve(); }); }); @@ -1292,7 +1336,7 @@ } } - onScorePosted() {} + onScorePosted() { return true; } //! V Completely necessary comment. // :3 @@ -1309,27 +1353,11 @@ //Other Stuff - onLoginSuccess() { - if (!userDat.logged) { - - NGIO.getConnectionStatus(statusReport); - return NGIO.hasUser; - } else { - return false; - } - } + onLoginSuccess() { return true; } - onLoginRequired() { - if (!userDat.requiredFired && ConnectionStatus == "Login Required") { - userDat.requiredFired = true; - NGIO.getConnectionStatus(statusReport); - return true; - } else { - return false; - } - } + onLoginRequired() { return true; } - waitForValid() { + waitForValid(util) { return new Promise((resolve, reject) => { const intervalID = setInterval(() => { NGIO.getConnectionStatus(statusReport); @@ -1341,13 +1369,13 @@ break; case "Login Required": - runtime.startHats("NGIO_onLoginRequired"); + util.startHats("NGIO_onLoginRequired"); clearInterval(intervalID); resolve(); break; case "Logged In": - runtime.startHats("NGIO_onLoginSuccess"); + util.startHats("NGIO_onLoginSuccess"); clearInterval(intervalID); //Set userDat object data @@ -1370,10 +1398,10 @@ }); } - promptLogin() { - if (NGIO.session) { + promptLogin(args, util) { + if (NGIO.session && !userDat.logged) { NGIO.openLoginPage(); - return this.waitForValid(); + return this.waitForValid(util); } } @@ -1395,13 +1423,13 @@ NGIO.getConnectionStatus(statusReport); } - setConnectionData({ gameID, code, version }) { + setConnectionData({ gameID, code, version }, util) { return new Promise((resolve, reject) => { NGOptions.version = version; NGIO.init(gameID, code, NGOptions); //Add a hook for the connection status to Newgrounds. - this.waitForValid().then(() => { + this.waitForValid(util).then(() => { resolve(); }); }); @@ -1428,6 +1456,28 @@ return isNG; } + getMedals() { + if (NGIO.session) { + const output = {}; + + for (let medalID in gameData.medals) { output[gameData.medals[medalID].name] = medalID; } + + return JSON.stringify(output); + } + else return "{}"; + } + + getScoreboards() { + if (NGIO.session) { + const output = {}; + + for (let scoreboardID in gameData.scoreBoards) { output[gameData.scoreBoards[scoreboardID].name] = scoreboardID; } + + return JSON.stringify(output); + } + else return "{}"; + } + //User Stuff getIfSupporter() { @@ -1455,9 +1505,9 @@ // Save Blocks - onSaveCompletedHat() {} + onSaveCompletedHat() { return true; } - saveData({ Data, Slot }) { + saveData({ Data, Slot }, util) { if (NGIO.session && loggedIn) { //Configure our slot to be in a good range! Slot = Math.max(1, Math.floor(Scratch.Cast.toNumber(Slot))); @@ -1467,7 +1517,7 @@ Scratch.Cast.toString(Slot), Scratch.Cast.toString(Data), () => { - runtime.startHats("NGIO_onSaveCompletedHat"); + util.startHats("NGIO_onSaveCompletedHat"); //Create dummy slot. gameData.saveSlots[Slot] = { hasData: true, @@ -1519,9 +1569,9 @@ } //Medals - onMedalUnlockedHat() {} + onMedalUnlockedHat() { return true; } - unlockMedal({ medalID }) { + unlockMedal({ medalID }, util) { if (NGIO.session && loggedIn) { this.revitalizeSession(); @@ -1529,7 +1579,7 @@ if (!(NGIO.session && gameData.medals[medalID])) return; NGIO.unlockMedal(medalID,() => { - runtime.startHats("NGIO_onMedalUnlockedHat"); + util.startHats("NGIO_onMedalUnlockedHat"); }); } } @@ -1592,13 +1642,9 @@ } } - //Keep Session alive if game is connected. - setInterval(() => { - NGIO.getConnectionStatus(statusReport); - if (loggedIn) { - NGIO.keepSessionAlive(); - } - }, 1500); + setInterval(function() { + NGIO.keepSessionAlive(); + }, 30000); Scratch.extensions.register(new NewgroundsAPI()); })(Scratch); From 3fcd7a7465fbe56bcfd6e618055f373ef791e13d Mon Sep 17 00:00:00 2001 From: "DangoCat[bot]" Date: Sun, 28 Sep 2025 04:14:13 +0000 Subject: [PATCH 08/16] [Automated] Format code --- extensions/obviousAlexC/newgroundsIO.js | 454 ++++++++++++++---------- 1 file changed, 265 insertions(+), 189 deletions(-) diff --git a/extensions/obviousAlexC/newgroundsIO.js b/extensions/obviousAlexC/newgroundsIO.js index 11dbbca08a..cfa1f73982 100644 --- a/extensions/obviousAlexC/newgroundsIO.js +++ b/extensions/obviousAlexC/newgroundsIO.js @@ -49,7 +49,7 @@ } //Make sure we load everything - if ((!NewgroundsIO) || (!NGIO) || (!CryptoJS)) { + if (!NewgroundsIO || !NGIO || !CryptoJS) { console.warn("One library needed for NGIO could not be loaded!"); } /* eslint-enable */ @@ -86,7 +86,7 @@ medals: {}, scoreBoards: {}, saveSlots: {}, - } + }; const quickParseData = (data) => { const returned = {}; @@ -97,7 +97,7 @@ } return returned; - } + }; //Define our user data. let userDat = { @@ -111,7 +111,7 @@ let monitorDisplayData = { itemCount: 20, - } + }; //Status functions and variable const statusReport = (status) => { @@ -173,7 +173,7 @@ break; } - } + }; let scorePosted = false; @@ -197,21 +197,21 @@ boxSizing: "border-box", //Picked up is drop-shadow(rgba(0, 0, 0, 0.6) 2px 2px 4px) filter: "drop-shadow(rgba(0, 0, 0, 0.0) 0px 0px 0px)", - transition: "filter 300ms" + transition: "filter 300ms", }, sc_monitor_list_label: { - backgroundColor: "white", - textAlign: "center", - fontWeight: "bold", - borderBottom: "1px solid hsla(0, 0%, 0%, 0.15)", - padding: "3px", + backgroundColor: "white", + textAlign: "center", + fontWeight: "bold", + borderBottom: "1px solid hsla(0, 0%, 0%, 0.15)", + padding: "3px", boxSizing: "border-box", - display: "flex" + display: "flex", }, sc_monitor_rows_outer: { - flexGrow: "1", + flexGrow: "1", boxSizing: "border-box", - overflowY: "scroll" + overflowY: "scroll", }, sc_monitor_list_footer: { display: "flex", @@ -219,7 +219,7 @@ textAlign: "center", fontWeight: "bold", padding: "3px", - boxSizing: "border-box" + boxSizing: "border-box", }, sc_monitor_row_root: { @@ -231,7 +231,7 @@ alignItems: "center", padding: "2px", width: "100%", - boxSizing: "border-box" + boxSizing: "border-box", }, sc_monitor_row_index: { fontWeight: "bold", @@ -240,7 +240,7 @@ boxSizing: "border-box", width: "25px", height: "25px", - borderRadius: "4px" + borderRadius: "4px", }, sc_monitor_row_value_outer: { display: "flex", @@ -253,7 +253,7 @@ margin: "0 3px", borderRadius: "calc(0.5rem / 2)", flexGrow: "1", - boxSizing: "border-box" + boxSizing: "border-box", }, sc_monitor_row_value_inner: { padding: "3px 5px", @@ -270,24 +270,23 @@ whiteSpace: "pre", }, - sc_monitor_page_text: { - flexGrow: "1", + flexGrow: "1", boxSizing: "border-box", }, sc_monitor_page_button: { border: "1px solid", borderRadius: "4px", borderColor: "rgba(0, 0, 0, 0.15)", - background: "white" + background: "white", }, sc_monitor_page_button_disabled: { border: "1px solid", borderRadius: "4px", borderColor: "rgba(0, 0, 0, 0.15)", - background: "hsla(215, 100%, 95%, 1)" - } - } + background: "hsla(215, 100%, 95%, 1)", + }, + }; const setElementCSS = (element, cssObject) => { if (element instanceof HTMLElement && typeof cssObject == "object") { @@ -295,16 +294,16 @@ element.style[key] = cssObject[key]; } } - } + }; //Finally our scratch stuff const runtime = Scratch.vm.runtime; const renderer = Scratch.vm.renderer; - const isPackaged = (typeof scaffolding !== "undefined"); + const isPackaged = typeof scaffolding !== "undefined"; const originifyJson = (inObject) => { return JSON.parse(JSON.stringify(inObject)); - } + }; ("use strict"); class NewgroundsAPI { @@ -313,7 +312,9 @@ this.serializedMonitors = {}; this.setupSaving(); - vm.runtime.on("PROJECT_LOADED", () => {this.setupSaving.call(this)}); + vm.runtime.on("PROJECT_LOADED", () => { + this.setupSaving.call(this); + }); } setupSaving() { @@ -329,13 +330,17 @@ this.monitors = deserializedData.monitors; this.serializedMonitors = deserializedData.monitors; }; - } - else { + } else { //Storage flip flop - if (!runtime.extensionStorage["NGIO"]) runtime.extensionStorage["NGIO"] = new Object({ monitors: {} }); - - this.serializedMonitors = originifyJson(runtime.extensionStorage["NGIO"].monitors); - this.monitors = originifyJson(runtime.extensionStorage["NGIO"].monitors); + if (!runtime.extensionStorage["NGIO"]) + runtime.extensionStorage["NGIO"] = new Object({ monitors: {} }); + + this.serializedMonitors = originifyJson( + runtime.extensionStorage["NGIO"].monitors + ); + this.monitors = originifyJson( + runtime.extensionStorage["NGIO"].monitors + ); } } @@ -348,7 +353,8 @@ id: monitorData.id, }; - if (!Scratch.extensions.isPenguinMod) runtime.extensionStorage["NGIO"].monitors = this.serializedMonitors; + if (!Scratch.extensions.isPenguinMod) + runtime.extensionStorage["NGIO"].monitors = this.serializedMonitors; } getInfo() { @@ -367,19 +373,19 @@ //Login Stuff { blockType: Scratch.BlockType.LABEL, - text: Scratch.translate("Connection") + text: Scratch.translate("Connection"), }, { opcode: "onLoginSuccess", blockType: Scratch.BlockType.HAT, text: Scratch.translate("when login success"), - isEdgeActivated: false + isEdgeActivated: false, }, { opcode: "onLoginRequired", blockType: Scratch.BlockType.HAT, text: Scratch.translate("when login required"), - isEdgeActivated: false + isEdgeActivated: false, }, { opcode: "promptLogin", @@ -425,7 +431,7 @@ }, }, }, - + { opcode: "setConnectionData", blockType: Scratch.BlockType.COMMAND, @@ -452,7 +458,7 @@ { blockType: Scratch.BlockType.LABEL, - text: Scratch.translate("API data") + text: Scratch.translate("API data"), }, { opcode: "isNewgrounds", @@ -478,7 +484,7 @@ { blockType: Scratch.BlockType.LABEL, - text: Scratch.translate("Changes will occur post refresh.") + text: Scratch.translate("Changes will occur post refresh."), }, { opcode: "getMedals", @@ -495,7 +501,7 @@ { blockType: Scratch.BlockType.LABEL, - text: Scratch.translate("User data") + text: Scratch.translate("User data"), }, { opcode: "getIfSupporter", @@ -517,13 +523,13 @@ "---", //Save Blocks { blockType: Scratch.BlockType.LABEL, - text: Scratch.translate("Save data") + text: Scratch.translate("Save data"), }, { opcode: "onSaveCompletedHat", blockType: Scratch.BlockType.HAT, text: Scratch.translate("when save completed"), - isEdgeActivated: false + isEdgeActivated: false, }, { opcode: "saveData", @@ -564,16 +570,16 @@ }, "---", //Medal Blocks - + { blockType: Scratch.BlockType.LABEL, - text: Scratch.translate("Medals") + text: Scratch.translate("Medals"), }, { opcode: "onMedalUnlockedHat", blockType: Scratch.BlockType.HAT, text: Scratch.translate("when medal unlocked"), - isEdgeActivated: false + isEdgeActivated: false, }, { opcode: "unlockMedal", @@ -592,7 +598,7 @@ text: Scratch.translate("get [data] of medal [medalID]"), arguments: { data: { - menu: "medalDatType", + menu: "medalDatType", }, medalID: { type: Scratch.ArgumentType.NUMBER, @@ -627,13 +633,13 @@ { blockType: Scratch.BlockType.LABEL, - text: Scratch.translate("Scoreboards") + text: Scratch.translate("Scoreboards"), }, { opcode: "onScorePosted", blockType: Scratch.BlockType.HAT, text: Scratch.translate("when score posted"), - isEdgeActivated: false + isEdgeActivated: false, }, { opcode: "postScore", @@ -655,14 +661,12 @@ { opcode: "scoreboardName", blockType: Scratch.BlockType.REPORTER, - text: Scratch.translate( - "name of scoreboard [scoreBoardID]" - ), + text: Scratch.translate("name of scoreboard [scoreBoardID]"), arguments: { scoreBoardID: { type: Scratch.ArgumentType.NUMBER, defaultValue: "000000", - } + }, }, }, { @@ -731,21 +735,19 @@ type: Scratch.ArgumentType.NUMBER, defaultValue: "000000", }, - } + }, }, "---", //Settings/changability - + { blockType: Scratch.BlockType.LABEL, - text: Scratch.translate("Extra") + text: Scratch.translate("Extra"), }, { opcode: "setMonitorDisplayData", blockType: Scratch.BlockType.COMMAND, - text: Scratch.translate( - "set [property] to [value]" - ), + text: Scratch.translate("set [property] to [value]"), arguments: { property: { type: Scratch.ArgumentType.STRING, @@ -755,7 +757,7 @@ type: Scratch.ArgumentType.STRING, defaultValue: "20", }, - } + }, }, "---", //Referrals @@ -884,7 +886,7 @@ { text: Scratch.translate("refresh"), value: "refresh", - } + }, ], }, displayPropertyTypes: { @@ -895,7 +897,7 @@ value: "itemCount", }, ], - } + }, }, }; } @@ -912,20 +914,19 @@ if (!this.monitors[scoreBoardID]) { monitorExists = false; this.monitors[scoreBoardID] = { - x: (runtime.stageWidth / 2) - 62.5, - y: (runtime.stageHeight / 2) - 100, + x: runtime.stageWidth / 2 - 62.5, + y: runtime.stageHeight / 2 - 100, width: 125, height: 200, - id: scoreBoardID - } + id: scoreBoardID, + }; this.serializeMonitor(this.monitors[scoreBoardID]); - } - else if (!this.monitors[scoreBoardID].element) monitorExists = false; + } else if (!this.monitors[scoreBoardID].element) monitorExists = false; //Now we decide if we need to create or just ignore the monitor const monitorData = this.monitors[scoreBoardID]; - + if (!monitorExists) { //Create elements and set up css const monitorRoot = document.createElement("div"); @@ -991,7 +992,7 @@ //Actually displaying the board const displayBoard = (board, scores) => { - if (scores.length == 0) { + if (scores.length == 0) { buttonPrevious.disabled = true; buttonNext.disabled = true; return; @@ -1004,18 +1005,28 @@ buttonNext.disabled = false; if (page == 0) buttonPrevious.disabled = true; - if (scores.length != (monitorDisplayData.itemCount + 1)) buttonNext.disabled = true; + if (scores.length != monitorDisplayData.itemCount + 1) + buttonNext.disabled = true; //Make sure buttons reflect the options - if (buttonPrevious.disabled) setElementCSS(buttonPrevious, customCSS.sc_monitor_page_button_disabled); + if (buttonPrevious.disabled) + setElementCSS( + buttonPrevious, + customCSS.sc_monitor_page_button_disabled + ); else setElementCSS(buttonPrevious, customCSS.sc_monitor_page_button); - if (buttonNext.disabled) setElementCSS(buttonNext, customCSS.sc_monitor_page_button_disabled); + if (buttonNext.disabled) + setElementCSS( + buttonNext, + customCSS.sc_monitor_page_button_disabled + ); else setElementCSS(buttonNext, customCSS.sc_monitor_page_button); //start displaying the monitor let scoresToDisplay = scores.length; - if (scores.length == (monitorDisplayData.itemCount + 1)) scoresToDisplay--; + if (scores.length == monitorDisplayData.itemCount + 1) + scoresToDisplay--; monitorInner.innerHTML = ""; @@ -1040,36 +1051,40 @@ rowOuter.appendChild(rowValue); rowValue.appendChild(rowValueText); - rowIndex.onmouseover = () => { rowValueText.innerText = score.user.name; } - rowIndex.onmouseout = () => { rowValueText.innerText = score.formatted_value; } + rowIndex.onmouseover = () => { + rowValueText.innerText = score.user.name; + }; + rowIndex.onmouseout = () => { + rowValueText.innerText = score.formatted_value; + }; monitorInner.appendChild(rowOuter); } - } + }; buttonPrevious.onclick = () => { page -= 1; searchOptions.skip = page * monitorDisplayData.itemCount; NGIO.getScores(scoreBoardID, searchOptions, displayBoard); - } + }; buttonNext.onclick = () => { page += 1; searchOptions.skip = page * monitorDisplayData.itemCount; NGIO.getScores(scoreBoardID, searchOptions, displayBoard); - } + }; //For refreshing through the monitor, add a cooldown so we can do this easier; const refreshClicked = (event) => { event.stopImmediatePropagation(); - + buttonRefresh.removeEventListener("click", refreshClicked); NGIO.getScores(scoreBoardID, searchOptions, displayBoard); setTimeout(() => { buttonRefresh.addEventListener("click", refreshClicked); }, 1000); - } + }; buttonRefresh.addEventListener("click", refreshClicked); @@ -1092,24 +1107,36 @@ //Monitor movement code const monitorDragMoveEvent = (event) => { //Get position from a 0-1 scale - let placedPositionX = (event.clientX - offsetX - boundingRect.x) / boundingRect.width; - let placedPositionY = (event.clientY - offsetY - boundingRect.y) / boundingRect.height; + let placedPositionX = + (event.clientX - offsetX - boundingRect.x) / boundingRect.width; + let placedPositionY = + (event.clientY - offsetY - boundingRect.y) / boundingRect.height; //Clamp to stage - placedPositionX = Math.min(Math.max(0, placedPositionX), (1 - (monitorData.width / runtime.stageWidth))) * runtime.stageWidth; - placedPositionY = Math.min(Math.max(0, placedPositionY), (1 - (monitorData.height / runtime.stageHeight))) * runtime.stageHeight; + placedPositionX = + Math.min( + Math.max(0, placedPositionX), + 1 - monitorData.width / runtime.stageWidth + ) * runtime.stageWidth; + placedPositionY = + Math.min( + Math.max(0, placedPositionY), + 1 - monitorData.height / runtime.stageHeight + ) * runtime.stageHeight; monitorData.x = placedPositionX; monitorData.y = placedPositionY; setElementCSS(monitorRoot, { left: `${placedPositionX}px`, - top: `${placedPositionY}px` + top: `${placedPositionY}px`, }); - } + }; const monitorDragReleaseEvent = () => { - setElementCSS(monitorRoot, { filter: "drop-shadow(rgba(0, 0, 0, 0.0) 0px 0px 0px)" }); + setElementCSS(monitorRoot, { + filter: "drop-shadow(rgba(0, 0, 0, 0.0) 0px 0px 0px)", + }); this.serializeMonitor(this.monitors[scoreBoardID]); @@ -1117,17 +1144,26 @@ document.removeEventListener("mouseup", monitorDragReleaseEvent); document.removeEventListener("mouseleave", monitorDragReleaseEvent); - } + }; const monitorResizeMoveEvent = (event) => { //Get position from a 0-1 scale - let placedSizeX = ((event.clientX - originalX) / boundingRect.width) + offsetX; - let placedSizeY = ((originalY - event.clientY) / boundingRect.height) + offsetY; + let placedSizeX = + (event.clientX - originalX) / boundingRect.width + offsetX; + let placedSizeY = + (originalY - event.clientY) / boundingRect.height + offsetY; - //Clamp to stage - let placedPositionY = (yoffsetForResizing - (Math.max(125 / runtime.stageHeight, placedSizeY) - offsetY)) * runtime.stageHeight; - placedSizeX = Math.min(Math.max(125 / runtime.stageWidth, placedSizeX), 1) * runtime.stageWidth; - placedSizeY = Math.min(Math.max(125 / runtime.stageHeight, placedSizeY), 1) * runtime.stageHeight; + //Clamp to stage + let placedPositionY = + (yoffsetForResizing - + (Math.max(125 / runtime.stageHeight, placedSizeY) - offsetY)) * + runtime.stageHeight; + placedSizeX = + Math.min(Math.max(125 / runtime.stageWidth, placedSizeX), 1) * + runtime.stageWidth; + placedSizeY = + Math.min(Math.max(125 / runtime.stageHeight, placedSizeY), 1) * + runtime.stageHeight; monitorData.width = placedSizeX; monitorData.height = placedSizeY; @@ -1136,24 +1172,29 @@ setElementCSS(monitorRoot, { width: `${placedSizeX}px`, height: `${placedSizeY}px`, - top: `${placedPositionY}px` - }); - } + top: `${placedPositionY}px`, + }); + }; const monitorResizeReleaseEvent = (event) => { - setElementCSS(monitorRoot, { filter: "drop-shadow(rgba(0, 0, 0, 0.0) 0px 0px 0px)" }); + setElementCSS(monitorRoot, { + filter: "drop-shadow(rgba(0, 0, 0, 0.0) 0px 0px 0px)", + }); - this.serializeMonitor(this.monitors[scoreBoardID]); + this.serializeMonitor(this.monitors[scoreBoardID]); document.removeEventListener("mousemove", monitorResizeMoveEvent); document.removeEventListener("mouseup", monitorResizeReleaseEvent); - document.removeEventListener("mouseleave", monitorResizeReleaseEvent); - } + document.removeEventListener( + "mouseleave", + monitorResizeReleaseEvent + ); + }; monitorHeader.onmousedown = (event) => { event.stopImmediatePropagation(); - + boundingRect = renderer.canvas.getBoundingClientRect(); const rootRect = monitorRoot.getBoundingClientRect(); @@ -1162,17 +1203,19 @@ originalX = event.clientX; originalY = event.clientY; - setElementCSS(monitorRoot, { filter: "drop-shadow(rgba(0, 0, 0, 0.6) 2px 2px 4px)" }); + setElementCSS(monitorRoot, { + filter: "drop-shadow(rgba(0, 0, 0, 0.6) 2px 2px 4px)", + }); document.addEventListener("mousemove", monitorDragMoveEvent); document.addEventListener("mouseup", monitorDragReleaseEvent); document.addEventListener("mouseleave", monitorDragReleaseEvent); - } + }; resizeDiv.onmousedown = () => { event.stopImmediatePropagation(); - + boundingRect = renderer.canvas.getBoundingClientRect(); const rootRect = monitorRoot.getBoundingClientRect(); @@ -1186,7 +1229,7 @@ document.addEventListener("mouseup", monitorResizeReleaseEvent); document.addEventListener("mouseleave", monitorResizeReleaseEvent); - } + }; } //Display the first page @@ -1198,7 +1241,7 @@ monitorData.element = monitorRoot; monitorData.refresh = () => { NGIO.getScores(scoreBoardID, searchOptions, displayBoard); - } + }; } } @@ -1219,7 +1262,7 @@ getScore({ rank, scoreBoardID, timeSpan, scoreDataType }) { if (!(NGIO.session && gameData.scoreBoards[scoreBoardID])) return 0; - + const searchOptions = { period: timeSpan, social: false, @@ -1268,7 +1311,7 @@ getScoresBulk({ count, rank, scoreBoardID, timeSpan }) { if (!(NGIO.session && gameData.scoreBoards[scoreBoardID])) return "{}"; - + const searchOptions = { period: timeSpan, social: false, @@ -1287,7 +1330,7 @@ isSupporting: scores[scoreID].user.supporter, icon: scores[scoreID].user.icons.large, score: scores[scoreID].value, - formattedScore: scores[scoreID].formatted_value + formattedScore: scores[scoreID].formatted_value, }); } @@ -1300,10 +1343,14 @@ if (NGIO.session && gameData.scoreBoards[scoreBoardID]) { //Wrap it in a promise to make sure the code is ran post score posting. return new Promise((resolve, reject) => { - NGIO.postScore(scoreBoardID, Math.round(Scratch.Cast.toNumber(score)), () => { - util.startHats("NGIO_onScorePosted"); - resolve(); - }); + NGIO.postScore( + scoreBoardID, + Math.round(Scratch.Cast.toNumber(score)), + () => { + util.startHats("NGIO_onScorePosted"); + resolve(); + } + ); }); } } @@ -1311,21 +1358,25 @@ scoreboardName({ scoreBoardID }) { if (NGIO.session && gameData.scoreBoards[scoreBoardID]) { return gameData.scoreBoards[scoreBoardID].name; - } - else { + } else { return ""; - } + } } setScoreboardVisibility({ visibilityType, scoreBoardID }) { if (visibilityType == "show") this._createMonitorFor(scoreBoardID); else if (visibilityType == "refresh") { - if (this.monitors[scoreBoardID] && this.monitors[scoreBoardID].refresh) { + if ( + this.monitors[scoreBoardID] && + this.monitors[scoreBoardID].refresh + ) { this.monitors[scoreBoardID].refresh(); } - } - else { - if (this.monitors[scoreBoardID] && this.monitors[scoreBoardID].element) { + } else { + if ( + this.monitors[scoreBoardID] && + this.monitors[scoreBoardID].element + ) { const element = this.monitors[scoreBoardID].element; element.parentElement.removeChild(element); @@ -1336,16 +1387,21 @@ } } - onScorePosted() { return true; } + onScorePosted() { + return true; + } //! V Completely necessary comment. // :3 setMonitorDisplayData({ property, value }) { switch (property) { case "itemCount": - monitorDisplayData.itemCount = Math.min(Math.max(1, Scratch.Cast.toNumber(value)), 100); + monitorDisplayData.itemCount = Math.min( + Math.max(1, Scratch.Cast.toNumber(value)), + 100 + ); break; - + default: break; } @@ -1353,47 +1409,51 @@ //Other Stuff - onLoginSuccess() { return true; } + onLoginSuccess() { + return true; + } - onLoginRequired() { return true; } + onLoginRequired() { + return true; + } waitForValid(util) { return new Promise((resolve, reject) => { - const intervalID = setInterval(() => { - NGIO.getConnectionStatus(statusReport); - - //Wait for finish - switch (ConnectionStatus) { - //In case we aren't awaiting - case "Awaiting": - break; - - case "Login Required": - util.startHats("NGIO_onLoginRequired"); - clearInterval(intervalID); - resolve(); - break; - - case "Logged In": - util.startHats("NGIO_onLoginSuccess"); - clearInterval(intervalID); - - //Set userDat object data - userDat.logged = NGIO.hasUser; - if (userDat.logged == true) { - userDat.icon = NGIO.user.icons.large; - userDat.name = NGIO.user.name; - userDat.supporter = NGIO.user.supporter; - userDat.id = NGIO.user.id; - } - resolve(); - break; - - default: - clearInterval(intervalID); - resolve(); - break; - } + const intervalID = setInterval(() => { + NGIO.getConnectionStatus(statusReport); + + //Wait for finish + switch (ConnectionStatus) { + //In case we aren't awaiting + case "Awaiting": + break; + + case "Login Required": + util.startHats("NGIO_onLoginRequired"); + clearInterval(intervalID); + resolve(); + break; + + case "Logged In": + util.startHats("NGIO_onLoginSuccess"); + clearInterval(intervalID); + + //Set userDat object data + userDat.logged = NGIO.hasUser; + if (userDat.logged == true) { + userDat.icon = NGIO.user.icons.large; + userDat.name = NGIO.user.name; + userDat.supporter = NGIO.user.supporter; + userDat.id = NGIO.user.id; + } + resolve(); + break; + + default: + clearInterval(intervalID); + resolve(); + break; + } }); }); } @@ -1460,22 +1520,24 @@ if (NGIO.session) { const output = {}; - for (let medalID in gameData.medals) { output[gameData.medals[medalID].name] = medalID; } + for (let medalID in gameData.medals) { + output[gameData.medals[medalID].name] = medalID; + } return JSON.stringify(output); - } - else return "{}"; + } else return "{}"; } getScoreboards() { if (NGIO.session) { const output = {}; - for (let scoreboardID in gameData.scoreBoards) { output[gameData.scoreBoards[scoreboardID].name] = scoreboardID; } + for (let scoreboardID in gameData.scoreBoards) { + output[gameData.scoreBoards[scoreboardID].name] = scoreboardID; + } return JSON.stringify(output); - } - else return "{}"; + } else return "{}"; } //User Stuff @@ -1505,7 +1567,9 @@ // Save Blocks - onSaveCompletedHat() { return true; } + onSaveCompletedHat() { + return true; + } saveData({ Data, Slot }, util) { if (NGIO.session && loggedIn) { @@ -1524,8 +1588,9 @@ }; resolve(); - }); - }) + } + ); + }); } } @@ -1538,12 +1603,13 @@ return new Promise((resolve, reject) => { //Try to get the data if (!gameData.saveSlots[Slot]) resolve(""); - else NGIO.getSaveSlotData(Scratch.Cast.toNumber(Slot), () => { - if (data) saveDat = Scratch.Cast.toString(data); - else saveDat = ""; + else + NGIO.getSaveSlotData(Scratch.Cast.toNumber(Slot), () => { + if (data) saveDat = Scratch.Cast.toString(data); + else saveDat = ""; - resolve(saveDat); - }); + resolve(saveDat); + }); }); } else { if (NGIO.session && !loggedIn) return "Not logged in!"; @@ -1569,7 +1635,9 @@ } //Medals - onMedalUnlockedHat() { return true; } + onMedalUnlockedHat() { + return true; + } unlockMedal({ medalID }, util) { if (NGIO.session && loggedIn) { @@ -1578,8 +1646,8 @@ medalID = Scratch.Cast.toNumber(medalID); if (!(NGIO.session && gameData.medals[medalID])) return; - NGIO.unlockMedal(medalID,() => { - util.startHats("NGIO_onMedalUnlockedHat"); + NGIO.unlockMedal(medalID, () => { + util.startHats("NGIO_onMedalUnlockedHat"); }); } } @@ -1609,7 +1677,7 @@ return false; } } - + getMedalData({ data, medalID }) { if (NGIO.session && loggedIn) { this.revitalizeSession(); @@ -1620,14 +1688,22 @@ const medal = gameData.medals[medalID]; switch (data) { - case "name": return medal.name; - case "description": return medal.description; + case "name": + return medal.name; + case "description": + return medal.description; //Make sure we get a url - case "icon": return (medal.icon.startsWith("https:")) ? medal.icon : "https:" + medal.icon; - case "difficulty": return medal.difficulty; - case "value": return medal.value; - - default: return ""; + case "icon": + return medal.icon.startsWith("https:") + ? medal.icon + : "https:" + medal.icon; + case "difficulty": + return medal.difficulty; + case "value": + return medal.value; + + default: + return ""; } } else { return ""; @@ -1642,7 +1718,7 @@ } } - setInterval(function() { + setInterval(function () { NGIO.keepSessionAlive(); }, 30000); From d7c7b277a59230fe4a57b805d48957278054a084 Mon Sep 17 00:00:00 2001 From: "Dr. Cleve" <76855369+David-Orangemoon@users.noreply.github.com> Date: Sun, 28 Sep 2025 00:17:35 -0400 Subject: [PATCH 09/16] fix linting --- extensions/obviousAlexC/newgroundsIO.js | 8 ++------ 1 file changed, 2 insertions(+), 6 deletions(-) diff --git a/extensions/obviousAlexC/newgroundsIO.js b/extensions/obviousAlexC/newgroundsIO.js index cfa1f73982..9a890c4137 100644 --- a/extensions/obviousAlexC/newgroundsIO.js +++ b/extensions/obviousAlexC/newgroundsIO.js @@ -65,7 +65,6 @@ let ConnectionStatus = "Awaiting"; let loggedIn = false; - let saveCompleted = false; const NGOptions = { // This should match the version number in your Newgrounds App Settings page @@ -175,8 +174,6 @@ } }; - let scorePosted = false; - //css "classes" for our monitor for convience const customCSS = { sc_monitor_root: { @@ -312,7 +309,7 @@ this.serializedMonitors = {}; this.setupSaving(); - vm.runtime.on("PROJECT_LOADED", () => { + Scratch.vm.runtime.on("PROJECT_LOADED", () => { this.setupSaving.call(this); }); } @@ -1217,7 +1214,6 @@ event.stopImmediatePropagation(); boundingRect = renderer.canvas.getBoundingClientRect(); - const rootRect = monitorRoot.getBoundingClientRect(); offsetX = monitorData.width / runtime.stageWidth; offsetY = monitorData.height / runtime.stageHeight; @@ -1604,7 +1600,7 @@ //Try to get the data if (!gameData.saveSlots[Slot]) resolve(""); else - NGIO.getSaveSlotData(Scratch.Cast.toNumber(Slot), () => { + NGIO.getSaveSlotData(Scratch.Cast.toNumber(Slot), (data) => { if (data) saveDat = Scratch.Cast.toString(data); else saveDat = ""; From 09e944cb801c6a1ef8d32545af0acfe0219d7543 Mon Sep 17 00:00:00 2001 From: "Dr. Cleve" <76855369+David-Orangemoon@users.noreply.github.com> Date: Thu, 2 Oct 2025 14:58:24 -0400 Subject: [PATCH 10/16] allow fetching --- extensions/obviousAlexC/newgroundsIO.js | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) diff --git a/extensions/obviousAlexC/newgroundsIO.js b/extensions/obviousAlexC/newgroundsIO.js index 9a890c4137..a0a3f082e1 100644 --- a/extensions/obviousAlexC/newgroundsIO.js +++ b/extensions/obviousAlexC/newgroundsIO.js @@ -1480,7 +1480,17 @@ } setConnectionData({ gameID, code, version }, util) { - return new Promise((resolve, reject) => { + return new Promise(async (resolve, reject) => { + + //Just do it once + const canFetch = await Scratch.canFetch("https://www.newgrounds.io/"); + + //Make sure it is possible + if (!canFetch) { + reject(); + return; + } + NGOptions.version = version; NGIO.init(gameID, code, NGOptions); From 77ba40fad9d533ee41ad98c4d5833e0989ea8ea7 Mon Sep 17 00:00:00 2001 From: "Dr. Cleve" <76855369+David-Orangemoon@users.noreply.github.com> Date: Thu, 2 Oct 2025 15:01:06 -0400 Subject: [PATCH 11/16] Fix lint --- extensions/obviousAlexC/newgroundsIO.js | 1 + 1 file changed, 1 insertion(+) diff --git a/extensions/obviousAlexC/newgroundsIO.js b/extensions/obviousAlexC/newgroundsIO.js index a0a3f082e1..ea7c79db96 100644 --- a/extensions/obviousAlexC/newgroundsIO.js +++ b/extensions/obviousAlexC/newgroundsIO.js @@ -1480,6 +1480,7 @@ } setConnectionData({ gameID, code, version }, util) { + //eslint-disable-next-line no-async-promise-executor return new Promise(async (resolve, reject) => { //Just do it once From 1893d8f683e4c6e88d86d7e7d07f8ee2a7b94a43 Mon Sep 17 00:00:00 2001 From: "DangoCat[bot]" Date: Thu, 2 Oct 2025 19:02:27 +0000 Subject: [PATCH 12/16] [Automated] Format code --- extensions/obviousAlexC/newgroundsIO.js | 1 - 1 file changed, 1 deletion(-) diff --git a/extensions/obviousAlexC/newgroundsIO.js b/extensions/obviousAlexC/newgroundsIO.js index ea7c79db96..b512bb20e6 100644 --- a/extensions/obviousAlexC/newgroundsIO.js +++ b/extensions/obviousAlexC/newgroundsIO.js @@ -1482,7 +1482,6 @@ setConnectionData({ gameID, code, version }, util) { //eslint-disable-next-line no-async-promise-executor return new Promise(async (resolve, reject) => { - //Just do it once const canFetch = await Scratch.canFetch("https://www.newgrounds.io/"); From 424be3115e3889557758ef2c6b280c8187a4162a Mon Sep 17 00:00:00 2001 From: "Dr. Cleve" <76855369+David-Orangemoon@users.noreply.github.com> Date: Thu, 2 Oct 2025 21:19:30 -0400 Subject: [PATCH 13/16] replace old link with new one. --- extensions/obviousAlexC/newgroundsIO.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/extensions/obviousAlexC/newgroundsIO.js b/extensions/obviousAlexC/newgroundsIO.js index b512bb20e6..b445cf3149 100644 --- a/extensions/obviousAlexC/newgroundsIO.js +++ b/extensions/obviousAlexC/newgroundsIO.js @@ -105,7 +105,7 @@ id: 0, supporter: false, requiredFired: false, - icon: "https://raw.githubusercontent.com/David-Orangemoon/DataHoldersRepo/main/newgroundsHolding/UnknownUser.png", + icon: "data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAADwAAAA8CAYAAAA6/NlyAAAAAXNSR0IArs4c6QAAAARnQU1BAACxjwv8YQUAAAAJcEhZcwAADsMAAA7DAcdvqGQAAAY3SURBVGhD7ZprbJNVGMf/27ru1sEurMxtsEvHBGHcjAbYYKgxMRDgA6h8QAlRgrcY4xcJfjNBvqrBSFiMGAxBRIwoxEQEdIioARlgNte5bgzJ1rGyS3fpug2f5+yUjNJ2fc/7duuAX/Km7znr3vP8+z7nPM+5xOCDY7dwHxErP+8bHgi+13kg+F7ngeB7nftOcMQTD1MMsCTLgnKrBQvTk1GYmoDMBBMS42LRPzSMds8gHN0eXLzZizNON861uTEYQYsiJtiaaMJLxVnYWJghBIYL/wAHHS58Wt8GZ/+grDUOwwWbY2Pw+sNWvEZXkkm9x/QNDuOTOic+rnXCM2yciYYKtpG77lmSjzlTk2SNfmo6+/DquSbUk9sbgWGDVhn10++enGWoWIafd5SeW0ZjgBEYIpjF7isvxJT4OFljLPzcfWWFhojWLZjduHJZAZJo1I0k/PzKpQUopvb0oMtKHqC4z0bqzfrD7XB7CdSuKroE82g8us9e7xlA8ZFLsjRC3lfV4tPtHcJbfzSh4OtqvHO+WdR939yB53+uF1fe4Wocbb6Ja70Dojzj8CW8/edVVLt6xXd9zKb23phtlSXtKAvmOMuhx5+ZFrO88zESBHbXtmKpNRWN6xdgTV6aqOPEI91swpcVxbi2YQHWzkiHZ+gW6ro8aN4wH6typ+JN+pH8eaXEKtpXQVkwJxWB4mwcRbpAkA5cpmyKKZ+eKj7HIjc5Ht4AQZPb3TorS5a0oSSY00XOoAIRE6R7vTs/B7H0x8eO/Y29lFD4ON3SJdx5Jl0+2j1D2HDajqdP1GHXolxZeycbCzIQH6yxECgJ5tw4WLoYyoT3Fubi4AobDjW6cL69R9StzJ4i3PkqXT74zX5WVoRNhZlo7vXK2jtJp/aXWlNkKXyUBPNEIBA5KWY43B40UB9kLrp68Igc1K5Id7alJmJuWjK6vcOiHIgkcqFUGpFfLsnCAccNWXs3y2lM0IqSYJ71BGPHvBxU/FiLbb85sOZkPbaXZov6SvsNbKpqwOYzDRig3Hhl9oix52kUrvihRrj15/+OiDPHjphVTD/ONBrUqlq7Rdmf+SHsCIZSLv37qjnkdv6j8Z1cp/CS4/edmzQT4m6XRiJ8DI6aGJhkfOW6QPf+cBuPH6+RpfBQesPhTPf8xTLc70aLZViM7/IR7N4fLdNOH0qCefIeDSQo2KFkOScM0YBHwQ4lwS7qi9EAr45oRUlwA4WeaMDhHpB34aMkuNrVJ+8mFl+qqgUlwVXOwHFxvKlyuuVd+CgJ5qVUlf5jJBzTz46XYF435nx4IjnU5KKZlOacSU0wU2lvE0upEwGHxcq6NlnShrJgXiTfM2qaN57sJbEtiov0yoKZ3bVO1HaO74ht7+rHhzWtsqQdXYJ5R4AXybu8Q7ImsnRTO9vONeraidAlmLF3e2gq2BjxdJPTSBbL61160C2Y4Xi45VeHeAORgJ+75awDv7RqD0P+GCKYYdFrT9rxT2e/rDEG7rPrTtkNEcsYJphh9171U50YVPS6OP//R/ScZ07U6Xbj0URsfzg70YStJVl4Lj9DTPzDhTMoTio4zqqGnlBETLAPXkpdZrVgOV2lfALAYhYrFTx554FInACgWQ9PBLhbcLqokkGFS8QFRxuG9uHJQMTecGJcDErTkjEvLQklUxKQb0lAdlI8MsxxSImPu7292kdu3UNhxzUwhJY+L5rcHjFIXenow+WOXhq8jDXPUMGFJIo3wJ7ITsXizOTb68uqDAwP40J7L061dOP4f51ikV8vugXzXu26GWnYVJRJIrVvfWjhQnsPvmhox7fNHcrppbJgHn1fsGWKPeLp5KrjibPfK0737CfxvIuhBSXBK6ZbsHNRnnDhiaSRXHzHX9c0ZWGaOhm7785FuTiw3DbhYpkCsoFteZ9sCvcYRNiCOVk4VGHDZts0WRM9vEg2sW3hbL2EJZiPFxxZacOjER6U9MC2fUM2jnUUYkzBHC/3lxeJfd1op4hsZFuTQ+w5jSmY+8dcSh4mC2zrrsV5snQ3IQVzAvFsQeCzHNHM+vx0PCU33P0JKXj7vIfk3eRje2lg24MKXjItZVK5sj98YI7PgPoTVPBqeXhsMrM6b6q88wH8D9GUMN69ilaeAAAAAElFTkSuQmCC", }; let monitorDisplayData = { From 12f67efa15d4954f6d1fff9895e4321b5c170139 Mon Sep 17 00:00:00 2001 From: Thomas Weber Date: Tue, 7 Oct 2025 18:21:31 -0500 Subject: [PATCH 14/16] copy and paste from the ngio github to ensure no tampering --- extensions/obviousAlexC/newgroundsIO.js | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/extensions/obviousAlexC/newgroundsIO.js b/extensions/obviousAlexC/newgroundsIO.js index b445cf3149..a3e45b35f8 100644 --- a/extensions/obviousAlexC/newgroundsIO.js +++ b/extensions/obviousAlexC/newgroundsIO.js @@ -40,12 +40,13 @@ //Updated to the latest //Put this in here since there are 3 objects - let NewgroundsIO = null; - let NGIO = null; - let CryptoJS = null; // prettier-ignore + var NewgroundsIO; + var NGIO; + var CryptoJS; { - NGIO = class{static get STATUS_INITIALIZED(){return"initialized"}static get STATUS_CHECKING_LOCAL_VERSION(){return"checking-local-version"}static get STATUS_LOCAL_VERSION_CHECKED(){return"local-version-checked"}static get STATUS_PRELOADING_ITEMS(){return"preloading-items"}static get STATUS_ITEMS_PRELOADED(){return"items-preloaded"}static get STATUS_READY(){return"ready"}static get STATUS_SESSION_UNINITIALIZED(){return NewgroundsIO.SessionState.SESSION_UNINITIALIZED}static get STATUS_WAITING_FOR_SERVER(){return NewgroundsIO.SessionState.WAITING_FOR_SERVER}static get STATUS_LOGIN_REQUIRED(){return NewgroundsIO.SessionState.LOGIN_REQUIRED}static get STATUS_WAITING_FOR_USER(){return NewgroundsIO.SessionState.WAITING_FOR_USER}static get STATUS_LOGIN_CANCELLED(){return NewgroundsIO.SessionState.LOGIN_CANCELLED}static get STATUS_LOGIN_SUCCESSFUL(){return NewgroundsIO.SessionState.LOGIN_SUCCESSFUL}static get STATUS_LOGIN_FAILED(){return NewgroundsIO.SessionState.LOGIN_FAILED}static get STATUS_USER_LOGGED_OUT(){return NewgroundsIO.SessionState.USER_LOGGED_OUT}static get STATUS_SERVER_UNAVAILABLE(){return NewgroundsIO.SessionState.SERVER_UNAVAILABLE}static get STATUS_EXCEEDED_MAX_ATTEMPTS(){return NewgroundsIO.SessionState.EXCEEDED_MAX_ATTEMPTS}static get isWaitingStatus(){return NewgroundsIO.SessionState.SESSION_WAITING.indexOf(this.#a)>=0||[this.STATUS_PRELOADING_ITEMS,this.LOCAL_VERSION_CHECKED,this.STATUS_CHECKING_LOCAL_VERSION].indexOf(this.#a)>=0}static get PERIOD_TODAY(){return"D"}static get PERIOD_CURRENT_WEEK(){return"W"}static get PERIOD_CURRENT_MONTH(){return"M"}static get PERIOD_CURRENT_YEAR(){return"Y"}static get PERIOD_ALL_TIME(){return"A"}static get PERIODS(){return[NGIO.PERIOD_TODAY,NGIO.PERIOD_CURRENT_WEEK,NGIO.PERIOD_CURRENT_MONTH,NGIO.PERIOD_CURRENT_YEAR,NGIO.PERIOD_ALL_TIME]}static get ngioCore(){return this.#b}static #b=null;static get medalScore(){return this.#c}static #c=-1;static get medals(){return this.#d}static #d=null;static get scoreBoards(){return this.#e}static #e=null;static get saveSlots(){return this.#f}static #f=null;static get lastExecution(){return this.#g}static #g=new Date;static get lastConnectionStatus(){return this.#a}static #a=new Date;static get sessionError(){return this.#h}static #h=null;static get legalHost(){return this.#i}static #i=!0;static get isDeprecated(){return this.#j}static #j=!0;static get newestVersion(){return this.#k}static #k=!0;static get loginPageOpen(){return this.#l}static #l=!1;static get gatewayVersion(){return this.#m}static #m=!0;static get lastMedalUnlocked(){return this.#n}static #n=!0;static get lastBoardPosted(){return this.#o}static #o=!0;static get lastScorePosted(){return this.#p}static #p=!0;static get lastGetScoresResult(){return this.#q}static #q=!0;static get lastSaveSlotLoaded(){return this.#r}static #r=!0;static get lastSaveSlotSaved(){return this.#s}static #s=!0;static get lastDateTime(){return this.#t}static #t="0000-00-00";static get lastLoggedEvent(){return this.#u}static #u=null;static get lastTimeStamp(){return this.#v}static #v=0;static get lastPingSuccess(){return this.#w}static #w=!0;static get isInitialized(){return null!==this.ngioCore}static get session(){return this.isInitialized?this.ngioCore.session:null}static get user(){return null===this.session?null:this.ngioCore.session.user}static get hasSession(){return null!==this.session}static get hasUser(){return null!==this.user}static get isReady(){return this.#a===this.STATUS_READY}static get version(){return this.#x}static #x="0.0.0";static get debugMode(){return this.#y}static #y=!1;static #z={autoLogNewView:!1,preloadMedals:!1,preloadScoreBoards:!1,preloadSaveSlots:!1};static #A=!1;static #B=!1;static #C=!1;static #D=!1;static init(e,t,s){if(!this.isInitialized){if(this.#b=new NewgroundsIO.Core(e,t),this.#b.addEventListener("serverResponse",function(e){NGIO.#E(e)}),s&&"object"==typeof s){"string"==typeof s.version&&(this.#x=s.version);let o=["debugMode","checkHostLicense","autoLogNewView","preloadMedals","preloadScoreBoards","preloadSaveSlots"];for(let r=0;r{t.hasData&&e++}),e}static getSaveSlotData(e,t,s){null===this.saveSlots&&(console.error("getSaveSlotData data called without any preloaded save slots."),s?t.call(s,null):t(null));let o=this.getSaveSlot(e);this.#r=o,o.getData(t,s)}static setSaveSlotData(e,t,s,o){if(null==this.saveSlots){console.error("setSaveSlotData data called without any preloaded save slots."),"function"==typeof s&&(o?s(o,null):s(null));return}var r=this.getSaveSlot(e);if(null==r){console.error("Slot #"+e+" does not exist."),"function"==typeof s&&(o?s(o,null):s(null));return}r.setData(t,function(){"function"==typeof s&&(o?s(o,this.lastSaveSlotSaved):s(this.lastSaveSlotSaved))},this)}static logEvent(e,t,s){this.ngioCore.executeComponent(this.ngioCore.getComponent("Event.logEvent",{event_name:e}),function(){"function"==typeof t&&(s?t(s,this.lastLoggedEvent):t(this.lastLoggedEvent))},this)}static getDateTime(e,t){this.ngioCore.executeComponent(this.ngioCore.getComponent("Gateway.getDatetime"),function(){"function"==typeof e&&(t?e(t,this.lastDateTime,this.lastTimeStamp):e(this.lastDateTime,this.lastTimeStamp))},this)}static keepSessionAlive(){if(this.hasUser)(new Date-this.#g).Seconds>=3e4&&(this.#g=new Date,this.ngioCore.executeComponent(this.ngioCore.getComponent("Gateway.ping")))}static getConnectionStatus(e,t){this.#D||null===this.#a||null==this.session||(this.#D=!0,this.#a===this.STATUS_INITIALIZED?(this.#a=this.STATUS_CHECKING_LOCAL_VERSION,this.#G(e,t),this.#H(e,t)):this.#A?this.#a===this.STATUS_LOGIN_SUCCESSFUL?(this.#a=this.STATUS_PRELOADING_ITEMS,this.#G(e,t),this.#I(function(){this.#G(e,t),this.#B=!1},this)):this.#a===this.STATUS_ITEMS_PRELOADED?(this.#l=!1,this.#a=this.STATUS_READY,this.#G(e,t),this.#B=!1):this.keepSessionAlive():this.#B?this.#J(e,t):this.#a!==this.STATUS_CHECKING_LOCAL_VERSION&&this.session.update(function(){this.#J(e,t)},this),this.#D=!1)}static #J(e,t){(this.session.statusChanged||this.#B)&&(this.#a=this.session.status,(this.session.status==NewgroundsIO.SessionState.LOGIN_SUCCESSFUL||this.#B)&&(this.#a=NewgroundsIO.SessionState.LOGIN_SUCCESSFUL,this.#A=!0),this.#G(e,t)),this.#B=!1}static #G(s,o){o?s.call(o,this.#a):s(this.#a)}static #H(r,i){if(this.#C){this.#a=this.STATUS_LOCAL_VERSION_CHECKED,this.#G(r,i);return}this.ngioCore.queueComponent(this.ngioCore.getComponent("App.getCurrentVersion",{version:this.#x})),this.ngioCore.queueComponent(this.ngioCore.getComponent("Gateway.getVersion")),this.#z.autoLogNewView&&this.ngioCore.queueComponent(this.ngioCore.getComponent("App.logView")),this.#z.checkHostLicense&&this.ngioCore.queueComponent(this.ngioCore.getComponent("App.getHostLicense")),this.ngioCore.executeQueue(function(){this.#a=this.STATUS_LOCAL_VERSION_CHECKED,this.#C=!0,this.#G(r,i),this.#j&&console.warn("NGIO - Version mistmatch! Published version is: "+this.#k+", this version is: "+this.version),this.#i||(console.warn("NGIO - This host has been blocked fom hosting this game!"),this.#A=!0,this.#a=this.STATUS_ITEMS_PRELOADED,this.#G(r,i))},this)}static #I(){this.#z.preloadMedals&&(this.ngioCore.queueComponent(this.ngioCore.getComponent("Medal.getMedalScore")),this.ngioCore.queueComponent(this.ngioCore.getComponent("Medal.getList"))),this.#z.preloadScoreBoards&&this.ngioCore.queueComponent(this.ngioCore.getComponent("ScoreBoard.getBoards")),null!==this.user&&this.#z.preloadSaveSlots&&this.ngioCore.queueComponent(this.ngioCore.getComponent("CloudSave.loadSlots")),this.ngioCore.hasQueue?this.ngioCore.executeQueue(function(){this.#a=this.STATUS_ITEMS_PRELOADED},this):this.#a=this.STATUS_ITEMS_PRELOADED}static #F(){this.#a=this.STATUS_INITIALIZED,this.#l=!1,this.#B=!1,this.#A=!1}static #K(n){if(this.#f){let a=this.#f.length;for(let u=0;u>>2]|=(s[r>>>2]>>>24-8*(r%4)&255)<<24-8*((o+r)%4);else if(65535>>2]=s[r>>>2];else t.push.apply(t,s);return this.sigBytes+=e,this},clamp:function(){var t=this.words,s=this.sigBytes;t[s>>>2]&=4294967295<<32-8*(s%4),t.length=e.ceil(s/4)},clone:function(){var e=i.clone.call(this);return e.words=this.words.slice(0),e},random:function(t){for(var s=[],o=0;o>>2]>>>24-8*(o%4)&255;s.push((r>>>4).toString(16)),s.push((15&r).toString(16))}return s.join("")},parse:function(e){for(var t=e.length,s=[],o=0;o>>3]|=parseInt(e.substr(o,2),16)<<24-4*(o%8);return new n.init(s,t/2)}},l=a.Latin1={stringify:function(e){var t=e.words;e=e.sigBytes;for(var s=[],o=0;o>>2]>>>24-8*(o%4)&255));return s.join("")},parse:function(e){for(var t=e.length,s=[],o=0;o>>2]|=(255&e.charCodeAt(o))<<24-8*(o%4);return new n.init(s,t)}},p=a.Utf8={stringify:function(e){try{return decodeURIComponent(escape(l.stringify(e)))}catch(t){throw Error("Malformed UTF-8 data")}},parse:function(e){return l.parse(unescape(encodeURIComponent(e)))}},c=o.BufferedBlockAlgorithm=i.extend({reset:function(){this._data=new n.init,this._nDataBytes=0},_append:function(e){"string"==typeof e&&(e=p.parse(e)),this._data.concat(e),this._nDataBytes+=e.sigBytes},_process:function(t){var s=this._data,o=s.words,r=s.sigBytes,i=this.blockSize,a=r/(4*i),a=t?e.ceil(a):e.max((0|a)-this._minBufferSize,0);if(t=a*i,r=e.min(4*t,r),t){for(var u=0;u>>2]>>>24-8*(r%4)&255)<<16|(t[r+1>>>2]>>>24-8*((r+1)%4)&255)<<8|t[r+2>>>2]>>>24-8*((r+2)%4)&255,n=0;4>n&&r+.75*n>>6*(3-n)&63));if(t=o.charAt(64))for(;e.length%4;)e.push(t);return e.join("")},parse:function(e){var s=e.length,o=this._map,r=o.charAt(64);r&&-1!=(r=e.indexOf(r))&&(s=r);for(var r=[],i=0,n=0;n>>6-2*(n%4);r[i>>>2]|=(a|u)<<24-8*(i%4),i++}return t.create(r,i)},_map:"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/="}}(),function(e){function t(e,t,s,o,r,i,n){return((e=e+(t&s|~t&o)+r+n)<>>32-i)+t}function s(e,t,s,o,r,i,n){return((e=e+(t&o|s&~o)+r+n)<>>32-i)+t}function o(e,t,s,o,r,i,n){return((e=e+(t^s^o)+r+n)<>>32-i)+t}function r(e,t,s,o,r,i,n){return((e=e+(s^(t|~o))+r+n)<>>32-i)+t}for(var i=CryptoJS,n=i.lib,a=n.WordArray,u=n.Hasher,n=i.algo,l=[],p=0;64>p;p++)l[p]=4294967296*e.abs(e.sin(p+1))|0;n=n.MD5=u.extend({_doReset:function(){this._hash=new a.init([1732584193,4023233417,2562383102,271733878])},_doProcessBlock:function(e,i){for(var n=0;16>n;n++){var a=i+n,u=e[a];e[a]=(u<<8|u>>>24)&16711935|(u<<24|u>>>8)&4278255360}var n=this._hash.words,a=e[i+0],u=e[i+1],p=e[i+2],c=e[i+3],h=e[i+4],d=e[i+5],g=e[i+6],f=e[i+7],w=e[i+8],O=e[i+9],I=e[i+10],m=e[i+11],S=e[i+12],N=e[i+13],b=e[i+14],y=e[i+15],v=n[0],$=n[1],C=n[2],E=n[3],v=t(v,$,C,E,a,7,l[0]),E=t(E,v,$,C,u,12,l[1]),C=t(C,E,v,$,p,17,l[2]),$=t($,C,E,v,c,22,l[3]),v=t(v,$,C,E,h,7,l[4]),E=t(E,v,$,C,d,12,l[5]),C=t(C,E,v,$,g,17,l[6]),$=t($,C,E,v,f,22,l[7]),v=t(v,$,C,E,w,7,l[8]),E=t(E,v,$,C,O,12,l[9]),C=t(C,E,v,$,I,17,l[10]),$=t($,C,E,v,m,22,l[11]),v=t(v,$,C,E,S,7,l[12]),E=t(E,v,$,C,N,12,l[13]),C=t(C,E,v,$,b,17,l[14]),$=t($,C,E,v,y,22,l[15]),v=s(v,$,C,E,u,5,l[16]),E=s(E,v,$,C,g,9,l[17]),C=s(C,E,v,$,m,14,l[18]),$=s($,C,E,v,a,20,l[19]),v=s(v,$,C,E,d,5,l[20]),E=s(E,v,$,C,I,9,l[21]),C=s(C,E,v,$,y,14,l[22]),$=s($,C,E,v,h,20,l[23]),v=s(v,$,C,E,O,5,l[24]),E=s(E,v,$,C,b,9,l[25]),C=s(C,E,v,$,c,14,l[26]),$=s($,C,E,v,w,20,l[27]),v=s(v,$,C,E,N,5,l[28]),E=s(E,v,$,C,p,9,l[29]),C=s(C,E,v,$,f,14,l[30]),$=s($,C,E,v,S,20,l[31]),v=o(v,$,C,E,d,4,l[32]),E=o(E,v,$,C,w,11,l[33]),C=o(C,E,v,$,m,16,l[34]),$=o($,C,E,v,b,23,l[35]),v=o(v,$,C,E,u,4,l[36]),E=o(E,v,$,C,h,11,l[37]),C=o(C,E,v,$,f,16,l[38]),$=o($,C,E,v,I,23,l[39]),v=o(v,$,C,E,N,4,l[40]),E=o(E,v,$,C,a,11,l[41]),C=o(C,E,v,$,c,16,l[42]),$=o($,C,E,v,g,23,l[43]),v=o(v,$,C,E,O,4,l[44]),E=o(E,v,$,C,S,11,l[45]),C=o(C,E,v,$,y,16,l[46]),$=o($,C,E,v,p,23,l[47]),v=r(v,$,C,E,a,6,l[48]),E=r(E,v,$,C,f,10,l[49]),C=r(C,E,v,$,b,15,l[50]),$=r($,C,E,v,d,21,l[51]),v=r(v,$,C,E,S,6,l[52]),E=r(E,v,$,C,c,10,l[53]),C=r(C,E,v,$,I,15,l[54]),$=r($,C,E,v,u,21,l[55]),v=r(v,$,C,E,w,6,l[56]),E=r(E,v,$,C,y,10,l[57]),C=r(C,E,v,$,g,15,l[58]),$=r($,C,E,v,N,21,l[59]),v=r(v,$,C,E,h,6,l[60]),E=r(E,v,$,C,m,10,l[61]),C=r(C,E,v,$,p,15,l[62]),$=r($,C,E,v,O,21,l[63]);n[0]=n[0]+v|0,n[1]=n[1]+$|0,n[2]=n[2]+C|0,n[3]=n[3]+E|0},_doFinalize:function(){var t=this._data,s=t.words,o=8*this._nDataBytes,r=8*t.sigBytes;s[r>>>5]|=128<<24-r%32;var i=e.floor(o/4294967296);for(s[(r+64>>>9<<4)+15]=(i<<8|i>>>24)&16711935|(i<<24|i>>>8)&4278255360,s[(r+64>>>9<<4)+14]=(o<<8|o>>>24)&16711935|(o<<24|o>>>8)&4278255360,t.sigBytes=4*(s.length+1),this._process(),s=(t=this._hash).words,o=0;4>o;o++)r=s[o],s[o]=(r<<8|r>>>24)&16711935|(r<<24|r>>>8)&4278255360;return t},clone:function(){var e=u.clone.call(this);return e._hash=this._hash.clone(),e}}),i.MD5=u._createHelper(n),i.HmacMD5=u._createHmacHelper(n)}(Math),function(){var e=CryptoJS,t=e.lib,s=t.Base,o=t.WordArray,t=e.algo,r=t.EvpKDF=s.extend({cfg:s.extend({keySize:4,hasher:t.MD5,iterations:1}),init:function(e){this.cfg=this.cfg.extend(e)},compute:function(e,t){for(var s=this.cfg,r=s.hasher.create(),i=o.create(),n=i.words,a=s.keySize,s=s.iterations;n.length>>2]}},s.BlockCipher=u.extend({cfg:u.cfg.extend({mode:l,padding:c}),reset:function(){u.reset.call(this);var e=this.cfg,t=e.iv,e=e.mode;if(this._xformMode==this._ENC_XFORM_MODE)var s=e.createEncryptor;else s=e.createDecryptor,this._minBufferSize=1;this._mode=s.call(e,this,t&&t.words)},_doProcessBlock:function(e,t){this._mode.processBlock(e,t)},_doFinalize:function(){var e=this.cfg.padding;if(this._xformMode==this._ENC_XFORM_MODE){e.pad(this._data,this.blockSize);var t=this._process(!0)}else t=this._process(!0),e.unpad(t);return t},blockSize:4});var h=s.CipherParams=o.extend({init:function(e){this.mixIn(e)},toString:function(e){return(e||this.formatter).stringify(this)}}),l=(t.format={}).OpenSSL={stringify:function(e){var t=e.ciphertext;return((e=e.salt)?r.create([1398893684,1701076831]).concat(e).concat(t):t).toString(n)},parse:function(e){var t=(e=n.parse(e)).words;if(1398893684==t[0]&&1701076831==t[1]){var s=r.create(t.slice(2,4));t.splice(0,4),e.sigBytes-=16}return h.create({ciphertext:e,salt:s})}},d=s.SerializableCipher=o.extend({cfg:o.extend({format:l}),encrypt:function(e,t,s,o){o=this.cfg.extend(o);var r=e.createEncryptor(s,o);return t=r.finalize(t),r=r.cfg,h.create({ciphertext:t,key:s,iv:r.iv,algorithm:e,mode:r.mode,padding:r.padding,blockSize:e.blockSize,formatter:o.format})},decrypt:function(e,t,s,o){return o=this.cfg.extend(o),t=this._parse(t,o.format),e.createDecryptor(s,o).finalize(t.ciphertext)},_parse:function(e,t){return"string"==typeof e?t.parse(e,this):e}}),t=(t.kdf={}).OpenSSL={execute:function(e,t,s,o){return o||(o=r.random(8)),e=a.create({keySize:t+s}).compute(e,o),s=r.create(e.words.slice(t),4*s),e.sigBytes=4*t,h.create({key:e,iv:s,salt:o})}},g=s.PasswordBasedCipher=d.extend({cfg:d.cfg.extend({kdf:t}),encrypt:function(e,t,s,o){return s=(o=this.cfg.extend(o)).kdf.execute(s,e.keySize,e.ivSize),o.iv=s.iv,(e=d.encrypt.call(this,e,t,s.key,o)).mixIn(s),e},decrypt:function(e,t,s,o){return o=this.cfg.extend(o),t=this._parse(t,o.format),s=o.kdf.execute(s,e.keySize,e.ivSize,t.salt),o.iv=s.iv,d.decrypt.call(this,e,t,s.key,o)}})}(),function(){for(var e=CryptoJS,t=e.lib.BlockCipher,s=e.algo,o=[],r=[],i=[],n=[],a=[],u=[],l=[],p=[],c=[],h=[],d=[],g=0;256>g;g++)d[g]=128>g?g<<1:g<<1^283;for(var f=0,w=0,g=0;256>g;g++){var O=w^w<<1^w<<2^w<<3^w<<4,O=O>>>8^255&O^99;o[f]=O,r[O]=f;var I=d[f],m=d[I],S=d[m],N=257*d[O]^16843008*O;i[f]=N<<24|N>>>8,n[f]=N<<16|N>>>16,a[f]=N<<8|N>>>24,u[f]=N,N=16843009*S^65537*m^257*I^16843008*f,l[O]=N<<24|N>>>8,p[O]=N<<16|N>>>16,c[O]=N<<8|N>>>24,h[O]=N,f?(f=I^d[d[d[S^I]]],w^=d[d[w]]):f=w=1}var b=[0,1,2,4,8,16,32,64,128,27,54],s=s.AES=t.extend({_doReset:function(){for(var e=this._key,t=e.words,s=e.sigBytes/4,e=4*((this._nRounds=s+6)+1),r=this._keySchedule=[],i=0;i>>24]<<24|o[n>>>16&255]<<16|o[n>>>8&255]<<8|o[255&n]):(n=o[(n=n<<8|n>>>24)>>>24]<<24|o[n>>>16&255]<<16|o[n>>>8&255]<<8|o[255&n],n^=b[i/s|0]<<24),r[i]=r[i-s]^n}for(s=0,t=this._invKeySchedule=[];ss||4>=i?n:l[o[n>>>24]]^p[o[n>>>16&255]]^c[o[n>>>8&255]]^h[o[255&n]]},encryptBlock:function(e,t){this._doCryptBlock(e,t,this._keySchedule,i,n,a,u,o)},decryptBlock:function(e,t){var s=e[t+1];e[t+1]=e[t+3],e[t+3]=s,this._doCryptBlock(e,t,this._invKeySchedule,l,p,c,h,r),s=e[t+1],e[t+1]=e[t+3],e[t+3]=s},_doCryptBlock:function(e,t,s,o,r,i,n,a){for(var u=this._nRounds,l=e[t]^s[0],p=e[t+1]^s[1],c=e[t+2]^s[2],h=e[t+3]^s[3],d=4,g=1;g>>24]^r[p>>>16&255]^i[c>>>8&255]^n[255&h]^s[d++],w=o[p>>>24]^r[c>>>16&255]^i[h>>>8&255]^n[255&l]^s[d++],O=o[c>>>24]^r[h>>>16&255]^i[l>>>8&255]^n[255&p]^s[d++],h=o[h>>>24]^r[l>>>16&255]^i[p>>>8&255]^n[255&c]^s[d++],l=f,p=w,c=O;f=(a[l>>>24]<<24|a[p>>>16&255]<<16|a[c>>>8&255]<<8|a[255&h])^s[d++],w=(a[p>>>24]<<24|a[c>>>16&255]<<16|a[h>>>8&255]<<8|a[255&l])^s[d++],O=(a[c>>>24]<<24|a[h>>>16&255]<<16|a[l>>>8&255]<<8|a[255&p])^s[d++],h=(a[h>>>24]<<24|a[l>>>16&255]<<16|a[p>>>8&255]<<8|a[255&c])^s[d++],e[t]=f,e[t+1]=w,e[t+2]=O,e[t+3]=h},keySize:8});e.AES=t._createHelper(s)}();NewgroundsIO=NewgroundsIO||{};NewgroundsIO.objects=NewgroundsIO.objects?NewgroundsIO.objects:{},NewgroundsIO.results=NewgroundsIO.results?NewgroundsIO.results:{},NewgroundsIO.components=NewgroundsIO.components?NewgroundsIO.components:{},(()=>{class e extends EventTarget{#O="https://www.newgrounds.io/gateway_v3.php";#P=!1;#Q=null;#R=null;#S=[];#T=null;#U=null;#V={};get GATEWAY_URI(){return this.#O}get debug(){return this.#P}set debug(e){this.#P=!!e}get appID(){return this.#Q}get componentQueue(){return this.#S}get hasQueue(){return this.#S.length>0}get host(){return this.#T}get session(){return this.#U}get user(){return this.#U?this.#U.user:null}get uriParams(){return this.#V}constructor(e,t){if(super(),void 0===e)throw"Missing required appID!";if(void 0===t)throw"Missing required aesKey!";if(this.#Q=e,this.#R=CryptoJS.enc.Base64.parse(t),this.#S=[],this.#V={},window&&window.location&&window.location.href?window.location.hostname?this.#T=window.location.hostname.toLowerCase():"file:"==window.location.href.toLowerCase().substr(0,5)?this.#T="":this.#T="":this.#T="","undefined"!=typeof window&&window.location){var s,o=window.location.href.split("?").pop();if(o)for(var r,i=o.split("&"),n=0;n{t instanceof NewgroundsIO.BaseComponent||(r._verifyComponent(e)||(o=!1),t.setCore(r))}),!o)return}else{if(!this._verifyComponent(e))return;e.setCore(this)}let i=this,n=this._getRequest(e);new NewgroundsIO.objects.Response;var a=new XMLHttpRequest;a.onreadystatechange=function(){if(4==a.readyState){var e;try{e=JSON.parse(a.responseText)}catch(o){(e={success:!1,app_id:i.app_id}).error={message:String(o),code:8002}}let r=i._populateResponse(e);i.dispatchEvent(new CustomEvent("serverResponse",{detail:r})),t&&(s?t.call(s,r):t(r))}};var u=void 0!==Array.prototype.toJSON?Array.prototype.toJSON:null;u&&delete Array.prototype.toJSON;let l=new FormData;l.append("request",JSON.stringify(n)),u&&(Array.prototype.toJSON=u),a.open("POST",this.GATEWAY_URI,!0),a.send(l)}loadComponent(e){if(!this._verifyComponent(e))return;e.setCore(this);let t=this._getRequest(e),s=this.GATEWAY_URI+"?request="+encodeURIComponent(JSON.stringify(t));window.open(s,"_blank")}onServerResponse(e){}_populateResponse(e){if(e.success){if(Array.isArray(e.result))for(let t=0;t{let o=s._getExecute(e);t.push(o)})):t=this._getExecute(e);let o=new NewgroundsIO.objects.Request({execute:t});return this.debug&&(o.debug=!0),o.setCore(this),o}_verifyComponent(e){return e instanceof NewgroundsIO.BaseComponent?!!e.isValid():(console.error("NewgroundsIO Type Mismatch: Expecting a NewgroundsIO.components.XXXX instance, got",e),!1)}}NewgroundsIO.Core=e})(),(()=>{class e{get type(){return this.__type}__type="object";__object="BaseObject";__properties=[];__required=[];__ngioCore=null;isValid(){if(0===this.__required.length)return!0;let e=!0;return this.__required.forEach(function(t){null===this[t]?(console.error("NewgroundsIO Error: "+this.__object+" "+this.__type+" is invalid, missing value for '"+t+"'"),e=!1):this[t]instanceof NewgroundsIO.BaseObject&&!this[t].isValid()&&(e=!1)},this),e}setCore(e){this._doSetCore(e,[])}objectMap={};arrayMap={};fromJSON(e,t){var s,o,r={};for(this.setCore(t),s=0;s{s instanceof NewgroundsIO.BaseObject&&-1===t.indexOf(s)&&s._doSetCore(e,t)},this),"host"!==s||this.host||(this.host=e.host)},this)):console.error("NewgroundsIO Error: Expecting NewgroundsIO.Core instance, got",e)}toJSON(){return this.__doToJSON()}__doToJSON(){if(void 0===this.__properties)return{};let e={};return this.__properties.forEach(function(t){null!==this[t]&&(e[t]="function"==typeof this[t].toJSON?this[t].toJSON():this[t])},this),e}toSecureJSON(){return this.__ngioCore&&this.__ngioCore instanceof NewgroundsIO.Core?{secure:this.__ngioCore.encrypt(JSON.stringify(this.__doToJSON()))}:(console.error("NewgroundsIO Error: Unable to create secure JSON object without calling setCore() first."),this.__doToJSON())}toString(){return this.__type}clone(e){return void 0===e&&(e=new this.constructor),this.__properties.forEach(t=>{e[t]=this[t]}),e.__ngioCore=this.__ngioCore,e}}NewgroundsIO.BaseObject=e;class t extends e{constructor(){super(),this.__type="component",this.__object="BaseComponent",this.__properties=["host","echo"],this._echo=null}get host(){return this.__ngioCore?this.__ngioCore.host:null}get echo(){return this._echo}set echo(e){this.echo=""+e}}NewgroundsIO.BaseComponent=t;class s extends e{constructor(){super(),this.__type="result",this.__object="BaseResult",this.__properties=["echo","error","success"],this._echo=null,this._error=null,this._success=null}get component(){return this.__object}get echo(){return this._echo}get error(){return this._error}set error(e){this._error=e}get success(){return!!this._success}set success(e){this._success=!!e}}NewgroundsIO.BaseResult=s})(),NewgroundsIO.SessionState={SESSION_UNINITIALIZED:"session-uninitialized",WAITING_FOR_SERVER:"waiting-for-server",LOGIN_REQUIRED:"login-required",WAITING_FOR_USER:"waiting-for-user",LOGIN_CANCELLED:"login-cancelled",LOGIN_SUCCESSFUL:"login-successful",LOGIN_FAILED:"login-failed",USER_LOGGED_OUT:"user-logged-out",SERVER_UNAVAILABLE:"server-unavailable",EXCEEDED_MAX_ATTEMPTS:"exceeded-max-attempts"},NewgroundsIO.SessionState.SESSION_WAITING=[NewgroundsIO.SessionState.SESSION_UNINITIALIZED,NewgroundsIO.SessionState.WAITING_FOR_SERVER,NewgroundsIO.SessionState.WAITING_FOR_USER,NewgroundsIO.SessionState.LOGIN_CANCELLED,NewgroundsIO.SessionStateLOGIN_FAILED],(()=>{class e extends NewgroundsIO.BaseComponent{constructor(){super(),this.__object="App.checkSession",this.__requireSession=!0}}void 0===NewgroundsIO.components.App&&(NewgroundsIO.components.App={}),NewgroundsIO.components.App.checkSession=e})(),(()=>{class e extends NewgroundsIO.BaseComponent{constructor(){super(),this.__object="App.endSession",this.__requireSession=!0}}void 0===NewgroundsIO.components.App&&(NewgroundsIO.components.App={}),NewgroundsIO.components.App.endSession=e})(),(()=>{class e extends NewgroundsIO.BaseComponent{constructor(e){super();let t=this;if(this.__object="App.getCurrentVersion",["version"].forEach(e=>{0>t.__properties.indexOf(e)&&t.__properties.push(e)}),e&&"object"==typeof e)for(var s=0;s{class e extends NewgroundsIO.BaseComponent{constructor(e){super();let t=this;if(this.__object="App.getHostLicense",["host"].forEach(e=>{0>t.__properties.indexOf(e)&&t.__properties.push(e)}),e&&"object"==typeof e)for(var s=0;s{class e extends NewgroundsIO.BaseComponent{constructor(e){super();let t=this;if(this.__object="App.logView",["host"].forEach(e=>{0>t.__properties.indexOf(e)&&t.__properties.push(e)}),e&&"object"==typeof e)for(var s=0;s{class e extends NewgroundsIO.BaseComponent{constructor(e){super();let t=this;if(this.__object="App.startSession",["force"].forEach(e=>{0>t.__properties.indexOf(e)&&t.__properties.push(e)}),e&&"object"==typeof e)for(var s=0;s{class e extends NewgroundsIO.BaseComponent{constructor(e){super();let t=this;if(this.__object="CloudSave.clearSlot",this.__requireSession=!0,["id"].forEach(e=>{0>t.__properties.indexOf(e)&&t.__properties.push(e)}),e&&"object"==typeof e)for(var s=0;s{class e extends NewgroundsIO.BaseComponent{constructor(e){super();let t=this;if(this.__object="CloudSave.loadSlot",this.__requireSession=!0,["id","app_id"].forEach(e=>{0>t.__properties.indexOf(e)&&t.__properties.push(e)}),e&&"object"==typeof e)for(var s=0;s{class e extends NewgroundsIO.BaseComponent{constructor(e){super();let t=this;if(this.__object="CloudSave.loadSlots",this.__requireSession=!0,["app_id"].forEach(e=>{0>t.__properties.indexOf(e)&&t.__properties.push(e)}),e&&"object"==typeof e)for(var s=0;s{class e extends NewgroundsIO.BaseComponent{constructor(e){super();let t=this;if(this.__object="CloudSave.setData",this.__requireSession=!0,["id","data"].forEach(e=>{0>t.__properties.indexOf(e)&&t.__properties.push(e)}),e&&"object"==typeof e)for(var s=0;s{class e extends NewgroundsIO.BaseComponent{constructor(e){super();let t=this;if(this.__object="Event.logEvent",["host","event_name"].forEach(e=>{0>t.__properties.indexOf(e)&&t.__properties.push(e)}),e&&"object"==typeof e)for(var s=0;s{class e extends NewgroundsIO.BaseComponent{constructor(){super(),this.__object="Gateway.getDatetime"}}void 0===NewgroundsIO.components.Gateway&&(NewgroundsIO.components.Gateway={}),NewgroundsIO.components.Gateway.getDatetime=e})(),(()=>{class e extends NewgroundsIO.BaseComponent{constructor(){super(),this.__object="Gateway.getVersion"}}void 0===NewgroundsIO.components.Gateway&&(NewgroundsIO.components.Gateway={}),NewgroundsIO.components.Gateway.getVersion=e})(),(()=>{class e extends NewgroundsIO.BaseComponent{constructor(){super(),this.__object="Gateway.ping"}}void 0===NewgroundsIO.components.Gateway&&(NewgroundsIO.components.Gateway={}),NewgroundsIO.components.Gateway.ping=e})(),(()=>{class e extends NewgroundsIO.BaseComponent{constructor(e){super();let t=this;if(this.__object="Loader.loadAuthorUrl",["host","redirect","log_stat"].forEach(e=>{0>t.__properties.indexOf(e)&&t.__properties.push(e)}),e&&"object"==typeof e)for(var s=0;s{class e extends NewgroundsIO.BaseComponent{constructor(e){super();let t=this;if(this.__object="Loader.loadMoreGames",["host","redirect","log_stat"].forEach(e=>{0>t.__properties.indexOf(e)&&t.__properties.push(e)}),e&&"object"==typeof e)for(var s=0;s{class e extends NewgroundsIO.BaseComponent{constructor(e){super();let t=this;if(this.__object="Loader.loadNewgrounds",["host","redirect","log_stat"].forEach(e=>{0>t.__properties.indexOf(e)&&t.__properties.push(e)}),e&&"object"==typeof e)for(var s=0;s{class e extends NewgroundsIO.BaseComponent{constructor(e){super();let t=this;if(this.__object="Loader.loadOfficialUrl",["host","redirect","log_stat"].forEach(e=>{0>t.__properties.indexOf(e)&&t.__properties.push(e)}),e&&"object"==typeof e)for(var s=0;s{class e extends NewgroundsIO.BaseComponent{constructor(e){super();let t=this;if(this.__object="Loader.loadReferral",["host","referral_name","redirect","log_stat"].forEach(e=>{0>t.__properties.indexOf(e)&&t.__properties.push(e)}),e&&"object"==typeof e)for(var s=0;s{class e extends NewgroundsIO.BaseComponent{constructor(e){super();let t=this;if(this.__object="Medal.getList",["app_id"].forEach(e=>{0>t.__properties.indexOf(e)&&t.__properties.push(e)}),e&&"object"==typeof e)for(var s=0;s{class e extends NewgroundsIO.BaseComponent{constructor(){super(),this.__object="Medal.getMedalScore",this.__requireSession=!0}}void 0===NewgroundsIO.components.Medal&&(NewgroundsIO.components.Medal={}),NewgroundsIO.components.Medal.getMedalScore=e})(),(()=>{class e extends NewgroundsIO.BaseComponent{constructor(e){super();let t=this;if(this.__object="Medal.unlock",this.__isSecure=!0,this.__requireSession=!0,["id"].forEach(e=>{0>t.__properties.indexOf(e)&&t.__properties.push(e)}),e&&"object"==typeof e)for(var s=0;s{class e extends NewgroundsIO.BaseComponent{constructor(){super(),this.__object="ScoreBoard.getBoards"}}void 0===NewgroundsIO.components.ScoreBoard&&(NewgroundsIO.components.ScoreBoard={}),NewgroundsIO.components.ScoreBoard.getBoards=e})(),(()=>{class e extends NewgroundsIO.BaseComponent{constructor(e){super();let t=this;if(this.__object="ScoreBoard.getScores",["id","period","tag","social","user","skip","limit","app_id"].forEach(e=>{0>t.__properties.indexOf(e)&&t.__properties.push(e)}),e&&"object"==typeof e)for(var s=0;s{class e extends NewgroundsIO.BaseComponent{constructor(e){super();let t=this;if(this.__object="ScoreBoard.postScore",this.__isSecure=!0,this.__requireSession=!0,["id","value","tag"].forEach(e=>{0>t.__properties.indexOf(e)&&t.__properties.push(e)}),e&&"object"==typeof e)for(var s=0;s{class e extends NewgroundsIO.BaseObject{constructor(e){super();let t=this;if(this.__object="Debug",["exec_time","request"].forEach(e=>{0>t.__properties.indexOf(e)&&t.__properties.push(e)}),e&&"object"==typeof e)for(var s=0;s{class e extends NewgroundsIO.BaseObject{constructor(e){super();let t=this;if(this.__object="Error",["message","code"].forEach(e=>{0>t.__properties.indexOf(e)&&t.__properties.push(e)}),e&&"object"==typeof e)for(var s=0;s{class e extends NewgroundsIO.BaseObject{constructor(e){super();let t=this;if(this.__object="Execute",["component","parameters","secure"].forEach(e=>{0>t.__properties.indexOf(e)&&t.__properties.push(e)}),e&&"object"==typeof e)for(var s=0;s{class e extends NewgroundsIO.BaseObject{constructor(e){super();let t=this;if(this.__object="Medal",["id","name","description","icon","value","difficulty","secret","unlocked"].forEach(e=>{0>t.__properties.indexOf(e)&&t.__properties.push(e)}),e&&"object"==typeof e)for(var s=0;s{class e extends NewgroundsIO.BaseObject{constructor(e){super();let t=this;if(this.__object="Request",["app_id","execute","session_id","debug"].forEach(e=>{0>t.__properties.indexOf(e)&&t.__properties.push(e)}),e&&"object"==typeof e)for(var s=0;s{class e extends NewgroundsIO.BaseObject{constructor(e){super();let t=this;if(this.__object="Response",["app_id","success","debug","result","error","api_version","help_url"].forEach(e=>{0>t.__properties.indexOf(e)&&t.__properties.push(e)}),e&&"object"==typeof e)for(var s=0;s{class e extends NewgroundsIO.BaseObject{constructor(e){super();let t=this;if(this.__object="SaveSlot",["id","size","datetime","timestamp","url"].forEach(e=>{0>t.__properties.indexOf(e)&&t.__properties.push(e)}),e&&"object"==typeof e)for(var s=0;s{class e extends NewgroundsIO.BaseObject{constructor(e){super();let t=this;if(this.__object="Score",["user","value","formatted_value","tag"].forEach(e=>{0>t.__properties.indexOf(e)&&t.__properties.push(e)}),e&&"object"==typeof e)for(var s=0;s{class e extends NewgroundsIO.BaseObject{constructor(e){super();let t=this;if(this.__object="ScoreBoard",["id","name"].forEach(e=>{0>t.__properties.indexOf(e)&&t.__properties.push(e)}),e&&"object"==typeof e)for(var s=0;s{class e extends NewgroundsIO.BaseObject{constructor(e){super();let t=this;if(this.__object="Session",["id","user","expired","remember","passport_url"].forEach(e=>{0>t.__properties.indexOf(e)&&t.__properties.push(e)}),e&&"object"==typeof e)for(var s=0;s=this.#aS?this.#aL=NewgroundsIO.SessionState.EXCEEDED_MAX_ATTEMPTS:(this.#aL=NewgroundsIO.SessionState.SESSION_UNINITIALIZED,this.#aR++)),this.status==NewgroundsIO.SessionState.SESSION_UNINITIALIZED&&(this.#aU=localStorage.getItem(this.storageKey),this.#aT?this.id=this.#aT:this.#aU&&(this.id=this.#aU),this.mode=this.id&&"null"!==this.id?"check":"new");var s=new Date;if(!(s-this.#aO<5e3))switch(this.#aO=s,this.mode){case"new":this.mode="wait",this.startSession();break;case"check":this.mode="wait",this.checkSession()}}}startSession(){this.#aP=!1,this.resetSession(),this.#aL=NewgroundsIO.SessionState.WAITING_FOR_SERVER;var e=this.__ngioCore.getComponent("App.startSession");this.__ngioCore.executeComponent(e,this._onStartSession,this)}_onStartSession(e){if(!0===e.success){let t=e.result;if(Array.isArray(t)){for(let s=0;s{class e extends NewgroundsIO.BaseObject{constructor(e){super();let t=this;if(this.__object="User",["id","name","icons","supporter"].forEach(e=>{0>t.__properties.indexOf(e)&&t.__properties.push(e)}),e&&"object"==typeof e)for(var s=0;s{class e extends NewgroundsIO.BaseObject{constructor(e){super();let t=this;if(this.__object="UserIcons",["small","medium","large"].forEach(e=>{0>t.__properties.indexOf(e)&&t.__properties.push(e)}),e&&"object"==typeof e)for(var s=0;s{class e extends NewgroundsIO.BaseResult{constructor(e){super();let t=this;if(this.__object="App.checkSession",["session"].forEach(e=>{0>t.__properties.indexOf(e)&&t.__properties.push(e)}),e&&"object"==typeof e)for(var s=0;s{class e extends NewgroundsIO.BaseResult{constructor(e){super();let t=this;if(this.__object="App.getCurrentVersion",["current_version","client_deprecated"].forEach(e=>{0>t.__properties.indexOf(e)&&t.__properties.push(e)}),e&&"object"==typeof e)for(var s=0;s{class e extends NewgroundsIO.BaseResult{constructor(e){super();let t=this;if(this.__object="App.getHostLicense",["host_approved"].forEach(e=>{0>t.__properties.indexOf(e)&&t.__properties.push(e)}),e&&"object"==typeof e)for(var s=0;s{class e extends NewgroundsIO.BaseResult{constructor(e){super();let t=this;if(this.__object="App.startSession",["session"].forEach(e=>{0>t.__properties.indexOf(e)&&t.__properties.push(e)}),e&&"object"==typeof e)for(var s=0;s{class e extends NewgroundsIO.BaseResult{constructor(e){super();let t=this;if(this.__object="CloudSave.clearSlot",["slot"].forEach(e=>{0>t.__properties.indexOf(e)&&t.__properties.push(e)}),e&&"object"==typeof e)for(var s=0;s{class e extends NewgroundsIO.BaseResult{constructor(e){super();let t=this;if(this.__object="CloudSave.loadSlot",["slot","app_id"].forEach(e=>{0>t.__properties.indexOf(e)&&t.__properties.push(e)}),e&&"object"==typeof e)for(var s=0;s{class e extends NewgroundsIO.BaseResult{constructor(e){super();let t=this;if(this.__object="CloudSave.loadSlots",["slots","app_id"].forEach(e=>{0>t.__properties.indexOf(e)&&t.__properties.push(e)}),e&&"object"==typeof e)for(var s=0;s{class e extends NewgroundsIO.BaseResult{constructor(e){super();let t=this;if(this.__object="CloudSave.setData",["slot"].forEach(e=>{0>t.__properties.indexOf(e)&&t.__properties.push(e)}),e&&"object"==typeof e)for(var s=0;s{class e extends NewgroundsIO.BaseResult{constructor(e){super();let t=this;if(this.__object="Event.logEvent",["event_name"].forEach(e=>{0>t.__properties.indexOf(e)&&t.__properties.push(e)}),e&&"object"==typeof e)for(var s=0;s{class e extends NewgroundsIO.BaseResult{constructor(e){super();let t=this;if(this.__object="Gateway.getDatetime",["datetime","timestamp"].forEach(e=>{0>t.__properties.indexOf(e)&&t.__properties.push(e)}),e&&"object"==typeof e)for(var s=0;s{class e extends NewgroundsIO.BaseResult{constructor(e){super();let t=this;if(this.__object="Gateway.getVersion",["version"].forEach(e=>{0>t.__properties.indexOf(e)&&t.__properties.push(e)}),e&&"object"==typeof e)for(var s=0;s{class e extends NewgroundsIO.BaseResult{constructor(e){super();let t=this;if(this.__object="Gateway.ping",["pong"].forEach(e=>{0>t.__properties.indexOf(e)&&t.__properties.push(e)}),e&&"object"==typeof e)for(var s=0;s{class e extends NewgroundsIO.BaseResult{constructor(e){super();let t=this;if(this.__object="Loader.loadAuthorUrl",["url"].forEach(e=>{0>t.__properties.indexOf(e)&&t.__properties.push(e)}),e&&"object"==typeof e)for(var s=0;s{class e extends NewgroundsIO.BaseResult{constructor(e){super();let t=this;if(this.__object="Loader.loadMoreGames",["url"].forEach(e=>{0>t.__properties.indexOf(e)&&t.__properties.push(e)}),e&&"object"==typeof e)for(var s=0;s{class e extends NewgroundsIO.BaseResult{constructor(e){super();let t=this;if(this.__object="Loader.loadNewgrounds",["url"].forEach(e=>{0>t.__properties.indexOf(e)&&t.__properties.push(e)}),e&&"object"==typeof e)for(var s=0;s{class e extends NewgroundsIO.BaseResult{constructor(e){super();let t=this;if(this.__object="Loader.loadOfficialUrl",["url"].forEach(e=>{0>t.__properties.indexOf(e)&&t.__properties.push(e)}),e&&"object"==typeof e)for(var s=0;s{class e extends NewgroundsIO.BaseResult{constructor(e){super();let t=this;if(this.__object="Loader.loadReferral",["url"].forEach(e=>{0>t.__properties.indexOf(e)&&t.__properties.push(e)}),e&&"object"==typeof e)for(var s=0;s{class e extends NewgroundsIO.BaseResult{constructor(e){super();let t=this;if(this.__object="Medal.getList",["medals","app_id"].forEach(e=>{0>t.__properties.indexOf(e)&&t.__properties.push(e)}),e&&"object"==typeof e)for(var s=0;s{class e extends NewgroundsIO.BaseResult{constructor(e){super();let t=this;if(this.__object="Medal.getMedalScore",["medal_score"].forEach(e=>{0>t.__properties.indexOf(e)&&t.__properties.push(e)}),e&&"object"==typeof e)for(var s=0;s{class e extends NewgroundsIO.BaseResult{constructor(e){super();let t=this;if(this.__object="Medal.unlock",["medal","medal_score"].forEach(e=>{0>t.__properties.indexOf(e)&&t.__properties.push(e)}),e&&"object"==typeof e)for(var s=0;s{class e extends NewgroundsIO.BaseResult{constructor(e){super();let t=this;if(this.__object="ScoreBoard.getBoards",["scoreboards"].forEach(e=>{0>t.__properties.indexOf(e)&&t.__properties.push(e)}),e&&"object"==typeof e)for(var s=0;s{class e extends NewgroundsIO.BaseResult{constructor(e){super();let t=this;if(this.__object="ScoreBoard.getScores",["period","social","limit","scoreboard","scores","user","app_id"].forEach(e=>{0>t.__properties.indexOf(e)&&t.__properties.push(e)}),e&&"object"==typeof e)for(var s=0;s{class e extends NewgroundsIO.BaseResult{constructor(e){super();let t=this;if(this.__object="ScoreBoard.postScore",["scoreboard","score"].forEach(e=>{0>t.__properties.indexOf(e)&&t.__properties.push(e)}),e&&"object"==typeof e)for(var s=0;s=0||[this.STATUS_PRELOADING_ITEMS,this.LOCAL_VERSION_CHECKED,this.STATUS_CHECKING_LOCAL_VERSION].indexOf(this.#a)>=0}static get PERIOD_TODAY(){return"D"}static get PERIOD_CURRENT_WEEK(){return"W"}static get PERIOD_CURRENT_MONTH(){return"M"}static get PERIOD_CURRENT_YEAR(){return"Y"}static get PERIOD_ALL_TIME(){return"A"}static get PERIODS(){return[NGIO.PERIOD_TODAY,NGIO.PERIOD_CURRENT_WEEK,NGIO.PERIOD_CURRENT_MONTH,NGIO.PERIOD_CURRENT_YEAR,NGIO.PERIOD_ALL_TIME]}static get ngioCore(){return this.#b}static #b=null;static get medalScore(){return this.#c}static #c=-1;static get medals(){return this.#d}static #d=null;static get scoreBoards(){return this.#e}static #e=null;static get saveSlots(){return this.#f}static #f=null;static get lastExecution(){return this.#g}static #g=new Date;static get lastConnectionStatus(){return this.#a}static #a=new Date;static get sessionError(){return this.#h}static #h=null;static get legalHost(){return this.#i}static #i=!0;static get isDeprecated(){return this.#j}static #j=!0;static get newestVersion(){return this.#k}static #k=!0;static get loginPageOpen(){return this.#l}static #l=!1;static get gatewayVersion(){return this.#m}static #m=!0;static get lastMedalUnlocked(){return this.#n}static #n=!0;static get lastBoardPosted(){return this.#o}static #o=!0;static get lastScorePosted(){return this.#p}static #p=!0;static get lastGetScoresResult(){return this.#q}static #q=!0;static get lastSaveSlotLoaded(){return this.#r}static #r=!0;static get lastSaveSlotSaved(){return this.#s}static #s=!0;static get lastDateTime(){return this.#t}static #t="0000-00-00";static get lastLoggedEvent(){return this.#u}static #u=null;static get lastTimeStamp(){return this.#v}static #v=0;static get lastPingSuccess(){return this.#w}static #w=!0;static get isInitialized(){return null!==this.ngioCore}static get session(){return this.isInitialized?this.ngioCore.session:null}static get user(){return null===this.session?null:this.ngioCore.session.user}static get hasSession(){return null!==this.session}static get hasUser(){return null!==this.user}static get isReady(){return this.#a===this.STATUS_READY}static get version(){return this.#x}static #x="0.0.0";static get debugMode(){return this.#y}static #y=!1;static #z={autoLogNewView:!1,preloadMedals:!1,preloadScoreBoards:!1,preloadSaveSlots:!1};static #A=!1;static #B=!1;static #C=!1;static #D=!1;static init(e,t,s){if(!this.isInitialized){if(this.#b=new NewgroundsIO.Core(e,t),this.#b.addEventListener("serverResponse",function(e){NGIO.#E(e)}),s&&"object"==typeof s){"string"==typeof s.version&&(this.#x=s.version);let o=["debugMode","checkHostLicense","autoLogNewView","preloadMedals","preloadScoreBoards","preloadSaveSlots"];for(let r=0;r{t.hasData&&e++}),e}static getSaveSlotData(e,t,s){null===this.saveSlots&&(console.error("getSaveSlotData data called without any preloaded save slots."),s?t.call(s,null):t(null));let o=this.getSaveSlot(e);this.#r=o,o.getData(t,s)}static setSaveSlotData(e,t,s,o){if(null==this.saveSlots){console.error("setSaveSlotData data called without any preloaded save slots."),"function"==typeof s&&(o?s(o,null):s(null));return}var r=this.getSaveSlot(e);if(null==r){console.error("Slot #"+e+" does not exist."),"function"==typeof s&&(o?s(o,null):s(null));return}r.setData(t,function(){"function"==typeof s&&(o?s(o,this.lastSaveSlotSaved):s(this.lastSaveSlotSaved))},this)}static logEvent(e,t,s){this.ngioCore.executeComponent(this.ngioCore.getComponent("Event.logEvent",{event_name:e}),function(){"function"==typeof t&&(s?t(s,this.lastLoggedEvent):t(this.lastLoggedEvent))},this)}static getDateTime(e,t){this.ngioCore.executeComponent(this.ngioCore.getComponent("Gateway.getDatetime"),function(){"function"==typeof e&&(t?e(t,this.lastDateTime,this.lastTimeStamp):e(this.lastDateTime,this.lastTimeStamp))},this)}static keepSessionAlive(){if(this.hasUser)(new Date-this.#g).Seconds>=3e4&&(this.#g=new Date,this.ngioCore.executeComponent(this.ngioCore.getComponent("Gateway.ping")))}static getConnectionStatus(e,t){this.#D||null===this.#a||null==this.session||(this.#D=!0,this.#a===this.STATUS_INITIALIZED?(this.#a=this.STATUS_CHECKING_LOCAL_VERSION,this.#G(e,t),this.#H(e,t)):this.#A?this.#a===this.STATUS_LOGIN_SUCCESSFUL?(this.#a=this.STATUS_PRELOADING_ITEMS,this.#G(e,t),this.#I(function(){this.#G(e,t),this.#B=!1},this)):this.#a===this.STATUS_ITEMS_PRELOADED?(this.#l=!1,this.#a=this.STATUS_READY,this.#G(e,t),this.#B=!1):this.keepSessionAlive():this.#B?this.#J(e,t):this.#a!==this.STATUS_CHECKING_LOCAL_VERSION&&this.session.update(function(){this.#J(e,t)},this),this.#D=!1)}static #J(e,t){(this.session.statusChanged||this.#B)&&(this.#a=this.session.status,(this.session.status==NewgroundsIO.SessionState.LOGIN_SUCCESSFUL||this.#B)&&(this.#a=NewgroundsIO.SessionState.LOGIN_SUCCESSFUL,this.#A=!0),this.#G(e,t)),this.#B=!1}static #G(s,o){o?s.call(o,this.#a):s(this.#a)}static #H(r,i){if(this.#C){this.#a=this.STATUS_LOCAL_VERSION_CHECKED,this.#G(r,i);return}this.ngioCore.queueComponent(this.ngioCore.getComponent("App.getCurrentVersion",{version:this.#x})),this.ngioCore.queueComponent(this.ngioCore.getComponent("Gateway.getVersion")),this.#z.autoLogNewView&&this.ngioCore.queueComponent(this.ngioCore.getComponent("App.logView")),this.#z.checkHostLicense&&this.ngioCore.queueComponent(this.ngioCore.getComponent("App.getHostLicense")),this.ngioCore.executeQueue(function(){this.#a=this.STATUS_LOCAL_VERSION_CHECKED,this.#C=!0,this.#G(r,i),this.#j&&console.warn("NGIO - Version mistmatch! Published version is: "+this.#k+", this version is: "+this.version),this.#i||(console.warn("NGIO - This host has been blocked fom hosting this game!"),this.#A=!0,this.#a=this.STATUS_ITEMS_PRELOADED,this.#G(r,i))},this)}static #I(){this.#z.preloadMedals&&(this.ngioCore.queueComponent(this.ngioCore.getComponent("Medal.getMedalScore")),this.ngioCore.queueComponent(this.ngioCore.getComponent("Medal.getList"))),this.#z.preloadScoreBoards&&this.ngioCore.queueComponent(this.ngioCore.getComponent("ScoreBoard.getBoards")),null!==this.user&&this.#z.preloadSaveSlots&&this.ngioCore.queueComponent(this.ngioCore.getComponent("CloudSave.loadSlots")),this.ngioCore.hasQueue?this.ngioCore.executeQueue(function(){this.#a=this.STATUS_ITEMS_PRELOADED},this):this.#a=this.STATUS_ITEMS_PRELOADED}static #F(){this.#a=this.STATUS_INITIALIZED,this.#l=!1,this.#B=!1,this.#A=!1}static #K(n){if(this.#f){let a=this.#f.length;for(let u=0;u>>2]|=(s[r>>>2]>>>24-8*(r%4)&255)<<24-8*((o+r)%4);else if(65535>>2]=s[r>>>2];else t.push.apply(t,s);return this.sigBytes+=e,this},clamp:function(){var t=this.words,s=this.sigBytes;t[s>>>2]&=4294967295<<32-8*(s%4),t.length=e.ceil(s/4)},clone:function(){var e=i.clone.call(this);return e.words=this.words.slice(0),e},random:function(t){for(var s=[],o=0;o>>2]>>>24-8*(o%4)&255;s.push((r>>>4).toString(16)),s.push((15&r).toString(16))}return s.join("")},parse:function(e){for(var t=e.length,s=[],o=0;o>>3]|=parseInt(e.substr(o,2),16)<<24-4*(o%8);return new n.init(s,t/2)}},l=a.Latin1={stringify:function(e){var t=e.words;e=e.sigBytes;for(var s=[],o=0;o>>2]>>>24-8*(o%4)&255));return s.join("")},parse:function(e){for(var t=e.length,s=[],o=0;o>>2]|=(255&e.charCodeAt(o))<<24-8*(o%4);return new n.init(s,t)}},p=a.Utf8={stringify:function(e){try{return decodeURIComponent(escape(l.stringify(e)))}catch(t){throw Error("Malformed UTF-8 data")}},parse:function(e){return l.parse(unescape(encodeURIComponent(e)))}},c=o.BufferedBlockAlgorithm=i.extend({reset:function(){this._data=new n.init,this._nDataBytes=0},_append:function(e){"string"==typeof e&&(e=p.parse(e)),this._data.concat(e),this._nDataBytes+=e.sigBytes},_process:function(t){var s=this._data,o=s.words,r=s.sigBytes,i=this.blockSize,a=r/(4*i),a=t?e.ceil(a):e.max((0|a)-this._minBufferSize,0);if(t=a*i,r=e.min(4*t,r),t){for(var u=0;u>>2]>>>24-8*(r%4)&255)<<16|(t[r+1>>>2]>>>24-8*((r+1)%4)&255)<<8|t[r+2>>>2]>>>24-8*((r+2)%4)&255,n=0;4>n&&r+.75*n>>6*(3-n)&63));if(t=o.charAt(64))for(;e.length%4;)e.push(t);return e.join("")},parse:function(e){var s=e.length,o=this._map,r=o.charAt(64);r&&-1!=(r=e.indexOf(r))&&(s=r);for(var r=[],i=0,n=0;n>>6-2*(n%4);r[i>>>2]|=(a|u)<<24-8*(i%4),i++}return t.create(r,i)},_map:"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/="}}(),function(e){function t(e,t,s,o,r,i,n){return((e=e+(t&s|~t&o)+r+n)<>>32-i)+t}function s(e,t,s,o,r,i,n){return((e=e+(t&o|s&~o)+r+n)<>>32-i)+t}function o(e,t,s,o,r,i,n){return((e=e+(t^s^o)+r+n)<>>32-i)+t}function r(e,t,s,o,r,i,n){return((e=e+(s^(t|~o))+r+n)<>>32-i)+t}for(var i=CryptoJS,n=i.lib,a=n.WordArray,u=n.Hasher,n=i.algo,l=[],p=0;64>p;p++)l[p]=4294967296*e.abs(e.sin(p+1))|0;n=n.MD5=u.extend({_doReset:function(){this._hash=new a.init([1732584193,4023233417,2562383102,271733878])},_doProcessBlock:function(e,i){for(var n=0;16>n;n++){var a=i+n,u=e[a];e[a]=(u<<8|u>>>24)&16711935|(u<<24|u>>>8)&4278255360}var n=this._hash.words,a=e[i+0],u=e[i+1],p=e[i+2],c=e[i+3],h=e[i+4],d=e[i+5],g=e[i+6],f=e[i+7],w=e[i+8],O=e[i+9],I=e[i+10],m=e[i+11],S=e[i+12],N=e[i+13],b=e[i+14],y=e[i+15],v=n[0],$=n[1],C=n[2],E=n[3],v=t(v,$,C,E,a,7,l[0]),E=t(E,v,$,C,u,12,l[1]),C=t(C,E,v,$,p,17,l[2]),$=t($,C,E,v,c,22,l[3]),v=t(v,$,C,E,h,7,l[4]),E=t(E,v,$,C,d,12,l[5]),C=t(C,E,v,$,g,17,l[6]),$=t($,C,E,v,f,22,l[7]),v=t(v,$,C,E,w,7,l[8]),E=t(E,v,$,C,O,12,l[9]),C=t(C,E,v,$,I,17,l[10]),$=t($,C,E,v,m,22,l[11]),v=t(v,$,C,E,S,7,l[12]),E=t(E,v,$,C,N,12,l[13]),C=t(C,E,v,$,b,17,l[14]),$=t($,C,E,v,y,22,l[15]),v=s(v,$,C,E,u,5,l[16]),E=s(E,v,$,C,g,9,l[17]),C=s(C,E,v,$,m,14,l[18]),$=s($,C,E,v,a,20,l[19]),v=s(v,$,C,E,d,5,l[20]),E=s(E,v,$,C,I,9,l[21]),C=s(C,E,v,$,y,14,l[22]),$=s($,C,E,v,h,20,l[23]),v=s(v,$,C,E,O,5,l[24]),E=s(E,v,$,C,b,9,l[25]),C=s(C,E,v,$,c,14,l[26]),$=s($,C,E,v,w,20,l[27]),v=s(v,$,C,E,N,5,l[28]),E=s(E,v,$,C,p,9,l[29]),C=s(C,E,v,$,f,14,l[30]),$=s($,C,E,v,S,20,l[31]),v=o(v,$,C,E,d,4,l[32]),E=o(E,v,$,C,w,11,l[33]),C=o(C,E,v,$,m,16,l[34]),$=o($,C,E,v,b,23,l[35]),v=o(v,$,C,E,u,4,l[36]),E=o(E,v,$,C,h,11,l[37]),C=o(C,E,v,$,f,16,l[38]),$=o($,C,E,v,I,23,l[39]),v=o(v,$,C,E,N,4,l[40]),E=o(E,v,$,C,a,11,l[41]),C=o(C,E,v,$,c,16,l[42]),$=o($,C,E,v,g,23,l[43]),v=o(v,$,C,E,O,4,l[44]),E=o(E,v,$,C,S,11,l[45]),C=o(C,E,v,$,y,16,l[46]),$=o($,C,E,v,p,23,l[47]),v=r(v,$,C,E,a,6,l[48]),E=r(E,v,$,C,f,10,l[49]),C=r(C,E,v,$,b,15,l[50]),$=r($,C,E,v,d,21,l[51]),v=r(v,$,C,E,S,6,l[52]),E=r(E,v,$,C,c,10,l[53]),C=r(C,E,v,$,I,15,l[54]),$=r($,C,E,v,u,21,l[55]),v=r(v,$,C,E,w,6,l[56]),E=r(E,v,$,C,y,10,l[57]),C=r(C,E,v,$,g,15,l[58]),$=r($,C,E,v,N,21,l[59]),v=r(v,$,C,E,h,6,l[60]),E=r(E,v,$,C,m,10,l[61]),C=r(C,E,v,$,p,15,l[62]),$=r($,C,E,v,O,21,l[63]);n[0]=n[0]+v|0,n[1]=n[1]+$|0,n[2]=n[2]+C|0,n[3]=n[3]+E|0},_doFinalize:function(){var t=this._data,s=t.words,o=8*this._nDataBytes,r=8*t.sigBytes;s[r>>>5]|=128<<24-r%32;var i=e.floor(o/4294967296);for(s[(r+64>>>9<<4)+15]=(i<<8|i>>>24)&16711935|(i<<24|i>>>8)&4278255360,s[(r+64>>>9<<4)+14]=(o<<8|o>>>24)&16711935|(o<<24|o>>>8)&4278255360,t.sigBytes=4*(s.length+1),this._process(),s=(t=this._hash).words,o=0;4>o;o++)r=s[o],s[o]=(r<<8|r>>>24)&16711935|(r<<24|r>>>8)&4278255360;return t},clone:function(){var e=u.clone.call(this);return e._hash=this._hash.clone(),e}}),i.MD5=u._createHelper(n),i.HmacMD5=u._createHmacHelper(n)}(Math),function(){var e=CryptoJS,t=e.lib,s=t.Base,o=t.WordArray,t=e.algo,r=t.EvpKDF=s.extend({cfg:s.extend({keySize:4,hasher:t.MD5,iterations:1}),init:function(e){this.cfg=this.cfg.extend(e)},compute:function(e,t){for(var s=this.cfg,r=s.hasher.create(),i=o.create(),n=i.words,a=s.keySize,s=s.iterations;n.length>>2]}},s.BlockCipher=u.extend({cfg:u.cfg.extend({mode:l,padding:c}),reset:function(){u.reset.call(this);var e=this.cfg,t=e.iv,e=e.mode;if(this._xformMode==this._ENC_XFORM_MODE)var s=e.createEncryptor;else s=e.createDecryptor,this._minBufferSize=1;this._mode=s.call(e,this,t&&t.words)},_doProcessBlock:function(e,t){this._mode.processBlock(e,t)},_doFinalize:function(){var e=this.cfg.padding;if(this._xformMode==this._ENC_XFORM_MODE){e.pad(this._data,this.blockSize);var t=this._process(!0)}else t=this._process(!0),e.unpad(t);return t},blockSize:4});var h=s.CipherParams=o.extend({init:function(e){this.mixIn(e)},toString:function(e){return(e||this.formatter).stringify(this)}}),l=(t.format={}).OpenSSL={stringify:function(e){var t=e.ciphertext;return((e=e.salt)?r.create([1398893684,1701076831]).concat(e).concat(t):t).toString(n)},parse:function(e){var t=(e=n.parse(e)).words;if(1398893684==t[0]&&1701076831==t[1]){var s=r.create(t.slice(2,4));t.splice(0,4),e.sigBytes-=16}return h.create({ciphertext:e,salt:s})}},d=s.SerializableCipher=o.extend({cfg:o.extend({format:l}),encrypt:function(e,t,s,o){o=this.cfg.extend(o);var r=e.createEncryptor(s,o);return t=r.finalize(t),r=r.cfg,h.create({ciphertext:t,key:s,iv:r.iv,algorithm:e,mode:r.mode,padding:r.padding,blockSize:e.blockSize,formatter:o.format})},decrypt:function(e,t,s,o){return o=this.cfg.extend(o),t=this._parse(t,o.format),e.createDecryptor(s,o).finalize(t.ciphertext)},_parse:function(e,t){return"string"==typeof e?t.parse(e,this):e}}),t=(t.kdf={}).OpenSSL={execute:function(e,t,s,o){return o||(o=r.random(8)),e=a.create({keySize:t+s}).compute(e,o),s=r.create(e.words.slice(t),4*s),e.sigBytes=4*t,h.create({key:e,iv:s,salt:o})}},g=s.PasswordBasedCipher=d.extend({cfg:d.cfg.extend({kdf:t}),encrypt:function(e,t,s,o){return s=(o=this.cfg.extend(o)).kdf.execute(s,e.keySize,e.ivSize),o.iv=s.iv,(e=d.encrypt.call(this,e,t,s.key,o)).mixIn(s),e},decrypt:function(e,t,s,o){return o=this.cfg.extend(o),t=this._parse(t,o.format),s=o.kdf.execute(s,e.keySize,e.ivSize,t.salt),o.iv=s.iv,d.decrypt.call(this,e,t,s.key,o)}})}(),function(){for(var e=CryptoJS,t=e.lib.BlockCipher,s=e.algo,o=[],r=[],i=[],n=[],a=[],u=[],l=[],p=[],c=[],h=[],d=[],g=0;256>g;g++)d[g]=128>g?g<<1:g<<1^283;for(var f=0,w=0,g=0;256>g;g++){var O=w^w<<1^w<<2^w<<3^w<<4,O=O>>>8^255&O^99;o[f]=O,r[O]=f;var I=d[f],m=d[I],S=d[m],N=257*d[O]^16843008*O;i[f]=N<<24|N>>>8,n[f]=N<<16|N>>>16,a[f]=N<<8|N>>>24,u[f]=N,N=16843009*S^65537*m^257*I^16843008*f,l[O]=N<<24|N>>>8,p[O]=N<<16|N>>>16,c[O]=N<<8|N>>>24,h[O]=N,f?(f=I^d[d[d[S^I]]],w^=d[d[w]]):f=w=1}var b=[0,1,2,4,8,16,32,64,128,27,54],s=s.AES=t.extend({_doReset:function(){for(var e=this._key,t=e.words,s=e.sigBytes/4,e=4*((this._nRounds=s+6)+1),r=this._keySchedule=[],i=0;i>>24]<<24|o[n>>>16&255]<<16|o[n>>>8&255]<<8|o[255&n]):(n=o[(n=n<<8|n>>>24)>>>24]<<24|o[n>>>16&255]<<16|o[n>>>8&255]<<8|o[255&n],n^=b[i/s|0]<<24),r[i]=r[i-s]^n}for(s=0,t=this._invKeySchedule=[];ss||4>=i?n:l[o[n>>>24]]^p[o[n>>>16&255]]^c[o[n>>>8&255]]^h[o[255&n]]},encryptBlock:function(e,t){this._doCryptBlock(e,t,this._keySchedule,i,n,a,u,o)},decryptBlock:function(e,t){var s=e[t+1];e[t+1]=e[t+3],e[t+3]=s,this._doCryptBlock(e,t,this._invKeySchedule,l,p,c,h,r),s=e[t+1],e[t+1]=e[t+3],e[t+3]=s},_doCryptBlock:function(e,t,s,o,r,i,n,a){for(var u=this._nRounds,l=e[t]^s[0],p=e[t+1]^s[1],c=e[t+2]^s[2],h=e[t+3]^s[3],d=4,g=1;g>>24]^r[p>>>16&255]^i[c>>>8&255]^n[255&h]^s[d++],w=o[p>>>24]^r[c>>>16&255]^i[h>>>8&255]^n[255&l]^s[d++],O=o[c>>>24]^r[h>>>16&255]^i[l>>>8&255]^n[255&p]^s[d++],h=o[h>>>24]^r[l>>>16&255]^i[p>>>8&255]^n[255&c]^s[d++],l=f,p=w,c=O;f=(a[l>>>24]<<24|a[p>>>16&255]<<16|a[c>>>8&255]<<8|a[255&h])^s[d++],w=(a[p>>>24]<<24|a[c>>>16&255]<<16|a[h>>>8&255]<<8|a[255&l])^s[d++],O=(a[c>>>24]<<24|a[h>>>16&255]<<16|a[l>>>8&255]<<8|a[255&p])^s[d++],h=(a[h>>>24]<<24|a[l>>>16&255]<<16|a[p>>>8&255]<<8|a[255&c])^s[d++],e[t]=f,e[t+1]=w,e[t+2]=O,e[t+3]=h},keySize:8});e.AES=t._createHelper(s)}();var NewgroundsIO=NewgroundsIO||{};NewgroundsIO.objects=NewgroundsIO.objects?NewgroundsIO.objects:{},NewgroundsIO.results=NewgroundsIO.results?NewgroundsIO.results:{},NewgroundsIO.components=NewgroundsIO.components?NewgroundsIO.components:{},(()=>{class e extends EventTarget{#O="https://www.newgrounds.io/gateway_v3.php";#P=!1;#Q=null;#R=null;#S=[];#T=null;#U=null;#V={};get GATEWAY_URI(){return this.#O}get debug(){return this.#P}set debug(e){this.#P=!!e}get appID(){return this.#Q}get componentQueue(){return this.#S}get hasQueue(){return this.#S.length>0}get host(){return this.#T}get session(){return this.#U}get user(){return this.#U?this.#U.user:null}get uriParams(){return this.#V}constructor(e,t){if(super(),void 0===e)throw"Missing required appID!";if(void 0===t)throw"Missing required aesKey!";if(this.#Q=e,this.#R=CryptoJS.enc.Base64.parse(t),this.#S=[],this.#V={},window&&window.location&&window.location.href?window.location.hostname?this.#T=window.location.hostname.toLowerCase():"file:"==window.location.href.toLowerCase().substr(0,5)?this.#T="":this.#T="":this.#T="","undefined"!=typeof window&&window.location){var s,o=window.location.href.split("?").pop();if(o)for(var r,i=o.split("&"),n=0;n{t instanceof NewgroundsIO.BaseComponent||(r._verifyComponent(e)||(o=!1),t.setCore(r))}),!o)return}else{if(!this._verifyComponent(e))return;e.setCore(this)}let i=this,n=this._getRequest(e);new NewgroundsIO.objects.Response;var a=new XMLHttpRequest;a.onreadystatechange=function(){if(4==a.readyState){var e;try{e=JSON.parse(a.responseText)}catch(o){(e={success:!1,app_id:i.app_id}).error={message:String(o),code:8002}}let r=i._populateResponse(e);i.dispatchEvent(new CustomEvent("serverResponse",{detail:r})),t&&(s?t.call(s,r):t(r))}};var u=void 0!==Array.prototype.toJSON?Array.prototype.toJSON:null;u&&delete Array.prototype.toJSON;let l=new FormData;l.append("request",JSON.stringify(n)),u&&(Array.prototype.toJSON=u),a.open("POST",this.GATEWAY_URI,!0),a.send(l)}loadComponent(e){if(!this._verifyComponent(e))return;e.setCore(this);let t=this._getRequest(e),s=this.GATEWAY_URI+"?request="+encodeURIComponent(JSON.stringify(t));window.open(s,"_blank")}onServerResponse(e){}_populateResponse(e){if(e.success){if(Array.isArray(e.result))for(let t=0;t{let o=s._getExecute(e);t.push(o)})):t=this._getExecute(e);let o=new NewgroundsIO.objects.Request({execute:t});return this.debug&&(o.debug=!0),o.setCore(this),o}_verifyComponent(e){return e instanceof NewgroundsIO.BaseComponent?!!e.isValid():(console.error("NewgroundsIO Type Mismatch: Expecting a NewgroundsIO.components.XXXX instance, got",e),!1)}}NewgroundsIO.Core=e})(),(()=>{class e{get type(){return this.__type}__type="object";__object="BaseObject";__properties=[];__required=[];__ngioCore=null;isValid(){if(0===this.__required.length)return!0;let e=!0;return this.__required.forEach(function(t){null===this[t]?(console.error("NewgroundsIO Error: "+this.__object+" "+this.__type+" is invalid, missing value for '"+t+"'"),e=!1):this[t]instanceof NewgroundsIO.BaseObject&&!this[t].isValid()&&(e=!1)},this),e}setCore(e){this._doSetCore(e,[])}objectMap={};arrayMap={};fromJSON(e,t){var s,o,r={};for(this.setCore(t),s=0;s{s instanceof NewgroundsIO.BaseObject&&-1===t.indexOf(s)&&s._doSetCore(e,t)},this),"host"!==s||this.host||(this.host=e.host)},this)):console.error("NewgroundsIO Error: Expecting NewgroundsIO.Core instance, got",e)}toJSON(){return this.__doToJSON()}__doToJSON(){if(void 0===this.__properties)return{};let e={};return this.__properties.forEach(function(t){null!==this[t]&&(e[t]="function"==typeof this[t].toJSON?this[t].toJSON():this[t])},this),e}toSecureJSON(){return this.__ngioCore&&this.__ngioCore instanceof NewgroundsIO.Core?{secure:this.__ngioCore.encrypt(JSON.stringify(this.__doToJSON()))}:(console.error("NewgroundsIO Error: Unable to create secure JSON object without calling setCore() first."),this.__doToJSON())}toString(){return this.__type}clone(e){return void 0===e&&(e=new this.constructor),this.__properties.forEach(t=>{e[t]=this[t]}),e.__ngioCore=this.__ngioCore,e}}NewgroundsIO.BaseObject=e;class t extends e{constructor(){super(),this.__type="component",this.__object="BaseComponent",this.__properties=["host","echo"],this._echo=null}get host(){return this.__ngioCore?this.__ngioCore.host:null}get echo(){return this._echo}set echo(e){this.echo=""+e}}NewgroundsIO.BaseComponent=t;class s extends e{constructor(){super(),this.__type="result",this.__object="BaseResult",this.__properties=["echo","error","success"],this._echo=null,this._error=null,this._success=null}get component(){return this.__object}get echo(){return this._echo}get error(){return this._error}set error(e){this._error=e}get success(){return!!this._success}set success(e){this._success=!!e}}NewgroundsIO.BaseResult=s})(),NewgroundsIO.SessionState={SESSION_UNINITIALIZED:"session-uninitialized",WAITING_FOR_SERVER:"waiting-for-server",LOGIN_REQUIRED:"login-required",WAITING_FOR_USER:"waiting-for-user",LOGIN_CANCELLED:"login-cancelled",LOGIN_SUCCESSFUL:"login-successful",LOGIN_FAILED:"login-failed",USER_LOGGED_OUT:"user-logged-out",SERVER_UNAVAILABLE:"server-unavailable",EXCEEDED_MAX_ATTEMPTS:"exceeded-max-attempts"},NewgroundsIO.SessionState.SESSION_WAITING=[NewgroundsIO.SessionState.SESSION_UNINITIALIZED,NewgroundsIO.SessionState.WAITING_FOR_SERVER,NewgroundsIO.SessionState.WAITING_FOR_USER,NewgroundsIO.SessionState.LOGIN_CANCELLED,NewgroundsIO.SessionStateLOGIN_FAILED],(()=>{class e extends NewgroundsIO.BaseComponent{constructor(){super(),this.__object="App.checkSession",this.__requireSession=!0}}void 0===NewgroundsIO.components.App&&(NewgroundsIO.components.App={}),NewgroundsIO.components.App.checkSession=e})(),(()=>{class e extends NewgroundsIO.BaseComponent{constructor(){super(),this.__object="App.endSession",this.__requireSession=!0}}void 0===NewgroundsIO.components.App&&(NewgroundsIO.components.App={}),NewgroundsIO.components.App.endSession=e})(),(()=>{class e extends NewgroundsIO.BaseComponent{constructor(e){super();let t=this;if(this.__object="App.getCurrentVersion",["version"].forEach(e=>{0>t.__properties.indexOf(e)&&t.__properties.push(e)}),e&&"object"==typeof e)for(var s=0;s{class e extends NewgroundsIO.BaseComponent{constructor(e){super();let t=this;if(this.__object="App.getHostLicense",["host"].forEach(e=>{0>t.__properties.indexOf(e)&&t.__properties.push(e)}),e&&"object"==typeof e)for(var s=0;s{class e extends NewgroundsIO.BaseComponent{constructor(e){super();let t=this;if(this.__object="App.logView",["host"].forEach(e=>{0>t.__properties.indexOf(e)&&t.__properties.push(e)}),e&&"object"==typeof e)for(var s=0;s{class e extends NewgroundsIO.BaseComponent{constructor(e){super();let t=this;if(this.__object="App.startSession",["force"].forEach(e=>{0>t.__properties.indexOf(e)&&t.__properties.push(e)}),e&&"object"==typeof e)for(var s=0;s{class e extends NewgroundsIO.BaseComponent{constructor(e){super();let t=this;if(this.__object="CloudSave.clearSlot",this.__requireSession=!0,["id"].forEach(e=>{0>t.__properties.indexOf(e)&&t.__properties.push(e)}),e&&"object"==typeof e)for(var s=0;s{class e extends NewgroundsIO.BaseComponent{constructor(e){super();let t=this;if(this.__object="CloudSave.loadSlot",this.__requireSession=!0,["id","app_id"].forEach(e=>{0>t.__properties.indexOf(e)&&t.__properties.push(e)}),e&&"object"==typeof e)for(var s=0;s{class e extends NewgroundsIO.BaseComponent{constructor(e){super();let t=this;if(this.__object="CloudSave.loadSlots",this.__requireSession=!0,["app_id"].forEach(e=>{0>t.__properties.indexOf(e)&&t.__properties.push(e)}),e&&"object"==typeof e)for(var s=0;s{class e extends NewgroundsIO.BaseComponent{constructor(e){super();let t=this;if(this.__object="CloudSave.setData",this.__requireSession=!0,["id","data"].forEach(e=>{0>t.__properties.indexOf(e)&&t.__properties.push(e)}),e&&"object"==typeof e)for(var s=0;s{class e extends NewgroundsIO.BaseComponent{constructor(e){super();let t=this;if(this.__object="Event.logEvent",["host","event_name"].forEach(e=>{0>t.__properties.indexOf(e)&&t.__properties.push(e)}),e&&"object"==typeof e)for(var s=0;s{class e extends NewgroundsIO.BaseComponent{constructor(){super(),this.__object="Gateway.getDatetime"}}void 0===NewgroundsIO.components.Gateway&&(NewgroundsIO.components.Gateway={}),NewgroundsIO.components.Gateway.getDatetime=e})(),(()=>{class e extends NewgroundsIO.BaseComponent{constructor(){super(),this.__object="Gateway.getVersion"}}void 0===NewgroundsIO.components.Gateway&&(NewgroundsIO.components.Gateway={}),NewgroundsIO.components.Gateway.getVersion=e})(),(()=>{class e extends NewgroundsIO.BaseComponent{constructor(){super(),this.__object="Gateway.ping"}}void 0===NewgroundsIO.components.Gateway&&(NewgroundsIO.components.Gateway={}),NewgroundsIO.components.Gateway.ping=e})(),(()=>{class e extends NewgroundsIO.BaseComponent{constructor(e){super();let t=this;if(this.__object="Loader.loadAuthorUrl",["host","redirect","log_stat"].forEach(e=>{0>t.__properties.indexOf(e)&&t.__properties.push(e)}),e&&"object"==typeof e)for(var s=0;s{class e extends NewgroundsIO.BaseComponent{constructor(e){super();let t=this;if(this.__object="Loader.loadMoreGames",["host","redirect","log_stat"].forEach(e=>{0>t.__properties.indexOf(e)&&t.__properties.push(e)}),e&&"object"==typeof e)for(var s=0;s{class e extends NewgroundsIO.BaseComponent{constructor(e){super();let t=this;if(this.__object="Loader.loadNewgrounds",["host","redirect","log_stat"].forEach(e=>{0>t.__properties.indexOf(e)&&t.__properties.push(e)}),e&&"object"==typeof e)for(var s=0;s{class e extends NewgroundsIO.BaseComponent{constructor(e){super();let t=this;if(this.__object="Loader.loadOfficialUrl",["host","redirect","log_stat"].forEach(e=>{0>t.__properties.indexOf(e)&&t.__properties.push(e)}),e&&"object"==typeof e)for(var s=0;s{class e extends NewgroundsIO.BaseComponent{constructor(e){super();let t=this;if(this.__object="Loader.loadReferral",["host","referral_name","redirect","log_stat"].forEach(e=>{0>t.__properties.indexOf(e)&&t.__properties.push(e)}),e&&"object"==typeof e)for(var s=0;s{class e extends NewgroundsIO.BaseComponent{constructor(e){super();let t=this;if(this.__object="Medal.getList",["app_id"].forEach(e=>{0>t.__properties.indexOf(e)&&t.__properties.push(e)}),e&&"object"==typeof e)for(var s=0;s{class e extends NewgroundsIO.BaseComponent{constructor(){super(),this.__object="Medal.getMedalScore",this.__requireSession=!0}}void 0===NewgroundsIO.components.Medal&&(NewgroundsIO.components.Medal={}),NewgroundsIO.components.Medal.getMedalScore=e})(),(()=>{class e extends NewgroundsIO.BaseComponent{constructor(e){super();let t=this;if(this.__object="Medal.unlock",this.__isSecure=!0,this.__requireSession=!0,["id"].forEach(e=>{0>t.__properties.indexOf(e)&&t.__properties.push(e)}),e&&"object"==typeof e)for(var s=0;s{class e extends NewgroundsIO.BaseComponent{constructor(){super(),this.__object="ScoreBoard.getBoards"}}void 0===NewgroundsIO.components.ScoreBoard&&(NewgroundsIO.components.ScoreBoard={}),NewgroundsIO.components.ScoreBoard.getBoards=e})(),(()=>{class e extends NewgroundsIO.BaseComponent{constructor(e){super();let t=this;if(this.__object="ScoreBoard.getScores",["id","period","tag","social","user","skip","limit","app_id"].forEach(e=>{0>t.__properties.indexOf(e)&&t.__properties.push(e)}),e&&"object"==typeof e)for(var s=0;s{class e extends NewgroundsIO.BaseComponent{constructor(e){super();let t=this;if(this.__object="ScoreBoard.postScore",this.__isSecure=!0,this.__requireSession=!0,["id","value","tag"].forEach(e=>{0>t.__properties.indexOf(e)&&t.__properties.push(e)}),e&&"object"==typeof e)for(var s=0;s{class e extends NewgroundsIO.BaseObject{constructor(e){super();let t=this;if(this.__object="Debug",["exec_time","request"].forEach(e=>{0>t.__properties.indexOf(e)&&t.__properties.push(e)}),e&&"object"==typeof e)for(var s=0;s{class e extends NewgroundsIO.BaseObject{constructor(e){super();let t=this;if(this.__object="Error",["message","code"].forEach(e=>{0>t.__properties.indexOf(e)&&t.__properties.push(e)}),e&&"object"==typeof e)for(var s=0;s{class e extends NewgroundsIO.BaseObject{constructor(e){super();let t=this;if(this.__object="Execute",["component","parameters","secure"].forEach(e=>{0>t.__properties.indexOf(e)&&t.__properties.push(e)}),e&&"object"==typeof e)for(var s=0;s{class e extends NewgroundsIO.BaseObject{constructor(e){super();let t=this;if(this.__object="Medal",["id","name","description","icon","value","difficulty","secret","unlocked"].forEach(e=>{0>t.__properties.indexOf(e)&&t.__properties.push(e)}),e&&"object"==typeof e)for(var s=0;s{class e extends NewgroundsIO.BaseObject{constructor(e){super();let t=this;if(this.__object="Request",["app_id","execute","session_id","debug"].forEach(e=>{0>t.__properties.indexOf(e)&&t.__properties.push(e)}),e&&"object"==typeof e)for(var s=0;s{class e extends NewgroundsIO.BaseObject{constructor(e){super();let t=this;if(this.__object="Response",["app_id","success","debug","result","error","api_version","help_url"].forEach(e=>{0>t.__properties.indexOf(e)&&t.__properties.push(e)}),e&&"object"==typeof e)for(var s=0;s{class e extends NewgroundsIO.BaseObject{constructor(e){super();let t=this;if(this.__object="SaveSlot",["id","size","datetime","timestamp","url"].forEach(e=>{0>t.__properties.indexOf(e)&&t.__properties.push(e)}),e&&"object"==typeof e)for(var s=0;s{class e extends NewgroundsIO.BaseObject{constructor(e){super();let t=this;if(this.__object="Score",["user","value","formatted_value","tag"].forEach(e=>{0>t.__properties.indexOf(e)&&t.__properties.push(e)}),e&&"object"==typeof e)for(var s=0;s{class e extends NewgroundsIO.BaseObject{constructor(e){super();let t=this;if(this.__object="ScoreBoard",["id","name"].forEach(e=>{0>t.__properties.indexOf(e)&&t.__properties.push(e)}),e&&"object"==typeof e)for(var s=0;s{class e extends NewgroundsIO.BaseObject{constructor(e){super();let t=this;if(this.__object="Session",["id","user","expired","remember","passport_url"].forEach(e=>{0>t.__properties.indexOf(e)&&t.__properties.push(e)}),e&&"object"==typeof e)for(var s=0;s=this.#aS?this.#aL=NewgroundsIO.SessionState.EXCEEDED_MAX_ATTEMPTS:(this.#aL=NewgroundsIO.SessionState.SESSION_UNINITIALIZED,this.#aR++)),this.status==NewgroundsIO.SessionState.SESSION_UNINITIALIZED&&(this.#aU=localStorage.getItem(this.storageKey),this.#aT?this.id=this.#aT:this.#aU&&(this.id=this.#aU),this.mode=this.id&&"null"!==this.id?"check":"new");var s=new Date;if(!(s-this.#aO<5e3))switch(this.#aO=s,this.mode){case"new":this.mode="wait",this.startSession();break;case"check":this.mode="wait",this.checkSession()}}}startSession(){this.#aP=!1,this.resetSession(),this.#aL=NewgroundsIO.SessionState.WAITING_FOR_SERVER;var e=this.__ngioCore.getComponent("App.startSession");this.__ngioCore.executeComponent(e,this._onStartSession,this)}_onStartSession(e){if(!0===e.success){let t=e.result;if(Array.isArray(t)){for(let s=0;s{class e extends NewgroundsIO.BaseObject{constructor(e){super();let t=this;if(this.__object="User",["id","name","icons","supporter"].forEach(e=>{0>t.__properties.indexOf(e)&&t.__properties.push(e)}),e&&"object"==typeof e)for(var s=0;s{class e extends NewgroundsIO.BaseObject{constructor(e){super();let t=this;if(this.__object="UserIcons",["small","medium","large"].forEach(e=>{0>t.__properties.indexOf(e)&&t.__properties.push(e)}),e&&"object"==typeof e)for(var s=0;s{class e extends NewgroundsIO.BaseResult{constructor(e){super();let t=this;if(this.__object="App.checkSession",["session"].forEach(e=>{0>t.__properties.indexOf(e)&&t.__properties.push(e)}),e&&"object"==typeof e)for(var s=0;s{class e extends NewgroundsIO.BaseResult{constructor(e){super();let t=this;if(this.__object="App.getCurrentVersion",["current_version","client_deprecated"].forEach(e=>{0>t.__properties.indexOf(e)&&t.__properties.push(e)}),e&&"object"==typeof e)for(var s=0;s{class e extends NewgroundsIO.BaseResult{constructor(e){super();let t=this;if(this.__object="App.getHostLicense",["host_approved"].forEach(e=>{0>t.__properties.indexOf(e)&&t.__properties.push(e)}),e&&"object"==typeof e)for(var s=0;s{class e extends NewgroundsIO.BaseResult{constructor(e){super();let t=this;if(this.__object="App.startSession",["session"].forEach(e=>{0>t.__properties.indexOf(e)&&t.__properties.push(e)}),e&&"object"==typeof e)for(var s=0;s{class e extends NewgroundsIO.BaseResult{constructor(e){super();let t=this;if(this.__object="CloudSave.clearSlot",["slot"].forEach(e=>{0>t.__properties.indexOf(e)&&t.__properties.push(e)}),e&&"object"==typeof e)for(var s=0;s{class e extends NewgroundsIO.BaseResult{constructor(e){super();let t=this;if(this.__object="CloudSave.loadSlot",["slot","app_id"].forEach(e=>{0>t.__properties.indexOf(e)&&t.__properties.push(e)}),e&&"object"==typeof e)for(var s=0;s{class e extends NewgroundsIO.BaseResult{constructor(e){super();let t=this;if(this.__object="CloudSave.loadSlots",["slots","app_id"].forEach(e=>{0>t.__properties.indexOf(e)&&t.__properties.push(e)}),e&&"object"==typeof e)for(var s=0;s{class e extends NewgroundsIO.BaseResult{constructor(e){super();let t=this;if(this.__object="CloudSave.setData",["slot"].forEach(e=>{0>t.__properties.indexOf(e)&&t.__properties.push(e)}),e&&"object"==typeof e)for(var s=0;s{class e extends NewgroundsIO.BaseResult{constructor(e){super();let t=this;if(this.__object="Event.logEvent",["event_name"].forEach(e=>{0>t.__properties.indexOf(e)&&t.__properties.push(e)}),e&&"object"==typeof e)for(var s=0;s{class e extends NewgroundsIO.BaseResult{constructor(e){super();let t=this;if(this.__object="Gateway.getDatetime",["datetime","timestamp"].forEach(e=>{0>t.__properties.indexOf(e)&&t.__properties.push(e)}),e&&"object"==typeof e)for(var s=0;s{class e extends NewgroundsIO.BaseResult{constructor(e){super();let t=this;if(this.__object="Gateway.getVersion",["version"].forEach(e=>{0>t.__properties.indexOf(e)&&t.__properties.push(e)}),e&&"object"==typeof e)for(var s=0;s{class e extends NewgroundsIO.BaseResult{constructor(e){super();let t=this;if(this.__object="Gateway.ping",["pong"].forEach(e=>{0>t.__properties.indexOf(e)&&t.__properties.push(e)}),e&&"object"==typeof e)for(var s=0;s{class e extends NewgroundsIO.BaseResult{constructor(e){super();let t=this;if(this.__object="Loader.loadAuthorUrl",["url"].forEach(e=>{0>t.__properties.indexOf(e)&&t.__properties.push(e)}),e&&"object"==typeof e)for(var s=0;s{class e extends NewgroundsIO.BaseResult{constructor(e){super();let t=this;if(this.__object="Loader.loadMoreGames",["url"].forEach(e=>{0>t.__properties.indexOf(e)&&t.__properties.push(e)}),e&&"object"==typeof e)for(var s=0;s{class e extends NewgroundsIO.BaseResult{constructor(e){super();let t=this;if(this.__object="Loader.loadNewgrounds",["url"].forEach(e=>{0>t.__properties.indexOf(e)&&t.__properties.push(e)}),e&&"object"==typeof e)for(var s=0;s{class e extends NewgroundsIO.BaseResult{constructor(e){super();let t=this;if(this.__object="Loader.loadOfficialUrl",["url"].forEach(e=>{0>t.__properties.indexOf(e)&&t.__properties.push(e)}),e&&"object"==typeof e)for(var s=0;s{class e extends NewgroundsIO.BaseResult{constructor(e){super();let t=this;if(this.__object="Loader.loadReferral",["url"].forEach(e=>{0>t.__properties.indexOf(e)&&t.__properties.push(e)}),e&&"object"==typeof e)for(var s=0;s{class e extends NewgroundsIO.BaseResult{constructor(e){super();let t=this;if(this.__object="Medal.getList",["medals","app_id"].forEach(e=>{0>t.__properties.indexOf(e)&&t.__properties.push(e)}),e&&"object"==typeof e)for(var s=0;s{class e extends NewgroundsIO.BaseResult{constructor(e){super();let t=this;if(this.__object="Medal.getMedalScore",["medal_score"].forEach(e=>{0>t.__properties.indexOf(e)&&t.__properties.push(e)}),e&&"object"==typeof e)for(var s=0;s{class e extends NewgroundsIO.BaseResult{constructor(e){super();let t=this;if(this.__object="Medal.unlock",["medal","medal_score"].forEach(e=>{0>t.__properties.indexOf(e)&&t.__properties.push(e)}),e&&"object"==typeof e)for(var s=0;s{class e extends NewgroundsIO.BaseResult{constructor(e){super();let t=this;if(this.__object="ScoreBoard.getBoards",["scoreboards"].forEach(e=>{0>t.__properties.indexOf(e)&&t.__properties.push(e)}),e&&"object"==typeof e)for(var s=0;s{class e extends NewgroundsIO.BaseResult{constructor(e){super();let t=this;if(this.__object="ScoreBoard.getScores",["period","social","limit","scoreboard","scores","user","app_id"].forEach(e=>{0>t.__properties.indexOf(e)&&t.__properties.push(e)}),e&&"object"==typeof e)for(var s=0;s{class e extends NewgroundsIO.BaseResult{constructor(e){super();let t=this;if(this.__object="ScoreBoard.postScore",["scoreboard","score"].forEach(e=>{0>t.__properties.indexOf(e)&&t.__properties.push(e)}),e&&"object"==typeof e)for(var s=0;s Date: Tue, 7 Oct 2025 18:27:13 -0500 Subject: [PATCH 15/16] remove innerhtml usage --- extensions/obviousAlexC/newgroundsIO.js | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/extensions/obviousAlexC/newgroundsIO.js b/extensions/obviousAlexC/newgroundsIO.js index a3e45b35f8..106aec89e6 100644 --- a/extensions/obviousAlexC/newgroundsIO.js +++ b/extensions/obviousAlexC/newgroundsIO.js @@ -271,6 +271,7 @@ sc_monitor_page_text: { flexGrow: "1", boxSizing: "border-box", + whiteSpace: "pre" }, sc_monitor_page_button: { border: "1px solid", @@ -978,7 +979,7 @@ const pageText = document.createElement("div"); setElementCSS(pageText, customCSS.sc_monitor_page_text); - pageText.innerHTML = `Page
${page + 1}`; + pageText.textContent = `Page\n${page + 1}`; const buttonNext = document.createElement("button"); setElementCSS(buttonNext, customCSS.sc_monitor_page_button); @@ -996,7 +997,7 @@ return; } - pageText.innerHTML = `Page
${page + 1}`; + pageText.textContent = `Page\n${page + 1}`; //Make sure buttons are valid buttonPrevious.disabled = false; @@ -1026,7 +1027,9 @@ if (scores.length == monitorDisplayData.itemCount + 1) scoresToDisplay--; - monitorInner.innerHTML = ""; + while (monitorInner.firstChild) { + monitorInner.removeChild(monitorInner.firstChild); + } for (let scoreID = 0; scoreID < scoresToDisplay; scoreID++) { const score = scores[scoreID]; From 028d3ddb17b45ab7c300dc421696f73884f9faaf Mon Sep 17 00:00:00 2001 From: Thomas Weber Date: Tue, 7 Oct 2025 18:29:42 -0500 Subject: [PATCH 16/16] fix format pass --- extensions/obviousAlexC/newgroundsIO.js | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/extensions/obviousAlexC/newgroundsIO.js b/extensions/obviousAlexC/newgroundsIO.js index 106aec89e6..0e009eee29 100644 --- a/extensions/obviousAlexC/newgroundsIO.js +++ b/extensions/obviousAlexC/newgroundsIO.js @@ -40,10 +40,10 @@ //Updated to the latest //Put this in here since there are 3 objects - // prettier-ignore var NewgroundsIO; var NGIO; var CryptoJS; + // prettier-ignore { NGIO = class{static get STATUS_INITIALIZED(){return"initialized"}static get STATUS_CHECKING_LOCAL_VERSION(){return"checking-local-version"}static get STATUS_LOCAL_VERSION_CHECKED(){return"local-version-checked"}static get STATUS_PRELOADING_ITEMS(){return"preloading-items"}static get STATUS_ITEMS_PRELOADED(){return"items-preloaded"}static get STATUS_READY(){return"ready"}static get STATUS_SESSION_UNINITIALIZED(){return NewgroundsIO.SessionState.SESSION_UNINITIALIZED}static get STATUS_WAITING_FOR_SERVER(){return NewgroundsIO.SessionState.WAITING_FOR_SERVER}static get STATUS_LOGIN_REQUIRED(){return NewgroundsIO.SessionState.LOGIN_REQUIRED}static get STATUS_WAITING_FOR_USER(){return NewgroundsIO.SessionState.WAITING_FOR_USER}static get STATUS_LOGIN_CANCELLED(){return NewgroundsIO.SessionState.LOGIN_CANCELLED}static get STATUS_LOGIN_SUCCESSFUL(){return NewgroundsIO.SessionState.LOGIN_SUCCESSFUL}static get STATUS_LOGIN_FAILED(){return NewgroundsIO.SessionState.LOGIN_FAILED}static get STATUS_USER_LOGGED_OUT(){return NewgroundsIO.SessionState.USER_LOGGED_OUT}static get STATUS_SERVER_UNAVAILABLE(){return NewgroundsIO.SessionState.SERVER_UNAVAILABLE}static get STATUS_EXCEEDED_MAX_ATTEMPTS(){return NewgroundsIO.SessionState.EXCEEDED_MAX_ATTEMPTS}static get isWaitingStatus(){return NewgroundsIO.SessionState.SESSION_WAITING.indexOf(this.#a)>=0||[this.STATUS_PRELOADING_ITEMS,this.LOCAL_VERSION_CHECKED,this.STATUS_CHECKING_LOCAL_VERSION].indexOf(this.#a)>=0}static get PERIOD_TODAY(){return"D"}static get PERIOD_CURRENT_WEEK(){return"W"}static get PERIOD_CURRENT_MONTH(){return"M"}static get PERIOD_CURRENT_YEAR(){return"Y"}static get PERIOD_ALL_TIME(){return"A"}static get PERIODS(){return[NGIO.PERIOD_TODAY,NGIO.PERIOD_CURRENT_WEEK,NGIO.PERIOD_CURRENT_MONTH,NGIO.PERIOD_CURRENT_YEAR,NGIO.PERIOD_ALL_TIME]}static get ngioCore(){return this.#b}static #b=null;static get medalScore(){return this.#c}static #c=-1;static get medals(){return this.#d}static #d=null;static get scoreBoards(){return this.#e}static #e=null;static get saveSlots(){return this.#f}static #f=null;static get lastExecution(){return this.#g}static #g=new Date;static get lastConnectionStatus(){return this.#a}static #a=new Date;static get sessionError(){return this.#h}static #h=null;static get legalHost(){return this.#i}static #i=!0;static get isDeprecated(){return this.#j}static #j=!0;static get newestVersion(){return this.#k}static #k=!0;static get loginPageOpen(){return this.#l}static #l=!1;static get gatewayVersion(){return this.#m}static #m=!0;static get lastMedalUnlocked(){return this.#n}static #n=!0;static get lastBoardPosted(){return this.#o}static #o=!0;static get lastScorePosted(){return this.#p}static #p=!0;static get lastGetScoresResult(){return this.#q}static #q=!0;static get lastSaveSlotLoaded(){return this.#r}static #r=!0;static get lastSaveSlotSaved(){return this.#s}static #s=!0;static get lastDateTime(){return this.#t}static #t="0000-00-00";static get lastLoggedEvent(){return this.#u}static #u=null;static get lastTimeStamp(){return this.#v}static #v=0;static get lastPingSuccess(){return this.#w}static #w=!0;static get isInitialized(){return null!==this.ngioCore}static get session(){return this.isInitialized?this.ngioCore.session:null}static get user(){return null===this.session?null:this.ngioCore.session.user}static get hasSession(){return null!==this.session}static get hasUser(){return null!==this.user}static get isReady(){return this.#a===this.STATUS_READY}static get version(){return this.#x}static #x="0.0.0";static get debugMode(){return this.#y}static #y=!1;static #z={autoLogNewView:!1,preloadMedals:!1,preloadScoreBoards:!1,preloadSaveSlots:!1};static #A=!1;static #B=!1;static #C=!1;static #D=!1;static init(e,t,s){if(!this.isInitialized){if(this.#b=new NewgroundsIO.Core(e,t),this.#b.addEventListener("serverResponse",function(e){NGIO.#E(e)}),s&&"object"==typeof s){"string"==typeof s.version&&(this.#x=s.version);let o=["debugMode","checkHostLicense","autoLogNewView","preloadMedals","preloadScoreBoards","preloadSaveSlots"];for(let r=0;r{t.hasData&&e++}),e}static getSaveSlotData(e,t,s){null===this.saveSlots&&(console.error("getSaveSlotData data called without any preloaded save slots."),s?t.call(s,null):t(null));let o=this.getSaveSlot(e);this.#r=o,o.getData(t,s)}static setSaveSlotData(e,t,s,o){if(null==this.saveSlots){console.error("setSaveSlotData data called without any preloaded save slots."),"function"==typeof s&&(o?s(o,null):s(null));return}var r=this.getSaveSlot(e);if(null==r){console.error("Slot #"+e+" does not exist."),"function"==typeof s&&(o?s(o,null):s(null));return}r.setData(t,function(){"function"==typeof s&&(o?s(o,this.lastSaveSlotSaved):s(this.lastSaveSlotSaved))},this)}static logEvent(e,t,s){this.ngioCore.executeComponent(this.ngioCore.getComponent("Event.logEvent",{event_name:e}),function(){"function"==typeof t&&(s?t(s,this.lastLoggedEvent):t(this.lastLoggedEvent))},this)}static getDateTime(e,t){this.ngioCore.executeComponent(this.ngioCore.getComponent("Gateway.getDatetime"),function(){"function"==typeof e&&(t?e(t,this.lastDateTime,this.lastTimeStamp):e(this.lastDateTime,this.lastTimeStamp))},this)}static keepSessionAlive(){if(this.hasUser)(new Date-this.#g).Seconds>=3e4&&(this.#g=new Date,this.ngioCore.executeComponent(this.ngioCore.getComponent("Gateway.ping")))}static getConnectionStatus(e,t){this.#D||null===this.#a||null==this.session||(this.#D=!0,this.#a===this.STATUS_INITIALIZED?(this.#a=this.STATUS_CHECKING_LOCAL_VERSION,this.#G(e,t),this.#H(e,t)):this.#A?this.#a===this.STATUS_LOGIN_SUCCESSFUL?(this.#a=this.STATUS_PRELOADING_ITEMS,this.#G(e,t),this.#I(function(){this.#G(e,t),this.#B=!1},this)):this.#a===this.STATUS_ITEMS_PRELOADED?(this.#l=!1,this.#a=this.STATUS_READY,this.#G(e,t),this.#B=!1):this.keepSessionAlive():this.#B?this.#J(e,t):this.#a!==this.STATUS_CHECKING_LOCAL_VERSION&&this.session.update(function(){this.#J(e,t)},this),this.#D=!1)}static #J(e,t){(this.session.statusChanged||this.#B)&&(this.#a=this.session.status,(this.session.status==NewgroundsIO.SessionState.LOGIN_SUCCESSFUL||this.#B)&&(this.#a=NewgroundsIO.SessionState.LOGIN_SUCCESSFUL,this.#A=!0),this.#G(e,t)),this.#B=!1}static #G(s,o){o?s.call(o,this.#a):s(this.#a)}static #H(r,i){if(this.#C){this.#a=this.STATUS_LOCAL_VERSION_CHECKED,this.#G(r,i);return}this.ngioCore.queueComponent(this.ngioCore.getComponent("App.getCurrentVersion",{version:this.#x})),this.ngioCore.queueComponent(this.ngioCore.getComponent("Gateway.getVersion")),this.#z.autoLogNewView&&this.ngioCore.queueComponent(this.ngioCore.getComponent("App.logView")),this.#z.checkHostLicense&&this.ngioCore.queueComponent(this.ngioCore.getComponent("App.getHostLicense")),this.ngioCore.executeQueue(function(){this.#a=this.STATUS_LOCAL_VERSION_CHECKED,this.#C=!0,this.#G(r,i),this.#j&&console.warn("NGIO - Version mistmatch! Published version is: "+this.#k+", this version is: "+this.version),this.#i||(console.warn("NGIO - This host has been blocked fom hosting this game!"),this.#A=!0,this.#a=this.STATUS_ITEMS_PRELOADED,this.#G(r,i))},this)}static #I(){this.#z.preloadMedals&&(this.ngioCore.queueComponent(this.ngioCore.getComponent("Medal.getMedalScore")),this.ngioCore.queueComponent(this.ngioCore.getComponent("Medal.getList"))),this.#z.preloadScoreBoards&&this.ngioCore.queueComponent(this.ngioCore.getComponent("ScoreBoard.getBoards")),null!==this.user&&this.#z.preloadSaveSlots&&this.ngioCore.queueComponent(this.ngioCore.getComponent("CloudSave.loadSlots")),this.ngioCore.hasQueue?this.ngioCore.executeQueue(function(){this.#a=this.STATUS_ITEMS_PRELOADED},this):this.#a=this.STATUS_ITEMS_PRELOADED}static #F(){this.#a=this.STATUS_INITIALIZED,this.#l=!1,this.#B=!1,this.#A=!1}static #K(n){if(this.#f){let a=this.#f.length;for(let u=0;u>>2]|=(s[r>>>2]>>>24-8*(r%4)&255)<<24-8*((o+r)%4);else if(65535>>2]=s[r>>>2];else t.push.apply(t,s);return this.sigBytes+=e,this},clamp:function(){var t=this.words,s=this.sigBytes;t[s>>>2]&=4294967295<<32-8*(s%4),t.length=e.ceil(s/4)},clone:function(){var e=i.clone.call(this);return e.words=this.words.slice(0),e},random:function(t){for(var s=[],o=0;o>>2]>>>24-8*(o%4)&255;s.push((r>>>4).toString(16)),s.push((15&r).toString(16))}return s.join("")},parse:function(e){for(var t=e.length,s=[],o=0;o>>3]|=parseInt(e.substr(o,2),16)<<24-4*(o%8);return new n.init(s,t/2)}},l=a.Latin1={stringify:function(e){var t=e.words;e=e.sigBytes;for(var s=[],o=0;o>>2]>>>24-8*(o%4)&255));return s.join("")},parse:function(e){for(var t=e.length,s=[],o=0;o>>2]|=(255&e.charCodeAt(o))<<24-8*(o%4);return new n.init(s,t)}},p=a.Utf8={stringify:function(e){try{return decodeURIComponent(escape(l.stringify(e)))}catch(t){throw Error("Malformed UTF-8 data")}},parse:function(e){return l.parse(unescape(encodeURIComponent(e)))}},c=o.BufferedBlockAlgorithm=i.extend({reset:function(){this._data=new n.init,this._nDataBytes=0},_append:function(e){"string"==typeof e&&(e=p.parse(e)),this._data.concat(e),this._nDataBytes+=e.sigBytes},_process:function(t){var s=this._data,o=s.words,r=s.sigBytes,i=this.blockSize,a=r/(4*i),a=t?e.ceil(a):e.max((0|a)-this._minBufferSize,0);if(t=a*i,r=e.min(4*t,r),t){for(var u=0;u>>2]>>>24-8*(r%4)&255)<<16|(t[r+1>>>2]>>>24-8*((r+1)%4)&255)<<8|t[r+2>>>2]>>>24-8*((r+2)%4)&255,n=0;4>n&&r+.75*n>>6*(3-n)&63));if(t=o.charAt(64))for(;e.length%4;)e.push(t);return e.join("")},parse:function(e){var s=e.length,o=this._map,r=o.charAt(64);r&&-1!=(r=e.indexOf(r))&&(s=r);for(var r=[],i=0,n=0;n>>6-2*(n%4);r[i>>>2]|=(a|u)<<24-8*(i%4),i++}return t.create(r,i)},_map:"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/="}}(),function(e){function t(e,t,s,o,r,i,n){return((e=e+(t&s|~t&o)+r+n)<>>32-i)+t}function s(e,t,s,o,r,i,n){return((e=e+(t&o|s&~o)+r+n)<>>32-i)+t}function o(e,t,s,o,r,i,n){return((e=e+(t^s^o)+r+n)<>>32-i)+t}function r(e,t,s,o,r,i,n){return((e=e+(s^(t|~o))+r+n)<>>32-i)+t}for(var i=CryptoJS,n=i.lib,a=n.WordArray,u=n.Hasher,n=i.algo,l=[],p=0;64>p;p++)l[p]=4294967296*e.abs(e.sin(p+1))|0;n=n.MD5=u.extend({_doReset:function(){this._hash=new a.init([1732584193,4023233417,2562383102,271733878])},_doProcessBlock:function(e,i){for(var n=0;16>n;n++){var a=i+n,u=e[a];e[a]=(u<<8|u>>>24)&16711935|(u<<24|u>>>8)&4278255360}var n=this._hash.words,a=e[i+0],u=e[i+1],p=e[i+2],c=e[i+3],h=e[i+4],d=e[i+5],g=e[i+6],f=e[i+7],w=e[i+8],O=e[i+9],I=e[i+10],m=e[i+11],S=e[i+12],N=e[i+13],b=e[i+14],y=e[i+15],v=n[0],$=n[1],C=n[2],E=n[3],v=t(v,$,C,E,a,7,l[0]),E=t(E,v,$,C,u,12,l[1]),C=t(C,E,v,$,p,17,l[2]),$=t($,C,E,v,c,22,l[3]),v=t(v,$,C,E,h,7,l[4]),E=t(E,v,$,C,d,12,l[5]),C=t(C,E,v,$,g,17,l[6]),$=t($,C,E,v,f,22,l[7]),v=t(v,$,C,E,w,7,l[8]),E=t(E,v,$,C,O,12,l[9]),C=t(C,E,v,$,I,17,l[10]),$=t($,C,E,v,m,22,l[11]),v=t(v,$,C,E,S,7,l[12]),E=t(E,v,$,C,N,12,l[13]),C=t(C,E,v,$,b,17,l[14]),$=t($,C,E,v,y,22,l[15]),v=s(v,$,C,E,u,5,l[16]),E=s(E,v,$,C,g,9,l[17]),C=s(C,E,v,$,m,14,l[18]),$=s($,C,E,v,a,20,l[19]),v=s(v,$,C,E,d,5,l[20]),E=s(E,v,$,C,I,9,l[21]),C=s(C,E,v,$,y,14,l[22]),$=s($,C,E,v,h,20,l[23]),v=s(v,$,C,E,O,5,l[24]),E=s(E,v,$,C,b,9,l[25]),C=s(C,E,v,$,c,14,l[26]),$=s($,C,E,v,w,20,l[27]),v=s(v,$,C,E,N,5,l[28]),E=s(E,v,$,C,p,9,l[29]),C=s(C,E,v,$,f,14,l[30]),$=s($,C,E,v,S,20,l[31]),v=o(v,$,C,E,d,4,l[32]),E=o(E,v,$,C,w,11,l[33]),C=o(C,E,v,$,m,16,l[34]),$=o($,C,E,v,b,23,l[35]),v=o(v,$,C,E,u,4,l[36]),E=o(E,v,$,C,h,11,l[37]),C=o(C,E,v,$,f,16,l[38]),$=o($,C,E,v,I,23,l[39]),v=o(v,$,C,E,N,4,l[40]),E=o(E,v,$,C,a,11,l[41]),C=o(C,E,v,$,c,16,l[42]),$=o($,C,E,v,g,23,l[43]),v=o(v,$,C,E,O,4,l[44]),E=o(E,v,$,C,S,11,l[45]),C=o(C,E,v,$,y,16,l[46]),$=o($,C,E,v,p,23,l[47]),v=r(v,$,C,E,a,6,l[48]),E=r(E,v,$,C,f,10,l[49]),C=r(C,E,v,$,b,15,l[50]),$=r($,C,E,v,d,21,l[51]),v=r(v,$,C,E,S,6,l[52]),E=r(E,v,$,C,c,10,l[53]),C=r(C,E,v,$,I,15,l[54]),$=r($,C,E,v,u,21,l[55]),v=r(v,$,C,E,w,6,l[56]),E=r(E,v,$,C,y,10,l[57]),C=r(C,E,v,$,g,15,l[58]),$=r($,C,E,v,N,21,l[59]),v=r(v,$,C,E,h,6,l[60]),E=r(E,v,$,C,m,10,l[61]),C=r(C,E,v,$,p,15,l[62]),$=r($,C,E,v,O,21,l[63]);n[0]=n[0]+v|0,n[1]=n[1]+$|0,n[2]=n[2]+C|0,n[3]=n[3]+E|0},_doFinalize:function(){var t=this._data,s=t.words,o=8*this._nDataBytes,r=8*t.sigBytes;s[r>>>5]|=128<<24-r%32;var i=e.floor(o/4294967296);for(s[(r+64>>>9<<4)+15]=(i<<8|i>>>24)&16711935|(i<<24|i>>>8)&4278255360,s[(r+64>>>9<<4)+14]=(o<<8|o>>>24)&16711935|(o<<24|o>>>8)&4278255360,t.sigBytes=4*(s.length+1),this._process(),s=(t=this._hash).words,o=0;4>o;o++)r=s[o],s[o]=(r<<8|r>>>24)&16711935|(r<<24|r>>>8)&4278255360;return t},clone:function(){var e=u.clone.call(this);return e._hash=this._hash.clone(),e}}),i.MD5=u._createHelper(n),i.HmacMD5=u._createHmacHelper(n)}(Math),function(){var e=CryptoJS,t=e.lib,s=t.Base,o=t.WordArray,t=e.algo,r=t.EvpKDF=s.extend({cfg:s.extend({keySize:4,hasher:t.MD5,iterations:1}),init:function(e){this.cfg=this.cfg.extend(e)},compute:function(e,t){for(var s=this.cfg,r=s.hasher.create(),i=o.create(),n=i.words,a=s.keySize,s=s.iterations;n.length>>2]}},s.BlockCipher=u.extend({cfg:u.cfg.extend({mode:l,padding:c}),reset:function(){u.reset.call(this);var e=this.cfg,t=e.iv,e=e.mode;if(this._xformMode==this._ENC_XFORM_MODE)var s=e.createEncryptor;else s=e.createDecryptor,this._minBufferSize=1;this._mode=s.call(e,this,t&&t.words)},_doProcessBlock:function(e,t){this._mode.processBlock(e,t)},_doFinalize:function(){var e=this.cfg.padding;if(this._xformMode==this._ENC_XFORM_MODE){e.pad(this._data,this.blockSize);var t=this._process(!0)}else t=this._process(!0),e.unpad(t);return t},blockSize:4});var h=s.CipherParams=o.extend({init:function(e){this.mixIn(e)},toString:function(e){return(e||this.formatter).stringify(this)}}),l=(t.format={}).OpenSSL={stringify:function(e){var t=e.ciphertext;return((e=e.salt)?r.create([1398893684,1701076831]).concat(e).concat(t):t).toString(n)},parse:function(e){var t=(e=n.parse(e)).words;if(1398893684==t[0]&&1701076831==t[1]){var s=r.create(t.slice(2,4));t.splice(0,4),e.sigBytes-=16}return h.create({ciphertext:e,salt:s})}},d=s.SerializableCipher=o.extend({cfg:o.extend({format:l}),encrypt:function(e,t,s,o){o=this.cfg.extend(o);var r=e.createEncryptor(s,o);return t=r.finalize(t),r=r.cfg,h.create({ciphertext:t,key:s,iv:r.iv,algorithm:e,mode:r.mode,padding:r.padding,blockSize:e.blockSize,formatter:o.format})},decrypt:function(e,t,s,o){return o=this.cfg.extend(o),t=this._parse(t,o.format),e.createDecryptor(s,o).finalize(t.ciphertext)},_parse:function(e,t){return"string"==typeof e?t.parse(e,this):e}}),t=(t.kdf={}).OpenSSL={execute:function(e,t,s,o){return o||(o=r.random(8)),e=a.create({keySize:t+s}).compute(e,o),s=r.create(e.words.slice(t),4*s),e.sigBytes=4*t,h.create({key:e,iv:s,salt:o})}},g=s.PasswordBasedCipher=d.extend({cfg:d.cfg.extend({kdf:t}),encrypt:function(e,t,s,o){return s=(o=this.cfg.extend(o)).kdf.execute(s,e.keySize,e.ivSize),o.iv=s.iv,(e=d.encrypt.call(this,e,t,s.key,o)).mixIn(s),e},decrypt:function(e,t,s,o){return o=this.cfg.extend(o),t=this._parse(t,o.format),s=o.kdf.execute(s,e.keySize,e.ivSize,t.salt),o.iv=s.iv,d.decrypt.call(this,e,t,s.key,o)}})}(),function(){for(var e=CryptoJS,t=e.lib.BlockCipher,s=e.algo,o=[],r=[],i=[],n=[],a=[],u=[],l=[],p=[],c=[],h=[],d=[],g=0;256>g;g++)d[g]=128>g?g<<1:g<<1^283;for(var f=0,w=0,g=0;256>g;g++){var O=w^w<<1^w<<2^w<<3^w<<4,O=O>>>8^255&O^99;o[f]=O,r[O]=f;var I=d[f],m=d[I],S=d[m],N=257*d[O]^16843008*O;i[f]=N<<24|N>>>8,n[f]=N<<16|N>>>16,a[f]=N<<8|N>>>24,u[f]=N,N=16843009*S^65537*m^257*I^16843008*f,l[O]=N<<24|N>>>8,p[O]=N<<16|N>>>16,c[O]=N<<8|N>>>24,h[O]=N,f?(f=I^d[d[d[S^I]]],w^=d[d[w]]):f=w=1}var b=[0,1,2,4,8,16,32,64,128,27,54],s=s.AES=t.extend({_doReset:function(){for(var e=this._key,t=e.words,s=e.sigBytes/4,e=4*((this._nRounds=s+6)+1),r=this._keySchedule=[],i=0;i>>24]<<24|o[n>>>16&255]<<16|o[n>>>8&255]<<8|o[255&n]):(n=o[(n=n<<8|n>>>24)>>>24]<<24|o[n>>>16&255]<<16|o[n>>>8&255]<<8|o[255&n],n^=b[i/s|0]<<24),r[i]=r[i-s]^n}for(s=0,t=this._invKeySchedule=[];ss||4>=i?n:l[o[n>>>24]]^p[o[n>>>16&255]]^c[o[n>>>8&255]]^h[o[255&n]]},encryptBlock:function(e,t){this._doCryptBlock(e,t,this._keySchedule,i,n,a,u,o)},decryptBlock:function(e,t){var s=e[t+1];e[t+1]=e[t+3],e[t+3]=s,this._doCryptBlock(e,t,this._invKeySchedule,l,p,c,h,r),s=e[t+1],e[t+1]=e[t+3],e[t+3]=s},_doCryptBlock:function(e,t,s,o,r,i,n,a){for(var u=this._nRounds,l=e[t]^s[0],p=e[t+1]^s[1],c=e[t+2]^s[2],h=e[t+3]^s[3],d=4,g=1;g>>24]^r[p>>>16&255]^i[c>>>8&255]^n[255&h]^s[d++],w=o[p>>>24]^r[c>>>16&255]^i[h>>>8&255]^n[255&l]^s[d++],O=o[c>>>24]^r[h>>>16&255]^i[l>>>8&255]^n[255&p]^s[d++],h=o[h>>>24]^r[l>>>16&255]^i[p>>>8&255]^n[255&c]^s[d++],l=f,p=w,c=O;f=(a[l>>>24]<<24|a[p>>>16&255]<<16|a[c>>>8&255]<<8|a[255&h])^s[d++],w=(a[p>>>24]<<24|a[c>>>16&255]<<16|a[h>>>8&255]<<8|a[255&l])^s[d++],O=(a[c>>>24]<<24|a[h>>>16&255]<<16|a[l>>>8&255]<<8|a[255&p])^s[d++],h=(a[h>>>24]<<24|a[l>>>16&255]<<16|a[p>>>8&255]<<8|a[255&c])^s[d++],e[t]=f,e[t+1]=w,e[t+2]=O,e[t+3]=h},keySize:8});e.AES=t._createHelper(s)}();var NewgroundsIO=NewgroundsIO||{};NewgroundsIO.objects=NewgroundsIO.objects?NewgroundsIO.objects:{},NewgroundsIO.results=NewgroundsIO.results?NewgroundsIO.results:{},NewgroundsIO.components=NewgroundsIO.components?NewgroundsIO.components:{},(()=>{class e extends EventTarget{#O="https://www.newgrounds.io/gateway_v3.php";#P=!1;#Q=null;#R=null;#S=[];#T=null;#U=null;#V={};get GATEWAY_URI(){return this.#O}get debug(){return this.#P}set debug(e){this.#P=!!e}get appID(){return this.#Q}get componentQueue(){return this.#S}get hasQueue(){return this.#S.length>0}get host(){return this.#T}get session(){return this.#U}get user(){return this.#U?this.#U.user:null}get uriParams(){return this.#V}constructor(e,t){if(super(),void 0===e)throw"Missing required appID!";if(void 0===t)throw"Missing required aesKey!";if(this.#Q=e,this.#R=CryptoJS.enc.Base64.parse(t),this.#S=[],this.#V={},window&&window.location&&window.location.href?window.location.hostname?this.#T=window.location.hostname.toLowerCase():"file:"==window.location.href.toLowerCase().substr(0,5)?this.#T="":this.#T="":this.#T="","undefined"!=typeof window&&window.location){var s,o=window.location.href.split("?").pop();if(o)for(var r,i=o.split("&"),n=0;n{t instanceof NewgroundsIO.BaseComponent||(r._verifyComponent(e)||(o=!1),t.setCore(r))}),!o)return}else{if(!this._verifyComponent(e))return;e.setCore(this)}let i=this,n=this._getRequest(e);new NewgroundsIO.objects.Response;var a=new XMLHttpRequest;a.onreadystatechange=function(){if(4==a.readyState){var e;try{e=JSON.parse(a.responseText)}catch(o){(e={success:!1,app_id:i.app_id}).error={message:String(o),code:8002}}let r=i._populateResponse(e);i.dispatchEvent(new CustomEvent("serverResponse",{detail:r})),t&&(s?t.call(s,r):t(r))}};var u=void 0!==Array.prototype.toJSON?Array.prototype.toJSON:null;u&&delete Array.prototype.toJSON;let l=new FormData;l.append("request",JSON.stringify(n)),u&&(Array.prototype.toJSON=u),a.open("POST",this.GATEWAY_URI,!0),a.send(l)}loadComponent(e){if(!this._verifyComponent(e))return;e.setCore(this);let t=this._getRequest(e),s=this.GATEWAY_URI+"?request="+encodeURIComponent(JSON.stringify(t));window.open(s,"_blank")}onServerResponse(e){}_populateResponse(e){if(e.success){if(Array.isArray(e.result))for(let t=0;t{let o=s._getExecute(e);t.push(o)})):t=this._getExecute(e);let o=new NewgroundsIO.objects.Request({execute:t});return this.debug&&(o.debug=!0),o.setCore(this),o}_verifyComponent(e){return e instanceof NewgroundsIO.BaseComponent?!!e.isValid():(console.error("NewgroundsIO Type Mismatch: Expecting a NewgroundsIO.components.XXXX instance, got",e),!1)}}NewgroundsIO.Core=e})(),(()=>{class e{get type(){return this.__type}__type="object";__object="BaseObject";__properties=[];__required=[];__ngioCore=null;isValid(){if(0===this.__required.length)return!0;let e=!0;return this.__required.forEach(function(t){null===this[t]?(console.error("NewgroundsIO Error: "+this.__object+" "+this.__type+" is invalid, missing value for '"+t+"'"),e=!1):this[t]instanceof NewgroundsIO.BaseObject&&!this[t].isValid()&&(e=!1)},this),e}setCore(e){this._doSetCore(e,[])}objectMap={};arrayMap={};fromJSON(e,t){var s,o,r={};for(this.setCore(t),s=0;s{s instanceof NewgroundsIO.BaseObject&&-1===t.indexOf(s)&&s._doSetCore(e,t)},this),"host"!==s||this.host||(this.host=e.host)},this)):console.error("NewgroundsIO Error: Expecting NewgroundsIO.Core instance, got",e)}toJSON(){return this.__doToJSON()}__doToJSON(){if(void 0===this.__properties)return{};let e={};return this.__properties.forEach(function(t){null!==this[t]&&(e[t]="function"==typeof this[t].toJSON?this[t].toJSON():this[t])},this),e}toSecureJSON(){return this.__ngioCore&&this.__ngioCore instanceof NewgroundsIO.Core?{secure:this.__ngioCore.encrypt(JSON.stringify(this.__doToJSON()))}:(console.error("NewgroundsIO Error: Unable to create secure JSON object without calling setCore() first."),this.__doToJSON())}toString(){return this.__type}clone(e){return void 0===e&&(e=new this.constructor),this.__properties.forEach(t=>{e[t]=this[t]}),e.__ngioCore=this.__ngioCore,e}}NewgroundsIO.BaseObject=e;class t extends e{constructor(){super(),this.__type="component",this.__object="BaseComponent",this.__properties=["host","echo"],this._echo=null}get host(){return this.__ngioCore?this.__ngioCore.host:null}get echo(){return this._echo}set echo(e){this.echo=""+e}}NewgroundsIO.BaseComponent=t;class s extends e{constructor(){super(),this.__type="result",this.__object="BaseResult",this.__properties=["echo","error","success"],this._echo=null,this._error=null,this._success=null}get component(){return this.__object}get echo(){return this._echo}get error(){return this._error}set error(e){this._error=e}get success(){return!!this._success}set success(e){this._success=!!e}}NewgroundsIO.BaseResult=s})(),NewgroundsIO.SessionState={SESSION_UNINITIALIZED:"session-uninitialized",WAITING_FOR_SERVER:"waiting-for-server",LOGIN_REQUIRED:"login-required",WAITING_FOR_USER:"waiting-for-user",LOGIN_CANCELLED:"login-cancelled",LOGIN_SUCCESSFUL:"login-successful",LOGIN_FAILED:"login-failed",USER_LOGGED_OUT:"user-logged-out",SERVER_UNAVAILABLE:"server-unavailable",EXCEEDED_MAX_ATTEMPTS:"exceeded-max-attempts"},NewgroundsIO.SessionState.SESSION_WAITING=[NewgroundsIO.SessionState.SESSION_UNINITIALIZED,NewgroundsIO.SessionState.WAITING_FOR_SERVER,NewgroundsIO.SessionState.WAITING_FOR_USER,NewgroundsIO.SessionState.LOGIN_CANCELLED,NewgroundsIO.SessionStateLOGIN_FAILED],(()=>{class e extends NewgroundsIO.BaseComponent{constructor(){super(),this.__object="App.checkSession",this.__requireSession=!0}}void 0===NewgroundsIO.components.App&&(NewgroundsIO.components.App={}),NewgroundsIO.components.App.checkSession=e})(),(()=>{class e extends NewgroundsIO.BaseComponent{constructor(){super(),this.__object="App.endSession",this.__requireSession=!0}}void 0===NewgroundsIO.components.App&&(NewgroundsIO.components.App={}),NewgroundsIO.components.App.endSession=e})(),(()=>{class e extends NewgroundsIO.BaseComponent{constructor(e){super();let t=this;if(this.__object="App.getCurrentVersion",["version"].forEach(e=>{0>t.__properties.indexOf(e)&&t.__properties.push(e)}),e&&"object"==typeof e)for(var s=0;s{class e extends NewgroundsIO.BaseComponent{constructor(e){super();let t=this;if(this.__object="App.getHostLicense",["host"].forEach(e=>{0>t.__properties.indexOf(e)&&t.__properties.push(e)}),e&&"object"==typeof e)for(var s=0;s{class e extends NewgroundsIO.BaseComponent{constructor(e){super();let t=this;if(this.__object="App.logView",["host"].forEach(e=>{0>t.__properties.indexOf(e)&&t.__properties.push(e)}),e&&"object"==typeof e)for(var s=0;s{class e extends NewgroundsIO.BaseComponent{constructor(e){super();let t=this;if(this.__object="App.startSession",["force"].forEach(e=>{0>t.__properties.indexOf(e)&&t.__properties.push(e)}),e&&"object"==typeof e)for(var s=0;s{class e extends NewgroundsIO.BaseComponent{constructor(e){super();let t=this;if(this.__object="CloudSave.clearSlot",this.__requireSession=!0,["id"].forEach(e=>{0>t.__properties.indexOf(e)&&t.__properties.push(e)}),e&&"object"==typeof e)for(var s=0;s{class e extends NewgroundsIO.BaseComponent{constructor(e){super();let t=this;if(this.__object="CloudSave.loadSlot",this.__requireSession=!0,["id","app_id"].forEach(e=>{0>t.__properties.indexOf(e)&&t.__properties.push(e)}),e&&"object"==typeof e)for(var s=0;s{class e extends NewgroundsIO.BaseComponent{constructor(e){super();let t=this;if(this.__object="CloudSave.loadSlots",this.__requireSession=!0,["app_id"].forEach(e=>{0>t.__properties.indexOf(e)&&t.__properties.push(e)}),e&&"object"==typeof e)for(var s=0;s{class e extends NewgroundsIO.BaseComponent{constructor(e){super();let t=this;if(this.__object="CloudSave.setData",this.__requireSession=!0,["id","data"].forEach(e=>{0>t.__properties.indexOf(e)&&t.__properties.push(e)}),e&&"object"==typeof e)for(var s=0;s{class e extends NewgroundsIO.BaseComponent{constructor(e){super();let t=this;if(this.__object="Event.logEvent",["host","event_name"].forEach(e=>{0>t.__properties.indexOf(e)&&t.__properties.push(e)}),e&&"object"==typeof e)for(var s=0;s{class e extends NewgroundsIO.BaseComponent{constructor(){super(),this.__object="Gateway.getDatetime"}}void 0===NewgroundsIO.components.Gateway&&(NewgroundsIO.components.Gateway={}),NewgroundsIO.components.Gateway.getDatetime=e})(),(()=>{class e extends NewgroundsIO.BaseComponent{constructor(){super(),this.__object="Gateway.getVersion"}}void 0===NewgroundsIO.components.Gateway&&(NewgroundsIO.components.Gateway={}),NewgroundsIO.components.Gateway.getVersion=e})(),(()=>{class e extends NewgroundsIO.BaseComponent{constructor(){super(),this.__object="Gateway.ping"}}void 0===NewgroundsIO.components.Gateway&&(NewgroundsIO.components.Gateway={}),NewgroundsIO.components.Gateway.ping=e})(),(()=>{class e extends NewgroundsIO.BaseComponent{constructor(e){super();let t=this;if(this.__object="Loader.loadAuthorUrl",["host","redirect","log_stat"].forEach(e=>{0>t.__properties.indexOf(e)&&t.__properties.push(e)}),e&&"object"==typeof e)for(var s=0;s{class e extends NewgroundsIO.BaseComponent{constructor(e){super();let t=this;if(this.__object="Loader.loadMoreGames",["host","redirect","log_stat"].forEach(e=>{0>t.__properties.indexOf(e)&&t.__properties.push(e)}),e&&"object"==typeof e)for(var s=0;s{class e extends NewgroundsIO.BaseComponent{constructor(e){super();let t=this;if(this.__object="Loader.loadNewgrounds",["host","redirect","log_stat"].forEach(e=>{0>t.__properties.indexOf(e)&&t.__properties.push(e)}),e&&"object"==typeof e)for(var s=0;s{class e extends NewgroundsIO.BaseComponent{constructor(e){super();let t=this;if(this.__object="Loader.loadOfficialUrl",["host","redirect","log_stat"].forEach(e=>{0>t.__properties.indexOf(e)&&t.__properties.push(e)}),e&&"object"==typeof e)for(var s=0;s{class e extends NewgroundsIO.BaseComponent{constructor(e){super();let t=this;if(this.__object="Loader.loadReferral",["host","referral_name","redirect","log_stat"].forEach(e=>{0>t.__properties.indexOf(e)&&t.__properties.push(e)}),e&&"object"==typeof e)for(var s=0;s{class e extends NewgroundsIO.BaseComponent{constructor(e){super();let t=this;if(this.__object="Medal.getList",["app_id"].forEach(e=>{0>t.__properties.indexOf(e)&&t.__properties.push(e)}),e&&"object"==typeof e)for(var s=0;s{class e extends NewgroundsIO.BaseComponent{constructor(){super(),this.__object="Medal.getMedalScore",this.__requireSession=!0}}void 0===NewgroundsIO.components.Medal&&(NewgroundsIO.components.Medal={}),NewgroundsIO.components.Medal.getMedalScore=e})(),(()=>{class e extends NewgroundsIO.BaseComponent{constructor(e){super();let t=this;if(this.__object="Medal.unlock",this.__isSecure=!0,this.__requireSession=!0,["id"].forEach(e=>{0>t.__properties.indexOf(e)&&t.__properties.push(e)}),e&&"object"==typeof e)for(var s=0;s{class e extends NewgroundsIO.BaseComponent{constructor(){super(),this.__object="ScoreBoard.getBoards"}}void 0===NewgroundsIO.components.ScoreBoard&&(NewgroundsIO.components.ScoreBoard={}),NewgroundsIO.components.ScoreBoard.getBoards=e})(),(()=>{class e extends NewgroundsIO.BaseComponent{constructor(e){super();let t=this;if(this.__object="ScoreBoard.getScores",["id","period","tag","social","user","skip","limit","app_id"].forEach(e=>{0>t.__properties.indexOf(e)&&t.__properties.push(e)}),e&&"object"==typeof e)for(var s=0;s{class e extends NewgroundsIO.BaseComponent{constructor(e){super();let t=this;if(this.__object="ScoreBoard.postScore",this.__isSecure=!0,this.__requireSession=!0,["id","value","tag"].forEach(e=>{0>t.__properties.indexOf(e)&&t.__properties.push(e)}),e&&"object"==typeof e)for(var s=0;s{class e extends NewgroundsIO.BaseObject{constructor(e){super();let t=this;if(this.__object="Debug",["exec_time","request"].forEach(e=>{0>t.__properties.indexOf(e)&&t.__properties.push(e)}),e&&"object"==typeof e)for(var s=0;s{class e extends NewgroundsIO.BaseObject{constructor(e){super();let t=this;if(this.__object="Error",["message","code"].forEach(e=>{0>t.__properties.indexOf(e)&&t.__properties.push(e)}),e&&"object"==typeof e)for(var s=0;s{class e extends NewgroundsIO.BaseObject{constructor(e){super();let t=this;if(this.__object="Execute",["component","parameters","secure"].forEach(e=>{0>t.__properties.indexOf(e)&&t.__properties.push(e)}),e&&"object"==typeof e)for(var s=0;s{class e extends NewgroundsIO.BaseObject{constructor(e){super();let t=this;if(this.__object="Medal",["id","name","description","icon","value","difficulty","secret","unlocked"].forEach(e=>{0>t.__properties.indexOf(e)&&t.__properties.push(e)}),e&&"object"==typeof e)for(var s=0;s{class e extends NewgroundsIO.BaseObject{constructor(e){super();let t=this;if(this.__object="Request",["app_id","execute","session_id","debug"].forEach(e=>{0>t.__properties.indexOf(e)&&t.__properties.push(e)}),e&&"object"==typeof e)for(var s=0;s{class e extends NewgroundsIO.BaseObject{constructor(e){super();let t=this;if(this.__object="Response",["app_id","success","debug","result","error","api_version","help_url"].forEach(e=>{0>t.__properties.indexOf(e)&&t.__properties.push(e)}),e&&"object"==typeof e)for(var s=0;s{class e extends NewgroundsIO.BaseObject{constructor(e){super();let t=this;if(this.__object="SaveSlot",["id","size","datetime","timestamp","url"].forEach(e=>{0>t.__properties.indexOf(e)&&t.__properties.push(e)}),e&&"object"==typeof e)for(var s=0;s{class e extends NewgroundsIO.BaseObject{constructor(e){super();let t=this;if(this.__object="Score",["user","value","formatted_value","tag"].forEach(e=>{0>t.__properties.indexOf(e)&&t.__properties.push(e)}),e&&"object"==typeof e)for(var s=0;s{class e extends NewgroundsIO.BaseObject{constructor(e){super();let t=this;if(this.__object="ScoreBoard",["id","name"].forEach(e=>{0>t.__properties.indexOf(e)&&t.__properties.push(e)}),e&&"object"==typeof e)for(var s=0;s{class e extends NewgroundsIO.BaseObject{constructor(e){super();let t=this;if(this.__object="Session",["id","user","expired","remember","passport_url"].forEach(e=>{0>t.__properties.indexOf(e)&&t.__properties.push(e)}),e&&"object"==typeof e)for(var s=0;s=this.#aS?this.#aL=NewgroundsIO.SessionState.EXCEEDED_MAX_ATTEMPTS:(this.#aL=NewgroundsIO.SessionState.SESSION_UNINITIALIZED,this.#aR++)),this.status==NewgroundsIO.SessionState.SESSION_UNINITIALIZED&&(this.#aU=localStorage.getItem(this.storageKey),this.#aT?this.id=this.#aT:this.#aU&&(this.id=this.#aU),this.mode=this.id&&"null"!==this.id?"check":"new");var s=new Date;if(!(s-this.#aO<5e3))switch(this.#aO=s,this.mode){case"new":this.mode="wait",this.startSession();break;case"check":this.mode="wait",this.checkSession()}}}startSession(){this.#aP=!1,this.resetSession(),this.#aL=NewgroundsIO.SessionState.WAITING_FOR_SERVER;var e=this.__ngioCore.getComponent("App.startSession");this.__ngioCore.executeComponent(e,this._onStartSession,this)}_onStartSession(e){if(!0===e.success){let t=e.result;if(Array.isArray(t)){for(let s=0;s{class e extends NewgroundsIO.BaseObject{constructor(e){super();let t=this;if(this.__object="User",["id","name","icons","supporter"].forEach(e=>{0>t.__properties.indexOf(e)&&t.__properties.push(e)}),e&&"object"==typeof e)for(var s=0;s{class e extends NewgroundsIO.BaseObject{constructor(e){super();let t=this;if(this.__object="UserIcons",["small","medium","large"].forEach(e=>{0>t.__properties.indexOf(e)&&t.__properties.push(e)}),e&&"object"==typeof e)for(var s=0;s{class e extends NewgroundsIO.BaseResult{constructor(e){super();let t=this;if(this.__object="App.checkSession",["session"].forEach(e=>{0>t.__properties.indexOf(e)&&t.__properties.push(e)}),e&&"object"==typeof e)for(var s=0;s{class e extends NewgroundsIO.BaseResult{constructor(e){super();let t=this;if(this.__object="App.getCurrentVersion",["current_version","client_deprecated"].forEach(e=>{0>t.__properties.indexOf(e)&&t.__properties.push(e)}),e&&"object"==typeof e)for(var s=0;s{class e extends NewgroundsIO.BaseResult{constructor(e){super();let t=this;if(this.__object="App.getHostLicense",["host_approved"].forEach(e=>{0>t.__properties.indexOf(e)&&t.__properties.push(e)}),e&&"object"==typeof e)for(var s=0;s{class e extends NewgroundsIO.BaseResult{constructor(e){super();let t=this;if(this.__object="App.startSession",["session"].forEach(e=>{0>t.__properties.indexOf(e)&&t.__properties.push(e)}),e&&"object"==typeof e)for(var s=0;s{class e extends NewgroundsIO.BaseResult{constructor(e){super();let t=this;if(this.__object="CloudSave.clearSlot",["slot"].forEach(e=>{0>t.__properties.indexOf(e)&&t.__properties.push(e)}),e&&"object"==typeof e)for(var s=0;s{class e extends NewgroundsIO.BaseResult{constructor(e){super();let t=this;if(this.__object="CloudSave.loadSlot",["slot","app_id"].forEach(e=>{0>t.__properties.indexOf(e)&&t.__properties.push(e)}),e&&"object"==typeof e)for(var s=0;s{class e extends NewgroundsIO.BaseResult{constructor(e){super();let t=this;if(this.__object="CloudSave.loadSlots",["slots","app_id"].forEach(e=>{0>t.__properties.indexOf(e)&&t.__properties.push(e)}),e&&"object"==typeof e)for(var s=0;s{class e extends NewgroundsIO.BaseResult{constructor(e){super();let t=this;if(this.__object="CloudSave.setData",["slot"].forEach(e=>{0>t.__properties.indexOf(e)&&t.__properties.push(e)}),e&&"object"==typeof e)for(var s=0;s{class e extends NewgroundsIO.BaseResult{constructor(e){super();let t=this;if(this.__object="Event.logEvent",["event_name"].forEach(e=>{0>t.__properties.indexOf(e)&&t.__properties.push(e)}),e&&"object"==typeof e)for(var s=0;s{class e extends NewgroundsIO.BaseResult{constructor(e){super();let t=this;if(this.__object="Gateway.getDatetime",["datetime","timestamp"].forEach(e=>{0>t.__properties.indexOf(e)&&t.__properties.push(e)}),e&&"object"==typeof e)for(var s=0;s{class e extends NewgroundsIO.BaseResult{constructor(e){super();let t=this;if(this.__object="Gateway.getVersion",["version"].forEach(e=>{0>t.__properties.indexOf(e)&&t.__properties.push(e)}),e&&"object"==typeof e)for(var s=0;s{class e extends NewgroundsIO.BaseResult{constructor(e){super();let t=this;if(this.__object="Gateway.ping",["pong"].forEach(e=>{0>t.__properties.indexOf(e)&&t.__properties.push(e)}),e&&"object"==typeof e)for(var s=0;s{class e extends NewgroundsIO.BaseResult{constructor(e){super();let t=this;if(this.__object="Loader.loadAuthorUrl",["url"].forEach(e=>{0>t.__properties.indexOf(e)&&t.__properties.push(e)}),e&&"object"==typeof e)for(var s=0;s{class e extends NewgroundsIO.BaseResult{constructor(e){super();let t=this;if(this.__object="Loader.loadMoreGames",["url"].forEach(e=>{0>t.__properties.indexOf(e)&&t.__properties.push(e)}),e&&"object"==typeof e)for(var s=0;s{class e extends NewgroundsIO.BaseResult{constructor(e){super();let t=this;if(this.__object="Loader.loadNewgrounds",["url"].forEach(e=>{0>t.__properties.indexOf(e)&&t.__properties.push(e)}),e&&"object"==typeof e)for(var s=0;s{class e extends NewgroundsIO.BaseResult{constructor(e){super();let t=this;if(this.__object="Loader.loadOfficialUrl",["url"].forEach(e=>{0>t.__properties.indexOf(e)&&t.__properties.push(e)}),e&&"object"==typeof e)for(var s=0;s{class e extends NewgroundsIO.BaseResult{constructor(e){super();let t=this;if(this.__object="Loader.loadReferral",["url"].forEach(e=>{0>t.__properties.indexOf(e)&&t.__properties.push(e)}),e&&"object"==typeof e)for(var s=0;s{class e extends NewgroundsIO.BaseResult{constructor(e){super();let t=this;if(this.__object="Medal.getList",["medals","app_id"].forEach(e=>{0>t.__properties.indexOf(e)&&t.__properties.push(e)}),e&&"object"==typeof e)for(var s=0;s{class e extends NewgroundsIO.BaseResult{constructor(e){super();let t=this;if(this.__object="Medal.getMedalScore",["medal_score"].forEach(e=>{0>t.__properties.indexOf(e)&&t.__properties.push(e)}),e&&"object"==typeof e)for(var s=0;s{class e extends NewgroundsIO.BaseResult{constructor(e){super();let t=this;if(this.__object="Medal.unlock",["medal","medal_score"].forEach(e=>{0>t.__properties.indexOf(e)&&t.__properties.push(e)}),e&&"object"==typeof e)for(var s=0;s{class e extends NewgroundsIO.BaseResult{constructor(e){super();let t=this;if(this.__object="ScoreBoard.getBoards",["scoreboards"].forEach(e=>{0>t.__properties.indexOf(e)&&t.__properties.push(e)}),e&&"object"==typeof e)for(var s=0;s{class e extends NewgroundsIO.BaseResult{constructor(e){super();let t=this;if(this.__object="ScoreBoard.getScores",["period","social","limit","scoreboard","scores","user","app_id"].forEach(e=>{0>t.__properties.indexOf(e)&&t.__properties.push(e)}),e&&"object"==typeof e)for(var s=0;s{class e extends NewgroundsIO.BaseResult{constructor(e){super();let t=this;if(this.__object="ScoreBoard.postScore",["scoreboard","score"].forEach(e=>{0>t.__properties.indexOf(e)&&t.__properties.push(e)}),e&&"object"==typeof e)for(var s=0;s