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AAC,IAAL,CAAU,GAAG,CAAC,MAAJ,GAAa,GAAvB;AAAT,KAArB,EAA4D,UAAC,CAAD,EAAI,KAAJ;AAAA,aAC1D,GAAG,CAAC,GAAG,CAAC,KAAJ,CAAU,KAAK,GAAG,GAAlB,EAAuB,CAAC,KAAK,GAAG,CAAT,IAAc,GAArC,CAAD,CADuD;AAAA,KAA5D,CAL4B;AAAA,GAA9B;;AASA,MAAM,oBAAoB,GAAG,SAAvB,oBAAuB,CAAC,KAAD;AAAA,WAC3B,IAAI,MAAJ,CACE,KAAK,CACF,GADH,CACO,UAAC,IAAD;AAAA,aAAU,YAAY,CAAC,IAAD,CAAtB;AAAA,KADP,EAEE;AACA;AAHF,KAIG,IAJH,CAIQ,UAAC,CAAD,EAAI,CAAJ;AAAA,aAAU,CAAC,CAAC,MAAF,GAAW,CAAC,CAAC,MAAvB;AAAA,KAJR,EAKG,IALH,CAKQ,GALR,CADF,CAD2B;AAAA,GAA7B;;AAUA,MAAM,yBAAyB,GAAG,SAA5B,yBAA4B,CAAC,KAAD;AAAA,WAChC,IAAI,MAAJ,QACO,KAAK,CACP,GADE,CACE,UAAC,IAAD;AAAA,aAAU,YAAY,CAAC,IAAD,CAAtB;AAAA,KADF,EAEH;AACA;AAHG,KAIF,IAJE,CAIG,UAAC,CAAD,EAAI,CAAJ;AAAA,aAAU,CAAC,CAAC,MAAF,GAAW,CAAC,CAAC,MAAvB;AAAA,KAJH,EAKF,IALE,CAKG,EALH,CADP,SADgC;AAAA,GAAlC;;AAUA,MAAM,YAAY,GAAG,SAAf,YAAe,CAAC,IAAD;AAAA,WACnB,IAAI,CAAC,OAAL,CAAa,0BAAb,EAAyC,MAAzC,CADmB;AAAA,GAArB","file":"hashids.js","sourcesContent":["type NumberLike = number | bigint\n\nexport default class Hashids {\n private alphabet: string[]\n private seps: string[]\n private guards: string[]\n private salt: string[]\n private guardsRegExp: RegExp\n private sepsRegExp: RegExp\n private allowedCharsRegExp: RegExp\n\n public constructor(\n salt = '',\n private minLength = 0,\n alphabet = 'abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ1234567890',\n seps = 'cfhistuCFHISTU',\n ) {\n if (typeof minLength !== 'number') {\n throw new TypeError(\n `Hashids: Provided 'minLength' has to be a number (is ${typeof minLength})`,\n )\n }\n if (typeof salt !== 'string') {\n throw new TypeError(\n `Hashids: Provided 'salt' has to be a string (is ${typeof salt})`,\n )\n }\n if (typeof alphabet !== 'string') {\n throw new TypeError(\n `Hashids: Provided alphabet has to be a string (is ${typeof alphabet})`,\n )\n }\n\n const saltChars = Array.from(salt)\n const alphabetChars = Array.from(alphabet)\n const sepsChars = Array.from(seps)\n\n this.salt = saltChars\n\n const uniqueAlphabet = keepUnique(alphabetChars)\n\n if (uniqueAlphabet.length < minAlphabetLength) {\n throw new Error(\n `Hashids: alphabet must contain at least ${minAlphabetLength} unique characters, provided: ${uniqueAlphabet}`,\n )\n }\n\n /** `alphabet` should not contains `seps` */\n this.alphabet = withoutChars(uniqueAlphabet, sepsChars)\n /** `seps` should contain only characters present in `alphabet` */\n const filteredSeps = onlyChars(sepsChars, uniqueAlphabet)\n this.seps = shuffle(filteredSeps, saltChars)\n\n let sepsLength\n let diff\n\n if (\n this.seps.length === 0 ||\n this.alphabet.length / this.seps.length > sepDiv\n ) {\n sepsLength = Math.ceil(this.alphabet.length / sepDiv)\n\n if (sepsLength > this.seps.length) {\n diff = sepsLength - this.seps.length\n this.seps.push(...this.alphabet.slice(0, diff))\n this.alphabet = this.alphabet.slice(diff)\n }\n }\n\n this.alphabet = shuffle(this.alphabet, saltChars)\n const guardCount = Math.ceil(this.alphabet.length / guardDiv)\n\n if (this.alphabet.length < 3) {\n this.guards = this.seps.slice(0, guardCount)\n this.seps = this.seps.slice(guardCount)\n } else {\n this.guards = this.alphabet.slice(0, guardCount)\n this.alphabet = this.alphabet.slice(guardCount)\n }\n\n this.guardsRegExp = makeAnyOfCharsRegExp(this.guards)\n this.sepsRegExp = makeAnyOfCharsRegExp(this.seps)\n this.allowedCharsRegExp = makeAtLeastSomeCharRegExp([\n ...this.alphabet,\n ...this.guards,\n ...this.seps,\n ])\n }\n\n public encode(numbers: string): string\n public encode(numbers: NumberLike[]): string\n public encode(...numbers: NumberLike[]): string\n public encode(numbers: string[]): string\n public encode(...numbers: string[]): string\n public encode<T extends string | NumberLike>(\n first: T[] | T,\n ...numbers: T[]\n ): string {\n const ret = ''\n\n if (Array.isArray(first)) {\n numbers = first\n } else {\n // eslint-disable-next-line eqeqeq\n numbers = [...(first != null ? [first] : []), ...numbers]\n }\n\n if (!numbers.length) {\n return ret\n }\n\n if (!numbers.every(isIntegerNumber)) {\n numbers = numbers.map((n) =>\n typeof n === 'bigint' || typeof n === 'number'\n ? n\n : safeParseInt10(String(n)),\n ) as T[]\n }\n\n if (!(numbers as NumberLike[]).every(isPositiveAndFinite)) {\n return ret\n }\n\n return this._encode(numbers as number[]).join('')\n }\n\n public decode(id: string): NumberLike[] {\n if (!id || typeof id !== 'string' || id.length === 0) return []\n return this._decode(id)\n }\n\n /**\n * @description Splits a hex string into groups of 12-digit hexadecimal numbers,\n * then prefixes each with '1' and encodes the resulting array of numbers\n *\n * Encoding '00000000000f00000000000f000f' would be the equivalent of:\n * Hashids.encode([0x100000000000f, 0x100000000000f, 0x1000f])\n *\n * This means that if your environment supports BigInts,\n * you will get different (shorter) results if you provide\n * a BigInt representation of your hex and use `encode` directly, e.g.:\n * Hashids.encode(BigInt(`0x${hex}`))\n *\n * To decode such a representation back to a hex string, use the following snippet:\n * Hashids.decode(id)[0].toString(16)\n */\n public encodeHex(hex: string | bigint): string {\n switch (typeof hex) {\n case 'bigint':\n hex = hex.toString(16)\n break\n case 'string':\n if (!/^[0-9a-fA-F]+$/.test(hex)) return ''\n break\n default:\n throw new Error(\n `Hashids: The provided value is neither a string, nor a BigInt (got: ${typeof hex})`,\n )\n }\n\n const numbers = splitAtIntervalAndMap(hex, 12, (part) =>\n parseInt(`1${part}`, 16),\n )\n return this.encode(numbers)\n }\n\n public decodeHex(id: string) {\n return this.decode(id)\n .map((number) => number.toString(16).slice(1))\n .join('')\n }\n\n private _encode(numbers: NumberLike[]): string[] {\n let alphabet = this.alphabet\n\n const numbersIdInt = numbers.reduce<number>(\n (last, number, i) =>\n last +\n (typeof number === 'bigint'\n ? Number(number % BigInt(i + 100))\n : number % (i + 100)),\n 0,\n )\n\n let ret: string[] = [alphabet[numbersIdInt % alphabet.length]]\n const lottery = ret.slice()\n\n const seps = this.seps\n const guards = this.guards\n\n numbers.forEach((number, i) => {\n const buffer = lottery.concat(this.salt, alphabet)\n\n alphabet = shuffle(alphabet, buffer)\n const last = toAlphabet(number, alphabet)\n\n ret.push(...last)\n\n if (i + 1 < numbers.length) {\n const charCode = last[0].codePointAt(0)! + i\n const extraNumber =\n typeof number === 'bigint'\n ? Number(number % BigInt(charCode))\n : number % charCode\n ret.push(seps[extraNumber % seps.length])\n }\n })\n\n if (ret.length < this.minLength) {\n const prefixGuardIndex =\n (numbersIdInt + ret[0].codePointAt(0)!) % guards.length\n ret.unshift(guards[prefixGuardIndex])\n\n if (ret.length < this.minLength) {\n const suffixGuardIndex =\n (numbersIdInt + ret[2].codePointAt(0)!) % guards.length\n ret.push(guards[suffixGuardIndex])\n }\n }\n\n const halfLength = Math.floor(alphabet.length / 2)\n while (ret.length < this.minLength) {\n alphabet = shuffle(alphabet, alphabet)\n ret.unshift(...alphabet.slice(halfLength))\n ret.push(...alphabet.slice(0, halfLength))\n\n const excess = ret.length - this.minLength\n if (excess > 0) {\n const halfOfExcess = excess / 2\n ret = ret.slice(halfOfExcess, halfOfExcess + this.minLength)\n }\n }\n\n return ret\n }\n\n public isValidId(id: string): boolean {\n return this.allowedCharsRegExp.test(id)\n }\n\n private _decode(id: string): NumberLike[] {\n if (!this.isValidId(id)) {\n throw new Error(\n `The provided ID (${id}) is invalid, as it contains characters that do not exist in the alphabet (${this.guards.join(\n '',\n )}${this.seps.join('')}${this.alphabet.join('')})`,\n )\n }\n const idGuardsArray = id.split(this.guardsRegExp)\n const splitIndex =\n idGuardsArray.length === 3 || idGuardsArray.length === 2 ? 1 : 0\n\n const idBreakdown = idGuardsArray[splitIndex]\n if (idBreakdown.length === 0) return []\n\n const lotteryChar = idBreakdown[Symbol.iterator]().next().value as string\n const idArray = idBreakdown.slice(lotteryChar.length).split(this.sepsRegExp)\n\n let lastAlphabet: string[] = this.alphabet\n const result: NumberLike[] = []\n\n for (const subId of idArray) {\n const buffer = [lotteryChar, ...this.salt, ...lastAlphabet]\n const nextAlphabet = shuffle(\n lastAlphabet,\n buffer.slice(0, lastAlphabet.length),\n )\n result.push(fromAlphabet(Array.from(subId), nextAlphabet))\n lastAlphabet = nextAlphabet\n }\n\n // if the result is different from what we'd expect, we return an empty result (malformed input):\n if (this._encode(result).join('') !== id) return []\n return result\n }\n}\n\nconst minAlphabetLength = 16\nconst sepDiv = 3.5\nconst guardDiv = 12\n\nexport const keepUnique = <T>(content: Iterable<T>): T[] =>\n Array.from(new Set(content))\n\nexport const withoutChars = (\n chars: string[],\n withoutChars: string[],\n): string[] => chars.filter((char) => !withoutChars.includes(char))\n\nexport const onlyChars = (chars: string[], keepChars: string[]): string[] =>\n chars.filter((char) => keepChars.includes(char))\n\nconst isIntegerNumber = (n: NumberLike | string) =>\n typeof n === 'bigint' ||\n (!Number.isNaN(Number(n)) && Math.floor(Number(n)) === n)\n\nconst isPositiveAndFinite = (n: NumberLike) =>\n typeof n === 'bigint' || (n >= 0 && Number.isSafeInteger(n))\n\nfunction shuffle(alphabetChars: string[], saltChars: string[]): string[] {\n if (saltChars.length === 0) {\n return alphabetChars\n }\n\n let integer: number\n const transformed = alphabetChars.slice()\n\n for (let i = transformed.length - 1, v = 0, p = 0; i > 0; i--, v++) {\n v %= saltChars.length\n p += integer = saltChars[v].codePointAt(0)!\n const j = (integer + v + p) % i\n\n // swap characters at positions i and j\n const a = transformed[i]\n const b = transformed[j]\n transformed[j] = a\n transformed[i] = b\n }\n\n return transformed\n}\n\nconst toAlphabet = (input: NumberLike, alphabetChars: string[]): string[] => {\n const id: string[] = []\n\n if (typeof input === 'bigint') {\n const alphabetLength = BigInt(alphabetChars.length)\n do {\n id.unshift(alphabetChars[Number(input % alphabetLength)])\n input = input / alphabetLength\n } while (input > BigInt(0))\n } else {\n do {\n id.unshift(alphabetChars[input % alphabetChars.length])\n input = Math.floor(input / alphabetChars.length)\n } while (input > 0)\n }\n\n return id\n}\n\nconst fromAlphabet = (\n inputChars: string[],\n alphabetChars: string[],\n): NumberLike =>\n inputChars.reduce((carry, item) => {\n const index = alphabetChars.indexOf(item)\n if (index === -1) {\n throw new Error(\n `The provided ID (${inputChars.join(\n '',\n )}) is invalid, as it contains characters that do not exist in the alphabet (${alphabetChars.join(\n '',\n )})`,\n )\n }\n if (typeof carry === 'bigint') {\n return carry * BigInt(alphabetChars.length) + BigInt(index)\n }\n const value = carry * alphabetChars.length + index\n const isSafeValue = Number.isSafeInteger(value)\n if (isSafeValue) {\n return value\n } else {\n if (typeof BigInt === 'function') {\n return BigInt(carry) * BigInt(alphabetChars.length) + BigInt(index)\n } else {\n // we do not have support for BigInt:\n throw new Error(\n `Unable to decode the provided string, due to lack of support for BigInt numbers in the current environment`,\n )\n }\n }\n }, 0 as NumberLike)\n\nconst safeToParseNumberRegExp = /^\\+?[0-9]+$/\nconst safeParseInt10 = (str: string) =>\n safeToParseNumberRegExp.test(str) ? parseInt(str, 10) : NaN\n\nconst splitAtIntervalAndMap = <T>(\n str: string,\n nth: number,\n map: (n: string) => T,\n): T[] =>\n Array.from<never, T>({length: Math.ceil(str.length / nth)}, (_, index) =>\n map(str.slice(index * nth, (index + 1) * nth)),\n )\n\nconst makeAnyOfCharsRegExp = (chars: string[]) =>\n new RegExp(\n chars\n .map((char) => escapeRegExp(char))\n // we need to sort these from longest to shortest,\n // as they may contain multibyte unicode characters (these should come first)\n .sort((a, b) => b.length - a.length)\n .join('|'),\n )\n\nconst makeAtLeastSomeCharRegExp = (chars: string[]) =>\n new RegExp(\n `^[${chars\n .map((char) => escapeRegExp(char))\n // we need to sort these from longest to shortest,\n // as they may contain multibyte unicode characters (these should come first)\n .sort((a, b) => b.length - a.length)\n .join('')}]+$`,\n )\n\nconst escapeRegExp = (text: string) =>\n text.replace(/[-[\\]{}()*+?.,\\\\^$|#\\s]/g, '\\\\$&')\n"]}
|