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,QAAQ,IAAI,OAAO,GAAG,EAAI,OAAQ,MAAO,EAAI,SACvD,EACL,EAGF,OAAO,QAAU","file":"/npm/swearfilter@2.0.4/src/index.js","sourceRoot":"","sourcesContent":["/**\n * Minified by jsDelivr using Terser v5.39.0.\n * Original file: /npm/swearfilter@2.0.4/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 baseFilter = require('./util/baseFilter.json')\r\nconst filterExp = require('./util/filterExp')\r\nconst normalizeChars = require('./util/normalizeChars')\r\nconst regex = require('./util/regex')\r\n\r\nconst firstShortWords = ['an', 'as', 'us', 'be']\r\nconst shortWords = ['it', 'at', 'xd']\r\n\r\nfunction inRange(x, min, max) {\r\n  return ((x - min) * (x - max) <= 0)\r\n}\r\n\r\nfunction resolve(content) {\r\n  // base stuff\r\n  content = content\r\n    .toLowerCase()\r\n    .replace(regex.removeRegex, '')\r\n    .replace(/<#?@?!?&?(\\d+)>/g, '') // discord mentions\r\n    .replace(/<a?:(\\w+):(\\d+)>/g, '$1') // emojis (as well as discord custom emojis)\r\n    .replace(regex.emailRegex, (...email) => {\r\n      return `${email[1]}${email[2]}${email[6]}`.replace(regex.replaceSpots.spaces, '')\r\n    }).replace(regex.linkRegex, (...link) => {\r\n      return `${link[2]}`.replace(regex.replaceSpots.spaces, '')\r\n    })\r\n    .replace(/(\\w)\\1{2,}/g, '$1$1') // multiple characters only come up once\r\n\r\n  for (const i in regex.converter.in) { // convert special character like accents and emojis into their readable counterparts\r\n    content = content.replace(regex.converter.in[i], regex.converter.out[i])\r\n  }\r\n\r\n  content = normalizeChars(content)\r\n\r\n  let res = Array(content.split(regex.replaceSpots.spaces).length + 1).fill().map(() => ({ i: [], t: '' })) // array of default objects\r\n\r\n  content = content.split(regex.replaceSpots.spaces)\r\n\r\n  function addSpot(text, spot, index) {\r\n    if (!res[index]) return false\r\n    res[index].t = text\r\n\r\n    function checkSpots(s) { // if indexes are outside of the range of the current spot, adjust the range\r\n      if (s < res[index].i[0]) res[index].i[0] = s\r\n      if (s > res[index].i[1]) res[index].i[1] = s\r\n    }\r\n\r\n    if (Array.isArray(spot)) {\r\n      if (res[index].i.length < 1) {\r\n        res[index].i = spot\r\n      } else {\r\n        checkSpots(spot[0])\r\n        checkSpots(spot[1])\r\n      }\r\n    } else {\r\n      if (res[index].i.length < 1) {\r\n        res[index].i = [spot, spot]\r\n      } else {\r\n        checkSpots(spot)\r\n      }\r\n    }\r\n\r\n    return true\r\n  }\r\n\r\n  let spotted = 0\r\n  const nextPushes = []\r\n\r\n  for (let i = 0; i < content.length; i++) { // base index pushing to array\r\n    const split = content[i]\r\n      .replace(regex.replaceSpots.nothing, '')\r\n      .split(regex.replaceSpots.spaces)\r\n\r\n    for (let spI = 0; spI < split.length; spI++) {\r\n      nextPushes.push({ i: [i, i], t: split[spI], n: true })\r\n      addSpot(\r\n        split[spI],\r\n        i,\r\n        spotted\r\n      )\r\n      spotted++\r\n    }\r\n  }\r\n\r\n  res = nextPushes.concat(res)\r\n\r\n  for (let i = 0; i < res.length; i++) { // combine < 3 character bits together\r\n    const s = res[i]\r\n    if (firstShortWords.includes(s.t)) continue\r\n\r\n    if (s.t && (s.t.length < 3) && res[i + 1]) {\r\n      if (s.n) continue\r\n      if (addSpot(s.t + res[i + 1].t, s.i, i + 1)) {\r\n        s.t = ''\r\n        s.i = []\r\n      }\r\n    }\r\n  }\r\n\r\n  for (let i = res.length; i > -1; i--) { // combine < 3 character bits together but going backwards\r\n    const s = res[i]\r\n    if (!s || shortWords.includes(s.t)) continue\r\n\r\n    if (s.t && (s.t.length < 3) && res[i - 1]) {\r\n      if (s.n || res[i - 1].n) continue\r\n      if (addSpot(res[i - 1].t + s.t, s.i, i - 1)) {\r\n        s.t = ''\r\n        s.i = []\r\n      }\r\n    }\r\n  }\r\n\r\n  // res = res.filter(x => x.t) // remove any blank spaces\r\n\r\n  for (let i = 0; i < res.length; i++) { // combine pieces that ends and start with the same character\r\n    const s = res[i]\r\n    if (!s || firstShortWords.some(x => s.t.endsWith(x))) continue\r\n\r\n    if (s.t && res[i + 1] && (s.t[s.t.length - 1] === res[i + 1].t[0])) {\r\n      if (s.n) continue\r\n      if (addSpot(s.t + res[i + 1].t, s.i, i + 1)) {\r\n        s.t = ''\r\n      }\r\n    }\r\n  }\r\n\r\n  // content = res.filter(x => x.t) // remove any blank spaces (again)\r\n\r\n  return res\r\n}\r\n\r\n/**\r\n * Swear Filter Options\r\n * @typedef {Object} FilterOptions\r\n * @prop {String[]} [swearWords=[]] The Words to Use in the Filter.\r\n * @prop {Boolean} [smartDetect=true] Whether you want the filter to detect words using leetspeak and and other circumvention techniques. Defaults to `true`.\r\n * @prop {Object} [baseFilter={}] Options for the Base Filter. (Contains Approx. 2,000 Words)\r\n * @prop {Boolean} [baseFilter.useBaseFilter=true] Whether or not to use the Base Filter. Defaults to `true`.\r\n * @prop {String[]} [baseFilter.uncensoredWords=[]] The Words to Ignore if Picked Up by the Filter.\r\n *\r\n */\r\n\r\nclass Filter {\r\n  /**\r\n  * Create a new Filter.\r\n  * @param {FilterOptions} options\r\n  * @example\r\n  * const Filter = require(\"swearfilter\"); \r\n  * \r\n  * const filter = new Filter({\r\n  *     swearWords: [\"bad\", \"words\", \"here\"],\r\n  *     smartDetect: true,\r\n  *     baseFilter: {\r\n  *         useBaseFilter: true,\r\n  *         uncensoredWords: [\"words\", \"to\", \"ignore\"]\r\n  *    }\r\n  * });\r\n  */\r\n\r\n  constructor(options = {}) {\r\n\r\n    /**\r\n    * Swear Filter Options\r\n    * @type {FilterOptions}\r\n    */\r\n\r\n    this.options = options;\r\n    if (!this.options.swearWords) this.options.swearWords = [];\r\n    if (this.options.smartDetect === undefined) this.options.smartDetect = true;\r\n\r\n    if (!this.options.baseFilter) this.options.baseFilter = {};\r\n    if (this.options.baseFilter.useBaseFilter === undefined) this.options.baseFilter.useBaseFilter = true;\r\n    if (!this.options.baseFilter.uncensoredWords) this.options.baseFilter.uncensoredWords = [];\r\n  }\r\n\r\n  /**\r\n   * @typedef {Object} FilterResponse\r\n   * @prop {String} word The Bad Word that was Found.\r\n   * @prop {String} filter The Filter that Contained the Bad Word.\r\n   */\r\n\r\n  /**\r\n   * Test a String of Text against the Filter.\r\n   * \r\n   * An Array of any Bad Words that were Found will be Returned.\r\n   * @param {String} string The String to Test for Bad Words.\r\n   * @returns {FilterResponse[]}\r\n   * @example\r\n   * const Filter = require(\"swearfilter\");\r\n   * \r\n   * const filter = new Filter({\r\n   *     swearWords: [\"bad\", \"words\", \"here\"],\r\n   *     smartDetect: true,\r\n   *     baseFilter: {\r\n   *         useBaseFilter: true,\r\n   *         uncensoredWords: [\"words\", \"to\", \"ignore\"]\r\n   *    }\r\n   * });\r\n   * \r\n   * filter.test(\"thisisbad\");\r\n   * // => [ { word: 'bad', filter: 'custom' } ]\r\n   * \r\n   * filter.test(\"b @ d\");\r\n   * // => [ { word: 'bad', filter: 'custom' } ]\r\n   * \r\n   * filter.test(\"b;a,..;a;.,;,d;,a.;,d;,B,;a,;D;;;g;h:f;;;d,;d\");\r\n   * // => [ { word: 'bad', filter: 'custom' } ]\r\n   */\r\n  test(string) {\r\n    if (!string) return console.log(\"Swear Filter Error: String was not Provided.\\nNeed Help? Join Our Discord Server at 'https://discord.gg/P2g24jp'\");\r\n    if (typeof string !== \"string\") return console.log(\"Swear Filter Error: The Parameter Provided was not of type 'string'.\\nNeed Help? Join Our Discord Server at 'https://discord.gg/P2g24jp'\");\r\n    const content = resolve(string)\r\n    const filterResponses = [];\r\n    const filter = {}\r\n    let ranges = []\r\n\r\n    if (this.options.baseFilter.useBaseFilter) {\r\n      filter.base = Object.keys(baseFilter).map(x => new filterExp(x, baseFilter[x]))\r\n    }\r\n\r\n    filter.custom = this.options.swearWords.map(x => new filterExp(x))\r\n\r\n    if (!this.options.smartDetect) {\r\n      if (this.options.baseFilter.useBaseFilter) {\r\n        for (let i = 0; i < Object.keys(baseFilter).length; i++) {\r\n          const word = Object.keys(baseFilter)[i]\r\n          if (string.includes(word)) {\r\n            filterResponses.push({ word, filter: 'base' })\r\n          }\r\n        }\r\n      }\r\n\r\n      for (let i = 0; i < this.options.swearWords.length; i++) {\r\n        const word = this.options.swearWords[i]\r\n        if (string.includes(word)) {\r\n          filterResponses.push({ word, filter: 'custom' })\r\n        }\r\n      }\r\n      return filterResponses\r\n    }\r\n\r\n    content.forEach(piece => {\r\n      let done = false\r\n      if (ranges.some(x => inRange(x[0], piece.i[0], piece.i[1]) && inRange(x[1], piece.i[0], piece.i[1]))) return\r\n      for (const key in filter) {\r\n        for (const part of filter[key]) {\r\n          if (!part.test(piece.t, this.options.baseFilter.uncensoredWords)) continue\r\n          done = true\r\n          ranges.push(piece.i)\r\n          filterResponses.push({ word: part.text, filter: key })\r\n          break\r\n        }\r\n        if (done) break\r\n      }\r\n    })\r\n\r\n    return filterResponses\r\n  }\r\n\r\n  /**\r\n   * @typedef {Object} CensorOptions\r\n   * @prop {String} [mask=\"*\"] The String to Censor the Bad Word. Defaults to `*`.\r\n   * @prop {\"character\" | \"word\"} [type=\"character\"] The Type of Censoring to Use. `character` will replace each letter with the mask. `word` will replace each word with the mask. Defaults to `character`.\r\n   */\r\n\r\n  /**\r\n   * Censor a String of Text.\r\n   * @param {String} string The String for which to Censor Bad Words.\r\n   * @param {CensorOptions} [options={}] The Options for Censoring.\r\n   * @returns {String}\r\n   * @example\r\n   * const Filter = require(\"swearfilter\");\r\n   * \r\n   * const filter = new Filter({\r\n   *     swearWords: [\"frick\", \"beach\", \"bad\"],\r\n   *     smartDetect: true,\r\n   *     baseFilter: {\r\n   *         useBaseFilter: true,\r\n   *         uncensoredWords: [\"words\", \"to\", \"ignore\"]\r\n   *    }\r\n   * });\r\n   * \r\n   * filter.censor(\"Hey, frick you beach, you are bad\", { mask: \"*\", type: \"character\" });\r\n   * // => \"Hey, ***** you *****, you are ***\"\r\n   * \r\n   * filter.censor(\"Hey, frick you beach, you are bad\", { mask: \"[bleep]\", type: \"word\" });\r\n   * // => \"Hey, [bleep] you [bleep], you are [bleep]\"\r\n   */\r\n  censor(string, options = {}) {\r\n    if (!string) return console.log(\"Swear Filter Error: String was not Provided.\\nNeed Help? Join Our Discord Server at 'https://discord.gg/P2g24jp'\");\r\n    if (typeof string !== \"string\") return console.log(\"Swear Filter Error: The Parameter Provided was not of type 'string'.\\nNeed Help? Join Our Discord Server at 'https://discord.gg/P2g24jp'\");\r\n    if (!options.mask) options.mask = \"*\";\r\n    if (!options.type) options.type = \"character\";\r\n    if (![\"character\", \"word\"].includes(options.type)) return console.log(\"Swear Filter Error: The Censoring Type must be either 'character' or 'word'.\\nNeed Help? Join Our Discord Server at 'https://discord.gg/P2g24jp'\");\r\n\r\n    const censor = (type, mask, string) => {\r\n      if (type === \"character\") {\r\n        return string.split('').map(x => mask).join('')\r\n      }\r\n      if (type === \"word\") {\r\n        return string.split(' ').map(x => mask).join(' ')\r\n      }\r\n    }\r\n\r\n    const filterResponses = this.test(string)\r\n    if (!filterResponses.length) return string\r\n\r\n    const censorResponses = filterResponses.map(x => {\r\n      return { word: x.word, censor: censor(options.type, options.mask, x.word) }\r\n    })\r\n\r\n    return censorResponses.reduce((acc, cur) => {\r\n      return acc.replace(new RegExp(`${cur.word}`, \"gi\"), cur.censor)\r\n    }, string)\r\n  }\r\n}\r\n\r\nmodule.exports = Filter"]}