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AEf,GAAI,MAAM,QAAQ,KAAK,QAAQ,MAAO,CACpC,MAAM,EAAM,KAAK,EAAK,YAElB,GACF,OAAO,KAAK,GAAK,SAAS,IACnB,KAAK,QAAQ,KAAK,SAAS,WACvB,EAAI,EACb,IAGJ,KAAK,KAAK,EAAK,YAAc,CAC/B,MACE,KAAK,KAAK,EAAK,YAAc,KAAK,EAAK,YAGvC,KAAK,QAAQ,MAAQ,KAAK,QAAQ,eACpC,EAAK,KAAO,KAAK,KAAK,EAAK,mBAEpB,KAAK,KAAK,EAAK,aAExB,KAAK,KAAK,EACZ,CACF,GACK,KAAK,QAAQ,MAAS,KAAK,QAAQ,MAAQ,KAAK,QAAQ,gBAC3D,KAAK,UAAO,GAId,KAAK,MAAK,CAAC,EAAG,KACZ,MAAM,EAAM,EAAE,KAAK,cAAc,EAAE,MACnC,OAAY,IAAR,EACK,EAAE,WAAW,cAAc,EAAE,YAE/B,CAAG,IAGZ,KAAK,SAAW,QAClB,CAiBA,MAAA,CAAO,GACL,MAAM,EAAI,GAEV,IAAK,MAAM,KAAM,KACX,EAAG,IAAK,EAAE,KAAK,GAErB,OAAO,CACT,CAOA,GAAA,CAAI,GACF,MAAM,EAAI,GACV,IAAK,MAAM,KAAM,KAAM,EAAE,KAAK,EAAG,IAEjC,OAAO,CACT","file":"/npm/@wfcd/items@1.1270.867/index.js","sourceRoot":"","sourcesContent":["/**\n * Minified by jsDelivr using Terser v5.39.0.\n * Original file: /npm/@wfcd/items@1.1270.867/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","'use strict';\n\n/* eslint-disable no-restricted-syntax */\n/**\n * Configuration options for @wfcd/items\n * @typedef {Object} Options\n *\n * @property {string[]} category List of allowed categories to be pulled in.\n *                        Default ['All'].\n *                        Allows any of:\n *                         - All\n *                         - Arcanes\n *                         - Archwing\n *                         - Arch-Gun\n *                         - Arch-Melee\n *                         - Corpus\n *                         - Enemy\n *                         - Fish\n *                         - Gear\n *                         - Glyphs\n *                         - Melee\n *                         - Misc\n *                         - Mods\n *                         - Pets\n *                         - Primary\n *                         - Quests\n *                         - Relics\n *                         - Resources\n *                         - Secondary\n *                         - Sentinels\n *                         - Skins\n *                         - Warframes\n * @property {boolean} ignoreEnemies If true, don't load any enemy categories\n * @property {boolean|Array<string>} i18n Whether or not to include i18n, or a list of allowed locales\n * @property {boolean} i18nOnObject Whether or not to include i18n on the object itself and not on the \"array\"\n */\n\nconst path = require('path');\nconst fs = require('fs');\n\nconst canAccess = (filePath) => {\n  try {\n    fs.accessSync(filePath, fs.constants.R_OK);\n    return true;\n  } catch (e) {\n    return false;\n  }\n};\n\nconst cache = {};\nconst readJson = (filePath) => {\n  if (cache[filePath]) return cache[filePath];\n\n  const resolved = path.resolve(__dirname, filePath);\n  if (canAccess(resolved)) {\n    const parsed = JSON.parse(fs.readFileSync(resolved, 'utf-8'));\n    cache[filePath] = parsed;\n    return parsed;\n  }\n  return [];\n};\n\nconst versions = readJson('./data/cache/.export.json');\n\nlet i18n = {};\ntry {\n  i18n = readJson('./data/json/i18n.json');\n} catch (ignored) {\n  // can only happen in really weird stuff, and we're already defaulting, so it's ok\n}\n\nconst ignored = ['All', 'i18n'];\nconst defaultCategories = fs\n  .readdirSync(path.join(__dirname, './data/json/'))\n  .filter((f) => f.includes('.json'))\n  .map((f) => f.replace('.json', ''))\n  .filter((f) => !ignored.includes(f));\n\nconst defaultOptions = { category: defaultCategories, i18n: false, i18nOnObject: false };\n\nmodule.exports = class Items extends Array {\n  constructor(options, ...existingItems) {\n    super(...existingItems);\n\n    // Merge provided options with defaults\n    this.options = {\n      ...defaultOptions,\n      ...options,\n    };\n\n    const containedAll = this.options.category.includes('All');\n    if (containedAll) {\n      this.options.category = Array.from(\n        new Set(this.options.category.filter((c) => c !== 'All').concat(defaultCategories))\n      );\n    }\n\n    this.i18n = {};\n\n    // Add items from options to array. Type equals the file name.\n    for (const category of this.options.category) {\n      // Ignores the enemy category.\n      if (this.options.ignoreEnemies && category === 'Enemy') continue;\n      const items = readJson(`./data/json/${category}.json`); // eslint-disable-line import/no-dynamic-require\n      for (const item of items) {\n        if (this.options.i18n) {\n          // only insert i18n for the objects we're inserting, so we don't bloat memory\n          if (Array.isArray(this.options.i18n)) {\n            const raw = i18n[item.uniqueName];\n            // only process if passed language is a supported i18n value\n            if (raw) {\n              Object.keys(raw).forEach((locale) => {\n                if (!this.options.i18n.includes(locale)) {\n                  delete raw[locale];\n                }\n              });\n            }\n            this.i18n[item.uniqueName] = raw;\n          } else {\n            this.i18n[item.uniqueName] = i18n[item.uniqueName];\n          }\n        }\n        if (this.options.i18n && this.options.i18nOnObject) {\n          item.i18n = this.i18n[item.uniqueName];\n          // keep data just on the object so no bloat in extra this.i18n\n          delete this.i18n[item.uniqueName];\n        }\n        this.push(item);\n      }\n    }\n    if (!this.options.i18n || (this.options.i18n && this.options.i18nOnObject)) {\n      this.i18n = undefined;\n    }\n\n    // Output won't be sorted if separate categories are chosen\n    this.sort((a, b) => {\n      const res = a.name.localeCompare(b.name);\n      if (res === 0) {\n        return a.uniqueName.localeCompare(b.uniqueName);\n      }\n      return res;\n    });\n\n    this.versions = versions;\n  }\n\n  /**\n   * @Override Array.prototype.filter\n   *\n   * This roughly implements Mozilla's builtin for `Array.prototype.filter`[1].\n   * V8 passes the prototype of the original Array into `ArraySpeciesCreate`[2][3],\n   * which is the Array that gets returned from `filter()`. However, they don't\n   * pass the arguments passed to the constructor of the original Array (this Class),\n   * which means that it will always return a new Array with ALL items, even when\n   * different categories are specified.[4]\n   *\n   * [1] https://hg.mozilla.org/mozilla-central/file/tip/js/src/builtin/Array.js#l320\n   * [2] https://github.com/v8/v8/blob/master/src/builtins/array-filter.tq#L193\n   * [3] https://www.ecma-international.org/ecma-262/7.0/#sec-arrayspeciescreate\n   * [4] https://runkit.com/kaptard/5c9daf33090ab900120465fe\n   */\n  filter(fn) {\n    const A = [];\n\n    for (const el of this) {\n      if (fn(el)) A.push(el);\n    }\n    return A;\n  }\n\n  /**\n   * @Override Array.prototype.map\n   *\n   * See filter override\n   */\n  map(fn) {\n    const a = [];\n    for (const el of this) a.push(fn(el));\n\n    return a;\n  }\n};\n"]}