{"version":3,"sources":["jsdelivr-header.js","/npm/pokemongo-game-master@2.1.2/src/index.js"],"names":[],"mappings":"AAAA;AACA;AACA;AACA;AACA;AACA;AACA,ACNA,MAAM,QAAU,QAAQ,WAElB,UAAY,gGACZ,eAAiB,CAAC,WAAY,QAc9B,WAAa,CAAC,EAAS,KACzB,GAAU,GAAU,QAAQ,cACrB,IAAI,SAAQ,CAAC,EAAS,KAEpB,eAAe,SAAS,IACzB,EAAO,oBAAoB,eAAe,KAAK,qBAGnD,QAAQ,IAAI,GAAG,aAAa,oBAA0B,KAAU,CAAC,EAAO,EAAU,KAC9E,GAAsB,qBAAlB,EAAS,KAA6B,OAAO,EAAO,IAAI,MAAM,sCAClE,GAAI,EAAO,OAAO,EAAO,GAGzB,GAAe,SAAX,EACA,IACI,EAAQ,KAAK,MAAM,GACvB,CAAE,MAAO,GACL,EAAO,EACX,MAGA,EAAQ,EACZ,GACF,KAcJ,qBAAuB,IAClB,IAAI,SAAQ,CAAC,EAAS,KACzB,MAAM,EAAM,GAAG,+BACf,QAAQ,IAAI,GAAK,CAAC,EAAO,EAAU,IACT,qBAAlB,EAAS,KAAoC,EAAO,IAAI,MAAM,GAAG,kDACjE,EAAc,EAAO,QACzB,EAAQ,IACV,IAIV,OAAO,QAAU,CAAE,sBAAY","file":"/npm/pokemongo-game-master@2.1.2/src/index.js","sourceRoot":"","sourcesContent":["/**\n * Minified by jsDelivr using Terser v5.39.0.\n * Original file: /npm/pokemongo-game-master@2.1.2/src/index.js\n *\n * Do NOT use SRI with dynamically generated files! More information: https://www.jsdelivr.com/using-sri-with-dynamic-files\n */\n","const request = require('request');\n\nconst FETCH_URL = 'https://raw.githubusercontent.com/pokemongo-dev-contrib/pokemongo-game-master/master/versions';\nconst allowedFormats = ['protobuf', 'json'];\n\n/**\n * Returns the content of the request version\n * @param {String} version The version you want to request. Can be a specific version (e.g. '0.83.3') or latest version (e.g. 'latest')\n * @param {'json'|'protobuf'} format The format of the version. Can be either 'json' or 'protobuf'.\n * @returns {Object|String} Returns a object, if format 'json' is given, or a string\n * \n * @example\n * const gameMaster = require('pokemongo-game-master');\n * \n * gameMaster.getVersion('latest', 'json').then(console.log); // Returns as object: { itemTemplates: [ ... ], timestampMs: '1512514949791' }\n * gameMaster.getVersion('latest', 'protobuf').then(console.log); // Returns as string\n */\nconst getVersion = (version, format) => {\n    format = (format || 'json').toLowerCase();\n    return new Promise((resolve, reject) => {\n        // Validate Format\n        if (!allowedFormats.includes(format)) {\n            reject(`Only the format .${allowedFormats.join(' .')} are allowed`);\n        }\n        // Get Date\n        request.get(`${FETCH_URL}/${version}/V2_GAME_MASTER.${format}`, (error, response, body) => {\n            if (response.body === '404: Not Found\\n') return reject(new Error('Given version could not be found.'));\n            if (error) return reject(error);\n\n            // Parse output, if JSON is selected\n            if (format === 'json') {\n                try {\n                    resolve(JSON.parse(body));\n                } catch (exception) {\n                    reject(exception);\n                }\n                // Return as string\n            } else {\n                resolve(body);\n            }\n        });\n    });\n};\n\n/**\n * Returns the number of the latest version\n * @returns {String} Returns the latest version number\n * \n * @example\n * const gameMaster = require('pokemongo-game-master');\n * \n * const version = await gameMaster.getLatestVersionName);\n * console.log(version) // E.g. 0.89.0\n */\nconst getLatestVersionName = () => {\n    return new Promise((resolve, reject) => {\n        const URL = `${FETCH_URL}/latest-version.txt`;\n        request.get(URL, (error, response, body) => {\n            if (response.body === '404: Not Found\\n') return reject(new Error(`${URL} was not found. Seems like an internal error`));\n            if (error) return reject(error);\n            resolve(body);\n        });\n    });\n};\n\nmodule.exports = { getVersion, getLatestVersionName };\n"]}