From 67cdffac7e82fceba5a07ae2baf98665897175f9 Mon Sep 17 00:00:00 2001 From: UmamiAppearance Date: Fri, 9 Dec 2022 22:10:06 +0100 Subject: [PATCH] v0.3.3 --- dist/BrowserSHAObj.esm.js | 2091 +++++++++++++++++++++++++------ dist/BrowserSHAObj.esm.min.js | 8 +- dist/BrowserSHAObj.iife.js | 2091 +++++++++++++++++++++++++------ dist/BrowserSHAObj.iife.min.js | 8 +- package-lock.json | 2092 ++------------------------------ package.json | 10 +- src/index.js | 2 +- 7 files changed, 3519 insertions(+), 2783 deletions(-) diff --git a/dist/BrowserSHAObj.esm.js b/dist/BrowserSHAObj.esm.js index 20b4d81..efacdc0 100644 --- a/dist/BrowserSHAObj.esm.js +++ b/dist/BrowserSHAObj.esm.js @@ -514,6 +514,23 @@ class SmartOutput { const DEFAULT_INPUT_HANDLER = SmartInput; const DEFAULT_OUTPUT_HANDLER = SmartOutput; +class SignError extends TypeError { + constructor() { + super("The input is signed but the converter is not set to treat input as signed.\nYou can pass the string 'signed' to the decode function or when constructing the converter."); + this.name = "SignError"; + } +} + +class DecodingError extends TypeError { + constructor(char, msg=null) { + if (msg === null) { + msg = `Character '${char}' is not part of the charset.`; + } + super(msg); + this.name = "DecodingError"; + } +} + /** * Utilities for every BaseEx class. @@ -522,16 +539,19 @@ const DEFAULT_OUTPUT_HANDLER = SmartOutput; */ class Utils { - constructor(main, addCharsetTools=true) { + constructor(main) { // Store the calling class in this.root // for accessability. this.root = main; + + // set specific args object for converters + this.converterArgs = {}; // If charsets are uses by the parent class, // add extra functions for the user. - if ("charsets" in main && addCharsetTools) this.#charsetUserToolsConstructor(); + this.#charsetUserToolsConstructor(); } setIOHandlers(inputHandler=DEFAULT_INPUT_HANDLER, outputHandler=DEFAULT_OUTPUT_HANDLER) { @@ -539,73 +559,135 @@ class Utils { this.outputHandler = outputHandler; } + + /** + * Constructor for the ability to add a charset and + * change the default version. + */ #charsetUserToolsConstructor() { - /* - Constructor for the ability to add a charset and - change the default version. - */ - - this.root.addCharset = (name, charset) => { - /* - Save method to add a charset. - ---------------------------- - - @name: string that represents the key for the new charset - @charset: string, array or Set of chars - the length must fit to the according class - */ + + /** + * Save method to add a charset. + * @param {string} name - "Charset name." + * @param {[string|set|array]} - "Charset" + */ + this.root.addCharset = (name, _charset, _padChars=[], info=true) => { + + const normalize = (typeName, set, setLen) => { + + if (setLen === 0 && set.length) { + console.warn(`This converter has no ${typeName}. The following argument was ignored:\n'${set}'`); + return []; + } + + let inputLen = setLen; + + if (typeof set === "string") { + set = [...set]; + } + + if (Array.isArray(set)) { + + // Store the input length of the input + inputLen = set.length; + + // Convert to "Set" -> eliminate duplicates + // If duplicates are found the length of the + // Set and the length of the initial input + // differ. + + set = new Set(set); + + } else if (!(set instanceof Set)) { + throw new TypeError(`The ${typeName} must be one of the types:\n'str', 'set', 'array'."`); + } + if (set.size === setLen) { + return [...set]; + } + + if (inputLen !== setLen) { + throw new Error(`Your ${typeName} has a length of ${inputLen}. The converter requires a length of ${setLen}.`); + } else { + const charAmounts = {}; + _charset = [..._charset]; + _charset.forEach(c => { + if (c in charAmounts) { + charAmounts[c]++; + } else { + charAmounts[c] = 1; + } + }); + + let infoStr = ""; + if (setLen < 100) { + infoStr = `${_charset.join("")}\n`; + _charset.forEach(c => { + if (charAmounts[c] > 1) { + infoStr += "^"; + } else { + infoStr += " "; + } + }); + } + const rChars = Object.keys(charAmounts).filter(c => charAmounts[c] > 1); + throw new Error(`You have repetitive char(s) [ ${rChars.join(" | ")} ] in your ${typeName}. Make sure each character is unique.\n${infoStr}`); + } + }; + + if (this.root.frozenCharsets) { + throw new Error("The charsets of this converter cannot be changed."); + } + if (typeof name !== "string") { throw new TypeError("The charset name must be a string."); } - // Get the appropriate length for the charset - // from the according converter - - const setLen = this.root.converter.radix; - let inputLen = setLen; - - if (typeof charset === "string" || Array.isArray(charset)) { - - // Store the input length of the input - inputLen = charset.length; - - // Convert to "Set" -> eliminate duplicates - // If duplicates are found the length of the - // Set and the length of the initial input - // differ. + if (info && name in this.root.charsets) { + console.warn(`An existing charset with name ${name} will get replaced.`); + } - charset = new Set(charset); + const charset = normalize("charset", _charset, this.root.converter.radix); + const padChars = normalize("padding set", _padChars, this.root.padCharAmount); - } else if (!(charset instanceof Set)) { - throw new TypeError("The charset must be one of the types:\n'str', 'set', 'array'."); + this.root.charsets[name] = charset; + if (padChars.length) { + this.root.padChars[name] = padChars; } - - if (charset.size === setLen) { - charset = [...charset].join(""); - this.root.charsets[name] = charset; + + if (info) { console.info(`New charset '${name}' was added and is ready to use`); - } else if (inputLen === setLen) { - throw new Error("There were repetitive chars found in your charset. Make sure each char is unique."); - } else { - throw new Error(`The length of the charset must be ${setLen}.`); } }; // Save method (argument gets validated) to // change the default version. this.root.setDefaultCharset = (version) => { - ({version } = this.validateArgs([version])); + if (!(version in this.root.charsets)) { + const sets = Object.keys(this.root.charsets).join("\n * "); + const msg = `Charset ${version} was not found. Available charsets are:\n * ${sets}`; + throw new TypeError(msg); + } this.root.version = version; }; } - makeArgList(args) { - /* - Returns argument lists for error messages. - */ + /** + * Argument lists for error messages. + * @param {string[]} args + * @returns string - Arguments joined as a string. + */ + #makeArgList(args) { return args.map(s => `'${s}'`).join(", "); } + /** + * Removes all padded zeros a the start of the string, + * adds a "-" if value is negative. + * @param {string} output - Former output. + * @param {boolean} negative - Indicates a negative value if true. + * @returns {string} - Output without zero padding and a sign if negative. + */ toSignedStr(output, negative) { output = output.replace(/^0+(?!$)/, ""); @@ -617,8 +699,14 @@ class Utils { return output; } + /** + * Analyzes the input for a negative sign. + * If a sign is found, it gets removed but + * negative bool gets true; + * @param {string} input - Input number as a string. + * @returns {array} - Number without sign and negativity indication bool. + */ extractSign(input) { - // Test for a negative sign let negative = false; if (input[0] === "-") { negative = true; @@ -628,29 +716,57 @@ class Utils { return [input, negative]; } - invalidArgument(arg, versions, outputTypes, initial) { - const IOHandlerHint = (initial) ? "\n * valid declarations for IO handlers are 'bytesOnly', 'bytesIn', 'bytesOut'" : ""; - const signedHint = (this.root.isMutable.signed) ? "\n * pass 'signed' to disable, 'unsigned' to enable the use of the twos's complement for negative integers" : ""; - const endiannessHint = (this.root.isMutable.littleEndian) ? "\n * 'be' for big , 'le' for little endian byte order for case conversion" : ""; - const padHint = (this.root.isMutable.padding) ? "\n * pass 'pad' to fill up, 'nopad' to not fill up the output with the particular padding" : ""; - const caseHint = (this.root.isMutable.upper) ? "\n * valid args for changing the encoded output case are 'upper' and 'lower'" : ""; - const outputHint = `\n * valid args for the output type are ${this.makeArgList(outputTypes)}`; - const versionHint = (versions) ? `\n * the options for version (charset) are: ${this.makeArgList(versions)}` : ""; - const numModeHint = "\n * 'number' for number-mode (converts every number into a Float64Array to keep the natural js number type)"; + /** + * All possible error messages for invalid arguments, + * gets adjusted according to the converter settings. + * @param {string} arg - Argument. + * @param {string[]} versions - Charset array. + * @param {string[]} outputTypes - Array of output types. + * @param {boolean} initial - Indicates if the arguments where passed during construction. + */ + #invalidArgument(arg, versions, outputTypes, initial) { + const loopConverterArgs = () => Object.keys(this.converterArgs).map( + key => this.converterArgs[key].map( + keyword => `'${keyword}'` + ) + .join(" and ") + ) + .join("\n - "); - throw new TypeError(`'${arg}'\n\nInput parameters:${IOHandlerHint}${signedHint}${endiannessHint}${padHint}${caseHint}${outputHint}${versionHint}${numModeHint}\n\nTraceback:`); + throw new TypeError([ + `'${arg}'\n\nParameters:`, + initial ? "\n * valid declarations for IO handlers are 'bytesOnly', 'bytesIn', 'bytesOut'" : "", + this.root.isMutable.signed ? "\n * pass 'signed' to disable, 'unsigned' to enable the use of the twos's complement for negative integers" : "", + this.root.isMutable.littleEndian ? "\n * 'be' for big , 'le' for little endian byte order for case conversion" : "", + this.root.isMutable.padding ? "\n * pass 'pad' to fill up, 'nopad' to not fill up the output with the particular padding" : "", + this.root.isMutable.upper ? "\n * valid args for changing the encoded output case are 'upper' and 'lower'" : "", + `\n * valid args for the output type are ${this.#makeArgList(outputTypes)}`, + versions ? `\n * the option(s) for version/charset are: ${this.#makeArgList(versions)}` : "", + "\n * valid args for integrity check are: 'integrity' and 'nointegrity'", + this.root.hasDecimalMode ? "\n * 'decimal' for decimal-mode (directly converts Numbers including decimal values, without byte-conversion)" : "", + "\n * 'number' for number-mode (converts every number into a Float64Array to keep the natural js number type)", + Object.keys(this.converterArgs).length ? `\n * converter specific args:\n - ${loopConverterArgs()}` : "", + "\n\nTraceback:" + ].join("")); } + + /** + * Test if provided arguments are in the argument list. + * Everything gets converted to lowercase and returned. + * @param {string[]} args - Passed arguments. + * @param {boolean} initial - Indicates if the arguments where passed during construction. + * @returns {Object} - Converter settings object. + */ validateArgs(args, initial=false) { - /* - Test if provided arguments are in the argument list. - Everything gets converted to lowercase and returned - */ // default settings const parameters = { + decimalMode: this.root.decimalMode, + integrity: this.root.integrity, littleEndian: this.root.littleEndian, numberMode: this.root.numberMode, + options: this.root.options, outputType: this.root.outputType, padding: this.root.padding, signed: this.root.signed, @@ -658,6 +774,11 @@ class Utils { version: this.root.version }; + // add any existing converter specific args + for (const param in this.converterArgs) { + parameters[param] = this.root[param]; + } + // if no args are provided return the default settings immediately if (!args.length) { @@ -681,12 +802,14 @@ class Utils { }; // set available versions and extra arguments - const versions = Object.prototype.hasOwnProperty.call(this.root, "charsets") ? Object.keys(this.root.charsets) : []; + const versions = Object.keys(this.root.charsets); const extraArgList = { + integrity: ["nointegrity", "integrity"], littleEndian: ["be", "le"], padding: ["nopad", "pad"], signed: ["unsigned", "signed"], upper: ["lower", "upper"], + ...this.converterArgs }; // if initial, look for IO specifications @@ -707,10 +830,31 @@ class Utils { if (extractArg("number")) { parameters.numberMode = true; parameters.outputType = "float_n"; + } + + // test for the special "decimal" keyword + if (extractArg("decimal")) { + if (!this.root.hasDecimalMode) { + throw TypeError(`Argument 'decimal' is only allowed for converters with a non-integer base.`); + } + parameters.decimalMode = true; + parameters.outputType = "decimal"; + + if (parameters.numberMode) { + parameters.numberMode = false; + console.warn("-> number-mode was disabled due to the decimal-mode"); + } } // walk through the remaining arguments args.forEach((arg) => { + + // additional/optional non boolean options + if (typeof arg === "object") { + parameters.options = {...parameters.options, ...arg}; + return; + } + arg = String(arg).toLowerCase(); if (versions.includes(arg)) { @@ -746,7 +890,7 @@ class Utils { } if (invalidArg) { - this.invalidArgument(arg, versions, outputTypes, initial); + this.#invalidArgument(arg, versions, outputTypes, initial); } } }); @@ -756,7 +900,7 @@ class Utils { // displayed. if (parameters.padding && parameters.signed) { parameters.padding = false; - this.constructor.warning("Padding was set to false due to the signed conversion."); + console.warn("-> padding was set to false due to the signed conversion"); } // overwrite the default parameters for the initial call @@ -769,17 +913,40 @@ class Utils { return parameters; } + /** + * A TypeError specifically for sign errors. + */ signError() { - throw new TypeError("The input is signed but the converter is not set to treat input as signed.\nYou can pass the string 'signed' to the decode function or when constructing the converter."); + throw new SignError(); } - static warning(message) { - if (Object.prototype.hasOwnProperty.call(console, "warn")) { - console.warn(message); - } else { - console.log(`___\n${message}\n`); + /** + * Wrap output to "cols" characters per line. + * @param {string} output - Output string. + * @param {number} cols - Number of cols per line. + * @returns {string} - Wrapped output. + */ + wrapOutput(output, cols=0) { + if (!cols) { + return output; } + const m = new RegExp(`.{1,${cols}}`, "gu"); + return output.match(m).join("\n"); } + + /** + * Ensures a string input. + * @param {*} input - Input. + * @param {boolean} [keepWS=false] - If set to false, whitespace is getting removed from the input if present. + * @returns {string} - Normalized input. + */ + normalizeInput(input, keepWS=false) { + if (keepWS) { + return String(input); + } + return String(input).replace(/\s/g, ""); + } + } /** @@ -851,7 +1018,7 @@ class BaseConverter { * @param {{ buffer: ArrayBufferLike; byteLength: any; byteOffset: any; length: any; BYTES_PER_ELEMENT: 1; }} inputBytes - Input as Uint8Array. * @param {string} charset - The charset used for conversion. * @param {boolean} littleEndian - Byte order, little endian bool. - * @param {*} replacer - Replacer function can replace groups of characters during encoding. + * @param {function} replacer - Replacer function can replace groups of characters during encoding. * @returns {number[]} - Output string and padding amount. */ encode(inputBytes, charset, littleEndian=false, replacer=null) { @@ -963,16 +1130,16 @@ class BaseConverter { /** * BaseEx Universal Base Decoding. + * Decodes to a string of the given radix to a byte array. * @param {string} inputBaseStr - Base as string (will also get converted to string but can only be used if valid after that). - * @param {string} charset - The charset used for conversion. - * @param {*} littleEndian - Byte order, little endian bool. + * @param {string[]} charset - The charset used for conversion. + * @param {string[]} padSet - Padding characters for integrity check. + * @param {boolean} integrity - If set to false invalid character will be ignored. + * @param {boolean} littleEndian - Byte order, little endian bool. * @returns {{ buffer: ArrayBufferLike; byteLength: any; byteOffset: any; length: any; BYTES_PER_ELEMENT: 1; }} - The decoded output as Uint8Array. */ - decode(inputBaseStr, charset, littleEndian=false) { - /* - Decodes to a string of the given radix to a byte array - */ - + decode(inputBaseStr, charset, padSet=[], integrity=true, littleEndian=false) { + // Convert each char of the input to the radix-integer // (this becomes the corresponding index of the char // from the charset). Every char, that is not found in @@ -986,13 +1153,14 @@ class BaseConverter { let bs = this.bsDec; const byteArray = new Array(); - inputBaseStr.split('').forEach((c) => { + [...inputBaseStr].forEach(c => { const index = charset.indexOf(c); if (index > -1) { - byteArray.push(index); + byteArray.push(index); + } else if (integrity && padSet.indexOf(c) === -1) { + throw new DecodingError(c); } }); - let padChars; @@ -1149,18 +1317,28 @@ class BaseTemplate { // predefined settings this.charsets = {}; + this.decimalMode = false; + this.frozenCharsets = false; + this.hasDecimalMode = false; this.hasSignedMode = false; + this.integrity = true; this.littleEndian = false; this.numberMode = false; this.outputType = "buffer"; this.padding = false; + this.padCharAmount = 0; + this.padChars = {}; this.signed = false; this.upper = null; if (appendUtils) this.utils = new Utils(this); this.version = "default"; + this.options = { + lineWrap: 0 + }; // list of allowed/disallowed args to change this.isMutable = { + integrity: true, littleEndian: false, padding: false, signed: false, @@ -1171,8 +1349,8 @@ class BaseTemplate { /** * BaseEx Generic Encoder. * @param {*} input - Any input the used byte converter allows. - * @param {*} [replacerFN] - Replacer function, which is passed to the encoder. - * @param {*} [postEncodeFN] - Function, which is executed after encoding. + * @param {function} [replacerFN] - Replacer function, which is passed to the encoder. + * @param {function} [postEncodeFN] - Function, which is executed after encoding. * @param {...any} args - Converter settings. * @returns {string} - Base encoded string. */ @@ -1182,8 +1360,7 @@ class BaseTemplate { const settings = this.utils.validateArgs(args); // handle input - let inputBytes, negative, type; - [inputBytes, negative, type] = this.utils.inputHandler.toBytes(input, settings); + let [inputBytes, negative, type] = this.utils.inputHandler.toBytes(input, settings); // generate replacer function if given let replacer = null; @@ -1192,8 +1369,7 @@ class BaseTemplate { } // Convert to base string - let output, zeroPadding; - [output, zeroPadding] = this.converter.encode(inputBytes, this.charsets[settings.version], settings.littleEndian, replacer); + let [output, zeroPadding] = this.converter.encode(inputBytes, this.charsets[settings.version], settings.littleEndian, replacer); // set sign if requested if (settings.signed) { @@ -1210,32 +1386,32 @@ class BaseTemplate { output = postEncodeFN({ inputBytes, output, settings, zeroPadding, type }); } - return output; + return this.utils.wrapOutput(output, settings.options.lineWrap); } /** * BaseEx Generic Decoder. - * @param {string} rawInput - Base String. - * @param {*} [preDecodeFN] - Function, which gets executed before decoding. - * @param {*} [postDecodeFN] - Function, which gets executed after decoding + * @param {string} input - Base String. + * @param {function} [preDecodeFN] - Function, which gets executed before decoding. + * @param {function} [postDecodeFN] - Function, which gets executed after decoding * @param {...any} args - Converter settings. * @returns {*} - Output according to converter settings. */ - decode(rawInput, preDecodeFN, postDecodeFN, ...args) { + decode(input, preDecodeFN, postDecodeFN, keepNL, ...args) { // apply settings const settings = this.utils.validateArgs(args); // ensure a string input - let input = String(rawInput); + input = this.utils.normalizeInput(input, keepNL); // set negative to false for starters let negative = false; // Test for a negative sign if converter supports it if (this.hasSignedMode) { - [input, negative] = this.utils.extractSign(input); + [ input, negative ] = this.utils.extractSign(input); // But don't allow a sign if the decoder is not configured to use it if (negative && !settings.signed) { @@ -1255,7 +1431,13 @@ class BaseTemplate { } // Run the decoder - let output = this.converter.decode(input, this.charsets[settings.version], settings.littleEndian); + let output = this.converter.decode( + input, + this.charsets[settings.version], + this.padChars[settings.version], + settings.integrity, + settings.littleEndian + ); // Run post decode function if provided if (postDecodeFN) { @@ -1269,7 +1451,7 @@ class BaseTemplate { /** * [BaseEx|Base1 Converter]{@link https://github.com/UmamiAppearance/BaseExJS/blob/main/src/converters/base-1.js} * - * @version 0.4.3 + * @version 0.6.1 * @author UmamiAppearance [mail@umamiappearance.eu] * @license GPL-3.0 */ @@ -1292,21 +1474,17 @@ class Base1 extends BaseTemplate { constructor(...args) { super(); - // Remove global charset adding method as - // it is not suitable for this converter. - delete this.addCharset; - // All chars in the string are used and picked randomly (prob. suitable for obfuscation) - this.charsets.all = " !\"#$%&'()*+,./0123456789:;<=>?@ABCDEFGHIJKLMNOPQRSTUVWXYZ[\\]^_`abcdefghijklmnopqrstuvwxyz{|}~"; + this.charsets.all = [..." !\"#$%&'()*+,-./0123456789:;<=>?@ABCDEFGHIJKLMNOPQRSTUVWXYZ[\\]^_`abcdefghijklmnopqrstuvwxyz{|}~"]; // The sequence is used from left to right again and again - this.charsets.sequence = "Hello World!"; + this.charsets.sequence = [..."Hello World!"]; // Standard unary string with one character - this.charsets.default = "1"; + this.charsets.default = ["1"]; // Telly Mark string, using hash for 5 and vertical bar for 1 - this.charsets.tmark = "|#"; + this.charsets.tmark = ["|", "#"]; // Base 10 converter this.converter = new BaseConverter(10, 0, 0); @@ -1317,6 +1495,7 @@ class Base1 extends BaseTemplate { this.signed = true; // mutable extra args + this.isMutable.charsets = false; this.isMutable.signed = true; this.isMutable.upper = true; @@ -1352,7 +1531,7 @@ class Base1 extends BaseTemplate { if (n > Number.MAX_SAFE_INTEGER) { throw new RangeError("Invalid string length."); } else if (n > 16777216) { - this.utils.constructor.warning("The string length is really long. The JavaScript engine may have memory issues generating the output string."); + console.warn("The string length is really long. The JavaScript engine may have memory issues generating the output string."); } n = Number(n); @@ -1363,7 +1542,7 @@ class Base1 extends BaseTemplate { // Convert to unary in respect to the version differences if (charAmount === 1) { - output = charset.repeat(n); + output = charset.at(0).repeat(n); } else if (settings.version === "all") { for (let i=0; i 4) { - output = charset[1].repeat((n - singulars) / 5); + output = charset.at(1).repeat((n - singulars) / 5); } - output += charset[0].repeat(singulars); + output += charset.at(0).repeat(singulars); } else { for (let i=0; i { - - let { input: normInput } = scope; + const normalizeInput = ({ input: normInput, settings }) => { + // Remove "0x" if present normInput = normInput.replace(/^0x/, ""); + // remove non-charset characters if integrity + // check is disabled + if (!settings.integrity) { + normInput = normInput + .toLowerCase() + .replace(/[^0-9a-f]/g, ""); + } + // Ensure even number of characters if (normInput.length % 2) { normInput = "0".concat(normInput); @@ -1500,14 +1688,14 @@ class Base16 extends BaseTemplate { return normInput; }; - return super.decode(input, normalizeInput, null, ...args); + return super.decode(input, normalizeInput, null, false, ...args); } } /** * [BaseEx|Base32 Converter]{@link https://github.com/UmamiAppearance/BaseExJS/blob/main/src/converters/base-32.js} * - * @version 0.4.3 + * @version 0.6.1 * @author UmamiAppearance [mail@umamiappearance.eu] * @license GPL-3.0 */ @@ -1536,19 +1724,24 @@ class Base32 extends BaseTemplate { */ constructor(...args) { super(); + this.converter = new BaseConverter(32, 5, 8); // charsets - this.charsets.crockford = "0123456789abcdefghjkmnpqrstvwxyz"; - this.charsets.rfc3548 = "abcdefghijklmnopqrstuvwxyz234567"; - this.charsets.rfc4648 = "0123456789abcdefghijklmnopqrstuv"; - this.charsets.zbase32 = "ybndrfg8ejkmcpqxot1uwisza345h769"; - - // converter - this.converter = new BaseConverter(32, 5, 8); + this.charsets.crockford = [ ..."0123456789abcdefghjkmnpqrstvwxyz" ]; + this.padChars.crockford = ["="], + this.charsets.rfc3548 = [..."abcdefghijklmnopqrstuvwxyz234567"]; + this.padChars.rfc3548 = ["="]; + + this.charsets.rfc4648 = [..."0123456789abcdefghijklmnopqrstuv"]; + this.padChars.rfc4648 = ["="]; + + this.charsets.zbase32 = [..."ybndrfg8ejkmcpqxot1uwisza345h769"]; + this.padChars.zbase32 = ["="]; + // predefined settings + this.padCharAmount = 1; this.hasSignedMode = true; - this.padding = true; this.version = "rfc4648"; // mutable extra args @@ -1559,6 +1752,8 @@ class Base32 extends BaseTemplate { // apply user settings this.utils.validateArgs(args, true); + this.padding = (/rfc3548|rfc4648/).test(this.version); + this.upper = this.version === "crockford"; } @@ -1570,17 +1765,16 @@ class Base32 extends BaseTemplate { */ encode(input, ...args) { - const applyPadding = (scope) => { - - let { output, settings, zeroPadding } = scope; + const applyPadding = ({ output, settings, zeroPadding }) => { if (!settings.littleEndian) { // Cut of redundant chars and append padding if set if (zeroPadding) { const padValue = this.converter.padBytes(zeroPadding); - output = output.slice(0, output.length-padValue); + const padChar = this.padChars[settings.version].at(0); + output = output.slice(0, -padValue); if (settings.padding) { - output = output.concat("=".repeat(padValue)); + output = output.concat(padChar.repeat(padValue)); } } } @@ -1599,14 +1793,14 @@ class Base32 extends BaseTemplate { * @returns {*} - Output according to converter settings. */ decode(input, ...args) { - return super.decode(input, null, null, ...args); + return super.decode(input, null, null, false, ...args); } } /** * [BaseEx|Base58 Converter]{@link https://github.com/UmamiAppearance/BaseExJS/blob/main/src/converters/base-58.js} * - * @version 0.4.3 + * @version 0.6.1 * @author UmamiAppearance [mail@umamiappearance.eu] * @license GPL-3.0 */ @@ -1631,15 +1825,25 @@ class Base58 extends BaseTemplate{ * @param {...string} [args] - Converter settings. */ constructor(...args) { - super(); + super(); + this.converter = new BaseConverter(58, 0, 0); // charsets - this.charsets.default = "123456789abcdefghijkmnopqrstuvwxyzABCDEFGHJKLMNPQRSTUVWXYZ"; - this.charsets.bitcoin = "123456789ABCDEFGHJKLMNPQRSTUVWXYZabcdefghijkmnopqrstuvwxyz"; - this.charsets.flickr = "123456789abcdefghijkmnopqrstuvwxyzABCDEFGHJKLMNPQRSTUVWXYZ"; + this.charsets.default = [..."123456789abcdefghijkmnopqrstuvwxyzABCDEFGHJKLMNPQRSTUVWXYZ"]; + Object.defineProperty(this.padChars, "default", { + get: () => [ this.charsets.default.at(0) ] + }); - // converter - this.converter = new BaseConverter(58, 0, 0); + this.charsets.bitcoin = [..."123456789ABCDEFGHJKLMNPQRSTUVWXYZabcdefghijkmnopqrstuvwxyz"]; + Object.defineProperty(this.padChars, "bitcoin", { + get: () => [ this.charsets.bitcoin.at(0) ] + }); + + this.charsets.flickr = [..."123456789abcdefghijkmnopqrstuvwxyzABCDEFGHJKLMNPQRSTUVWXYZ"]; + Object.defineProperty(this.padChars, "flickr", { + get: () => [ this.charsets.flickr.at(0) ] + }); + // predefined settings this.padding = true; @@ -1662,9 +1866,7 @@ class Base58 extends BaseTemplate{ */ encode(input, ...args) { - const applyPadding = (scope) => { - - let { inputBytes, output, settings, type } = scope; + const applyPadding = ({ inputBytes, output, settings, type }) => { if (settings.padding && type !== "int") { @@ -1674,6 +1876,9 @@ class Base58 extends BaseTemplate{ let i = 0; const end = inputBytes.length; + // pad char is always! the first char in the set + const padChar = this.charsets[settings.version].at(0); + // only proceed if input has a length at all if (end) { while (!inputBytes[i]) { @@ -1690,7 +1895,7 @@ class Base58 extends BaseTemplate{ // Set a one for every leading null byte if (zeroPadding) { - output = ("1".repeat(zeroPadding)).concat(output); + output = (padChar.repeat(zeroPadding)).concat(output); } } } @@ -1711,15 +1916,16 @@ class Base58 extends BaseTemplate{ decode(input, ...args) { // post decoding function - const applyPadding = (scope) => { + const applyPadding = ({ input, output, settings }) => { - let { input, output, settings } = scope; + // pad char is always! the first char in the set + const padChar = this.charsets[settings.version].at(0); if (settings.padding && input.length > 1) { - // Count leading ones + // Count leading padding (char should be 1) let i = 0; - while (input[i] === "1") { + while (input[i] === padChar) { i++; } @@ -1737,14 +1943,14 @@ class Base58 extends BaseTemplate{ return output; }; - return super.decode(input, null, applyPadding, ...args); + return super.decode(input, null, applyPadding, false, ...args); } } /** * [BaseEx|Base64 Converter]{@link https://github.com/UmamiAppearance/BaseExJS/blob/main/src/converters/base-64.js} * - * @version 0.4.3 + * @version 0.6.1 * @author UmamiAppearance [mail@umamiappearance.eu] * @license GPL-3.0 */ @@ -1763,22 +1969,24 @@ class Base58 extends BaseTemplate{ */ class Base64 extends BaseTemplate { - /** + /**this.padChars. * BaseEx Base64 Constructor. * @param {...string} [args] - Converter settings. */ constructor(...args) { super(); + this.converter = new BaseConverter(64, 3, 4); // charsets - const b62Chars = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789"; - this.charsets.default = b62Chars.concat("+/"); - this.charsets.urlsafe = b62Chars.concat("-_"); - - // converter - this.converter = new BaseConverter(64, 3, 4); + this.charsets.default = [..."ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/"]; + this.padChars.default = ["="]; + + this.charsets.urlsafe = this.charsets.default.slice(0, -2).concat(["-", "_"]); + this.padChars.urlsafe = ["="]; + // predefined settings + this.padCharAmount = 1; this.padding = true; // mutable extra args @@ -1797,16 +2005,15 @@ class Base64 extends BaseTemplate { */ encode(input, ...args) { - const applyPadding = (scope) => { - - let { output, settings, zeroPadding } = scope; + const applyPadding = ({ output, settings, zeroPadding }) => { // Cut of redundant chars and append padding if set if (zeroPadding) { const padValue = this.converter.padBytes(zeroPadding); - output = output.slice(0, output.length-padValue); + const padChar = this.padChars[settings.version].at(0); + output = output.slice(0, -padValue); if (settings.padding) { - output = output.concat("=".repeat(padValue)); + output = output.concat(padChar.repeat(padValue)); } } @@ -1824,14 +2031,218 @@ class Base64 extends BaseTemplate { * @returns {*} - Output according to converter settings. */ decode(input, ...args) { - return super.decode(input, null, null, ...args); + return super.decode(input, null, null, false, ...args); + } +} + +/** + * [BaseEx|UUencode Converter]{@link https://github.com/UmamiAppearance/BaseExJS/blob/main/src/converters/uuencode.js} + * + * @version 0.6.1 + * @author UmamiAppearance [mail@umamiappearance.eu] + * @license GPL-3.0 + */ + +/** + * BaseEx UUencode Converter. + * ------------------------ + * + * This is a base64 converter. Various input can be + * converted to a base64 string or a base64 string + * can be decoded into various formats. + * + * Available charsets are: + * - default + * - urlsafe + */ +class UUencode extends BaseTemplate { + + /** + * BaseEx UUencode Constructor. + * @param {...string} [args] - Converter settings. + */ + constructor(...args) { + super(); + this.converter = new BaseConverter(64, 3, 4); + + // charsets + this.charsets.default = [..."`!\"#$%&'()*+,-./0123456789:;<=>?@ABCDEFGHIJKLMNOPQRSTUVWXYZ[\\]^_"]; + Object.defineProperty(this.padChars, "default", { + get: () => [ this.charsets.default.at(0) ] + }); + + this.charsets.original = [" ", ...this.charsets.default.slice(1)]; + Object.defineProperty(this.padChars, "original", { + get: () => [ this.charsets.original.at(0) ] + }); + + this.charsets.xx = [..."+-0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz"]; + Object.defineProperty(this.padChars, "xx", { + get: () => [ this.charsets.xx.at(0) ] + }); + + + // predefined settings + this.padding = true; + this.header = false; + this.utils.converterArgs.header = ["noheader", "header"]; + this.isMutable.header = true; + this.isMutable.integrity = false; + + // apply user settings + this.utils.validateArgs(args, true); + } + + + /** + * BaseEx UUencoder. + * @param {*} input - Input according to the used byte converter. + * @param {...str} [args] - Converter settings. + * @returns {string} - UUencode string. + */ + encode(input, ...args) { + + const format = ({ output, settings, zeroPadding }) => { + + const charset = this.charsets[settings.version]; + const outArray = [...output]; + + + if (settings.header) { + const permissions = settings.options.permissions || een(); + const fileName = settings.options.file || ees(); + output = `begin ${permissions} ${fileName}\n`; + } else { + output = ""; + } + + // repeatedly take 60 chars from the output until it is empty + for (;;) { + const lArray = outArray.splice(0, 60); + + // if all chars are taken, remove eventually added pad zeros + if (!outArray.length) { + const byteCount = this.converter.padChars(lArray.length) - zeroPadding; + + // add the the current chars plus the leading + // count char + output += `${charset.at(byteCount)}${lArray.join("")}\n`; + break; + } + + // add the the current chars plus the leading + // count char ("M" for default charsets) + output += `${charset.at(45)}${lArray.join("")}\n`; + } + + output += `${charset.at(0)}\n`; + + if (settings.header) { + output += "\nend"; + } + + + return output; + }; + + return super.encode(input, null, format, ...args); + } + + + /** + * BaseEx UUdecoder. + * @param {string} input - UUencode String. + * @param {...any} [args] - Converter settings. + * @returns {*} - Output according to converter settings. + */ + decode(input, ...args) { + + let padChars = 0; + + const format = ({ input, settings }) => { + + const charset = this.charsets[settings.version]; + const lines = input.trim().split("\n"); + const inArray = []; + + if ((/^begin/i).test(lines.at(0))) { + lines.shift(); + } + + for (const line of lines) { + const lArray = [...line]; + const byteCount = charset.indexOf(lArray.shift()); + + if (!(byteCount > 0)) { + break; + } + + inArray.push(...lArray); + + if (byteCount !== 45) { + padChars = this.converter.padChars(lArray.length) - byteCount; + break; + } + } + + return inArray.join(""); + + }; + + const removePadChars = ({ output }) => { + if (padChars) { + output = new Uint8Array(output.slice(0, -padChars)); + } + return output; + }; + + return super.decode(input, format, removePadChars, true, ...args); } } + +const een = () => { + const o = () => Math.floor(Math.random() * 8); + return `${o()}${o()}${o()}`; +}; + +const ees = () => { + const name = [ + "unchronological", + "unconditionally", + "underemphasized", + "underprivileged", + "undistinguished", + "unsophisticated", + "untitled", + "untitled-1", + "untitled-3", + "uuencode" + ]; + + const ext = [ + "applescript", + "bat", + "beam", + "bin", + "exe", + "js", + "mam", + "py", + "sh", + "vdo", + "wiz" + ]; + + const pick = (arr) => arr.at(Math.floor(Math.random() * arr.length)); + + return `${pick(name)}.${pick(ext)}`; +}; + /** * [BaseEx|Base85 Converter]{@link https://github.com/UmamiAppearance/BaseExJS/blob/main/src/converters/base-85.js} * - * @version 0.4.3 + * @version 0.6.1 * @author UmamiAppearance [mail@umamiappearance.eu] * @license GPL-3.0 */ @@ -1869,15 +2280,13 @@ class Base85 extends BaseTemplate { */ constructor(...args) { super(); + this.converter = new BaseConverter(85, 4, 5, 84); // charsets - this.charsets.adobe = "!\"#$%&'()*+,-./0123456789:;<=>?@ABCDEFGHIJKLMNOPQRSTUVWXYZ[\\]^_`abcdefghijklmnopqrstu"; - this.charsets.ascii85 = this.charsets.adobe; - this.charsets.rfc1924 = "0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz!#$%&()*+-;<=>?@^_`{|}~"; - this.charsets.z85 = "0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ.-:+=^!/*?&<>()[]{}@%$#"; - - // converter - this.converter = new BaseConverter(85, 4, 5, 84); + this.charsets.adobe = [..."!\"#$%&'()*+,-./0123456789:;<=>?@ABCDEFGHIJKLMNOPQRSTUVWXYZ[\\]^_`abcdefghijklmnopqrstu"]; + this.charsets.ascii85 = this.charsets.adobe.slice(); + this.charsets.rfc1924 = [..."0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz!#$%&()*+-;<=>?@^_`{|}~"]; + this.charsets.z85 = [..."0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ.-:+=^!/*?&<>()[]{}@%$#"]; // predefined settings this.version = "ascii85"; @@ -1907,14 +2316,12 @@ class Base85 extends BaseTemplate { // Remove padded values and add a frame for the // adobe variant - const framesAndPadding = (scope) => { - - let { output, settings, zeroPadding } = scope; + const framesAndPadding = ({ output, settings, zeroPadding }) => { // Cut of redundant chars if (zeroPadding) { const padValue = this.converter.padBytes(zeroPadding); - output = output.slice(0, output.length-padValue); + output = output.slice(0, -padValue); } // Adobes variant gets its <~framing~> @@ -1937,9 +2344,7 @@ class Base85 extends BaseTemplate { */ decode(input, ...args) { - const prepareInput = (scope) => { - - let { input, settings } = scope; + const prepareInput = ({ input, settings }) => { // For default ascii85 convert "z" back to "!!!!!" // Remove the adobe <~frame~> @@ -1953,14 +2358,14 @@ class Base85 extends BaseTemplate { return input }; - return super.decode(input, prepareInput, null, ...args); + return super.decode(input, prepareInput, null, false, ...args); } } /** * [BaseEx|Base91 Converter]{@link https://github.com/UmamiAppearance/BaseExJS/blob/main/src/converters/base-91.js} * - * @version 0.4.3 + * @version 0.6.1 * @author UmamiAppearance [mail@umamiappearance.eu] * @license GPL-3.0 AND BSD-3-Clause (Base91, Copyright (c) 2000-2006 Joachim Henke) */ @@ -1970,7 +2375,7 @@ class Base85 extends BaseTemplate { * ------------------------ * * This is a base91 converter. Various input can be - * converted to a base85 string or a base91 string + * converted to a base91 string or a base91 string * can be decoded into various formats. * * It is an implementation of Joachim Henkes method @@ -1990,8 +2395,16 @@ class Base91 extends BaseTemplate { constructor(...args) { super(); + // converter (properties only) + this.converter = { + radix: 91, + bsEnc: 0, + bsDec: 0 + }; + // charsets - this.charsets.default = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789!#$%&()*+,./:;<=>?@[]^_`{|}~\""; + this.charsets.default = [..."ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789!#$%&()*+,./:;<=>?@[]^_`{|}~\""]; + this.version = "default"; // apply user settings this.utils.validateArgs(args, true); @@ -2020,8 +2433,7 @@ class Base91 extends BaseTemplate { let n = 0; let output = ""; - // Shortcut - const chars = this.charsets[settings.version]; + const charset = this.charsets[settings.version]; inputBytes.forEach(byte => { //n = n + byte * 2^bitcount; @@ -2057,12 +2469,12 @@ class Base91 extends BaseTemplate { // the before calculated remainder of n // -> "rN" let q, r; - [q, r] = this.divmod(rN, 91); + [q, r] = this.#divmod(rN, 91); // Lookup the corresponding characters for // "r" and "q" in the set, append it to the // output string. - output = `${output}${chars[r]}${chars[q]}`; + output = `${output}${charset[r]}${charset[q]}`; } }); @@ -2071,20 +2483,20 @@ class Base91 extends BaseTemplate { // once more. if (bitCount) { let q, r; - [q, r] = this.divmod(n, 91); + [q, r] = this.#divmod(n, 91); // The remainder is concatenated in any case - output = output.concat(chars[r]); + output = output.concat(charset[r]); // The quotient is also appended, but only // if the bitCount still has the size of a byte // or n can still represent 91 conditions. if (bitCount > 7 || n > 90) { - output = output.concat(chars[q]); + output = output.concat(charset[q]); } } - return output; + return this.utils.wrapOutput(output, settings.options.lineWrap); } @@ -2098,11 +2510,19 @@ class Base91 extends BaseTemplate { // Argument validation and output settings const settings = this.utils.validateArgs(args); + const charset = this.charsets[settings.version]; // Make it a string, whatever goes in - input = String(input); + input = this.utils.normalizeInput(input); + let inArray = [...input]; + + // remove unwanted characters if integrity is false + if (!settings.integrity) { + inArray = inArray.filter(c => charset.includes(c)); + } - let l = input.length; + + let l = inArray.length; // For starters leave the last char behind // if the length of the input string is odd. @@ -2118,7 +2538,6 @@ class Base91 extends BaseTemplate { let n = 0; let bitCount = 0; - const chars = this.charsets[settings.version]; // Initialize an ordinary array const b256Array = new Array(); @@ -2127,8 +2546,18 @@ class Base91 extends BaseTemplate { // (aka collect remainder- and quotient-pairs) for (let i=0; i 88) ? 13 : 14; @@ -2143,8 +2572,8 @@ class Base91 extends BaseTemplate { // Calculate the last byte if the input is odd // and add it if (odd) { - const lastChar = input.charAt(l); - const rN = chars.indexOf(lastChar); + const lastChar = inArray.at(l); + const rN = charset.indexOf(lastChar); b256Array.push(((rN << bitCount) + n) % 256); } @@ -2161,141 +2590,31 @@ class Base91 extends BaseTemplate { * @param {*} y - number 2 * @returns {number} Modulo y of x */ - divmod (x, y) { + #divmod (x, y) { return [Math.floor(x/y), x%y]; } } /** - * [BaseEx|Byte Converter]{@link https://github.com/UmamiAppearance/BaseExJS/blob/main/src/converters/byte-converter.js} + * [BaseEx|LEB128 Converter]{@link https://github.com/UmamiAppearance/BaseExJS/blob/main/src/converters/leb-128.js} * - * @version 0.4.3 + * @version 0.6.1 * @author UmamiAppearance [mail@umamiappearance.eu] * @license GPL-3.0 */ /** - * BaseEx Byte Converter. + * BaseEx Little Endian Base 128 Converter. * --------------------------------------- * - * This is a byte converter. Various input can be - * converted to a bytes or bytes can be decoded into - * various formats. + * This is a leb128 converter. Various input can be + * converted to a leb128 string or a leb128 string + * can be decoded into various formats. * - * As en- and decoder were already available, for the - * use of converting in- and output for the base - * converters, this is just a little extra tool, which - * was fast and easy to create. - */ -class ByteConverter { - - /** - * BaseEx ByteConverter Constructor. - * @param {...string} [args] - Converter settings. - */ - constructor(...args) { - - // predefined settings - this.littleEndian = true; - this.numberMode = false; - this.outputType = "buffer"; - - // simplified utils - this.utils = { - validateArgs: (args, initial=false) => { - - const parameters = { - littleEndian: this.littleEndian, - numberMode: this.numberMode, - outputType: this.outputType, - signed: false, - }; - - if (!args.length) { - return parameters; - } - - if (args.includes("number")) { - args.splice(args.indexOf("number"), 1); - parameters.numberMode = true; - parameters.outputType = "float_n"; - } - - const outTypes = SmartOutput.typeList.map(s => `'${s}'`).join(", "); - - args.forEach((arg) => { - arg = String(arg).toLowerCase(); - - if (arg === "le") { - parameters.littleEndian = true; - } else if (arg === "be") { - parameters.littleEndian = false; - } else if (SmartOutput.typeList.includes(arg)) { - parameters.outputType = arg; - } else { - throw new TypeError(`Invalid argument: '${arg}.\nValid arguments are:\n'le', 'be', ${outTypes}`); - } - }); - - if (initial) { - for (const param in parameters) { - this[param] = parameters[param]; - } - } - - return parameters; - } - }; - - // apply user settings - this.utils.validateArgs(args, true); - } - - - /** - * BaseEx Byte Encoder. - * @param {*} input - Almost any input. - * @param {...str} [args] - Converter settings. - * @returns {{ buffer: ArrayBufferLike; }} - Bytes of Input. - */ - encode(input, ...args) { - const settings = this.utils.validateArgs(args); - return SmartInput.toBytes(input, settings)[0]; - } - - - /** - * BaseEx Byte Decoder. - * @param {{ buffer: ArrayBufferLike; }} input - Bytes/Buffer/View - * @param {...any} [args] - Converter settings. - * @returns {*} - Output of requested type. - */ - decode(input, ...args) { - const settings = this.utils.validateArgs(args); - return SmartOutput.compile(input, settings.outputType, settings.littleEndian); - } -} - -/** - * [BaseEx|LEB128 Converter]{@link https://github.com/UmamiAppearance/BaseExJS/blob/main/src/converters/leb-128.js} - * - * @version 0.4.3 - * @author UmamiAppearance [mail@umamiappearance.eu] - * @license GPL-3.0 - */ - -/** - * BaseEx Little Endian Base 128 Converter. - * --------------------------------------- - * - * This is a leb128 converter. Various input can be - * converted to a leb128 string or a leb128 string - * can be decoded into various formats. - * - * There is no real charset available as the input is - * getting converted to bytes. For having the chance - * to store these byes, there is a hexadecimal output - * available. + * There is no real charset available as the input is + * getting converted to bytes. For having the chance + * to store these bytes, there is a hexadecimal output + * available. */ class LEB128 extends BaseTemplate { @@ -2305,20 +2624,20 @@ class LEB128 extends BaseTemplate { */ constructor(...args) { // initialize base template without utils - super(false); - - // charsets - this.charsets.default = "", - this.charsets.hex = ""; - this.version = "default"; + super(); // converters this.converter = new BaseConverter(10, 0, 0); this.hexlify = new BaseConverter(16, 1, 2); - // utils (as lacking before) - this.utils = new Utils(this, false); - + // charsets + this.charsets.default = ""; + this.charsets.hex = ""; + + // predefined settings + this.version = "default"; + this.frozenCharsets = true; + // predefined settings this.littleEndian = true; this.hasSignedMode = true; @@ -2340,10 +2659,9 @@ class LEB128 extends BaseTemplate { // argument validation and input settings const settings = this.utils.validateArgs(args); - let inputBytes, negative; const signed = settings.signed; settings.signed = true; - [inputBytes, negative,] = this.utils.inputHandler.toBytes(input, settings); + const [ inputBytes, negative, ] = this.utils.inputHandler.toBytes(input, settings); // Convert to BaseRadix string let base10 = this.converter.encode(inputBytes, null, settings.littleEndian)[0]; @@ -2386,7 +2704,7 @@ class LEB128 extends BaseTemplate { const Uint8Output = Uint8Array.from(output); if (settings.version === "hex") { - return this.hexlify.encode(Uint8Output, "0123456789abcdef", false)[0]; + return this.hexlify.encode(Uint8Output, [..."0123456789abcdef"], false)[0]; } return Uint8Output; @@ -2405,9 +2723,11 @@ class LEB128 extends BaseTemplate { const settings = this.utils.validateArgs(args); if (settings.version === "hex") { - input = this.hexlify.decode(String(input).toLowerCase(), "0123456789abcdef", false); - } else if (input instanceof ArrayBuffer) { - input = new Uint8Array(input); + input = this.hexlify.decode(this.utils.normalizeInput(input).toLowerCase(), [..."0123456789abcdef"], [], settings.integrity, false); + } else if (typeof input.byteLength !== "undefined") { + input = BytesInput.toBytes(input)[0]; + } else { + throw new TypeError("Input must be a bytes like object."); } if (input.length === 1 && !input[0]) { @@ -2433,7 +2753,7 @@ class LEB128 extends BaseTemplate { let decimalNum, negative; [decimalNum, negative] = this.utils.extractSign(n.toString()); - const output = this.converter.decode(decimalNum, "0123456789", true); + const output = this.converter.decode(decimalNum, [..."0123456789"], [], settings.integrity, true); // Return the output return this.utils.outputHandler.compile(output, settings.outputType, true, negative); @@ -2441,74 +2761,1087 @@ class LEB128 extends BaseTemplate { } /** - * [BaseEx|SimpleBase Converter]{@link https://github.com/UmamiAppearance/BaseExJS/blob/main/src/converters/leb-128.js} + * [BaseEx|Ecoji Converter]{@link https://github.com/UmamiAppearance/BaseExJS/blob/main/src/converters/ecoji.js} * - * @version 0.4.3 + * @version 0.6.1 * @author UmamiAppearance [mail@umamiappearance.eu] - * @license GPL-3.0 + * @license GPL-3.0 OR Apache-2.0 + * @see https://github.com/keith-turner/ecoji */ -class SimpleBase extends BaseTemplate { - constructor(radix, ...args) { +/** + * BaseEx Ecoji (a Base 1024) Converter. + * ------------------------------------ + * This an implementation of the Ecoji converter. + * Various input can be converted to an Ecoji string + * or an Ecoji string can be decoded into various + * formats. Versions 1 and 2 are supported. + * This variant pretty much follows the standard + * (at least in its results, the algorithm is very + * different from the original). + * A deviation is the handling of padding. The last + * pad char can be trimmed for both versions and + * additionally omitted completely if integrity + * checks are disabled. + */ +class Ecoji extends BaseTemplate { + + #revEmojiVersion = {}; + #padRegex = null; + + /** + * BaseEx Ecoji Constructor. + * @param {...string} [args] - Converter settings. + */ + constructor(...args) { super(); - if (!radix || !Number.isInteger(radix) || radix < 2 || radix > 36) { - throw new RangeError("Radix argument must be provided and has to be an integer between 2 and 36.") - } + // charsets + this.charsets.emojis_v1 = [..."🀄🃏🅰🅱🅾🅿🆎🆑🆒🆓🆔🆕🆖🆗🆘🆙🆚🇦🇧🇨🇩🇪🇫🇬🇭🇮🇯🇰🇱🇲🇳🇴🇵🇶🇷🇸🇹🇺🇻🇼🇽🇾🇿🈁🈂🈚🈯🈲🈳🈴🈵🈶🈷🈸🈹🈺🉐🉑🌀🌁🌂🌃🌄🌅🌆🌇🌈🌉🌊🌋🌌🌍🌎🌏🌐🌑🌒🌓🌔🌕🌖🌗🌘🌙🌚🌛🌜🌝🌞🌟🌠🌡🌤🌥🌦🌧🌨🌩🌪🌫🌬🌭🌮🌯🌰🌱🌲🌳🌴🌵🌶🌷🌸🌹🌺🌻🌼🌽🌾🌿🍀🍁🍂🍃🍄🍅🍆🍇🍈🍉🍊🍋🍌🍍🍎🍏🍐🍑🍒🍓🍔🍕🍖🍗🍘🍙🍚🍛🍜🍝🍞🍟🍠🍡🍢🍣🍤🍥🍦🍧🍨🍩🍪🍫🍬🍭🍮🍯🍰🍱🍲🍳🍴🍵🍶🍷🍸🍹🍺🍻🍼🍽🍾🍿🎀🎁🎂🎃🎄🎅🎆🎇🎈🎉🎊🎋🎌🎍🎎🎏🎐🎑🎒🎓🎖🎗🎙🎚🎛🎞🎟🎠🎡🎢🎣🎤🎥🎦🎧🎨🎩🎪🎫🎬🎭🎮🎯🎰🎱🎲🎳🎴🎵🎶🎷🎸🎹🎺🎻🎼🎽🎾🎿🏀🏁🏂🏃🏄🏅🏆🏇🏈🏉🏊🏋🏌🏎🏏🏐🏑🏒🏓🏔🏕🏖🏗🏘🏙🏚🏛🏜🏝🏞🏟🏠🏡🏢🏣🏤🏥🏦🏧🏨🏩🏪🏫🏬🏭🏮🏯🏰🏳🏴🏵🏷🏸🏹🏺🏻🏼🏽🏾🏿🐀🐁🐂🐃🐄🐅🐆🐇🐈🐉🐊🐋🐌🐍🐎🐏🐐🐑🐒🐓🐔🐕🐖🐗🐘🐙🐚🐛🐜🐝🐞🐟🐠🐡🐢🐣🐤🐥🐦🐧🐨🐩🐪🐫🐬🐭🐮🐯🐰🐱🐲🐳🐴🐵🐶🐷🐸🐹🐺🐻🐼🐽🐾🐿👀👁👂👃👄👅👆👇👈👉👊👋👌👍👎👏👐👑👒👓👔👕👖👗👘👙👚👛👜👝👞👟👠👡👢👣👤👥👦👧👨👩👪👫👬👭👮👯👰👱👲👳👴👵👶👷👸👹👺👻👼👽👾👿💀💁💂💃💄💅💆💇💈💉💊💋💌💍💎💏💐💑💒💓💔💕💖💗💘💙💚💛💜💝💞💟💠💡💢💣💤💥💦💧💨💩💪💫💬💭💮💯💰💱💲💳💴💵💶💷💸💹💺💻💼💽💾💿📀📁📂📃📄📅📆📇📈📉📊📋📌📍📎📏📐📒📓📔📕📖📗📘📙📚📛📜📝📞📟📠📡📢📣📤📥📦📧📨📩📪📫📬📭📮📯📰📱📲📳📴📵📶📷📸📹📺📻📼📽📿🔀🔁🔂🔃🔄🔅🔆🔇🔈🔉🔊🔋🔌🔍🔎🔏🔐🔑🔒🔓🔔🔕🔖🔗🔘🔙🔚🔛🔜🔝🔞🔟🔠🔡🔢🔣🔤🔥🔦🔧🔨🔩🔪🔫🔬🔭🔮🔯🔰🔱🔲🔳🔴🔵🔶🔷🔸🔹🔺🔻🔼🔽🕉🕊🕋🕌🕍🕎🕐🕑🕒🕓🕔🕕🕖🕗🕘🕙🕚🕛🕜🕝🕞🕟🕠🕡🕢🕣🕤🕥🕦🕧🕯🕰🕳🕴🕵🕶🕷🕸🕹🕺🖇🖊🖋🖌🖍🖐🖕🖖🖤🖥🖨🖱🖲🖼🗂🗃🗄🗑🗒🗓🗜🗝🗞🗡🗣🗨🗯🗳🗺🗻🗼🗽🗾🗿😀😁😂😃😄😅😆😇😈😉😊😋😌😍😎😏😐😑😒😓😔😕😖😗😘😙😚😛😜😝😞😟😠😡😢😣😤😥😦😧😨😩😪😫😬😭😮😯😰😱😲😳😴😵😶😷😸😹😺😻😼😽😾😿🙀🙁🙂🙃🙄🙅🙆🙇🙈🙉🙊🙌🙍🙎🙏🚀🚁🚂🚃🚄🚅🚆🚇🚈🚉🚊🚋🚌🚍🚎🚏🚐🚑🚒🚓🚔🚕🚖🚗🚘🚙🚚🚛🚜🚝🚞🚟🚠🚡🚢🚣🚤🚥🚦🚧🚨🚩🚪🚫🚬🚭🚮🚯🚰🚱🚲🚳🚴🚵🚶🚷🚸🚹🚺🚻🚼🚽🚾🚿🛀🛁🛂🛃🛄🛅🛋🛌🛍🛎🛏🛐🛑🛒🛠🛡🛢🛣🛤🛥🛩🛫🛬🛰🛳🛴🛵🛶🛷🛸🛹🤐🤑🤒🤓🤔🤕🤖🤗🤘🤙🤚🤛🤜🤝🤞🤟🤠🤡🤢🤣🤤🤥🤦🤧🤨🤩🤪🤫🤬🤭🤮🤯🤰🤱🤲🤳🤴🤵🤶🤷🤸🤹🤺🤼🤽🤾🥀🥁🥂🥃🥄🥅🥇🥈🥉🥊🥋🥌🥍🥎🥏🥐🥑🥒🥓🥔🥕🥖🥗🥘🥙🥚🥛🥜🥝🥞🥟🥠🥡🥢🥣🥤🥥🥦🥧🥨🥩🥪🥫🥬🥭🥮🥯🥰🥳🥴🥵🥶🥺🥼🥽🥾🥿🦀🦁🦂🦃🦄🦅🦆🦇🦈🦉🦊🦋🦌🦍🦎🦏🦐🦑🦒🦓🦔🦕🦖🦗🦘🦙🦚🦛🦜🦝🦞🦟🦠🦡🦢🦰🦱🦲🦳🦴🦵🦶🦷🦸🦹🧀🧁🧂🧐🧑🧒🧓🧔🧕"]; + this.padChars.emojis_v1 = [ "⚜", "🏍", "📑", "🙋", "☕" ]; + + this.charsets.emojis_v2 = [..."🀄🃏⏰⏳☔♈♉♊♋♌♍♎♏♐♑♒♓♿⚓⚡⚽⚾⛄⛅⛎⛔⛪⛲⛳⛵⛺⛽✊✋✨⭐🛕🛖🛗🛝🛞🛟🛺🈁🛻🤌🤏🤿🥱🥲🥸🥹🥻🦣🦤🦥🦦🦧🌀🌁🌂🌃🌄🌅🌆🌇🌈🌉🌊🌋🌌🌍🌎🌏🌐🌑🌒🌓🌔🌕🌖🌗🌘🌙🌚🌛🌜🌝🌞🌟🌠🦨🦩🦪🦫🦬🦭🦮🦯🦺🦻🌭🌮🌯🌰🌱🌲🌳🌴🌵🦼🌷🌸🌹🌺🌻🌼🌽🌾🌿🍀🍁🍂🍃🍄🍅🍆🍇🍈🍉🍊🍋🍌🍍🍎🍏🍐🍑🍒🍓🍔🍕🍖🍗🍘🍙🍚🍛🍜🍝🍞🍟🍠🍡🍢🍣🍤🍥🍦🍧🍨🍩🍪🍫🍬🍭🍮🍯🍰🍱🍲🍳🍴🍵🍶🍷🍸🍹🍺🍻🍼🦽🍾🍿🎀🎁🎂🎃🎄🎅🎆🎇🎈🎉🎊🎋🎌🎍🎎🎏🎐🎑🎒🎓🦾🦿🧃🧄🧅🧆🧇🎠🎡🎢🎣🎤🎥🧈🎧🎨🎩🎪🎫🎬🎭🎮🎯🎰🎱🎲🎳🎴🎵🎶🎷🎸🎹🎺🎻🎼🎽🎾🎿🏀🏁🏂🏃🏄🏅🏆🏇🏈🏉🏊🧉🧊🧋🏏🏐🏑🏒🏓🧌🧍🧎🧏🧖🧗🧘🧙🧚🧛🧜🧝🏠🏡🏢🏣🏤🏥🏦🧞🏨🏩🏪🏫🏬🏭🏮🏯🏰🧟🏴🧠🧢🏸🏹🏺🧣🧤🧥🧦🧧🐀🐁🐂🐃🐄🐅🐆🐇🐈🐉🐊🐋🐌🐍🐎🐏🐐🐑🐒🐓🐔🐕🐖🐗🐘🐙🐚🐛🐜🐝🐞🐟🐠🐡🐢🐣🐤🐥🐦🐧🐨🐩🐪🐫🐬🐭🐮🐯🐰🐱🐲🐳🐴🐵🐶🐷🐸🐹🐺🐻🐼🐽🐾🧨👀🧩👂👃👄👅👆👇👈👉👊👋👌👍👎👏👐👑👒👓👔👕👖👗👘👙👚👛👜👝👞👟👠👡👢👣👤👥👦👧👨👩👪👫👬👭👮👯👰👱👲👳👴👵👶👷👸👹👺👻👼👽👾👿💀💁💂💃💄💅💆💇💈💉💊💋💌💍💎💏💐💑💒💓💔💕💖💗💘💙💚💛💜💝💞💟💠💡💢💣💤💥💦💧💨💩💪💫💬💭💮💯💰💱💲💳💴💵💶💷💸🧪💺💻💼💽💾💿📀🧫📂📃📄🧬📆📇📈📉📊📋📌📍📎📏📐📒📓📔📕📖📗📘📙📚📛📜📝📞📟📠📡📢📣📤📥📦📧📨📩📪📫📬📭📮📯📰📱📲📳🧭📵📶📷📸📹📺📻📼🧮📿🧯🧰🧱🧲🧳🔅🔆🔇🔈🔉🔊🔋🔌🔍🔎🔏🔐🔑🔒🔓🔔🔕🔖🔗🔘🧴🧵🧶🧷🧸🧹🧺🧻🧼🧽🧾🧿🔥🔦🔧🔨🔩🔪🔫🔬🔭🔮🔯🔰🔱🔲🔳🩰🩱🩲🩳🩴🩸🩹🩺🩻🩼🪀🪁🕋🕌🕍🕎🪂🪃🪄🪅🪆🪐🪑🪒🪓🪔🪕🪖🪗🪘🪙🪚🪛🪜🪝🪞🪟🪠🪡🪢🪣🪤🪥🪦🪧🪨🪩🪪🪫🕺🪬🪰🪱🪲🪳🪴🖕🖖🖤🪵🪶🪷🪸🪹🪺🫀🫁🫂🫃🫄🫅🫐🫑🫒🫓🫔🫕🫖🫗🗻🗼🗽🗾🗿😀😁😂😃😄😅😆😇😈😉😊😋😌😍😎😏😐😑😒😓😔😕😖😗😘😙😚😛😜😝😞😟😠😡😢😣😤😥😦😧😨😩😪😫😬😭😮😯😰😱😲😳😴😵😶😷😸😹😺😻😼😽😾😿🙀🙁🙂🙃🙄🙅🙆🙇🙈🙉🙊🙌🙍🙎🙏🚀🚁🚂🚃🚄🚅🚆🚇🚈🚉🚊🚋🚌🚍🚎🚏🚐🚑🚒🚓🚔🚕🚖🚗🚘🚙🚚🚛🚜🚝🚞🚟🚠🚡🚢🚣🚤🚥🚦🚧🚨🚩🚪🚫🚬🚭🚮🚯🚰🚱🚲🚳🚴🚵🚶🚷🚸🚹🚺🚻🚼🚽🚾🚿🛀🛁🛂🛃🛄🛅🫘🛌🫙🫠🫡🛐🛑🛒🫢🫣🫤🫥🫦🫧🫰🛫🛬🫱🫲🛴🛵🛶🛷🛸🛹🤐🤑🤒🤓🤔🤕🤖🤗🤘🤙🤚🤛🤜🤝🤞🤟🤠🤡🤢🤣🤤🤥🤦🤧🤨🤩🤪🤫🤬🤭🤮🤯🤰🤱🤲🤳🤴🤵🤶🤷🤸🤹🤺🤼🤽🤾🥀🥁🥂🥃🥄🥅🥇🥈🥉🥊🥋🥌🥍🥎🥏🥐🥑🥒🥓🥔🥕🥖🥗🥘🥙🥚🥛🥜🥝🥞🥟🥠🥡🥢🥣🥤🥥🥦🥧🥨🥩🥪🥫🥬🥭🥮🥯🥰🥳🥴🥵🥶🥺🥼🥽🥾🥿🦀🦁🦂🦃🦄🦅🦆🦇🦈🦉🦊🦋🦌🦍🦎🦏🦐🦑🦒🦓🦔🦕🦖🦗🦘🦙🦚🦛🦜🦝🦞🦟🦠🦡🦢🫳🫴🫵🫶🦴🦵🦶🦷🦸🦹🧀🧁🧂🧐🧑🧒🧓🧔🧕"]; + this.padChars.emojis_v2 = [ "🥷", "🛼", "📑", "🙋", "☕" ]; + + // init mapping for decoding particularities of the two versions + this.#init(); + + // converter + this.converter = new BaseConverter(1024, 5, 4); - this.charsets.default = "0123456789abcdefghijklmnopqrstuvwxyz".substring(0, radix); - // predefined settings - this.converter = new BaseConverter(radix, 0, 0); - this.hasSignedMode = true; - this.littleEndian = !(radix === 2 || radix === 16); - this.signed = true; - this.version = "default"; + this.padding = true; + this.padCharAmount = 5; + this.version = "emojis_v1"; - // list of allowed/disallowed args to change - this.isMutable.littleEndian = true, - this.isMutable.upper = true; + // mutable extra args + this.isMutable.padding = true; + this.isMutable.trim = true; + // set trim option + this.trim = null; + this.utils.converterArgs.trim = ["notrim", "trim"]; + // apply user settings this.utils.validateArgs(args, true); + + if (this.trim === null) { + this.trim = this.version === "emojis_v2"; + } } - + + + /** + * Analyzes v1 and two charsets for equal and non + * equal characters to create a "revEmojiObj" for + * decoding lookup. Also generates a RegExp object + * for handling concatenated strings. + */ + #init() { + + // Stores all padding for a regex generation. + const padAll = {}; + + // Creates an object which holds all characters + // of both versions. Unique chars for version one + // are getting the version value "1", version two "2" + // and overlaps "3". + const revEmojisAdd = (version, set) => { + set.forEach((char) => { + if (char in this.#revEmojiVersion) { + this.#revEmojiVersion[char].version += version; + } else { + this.#revEmojiVersion[char] = { version }; + } + }); + }; + + // This function adds a padding character of both + // versions to the object, with additional information + // about the padding type. In this process each unique + // padChar is also added to the "padAll" object. + const handlePadding = (version, set, type) => { + set.forEach(padChar => { + + if (padChar in padAll) { + this.#revEmojiVersion[padChar].version = 3; + } else { + this.#revEmojiVersion[padChar] = { + version, + padding: type + }; + padAll[padChar] = type; + } + }); + }; + + revEmojisAdd(1, this.charsets.emojis_v1); + revEmojisAdd(2, this.charsets.emojis_v2); + + handlePadding(1, this.padChars.emojis_v1.slice(0, -1), "last"); + handlePadding(2, this.padChars.emojis_v2.slice(0, -1), "last"); + handlePadding(1, this.padChars.emojis_v1.slice(-1), "fill"); + handlePadding(2, this.padChars.emojis_v2.slice(-1), "fill"); + + + // Create an array of keys for the final regex + const regexArray = []; + + for (const padChar in padAll) { + if (padAll[padChar] === "last") { + regexArray.push(padChar); + } else { + regexArray.push(`${padChar}+`); + } + } + + // create a regex obj for matching all pad chars + this.#padRegex = new RegExp(regexArray.join("|"), "g"); + } + + + /** + * BaseEx Ecoji Encoder. + * @param {*} input - Input according to the used byte converter. + * @param {...str} [args] - Converter settings. + * @returns {string} - Ecoji encoded string. + */ encode(input, ...args) { - return super.encode(input, null, null, ...args); + + const applyPadding = ({ output, settings, zeroPadding }) => { + + const charset = this.charsets[settings.version]; + let outArray = [...output]; + + if (zeroPadding > 1) { + const padValue = this.converter.padBytes(zeroPadding); + if (settings.padding) { + const padLen = settings.trim ? 1 : padValue; + const padArr = new Array(padLen).fill(this.padChars[settings.version].at(-1)); + outArray.splice(outArray.length-padValue, padValue, ...padArr); + } else { + outArray.splice(outArray.length-padValue, padValue); + } + } + + else if (zeroPadding === 1) { + const lastVal = charset.indexOf(outArray.pop()); + const x = lastVal >> 8; + outArray.push(this.padChars[settings.version].at(x)); + } + + return outArray.join(""); + }; + + return super.encode(input, null, applyPadding, ...args); } - decode(rawInput, ...args) { + + /** + * BaseEx Ecoji Decoder. + * @param {string} input - Ecoji String. + * @param {...any} [args] - Converter settings. + * @returns {*} - Output according to converter settings. + */ + decode(input, ...args) { - // pre decoding function - const normalizeInput = (scope) => { + // Argument validation and output settings + const settings = this.utils.validateArgs(args); + input = this.utils.normalizeInput(input); - let { input } = scope; + let version = settings.version; + let versionKey = null; - // normalize input (add leading zeros) for base 2 and 16 - if (this.converter.radix === 2) { - const leadingZeros = (8 - (input.length % 8)) % 8; - input = `${"0".repeat(leadingZeros)}${input}`; - } else if (this.converter.radix === 16) { - const leadingZeros = input.length % 2; - input = `${"0".repeat(leadingZeros)}${input}`; + if (settings.version === "emojis_v1" || settings.version === "emojis_v2") { + // versionKey can be both v1 or v2 + versionKey = 3; + } + + // the actual decoding is wrapped in a function + // for the possibility to call it multiple times + const decode = (input) => { + + if (versionKey !== null) { + versionKey = this.#preDecode(input, versionKey, settings.integrity); + version = (versionKey === 3) + ? settings.version + : `emojis_v${versionKey}`; } - return input; + const charset = this.charsets[version]; + + const inArray = [...input]; + const lastChar = inArray.at(-1); + let skipLast = false; + + for (let i=0; i { + const end = match.index + match.at(0).length; + preOutArray.push(...decode(input.slice(start, end))); + start = end; + }); + + // in case the last group has no padding, it is not yet + // decoded -> do it now + if (start !== input.length) { + preOutArray.push(...decode(input.slice(start, input.length))); + } + + output = Uint8Array.from(preOutArray); + } + + return this.utils.outputHandler.compile(output, settings.outputType); } -} -/** - * [BaseEx]{@link https://github.com/UmamiAppearance/BaseExJS} - * - * @version 0.4.3 - * @author UmamiAppearance [mail@umamiappearance.eu] - * @license GPL-3.0 AND BSD-3-Clause (only regarding Base91, Copyright (c) 2000-2006 Joachim Henke) - */ + /** + * Determines the version (1/2) and analyzes the input for integrity. + * @param {string} input - Input string. + * @param {number} versionKey - Version key from former calls (initially always 3). + * @param {boolean} integrity - If false non standard or wrong padding gets ignored. + * @returns {number} - Version key (1|2|3) + */ + #preDecode(input, versionKey, integrity) { + + const inArray = [...input]; + let sawPadding; + + inArray.forEach((char, i) => { + + if (char in this.#revEmojiVersion) { + + const charVersion = this.#revEmojiVersion[char].version; + + // version changes can only happen if the char is + // not in both versions (not 3) + if (charVersion !== 3) { + if (versionKey === 3) { + versionKey = charVersion; + } else if (versionKey !== charVersion) { + throw new TypeError(`Emojis from different ecoji versions seen : ${char} from emojis_v${charVersion}`); + } + } + + // analyze possible wrong padding if integrity checks + // are enabled + if (integrity) { + const padding = this.#revEmojiVersion[char].padding; + if (padding) { + + // index relative to a group of four bytes + const relIndex = i%4; + sawPadding = true; + + if (padding === "fill") { + if (relIndex === 0) { + throw new TypeError(`Padding unexpectedly seen in first position ${char}`); + } + } else if (relIndex !== 3) { + throw new TypeError(`Last padding seen in unexpected position ${char}`); + } + } + + else if (sawPadding) { + throw new TypeError("Unexpectedly saw non-padding after padding"); + } + } + + } else { + throw new DecodingError(char); + } + }); + + // lastly test for invalid string + if (integrity && inArray.length % 4) { + if ( + versionKey === 1 || + this.#revEmojiVersion[inArray.at(-1)].padding !== "fill" + ) { + throw new TypeError("Unexpected end of data, input data size not multiple of 4"); + } + } + + return versionKey; + } +} + +/** + * [BaseEx|Base2048 Converter]{@link https://github.com/UmamiAppearance/BaseExJS/blob/main/src/converters/base-2048.js} + * + * @version 0.6.1 + * @author UmamiAppearance [mail@umamiappearance.eu] + * @license GPL-3.0 AND MIT (Base2048, Copyright (c) 2017 qntm) + */ + +/** + * BaseEx Base 2048 Converter. + * ------------------------ + * This is a base2048/converter. Various input can be + * converted to a hex string or a hex string can be + * decoded into various formats. It is possible to + * convert in both signed and unsigned mode. + * + * @see https://github.com/qntm/base2048 + */ +class Base2048 extends BaseTemplate { + + /** + * BaseEx Base2048 Constructor. + * @param {...string} [args] - Converter settings. + */ + constructor(...args) { + super(); + + // converter (properties only) + this.converter = { + radix: 2048, + bsEnc: 11, + bsEncPad: 3, + bsDec: 8 + }; + + // default settings + this.charsets.default = [..."89ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyzÆÐØÞßæðøþĐđĦħıĸŁłŊŋŒœŦŧƀƁƂƃƄƅƆƇƈƉƊƋƌƍƎƏƐƑƒƓƔƕƖƗƘƙƚƛƜƝƞƟƢƣƤƥƦƧƨƩƪƫƬƭƮƱƲƳƴƵƶƷƸƹƺƻƼƽƾƿǀǁǂǃǝǤǥǶǷȜȝȠȡȢȣȤȥȴȵȶȷȸȹȺȻȼȽȾȿɀɁɂɃɄɅɆɇɈɉɊɋɌɍɎɏɐɑɒɓɔɕɖɗɘəɚɛɜɝɞɟɠɡɢɣɤɥɦɧɨɩɪɫɬɭɮɯɰɱɲɳɴɵɶɷɸɹɺɻɼɽɾɿʀʁʂʃʄʅʆʇʈʉʊʋʌʍʎʏʐʑʒʓʔʕʖʗʘʙʚʛʜʝʞʟʠʡʢʣʤʥʦʧʨʩʪʫʬʭʮʯͰͱͲͳͶͷͻͼͽͿΑΒΓΔΕΖΗΘΙΚΛΜΝΞΟΠΡΣΤΥΦΧΨΩαβγδεζηθικλμνξοπρςστυφχψωϏϗϘϙϚϛϜϝϞϟϠϡϢϣϤϥϦϧϨϩϪϫϬϭϮϯϳϷϸϺϻϼϽϾϿЂЄЅІЈЉЊЋЏАБВГДЕЖЗИКЛМНОПРСТУФХЦЧШЩЪЫЬЭЮЯабвгдежзиклмнопрстуфхцчшщъыьэюяђєѕіјљњћџѠѡѢѣѤѥѦѧѨѩѪѫѬѭѮѯѰѱѲѳѴѵѸѹѺѻѼѽѾѿҀҁҊҋҌҍҎҏҐґҒғҔҕҖҗҘҙҚқҜҝҞҟҠҡҢңҤҥҦҧҨҩҪҫҬҭҮүҰұҲҳҴҵҶҷҸҹҺһҼҽҾҿӀӃӄӅӆӇӈӉӊӋӌӍӎӏӔӕӘәӠӡӨөӶӷӺӻӼӽӾӿԀԁԂԃԄԅԆԇԈԉԊԋԌԍԎԏԐԑԒԓԔԕԖԗԘԙԚԛԜԝԞԟԠԡԢԣԤԥԦԧԨԩԪԫԬԭԮԯԱԲԳԴԵԶԷԸԹԺԻԼԽԾԿՀՁՂՃՄՅՆՇՈՉՊՋՌՍՎՏՐՑՒՓՔՕՖաբգդեզէըթժիլխծկհձղճմյնշոչպջռսվտրցւփքօֆאבגדהוזחטיךכלםמןנסעףפץצקרשתװױײؠءابةتثجحخدذرزسشصضطظعغػؼؽؾؿفقكلمنهوىي٠١٢٣٤٥٦٧٨٩ٮٯٱٲٳٴٹٺٻټٽپٿڀځڂڃڄڅچڇڈډڊڋڌڍڎڏڐڑڒړڔڕږڗژڙښڛڜڝڞڟڠڡڢڣڤڥڦڧڨکڪګڬڭڮگڰڱڲڳڴڵڶڷڸڹںڻڼڽھڿہۃۄۅۆۇۈۉۊۋیۍێۏېۑےەۮۯ۰۱۲۳۴۵۶۷۸۹ۺۻۼۿܐܒܓܔܕܖܗܘܙܚܛܜܝܞܟܠܡܢܣܤܥܦܧܨܩܪܫܬܭܮܯݍݎݏݐݑݒݓݔݕݖݗݘݙݚݛݜݝݞݟݠݡݢݣݤݥݦݧݨݩݪݫݬݭݮݯݰݱݲݳݴݵݶݷݸݹݺݻݼݽݾݿހށނރބޅކއވމފދތލގޏސޑޒޓޔޕޖޗޘޙޚޛޜޝޞޟޠޡޢޣޤޥޱ߀߁߂߃߄߅߆߇߈߉ߊߋߌߍߎߏߐߑߒߓߔߕߖߗߘߙߚߛߜߝߞߟߠߡߢߣߤߥߦߧߨߩߪࠀࠁࠂࠃࠄࠅࠆࠇࠈࠉࠊࠋࠌࠍࠎࠏࠐࠑࠒࠓࠔࠕࡀࡁࡂࡃࡄࡅࡆࡇࡈࡉࡊࡋࡌࡍࡎࡏࡐࡑࡒࡓࡔࡕࡖࡗࡘࡠࡡࡢࡣࡤࡥࡦࡧࡨࡩࡪࢠࢡࢢࢣࢤࢥࢦࢧࢨࢩࢪࢫࢬࢭࢮࢯࢰࢱࢲࢳࢴࢶࢷࢸࢹࢺࢻࢼࢽऄअआइईउऊऋऌऍऎएऐऑऒओऔकखगघङचछजझञटठडढणतथदधनपफबभमयरलळवशषसहऽॐॠॡ०१२३४५६७८९ॲॳॴॵॶॷॸॹॺॻॼॽॾॿঀঅআইঈউঊঋঌএঐওঔকখগঘঙচছজঝঞটঠডঢণতথদধনপফবভমযরলশষসহঽৎৠৡ০১২৩৪৫৬৭৮৯ৰৱ৴৵৶৷৸৹ৼਅਆਇਈਉਊਏਐਓਔਕਖਗਘਙਚਛਜਝਞਟਠਡਢਣਤਥਦਧਨਪਫਬਭਮਯਰਲਵਸਹੜ੦੧੨੩੪੫੬੭੮੯ੲੳੴઅઆઇઈઉઊઋઌઍએઐઑઓઔકખગઘઙચછજઝઞટઠડઢણતથદધનપફબભમયરલળવશષસહઽૐૠૡ૦૧૨૩૪૫૬૭૮૯ૹଅଆଇଈଉଊଋଌଏଐଓଔକଖଗଘଙଚଛଜଝଞଟଠଡଢଣତଥଦଧନପଫବଭମଯରଲଳଵଶଷସହଽୟୠୡ୦୧୨୩୪୫୬୭୮୯ୱ୲୳୴୵୶୷ஃஅஆஇஈஉஊஎஏஐஒஓகஙசஜஞடணதநனபமயரறலளழவஶஷஸஹௐ௦௧௨௩௪௫௬௭௮௯௰௱௲అఆఇఈఉఊఋఌఎఏఐఒఓఔకఖగఘఙచఛజఝఞటఠడఢణతథదధనపఫబభమయరఱలళఴవశషసహఽౘౙౚౠౡ౦౧౨౩౪౫౬౭౮౯౸౹౺౻౼౽౾ಀಅಆಇಈಉಊಋಌಎಏಐಒಓಔಕಖಗಘಙಚಛಜಝಞಟಠಡಢಣತಥದಧನಪಫಬಭಮಯರಱಲಳವಶಷಸಹಽೞೠೡ೦೧೨೩೪೫೬೭೮೯ೱೲഅആഇഈഉഊഋഌഎഏഐഒഓഔകഖഗഘങചഛജഝഞടഠഡഢണതഥദധനഩപഫബഭമയരറലളഴവശഷസഹഺഽൎൔൕൖ൘൙൚൛൜൝൞ൟൠൡ൦൧൨൩൪൫൬൭൮൯൰൱൲൳൴൵൶൷൸ൺൻർൽൾൿඅආඇඈඉඊඋඌඍඎඏඐඑඒඓඔඕඖකඛගඝඞඟචඡජඣඤඥඦටඨඩඪණඬතථදධනඳපඵබභමඹයරලවශෂසහළෆ෦෧෨෩෪෫෬෭෮෯กขฃคฅฆงจฉชซฌญฎฏฐฑฒณดตถทธนบปผฝพฟภมยรฤลฦวศษสหฬอฮฯะาเแโใไๅ๐๑๒๓๔๕๖๗๘๙ກຂຄງຈຊຍດຕຖທນບປຜຝພຟມຢຣລວສຫອຮຯະາຽເແໂໃໄ໐໑໒໓໔໕໖໗໘໙ໞໟༀ༠༡༢༣༤༥༦༧༨༩༪༫༬༭༮༯༰༱༲༳ཀཁགངཅཆཇཉཊཋཌཎཏཐདནཔཕབམཙཚཛཝཞཟའཡརལཤཥསཧཨཪཫཬྈྉྊྋྌကခဂဃငစဆဇဈဉညဋဌဍဎဏတထဒဓနပဖဗဘမယရလဝသဟဠအဢဣဤဥဧဨဩဪဿ၀၁၂၃၄၅၆၇၈၉ၐၑၒၓၔၕ"]; + this.padChars.default = [..."01234567"]; + + this.padCharAmount = 8; + this.hasSignedMode = true; + this.littleEndian = false; + + // apply user settings + this.utils.validateArgs(args, true); + } + + + /** + * BaseEx Base2048 Encoder. + * @param {*} input - Input according to the used byte converter. + * @param {...str} [args] - Converter settings. + * @returns {string} - Base2048 encoded string. + */ + encode(input, ...args) { + + const settings = this.utils.validateArgs(args); + let inputBytes = this.utils.inputHandler.toBytes(input, settings).at(0); + + const charset = this.charsets[settings.version]; + const padChars = this.padChars[settings.version]; + + let output = ""; + let z = 0; + let numZBits = 0; + + inputBytes.forEach(uint8 => { + + for (let i=this.converter.bsDec-1; i>=0; i--) { + + z = (z << 1) + ((uint8 >> i) & 1); + numZBits++; + + if (numZBits === this.converter.bsEnc) { + output += charset.at(z); + z = 0; + numZBits = 0; + } + } + }); + + if (numZBits !== 0) { + + let bitCount; + let isPadding; + + if (numZBits <= this.converter.bsEncPad) { + bitCount = this.converter.bsEncPad; + isPadding = true; + } else { + bitCount = this.converter.bsEnc; + isPadding = false; + } + + while (numZBits !== bitCount) { + z = (z << 1) + 1; + numZBits++; + if (numZBits > this.converter.bsEnc) { + throw new Error("Cannot process input. This is a bug!"); + } + } + + if (isPadding) { + output += padChars.at(z); + } else { + output += charset.at(z); + } + } + + return this.utils.wrapOutput(output, settings.options.lineWrap); + } + + + /** + * BaseEx Base2048 Decoder. + * @param {string} input - Base2048/Hex String. + * @param {...any} [args] - Converter settings. + * @returns {*} - Output according to converter settings. + */ + decode(input, ...args) { + + // apply settings + const settings = this.utils.validateArgs(args); + + // ensure a string input + input = this.utils.normalizeInput(input); + const inArray = [...input]; + + const charset = this.charsets[settings.version]; + const padChars = this.padChars[settings.version]; + + const byteArray = new Array(); + let uint8 = 0; + let numUint8Bits = 0; + + inArray.forEach((c, i) => { + + let numZBits; + let z = charset.indexOf(c); + if (z > -1) { + numZBits = this.converter.bsEnc; + } else { + z = padChars.indexOf(c); + + if (z > -1) { + if (i+1 !== inArray.length) { + throw new DecodingError(null, `Secondary character found before end of input, index: ${i}`); + } + + numZBits = this.converter.bsEncPad; + } + + else if (settings.integrity) { + throw new DecodingError(c); + } + } + + // Take most significant bit first + for (let j=numZBits-1; j>=0; j--) { + + uint8 = (uint8 << 1) + ((z >> j) & 1); + numUint8Bits++; + + if (numUint8Bits === this.converter.bsDec) { + byteArray.push(uint8); + uint8 = 0; + numUint8Bits = 0; + } + } + }); + + return this.utils.outputHandler.compile( + Uint8Array.from(byteArray), + settings.outputType + ); + } +} + +/** + * [BaseEx|SimpleBase Converter]{@link https://github.com/UmamiAppearance/BaseExJS/blob/main/src/converters/simple-base.js} + * + * @version 0.6.1 + * @author UmamiAppearance [mail@umamiappearance.eu] + * @license GPL-3.0 + */ + + +/** + * BaseEx SimpleBase Converter. + * --------------------------- + * SimpleBase provides the simple mathematical base + * conversion as known from (n).toString(radix) and + * parseInt(n, radix). + * + * The constructor needs a radix between 2-62 as the + * first argument. In other regards it behaves pretty + * much as any other converter. + */ +class SimpleBase extends BaseTemplate { + + /** + * SimpleBase Constructor. + * @param {number} radix - Radix between 2 and 62 + * @param {...any} args - Converter settings. + */ + constructor(radix, ...args) { + super(); + + if (!radix || !Number.isInteger(radix) || radix < 2 || radix > 62) { + throw new RangeError("Radix argument must be provided and has to be an integer between 2 and 62.") + } + this.converter = new BaseConverter(radix, 0, 0); + + + // charsets + this.charsets.default = [..."0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ"].slice(0, radix); + + + // predefined settings + this.frozenCharsets = true; + this.hasSignedMode = true; + this.littleEndian = !(radix === 2 || radix === 16); + this.signed = true; + this.version = "default"; + + // list of allowed/disallowed args to change + this.isMutable.littleEndian = true, + this.isMutable.upper = radix <= 36; + + // apply user settings + this.utils.validateArgs(args, true); + } + + + /** + * BaseEx SimpleBase Encoder. + * @param {*} input - Input according to the used byte converter. + * @param {...any} [args] - Converter settings. + * @returns {string} - Base 2-62 encoded string. + */ + encode(input, ...args) { + return super.encode(input, null, null, ...args); + } + + + /** + * BaseEx SimpleBase Decoder. + * @param {string} input - Base 2-62 String. + * @param {...any} [args] - Converter settings. + * @returns {*} - Output according to converter settings. + */ + decode(rawInput, ...args) { + + // pre decoding function + const normalizeInput = ({ input }) => { + + // normalize input (add leading zeros) for base 2 and 16 + if (this.converter.radix === 2) { + const leadingZeros = (8 - (input.length % 8)) % 8; + input = `${"0".repeat(leadingZeros)}${input}`; + } else if (this.converter.radix === 16) { + const leadingZeros = input.length % 2; + input = `${"0".repeat(leadingZeros)}${input}`; + } + + return input; + }; + + return super.decode(rawInput, normalizeInput, null, false, ...args); + + } +} + +/** + * big.js v6.2.1 // Copyright (c) 2022 Michael Mclaughlin // https://github.com/MikeMcl/big.js/LICENCE.md // Modified (reduced) and minified for BaseEx + */ +let DP=20,RM=1,MAX_DP=1e6,NE=-7,PE=21,STRICT=!1,NAME="[big.js] ",INVALID=NAME+"Invalid ",INVALID_DP=INVALID+"decimal places",INVALID_RM=INVALID+"rounding mode",P={},NUMERIC=/^-?(\d+(\.\d*)?|\.\d+)(e[+-]?\d+)?$/i;function _Big_(){function Big(n){let x=this;if(!(x instanceof Big))return void 0===n?_Big_():new Big(n);if(n instanceof Big)x.s=n.s,x.e=n.e,x.c=n.c.slice();else {if("string"!=typeof n){if(!0===Big.strict&&"bigint"!=typeof n)throw TypeError(INVALID+"value");n=0===n&&1/n<0?"-0":String(n);}parse(x,n);}x.constructor=Big;}return Big.prototype=P,Big.DP=DP,Big.RM=RM,Big.NE=NE,Big.PE=PE,Big.strict=STRICT,Big.roundDown=0,Big.roundHalfUp=1,Big.roundHalfEven=2,Big.roundUp=3,Big}function parse(x,n){let e,i,nl;if(!NUMERIC.test(n))throw Error(`${INVALID}number`);for(x.s="-"==n.charAt(0)?(n=n.slice(1),-1):1,(e=n.indexOf("."))>-1&&(n=n.replace(".","")),(i=n.search(/e/i))>0?(e<0&&(e=i),e+=+n.slice(i+1),n=n.substring(0,i)):e<0&&(e=n.length),nl=n.length,i=0;i0&&"0"==n.charAt(--nl););for(x.e=e-i-1,x.c=[],e=0;i<=nl;)x.c[e++]=+n.charAt(i++);}return x}function round(x,sd,rm,more){let xc=x.c;if(void 0===rm&&(rm=x.constructor.RM),0!==rm&&1!==rm&&2!==rm&&3!==rm)throw Error(INVALID_RM);if(sd<1)more=3===rm&&(more||!!xc[0])||0===sd&&(1===rm&&xc[0]>=5||2===rm&&(xc[0]>5||5===xc[0]&&(more||void 0!==xc[1]))),xc.length=1,more?(x.e=x.e-sd+1,xc[0]=1):xc[0]=x.e=0;else if(sd=5||2===rm&&(xc[sd]>5||5===xc[sd]&&(more||void 0!==xc[sd+1]||1&xc[sd-1]))||3===rm&&(more||!!xc[0]),xc.length=sd,more)for(;++xc[--sd]>9;)if(xc[sd]=0,0===sd){++x.e,xc.unshift(1);break}for(sd=xc.length;!xc[--sd];)xc.pop();}return x}function stringify(x,doExponential,isNonzero){let e=x.e,s=x.c.join(""),n=s.length;if(doExponential)s=s.charAt(0)+(n>1?"."+s.slice(1):"")+(e<0?"e":"e+")+e;else if(e<0){for(;++e;)s="0"+s;s="0."+s;}else if(e>0)if(++e>n)for(e-=n;e--;)s+="0";else e1&&(s=s.charAt(0)+"."+s.slice(1));return x.s<0&&isNonzero?"-"+s:s}P.abs=function(){let x=new this.constructor(this);return x.s=1,x},P.cmp=function(y){let isneg,x=this,xc=x.c,yc=(y=new x.constructor(y)).c,i=x.s,j=y.s,k=x.e,l=y.e;if(!xc[0]||!yc[0])return xc[0]?i:yc[0]?-j:0;if(i!=j)return i;if(isneg=i<0,k!=l)return k>l^isneg?1:-1;for(j=(k=xc.length)<(l=yc.length)?k:l,i=-1;++iyc[i]^isneg?1:-1;return k==l?0:k>l^isneg?1:-1},P.eq=function(y){return 0===this.cmp(y)},P.gt=function(y){return this.cmp(y)>0},P.gte=function(y){return this.cmp(y)>-1},P.lt=function(y){return this.cmp(y)<0},P.lte=function(y){return this.cmp(y)<1},P.minus=P.sub=function(y){let i,j,t,xlty,x=this,Big=x.constructor,a=x.s,b=(y=new Big(y)).s;if(a!=b)return y.s=-b,x.plus(y);let xc=x.c.slice(),xe=x.e,yc=y.c,ye=y.e;if(!xc[0]||!yc[0])return yc[0]?y.s=-b:xc[0]?y=new Big(x):y.s=1,y;if(a=xe-ye){for((xlty=a<0)?(a=-a,t=xc):(ye=xe,t=yc),t.reverse(),b=a;b--;)t.push(0);t.reverse();}else for(j=((xlty=xc.length0)for(;b--;)xc[i++]=0;for(b=i;j>a;){if(xc[--j]0?(ye=xe,t=yc):(e=-e,t=xc),t.reverse();e--;)t.push(0);t.reverse();}for(xc.length-yc.length<0&&(t=yc,yc=xc,xc=t),e=yc.length,k=0;e;xc[e]%=10)k=(xc[--e]=xc[e]+yc[e]+k)/10|0;for(k&&(xc.unshift(k),++ye),e=xc.length;0===xc[--e];)xc.pop();return y.c=xc,y.e=ye,y},P.round=function(dp,rm){if(void 0===dp)dp=0;else if(dp!==~~dp||dp<-MAX_DP||dp>MAX_DP)throw Error(INVALID_DP);return round(new this.constructor(this),dp+this.e+1,rm)},P.toFixed=function(dp,rm){let x=this,n=x.c[0];if(void 0!==dp){if(dp!==~~dp||dp<0||dp>MAX_DP)throw Error(INVALID_DP);for(x=round(new x.constructor(x),dp+x.e+1,rm),dp=dp+x.e+1;x.c.length=Big.PE,!!x.c[0])},P.toNumber=function(){let n=Number(stringify(this,!0,!0));if(!0===this.constructor.strict&&!this.eq(n.toString()))throw Error(NAME+"Imprecise conversion");return n};const Big=_Big_(); + +/** + * [BaseEx|BasePhi Converter]{@link https://github.com/UmamiAppearance/BaseExJS/blob/main/src/converters/base-phi.js} + * + * @version 0.6.1 + * @author UmamiAppearance [mail@umamiappearance.eu] + * @license GPL-3.0 + */ + +/** + * BaseEx Base Phi Converter. + * ------------------------ + * + * This is a base phi converter. Various input can be + * converted to a base phi string or a base phi string + * can be decoded into various formats. + * + */ +class BasePhi extends BaseTemplate { + + #Phi = Big("1.618033988749894848204586834365638117720309179805762862135448622705260462818902449707207204189391137484754088075386891752"); + + /** + * BaseEx basE91 Constructor. + * @param {...string} [args] - Converter settings. + */ + constructor(...args) { + super(); + + // converter (properties only) + this.converter = { + radix: 2, // radix is Phi, but the normalized representation allows two chars + bsEnc: 0, + bsDec: 0 + }; + + // base10 converter to have always have a numerical input + this.b10 = new BaseConverter(10, 0, 0); + + // charsets + this.charsets.default = ["0", "1"]; + + this.version = "default"; + this.signed = true; + this.hasDecimalMode = true; + + // apply user settings + this.utils.validateArgs(args, true); + } + + + /** + * BaseEx BasePhi Encoder. + * @param {*} input - Input according to the used byte converter. + * @param {...string} [args] - Converter settings. + * @returns {string} - BasePhi encoded string. + */ + encode(input, ...args) { + + // argument validation and input settings + const settings = this.utils.validateArgs(args); + const charset = this.charsets[settings.version]; + + let inputBytes; + let negative; + let n; + let output = ""; + + // Base Phi allows direct encoding of rational + // and irrational numbers, which can be enabled + // by using the special type "decimal". Input + // type must be "Number" for this mode. + if (settings.decimalMode) { + if (Number.isFinite(input)) { + if (input < 0) { + negative = true; + n = Big(-input); + } else { + negative = false; + n = Big(input); + } + } + + else { + throw new TypeError("When running the converter in decimal-mode, only input of type 'Number' is allowed.") + } + } + + // Every other type first converts the byte representation + // of the input to base 10. + else { + [ inputBytes, negative, ] = this.utils.inputHandler.toBytes(input, settings); + n = Big( + this.b10.encode(inputBytes, null, settings.littleEndian)[0] + ); + } + + // if "n" if 0 or 1 stop here and return 0 or 1 (according to the charset) + if (n.eq(0) || n.eq(1)) { + output = charset[n.toNumber()]; + if (negative) { + output = `-${output}`; + } + return output; + } + + // create two arrays to store all exponents + const exponents = []; + const decExponents = []; + + + // The very first step is to find the highest exponent + // of Phi which fits into "n" (the rounded highest exponent + // is also the highest Lucas number which fits into "n") + // To find the highest fitting exponent start with + // Phi^0 (1) and Phi^1 (Phi). + + let last = Big(1); + let cur = this.#Phi; + let exp = 0; + + // Now add the result with the last higher value "cur", + // util "cur" is bigger than "n" + while (cur.lt(n)) { + [ last, cur ] = this.#nextPhiExp(last, cur); + exp++; + } + + /** + * Recursive reduction function for "n". Finds the largest + * fitting exponent of Phi (Lucas index), stores that index + * in the exponent arrays and reduces "n" by the current exponents + * power. + * Once started, it calls itself until "n" is zero. + * @param {Object} cur - Current result of Phi^exp as a Big.js object. + * @param {Object} prev - Previous result of Phi^exp as a Big.js object. + * @param {number} exp - Exponent of Phi/Lucas index. + */ + const reduceN = (cur, prev, exp) => { + + // Due to the high floating point precision "n" should + // be exactly zero, but if not, an approximation is + // sufficient. + if (this.#approxNull(n)) return; + + // Reduce the exponents of Phi until it power fits into "n" + while (cur.gt(n)) { + [ cur, prev ] = this.#prevPhiExp(cur, prev); + + // if "cur" gets negative return immediately + // prevent an infinite loop + if (cur.lte(0)) { + console.warn("Could not find an exact base-phi representation. Value is approximated."); + return; + } + exp--; + } + + // Store the exponents + if (exp > -1) { + exponents.unshift(exp); + } else { + decExponents.push(exp); + } + + // Reduce "n" + n = n.minus(cur); + + reduceN(cur, prev, exp); + }; + + // Initial call of the reduction function + reduceN(last, cur, exp); + + + // Create a BasePhi string by setting a "1" at every + // index stored in the "exponent" array. for every + // number between two indices a zero is added. + exp = 0; + exponents.forEach(nExp => { + while (exp < nExp) { + output = `${charset[0]}${output}`; + exp++; + } + output = `${charset[1]}${output}`; + exp++; + }); + + // Add a decimal point + if (!output) { + output = "0."; + } else { + output += "."; + } + + // Proceed with the decimal exponents + exp = -1; + decExponents.forEach(nExp => { + while (exp > nExp) { + output += charset[0]; + exp--; + } + output += charset[1]; + exp--; + }); + + // Add a "-" if the input is negative. + if (negative) { + output = `-${output}`; + } + + return output; + } + + + /** + * BaseEx Base Phi Decoder. + * @param {string} input - Base Phi String. + * @param {...any} [args] - Converter settings. + * @returns {*} - Output according to converter settings. + */ + decode(input, ...args) { + + // Argument validation and output settings + const settings = this.utils.validateArgs(args); + const charset = this.charsets[settings.version]; + + let negative; + [ input, negative ] = this.utils.extractSign( + this.utils.normalizeInput(input) + ); + + // remove unwanted characters if integrity is false + if (!settings.integrity) { + const testChars = [...charset, "."]; + input = [...input].filter(c => testChars.includes(c)).join(""); + } + + // Split the input String at the decimal sign + // and initialize a big.js-object with value 0 + const inputSplit = input.split("."); + if (settings.integrity && inputSplit.length > 2) { + throw new DecodingError(null, "There are multiple decimal points in the input."); + } + + const [ posExpStr, decExpStr ] = inputSplit; + let n = Big(0); + + // Initialize two variables "last" and "cur" + // for Phi^exp-1 and Phi^exp + let last = this.#Phi.minus(1); + let cur = Big(1); + + // Convert the left side of the input string + // to an array of chars and reverse it. Raise + // the exponent of Phi and its values until a + // one is found in the array, if a "1" was found + // add the value "cur" to number "n" (one can + // also be another corresponding char of the set + // which represents 1). + [...posExpStr].reverse().forEach((char) => { + const charIndex = charset.indexOf(char); + if (charIndex === 1) { + n = n.plus(cur); + } else if (charIndex !== 0) { + throw new DecodingError(char); + } + [ last, cur ] = this.#nextPhiExp(last, cur); + }); + + // Now also add the values for the decimal places. + if (decExpStr) { + let prev = Big(1); + cur = this.#Phi.minus(prev); + + [...decExpStr].forEach((char) => { + const charIndex = charset.indexOf(char); + if (charIndex === 1) { + n = n.plus(cur); + } else if (charIndex !== 0) { + throw new DecodingError(char); + } + [ cur, prev ] = this.#prevPhiExp(cur, prev); + }); + } + + // If running in decimal mode return n as a Number + if (settings.decimalMode) { + return n.toNumber(); + } + + // For every other case round "n" and turn it + // into a string of an integer. + n = n.round().toFixed(); + + // Use the base 10 decoder to get the byte + // representation of "n". + const output = this.b10.decode(n, [..."0123456789"], [], settings.integrity, settings.littleEndian); + + // Return the output according to the settings. + return this.utils.outputHandler.compile(output, settings.outputType, settings.littleEndian, negative); + } + + /** + * Test if n is approximately zero. + * @param {Object} n - Big.js Object. + * @returns {Boolean} + */ + #approxNull(n) { + return !(n.round(50) + .abs() + .toNumber() + ); + } + + /** + * Get the results of of the following exponents of Phi + * from the predecessors. + * @param {Object} last - Phi^exp-1 as a big.js-object + * @param {Object} cur - Phi^exp as a big.js-object + * @returns {Object[]} - Array with Phi^exp and Phi^exp+1 + */ + #nextPhiExp(last, cur) { + return [ cur, last.plus(cur) ]; + } + + /** + * Get the results of of the previous exponents of Phi + * from the predecessors. + * @param {Object} cur - Phi^exp as a big.js-object + * @param {Object} prev - Phi^exp-1 as a big.js-object + * @returns {Object[]} - Array with Phi^exp-1 and Phi^exp + */ + #prevPhiExp(cur, prev) { + return [ prev.minus(cur), cur ]; + } +} + +/** + * [BaseEx|Byte Converter]{@link https://github.com/UmamiAppearance/BaseExJS/blob/main/src/converters/byte-converter.js} + * + * @version 0.6.1 + * @author UmamiAppearance [mail@umamiappearance.eu] + * @license GPL-3.0 + */ + +// Endianness of the system +const LITTLE_ENDIAN = (() => { + const testInt = new Uint16Array([1]); + const byteRepresentation = new Uint8Array(testInt.buffer); + return Boolean(byteRepresentation.at(0)); +})(); + + +/** + * BaseEx Byte Converter. + * --------------------- + * + * This is a byte converter. Various input can be + * converted to a bytes or bytes can be decoded into + * various formats. + * + * As en- and decoder were already available, for the + * use of converting in- and output for the base + * converters, this is just a little extra tool, which + * was fast and easy to create. + */ +class ByteConverter { + + /** + * BaseEx ByteConverter Constructor. + * @param {...string} [args] - Converter settings. + */ + constructor(...args) { + + // predefined settings + this.littleEndian = LITTLE_ENDIAN; + this.numberMode = false; + this.outputType = "buffer"; + + // simplified utils + this.utils = { + validateArgs: (args, initial=false) => { + + const parameters = { + littleEndian: this.littleEndian, + numberMode: this.numberMode, + outputType: this.outputType, + signed: false, + }; + + if (!args.length) { + return parameters; + } + + if (args.includes("number")) { + args.splice(args.indexOf("number"), 1); + parameters.numberMode = true; + parameters.outputType = "float_n"; + } + + const outTypes = SmartOutput.typeList.map(s => `'${s}'`).join(", "); + + args.forEach((arg) => { + arg = String(arg).toLowerCase(); + + if (arg === "le") { + parameters.littleEndian = true; + } else if (arg === "be") { + parameters.littleEndian = false; + } else if (SmartOutput.typeList.includes(arg)) { + parameters.outputType = arg; + } else { + throw new TypeError(`Invalid argument: '${arg}.\nValid arguments are:\n'le', 'be', ${outTypes}`); + } + }); + + if (initial) { + for (const param in parameters) { + this[param] = parameters[param]; + } + } + + return parameters; + } + }; + + // apply user settings + this.utils.validateArgs(args, true); + } + + + /** + * BaseEx Byte Encoder. + * @param {*} input - Almost any input. + * @param {...str} [args] - Converter settings. + * @returns {{ buffer: ArrayBufferLike; }} - Bytes of Input. + */ + encode(input, ...args) { + const settings = this.utils.validateArgs(args); + return SmartInput.toBytes(input, settings)[0]; + } + + + /** + * BaseEx Byte Decoder. + * @param {{ buffer: ArrayBufferLike; }} input - Bytes/Buffer/View + * @param {...any} [args] - Converter settings. + * @returns {*} - Output of requested type. + */ + decode(input, ...args) { + const settings = this.utils.validateArgs(args); + return SmartOutput.compile(input, settings.outputType, settings.littleEndian); + } +} + +/** + * [BaseEx]{@link https://github.com/UmamiAppearance/BaseExJS} + * + * @version 0.6.1 + * @author UmamiAppearance [mail@umamiappearance.eu] + * @license GPL-3.0 AND BSD-3-Clause (only regarding Base91, Copyright (c) 2000-2006 Joachim Henke) + */ /** * BaseEx Converter Collection. @@ -2545,15 +3878,21 @@ class BaseEx { this.base58_flickr = new Base58("flickr", outputType); this.base64 = new Base64("default", outputType); this.base64_urlsafe = new Base64("urlsafe", outputType); + this.uuencode = new UUencode("default", outputType); + this.xxencode = new UUencode("xx", outputType); this.base85_adobe = new Base85("adobe", outputType); this.base85_ascii = new Base85("ascii85", outputType); this.base85_z85 = new Base85("z85", outputType); this.base91 = new Base91("default",outputType); this.leb128 = new LEB128("default", outputType); + this.ecoji_v1 = new Ecoji("emojis_v1", outputType); + this.ecoji_v2 = new Ecoji("emojis_v2", outputType); + this.base2048 = new Base2048("default", outputType); + this.basePhi = new BasePhi("default", outputType); this.byteConverter = new ByteConverter(outputType); this.simpleBase = {}; - for (let i=2; i<37; i++) { + for (let i=2; i<=62; i++) { this.simpleBase[`base${i}`] = new SimpleBase(i, outputType); } } @@ -2562,7 +3901,7 @@ class BaseEx { /** * [BrowserSHAObj]{@link https://github.com/UmamiAppearance/BrowserSHAObj} * - * @version 0.3.2 + * @version 0.3.3 * @author UmamiAppearance [mail@umamiappearance.eu] * @license GPL-3.0 */ diff --git a/dist/BrowserSHAObj.esm.min.js b/dist/BrowserSHAObj.esm.min.js index 1914dd7..f0a9b03 100644 --- a/dist/BrowserSHAObj.esm.min.js +++ b/dist/BrowserSHAObj.esm.min.js @@ -1,16 +1,16 @@ -class t{static toBytes(t){return ArrayBuffer.isView(t)&&(t=t.buffer),[new Uint8Array(t),!1,"bytes"]}}class e{static get typeList(){return["buffer","bytes","uint8","view"]}static getType(t){if(!e.typeList.includes(t))throw new TypeError(`Unknown output type: '${t}'`);return t}static compile(t,s){let i;return i="buffer"===(s=e.getType(s))?t.buffer:"view"===s?new DataView(t.buffer):t,i}}class s{static makeDataView(t){const e=new ArrayBuffer(t);return new DataView(e)}static floatingPoints(t,e=!1){const s=this.makeDataView(8);return s.setFloat64(0,t,e),s}static numbers(t,e=!1){let s,i;if(Number.isInteger(t)){if(i="int",!Number.isSafeInteger(t)){let e,s,i;throw t<0?(e=Number.MIN_SAFE_INTEGER,s="smaller",i="MIN"):(e=Number.MAX_SAFE_INTEGER,s="bigger",i="MAX"),new RangeError(`The provided integer is ${s} than ${i}_SAFE_INTEGER: '${e}'\nData integrity is not guaranteed. Use a BigInt to avoid this issue.\n(If you see this error although a float was provided, the input has to many digits before the decimal point to store the decimal places in a float with 64 bits.)`)}t<0?t<-2147483648?(s=this.makeDataView(8),s.setBigInt64(0,BigInt(t),e)):t<-32768?(s=this.makeDataView(4),s.setInt32(0,t,e)):(s=this.makeDataView(2),s.setInt16(0,t,e)):t>0?t>4294967295?(s=this.makeDataView(8),s.setBigUint64(0,BigInt(t),e)):t>65535?(s=this.makeDataView(4),s.setUint32(0,t,e)):(s=this.makeDataView(2),s.setInt16(0,t,e)):s=new Uint16Array([0])}else i="float",s=this.floatingPoints(t,e);return[new Uint8Array(s.buffer),i]}static bigInts(t,e=!1){const s=new Array,i=e?"push":"unshift",n=18446744073709551616n;if(t<0)for(;t<-9223372036854775808n;)s[i](t%n),t>>=64n;else for(;t>=n;)s[i](t%n),t>>=64n;s[i](t);const r=8*s.length,a=this.makeDataView(r);return s.forEach(((t,s)=>{const i=8*s;a.setBigUint64(i,t,e)})),new Uint8Array(a.buffer)}static toBytes(t,e){let s,i=!1,n="bytes";if(t instanceof ArrayBuffer)s=new Uint8Array(t.slice());else if(ArrayBuffer.isView(t))s=new Uint8Array(t.buffer.slice());else if("string"==typeof t||t instanceof String)s=(new TextEncoder).encode(t);else if("number"==typeof t){if(isNaN(t))throw new TypeError("Cannot proceed. Input is NaN.");if(t==1/0)throw new TypeError("Cannot proceed. Input is Infinity.");if(e.signed&&t<0&&(i=!0,t=-t),e.numberMode){const i=this.floatingPoints(t,e.littleEndian);s=new Uint8Array(i.buffer),n="float"}else[s,n]=this.numbers(t,e.littleEndian)}else if("bigint"==typeof t)e.signed&&t<0&&(i=!0,t*=-1n),s=this.bigInts(t,e.littleEndian),n="int";else{if(!Array.isArray(t))throw new TypeError("The provided input type can not be processed.");{const i=new Array;for(const s of t)i.push(...this.toBytes(s,e)[0]);s=Uint8Array.from(i)}}return[s,i,n]}}class i{static get typeList(){return["bigint64","bigint_n","biguint64","buffer","bytes","float32","float64","float_n","int8","int16","int32","int_n","str","uint8","uint16","uint32","uint_n","view"]}static getType(t){if(!this.typeList.includes(t))throw new TypeError(`Unknown output type: '${t}'`);return t}static makeTypedArrayBuffer(t,e,s,i){const n=t.byteLength,r=(e-t.byteLength%e)%e,a=i&&n>1?255:0;let o=t;if(r){o=new Uint8Array(n+r),o.fill(a);const e=s?0:r;o.set(t,e)}return o.buffer}static makeTypedArray(t,e,s,i){let n;if("int16"===e||"uint16"===e){const r=this.makeTypedArrayBuffer(t,2,s,i);n="int16"===e?new Int16Array(r):new Uint16Array(r)}else if("int32"===e||"uint32"===e||"float32"===e){const r=this.makeTypedArrayBuffer(t,4,s,i);n="int32"===e?new Int32Array(r):"uint32"===e?new Uint32Array(r):new Float32Array(r)}else if("bigint64"===e||"biguint64"===e||"float64"===e){const r=this.makeTypedArrayBuffer(t,8,s,i);n="bigint64"===e?new BigInt64Array(r):"biguint64"===e?new BigUint64Array(r):new Float64Array(r)}return n}static compile(t,e,i=!1,n=!1){let r;if(e=this.getType(e),n){let n;if(n=e.match(/^float/)?-this.compile(t,"float_n",i):-this.compile(t,"uint_n",i),"float_n"===e)return n;t=s.toBytes(n,{littleEndian:i,numberMode:!1,signed:!1})[0]}if("buffer"===e)r=t.buffer;else if("bytes"===e||"uint8"===e)r=t;else if("int8"===e)r=new Int8Array(t.buffer);else if("view"===e)r=new DataView(t.buffer);else if("str"===e)r=(new TextDecoder).decode(t);else if("uint_n"===e||"int_n"===e||"bigint_n"===e){if(1===t.length){const e=this.makeTypedArrayBuffer(t,2,i,n);t=new Uint8Array(e)}i&&t.reverse();let s=0n;t.forEach((t=>s=(s<<8n)+BigInt(t))),"uint_n"!==e&&(s=BigInt.asIntN(8*t.length,s)),r="bigint_n"!==e&&s>=Number.MIN_SAFE_INTEGER&&s<=Number.MAX_SAFE_INTEGER?Number(s):s}else if("float_n"===e)if(t.length<=4){let e;e=4===t.length?t:this.makeTypedArray(t,"float32",!1,n);r=new DataView(e.buffer).getFloat32(0,i)}else{if(!(t.length<=8))throw new RangeError("The provided input is to complex to be converted into a floating point.");{let e;e=8===t.length?t:this.makeTypedArray(t,"float64",!1,n);r=new DataView(e.buffer).getFloat64(0,i)}}else if("number"===e){if(8!==t.length)throw new TypeError("Type mismatch. Cannot convert into number.");const e=new Float64Array(t.buffer);r=Number(e)}else r=this.makeTypedArray(t,e,i,n);return r}}const n=s,r=i;class a{constructor(t,e=!0){this.root=t,"charsets"in t&&e&&this.#t()}setIOHandlers(t=n,e=r){this.inputHandler=t,this.outputHandler=e}#t(){this.root.addCharset=(t,e)=>{if("string"!=typeof t)throw new TypeError("The charset name must be a string.");const s=this.root.converter.radix;let i=s;if("string"==typeof e||Array.isArray(e))i=e.length,e=new Set(e);else if(!(e instanceof Set))throw new TypeError("The charset must be one of the types:\n'str', 'set', 'array'.");if(e.size!==s)throw i===s?new Error("There were repetitive chars found in your charset. Make sure each char is unique."):new Error(`The length of the charset must be ${s}.`);e=[...e].join(""),this.root.charsets[t]=e,console.info(`New charset '${t}' was added and is ready to use`)},this.root.setDefaultCharset=t=>{({version:t}=this.validateArgs([t])),this.root.version=t}}makeArgList(t){return t.map((t=>`'${t}'`)).join(", ")}toSignedStr(t,e){return t=t.replace(/^0+(?!$)/,""),e&&(t="-".concat(t)),t}extractSign(t){let e=!1;return"-"===t[0]&&(e=!0,t=t.slice(1)),[t,e]}invalidArgument(t,e,s,i){const n=i?"\n * valid declarations for IO handlers are 'bytesOnly', 'bytesIn', 'bytesOut'":"",r=this.root.isMutable.signed?"\n * pass 'signed' to disable, 'unsigned' to enable the use of the twos's complement for negative integers":"",a=this.root.isMutable.littleEndian?"\n * 'be' for big , 'le' for little endian byte order for case conversion":"",o=this.root.isMutable.padding?"\n * pass 'pad' to fill up, 'nopad' to not fill up the output with the particular padding":"",l=this.root.isMutable.upper?"\n * valid args for changing the encoded output case are 'upper' and 'lower'":"",h=`\n * valid args for the output type are ${this.makeArgList(s)}`,u=e?`\n * the options for version (charset) are: ${this.makeArgList(e)}`:"";throw new TypeError(`'${t}'\n\nInput parameters:${n}${r}${a}${o}${l}${h}${u}\n * 'number' for number-mode (converts every number into a Float64Array to keep the natural js number type)\n\nTraceback:`)}validateArgs(s,i=!1){const a={littleEndian:this.root.littleEndian,numberMode:this.root.numberMode,outputType:this.root.outputType,padding:this.root.padding,signed:this.root.signed,upper:this.root.upper,version:this.root.version};if(!s.length)return i&&this.setIOHandlers(),a;const o=t=>!!s.includes(t)&&(s.splice(s.indexOf(t),1),!0),l=Object.prototype.hasOwnProperty.call(this.root,"charsets")?Object.keys(this.root.charsets):[],h={littleEndian:["be","le"],padding:["nopad","pad"],signed:["unsigned","signed"],upper:["lower","upper"]};if(i)if(o("bytes_only"))this.setIOHandlers(t,e);else{const s=o("bytes_in")?t:n,i=o("bytes_out")?e:r;this.setIOHandlers(s,i)}const u=this.outputHandler.typeList;if(o("number")&&(a.numberMode=!0,a.outputType="float_n"),s.forEach((t=>{if(t=String(t).toLowerCase(),l.includes(t))a.version=t;else if(u.includes(t))a.outputType=t;else{let e=!0;for(const s in h)if(h[s].includes(t)){if(e=!1,!this.root.isMutable[s])throw TypeError(`Argument '${t}' is not allowed for this type of converter.`);a[s]=Boolean(h[s].indexOf(t))}e&&this.invalidArgument(t,l,u,i)}})),a.padding&&a.signed&&(a.padding=!1,this.constructor.warning("Padding was set to false due to the signed conversion.")),i)for(const t in a)this.root[t]=a[t];return a}signError(){throw new TypeError("The input is signed but the converter is not set to treat input as signed.\nYou can pass the string 'signed' to the decode function or when constructing the converter.")}static warning(t){Object.prototype.hasOwnProperty.call(console,"warn")?console.warn(t):console.log(`___\n${t}\n`)}}class o{constructor(t,e=null,s=null,i=0){this.radix=t,null!==e&&null!==s?(this.bsEnc=e,this.bsDec=s):[this.bsEnc,this.bsDec]=this.constructor.guessBS(t),this.decPadVal=i}static guessBS(t){let e=t<8?t:Math.ceil(256/t);for(;e>8&&!(e%8);)e/=8;let s=0;for(;8*s*Math.log(2)/Math.log(t)=this.radix;)[u,h]=this.divmod(u,this.radix),o.unshift(parseInt(h,10));for(o.unshift(parseInt(u,10));o.lengthc=c.concat(e[t]))),i&&(c=i(c,a)),r=r.concat(c)}return[r,a]}decode(t,e,s=!1){if(!t)return new Uint8Array(0);let i=this.bsDec;const n=new Array;let r;if(t.split("").forEach((t=>{const s=e.indexOf(t);s>-1&&n.push(s)})),0===i)i=n.length;else{r=(i-n.length%i)%i;const t=new Array(r).fill(this.decPadVal);s?n.unshift(...t):n.push(...t)}let a=new Array;for(let t=0,e=n.length;t=256;)[o,r]=this.divmod(o,256),s.unshift(parseInt(r,10));for(s.unshift(parseInt(o,10));s.length1){for(;!a[0];)a.shift();a.length||a.push(0),a.reverse()}}else if(this.bsDec){const t=this.padChars(r);a.splice(a.length-t)}return Uint8Array.from(a)}padBytes(t){return Math.floor(t*this.bsDec/this.bsEnc)}padChars(t){return Math.ceil(t*this.bsEnc/this.bsDec)}pow(t){return BigInt(this.radix)**BigInt(t)}divmod(t,e){return[t,e]=[BigInt(t),BigInt(e)],[t/e,t%e]}}class l{constructor(t=!0){this.charsets={},this.hasSignedMode=!1,this.littleEndian=!1,this.numberMode=!1,this.outputType="buffer",this.padding=!1,this.signed=!1,this.upper=null,t&&(this.utils=new a(this)),this.version="default",this.isMutable={littleEndian:!1,padding:!1,signed:!1,upper:!1}}encode(t,e,s,...i){const n=this.utils.validateArgs(i);let r,a,o;[r,a,o]=this.utils.inputHandler.toBytes(t,n);let l,h,u=null;return e&&(u=e(n)),[l,h]=this.converter.encode(r,this.charsets[n.version],n.littleEndian,u),n.signed&&(l=this.utils.toSignedStr(l,a)),n.upper&&(l=l.toUpperCase()),s&&(l=s({inputBytes:r,output:l,settings:n,zeroPadding:h,type:o})),l}decode(t,e,s,...i){const n=this.utils.validateArgs(i);let r=String(t),a=!1;this.hasSignedMode&&([r,a]=this.utils.extractSign(r),a&&!n.signed&&this.utils.signError()),this.isMutable.upper&&(r=r.toLowerCase()),e&&(r=e({input:r,settings:n}));let o=this.converter.decode(r,this.charsets[n.version],n.littleEndian);return s&&(o=s({input:r,output:o,settings:n})),this.utils.outputHandler.compile(o,n.outputType,n.littleEndian,a)}}class h extends l{constructor(...t){super(),delete this.addCharset,this.charsets.all=" !\"#$%&'()*+,./0123456789:;<=>?@ABCDEFGHIJKLMNOPQRSTUVWXYZ[\\]^_`abcdefghijklmnopqrstuvwxyz{|}~",this.charsets.sequence="Hello World!",this.charsets.default="1",this.charsets.tmark="|#",this.converter=new o(10,0,0),this.hasSignedMode=!0,this.littleEndian=!0,this.signed=!0,this.isMutable.signed=!0,this.isMutable.upper=!0,this.utils.validateArgs(t,!0)}encode(t,...e){const s=this.utils.validateArgs(e);let i,n;[i,n]=this.utils.inputHandler.toBytes(t,s);let r=this.converter.encode(i,null,s.littleEndian)[0],a=BigInt(r);if(a>Number.MAX_SAFE_INTEGER)throw new RangeError("Invalid string length.");a>16777216&&this.utils.constructor.warning("The string length is really long. The JavaScript engine may have memory issues generating the output string."),a=Number(a);const o=this.charsets[s.version],l=o.length;let h="";if(1===l)h=o.repeat(a);else if("all"===s.version)for(let t=0;t4&&(h=o[1].repeat((a-t)/5)),h+=o[0].repeat(t)}else for(let t=0;t{let{input:e}=t;return e=e.replace(/^0x/,""),e.length%2&&(e="0".concat(e)),e}),null,...e)}}class c extends l{constructor(...t){super(),this.charsets.crockford="0123456789abcdefghjkmnpqrstvwxyz",this.charsets.rfc3548="abcdefghijklmnopqrstuvwxyz234567",this.charsets.rfc4648="0123456789abcdefghijklmnopqrstuv",this.charsets.zbase32="ybndrfg8ejkmcpqxot1uwisza345h769",this.converter=new o(32,5,8),this.hasSignedMode=!0,this.padding=!0,this.version="rfc4648",this.isMutable.littleEndian=!0,this.isMutable.padding=!0,this.isMutable.signed=!0,this.isMutable.upper=!0,this.utils.validateArgs(t,!0)}encode(t,...e){return super.encode(t,null,(t=>{let{output:e,settings:s,zeroPadding:i}=t;if(!s.littleEndian&&i){const t=this.converter.padBytes(i);e=e.slice(0,e.length-t),s.padding&&(e=e.concat("=".repeat(t)))}return e}),...e)}decode(t,...e){return super.decode(t,null,null,...e)}}class d extends l{constructor(...t){super(),this.charsets.default="123456789abcdefghijkmnopqrstuvwxyzABCDEFGHJKLMNPQRSTUVWXYZ",this.charsets.bitcoin="123456789ABCDEFGHJKLMNPQRSTUVWXYZabcdefghijkmnopqrstuvwxyz",this.charsets.flickr="123456789abcdefghijkmnopqrstuvwxyzABCDEFGHJKLMNPQRSTUVWXYZ",this.converter=new o(58,0,0),this.padding=!0,this.version="bitcoin",this.isMutable.padding=!0,this.isMutable.signed=!0,this.utils.validateArgs(t,!0)}encode(t,...e){return super.encode(t,null,(t=>{let{inputBytes:e,output:s,settings:i,type:n}=t;if(i.padding&&"int"!==n){let t=0;const i=e.length;if(i){for(;!e[t];)if(t++,t===i){t=0;break}const n=t;n&&(s="1".repeat(n).concat(s))}}return s}),...e)}decode(t,...e){return super.decode(t,null,(t=>{let{input:e,output:s,settings:i}=t;if(i.padding&&e.length>1){let t=0;for(;"1"===e[t];)t++;const i=t;i&&(s=Uint8Array.from([...new Array(i).fill(0),...s]))}return s}),...e)}}class f extends l{constructor(...t){super();const e="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789";this.charsets.default=e.concat("+/"),this.charsets.urlsafe=e.concat("-_"),this.converter=new o(64,3,4),this.padding=!0,this.isMutable.padding=!0,this.utils.validateArgs(t,!0)}encode(t,...e){return super.encode(t,null,(t=>{let{output:e,settings:s,zeroPadding:i}=t;if(i){const t=this.converter.padBytes(i);e=e.slice(0,e.length-t),s.padding&&(e=e.concat("=".repeat(t)))}return e}),...e)}decode(t,...e){return super.decode(t,null,null,...e)}}class p extends l{constructor(...t){super(),this.charsets.adobe="!\"#$%&'()*+,-./0123456789:;<=>?@ABCDEFGHIJKLMNOPQRSTUVWXYZ[\\]^_`abcdefghijklmnopqrstu",this.charsets.ascii85=this.charsets.adobe,this.charsets.rfc1924="0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz!#$%&()*+-;<=>?@^_`{|}~",this.charsets.z85="0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ.-:+=^!/*?&<>()[]{}@%$#",this.converter=new o(85,4,5,84),this.version="ascii85",this.utils.validateArgs(t,!0)}encode(t,...e){return super.encode(t,(t=>{let e;return t.version.match(/adobe|ascii85/)&&(e=(t,e)=>e||"!!!!!"!==t?t:"z"),e}),(t=>{let{output:e,settings:s,zeroPadding:i}=t;if(i){const t=this.converter.padBytes(i);e=e.slice(0,e.length-t)}return"adobe"===s.version&&(e=`<~${e}~>`),e}),...e)}decode(t,...e){return super.decode(t,(t=>{let{input:e,settings:s}=t;return s.version.match(/adobe|ascii85/)&&(e=e.replace(/z/g,"!!!!!"),"adobe"===s.version&&(e=e.replace(/^<~|~>$/g,""))),e}),null,...e)}}class g extends l{constructor(...t){super(),this.charsets.default='ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789!#$%&()*+,./:;<=>?@[]^_`{|}~"',this.utils.validateArgs(t,!0)}encode(t,...e){const s=this.utils.validateArgs(e),i=this.utils.inputHandler.toBytes(t,s)[0];let n=0,r=0,a="";const o=this.charsets[s.version];if(i.forEach((t=>{if(r+=t<13){let t,e,s=13,i=r%8192;i<89&&(s=14,i=r%16384),r>>=s,n-=s,[t,e]=this.divmod(i,91),a=`${a}${o[e]}${o[t]}`}})),n){let t,e;[t,e]=this.divmod(r,91),a=a.concat(o[e]),(n>7||r>90)&&(a=a.concat(o[t]))}return a}decode(t,...e){const s=this.utils.validateArgs(e);let i=(t=String(t)).length,n=!1;i%2&&(n=!0,i--);let r=0,a=0;const o=this.charsets[s.version],l=new Array;for(let e=0;e88?13:14;do{l.push(r%256),r>>=8,a-=8}while(a>7)}if(n){const e=t.charAt(i),s=o.indexOf(e);l.push(((s<{const s={littleEndian:this.littleEndian,numberMode:this.numberMode,outputType:this.outputType,signed:!1};if(!t.length)return s;t.includes("number")&&(t.splice(t.indexOf("number"),1),s.numberMode=!0,s.outputType="float_n");const n=i.typeList.map((t=>`'${t}'`)).join(", ");if(t.forEach((t=>{if("le"===(t=String(t).toLowerCase()))s.littleEndian=!0;else if("be"===t)s.littleEndian=!1;else{if(!i.typeList.includes(t))throw new TypeError(`Invalid argument: '${t}.\nValid arguments are:\n'le', 'be', ${n}`);s.outputType=t}})),e)for(const t in s)this[t]=s[t];return s}},this.utils.validateArgs(t,!0)}encode(t,...e){const i=this.utils.validateArgs(e);return s.toBytes(t,i)[0]}decode(t,...e){const s=this.utils.validateArgs(e);return i.compile(t,s.outputType,s.littleEndian)}}class y extends l{constructor(...t){super(!1),this.charsets.default="",this.charsets.hex="",this.version="default",this.converter=new o(10,0,0),this.hexlify=new o(16,1,2),this.utils=new a(this,!1),this.littleEndian=!0,this.hasSignedMode=!0,this.isMutable.signed=!0,this.utils.validateArgs(t,!0)}encode(t,...e){const s=this.utils.validateArgs(e);let i,n;const r=s.signed;s.signed=!0,[i,n]=this.utils.inputHandler.toBytes(t,s);let a=this.converter.encode(i,null,s.littleEndian)[0],o=BigInt(a),l=new Array;if(n){if(!r)throw new TypeError("Negative values in unsigned mode are invalid.");o=-o}if(r)for(;;){const t=Number(127n&o);if(o>>=7n,0==o&&0==(64&t)||-1==o&&0!=(64&t)){l.push(t);break}l.push(128|t)}else for(;;){const t=Number(127n&o);if(o>>=7n,0==o){l.push(t);break}l.push(128|t)}const h=Uint8Array.from(l);return"hex"===s.version?this.hexlify.encode(h,"0123456789abcdef",!1)[0]:h}decode(t,...e){const s=this.utils.validateArgs(e);if("hex"===s.version?t=this.hexlify.decode(String(t).toLowerCase(),"0123456789abcdef",!1):t instanceof ArrayBuffer&&(t=new Uint8Array(t)),1===t.length&&!t[0])return this.utils.outputHandler.compile(new Uint8Array(1),s.outputType,!0);t=Array.from(t);let i,n,r,a=0n,o=-7n;for(i of t)o+=7n,a+=BigInt(127&i)<36)throw new RangeError("Radix argument must be provided and has to be an integer between 2 and 36.");this.charsets.default="0123456789abcdefghijklmnopqrstuvwxyz".substring(0,t),this.converter=new o(t,0,0),this.hasSignedMode=!0,this.littleEndian=!(2===t||16===t),this.signed=!0,this.version="default",this.isMutable.littleEndian=!0,this.isMutable.upper=!0,this.utils.validateArgs(e,!0)}encode(t,...e){return super.encode(t,null,null,...e)}decode(t,...e){return super.decode(t,(t=>{let{input:e}=t;if(2===this.converter.radix){const t=(8-e.length%8)%8;e=`${"0".repeat(t)}${e}`}else if(16===this.converter.radix){const t=e.length%2;e=`${"0".repeat(t)}${e}`}return e}),null,...e)}} +class t{static toBytes(t){return ArrayBuffer.isView(t)&&(t=t.buffer),[new Uint8Array(t),!1,"bytes"]}}class e{static get typeList(){return["buffer","bytes","uint8","view"]}static getType(t){if(!e.typeList.includes(t))throw new TypeError(`Unknown output type: '${t}'`);return t}static compile(t,i){let s;return s="buffer"===(i=e.getType(i))?t.buffer:"view"===i?new DataView(t.buffer):t,s}}class i{static makeDataView(t){const e=new ArrayBuffer(t);return new DataView(e)}static floatingPoints(t,e=!1){const i=this.makeDataView(8);return i.setFloat64(0,t,e),i}static numbers(t,e=!1){let i,s;if(Number.isInteger(t)){if(s="int",!Number.isSafeInteger(t)){let e,i,s;throw t<0?(e=Number.MIN_SAFE_INTEGER,i="smaller",s="MIN"):(e=Number.MAX_SAFE_INTEGER,i="bigger",s="MAX"),new RangeError(`The provided integer is ${i} than ${s}_SAFE_INTEGER: '${e}'\nData integrity is not guaranteed. Use a BigInt to avoid this issue.\n(If you see this error although a float was provided, the input has to many digits before the decimal point to store the decimal places in a float with 64 bits.)`)}t<0?t<-2147483648?(i=this.makeDataView(8),i.setBigInt64(0,BigInt(t),e)):t<-32768?(i=this.makeDataView(4),i.setInt32(0,t,e)):(i=this.makeDataView(2),i.setInt16(0,t,e)):t>0?t>4294967295?(i=this.makeDataView(8),i.setBigUint64(0,BigInt(t),e)):t>65535?(i=this.makeDataView(4),i.setUint32(0,t,e)):(i=this.makeDataView(2),i.setInt16(0,t,e)):i=new Uint16Array([0])}else s="float",i=this.floatingPoints(t,e);return[new Uint8Array(i.buffer),s]}static bigInts(t,e=!1){const i=new Array,s=e?"push":"unshift",r=18446744073709551616n;if(t<0)for(;t<-9223372036854775808n;)i[s](t%r),t>>=64n;else for(;t>=r;)i[s](t%r),t>>=64n;i[s](t);const n=8*i.length,o=this.makeDataView(n);return i.forEach(((t,i)=>{const s=8*i;o.setBigUint64(s,t,e)})),new Uint8Array(o.buffer)}static toBytes(t,e){let i,s=!1,r="bytes";if(t instanceof ArrayBuffer)i=new Uint8Array(t.slice());else if(ArrayBuffer.isView(t))i=new Uint8Array(t.buffer.slice());else if("string"==typeof t||t instanceof String)i=(new TextEncoder).encode(t);else if("number"==typeof t){if(isNaN(t))throw new TypeError("Cannot proceed. Input is NaN.");if(t==1/0)throw new TypeError("Cannot proceed. Input is Infinity.");if(e.signed&&t<0&&(s=!0,t=-t),e.numberMode){const s=this.floatingPoints(t,e.littleEndian);i=new Uint8Array(s.buffer),r="float"}else[i,r]=this.numbers(t,e.littleEndian)}else if("bigint"==typeof t)e.signed&&t<0&&(s=!0,t*=-1n),i=this.bigInts(t,e.littleEndian),r="int";else{if(!Array.isArray(t))throw new TypeError("The provided input type can not be processed.");{const s=new Array;for(const i of t)s.push(...this.toBytes(i,e)[0]);i=Uint8Array.from(s)}}return[i,s,r]}}class s{static get typeList(){return["bigint64","bigint_n","biguint64","buffer","bytes","float32","float64","float_n","int8","int16","int32","int_n","str","uint8","uint16","uint32","uint_n","view"]}static getType(t){if(!this.typeList.includes(t))throw new TypeError(`Unknown output type: '${t}'`);return t}static makeTypedArrayBuffer(t,e,i,s){const r=t.byteLength,n=(e-t.byteLength%e)%e,o=s&&r>1?255:0;let a=t;if(n){a=new Uint8Array(r+n),a.fill(o);const e=i?0:n;a.set(t,e)}return a.buffer}static makeTypedArray(t,e,i,s){let r;if("int16"===e||"uint16"===e){const n=this.makeTypedArrayBuffer(t,2,i,s);r="int16"===e?new Int16Array(n):new Uint16Array(n)}else if("int32"===e||"uint32"===e||"float32"===e){const n=this.makeTypedArrayBuffer(t,4,i,s);r="int32"===e?new Int32Array(n):"uint32"===e?new Uint32Array(n):new Float32Array(n)}else if("bigint64"===e||"biguint64"===e||"float64"===e){const n=this.makeTypedArrayBuffer(t,8,i,s);r="bigint64"===e?new BigInt64Array(n):"biguint64"===e?new BigUint64Array(n):new Float64Array(n)}return r}static compile(t,e,s=!1,r=!1){let n;if(e=this.getType(e),r){let r;if(r=e.match(/^float/)?-this.compile(t,"float_n",s):-this.compile(t,"uint_n",s),"float_n"===e)return r;t=i.toBytes(r,{littleEndian:s,numberMode:!1,signed:!1})[0]}if("buffer"===e)n=t.buffer;else if("bytes"===e||"uint8"===e)n=t;else if("int8"===e)n=new Int8Array(t.buffer);else if("view"===e)n=new DataView(t.buffer);else if("str"===e)n=(new TextDecoder).decode(t);else if("uint_n"===e||"int_n"===e||"bigint_n"===e){if(1===t.length){const e=this.makeTypedArrayBuffer(t,2,s,r);t=new Uint8Array(e)}s&&t.reverse();let i=0n;t.forEach((t=>i=(i<<8n)+BigInt(t))),"uint_n"!==e&&(i=BigInt.asIntN(8*t.length,i)),n="bigint_n"!==e&&i>=Number.MIN_SAFE_INTEGER&&i<=Number.MAX_SAFE_INTEGER?Number(i):i}else if("float_n"===e)if(t.length<=4){let e;e=4===t.length?t:this.makeTypedArray(t,"float32",!1,r);n=new DataView(e.buffer).getFloat32(0,s)}else{if(!(t.length<=8))throw new RangeError("The provided input is to complex to be converted into a floating point.");{let e;e=8===t.length?t:this.makeTypedArray(t,"float64",!1,r);n=new DataView(e.buffer).getFloat64(0,s)}}else if("number"===e){if(8!==t.length)throw new TypeError("Type mismatch. Cannot convert into number.");const e=new Float64Array(t.buffer);n=Number(e)}else n=this.makeTypedArray(t,e,s,r);return n}}const r=i,n=s;class o extends TypeError{constructor(){super("The input is signed but the converter is not set to treat input as signed.\nYou can pass the string 'signed' to the decode function or when constructing the converter."),this.name="SignError"}}class a extends TypeError{constructor(t,e=null){null===e&&(e=`Character '${t}' is not part of the charset.`),super(e),this.name="DecodingError"}}class h{constructor(t){this.root=t,this.converterArgs={},this.#t()}setIOHandlers(t=r,e=n){this.inputHandler=t,this.outputHandler=e}#t(){this.root.addCharset=(t,e,i=[],s=!0)=>{const r=(t,i,s)=>{if(0===s&&i.length)return console.warn(`This converter has no ${t}. The following argument was ignored:\n'${i}'`),[];let r=s;if("string"==typeof i&&(i=[...i]),Array.isArray(i))r=i.length,i=new Set(i);else if(!(i instanceof Set))throw new TypeError(`The ${t} must be one of the types:\n'str', 'set', 'array'."`);if(i.size===s)return[...i];if(r!==s)throw new Error(`Your ${t} has a length of ${r}. The converter requires a length of ${s}.`);{const i={};(e=[...e]).forEach((t=>{t in i?i[t]++:i[t]=1}));let r="";s<100&&(r=`${e.join("")}\n`,e.forEach((t=>{i[t]>1?r+="^":r+=" "})));const n=Object.keys(i).filter((t=>i[t]>1));throw new Error(`You have repetitive char(s) [ ${n.join(" | ")} ] in your ${t}. Make sure each character is unique.\n${r}`)}};if(this.root.frozenCharsets)throw new Error("The charsets of this converter cannot be changed.");if("string"!=typeof t)throw new TypeError("The charset name must be a string.");s&&t in this.root.charsets&&console.warn(`An existing charset with name ${t} will get replaced.`);const n=r("charset",e,this.root.converter.radix),o=r("padding set",i,this.root.padCharAmount);this.root.charsets[t]=n,o.length&&(this.root.padChars[t]=o),s&&console.info(`New charset '${t}' was added and is ready to use`)},this.root.setDefaultCharset=t=>{if(!(t in this.root.charsets)){const e=Object.keys(this.root.charsets).join("\n * ");throw new TypeError(`Charset ${t} was not found. Available charsets are:\n * ${e}`)}this.root.version=t}}#e(t){return t.map((t=>`'${t}'`)).join(", ")}toSignedStr(t,e){return t=t.replace(/^0+(?!$)/,""),e&&(t="-".concat(t)),t}extractSign(t){let e=!1;return"-"===t[0]&&(e=!0,t=t.slice(1)),[t,e]}#i(t,e,i,s){throw new TypeError([`'${t}'\n\nParameters:`,s?"\n * valid declarations for IO handlers are 'bytesOnly', 'bytesIn', 'bytesOut'":"",this.root.isMutable.signed?"\n * pass 'signed' to disable, 'unsigned' to enable the use of the twos's complement for negative integers":"",this.root.isMutable.littleEndian?"\n * 'be' for big , 'le' for little endian byte order for case conversion":"",this.root.isMutable.padding?"\n * pass 'pad' to fill up, 'nopad' to not fill up the output with the particular padding":"",this.root.isMutable.upper?"\n * valid args for changing the encoded output case are 'upper' and 'lower'":"",`\n * valid args for the output type are ${this.#e(i)}`,e?`\n * the option(s) for version/charset are: ${this.#e(e)}`:"","\n * valid args for integrity check are: 'integrity' and 'nointegrity'",this.root.hasDecimalMode?"\n * 'decimal' for decimal-mode (directly converts Numbers including decimal values, without byte-conversion)":"","\n * 'number' for number-mode (converts every number into a Float64Array to keep the natural js number type)",Object.keys(this.converterArgs).length?`\n * converter specific args:\n - ${(()=>Object.keys(this.converterArgs).map((t=>this.converterArgs[t].map((t=>`'${t}'`)).join(" and "))).join("\n - "))()}`:"","\n\nTraceback:"].join(""))}validateArgs(i,s=!1){const o={decimalMode:this.root.decimalMode,integrity:this.root.integrity,littleEndian:this.root.littleEndian,numberMode:this.root.numberMode,options:this.root.options,outputType:this.root.outputType,padding:this.root.padding,signed:this.root.signed,upper:this.root.upper,version:this.root.version};for(const t in this.converterArgs)o[t]=this.root[t];if(!i.length)return s&&this.setIOHandlers(),o;const a=t=>!!i.includes(t)&&(i.splice(i.indexOf(t),1),!0),h=Object.keys(this.root.charsets),l={integrity:["nointegrity","integrity"],littleEndian:["be","le"],padding:["nopad","pad"],signed:["unsigned","signed"],upper:["lower","upper"],...this.converterArgs};if(s)if(a("bytes_only"))this.setIOHandlers(t,e);else{const i=a("bytes_in")?t:r,s=a("bytes_out")?e:n;this.setIOHandlers(i,s)}const c=this.outputHandler.typeList;if(a("number")&&(o.numberMode=!0,o.outputType="float_n"),a("decimal")){if(!this.root.hasDecimalMode)throw TypeError("Argument 'decimal' is only allowed for converters with a non-integer base.");o.decimalMode=!0,o.outputType="decimal",o.numberMode&&(o.numberMode=!1,console.warn("-> number-mode was disabled due to the decimal-mode"))}if(i.forEach((t=>{if("object"!=typeof t)if(t=String(t).toLowerCase(),h.includes(t))o.version=t;else if(c.includes(t))o.outputType=t;else{let e=!0;for(const i in l)if(l[i].includes(t)){if(e=!1,!this.root.isMutable[i])throw TypeError(`Argument '${t}' is not allowed for this type of converter.`);o[i]=Boolean(l[i].indexOf(t))}e&&this.#i(t,h,c,s)}else o.options={...o.options,...t}})),o.padding&&o.signed&&(o.padding=!1,console.warn("-> padding was set to false due to the signed conversion")),s)for(const t in o)this.root[t]=o[t];return o}signError(){throw new o}wrapOutput(t,e=0){if(!e)return t;const i=new RegExp(`.{1,${e}}`,"gu");return t.match(i).join("\n")}normalizeInput(t,e=!1){return e?String(t):String(t).replace(/\s/g,"")}}class l{constructor(t,e=null,i=null,s=0){this.radix=t,null!==e&&null!==i?(this.bsEnc=e,this.bsDec=i):[this.bsEnc,this.bsDec]=this.constructor.guessBS(t),this.decPadVal=s}static guessBS(t){let e=t<8?t:Math.ceil(256/t);for(;e>8&&!(e%8);)e/=8;let i=0;for(;8*i*Math.log(2)/Math.log(t)=this.radix;)[c,l]=this.divmod(c,this.radix),a.unshift(parseInt(l,10));for(a.unshift(parseInt(c,10));a.lengthu=u.concat(e[t]))),s&&(u=s(u,o)),n=n.concat(u)}return[n,o]}decode(t,e,i=[],s=!0,r=!1){if(!t)return new Uint8Array(0);let n=this.bsDec;const o=new Array;let h;if([...t].forEach((t=>{const r=e.indexOf(t);if(r>-1)o.push(r);else if(s&&-1===i.indexOf(t))throw new a(t)})),0===n)n=o.length;else{h=(n-o.length%n)%n;const t=new Array(h).fill(this.decPadVal);r?o.unshift(...t):o.push(...t)}let l=new Array;for(let t=0,e=o.length;t=256;)[r,s]=this.divmod(r,256),i.unshift(parseInt(s,10));for(i.unshift(parseInt(r,10));i.length1){for(;!l[0];)l.shift();l.length||l.push(0),l.reverse()}}else if(this.bsDec){const t=this.padChars(h);l.splice(l.length-t)}return Uint8Array.from(l)}padBytes(t){return Math.floor(t*this.bsDec/this.bsEnc)}padChars(t){return Math.ceil(t*this.bsEnc/this.bsDec)}pow(t){return BigInt(this.radix)**BigInt(t)}divmod(t,e){return[t,e]=[BigInt(t),BigInt(e)],[t/e,t%e]}}class c{constructor(t=!0){this.charsets={},this.decimalMode=!1,this.frozenCharsets=!1,this.hasDecimalMode=!1,this.hasSignedMode=!1,this.integrity=!0,this.littleEndian=!1,this.numberMode=!1,this.outputType="buffer",this.padding=!1,this.padCharAmount=0,this.padChars={},this.signed=!1,this.upper=null,t&&(this.utils=new h(this)),this.version="default",this.options={lineWrap:0},this.isMutable={integrity:!0,littleEndian:!1,padding:!1,signed:!1,upper:!1}}encode(t,e,i,...s){const r=this.utils.validateArgs(s);let[n,o,a]=this.utils.inputHandler.toBytes(t,r),h=null;e&&(h=e(r));let[l,c]=this.converter.encode(n,this.charsets[r.version],r.littleEndian,h);return r.signed&&(l=this.utils.toSignedStr(l,o)),r.upper&&(l=l.toUpperCase()),i&&(l=i({inputBytes:n,output:l,settings:r,zeroPadding:c,type:a})),this.utils.wrapOutput(l,r.options.lineWrap)}decode(t,e,i,s,...r){const n=this.utils.validateArgs(r);t=this.utils.normalizeInput(t,s);let o=!1;this.hasSignedMode&&([t,o]=this.utils.extractSign(t),o&&!n.signed&&this.utils.signError()),this.isMutable.upper&&(t=t.toLowerCase()),e&&(t=e({input:t,settings:n}));let a=this.converter.decode(t,this.charsets[n.version],this.padChars[n.version],n.integrity,n.littleEndian);return i&&(a=i({input:t,output:a,settings:n})),this.utils.outputHandler.compile(a,n.outputType,n.littleEndian,o)}}class u extends c{constructor(...t){super(),this.charsets.all=[..." !\"#$%&'()*+,-./0123456789:;<=>?@ABCDEFGHIJKLMNOPQRSTUVWXYZ[\\]^_`abcdefghijklmnopqrstuvwxyz{|}~"],this.charsets.sequence=[..."Hello World!"],this.charsets.default=["1"],this.charsets.tmark=["|","#"],this.converter=new l(10,0,0),this.hasSignedMode=!0,this.littleEndian=!0,this.signed=!0,this.isMutable.charsets=!1,this.isMutable.signed=!0,this.isMutable.upper=!0,this.utils.validateArgs(t,!0)}encode(t,...e){const i=this.utils.validateArgs(e);let s,r;[s,r]=this.utils.inputHandler.toBytes(t,i);let n=this.converter.encode(s,null,i.littleEndian)[0],o=BigInt(n);if(o>Number.MAX_SAFE_INTEGER)throw new RangeError("Invalid string length.");o>16777216&&console.warn("The string length is really long. The JavaScript engine may have memory issues generating the output string."),o=Number(o);const a=this.charsets[i.version],h=a.length;let l="";if(1===h)l=a.at(0).repeat(o);else if("all"===i.version)for(let t=0;t4&&(l=a.at(1).repeat((o-t)/5)),l+=a.at(0).repeat(t)}else for(let t=0;t(t=t.replace(/^0x/,""),e.integrity||(t=t.toLowerCase().replace(/[^0-9a-f]/g,"")),t.length%2&&(t="0".concat(t)),t)),null,!1,...e)}}class f extends c{constructor(...t){super(),this.converter=new l(32,5,8),this.charsets.crockford=[..."0123456789abcdefghjkmnpqrstvwxyz"],this.padChars.crockford=["="],this.charsets.rfc3548=[..."abcdefghijklmnopqrstuvwxyz234567"],this.padChars.rfc3548=["="],this.charsets.rfc4648=[..."0123456789abcdefghijklmnopqrstuv"],this.padChars.rfc4648=["="],this.charsets.zbase32=[..."ybndrfg8ejkmcpqxot1uwisza345h769"],this.padChars.zbase32=["="],this.padCharAmount=1,this.hasSignedMode=!0,this.version="rfc4648",this.isMutable.littleEndian=!0,this.isMutable.padding=!0,this.isMutable.signed=!0,this.isMutable.upper=!0,this.utils.validateArgs(t,!0),this.padding=/rfc3548|rfc4648/.test(this.version),this.upper="crockford"===this.version}encode(t,...e){return super.encode(t,null,(({output:t,settings:e,zeroPadding:i})=>{if(!e.littleEndian&&i){const s=this.converter.padBytes(i),r=this.padChars[e.version].at(0);t=t.slice(0,-s),e.padding&&(t=t.concat(r.repeat(s)))}return t}),...e)}decode(t,...e){return super.decode(t,null,null,!1,...e)}}class p extends c{constructor(...t){super(),this.converter=new l(58,0,0),this.charsets.default=[..."123456789abcdefghijkmnopqrstuvwxyzABCDEFGHJKLMNPQRSTUVWXYZ"],Object.defineProperty(this.padChars,"default",{get:()=>[this.charsets.default.at(0)]}),this.charsets.bitcoin=[..."123456789ABCDEFGHJKLMNPQRSTUVWXYZabcdefghijkmnopqrstuvwxyz"],Object.defineProperty(this.padChars,"bitcoin",{get:()=>[this.charsets.bitcoin.at(0)]}),this.charsets.flickr=[..."123456789abcdefghijkmnopqrstuvwxyzABCDEFGHJKLMNPQRSTUVWXYZ"],Object.defineProperty(this.padChars,"flickr",{get:()=>[this.charsets.flickr.at(0)]}),this.padding=!0,this.version="bitcoin",this.isMutable.padding=!0,this.isMutable.signed=!0,this.utils.validateArgs(t,!0)}encode(t,...e){return super.encode(t,null,(({inputBytes:t,output:e,settings:i,type:s})=>{if(i.padding&&"int"!==s){let s=0;const r=t.length,n=this.charsets[i.version].at(0);if(r){for(;!t[s];)if(s++,s===r){s=0;break}const i=s;i&&(e=n.repeat(i).concat(e))}}return e}),...e)}decode(t,...e){return super.decode(t,null,(({input:t,output:e,settings:i})=>{const s=this.charsets[i.version].at(0);if(i.padding&&t.length>1){let i=0;for(;t[i]===s;)i++;const r=i;r&&(e=Uint8Array.from([...new Array(r).fill(0),...e]))}return e}),!1,...e)}}class g extends c{constructor(...t){super(),this.converter=new l(64,3,4),this.charsets.default=[..."ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/"],this.padChars.default=["="],this.charsets.urlsafe=this.charsets.default.slice(0,-2).concat(["-","_"]),this.padChars.urlsafe=["="],this.padCharAmount=1,this.padding=!0,this.isMutable.padding=!0,this.utils.validateArgs(t,!0)}encode(t,...e){return super.encode(t,null,(({output:t,settings:e,zeroPadding:i})=>{if(i){const s=this.converter.padBytes(i),r=this.padChars[e.version].at(0);t=t.slice(0,-s),e.padding&&(t=t.concat(r.repeat(s)))}return t}),...e)}decode(t,...e){return super.decode(t,null,null,!1,...e)}}class b extends c{constructor(...t){super(),this.converter=new l(64,3,4),this.charsets.default=[..."`!\"#$%&'()*+,-./0123456789:;<=>?@ABCDEFGHIJKLMNOPQRSTUVWXYZ[\\]^_"],Object.defineProperty(this.padChars,"default",{get:()=>[this.charsets.default.at(0)]}),this.charsets.original=[" ",...this.charsets.default.slice(1)],Object.defineProperty(this.padChars,"original",{get:()=>[this.charsets.original.at(0)]}),this.charsets.xx=[..."+-0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz"],Object.defineProperty(this.padChars,"xx",{get:()=>[this.charsets.xx.at(0)]}),this.padding=!0,this.header=!1,this.utils.converterArgs.header=["noheader","header"],this.isMutable.header=!0,this.isMutable.integrity=!1,this.utils.validateArgs(t,!0)}encode(t,...e){return super.encode(t,null,(({output:t,settings:e,zeroPadding:i})=>{const s=this.charsets[e.version],r=[...t];if(e.header){t=`begin ${e.options.permissions||y()} ${e.options.file||m()}\n`}else t="";for(;;){const e=r.splice(0,60);if(!r.length){const r=this.converter.padChars(e.length)-i;t+=`${s.at(r)}${e.join("")}\n`;break}t+=`${s.at(45)}${e.join("")}\n`}return t+=`${s.at(0)}\n`,e.header&&(t+="\nend"),t}),...e)}decode(t,...e){let i=0;return super.decode(t,(({input:t,settings:e})=>{const s=this.charsets[e.version],r=t.trim().split("\n"),n=[];/^begin/i.test(r.at(0))&&r.shift();for(const t of r){const e=[...t],r=s.indexOf(e.shift());if(!(r>0))break;if(n.push(...e),45!==r){i=this.converter.padChars(e.length)-r;break}}return n.join("")}),(({output:t})=>(i&&(t=new Uint8Array(t.slice(0,-i))),t)),!0,...e)}}const y=()=>{const t=()=>Math.floor(8*Math.random());return`${t()}${t()}${t()}`},m=()=>{const t=t=>t.at(Math.floor(Math.random()*t.length));return`${t(["unchronological","unconditionally","underemphasized","underprivileged","undistinguished","unsophisticated","untitled","untitled-1","untitled-3","uuencode"])}.${t(["applescript","bat","beam","bin","exe","js","mam","py","sh","vdo","wiz"])}`};class w extends c{constructor(...t){super(),this.converter=new l(85,4,5,84),this.charsets.adobe=[..."!\"#$%&'()*+,-./0123456789:;<=>?@ABCDEFGHIJKLMNOPQRSTUVWXYZ[\\]^_`abcdefghijklmnopqrstu"],this.charsets.ascii85=this.charsets.adobe.slice(),this.charsets.rfc1924=[..."0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz!#$%&()*+-;<=>?@^_`{|}~"],this.charsets.z85=[..."0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ.-:+=^!/*?&<>()[]{}@%$#"],this.version="ascii85",this.utils.validateArgs(t,!0)}encode(t,...e){return super.encode(t,(t=>{let e;return t.version.match(/adobe|ascii85/)&&(e=(t,e)=>e||"!!!!!"!==t?t:"z"),e}),(({output:t,settings:e,zeroPadding:i})=>{if(i){const e=this.converter.padBytes(i);t=t.slice(0,-e)}return"adobe"===e.version&&(t=`<~${t}~>`),t}),...e)}decode(t,...e){return super.decode(t,(({input:t,settings:e})=>(e.version.match(/adobe|ascii85/)&&(t=t.replace(/z/g,"!!!!!"),"adobe"===e.version&&(t=t.replace(/^<~|~>$/g,""))),t)),null,!1,...e)}}class v extends c{constructor(...t){super(),this.converter={radix:91,bsEnc:0,bsDec:0},this.charsets.default=[...'ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789!#$%&()*+,./:;<=>?@[]^_`{|}~"'],this.version="default",this.utils.validateArgs(t,!0)}encode(t,...e){const i=this.utils.validateArgs(e),s=this.utils.inputHandler.toBytes(t,i)[0];let r=0,n=0,o="";const a=this.charsets[i.version];if(s.forEach((t=>{if(n+=t<13){let t,e,i=13,s=n%8192;s<89&&(i=14,s=n%16384),n>>=i,r-=i,[t,e]=this.#s(s,91),o=`${o}${a[e]}${a[t]}`}})),r){let t,e;[t,e]=this.#s(n,91),o=o.concat(a[e]),(r>7||n>90)&&(o=o.concat(a[t]))}return this.utils.wrapOutput(o,i.options.lineWrap)}decode(t,...e){const i=this.utils.validateArgs(e),s=this.charsets[i.version];t=this.utils.normalizeInput(t);let r=[...t];i.integrity||(r=r.filter((t=>s.includes(t))));let n=r.length,o=!1;n%2&&(o=!0,n--);let h=0,l=0;const c=new Array;for(let t=0;t88?13:14;do{c.push(h%256),h>>=8,l-=8}while(l>7)}if(o){const t=r.at(n),e=s.indexOf(t);c.push(((e<>=7n,0==a&&0==(64&t)||-1==a&&0!=(64&t)){h.push(t);break}h.push(128|t)}else for(;;){const t=Number(127n&a);if(a>>=7n,0==a){h.push(t);break}h.push(128|t)}const l=Uint8Array.from(h);return"hex"===i.version?this.hexlify.encode(l,[..."0123456789abcdef"],!1)[0]:l}decode(e,...i){const s=this.utils.validateArgs(i);if("hex"===s.version)e=this.hexlify.decode(this.utils.normalizeInput(e).toLowerCase(),[..."0123456789abcdef"],[],s.integrity,!1);else{if(void 0===e.byteLength)throw new TypeError("Input must be a bytes like object.");e=t.toBytes(e)[0]}if(1===e.length&&!e[0])return this.utils.outputHandler.compile(new Uint8Array(1),s.outputType,!0);e=Array.from(e);let r,n,o,a=0n,h=-7n;for(r of e)h+=7n,a+=BigInt(127&r)<{e.forEach((e=>{e in this.#r?this.#r[e].version+=t:this.#r[e]={version:t}}))},i=(e,i,s)=>{i.forEach((i=>{i in t?this.#r[i].version=3:(this.#r[i]={version:e,padding:s},t[i]=s)}))};e(1,this.charsets.emojis_v1),e(2,this.charsets.emojis_v2),i(1,this.padChars.emojis_v1.slice(0,-1),"last"),i(2,this.padChars.emojis_v2.slice(0,-1),"last"),i(1,this.padChars.emojis_v1.slice(-1),"fill"),i(2,this.padChars.emojis_v2.slice(-1),"fill");const s=[];for(const e in t)"last"===t[e]?s.push(e):s.push(`${e}+`);this.#n=new RegExp(s.join("|"),"g")}encode(t,...e){return super.encode(t,null,(({output:t,settings:e,zeroPadding:i})=>{const s=this.charsets[e.version];let r=[...t];if(i>1){const t=this.converter.padBytes(i);if(e.padding){const i=e.trim?1:t,s=new Array(i).fill(this.padChars[e.version].at(-1));r.splice(r.length-t,t,...s)}else r.splice(r.length-t,t)}else if(1===i){const t=s.indexOf(r.pop())>>8;r.push(this.padChars[e.version].at(t))}return r.join("")}),...e)}decode(t,...e){const i=this.utils.validateArgs(e);t=this.utils.normalizeInput(t);let s=i.version,r=null;"emojis_v1"!==i.version&&"emojis_v2"!==i.version||(r=3);const n=t=>{null!==r&&(r=this.#a(t,r,i.integrity),s=3===r?i.version:`emojis_v${r}`);const e=this.charsets[s],n=[...t],o=n.at(-1);let a=!1;for(let i=0;i{const r=s.index+s.at(0).length;e.push(...n(t.slice(i,r))),i=r})),i!==t.length&&e.push(...n(t.slice(i,t.length))),a=Uint8Array.from(e)}return this.utils.outputHandler.compile(a,i.outputType)}#a(t,e,i){const s=[...t];let r;if(s.forEach(((t,s)=>{if(!(t in this.#r))throw new a(t);{const n=this.#r[t].version;if(3!==n)if(3===e)e=n;else if(e!==n)throw new TypeError(`Emojis from different ecoji versions seen : ${t} from emojis_v${n}`);if(i){const e=this.#r[t].padding;if(e){const i=s%4;if(r=!0,"fill"===e){if(0===i)throw new TypeError(`Padding unexpectedly seen in first position ${t}`)}else if(3!==i)throw new TypeError(`Last padding seen in unexpected position ${t}`)}else if(r)throw new TypeError("Unexpectedly saw non-padding after padding")}}})),i&&s.length%4&&(1===e||"fill"!==this.#r[s.at(-1)].padding))throw new TypeError("Unexpected end of data, input data size not multiple of 4");return e}}class x extends c{constructor(...t){super(),this.converter={radix:2048,bsEnc:11,bsEncPad:3,bsDec:8},this.charsets.default=[..."89ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyzÆÐØÞßæðøþĐđĦħıĸŁłŊŋŒœŦŧƀƁƂƃƄƅƆƇƈƉƊƋƌƍƎƏƐƑƒƓƔƕƖƗƘƙƚƛƜƝƞƟƢƣƤƥƦƧƨƩƪƫƬƭƮƱƲƳƴƵƶƷƸƹƺƻƼƽƾƿǀǁǂǃǝǤǥǶǷȜȝȠȡȢȣȤȥȴȵȶȷȸȹȺȻȼȽȾȿɀɁɂɃɄɅɆɇɈɉɊɋɌɍɎɏɐɑɒɓɔɕɖɗɘəɚɛɜɝɞɟɠɡɢɣɤɥɦɧɨɩɪɫɬɭɮɯɰɱɲɳɴɵɶɷɸɹɺɻɼɽɾɿʀʁʂʃʄʅʆʇʈʉʊʋʌʍʎʏʐʑʒʓʔʕʖʗʘʙʚʛʜʝʞʟʠʡʢʣʤʥʦʧʨʩʪʫʬʭʮʯͰͱͲͳͶͷͻͼͽͿΑΒΓΔΕΖΗΘΙΚΛΜΝΞΟΠΡΣΤΥΦΧΨΩαβγδεζηθικλμνξοπρςστυφχψωϏϗϘϙϚϛϜϝϞϟϠϡϢϣϤϥϦϧϨϩϪϫϬϭϮϯϳϷϸϺϻϼϽϾϿЂЄЅІЈЉЊЋЏАБВГДЕЖЗИКЛМНОПРСТУФХЦЧШЩЪЫЬЭЮЯабвгдежзиклмнопрстуфхцчшщъыьэюяђєѕіјљњћџѠѡѢѣѤѥѦѧѨѩѪѫѬѭѮѯѰѱѲѳѴѵѸѹѺѻѼѽѾѿҀҁҊҋҌҍҎҏҐґҒғҔҕҖҗҘҙҚқҜҝҞҟҠҡҢңҤҥҦҧҨҩҪҫҬҭҮүҰұҲҳҴҵҶҷҸҹҺһҼҽҾҿӀӃӄӅӆӇӈӉӊӋӌӍӎӏӔӕӘәӠӡӨөӶӷӺӻӼӽӾӿԀԁԂԃԄԅԆԇԈԉԊԋԌԍԎԏԐԑԒԓԔԕԖԗԘԙԚԛԜԝԞԟԠԡԢԣԤԥԦԧԨԩԪԫԬԭԮԯԱԲԳԴԵԶԷԸԹԺԻԼԽԾԿՀՁՂՃՄՅՆՇՈՉՊՋՌՍՎՏՐՑՒՓՔՕՖաբգդեզէըթժիլխծկհձղճմյնշոչպջռսվտրցւփքօֆאבגדהוזחטיךכלםמןנסעףפץצקרשתװױײؠءابةتثجحخدذرزسشصضطظعغػؼؽؾؿفقكلمنهوىي٠١٢٣٤٥٦٧٨٩ٮٯٱٲٳٴٹٺٻټٽپٿڀځڂڃڄڅچڇڈډڊڋڌڍڎڏڐڑڒړڔڕږڗژڙښڛڜڝڞڟڠڡڢڣڤڥڦڧڨکڪګڬڭڮگڰڱڲڳڴڵڶڷڸڹںڻڼڽھڿہۃۄۅۆۇۈۉۊۋیۍێۏېۑےەۮۯ۰۱۲۳۴۵۶۷۸۹ۺۻۼۿܐܒܓܔܕܖܗܘܙܚܛܜܝܞܟܠܡܢܣܤܥܦܧܨܩܪܫܬܭܮܯݍݎݏݐݑݒݓݔݕݖݗݘݙݚݛݜݝݞݟݠݡݢݣݤݥݦݧݨݩݪݫݬݭݮݯݰݱݲݳݴݵݶݷݸݹݺݻݼݽݾݿހށނރބޅކއވމފދތލގޏސޑޒޓޔޕޖޗޘޙޚޛޜޝޞޟޠޡޢޣޤޥޱ߀߁߂߃߄߅߆߇߈߉ߊߋߌߍߎߏߐߑߒߓߔߕߖߗߘߙߚߛߜߝߞߟߠߡߢߣߤߥߦߧߨߩߪࠀࠁࠂࠃࠄࠅࠆࠇࠈࠉࠊࠋࠌࠍࠎࠏࠐࠑࠒࠓࠔࠕࡀࡁࡂࡃࡄࡅࡆࡇࡈࡉࡊࡋࡌࡍࡎࡏࡐࡑࡒࡓࡔࡕࡖࡗࡘࡠࡡࡢࡣࡤࡥࡦࡧࡨࡩࡪࢠࢡࢢࢣࢤࢥࢦࢧࢨࢩࢪࢫࢬࢭࢮࢯࢰࢱࢲࢳࢴࢶࢷࢸࢹࢺࢻࢼࢽऄअआइईउऊऋऌऍऎएऐऑऒओऔकखगघङचछजझञटठडढणतथदधनपफबभमयरलळवशषसहऽॐॠॡ०१२३४५६७८९ॲॳॴॵॶॷॸॹॺॻॼॽॾॿঀঅআইঈউঊঋঌএঐওঔকখগঘঙচছজঝঞটঠডঢণতথদধনপফবভমযরলশষসহঽৎৠৡ০১২৩৪৫৬৭৮৯ৰৱ৴৵৶৷৸৹ৼਅਆਇਈਉਊਏਐਓਔਕਖਗਘਙਚਛਜਝਞਟਠਡਢਣਤਥਦਧਨਪਫਬਭਮਯਰਲਵਸਹੜ੦੧੨੩੪੫੬੭੮੯ੲੳੴઅઆઇઈઉઊઋઌઍએઐઑઓઔકખગઘઙચછજઝઞટઠડઢણતથદધનપફબભમયરલળવશષસહઽૐૠૡ૦૧૨૩૪૫૬૭૮૯ૹଅଆଇଈଉଊଋଌଏଐଓଔକଖଗଘଙଚଛଜଝଞଟଠଡଢଣତଥଦଧନପଫବଭମଯରଲଳଵଶଷସହଽୟୠୡ୦୧୨୩୪୫୬୭୮୯ୱ୲୳୴୵୶୷ஃஅஆஇஈஉஊஎஏஐஒஓகஙசஜஞடணதநனபமயரறலளழவஶஷஸஹௐ௦௧௨௩௪௫௬௭௮௯௰௱௲అఆఇఈఉఊఋఌఎఏఐఒఓఔకఖగఘఙచఛజఝఞటఠడఢణతథదధనపఫబభమయరఱలళఴవశషసహఽౘౙౚౠౡ౦౧౨౩౪౫౬౭౮౯౸౹౺౻౼౽౾ಀಅಆಇಈಉಊಋಌಎಏಐಒಓಔಕಖಗಘಙಚಛಜಝಞಟಠಡಢಣತಥದಧನಪಫಬಭಮಯರಱಲಳವಶಷಸಹಽೞೠೡ೦೧೨೩೪೫೬೭೮೯ೱೲഅആഇഈഉഊഋഌഎഏഐഒഓഔകഖഗഘങചഛജഝഞടഠഡഢണതഥദധനഩപഫബഭമയരറലളഴവശഷസഹഺഽൎൔൕൖ൘൙൚൛൜൝൞ൟൠൡ൦൧൨൩൪൫൬൭൮൯൰൱൲൳൴൵൶൷൸ൺൻർൽൾൿඅආඇඈඉඊඋඌඍඎඏඐඑඒඓඔඕඖකඛගඝඞඟචඡජඣඤඥඦටඨඩඪණඬතථදධනඳපඵබභමඹයරලවශෂසහළෆ෦෧෨෩෪෫෬෭෮෯กขฃคฅฆงจฉชซฌญฎฏฐฑฒณดตถทธนบปผฝพฟภมยรฤลฦวศษสหฬอฮฯะาเแโใไๅ๐๑๒๓๔๕๖๗๘๙ກຂຄງຈຊຍດຕຖທນບປຜຝພຟມຢຣລວສຫອຮຯະາຽເແໂໃໄ໐໑໒໓໔໕໖໗໘໙ໞໟༀ༠༡༢༣༤༥༦༧༨༩༪༫༬༭༮༯༰༱༲༳ཀཁགངཅཆཇཉཊཋཌཎཏཐདནཔཕབམཙཚཛཝཞཟའཡརལཤཥསཧཨཪཫཬྈྉྊྋྌကခဂဃငစဆဇဈဉညဋဌဍဎဏတထဒဓနပဖဗဘမယရလဝသဟဠအဢဣဤဥဧဨဩဪဿ၀၁၂၃၄၅၆၇၈၉ၐၑၒၓၔၕ"],this.padChars.default=[..."01234567"],this.padCharAmount=8,this.hasSignedMode=!0,this.littleEndian=!1,this.utils.validateArgs(t,!0)}encode(t,...e){const i=this.utils.validateArgs(e);let s=this.utils.inputHandler.toBytes(t,i).at(0);const r=this.charsets[i.version],n=this.padChars[i.version];let o="",a=0,h=0;if(s.forEach((t=>{for(let e=this.converter.bsDec-1;e>=0;e--)a=(a<<1)+(t>>e&1),h++,h===this.converter.bsEnc&&(o+=r.at(a),a=0,h=0)})),0!==h){let t,e;for(h<=this.converter.bsEncPad?(t=this.converter.bsEncPad,e=!0):(t=this.converter.bsEnc,e=!1);h!==t;)if(a=1+(a<<1),h++,h>this.converter.bsEnc)throw new Error("Cannot process input. This is a bug!");o+=e?n.at(a):r.at(a)}return this.utils.wrapOutput(o,i.options.lineWrap)}decode(t,...e){const i=this.utils.validateArgs(e);t=this.utils.normalizeInput(t);const s=[...t],r=this.charsets[i.version],n=this.padChars[i.version],o=new Array;let h=0,l=0;return s.forEach(((t,e)=>{let c,u=r.indexOf(t);if(u>-1)c=this.converter.bsEnc;else if(u=n.indexOf(t),u>-1){if(e+1!==s.length)throw new a(null,`Secondary character found before end of input, index: ${e}`);c=this.converter.bsEncPad}else if(i.integrity)throw new a(t);for(let t=c-1;t>=0;t--)h=(h<<1)+(u>>t&1),l++,l===this.converter.bsDec&&(o.push(h),h=0,l=0)})),this.utils.outputHandler.compile(Uint8Array.from(o),i.outputType)}}class T extends c{constructor(t,...e){if(super(),!t||!Number.isInteger(t)||t<2||t>62)throw new RangeError("Radix argument must be provided and has to be an integer between 2 and 62.");this.converter=new l(t,0,0),this.charsets.default=[..."0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ"].slice(0,t),this.frozenCharsets=!0,this.hasSignedMode=!0,this.littleEndian=!(2===t||16===t),this.signed=!0,this.version="default",this.isMutable.littleEndian=!0,this.isMutable.upper=t<=36,this.utils.validateArgs(e,!0)}encode(t,...e){return super.encode(t,null,null,...e)}decode(t,...e){return super.decode(t,(({input:t})=>{if(2===this.converter.radix){const e=(8-t.length%8)%8;t=`${"0".repeat(e)}${t}`}else if(16===this.converter.radix){const e=t.length%2;t=`${"0".repeat(e)}${t}`}return t}),null,!1,...e)}}let M=1e6,j="[big.js] ",C=j+"Invalid ",$=C+"decimal places",I=C+"rounding mode",B={},S=/^-?(\d+(\.\d*)?|\.\d+)(e[+-]?\d+)?$/i;function k(t,e,i,s){let r=t.c;if(void 0===i&&(i=t.constructor.RM),0!==i&&1!==i&&2!==i&&3!==i)throw Error(I);if(e<1)s=3===i&&(s||!!r[0])||0===e&&(1===i&&r[0]>=5||2===i&&(r[0]>5||5===r[0]&&(s||void 0!==r[1]))),r.length=1,s?(t.e=t.e-e+1,r[0]=1):r[0]=t.e=0;else if(e=5||2===i&&(r[e]>5||5===r[e]&&(s||void 0!==r[e+1]||1&r[e-1]))||3===i&&(s||!!r[0]),r.length=e,s)for(;++r[--e]>9;)if(r[e]=0,0===e){++t.e,r.unshift(1);break}for(e=r.length;!r[--e];)r.pop()}return t}function _(t,e,i){let s=t.e,r=t.c.join(""),n=r.length;if(e)r=r.charAt(0)+(n>1?"."+r.slice(1):"")+(s<0?"e":"e+")+s;else if(s<0){for(;++s;)r="0"+r;r="0."+r}else if(s>0)if(++s>n)for(s-=n;s--;)r+="0";else s1&&(r=r.charAt(0)+"."+r.slice(1));return t.s<0&&i?"-"+r:r}B.abs=function(){let t=new this.constructor(this);return t.s=1,t},B.cmp=function(t){let e,i=this,s=i.c,r=(t=new i.constructor(t)).c,n=i.s,o=t.s,a=i.e,h=t.e;if(!s[0]||!r[0])return s[0]?n:r[0]?-o:0;if(n!=o)return n;if(e=n<0,a!=h)return a>h^e?1:-1;for(o=(a=s.length)<(h=r.length)?a:h,n=-1;++nr[n]^e?1:-1;return a==h?0:a>h^e?1:-1},B.eq=function(t){return 0===this.cmp(t)},B.gt=function(t){return this.cmp(t)>0},B.gte=function(t){return this.cmp(t)>-1},B.lt=function(t){return this.cmp(t)<0},B.lte=function(t){return this.cmp(t)<1},B.minus=B.sub=function(t){let e,i,s,r,n=this,o=n.constructor,a=n.s,h=(t=new o(t)).s;if(a!=h)return t.s=-h,n.plus(t);let l=n.c.slice(),c=n.e,u=t.c,d=t.e;if(!l[0]||!u[0])return u[0]?t.s=-h:l[0]?t=new o(n):t.s=1,t;if(a=c-d){for((r=a<0)?(a=-a,s=l):(d=c,s=u),s.reverse(),h=a;h--;)s.push(0);s.reverse()}else for(i=((r=l.length0)for(;h--;)l[e++]=0;for(h=e;i>a;){if(l[--i]0?(h=o,s=l):(e=-e,s=a),s.reverse();e--;)s.push(0);s.reverse()}for(a.length-l.length<0&&(s=l,l=a,a=s),e=l.length,i=0;e;a[e]%=10)i=(a[--e]=a[e]+l[e]+i)/10|0;for(i&&(a.unshift(i),++h),e=a.length;0===a[--e];)a.pop();return t.c=a,t.e=h,t},B.round=function(t,e){if(void 0===t)t=0;else if(t!==~~t||t<-M||t>M)throw Error($);return k(new this.constructor(this),t+this.e+1,e)},B.toFixed=function(t,e){let i=this,s=i.c[0];if(void 0!==t){if(t!==~~t||t<0||t>M)throw Error($);for(i=k(new i.constructor(i),t+i.e+1,e),t=t+i.e+1;i.c.length=e.PE,!!t.c[0])},B.toNumber=function(){let t=Number(_(this,!0,!0));if(!0===this.constructor.strict&&!this.eq(t.toString()))throw Error(j+"Imprecise conversion");return t};const U=function t(){function e(i){let s=this;if(!(s instanceof e))return void 0===i?t():new e(i);if(i instanceof e)s.s=i.s,s.e=i.e,s.c=i.c.slice();else{if("string"!=typeof i){if(!0===e.strict&&"bigint"!=typeof i)throw TypeError(C+"value");i=0===i&&1/i<0?"-0":String(i)}!function(t,e){let i,s,r;if(!S.test(e))throw Error(`${C}number`);for(t.s="-"==e.charAt(0)?(e=e.slice(1),-1):1,(i=e.indexOf("."))>-1&&(e=e.replace(".","")),(s=e.search(/e/i))>0?(i<0&&(i=s),i+=+e.slice(s+1),e=e.substring(0,s)):i<0&&(i=e.length),r=e.length,s=0;s0&&"0"==e.charAt(--r););for(t.e=i-s-1,t.c=[],i=0;s<=r;)t.c[i++]=+e.charAt(s++)}}(s,i)}s.constructor=e}return e.prototype=B,e.DP=20,e.RM=1,e.NE=-7,e.PE=21,e.strict=false,e.roundDown=0,e.roundHalfUp=1,e.roundHalfEven=2,e.roundUp=3,e}();class N extends c{#h=U("1.618033988749894848204586834365638117720309179805762862135448622705260462818902449707207204189391137484754088075386891752");constructor(...t){super(),this.converter={radix:2,bsEnc:0,bsDec:0},this.b10=new l(10,0,0),this.charsets.default=["0","1"],this.version="default",this.signed=!0,this.hasDecimalMode=!0,this.utils.validateArgs(t,!0)}encode(t,...e){const i=this.utils.validateArgs(e),s=this.charsets[i.version];let r,n,o,a="";if(i.decimalMode){if(!Number.isFinite(t))throw new TypeError("When running the converter in decimal-mode, only input of type 'Number' is allowed.");t<0?(n=!0,o=U(-t)):(n=!1,o=U(t))}else[r,n]=this.utils.inputHandler.toBytes(t,i),o=U(this.b10.encode(r,null,i.littleEndian)[0]);if(o.eq(0)||o.eq(1))return a=s[o.toNumber()],n&&(a=`-${a}`),a;const h=[],l=[];let c=U(1),u=this.#h,d=0;for(;u.lt(o);)[c,u]=this.#l(c,u),d++;const f=(t,e,i)=>{if(!this.#c(o)){for(;t.gt(o);){if([t,e]=this.#u(t,e),t.lte(0))return void console.warn("Could not find an exact base-phi representation. Value is approximated.");i--}i>-1?h.unshift(i):l.push(i),o=o.minus(t),f(t,e,i)}};return f(c,u,d),d=0,h.forEach((t=>{for(;d{for(;d>t;)a+=s[0],d--;a+=s[1],d--})),n&&(a=`-${a}`),a}decode(t,...e){const i=this.utils.validateArgs(e),s=this.charsets[i.version];let r;if([t,r]=this.utils.extractSign(this.utils.normalizeInput(t)),!i.integrity){const e=[...s,"."];t=[...t].filter((t=>e.includes(t))).join("")}const n=t.split(".");if(i.integrity&&n.length>2)throw new a(null,"There are multiple decimal points in the input.");const[o,h]=n;let l=U(0),c=this.#h.minus(1),u=U(1);if([...o].reverse().forEach((t=>{const e=s.indexOf(t);if(1===e)l=l.plus(u);else if(0!==e)throw new a(t);[c,u]=this.#l(c,u)})),h){let t=U(1);u=this.#h.minus(t),[...h].forEach((e=>{const i=s.indexOf(e);if(1===i)l=l.plus(u);else if(0!==i)throw new a(e);[u,t]=this.#u(u,t)}))}if(i.decimalMode)return l.toNumber();l=l.round().toFixed();const d=this.b10.decode(l,[..."0123456789"],[],i.integrity,i.littleEndian);return this.utils.outputHandler.compile(d,i.outputType,i.littleEndian,r)}#c(t){return!t.round(50).abs().toNumber()}#l(t,e){return[e,t.plus(e)]}#u(t,e){return[e.minus(t),t]}}const D=(()=>{const t=new Uint16Array([1]),e=new Uint8Array(t.buffer);return Boolean(e.at(0))})();class O{constructor(...t){this.littleEndian=D,this.numberMode=!1,this.outputType="buffer",this.utils={validateArgs:(t,e=!1)=>{const i={littleEndian:this.littleEndian,numberMode:this.numberMode,outputType:this.outputType,signed:!1};if(!t.length)return i;t.includes("number")&&(t.splice(t.indexOf("number"),1),i.numberMode=!0,i.outputType="float_n");const r=s.typeList.map((t=>`'${t}'`)).join(", ");if(t.forEach((t=>{if("le"===(t=String(t).toLowerCase()))i.littleEndian=!0;else if("be"===t)i.littleEndian=!1;else{if(!s.typeList.includes(t))throw new TypeError(`Invalid argument: '${t}.\nValid arguments are:\n'le', 'be', ${r}`);i.outputType=t}})),e)for(const t in i)this[t]=i[t];return i}},this.utils.validateArgs(t,!0)}encode(t,...e){const s=this.utils.validateArgs(e);return i.toBytes(t,s)[0]}decode(t,...e){const i=this.utils.validateArgs(e);return s.compile(t,i.outputType,i.littleEndian)}} /** * [BaseEx]{@link https://github.com/UmamiAppearance/BaseExJS} * - * @version 0.4.3 + * @version 0.6.1 * @author UmamiAppearance [mail@umamiappearance.eu] * @license GPL-3.0 AND BSD-3-Clause (only regarding Base91, Copyright (c) 2000-2006 Joachim Henke) */ /** * [BrowserSHAObj]{@link https://github.com/UmamiAppearance/BrowserSHAObj} * - * @version 0.3.2 + * @version 0.3.3 * @author UmamiAppearance [mail@umamiappearance.eu] * @license GPL-3.0 */ -const m=["SHA-1","SHA-256","SHA-384","SHA-512"],v=new class{constructor(t="buffer"){if(!r.typeList.includes(t)){let e=`Invalid argument '${t}' for output type. Allowed types are:\n`;throw e=e.concat(r.typeList.join(", ")),new TypeError(e)}this.base1=new h("default",t),this.base16=new u("default",t),this.base32_crockford=new c("rfc4648",t),this.base32_rfc3548=new c("rfc3548",t),this.base32_rfc4648=new c("rfc4648",t),this.base32_zbase32=new c("zbase32",t),this.base58=new d("default",t),this.base58_bitcoin=new d("bitcoin",t),this.base58_flickr=new d("flickr",t),this.base64=new f("default",t),this.base64_urlsafe=new f("urlsafe",t),this.base85_adobe=new p("adobe",t),this.base85_ascii=new p("ascii85",t),this.base85_z85=new p("z85",t),this.base91=new g("default",t),this.leb128=new y("default",t),this.byteConverter=new b(t),this.simpleBase={};for(let e=2;e<37;e++)this.simpleBase[`base${e}`]=new w(e,t)}};class A{#e=null;#s=null;#i=null;#n=[];constructor(t="SHA-256"){const e=this.constructor.algorithmsAvailable();if(this.#s=0|[].concat(String(t).match(/[0-9]+/)).at(0),this.#e=`SHA-${this.#s}`,1===this.#s&&(this.#s=160),!e.has(this.#e))throw new TypeError(`Available algorithms are: '${m.join(", ")}'.`);this.#r()}static baseEx=v;static algorithmsAvailable(){return new Set(m)}static algorithmsGuaranteed(){return this.constructor.algorithmsAvailable()}static async new(t="SHA-256",e=null){const s=new this(t);return null!==e&&await s.update(e),s}get digestSize(){return this.#s/8}get blockSize(){return this.#s>256?128:64}get name(){return this.#e}async copy(){const t=this.#n.length?Uint8Array.from(this.#n):null;return this.constructor.new(this.#e,t)}async update(t,e=!1){let s;(t=t instanceof ArrayBuffer?new Uint8Array(t):ArrayBuffer.isView(t)?new Uint8Array(t.buffer):v.byteConverter.encode(t,"uint8")).byteLength<2e8?(this.#n=e?Array.from(t):this.#n.concat(Array.from(t)),s=Uint8Array.from(this.#n),s.byteLength>5e8&&!this.warned&&(console.warn("The stored input is getting really big. Dependent from your environment this can lead to memory issues."),this.warned=!0)):(console.warn("Input gets too big to safely store it in memory. It will get processed directly and neither stored nor concatenated to previous input. If the operation fails, it is due to memory issues."),s=t),this.#i=await window.crypto.subtle.digest(this.#e,s)}async replace(t){await this.update(t,!0)}digest(){return this.#i}#r(){const t=(t,e)=>t.splice(t.indexOf(e),1),e=t=>t.charAt(0).toUpperCase().concat(t.slice(1));this.hexdigest=()=>this.#i?v.base16.encode(this.#i):null;const s=Object.keys(v);this.basedigest={toSimpleBase:{}},t(s,"base1"),t(s,"byteConverter"),t(s,"simpleBase");for(const t of s)this.basedigest[`to${e(t)}`]=(...e)=>this.#i?v[t].encode(this.#i,...e):null;for(const t in v.simpleBase)this.basedigest.toSimpleBase[e(t)]=(...e)=>this.#i?v.simpleBase[t].encode(this.#i,...e):null;this.basedigest.toBytes=(...t)=>this.#i?v.byteConverter.encode(this.#i,...t):null}}export{A as default}; +const P=["SHA-1","SHA-256","SHA-384","SHA-512"],z=new class{constructor(t="buffer"){if(!n.typeList.includes(t)){let e=`Invalid argument '${t}' for output type. Allowed types are:\n`;throw e=e.concat(n.typeList.join(", ")),new TypeError(e)}this.base1=new u("default",t),this.base16=new d("default",t),this.base32_crockford=new f("rfc4648",t),this.base32_rfc3548=new f("rfc3548",t),this.base32_rfc4648=new f("rfc4648",t),this.base32_zbase32=new f("zbase32",t),this.base58=new p("default",t),this.base58_bitcoin=new p("bitcoin",t),this.base58_flickr=new p("flickr",t),this.base64=new g("default",t),this.base64_urlsafe=new g("urlsafe",t),this.uuencode=new b("default",t),this.xxencode=new b("xx",t),this.base85_adobe=new w("adobe",t),this.base85_ascii=new w("ascii85",t),this.base85_z85=new w("z85",t),this.base91=new v("default",t),this.leb128=new E("default",t),this.ecoji_v1=new A("emojis_v1",t),this.ecoji_v2=new A("emojis_v2",t),this.base2048=new x("default",t),this.basePhi=new N("default",t),this.byteConverter=new O(t),this.simpleBase={};for(let e=2;e<=62;e++)this.simpleBase[`base${e}`]=new T(e,t)}};class H{#d=null;#f=null;#p=null;#g=[];constructor(t="SHA-256"){const e=this.constructor.algorithmsAvailable();if(this.#f=0|[].concat(String(t).match(/[0-9]+/)).at(0),this.#d=`SHA-${this.#f}`,1===this.#f&&(this.#f=160),!e.has(this.#d))throw new TypeError(`Available algorithms are: '${P.join(", ")}'.`);this.#b()}static baseEx=z;static algorithmsAvailable(){return new Set(P)}static algorithmsGuaranteed(){return this.constructor.algorithmsAvailable()}static async new(t="SHA-256",e=null){const i=new this(t);return null!==e&&await i.update(e),i}get digestSize(){return this.#f/8}get blockSize(){return this.#f>256?128:64}get name(){return this.#d}async copy(){const t=this.#g.length?Uint8Array.from(this.#g):null;return this.constructor.new(this.#d,t)}async update(t,e=!1){let i;(t=t instanceof ArrayBuffer?new Uint8Array(t):ArrayBuffer.isView(t)?new Uint8Array(t.buffer):z.byteConverter.encode(t,"uint8")).byteLength<2e8?(this.#g=e?Array.from(t):this.#g.concat(Array.from(t)),i=Uint8Array.from(this.#g),i.byteLength>5e8&&!this.warned&&(console.warn("The stored input is getting really big. Dependent from your environment this can lead to memory issues."),this.warned=!0)):(console.warn("Input gets too big to safely store it in memory. It will get processed directly and neither stored nor concatenated to previous input. If the operation fails, it is due to memory issues."),i=t),this.#p=await window.crypto.subtle.digest(this.#d,i)}async replace(t){await this.update(t,!0)}digest(){return this.#p}#b(){const t=(t,e)=>t.splice(t.indexOf(e),1),e=t=>t.charAt(0).toUpperCase().concat(t.slice(1));this.hexdigest=()=>this.#p?z.base16.encode(this.#p):null;const i=Object.keys(z);this.basedigest={toSimpleBase:{}},t(i,"base1"),t(i,"byteConverter"),t(i,"simpleBase");for(const t of i)this.basedigest[`to${e(t)}`]=(...e)=>this.#p?z[t].encode(this.#p,...e):null;for(const t in z.simpleBase)this.basedigest.toSimpleBase[e(t)]=(...e)=>this.#p?z.simpleBase[t].encode(this.#p,...e):null;this.basedigest.toBytes=(...t)=>this.#p?z.byteConverter.encode(this.#p,...t):null}}export{H as default}; diff --git a/dist/BrowserSHAObj.iife.js b/dist/BrowserSHAObj.iife.js index 8dec502..c7da943 100644 --- a/dist/BrowserSHAObj.iife.js +++ b/dist/BrowserSHAObj.iife.js @@ -517,6 +517,23 @@ var BrowserSHAObj = (function () { const DEFAULT_INPUT_HANDLER = SmartInput; const DEFAULT_OUTPUT_HANDLER = SmartOutput; + class SignError extends TypeError { + constructor() { + super("The input is signed but the converter is not set to treat input as signed.\nYou can pass the string 'signed' to the decode function or when constructing the converter."); + this.name = "SignError"; + } + } + + class DecodingError extends TypeError { + constructor(char, msg=null) { + if (msg === null) { + msg = `Character '${char}' is not part of the charset.`; + } + super(msg); + this.name = "DecodingError"; + } + } + /** * Utilities for every BaseEx class. @@ -525,16 +542,19 @@ var BrowserSHAObj = (function () { */ class Utils { - constructor(main, addCharsetTools=true) { + constructor(main) { // Store the calling class in this.root // for accessability. this.root = main; + + // set specific args object for converters + this.converterArgs = {}; // If charsets are uses by the parent class, // add extra functions for the user. - if ("charsets" in main && addCharsetTools) this.#charsetUserToolsConstructor(); + this.#charsetUserToolsConstructor(); } setIOHandlers(inputHandler=DEFAULT_INPUT_HANDLER, outputHandler=DEFAULT_OUTPUT_HANDLER) { @@ -542,73 +562,135 @@ var BrowserSHAObj = (function () { this.outputHandler = outputHandler; } + + /** + * Constructor for the ability to add a charset and + * change the default version. + */ #charsetUserToolsConstructor() { - /* - Constructor for the ability to add a charset and - change the default version. - */ - - this.root.addCharset = (name, charset) => { - /* - Save method to add a charset. - ---------------------------- - - @name: string that represents the key for the new charset - @charset: string, array or Set of chars - the length must fit to the according class - */ + + /** + * Save method to add a charset. + * @param {string} name - "Charset name." + * @param {[string|set|array]} - "Charset" + */ + this.root.addCharset = (name, _charset, _padChars=[], info=true) => { + + const normalize = (typeName, set, setLen) => { + + if (setLen === 0 && set.length) { + console.warn(`This converter has no ${typeName}. The following argument was ignored:\n'${set}'`); + return []; + } + + let inputLen = setLen; + + if (typeof set === "string") { + set = [...set]; + } + + if (Array.isArray(set)) { + + // Store the input length of the input + inputLen = set.length; + + // Convert to "Set" -> eliminate duplicates + // If duplicates are found the length of the + // Set and the length of the initial input + // differ. + + set = new Set(set); + + } else if (!(set instanceof Set)) { + throw new TypeError(`The ${typeName} must be one of the types:\n'str', 'set', 'array'."`); + } + if (set.size === setLen) { + return [...set]; + } + + if (inputLen !== setLen) { + throw new Error(`Your ${typeName} has a length of ${inputLen}. The converter requires a length of ${setLen}.`); + } else { + const charAmounts = {}; + _charset = [..._charset]; + _charset.forEach(c => { + if (c in charAmounts) { + charAmounts[c]++; + } else { + charAmounts[c] = 1; + } + }); + + let infoStr = ""; + if (setLen < 100) { + infoStr = `${_charset.join("")}\n`; + _charset.forEach(c => { + if (charAmounts[c] > 1) { + infoStr += "^"; + } else { + infoStr += " "; + } + }); + } + const rChars = Object.keys(charAmounts).filter(c => charAmounts[c] > 1); + throw new Error(`You have repetitive char(s) [ ${rChars.join(" | ")} ] in your ${typeName}. Make sure each character is unique.\n${infoStr}`); + } + }; + + if (this.root.frozenCharsets) { + throw new Error("The charsets of this converter cannot be changed."); + } + if (typeof name !== "string") { throw new TypeError("The charset name must be a string."); } - // Get the appropriate length for the charset - // from the according converter - - const setLen = this.root.converter.radix; - let inputLen = setLen; - - if (typeof charset === "string" || Array.isArray(charset)) { - - // Store the input length of the input - inputLen = charset.length; - - // Convert to "Set" -> eliminate duplicates - // If duplicates are found the length of the - // Set and the length of the initial input - // differ. + if (info && name in this.root.charsets) { + console.warn(`An existing charset with name ${name} will get replaced.`); + } - charset = new Set(charset); + const charset = normalize("charset", _charset, this.root.converter.radix); + const padChars = normalize("padding set", _padChars, this.root.padCharAmount); - } else if (!(charset instanceof Set)) { - throw new TypeError("The charset must be one of the types:\n'str', 'set', 'array'."); + this.root.charsets[name] = charset; + if (padChars.length) { + this.root.padChars[name] = padChars; } - - if (charset.size === setLen) { - charset = [...charset].join(""); - this.root.charsets[name] = charset; + + if (info) { console.info(`New charset '${name}' was added and is ready to use`); - } else if (inputLen === setLen) { - throw new Error("There were repetitive chars found in your charset. Make sure each char is unique."); - } else { - throw new Error(`The length of the charset must be ${setLen}.`); } }; // Save method (argument gets validated) to // change the default version. this.root.setDefaultCharset = (version) => { - ({version } = this.validateArgs([version])); + if (!(version in this.root.charsets)) { + const sets = Object.keys(this.root.charsets).join("\n * "); + const msg = `Charset ${version} was not found. Available charsets are:\n * ${sets}`; + throw new TypeError(msg); + } this.root.version = version; }; } - makeArgList(args) { - /* - Returns argument lists for error messages. - */ + /** + * Argument lists for error messages. + * @param {string[]} args + * @returns string - Arguments joined as a string. + */ + #makeArgList(args) { return args.map(s => `'${s}'`).join(", "); } + /** + * Removes all padded zeros a the start of the string, + * adds a "-" if value is negative. + * @param {string} output - Former output. + * @param {boolean} negative - Indicates a negative value if true. + * @returns {string} - Output without zero padding and a sign if negative. + */ toSignedStr(output, negative) { output = output.replace(/^0+(?!$)/, ""); @@ -620,8 +702,14 @@ var BrowserSHAObj = (function () { return output; } + /** + * Analyzes the input for a negative sign. + * If a sign is found, it gets removed but + * negative bool gets true; + * @param {string} input - Input number as a string. + * @returns {array} - Number without sign and negativity indication bool. + */ extractSign(input) { - // Test for a negative sign let negative = false; if (input[0] === "-") { negative = true; @@ -631,29 +719,57 @@ var BrowserSHAObj = (function () { return [input, negative]; } - invalidArgument(arg, versions, outputTypes, initial) { - const IOHandlerHint = (initial) ? "\n * valid declarations for IO handlers are 'bytesOnly', 'bytesIn', 'bytesOut'" : ""; - const signedHint = (this.root.isMutable.signed) ? "\n * pass 'signed' to disable, 'unsigned' to enable the use of the twos's complement for negative integers" : ""; - const endiannessHint = (this.root.isMutable.littleEndian) ? "\n * 'be' for big , 'le' for little endian byte order for case conversion" : ""; - const padHint = (this.root.isMutable.padding) ? "\n * pass 'pad' to fill up, 'nopad' to not fill up the output with the particular padding" : ""; - const caseHint = (this.root.isMutable.upper) ? "\n * valid args for changing the encoded output case are 'upper' and 'lower'" : ""; - const outputHint = `\n * valid args for the output type are ${this.makeArgList(outputTypes)}`; - const versionHint = (versions) ? `\n * the options for version (charset) are: ${this.makeArgList(versions)}` : ""; - const numModeHint = "\n * 'number' for number-mode (converts every number into a Float64Array to keep the natural js number type)"; + /** + * All possible error messages for invalid arguments, + * gets adjusted according to the converter settings. + * @param {string} arg - Argument. + * @param {string[]} versions - Charset array. + * @param {string[]} outputTypes - Array of output types. + * @param {boolean} initial - Indicates if the arguments where passed during construction. + */ + #invalidArgument(arg, versions, outputTypes, initial) { + const loopConverterArgs = () => Object.keys(this.converterArgs).map( + key => this.converterArgs[key].map( + keyword => `'${keyword}'` + ) + .join(" and ") + ) + .join("\n - "); - throw new TypeError(`'${arg}'\n\nInput parameters:${IOHandlerHint}${signedHint}${endiannessHint}${padHint}${caseHint}${outputHint}${versionHint}${numModeHint}\n\nTraceback:`); + throw new TypeError([ + `'${arg}'\n\nParameters:`, + initial ? "\n * valid declarations for IO handlers are 'bytesOnly', 'bytesIn', 'bytesOut'" : "", + this.root.isMutable.signed ? "\n * pass 'signed' to disable, 'unsigned' to enable the use of the twos's complement for negative integers" : "", + this.root.isMutable.littleEndian ? "\n * 'be' for big , 'le' for little endian byte order for case conversion" : "", + this.root.isMutable.padding ? "\n * pass 'pad' to fill up, 'nopad' to not fill up the output with the particular padding" : "", + this.root.isMutable.upper ? "\n * valid args for changing the encoded output case are 'upper' and 'lower'" : "", + `\n * valid args for the output type are ${this.#makeArgList(outputTypes)}`, + versions ? `\n * the option(s) for version/charset are: ${this.#makeArgList(versions)}` : "", + "\n * valid args for integrity check are: 'integrity' and 'nointegrity'", + this.root.hasDecimalMode ? "\n * 'decimal' for decimal-mode (directly converts Numbers including decimal values, without byte-conversion)" : "", + "\n * 'number' for number-mode (converts every number into a Float64Array to keep the natural js number type)", + Object.keys(this.converterArgs).length ? `\n * converter specific args:\n - ${loopConverterArgs()}` : "", + "\n\nTraceback:" + ].join("")); } + + /** + * Test if provided arguments are in the argument list. + * Everything gets converted to lowercase and returned. + * @param {string[]} args - Passed arguments. + * @param {boolean} initial - Indicates if the arguments where passed during construction. + * @returns {Object} - Converter settings object. + */ validateArgs(args, initial=false) { - /* - Test if provided arguments are in the argument list. - Everything gets converted to lowercase and returned - */ // default settings const parameters = { + decimalMode: this.root.decimalMode, + integrity: this.root.integrity, littleEndian: this.root.littleEndian, numberMode: this.root.numberMode, + options: this.root.options, outputType: this.root.outputType, padding: this.root.padding, signed: this.root.signed, @@ -661,6 +777,11 @@ var BrowserSHAObj = (function () { version: this.root.version }; + // add any existing converter specific args + for (const param in this.converterArgs) { + parameters[param] = this.root[param]; + } + // if no args are provided return the default settings immediately if (!args.length) { @@ -684,12 +805,14 @@ var BrowserSHAObj = (function () { }; // set available versions and extra arguments - const versions = Object.prototype.hasOwnProperty.call(this.root, "charsets") ? Object.keys(this.root.charsets) : []; + const versions = Object.keys(this.root.charsets); const extraArgList = { + integrity: ["nointegrity", "integrity"], littleEndian: ["be", "le"], padding: ["nopad", "pad"], signed: ["unsigned", "signed"], upper: ["lower", "upper"], + ...this.converterArgs }; // if initial, look for IO specifications @@ -710,10 +833,31 @@ var BrowserSHAObj = (function () { if (extractArg("number")) { parameters.numberMode = true; parameters.outputType = "float_n"; + } + + // test for the special "decimal" keyword + if (extractArg("decimal")) { + if (!this.root.hasDecimalMode) { + throw TypeError(`Argument 'decimal' is only allowed for converters with a non-integer base.`); + } + parameters.decimalMode = true; + parameters.outputType = "decimal"; + + if (parameters.numberMode) { + parameters.numberMode = false; + console.warn("-> number-mode was disabled due to the decimal-mode"); + } } // walk through the remaining arguments args.forEach((arg) => { + + // additional/optional non boolean options + if (typeof arg === "object") { + parameters.options = {...parameters.options, ...arg}; + return; + } + arg = String(arg).toLowerCase(); if (versions.includes(arg)) { @@ -749,7 +893,7 @@ var BrowserSHAObj = (function () { } if (invalidArg) { - this.invalidArgument(arg, versions, outputTypes, initial); + this.#invalidArgument(arg, versions, outputTypes, initial); } } }); @@ -759,7 +903,7 @@ var BrowserSHAObj = (function () { // displayed. if (parameters.padding && parameters.signed) { parameters.padding = false; - this.constructor.warning("Padding was set to false due to the signed conversion."); + console.warn("-> padding was set to false due to the signed conversion"); } // overwrite the default parameters for the initial call @@ -772,17 +916,40 @@ var BrowserSHAObj = (function () { return parameters; } + /** + * A TypeError specifically for sign errors. + */ signError() { - throw new TypeError("The input is signed but the converter is not set to treat input as signed.\nYou can pass the string 'signed' to the decode function or when constructing the converter."); + throw new SignError(); } - static warning(message) { - if (Object.prototype.hasOwnProperty.call(console, "warn")) { - console.warn(message); - } else { - console.log(`___\n${message}\n`); + /** + * Wrap output to "cols" characters per line. + * @param {string} output - Output string. + * @param {number} cols - Number of cols per line. + * @returns {string} - Wrapped output. + */ + wrapOutput(output, cols=0) { + if (!cols) { + return output; } + const m = new RegExp(`.{1,${cols}}`, "gu"); + return output.match(m).join("\n"); } + + /** + * Ensures a string input. + * @param {*} input - Input. + * @param {boolean} [keepWS=false] - If set to false, whitespace is getting removed from the input if present. + * @returns {string} - Normalized input. + */ + normalizeInput(input, keepWS=false) { + if (keepWS) { + return String(input); + } + return String(input).replace(/\s/g, ""); + } + } /** @@ -854,7 +1021,7 @@ var BrowserSHAObj = (function () { * @param {{ buffer: ArrayBufferLike; byteLength: any; byteOffset: any; length: any; BYTES_PER_ELEMENT: 1; }} inputBytes - Input as Uint8Array. * @param {string} charset - The charset used for conversion. * @param {boolean} littleEndian - Byte order, little endian bool. - * @param {*} replacer - Replacer function can replace groups of characters during encoding. + * @param {function} replacer - Replacer function can replace groups of characters during encoding. * @returns {number[]} - Output string and padding amount. */ encode(inputBytes, charset, littleEndian=false, replacer=null) { @@ -966,16 +1133,16 @@ var BrowserSHAObj = (function () { /** * BaseEx Universal Base Decoding. + * Decodes to a string of the given radix to a byte array. * @param {string} inputBaseStr - Base as string (will also get converted to string but can only be used if valid after that). - * @param {string} charset - The charset used for conversion. - * @param {*} littleEndian - Byte order, little endian bool. + * @param {string[]} charset - The charset used for conversion. + * @param {string[]} padSet - Padding characters for integrity check. + * @param {boolean} integrity - If set to false invalid character will be ignored. + * @param {boolean} littleEndian - Byte order, little endian bool. * @returns {{ buffer: ArrayBufferLike; byteLength: any; byteOffset: any; length: any; BYTES_PER_ELEMENT: 1; }} - The decoded output as Uint8Array. */ - decode(inputBaseStr, charset, littleEndian=false) { - /* - Decodes to a string of the given radix to a byte array - */ - + decode(inputBaseStr, charset, padSet=[], integrity=true, littleEndian=false) { + // Convert each char of the input to the radix-integer // (this becomes the corresponding index of the char // from the charset). Every char, that is not found in @@ -989,13 +1156,14 @@ var BrowserSHAObj = (function () { let bs = this.bsDec; const byteArray = new Array(); - inputBaseStr.split('').forEach((c) => { + [...inputBaseStr].forEach(c => { const index = charset.indexOf(c); if (index > -1) { - byteArray.push(index); + byteArray.push(index); + } else if (integrity && padSet.indexOf(c) === -1) { + throw new DecodingError(c); } }); - let padChars; @@ -1152,18 +1320,28 @@ var BrowserSHAObj = (function () { // predefined settings this.charsets = {}; + this.decimalMode = false; + this.frozenCharsets = false; + this.hasDecimalMode = false; this.hasSignedMode = false; + this.integrity = true; this.littleEndian = false; this.numberMode = false; this.outputType = "buffer"; this.padding = false; + this.padCharAmount = 0; + this.padChars = {}; this.signed = false; this.upper = null; if (appendUtils) this.utils = new Utils(this); this.version = "default"; + this.options = { + lineWrap: 0 + }; // list of allowed/disallowed args to change this.isMutable = { + integrity: true, littleEndian: false, padding: false, signed: false, @@ -1174,8 +1352,8 @@ var BrowserSHAObj = (function () { /** * BaseEx Generic Encoder. * @param {*} input - Any input the used byte converter allows. - * @param {*} [replacerFN] - Replacer function, which is passed to the encoder. - * @param {*} [postEncodeFN] - Function, which is executed after encoding. + * @param {function} [replacerFN] - Replacer function, which is passed to the encoder. + * @param {function} [postEncodeFN] - Function, which is executed after encoding. * @param {...any} args - Converter settings. * @returns {string} - Base encoded string. */ @@ -1185,8 +1363,7 @@ var BrowserSHAObj = (function () { const settings = this.utils.validateArgs(args); // handle input - let inputBytes, negative, type; - [inputBytes, negative, type] = this.utils.inputHandler.toBytes(input, settings); + let [inputBytes, negative, type] = this.utils.inputHandler.toBytes(input, settings); // generate replacer function if given let replacer = null; @@ -1195,8 +1372,7 @@ var BrowserSHAObj = (function () { } // Convert to base string - let output, zeroPadding; - [output, zeroPadding] = this.converter.encode(inputBytes, this.charsets[settings.version], settings.littleEndian, replacer); + let [output, zeroPadding] = this.converter.encode(inputBytes, this.charsets[settings.version], settings.littleEndian, replacer); // set sign if requested if (settings.signed) { @@ -1213,32 +1389,32 @@ var BrowserSHAObj = (function () { output = postEncodeFN({ inputBytes, output, settings, zeroPadding, type }); } - return output; + return this.utils.wrapOutput(output, settings.options.lineWrap); } /** * BaseEx Generic Decoder. - * @param {string} rawInput - Base String. - * @param {*} [preDecodeFN] - Function, which gets executed before decoding. - * @param {*} [postDecodeFN] - Function, which gets executed after decoding + * @param {string} input - Base String. + * @param {function} [preDecodeFN] - Function, which gets executed before decoding. + * @param {function} [postDecodeFN] - Function, which gets executed after decoding * @param {...any} args - Converter settings. * @returns {*} - Output according to converter settings. */ - decode(rawInput, preDecodeFN, postDecodeFN, ...args) { + decode(input, preDecodeFN, postDecodeFN, keepNL, ...args) { // apply settings const settings = this.utils.validateArgs(args); // ensure a string input - let input = String(rawInput); + input = this.utils.normalizeInput(input, keepNL); // set negative to false for starters let negative = false; // Test for a negative sign if converter supports it if (this.hasSignedMode) { - [input, negative] = this.utils.extractSign(input); + [ input, negative ] = this.utils.extractSign(input); // But don't allow a sign if the decoder is not configured to use it if (negative && !settings.signed) { @@ -1258,7 +1434,13 @@ var BrowserSHAObj = (function () { } // Run the decoder - let output = this.converter.decode(input, this.charsets[settings.version], settings.littleEndian); + let output = this.converter.decode( + input, + this.charsets[settings.version], + this.padChars[settings.version], + settings.integrity, + settings.littleEndian + ); // Run post decode function if provided if (postDecodeFN) { @@ -1272,7 +1454,7 @@ var BrowserSHAObj = (function () { /** * [BaseEx|Base1 Converter]{@link https://github.com/UmamiAppearance/BaseExJS/blob/main/src/converters/base-1.js} * - * @version 0.4.3 + * @version 0.6.1 * @author UmamiAppearance [mail@umamiappearance.eu] * @license GPL-3.0 */ @@ -1295,21 +1477,17 @@ var BrowserSHAObj = (function () { constructor(...args) { super(); - // Remove global charset adding method as - // it is not suitable for this converter. - delete this.addCharset; - // All chars in the string are used and picked randomly (prob. suitable for obfuscation) - this.charsets.all = " !\"#$%&'()*+,./0123456789:;<=>?@ABCDEFGHIJKLMNOPQRSTUVWXYZ[\\]^_`abcdefghijklmnopqrstuvwxyz{|}~"; + this.charsets.all = [..." !\"#$%&'()*+,-./0123456789:;<=>?@ABCDEFGHIJKLMNOPQRSTUVWXYZ[\\]^_`abcdefghijklmnopqrstuvwxyz{|}~"]; // The sequence is used from left to right again and again - this.charsets.sequence = "Hello World!"; + this.charsets.sequence = [..."Hello World!"]; // Standard unary string with one character - this.charsets.default = "1"; + this.charsets.default = ["1"]; // Telly Mark string, using hash for 5 and vertical bar for 1 - this.charsets.tmark = "|#"; + this.charsets.tmark = ["|", "#"]; // Base 10 converter this.converter = new BaseConverter(10, 0, 0); @@ -1320,6 +1498,7 @@ var BrowserSHAObj = (function () { this.signed = true; // mutable extra args + this.isMutable.charsets = false; this.isMutable.signed = true; this.isMutable.upper = true; @@ -1355,7 +1534,7 @@ var BrowserSHAObj = (function () { if (n > Number.MAX_SAFE_INTEGER) { throw new RangeError("Invalid string length."); } else if (n > 16777216) { - this.utils.constructor.warning("The string length is really long. The JavaScript engine may have memory issues generating the output string."); + console.warn("The string length is really long. The JavaScript engine may have memory issues generating the output string."); } n = Number(n); @@ -1366,7 +1545,7 @@ var BrowserSHAObj = (function () { // Convert to unary in respect to the version differences if (charAmount === 1) { - output = charset.repeat(n); + output = charset.at(0).repeat(n); } else if (settings.version === "all") { for (let i=0; i 4) { - output = charset[1].repeat((n - singulars) / 5); + output = charset.at(1).repeat((n - singulars) / 5); } - output += charset[0].repeat(singulars); + output += charset.at(0).repeat(singulars); } else { for (let i=0; i { - - let { input: normInput } = scope; + const normalizeInput = ({ input: normInput, settings }) => { + // Remove "0x" if present normInput = normInput.replace(/^0x/, ""); + // remove non-charset characters if integrity + // check is disabled + if (!settings.integrity) { + normInput = normInput + .toLowerCase() + .replace(/[^0-9a-f]/g, ""); + } + // Ensure even number of characters if (normInput.length % 2) { normInput = "0".concat(normInput); @@ -1503,14 +1691,14 @@ var BrowserSHAObj = (function () { return normInput; }; - return super.decode(input, normalizeInput, null, ...args); + return super.decode(input, normalizeInput, null, false, ...args); } } /** * [BaseEx|Base32 Converter]{@link https://github.com/UmamiAppearance/BaseExJS/blob/main/src/converters/base-32.js} * - * @version 0.4.3 + * @version 0.6.1 * @author UmamiAppearance [mail@umamiappearance.eu] * @license GPL-3.0 */ @@ -1539,19 +1727,24 @@ var BrowserSHAObj = (function () { */ constructor(...args) { super(); + this.converter = new BaseConverter(32, 5, 8); // charsets - this.charsets.crockford = "0123456789abcdefghjkmnpqrstvwxyz"; - this.charsets.rfc3548 = "abcdefghijklmnopqrstuvwxyz234567"; - this.charsets.rfc4648 = "0123456789abcdefghijklmnopqrstuv"; - this.charsets.zbase32 = "ybndrfg8ejkmcpqxot1uwisza345h769"; - - // converter - this.converter = new BaseConverter(32, 5, 8); + this.charsets.crockford = [ ..."0123456789abcdefghjkmnpqrstvwxyz" ]; + this.padChars.crockford = ["="], + this.charsets.rfc3548 = [..."abcdefghijklmnopqrstuvwxyz234567"]; + this.padChars.rfc3548 = ["="]; + + this.charsets.rfc4648 = [..."0123456789abcdefghijklmnopqrstuv"]; + this.padChars.rfc4648 = ["="]; + + this.charsets.zbase32 = [..."ybndrfg8ejkmcpqxot1uwisza345h769"]; + this.padChars.zbase32 = ["="]; + // predefined settings + this.padCharAmount = 1; this.hasSignedMode = true; - this.padding = true; this.version = "rfc4648"; // mutable extra args @@ -1562,6 +1755,8 @@ var BrowserSHAObj = (function () { // apply user settings this.utils.validateArgs(args, true); + this.padding = (/rfc3548|rfc4648/).test(this.version); + this.upper = this.version === "crockford"; } @@ -1573,17 +1768,16 @@ var BrowserSHAObj = (function () { */ encode(input, ...args) { - const applyPadding = (scope) => { - - let { output, settings, zeroPadding } = scope; + const applyPadding = ({ output, settings, zeroPadding }) => { if (!settings.littleEndian) { // Cut of redundant chars and append padding if set if (zeroPadding) { const padValue = this.converter.padBytes(zeroPadding); - output = output.slice(0, output.length-padValue); + const padChar = this.padChars[settings.version].at(0); + output = output.slice(0, -padValue); if (settings.padding) { - output = output.concat("=".repeat(padValue)); + output = output.concat(padChar.repeat(padValue)); } } } @@ -1602,14 +1796,14 @@ var BrowserSHAObj = (function () { * @returns {*} - Output according to converter settings. */ decode(input, ...args) { - return super.decode(input, null, null, ...args); + return super.decode(input, null, null, false, ...args); } } /** * [BaseEx|Base58 Converter]{@link https://github.com/UmamiAppearance/BaseExJS/blob/main/src/converters/base-58.js} * - * @version 0.4.3 + * @version 0.6.1 * @author UmamiAppearance [mail@umamiappearance.eu] * @license GPL-3.0 */ @@ -1634,15 +1828,25 @@ var BrowserSHAObj = (function () { * @param {...string} [args] - Converter settings. */ constructor(...args) { - super(); + super(); + this.converter = new BaseConverter(58, 0, 0); // charsets - this.charsets.default = "123456789abcdefghijkmnopqrstuvwxyzABCDEFGHJKLMNPQRSTUVWXYZ"; - this.charsets.bitcoin = "123456789ABCDEFGHJKLMNPQRSTUVWXYZabcdefghijkmnopqrstuvwxyz"; - this.charsets.flickr = "123456789abcdefghijkmnopqrstuvwxyzABCDEFGHJKLMNPQRSTUVWXYZ"; + this.charsets.default = [..."123456789abcdefghijkmnopqrstuvwxyzABCDEFGHJKLMNPQRSTUVWXYZ"]; + Object.defineProperty(this.padChars, "default", { + get: () => [ this.charsets.default.at(0) ] + }); - // converter - this.converter = new BaseConverter(58, 0, 0); + this.charsets.bitcoin = [..."123456789ABCDEFGHJKLMNPQRSTUVWXYZabcdefghijkmnopqrstuvwxyz"]; + Object.defineProperty(this.padChars, "bitcoin", { + get: () => [ this.charsets.bitcoin.at(0) ] + }); + + this.charsets.flickr = [..."123456789abcdefghijkmnopqrstuvwxyzABCDEFGHJKLMNPQRSTUVWXYZ"]; + Object.defineProperty(this.padChars, "flickr", { + get: () => [ this.charsets.flickr.at(0) ] + }); + // predefined settings this.padding = true; @@ -1665,9 +1869,7 @@ var BrowserSHAObj = (function () { */ encode(input, ...args) { - const applyPadding = (scope) => { - - let { inputBytes, output, settings, type } = scope; + const applyPadding = ({ inputBytes, output, settings, type }) => { if (settings.padding && type !== "int") { @@ -1677,6 +1879,9 @@ var BrowserSHAObj = (function () { let i = 0; const end = inputBytes.length; + // pad char is always! the first char in the set + const padChar = this.charsets[settings.version].at(0); + // only proceed if input has a length at all if (end) { while (!inputBytes[i]) { @@ -1693,7 +1898,7 @@ var BrowserSHAObj = (function () { // Set a one for every leading null byte if (zeroPadding) { - output = ("1".repeat(zeroPadding)).concat(output); + output = (padChar.repeat(zeroPadding)).concat(output); } } } @@ -1714,15 +1919,16 @@ var BrowserSHAObj = (function () { decode(input, ...args) { // post decoding function - const applyPadding = (scope) => { + const applyPadding = ({ input, output, settings }) => { - let { input, output, settings } = scope; + // pad char is always! the first char in the set + const padChar = this.charsets[settings.version].at(0); if (settings.padding && input.length > 1) { - // Count leading ones + // Count leading padding (char should be 1) let i = 0; - while (input[i] === "1") { + while (input[i] === padChar) { i++; } @@ -1740,14 +1946,14 @@ var BrowserSHAObj = (function () { return output; }; - return super.decode(input, null, applyPadding, ...args); + return super.decode(input, null, applyPadding, false, ...args); } } /** * [BaseEx|Base64 Converter]{@link https://github.com/UmamiAppearance/BaseExJS/blob/main/src/converters/base-64.js} * - * @version 0.4.3 + * @version 0.6.1 * @author UmamiAppearance [mail@umamiappearance.eu] * @license GPL-3.0 */ @@ -1766,22 +1972,24 @@ var BrowserSHAObj = (function () { */ class Base64 extends BaseTemplate { - /** + /**this.padChars. * BaseEx Base64 Constructor. * @param {...string} [args] - Converter settings. */ constructor(...args) { super(); + this.converter = new BaseConverter(64, 3, 4); // charsets - const b62Chars = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789"; - this.charsets.default = b62Chars.concat("+/"); - this.charsets.urlsafe = b62Chars.concat("-_"); - - // converter - this.converter = new BaseConverter(64, 3, 4); + this.charsets.default = [..."ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/"]; + this.padChars.default = ["="]; + + this.charsets.urlsafe = this.charsets.default.slice(0, -2).concat(["-", "_"]); + this.padChars.urlsafe = ["="]; + // predefined settings + this.padCharAmount = 1; this.padding = true; // mutable extra args @@ -1800,16 +2008,15 @@ var BrowserSHAObj = (function () { */ encode(input, ...args) { - const applyPadding = (scope) => { - - let { output, settings, zeroPadding } = scope; + const applyPadding = ({ output, settings, zeroPadding }) => { // Cut of redundant chars and append padding if set if (zeroPadding) { const padValue = this.converter.padBytes(zeroPadding); - output = output.slice(0, output.length-padValue); + const padChar = this.padChars[settings.version].at(0); + output = output.slice(0, -padValue); if (settings.padding) { - output = output.concat("=".repeat(padValue)); + output = output.concat(padChar.repeat(padValue)); } } @@ -1827,14 +2034,218 @@ var BrowserSHAObj = (function () { * @returns {*} - Output according to converter settings. */ decode(input, ...args) { - return super.decode(input, null, null, ...args); + return super.decode(input, null, null, false, ...args); + } + } + + /** + * [BaseEx|UUencode Converter]{@link https://github.com/UmamiAppearance/BaseExJS/blob/main/src/converters/uuencode.js} + * + * @version 0.6.1 + * @author UmamiAppearance [mail@umamiappearance.eu] + * @license GPL-3.0 + */ + + /** + * BaseEx UUencode Converter. + * ------------------------ + * + * This is a base64 converter. Various input can be + * converted to a base64 string or a base64 string + * can be decoded into various formats. + * + * Available charsets are: + * - default + * - urlsafe + */ + class UUencode extends BaseTemplate { + + /** + * BaseEx UUencode Constructor. + * @param {...string} [args] - Converter settings. + */ + constructor(...args) { + super(); + this.converter = new BaseConverter(64, 3, 4); + + // charsets + this.charsets.default = [..."`!\"#$%&'()*+,-./0123456789:;<=>?@ABCDEFGHIJKLMNOPQRSTUVWXYZ[\\]^_"]; + Object.defineProperty(this.padChars, "default", { + get: () => [ this.charsets.default.at(0) ] + }); + + this.charsets.original = [" ", ...this.charsets.default.slice(1)]; + Object.defineProperty(this.padChars, "original", { + get: () => [ this.charsets.original.at(0) ] + }); + + this.charsets.xx = [..."+-0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz"]; + Object.defineProperty(this.padChars, "xx", { + get: () => [ this.charsets.xx.at(0) ] + }); + + + // predefined settings + this.padding = true; + this.header = false; + this.utils.converterArgs.header = ["noheader", "header"]; + this.isMutable.header = true; + this.isMutable.integrity = false; + + // apply user settings + this.utils.validateArgs(args, true); + } + + + /** + * BaseEx UUencoder. + * @param {*} input - Input according to the used byte converter. + * @param {...str} [args] - Converter settings. + * @returns {string} - UUencode string. + */ + encode(input, ...args) { + + const format = ({ output, settings, zeroPadding }) => { + + const charset = this.charsets[settings.version]; + const outArray = [...output]; + + + if (settings.header) { + const permissions = settings.options.permissions || een(); + const fileName = settings.options.file || ees(); + output = `begin ${permissions} ${fileName}\n`; + } else { + output = ""; + } + + // repeatedly take 60 chars from the output until it is empty + for (;;) { + const lArray = outArray.splice(0, 60); + + // if all chars are taken, remove eventually added pad zeros + if (!outArray.length) { + const byteCount = this.converter.padChars(lArray.length) - zeroPadding; + + // add the the current chars plus the leading + // count char + output += `${charset.at(byteCount)}${lArray.join("")}\n`; + break; + } + + // add the the current chars plus the leading + // count char ("M" for default charsets) + output += `${charset.at(45)}${lArray.join("")}\n`; + } + + output += `${charset.at(0)}\n`; + + if (settings.header) { + output += "\nend"; + } + + + return output; + }; + + return super.encode(input, null, format, ...args); + } + + + /** + * BaseEx UUdecoder. + * @param {string} input - UUencode String. + * @param {...any} [args] - Converter settings. + * @returns {*} - Output according to converter settings. + */ + decode(input, ...args) { + + let padChars = 0; + + const format = ({ input, settings }) => { + + const charset = this.charsets[settings.version]; + const lines = input.trim().split("\n"); + const inArray = []; + + if ((/^begin/i).test(lines.at(0))) { + lines.shift(); + } + + for (const line of lines) { + const lArray = [...line]; + const byteCount = charset.indexOf(lArray.shift()); + + if (!(byteCount > 0)) { + break; + } + + inArray.push(...lArray); + + if (byteCount !== 45) { + padChars = this.converter.padChars(lArray.length) - byteCount; + break; + } + } + + return inArray.join(""); + + }; + + const removePadChars = ({ output }) => { + if (padChars) { + output = new Uint8Array(output.slice(0, -padChars)); + } + return output; + }; + + return super.decode(input, format, removePadChars, true, ...args); } } + + const een = () => { + const o = () => Math.floor(Math.random() * 8); + return `${o()}${o()}${o()}`; + }; + + const ees = () => { + const name = [ + "unchronological", + "unconditionally", + "underemphasized", + "underprivileged", + "undistinguished", + "unsophisticated", + "untitled", + "untitled-1", + "untitled-3", + "uuencode" + ]; + + const ext = [ + "applescript", + "bat", + "beam", + "bin", + "exe", + "js", + "mam", + "py", + "sh", + "vdo", + "wiz" + ]; + + const pick = (arr) => arr.at(Math.floor(Math.random() * arr.length)); + + return `${pick(name)}.${pick(ext)}`; + }; + /** * [BaseEx|Base85 Converter]{@link https://github.com/UmamiAppearance/BaseExJS/blob/main/src/converters/base-85.js} * - * @version 0.4.3 + * @version 0.6.1 * @author UmamiAppearance [mail@umamiappearance.eu] * @license GPL-3.0 */ @@ -1872,15 +2283,13 @@ var BrowserSHAObj = (function () { */ constructor(...args) { super(); + this.converter = new BaseConverter(85, 4, 5, 84); // charsets - this.charsets.adobe = "!\"#$%&'()*+,-./0123456789:;<=>?@ABCDEFGHIJKLMNOPQRSTUVWXYZ[\\]^_`abcdefghijklmnopqrstu"; - this.charsets.ascii85 = this.charsets.adobe; - this.charsets.rfc1924 = "0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz!#$%&()*+-;<=>?@^_`{|}~"; - this.charsets.z85 = "0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ.-:+=^!/*?&<>()[]{}@%$#"; - - // converter - this.converter = new BaseConverter(85, 4, 5, 84); + this.charsets.adobe = [..."!\"#$%&'()*+,-./0123456789:;<=>?@ABCDEFGHIJKLMNOPQRSTUVWXYZ[\\]^_`abcdefghijklmnopqrstu"]; + this.charsets.ascii85 = this.charsets.adobe.slice(); + this.charsets.rfc1924 = [..."0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz!#$%&()*+-;<=>?@^_`{|}~"]; + this.charsets.z85 = [..."0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ.-:+=^!/*?&<>()[]{}@%$#"]; // predefined settings this.version = "ascii85"; @@ -1910,14 +2319,12 @@ var BrowserSHAObj = (function () { // Remove padded values and add a frame for the // adobe variant - const framesAndPadding = (scope) => { - - let { output, settings, zeroPadding } = scope; + const framesAndPadding = ({ output, settings, zeroPadding }) => { // Cut of redundant chars if (zeroPadding) { const padValue = this.converter.padBytes(zeroPadding); - output = output.slice(0, output.length-padValue); + output = output.slice(0, -padValue); } // Adobes variant gets its <~framing~> @@ -1940,9 +2347,7 @@ var BrowserSHAObj = (function () { */ decode(input, ...args) { - const prepareInput = (scope) => { - - let { input, settings } = scope; + const prepareInput = ({ input, settings }) => { // For default ascii85 convert "z" back to "!!!!!" // Remove the adobe <~frame~> @@ -1956,14 +2361,14 @@ var BrowserSHAObj = (function () { return input }; - return super.decode(input, prepareInput, null, ...args); + return super.decode(input, prepareInput, null, false, ...args); } } /** * [BaseEx|Base91 Converter]{@link https://github.com/UmamiAppearance/BaseExJS/blob/main/src/converters/base-91.js} * - * @version 0.4.3 + * @version 0.6.1 * @author UmamiAppearance [mail@umamiappearance.eu] * @license GPL-3.0 AND BSD-3-Clause (Base91, Copyright (c) 2000-2006 Joachim Henke) */ @@ -1973,7 +2378,7 @@ var BrowserSHAObj = (function () { * ------------------------ * * This is a base91 converter. Various input can be - * converted to a base85 string or a base91 string + * converted to a base91 string or a base91 string * can be decoded into various formats. * * It is an implementation of Joachim Henkes method @@ -1993,8 +2398,16 @@ var BrowserSHAObj = (function () { constructor(...args) { super(); + // converter (properties only) + this.converter = { + radix: 91, + bsEnc: 0, + bsDec: 0 + }; + // charsets - this.charsets.default = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789!#$%&()*+,./:;<=>?@[]^_`{|}~\""; + this.charsets.default = [..."ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789!#$%&()*+,./:;<=>?@[]^_`{|}~\""]; + this.version = "default"; // apply user settings this.utils.validateArgs(args, true); @@ -2023,8 +2436,7 @@ var BrowserSHAObj = (function () { let n = 0; let output = ""; - // Shortcut - const chars = this.charsets[settings.version]; + const charset = this.charsets[settings.version]; inputBytes.forEach(byte => { //n = n + byte * 2^bitcount; @@ -2060,12 +2472,12 @@ var BrowserSHAObj = (function () { // the before calculated remainder of n // -> "rN" let q, r; - [q, r] = this.divmod(rN, 91); + [q, r] = this.#divmod(rN, 91); // Lookup the corresponding characters for // "r" and "q" in the set, append it to the // output string. - output = `${output}${chars[r]}${chars[q]}`; + output = `${output}${charset[r]}${charset[q]}`; } }); @@ -2074,20 +2486,20 @@ var BrowserSHAObj = (function () { // once more. if (bitCount) { let q, r; - [q, r] = this.divmod(n, 91); + [q, r] = this.#divmod(n, 91); // The remainder is concatenated in any case - output = output.concat(chars[r]); + output = output.concat(charset[r]); // The quotient is also appended, but only // if the bitCount still has the size of a byte // or n can still represent 91 conditions. if (bitCount > 7 || n > 90) { - output = output.concat(chars[q]); + output = output.concat(charset[q]); } } - return output; + return this.utils.wrapOutput(output, settings.options.lineWrap); } @@ -2101,11 +2513,19 @@ var BrowserSHAObj = (function () { // Argument validation and output settings const settings = this.utils.validateArgs(args); + const charset = this.charsets[settings.version]; // Make it a string, whatever goes in - input = String(input); + input = this.utils.normalizeInput(input); + let inArray = [...input]; + + // remove unwanted characters if integrity is false + if (!settings.integrity) { + inArray = inArray.filter(c => charset.includes(c)); + } - let l = input.length; + + let l = inArray.length; // For starters leave the last char behind // if the length of the input string is odd. @@ -2121,7 +2541,6 @@ var BrowserSHAObj = (function () { let n = 0; let bitCount = 0; - const chars = this.charsets[settings.version]; // Initialize an ordinary array const b256Array = new Array(); @@ -2130,8 +2549,18 @@ var BrowserSHAObj = (function () { // (aka collect remainder- and quotient-pairs) for (let i=0; i 88) ? 13 : 14; @@ -2146,8 +2575,8 @@ var BrowserSHAObj = (function () { // Calculate the last byte if the input is odd // and add it if (odd) { - const lastChar = input.charAt(l); - const rN = chars.indexOf(lastChar); + const lastChar = inArray.at(l); + const rN = charset.indexOf(lastChar); b256Array.push(((rN << bitCount) + n) % 256); } @@ -2164,141 +2593,31 @@ var BrowserSHAObj = (function () { * @param {*} y - number 2 * @returns {number} Modulo y of x */ - divmod (x, y) { + #divmod (x, y) { return [Math.floor(x/y), x%y]; } } /** - * [BaseEx|Byte Converter]{@link https://github.com/UmamiAppearance/BaseExJS/blob/main/src/converters/byte-converter.js} + * [BaseEx|LEB128 Converter]{@link https://github.com/UmamiAppearance/BaseExJS/blob/main/src/converters/leb-128.js} * - * @version 0.4.3 + * @version 0.6.1 * @author UmamiAppearance [mail@umamiappearance.eu] * @license GPL-3.0 */ /** - * BaseEx Byte Converter. + * BaseEx Little Endian Base 128 Converter. * --------------------------------------- * - * This is a byte converter. Various input can be - * converted to a bytes or bytes can be decoded into - * various formats. + * This is a leb128 converter. Various input can be + * converted to a leb128 string or a leb128 string + * can be decoded into various formats. * - * As en- and decoder were already available, for the - * use of converting in- and output for the base - * converters, this is just a little extra tool, which - * was fast and easy to create. - */ - class ByteConverter { - - /** - * BaseEx ByteConverter Constructor. - * @param {...string} [args] - Converter settings. - */ - constructor(...args) { - - // predefined settings - this.littleEndian = true; - this.numberMode = false; - this.outputType = "buffer"; - - // simplified utils - this.utils = { - validateArgs: (args, initial=false) => { - - const parameters = { - littleEndian: this.littleEndian, - numberMode: this.numberMode, - outputType: this.outputType, - signed: false, - }; - - if (!args.length) { - return parameters; - } - - if (args.includes("number")) { - args.splice(args.indexOf("number"), 1); - parameters.numberMode = true; - parameters.outputType = "float_n"; - } - - const outTypes = SmartOutput.typeList.map(s => `'${s}'`).join(", "); - - args.forEach((arg) => { - arg = String(arg).toLowerCase(); - - if (arg === "le") { - parameters.littleEndian = true; - } else if (arg === "be") { - parameters.littleEndian = false; - } else if (SmartOutput.typeList.includes(arg)) { - parameters.outputType = arg; - } else { - throw new TypeError(`Invalid argument: '${arg}.\nValid arguments are:\n'le', 'be', ${outTypes}`); - } - }); - - if (initial) { - for (const param in parameters) { - this[param] = parameters[param]; - } - } - - return parameters; - } - }; - - // apply user settings - this.utils.validateArgs(args, true); - } - - - /** - * BaseEx Byte Encoder. - * @param {*} input - Almost any input. - * @param {...str} [args] - Converter settings. - * @returns {{ buffer: ArrayBufferLike; }} - Bytes of Input. - */ - encode(input, ...args) { - const settings = this.utils.validateArgs(args); - return SmartInput.toBytes(input, settings)[0]; - } - - - /** - * BaseEx Byte Decoder. - * @param {{ buffer: ArrayBufferLike; }} input - Bytes/Buffer/View - * @param {...any} [args] - Converter settings. - * @returns {*} - Output of requested type. - */ - decode(input, ...args) { - const settings = this.utils.validateArgs(args); - return SmartOutput.compile(input, settings.outputType, settings.littleEndian); - } - } - - /** - * [BaseEx|LEB128 Converter]{@link https://github.com/UmamiAppearance/BaseExJS/blob/main/src/converters/leb-128.js} - * - * @version 0.4.3 - * @author UmamiAppearance [mail@umamiappearance.eu] - * @license GPL-3.0 - */ - - /** - * BaseEx Little Endian Base 128 Converter. - * --------------------------------------- - * - * This is a leb128 converter. Various input can be - * converted to a leb128 string or a leb128 string - * can be decoded into various formats. - * - * There is no real charset available as the input is - * getting converted to bytes. For having the chance - * to store these byes, there is a hexadecimal output - * available. + * There is no real charset available as the input is + * getting converted to bytes. For having the chance + * to store these bytes, there is a hexadecimal output + * available. */ class LEB128 extends BaseTemplate { @@ -2308,20 +2627,20 @@ var BrowserSHAObj = (function () { */ constructor(...args) { // initialize base template without utils - super(false); - - // charsets - this.charsets.default = "", - this.charsets.hex = ""; - this.version = "default"; + super(); // converters this.converter = new BaseConverter(10, 0, 0); this.hexlify = new BaseConverter(16, 1, 2); - // utils (as lacking before) - this.utils = new Utils(this, false); - + // charsets + this.charsets.default = ""; + this.charsets.hex = ""; + + // predefined settings + this.version = "default"; + this.frozenCharsets = true; + // predefined settings this.littleEndian = true; this.hasSignedMode = true; @@ -2343,10 +2662,9 @@ var BrowserSHAObj = (function () { // argument validation and input settings const settings = this.utils.validateArgs(args); - let inputBytes, negative; const signed = settings.signed; settings.signed = true; - [inputBytes, negative,] = this.utils.inputHandler.toBytes(input, settings); + const [ inputBytes, negative, ] = this.utils.inputHandler.toBytes(input, settings); // Convert to BaseRadix string let base10 = this.converter.encode(inputBytes, null, settings.littleEndian)[0]; @@ -2389,7 +2707,7 @@ var BrowserSHAObj = (function () { const Uint8Output = Uint8Array.from(output); if (settings.version === "hex") { - return this.hexlify.encode(Uint8Output, "0123456789abcdef", false)[0]; + return this.hexlify.encode(Uint8Output, [..."0123456789abcdef"], false)[0]; } return Uint8Output; @@ -2408,9 +2726,11 @@ var BrowserSHAObj = (function () { const settings = this.utils.validateArgs(args); if (settings.version === "hex") { - input = this.hexlify.decode(String(input).toLowerCase(), "0123456789abcdef", false); - } else if (input instanceof ArrayBuffer) { - input = new Uint8Array(input); + input = this.hexlify.decode(this.utils.normalizeInput(input).toLowerCase(), [..."0123456789abcdef"], [], settings.integrity, false); + } else if (typeof input.byteLength !== "undefined") { + input = BytesInput.toBytes(input)[0]; + } else { + throw new TypeError("Input must be a bytes like object."); } if (input.length === 1 && !input[0]) { @@ -2436,7 +2756,7 @@ var BrowserSHAObj = (function () { let decimalNum, negative; [decimalNum, negative] = this.utils.extractSign(n.toString()); - const output = this.converter.decode(decimalNum, "0123456789", true); + const output = this.converter.decode(decimalNum, [..."0123456789"], [], settings.integrity, true); // Return the output return this.utils.outputHandler.compile(output, settings.outputType, true, negative); @@ -2444,74 +2764,1087 @@ var BrowserSHAObj = (function () { } /** - * [BaseEx|SimpleBase Converter]{@link https://github.com/UmamiAppearance/BaseExJS/blob/main/src/converters/leb-128.js} + * [BaseEx|Ecoji Converter]{@link https://github.com/UmamiAppearance/BaseExJS/blob/main/src/converters/ecoji.js} * - * @version 0.4.3 + * @version 0.6.1 * @author UmamiAppearance [mail@umamiappearance.eu] - * @license GPL-3.0 + * @license GPL-3.0 OR Apache-2.0 + * @see https://github.com/keith-turner/ecoji */ - class SimpleBase extends BaseTemplate { - constructor(radix, ...args) { + /** + * BaseEx Ecoji (a Base 1024) Converter. + * ------------------------------------ + * This an implementation of the Ecoji converter. + * Various input can be converted to an Ecoji string + * or an Ecoji string can be decoded into various + * formats. Versions 1 and 2 are supported. + * This variant pretty much follows the standard + * (at least in its results, the algorithm is very + * different from the original). + * A deviation is the handling of padding. The last + * pad char can be trimmed for both versions and + * additionally omitted completely if integrity + * checks are disabled. + */ + class Ecoji extends BaseTemplate { + + #revEmojiVersion = {}; + #padRegex = null; + + /** + * BaseEx Ecoji Constructor. + * @param {...string} [args] - Converter settings. + */ + constructor(...args) { super(); - if (!radix || !Number.isInteger(radix) || radix < 2 || radix > 36) { - throw new RangeError("Radix argument must be provided and has to be an integer between 2 and 36.") - } + // charsets + this.charsets.emojis_v1 = [..."🀄🃏🅰🅱🅾🅿🆎🆑🆒🆓🆔🆕🆖🆗🆘🆙🆚🇦🇧🇨🇩🇪🇫🇬🇭🇮🇯🇰🇱🇲🇳🇴🇵🇶🇷🇸🇹🇺🇻🇼🇽🇾🇿🈁🈂🈚🈯🈲🈳🈴🈵🈶🈷🈸🈹🈺🉐🉑🌀🌁🌂🌃🌄🌅🌆🌇🌈🌉🌊🌋🌌🌍🌎🌏🌐🌑🌒🌓🌔🌕🌖🌗🌘🌙🌚🌛🌜🌝🌞🌟🌠🌡🌤🌥🌦🌧🌨🌩🌪🌫🌬🌭🌮🌯🌰🌱🌲🌳🌴🌵🌶🌷🌸🌹🌺🌻🌼🌽🌾🌿🍀🍁🍂🍃🍄🍅🍆🍇🍈🍉🍊🍋🍌🍍🍎🍏🍐🍑🍒🍓🍔🍕🍖🍗🍘🍙🍚🍛🍜🍝🍞🍟🍠🍡🍢🍣🍤🍥🍦🍧🍨🍩🍪🍫🍬🍭🍮🍯🍰🍱🍲🍳🍴🍵🍶🍷🍸🍹🍺🍻🍼🍽🍾🍿🎀🎁🎂🎃🎄🎅🎆🎇🎈🎉🎊🎋🎌🎍🎎🎏🎐🎑🎒🎓🎖🎗🎙🎚🎛🎞🎟🎠🎡🎢🎣🎤🎥🎦🎧🎨🎩🎪🎫🎬🎭🎮🎯🎰🎱🎲🎳🎴🎵🎶🎷🎸🎹🎺🎻🎼🎽🎾🎿🏀🏁🏂🏃🏄🏅🏆🏇🏈🏉🏊🏋🏌🏎🏏🏐🏑🏒🏓🏔🏕🏖🏗🏘🏙🏚🏛🏜🏝🏞🏟🏠🏡🏢🏣🏤🏥🏦🏧🏨🏩🏪🏫🏬🏭🏮🏯🏰🏳🏴🏵🏷🏸🏹🏺🏻🏼🏽🏾🏿🐀🐁🐂🐃🐄🐅🐆🐇🐈🐉🐊🐋🐌🐍🐎🐏🐐🐑🐒🐓🐔🐕🐖🐗🐘🐙🐚🐛🐜🐝🐞🐟🐠🐡🐢🐣🐤🐥🐦🐧🐨🐩🐪🐫🐬🐭🐮🐯🐰🐱🐲🐳🐴🐵🐶🐷🐸🐹🐺🐻🐼🐽🐾🐿👀👁👂👃👄👅👆👇👈👉👊👋👌👍👎👏👐👑👒👓👔👕👖👗👘👙👚👛👜👝👞👟👠👡👢👣👤👥👦👧👨👩👪👫👬👭👮👯👰👱👲👳👴👵👶👷👸👹👺👻👼👽👾👿💀💁💂💃💄💅💆💇💈💉💊💋💌💍💎💏💐💑💒💓💔💕💖💗💘💙💚💛💜💝💞💟💠💡💢💣💤💥💦💧💨💩💪💫💬💭💮💯💰💱💲💳💴💵💶💷💸💹💺💻💼💽💾💿📀📁📂📃📄📅📆📇📈📉📊📋📌📍📎📏📐📒📓📔📕📖📗📘📙📚📛📜📝📞📟📠📡📢📣📤📥📦📧📨📩📪📫📬📭📮📯📰📱📲📳📴📵📶📷📸📹📺📻📼📽📿🔀🔁🔂🔃🔄🔅🔆🔇🔈🔉🔊🔋🔌🔍🔎🔏🔐🔑🔒🔓🔔🔕🔖🔗🔘🔙🔚🔛🔜🔝🔞🔟🔠🔡🔢🔣🔤🔥🔦🔧🔨🔩🔪🔫🔬🔭🔮🔯🔰🔱🔲🔳🔴🔵🔶🔷🔸🔹🔺🔻🔼🔽🕉🕊🕋🕌🕍🕎🕐🕑🕒🕓🕔🕕🕖🕗🕘🕙🕚🕛🕜🕝🕞🕟🕠🕡🕢🕣🕤🕥🕦🕧🕯🕰🕳🕴🕵🕶🕷🕸🕹🕺🖇🖊🖋🖌🖍🖐🖕🖖🖤🖥🖨🖱🖲🖼🗂🗃🗄🗑🗒🗓🗜🗝🗞🗡🗣🗨🗯🗳🗺🗻🗼🗽🗾🗿😀😁😂😃😄😅😆😇😈😉😊😋😌😍😎😏😐😑😒😓😔😕😖😗😘😙😚😛😜😝😞😟😠😡😢😣😤😥😦😧😨😩😪😫😬😭😮😯😰😱😲😳😴😵😶😷😸😹😺😻😼😽😾😿🙀🙁🙂🙃🙄🙅🙆🙇🙈🙉🙊🙌🙍🙎🙏🚀🚁🚂🚃🚄🚅🚆🚇🚈🚉🚊🚋🚌🚍🚎🚏🚐🚑🚒🚓🚔🚕🚖🚗🚘🚙🚚🚛🚜🚝🚞🚟🚠🚡🚢🚣🚤🚥🚦🚧🚨🚩🚪🚫🚬🚭🚮🚯🚰🚱🚲🚳🚴🚵🚶🚷🚸🚹🚺🚻🚼🚽🚾🚿🛀🛁🛂🛃🛄🛅🛋🛌🛍🛎🛏🛐🛑🛒🛠🛡🛢🛣🛤🛥🛩🛫🛬🛰🛳🛴🛵🛶🛷🛸🛹🤐🤑🤒🤓🤔🤕🤖🤗🤘🤙🤚🤛🤜🤝🤞🤟🤠🤡🤢🤣🤤🤥🤦🤧🤨🤩🤪🤫🤬🤭🤮🤯🤰🤱🤲🤳🤴🤵🤶🤷🤸🤹🤺🤼🤽🤾🥀🥁🥂🥃🥄🥅🥇🥈🥉🥊🥋🥌🥍🥎🥏🥐🥑🥒🥓🥔🥕🥖🥗🥘🥙🥚🥛🥜🥝🥞🥟🥠🥡🥢🥣🥤🥥🥦🥧🥨🥩🥪🥫🥬🥭🥮🥯🥰🥳🥴🥵🥶🥺🥼🥽🥾🥿🦀🦁🦂🦃🦄🦅🦆🦇🦈🦉🦊🦋🦌🦍🦎🦏🦐🦑🦒🦓🦔🦕🦖🦗🦘🦙🦚🦛🦜🦝🦞🦟🦠🦡🦢🦰🦱🦲🦳🦴🦵🦶🦷🦸🦹🧀🧁🧂🧐🧑🧒🧓🧔🧕"]; + this.padChars.emojis_v1 = [ "⚜", "🏍", "📑", "🙋", "☕" ]; + + this.charsets.emojis_v2 = [..."🀄🃏⏰⏳☔♈♉♊♋♌♍♎♏♐♑♒♓♿⚓⚡⚽⚾⛄⛅⛎⛔⛪⛲⛳⛵⛺⛽✊✋✨⭐🛕🛖🛗🛝🛞🛟🛺🈁🛻🤌🤏🤿🥱🥲🥸🥹🥻🦣🦤🦥🦦🦧🌀🌁🌂🌃🌄🌅🌆🌇🌈🌉🌊🌋🌌🌍🌎🌏🌐🌑🌒🌓🌔🌕🌖🌗🌘🌙🌚🌛🌜🌝🌞🌟🌠🦨🦩🦪🦫🦬🦭🦮🦯🦺🦻🌭🌮🌯🌰🌱🌲🌳🌴🌵🦼🌷🌸🌹🌺🌻🌼🌽🌾🌿🍀🍁🍂🍃🍄🍅🍆🍇🍈🍉🍊🍋🍌🍍🍎🍏🍐🍑🍒🍓🍔🍕🍖🍗🍘🍙🍚🍛🍜🍝🍞🍟🍠🍡🍢🍣🍤🍥🍦🍧🍨🍩🍪🍫🍬🍭🍮🍯🍰🍱🍲🍳🍴🍵🍶🍷🍸🍹🍺🍻🍼🦽🍾🍿🎀🎁🎂🎃🎄🎅🎆🎇🎈🎉🎊🎋🎌🎍🎎🎏🎐🎑🎒🎓🦾🦿🧃🧄🧅🧆🧇🎠🎡🎢🎣🎤🎥🧈🎧🎨🎩🎪🎫🎬🎭🎮🎯🎰🎱🎲🎳🎴🎵🎶🎷🎸🎹🎺🎻🎼🎽🎾🎿🏀🏁🏂🏃🏄🏅🏆🏇🏈🏉🏊🧉🧊🧋🏏🏐🏑🏒🏓🧌🧍🧎🧏🧖🧗🧘🧙🧚🧛🧜🧝🏠🏡🏢🏣🏤🏥🏦🧞🏨🏩🏪🏫🏬🏭🏮🏯🏰🧟🏴🧠🧢🏸🏹🏺🧣🧤🧥🧦🧧🐀🐁🐂🐃🐄🐅🐆🐇🐈🐉🐊🐋🐌🐍🐎🐏🐐🐑🐒🐓🐔🐕🐖🐗🐘🐙🐚🐛🐜🐝🐞🐟🐠🐡🐢🐣🐤🐥🐦🐧🐨🐩🐪🐫🐬🐭🐮🐯🐰🐱🐲🐳🐴🐵🐶🐷🐸🐹🐺🐻🐼🐽🐾🧨👀🧩👂👃👄👅👆👇👈👉👊👋👌👍👎👏👐👑👒👓👔👕👖👗👘👙👚👛👜👝👞👟👠👡👢👣👤👥👦👧👨👩👪👫👬👭👮👯👰👱👲👳👴👵👶👷👸👹👺👻👼👽👾👿💀💁💂💃💄💅💆💇💈💉💊💋💌💍💎💏💐💑💒💓💔💕💖💗💘💙💚💛💜💝💞💟💠💡💢💣💤💥💦💧💨💩💪💫💬💭💮💯💰💱💲💳💴💵💶💷💸🧪💺💻💼💽💾💿📀🧫📂📃📄🧬📆📇📈📉📊📋📌📍📎📏📐📒📓📔📕📖📗📘📙📚📛📜📝📞📟📠📡📢📣📤📥📦📧📨📩📪📫📬📭📮📯📰📱📲📳🧭📵📶📷📸📹📺📻📼🧮📿🧯🧰🧱🧲🧳🔅🔆🔇🔈🔉🔊🔋🔌🔍🔎🔏🔐🔑🔒🔓🔔🔕🔖🔗🔘🧴🧵🧶🧷🧸🧹🧺🧻🧼🧽🧾🧿🔥🔦🔧🔨🔩🔪🔫🔬🔭🔮🔯🔰🔱🔲🔳🩰🩱🩲🩳🩴🩸🩹🩺🩻🩼🪀🪁🕋🕌🕍🕎🪂🪃🪄🪅🪆🪐🪑🪒🪓🪔🪕🪖🪗🪘🪙🪚🪛🪜🪝🪞🪟🪠🪡🪢🪣🪤🪥🪦🪧🪨🪩🪪🪫🕺🪬🪰🪱🪲🪳🪴🖕🖖🖤🪵🪶🪷🪸🪹🪺🫀🫁🫂🫃🫄🫅🫐🫑🫒🫓🫔🫕🫖🫗🗻🗼🗽🗾🗿😀😁😂😃😄😅😆😇😈😉😊😋😌😍😎😏😐😑😒😓😔😕😖😗😘😙😚😛😜😝😞😟😠😡😢😣😤😥😦😧😨😩😪😫😬😭😮😯😰😱😲😳😴😵😶😷😸😹😺😻😼😽😾😿🙀🙁🙂🙃🙄🙅🙆🙇🙈🙉🙊🙌🙍🙎🙏🚀🚁🚂🚃🚄🚅🚆🚇🚈🚉🚊🚋🚌🚍🚎🚏🚐🚑🚒🚓🚔🚕🚖🚗🚘🚙🚚🚛🚜🚝🚞🚟🚠🚡🚢🚣🚤🚥🚦🚧🚨🚩🚪🚫🚬🚭🚮🚯🚰🚱🚲🚳🚴🚵🚶🚷🚸🚹🚺🚻🚼🚽🚾🚿🛀🛁🛂🛃🛄🛅🫘🛌🫙🫠🫡🛐🛑🛒🫢🫣🫤🫥🫦🫧🫰🛫🛬🫱🫲🛴🛵🛶🛷🛸🛹🤐🤑🤒🤓🤔🤕🤖🤗🤘🤙🤚🤛🤜🤝🤞🤟🤠🤡🤢🤣🤤🤥🤦🤧🤨🤩🤪🤫🤬🤭🤮🤯🤰🤱🤲🤳🤴🤵🤶🤷🤸🤹🤺🤼🤽🤾🥀🥁🥂🥃🥄🥅🥇🥈🥉🥊🥋🥌🥍🥎🥏🥐🥑🥒🥓🥔🥕🥖🥗🥘🥙🥚🥛🥜🥝🥞🥟🥠🥡🥢🥣🥤🥥🥦🥧🥨🥩🥪🥫🥬🥭🥮🥯🥰🥳🥴🥵🥶🥺🥼🥽🥾🥿🦀🦁🦂🦃🦄🦅🦆🦇🦈🦉🦊🦋🦌🦍🦎🦏🦐🦑🦒🦓🦔🦕🦖🦗🦘🦙🦚🦛🦜🦝🦞🦟🦠🦡🦢🫳🫴🫵🫶🦴🦵🦶🦷🦸🦹🧀🧁🧂🧐🧑🧒🧓🧔🧕"]; + this.padChars.emojis_v2 = [ "🥷", "🛼", "📑", "🙋", "☕" ]; + + // init mapping for decoding particularities of the two versions + this.#init(); + + // converter + this.converter = new BaseConverter(1024, 5, 4); - this.charsets.default = "0123456789abcdefghijklmnopqrstuvwxyz".substring(0, radix); - // predefined settings - this.converter = new BaseConverter(radix, 0, 0); - this.hasSignedMode = true; - this.littleEndian = !(radix === 2 || radix === 16); - this.signed = true; - this.version = "default"; + this.padding = true; + this.padCharAmount = 5; + this.version = "emojis_v1"; - // list of allowed/disallowed args to change - this.isMutable.littleEndian = true, - this.isMutable.upper = true; + // mutable extra args + this.isMutable.padding = true; + this.isMutable.trim = true; + // set trim option + this.trim = null; + this.utils.converterArgs.trim = ["notrim", "trim"]; + // apply user settings this.utils.validateArgs(args, true); + + if (this.trim === null) { + this.trim = this.version === "emojis_v2"; + } } - + + + /** + * Analyzes v1 and two charsets for equal and non + * equal characters to create a "revEmojiObj" for + * decoding lookup. Also generates a RegExp object + * for handling concatenated strings. + */ + #init() { + + // Stores all padding for a regex generation. + const padAll = {}; + + // Creates an object which holds all characters + // of both versions. Unique chars for version one + // are getting the version value "1", version two "2" + // and overlaps "3". + const revEmojisAdd = (version, set) => { + set.forEach((char) => { + if (char in this.#revEmojiVersion) { + this.#revEmojiVersion[char].version += version; + } else { + this.#revEmojiVersion[char] = { version }; + } + }); + }; + + // This function adds a padding character of both + // versions to the object, with additional information + // about the padding type. In this process each unique + // padChar is also added to the "padAll" object. + const handlePadding = (version, set, type) => { + set.forEach(padChar => { + + if (padChar in padAll) { + this.#revEmojiVersion[padChar].version = 3; + } else { + this.#revEmojiVersion[padChar] = { + version, + padding: type + }; + padAll[padChar] = type; + } + }); + }; + + revEmojisAdd(1, this.charsets.emojis_v1); + revEmojisAdd(2, this.charsets.emojis_v2); + + handlePadding(1, this.padChars.emojis_v1.slice(0, -1), "last"); + handlePadding(2, this.padChars.emojis_v2.slice(0, -1), "last"); + handlePadding(1, this.padChars.emojis_v1.slice(-1), "fill"); + handlePadding(2, this.padChars.emojis_v2.slice(-1), "fill"); + + + // Create an array of keys for the final regex + const regexArray = []; + + for (const padChar in padAll) { + if (padAll[padChar] === "last") { + regexArray.push(padChar); + } else { + regexArray.push(`${padChar}+`); + } + } + + // create a regex obj for matching all pad chars + this.#padRegex = new RegExp(regexArray.join("|"), "g"); + } + + + /** + * BaseEx Ecoji Encoder. + * @param {*} input - Input according to the used byte converter. + * @param {...str} [args] - Converter settings. + * @returns {string} - Ecoji encoded string. + */ encode(input, ...args) { - return super.encode(input, null, null, ...args); + + const applyPadding = ({ output, settings, zeroPadding }) => { + + const charset = this.charsets[settings.version]; + let outArray = [...output]; + + if (zeroPadding > 1) { + const padValue = this.converter.padBytes(zeroPadding); + if (settings.padding) { + const padLen = settings.trim ? 1 : padValue; + const padArr = new Array(padLen).fill(this.padChars[settings.version].at(-1)); + outArray.splice(outArray.length-padValue, padValue, ...padArr); + } else { + outArray.splice(outArray.length-padValue, padValue); + } + } + + else if (zeroPadding === 1) { + const lastVal = charset.indexOf(outArray.pop()); + const x = lastVal >> 8; + outArray.push(this.padChars[settings.version].at(x)); + } + + return outArray.join(""); + }; + + return super.encode(input, null, applyPadding, ...args); } - decode(rawInput, ...args) { + + /** + * BaseEx Ecoji Decoder. + * @param {string} input - Ecoji String. + * @param {...any} [args] - Converter settings. + * @returns {*} - Output according to converter settings. + */ + decode(input, ...args) { - // pre decoding function - const normalizeInput = (scope) => { + // Argument validation and output settings + const settings = this.utils.validateArgs(args); + input = this.utils.normalizeInput(input); - let { input } = scope; + let version = settings.version; + let versionKey = null; - // normalize input (add leading zeros) for base 2 and 16 - if (this.converter.radix === 2) { - const leadingZeros = (8 - (input.length % 8)) % 8; - input = `${"0".repeat(leadingZeros)}${input}`; - } else if (this.converter.radix === 16) { - const leadingZeros = input.length % 2; - input = `${"0".repeat(leadingZeros)}${input}`; + if (settings.version === "emojis_v1" || settings.version === "emojis_v2") { + // versionKey can be both v1 or v2 + versionKey = 3; + } + + // the actual decoding is wrapped in a function + // for the possibility to call it multiple times + const decode = (input) => { + + if (versionKey !== null) { + versionKey = this.#preDecode(input, versionKey, settings.integrity); + version = (versionKey === 3) + ? settings.version + : `emojis_v${versionKey}`; } - return input; + const charset = this.charsets[version]; + + const inArray = [...input]; + const lastChar = inArray.at(-1); + let skipLast = false; + + for (let i=0; i { + const end = match.index + match.at(0).length; + preOutArray.push(...decode(input.slice(start, end))); + start = end; + }); + + // in case the last group has no padding, it is not yet + // decoded -> do it now + if (start !== input.length) { + preOutArray.push(...decode(input.slice(start, input.length))); + } + + output = Uint8Array.from(preOutArray); + } + + return this.utils.outputHandler.compile(output, settings.outputType); } - } - /** - * [BaseEx]{@link https://github.com/UmamiAppearance/BaseExJS} - * - * @version 0.4.3 - * @author UmamiAppearance [mail@umamiappearance.eu] - * @license GPL-3.0 AND BSD-3-Clause (only regarding Base91, Copyright (c) 2000-2006 Joachim Henke) - */ + /** + * Determines the version (1/2) and analyzes the input for integrity. + * @param {string} input - Input string. + * @param {number} versionKey - Version key from former calls (initially always 3). + * @param {boolean} integrity - If false non standard or wrong padding gets ignored. + * @returns {number} - Version key (1|2|3) + */ + #preDecode(input, versionKey, integrity) { + + const inArray = [...input]; + let sawPadding; + + inArray.forEach((char, i) => { + + if (char in this.#revEmojiVersion) { + + const charVersion = this.#revEmojiVersion[char].version; + + // version changes can only happen if the char is + // not in both versions (not 3) + if (charVersion !== 3) { + if (versionKey === 3) { + versionKey = charVersion; + } else if (versionKey !== charVersion) { + throw new TypeError(`Emojis from different ecoji versions seen : ${char} from emojis_v${charVersion}`); + } + } + + // analyze possible wrong padding if integrity checks + // are enabled + if (integrity) { + const padding = this.#revEmojiVersion[char].padding; + if (padding) { + + // index relative to a group of four bytes + const relIndex = i%4; + sawPadding = true; + + if (padding === "fill") { + if (relIndex === 0) { + throw new TypeError(`Padding unexpectedly seen in first position ${char}`); + } + } else if (relIndex !== 3) { + throw new TypeError(`Last padding seen in unexpected position ${char}`); + } + } + + else if (sawPadding) { + throw new TypeError("Unexpectedly saw non-padding after padding"); + } + } + + } else { + throw new DecodingError(char); + } + }); + + // lastly test for invalid string + if (integrity && inArray.length % 4) { + if ( + versionKey === 1 || + this.#revEmojiVersion[inArray.at(-1)].padding !== "fill" + ) { + throw new TypeError("Unexpected end of data, input data size not multiple of 4"); + } + } + + return versionKey; + } + } + + /** + * [BaseEx|Base2048 Converter]{@link https://github.com/UmamiAppearance/BaseExJS/blob/main/src/converters/base-2048.js} + * + * @version 0.6.1 + * @author UmamiAppearance [mail@umamiappearance.eu] + * @license GPL-3.0 AND MIT (Base2048, Copyright (c) 2017 qntm) + */ + + /** + * BaseEx Base 2048 Converter. + * ------------------------ + * This is a base2048/converter. Various input can be + * converted to a hex string or a hex string can be + * decoded into various formats. It is possible to + * convert in both signed and unsigned mode. + * + * @see https://github.com/qntm/base2048 + */ + class Base2048 extends BaseTemplate { + + /** + * BaseEx Base2048 Constructor. + * @param {...string} [args] - Converter settings. + */ + constructor(...args) { + super(); + + // converter (properties only) + this.converter = { + radix: 2048, + bsEnc: 11, + bsEncPad: 3, + bsDec: 8 + }; + + // default settings + this.charsets.default = [..."89ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyzÆÐØÞßæðøþĐđĦħıĸŁłŊŋŒœŦŧƀƁƂƃƄƅƆƇƈƉƊƋƌƍƎƏƐƑƒƓƔƕƖƗƘƙƚƛƜƝƞƟƢƣƤƥƦƧƨƩƪƫƬƭƮƱƲƳƴƵƶƷƸƹƺƻƼƽƾƿǀǁǂǃǝǤǥǶǷȜȝȠȡȢȣȤȥȴȵȶȷȸȹȺȻȼȽȾȿɀɁɂɃɄɅɆɇɈɉɊɋɌɍɎɏɐɑɒɓɔɕɖɗɘəɚɛɜɝɞɟɠɡɢɣɤɥɦɧɨɩɪɫɬɭɮɯɰɱɲɳɴɵɶɷɸɹɺɻɼɽɾɿʀʁʂʃʄʅʆʇʈʉʊʋʌʍʎʏʐʑʒʓʔʕʖʗʘʙʚʛʜʝʞʟʠʡʢʣʤʥʦʧʨʩʪʫʬʭʮʯͰͱͲͳͶͷͻͼͽͿΑΒΓΔΕΖΗΘΙΚΛΜΝΞΟΠΡΣΤΥΦΧΨΩαβγδεζηθικλμνξοπρςστυφχψωϏϗϘϙϚϛϜϝϞϟϠϡϢϣϤϥϦϧϨϩϪϫϬϭϮϯϳϷϸϺϻϼϽϾϿЂЄЅІЈЉЊЋЏАБВГДЕЖЗИКЛМНОПРСТУФХЦЧШЩЪЫЬЭЮЯабвгдежзиклмнопрстуфхцчшщъыьэюяђєѕіјљњћџѠѡѢѣѤѥѦѧѨѩѪѫѬѭѮѯѰѱѲѳѴѵѸѹѺѻѼѽѾѿҀҁҊҋҌҍҎҏҐґҒғҔҕҖҗҘҙҚқҜҝҞҟҠҡҢңҤҥҦҧҨҩҪҫҬҭҮүҰұҲҳҴҵҶҷҸҹҺһҼҽҾҿӀӃӄӅӆӇӈӉӊӋӌӍӎӏӔӕӘәӠӡӨөӶӷӺӻӼӽӾӿԀԁԂԃԄԅԆԇԈԉԊԋԌԍԎԏԐԑԒԓԔԕԖԗԘԙԚԛԜԝԞԟԠԡԢԣԤԥԦԧԨԩԪԫԬԭԮԯԱԲԳԴԵԶԷԸԹԺԻԼԽԾԿՀՁՂՃՄՅՆՇՈՉՊՋՌՍՎՏՐՑՒՓՔՕՖաբգդեզէըթժիլխծկհձղճմյնշոչպջռսվտրցւփքօֆאבגדהוזחטיךכלםמןנסעףפץצקרשתװױײؠءابةتثجحخدذرزسشصضطظعغػؼؽؾؿفقكلمنهوىي٠١٢٣٤٥٦٧٨٩ٮٯٱٲٳٴٹٺٻټٽپٿڀځڂڃڄڅچڇڈډڊڋڌڍڎڏڐڑڒړڔڕږڗژڙښڛڜڝڞڟڠڡڢڣڤڥڦڧڨکڪګڬڭڮگڰڱڲڳڴڵڶڷڸڹںڻڼڽھڿہۃۄۅۆۇۈۉۊۋیۍێۏېۑےەۮۯ۰۱۲۳۴۵۶۷۸۹ۺۻۼۿܐܒܓܔܕܖܗܘܙܚܛܜܝܞܟܠܡܢܣܤܥܦܧܨܩܪܫܬܭܮܯݍݎݏݐݑݒݓݔݕݖݗݘݙݚݛݜݝݞݟݠݡݢݣݤݥݦݧݨݩݪݫݬݭݮݯݰݱݲݳݴݵݶݷݸݹݺݻݼݽݾݿހށނރބޅކއވމފދތލގޏސޑޒޓޔޕޖޗޘޙޚޛޜޝޞޟޠޡޢޣޤޥޱ߀߁߂߃߄߅߆߇߈߉ߊߋߌߍߎߏߐߑߒߓߔߕߖߗߘߙߚߛߜߝߞߟߠߡߢߣߤߥߦߧߨߩߪࠀࠁࠂࠃࠄࠅࠆࠇࠈࠉࠊࠋࠌࠍࠎࠏࠐࠑࠒࠓࠔࠕࡀࡁࡂࡃࡄࡅࡆࡇࡈࡉࡊࡋࡌࡍࡎࡏࡐࡑࡒࡓࡔࡕࡖࡗࡘࡠࡡࡢࡣࡤࡥࡦࡧࡨࡩࡪࢠࢡࢢࢣࢤࢥࢦࢧࢨࢩࢪࢫࢬࢭࢮࢯࢰࢱࢲࢳࢴࢶࢷࢸࢹࢺࢻࢼࢽऄअआइईउऊऋऌऍऎएऐऑऒओऔकखगघङचछजझञटठडढणतथदधनपफबभमयरलळवशषसहऽॐॠॡ०१२३४५६७८९ॲॳॴॵॶॷॸॹॺॻॼॽॾॿঀঅআইঈউঊঋঌএঐওঔকখগঘঙচছজঝঞটঠডঢণতথদধনপফবভমযরলশষসহঽৎৠৡ০১২৩৪৫৬৭৮৯ৰৱ৴৵৶৷৸৹ৼਅਆਇਈਉਊਏਐਓਔਕਖਗਘਙਚਛਜਝਞਟਠਡਢਣਤਥਦਧਨਪਫਬਭਮਯਰਲਵਸਹੜ੦੧੨੩੪੫੬੭੮੯ੲੳੴઅઆઇઈઉઊઋઌઍએઐઑઓઔકખગઘઙચછજઝઞટઠડઢણતથદધનપફબભમયરલળવશષસહઽૐૠૡ૦૧૨૩૪૫૬૭૮૯ૹଅଆଇଈଉଊଋଌଏଐଓଔକଖଗଘଙଚଛଜଝଞଟଠଡଢଣତଥଦଧନପଫବଭମଯରଲଳଵଶଷସହଽୟୠୡ୦୧୨୩୪୫୬୭୮୯ୱ୲୳୴୵୶୷ஃஅஆஇஈஉஊஎஏஐஒஓகஙசஜஞடணதநனபமயரறலளழவஶஷஸஹௐ௦௧௨௩௪௫௬௭௮௯௰௱௲అఆఇఈఉఊఋఌఎఏఐఒఓఔకఖగఘఙచఛజఝఞటఠడఢణతథదధనపఫబభమయరఱలళఴవశషసహఽౘౙౚౠౡ౦౧౨౩౪౫౬౭౮౯౸౹౺౻౼౽౾ಀಅಆಇಈಉಊಋಌಎಏಐಒಓಔಕಖಗಘಙಚಛಜಝಞಟಠಡಢಣತಥದಧನಪಫಬಭಮಯರಱಲಳವಶಷಸಹಽೞೠೡ೦೧೨೩೪೫೬೭೮೯ೱೲഅആഇഈഉഊഋഌഎഏഐഒഓഔകഖഗഘങചഛജഝഞടഠഡഢണതഥദധനഩപഫബഭമയരറലളഴവശഷസഹഺഽൎൔൕൖ൘൙൚൛൜൝൞ൟൠൡ൦൧൨൩൪൫൬൭൮൯൰൱൲൳൴൵൶൷൸ൺൻർൽൾൿඅආඇඈඉඊඋඌඍඎඏඐඑඒඓඔඕඖකඛගඝඞඟචඡජඣඤඥඦටඨඩඪණඬතථදධනඳපඵබභමඹයරලවශෂසහළෆ෦෧෨෩෪෫෬෭෮෯กขฃคฅฆงจฉชซฌญฎฏฐฑฒณดตถทธนบปผฝพฟภมยรฤลฦวศษสหฬอฮฯะาเแโใไๅ๐๑๒๓๔๕๖๗๘๙ກຂຄງຈຊຍດຕຖທນບປຜຝພຟມຢຣລວສຫອຮຯະາຽເແໂໃໄ໐໑໒໓໔໕໖໗໘໙ໞໟༀ༠༡༢༣༤༥༦༧༨༩༪༫༬༭༮༯༰༱༲༳ཀཁགངཅཆཇཉཊཋཌཎཏཐདནཔཕབམཙཚཛཝཞཟའཡརལཤཥསཧཨཪཫཬྈྉྊྋྌကခဂဃငစဆဇဈဉညဋဌဍဎဏတထဒဓနပဖဗဘမယရလဝသဟဠအဢဣဤဥဧဨဩဪဿ၀၁၂၃၄၅၆၇၈၉ၐၑၒၓၔၕ"]; + this.padChars.default = [..."01234567"]; + + this.padCharAmount = 8; + this.hasSignedMode = true; + this.littleEndian = false; + + // apply user settings + this.utils.validateArgs(args, true); + } + + + /** + * BaseEx Base2048 Encoder. + * @param {*} input - Input according to the used byte converter. + * @param {...str} [args] - Converter settings. + * @returns {string} - Base2048 encoded string. + */ + encode(input, ...args) { + + const settings = this.utils.validateArgs(args); + let inputBytes = this.utils.inputHandler.toBytes(input, settings).at(0); + + const charset = this.charsets[settings.version]; + const padChars = this.padChars[settings.version]; + + let output = ""; + let z = 0; + let numZBits = 0; + + inputBytes.forEach(uint8 => { + + for (let i=this.converter.bsDec-1; i>=0; i--) { + + z = (z << 1) + ((uint8 >> i) & 1); + numZBits++; + + if (numZBits === this.converter.bsEnc) { + output += charset.at(z); + z = 0; + numZBits = 0; + } + } + }); + + if (numZBits !== 0) { + + let bitCount; + let isPadding; + + if (numZBits <= this.converter.bsEncPad) { + bitCount = this.converter.bsEncPad; + isPadding = true; + } else { + bitCount = this.converter.bsEnc; + isPadding = false; + } + + while (numZBits !== bitCount) { + z = (z << 1) + 1; + numZBits++; + if (numZBits > this.converter.bsEnc) { + throw new Error("Cannot process input. This is a bug!"); + } + } + + if (isPadding) { + output += padChars.at(z); + } else { + output += charset.at(z); + } + } + + return this.utils.wrapOutput(output, settings.options.lineWrap); + } + + + /** + * BaseEx Base2048 Decoder. + * @param {string} input - Base2048/Hex String. + * @param {...any} [args] - Converter settings. + * @returns {*} - Output according to converter settings. + */ + decode(input, ...args) { + + // apply settings + const settings = this.utils.validateArgs(args); + + // ensure a string input + input = this.utils.normalizeInput(input); + const inArray = [...input]; + + const charset = this.charsets[settings.version]; + const padChars = this.padChars[settings.version]; + + const byteArray = new Array(); + let uint8 = 0; + let numUint8Bits = 0; + + inArray.forEach((c, i) => { + + let numZBits; + let z = charset.indexOf(c); + if (z > -1) { + numZBits = this.converter.bsEnc; + } else { + z = padChars.indexOf(c); + + if (z > -1) { + if (i+1 !== inArray.length) { + throw new DecodingError(null, `Secondary character found before end of input, index: ${i}`); + } + + numZBits = this.converter.bsEncPad; + } + + else if (settings.integrity) { + throw new DecodingError(c); + } + } + + // Take most significant bit first + for (let j=numZBits-1; j>=0; j--) { + + uint8 = (uint8 << 1) + ((z >> j) & 1); + numUint8Bits++; + + if (numUint8Bits === this.converter.bsDec) { + byteArray.push(uint8); + uint8 = 0; + numUint8Bits = 0; + } + } + }); + + return this.utils.outputHandler.compile( + Uint8Array.from(byteArray), + settings.outputType + ); + } + } + + /** + * [BaseEx|SimpleBase Converter]{@link https://github.com/UmamiAppearance/BaseExJS/blob/main/src/converters/simple-base.js} + * + * @version 0.6.1 + * @author UmamiAppearance [mail@umamiappearance.eu] + * @license GPL-3.0 + */ + + + /** + * BaseEx SimpleBase Converter. + * --------------------------- + * SimpleBase provides the simple mathematical base + * conversion as known from (n).toString(radix) and + * parseInt(n, radix). + * + * The constructor needs a radix between 2-62 as the + * first argument. In other regards it behaves pretty + * much as any other converter. + */ + class SimpleBase extends BaseTemplate { + + /** + * SimpleBase Constructor. + * @param {number} radix - Radix between 2 and 62 + * @param {...any} args - Converter settings. + */ + constructor(radix, ...args) { + super(); + + if (!radix || !Number.isInteger(radix) || radix < 2 || radix > 62) { + throw new RangeError("Radix argument must be provided and has to be an integer between 2 and 62.") + } + this.converter = new BaseConverter(radix, 0, 0); + + + // charsets + this.charsets.default = [..."0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ"].slice(0, radix); + + + // predefined settings + this.frozenCharsets = true; + this.hasSignedMode = true; + this.littleEndian = !(radix === 2 || radix === 16); + this.signed = true; + this.version = "default"; + + // list of allowed/disallowed args to change + this.isMutable.littleEndian = true, + this.isMutable.upper = radix <= 36; + + // apply user settings + this.utils.validateArgs(args, true); + } + + + /** + * BaseEx SimpleBase Encoder. + * @param {*} input - Input according to the used byte converter. + * @param {...any} [args] - Converter settings. + * @returns {string} - Base 2-62 encoded string. + */ + encode(input, ...args) { + return super.encode(input, null, null, ...args); + } + + + /** + * BaseEx SimpleBase Decoder. + * @param {string} input - Base 2-62 String. + * @param {...any} [args] - Converter settings. + * @returns {*} - Output according to converter settings. + */ + decode(rawInput, ...args) { + + // pre decoding function + const normalizeInput = ({ input }) => { + + // normalize input (add leading zeros) for base 2 and 16 + if (this.converter.radix === 2) { + const leadingZeros = (8 - (input.length % 8)) % 8; + input = `${"0".repeat(leadingZeros)}${input}`; + } else if (this.converter.radix === 16) { + const leadingZeros = input.length % 2; + input = `${"0".repeat(leadingZeros)}${input}`; + } + + return input; + }; + + return super.decode(rawInput, normalizeInput, null, false, ...args); + + } + } + + /** + * big.js v6.2.1 // Copyright (c) 2022 Michael Mclaughlin // https://github.com/MikeMcl/big.js/LICENCE.md // Modified (reduced) and minified for BaseEx + */ + let DP=20,RM=1,MAX_DP=1e6,NE=-7,PE=21,STRICT=!1,NAME="[big.js] ",INVALID=NAME+"Invalid ",INVALID_DP=INVALID+"decimal places",INVALID_RM=INVALID+"rounding mode",P={},NUMERIC=/^-?(\d+(\.\d*)?|\.\d+)(e[+-]?\d+)?$/i;function _Big_(){function Big(n){let x=this;if(!(x instanceof Big))return void 0===n?_Big_():new Big(n);if(n instanceof Big)x.s=n.s,x.e=n.e,x.c=n.c.slice();else {if("string"!=typeof n){if(!0===Big.strict&&"bigint"!=typeof n)throw TypeError(INVALID+"value");n=0===n&&1/n<0?"-0":String(n);}parse(x,n);}x.constructor=Big;}return Big.prototype=P,Big.DP=DP,Big.RM=RM,Big.NE=NE,Big.PE=PE,Big.strict=STRICT,Big.roundDown=0,Big.roundHalfUp=1,Big.roundHalfEven=2,Big.roundUp=3,Big}function parse(x,n){let e,i,nl;if(!NUMERIC.test(n))throw Error(`${INVALID}number`);for(x.s="-"==n.charAt(0)?(n=n.slice(1),-1):1,(e=n.indexOf("."))>-1&&(n=n.replace(".","")),(i=n.search(/e/i))>0?(e<0&&(e=i),e+=+n.slice(i+1),n=n.substring(0,i)):e<0&&(e=n.length),nl=n.length,i=0;i0&&"0"==n.charAt(--nl););for(x.e=e-i-1,x.c=[],e=0;i<=nl;)x.c[e++]=+n.charAt(i++);}return x}function round(x,sd,rm,more){let xc=x.c;if(void 0===rm&&(rm=x.constructor.RM),0!==rm&&1!==rm&&2!==rm&&3!==rm)throw Error(INVALID_RM);if(sd<1)more=3===rm&&(more||!!xc[0])||0===sd&&(1===rm&&xc[0]>=5||2===rm&&(xc[0]>5||5===xc[0]&&(more||void 0!==xc[1]))),xc.length=1,more?(x.e=x.e-sd+1,xc[0]=1):xc[0]=x.e=0;else if(sd=5||2===rm&&(xc[sd]>5||5===xc[sd]&&(more||void 0!==xc[sd+1]||1&xc[sd-1]))||3===rm&&(more||!!xc[0]),xc.length=sd,more)for(;++xc[--sd]>9;)if(xc[sd]=0,0===sd){++x.e,xc.unshift(1);break}for(sd=xc.length;!xc[--sd];)xc.pop();}return x}function stringify(x,doExponential,isNonzero){let e=x.e,s=x.c.join(""),n=s.length;if(doExponential)s=s.charAt(0)+(n>1?"."+s.slice(1):"")+(e<0?"e":"e+")+e;else if(e<0){for(;++e;)s="0"+s;s="0."+s;}else if(e>0)if(++e>n)for(e-=n;e--;)s+="0";else e1&&(s=s.charAt(0)+"."+s.slice(1));return x.s<0&&isNonzero?"-"+s:s}P.abs=function(){let x=new this.constructor(this);return x.s=1,x},P.cmp=function(y){let isneg,x=this,xc=x.c,yc=(y=new x.constructor(y)).c,i=x.s,j=y.s,k=x.e,l=y.e;if(!xc[0]||!yc[0])return xc[0]?i:yc[0]?-j:0;if(i!=j)return i;if(isneg=i<0,k!=l)return k>l^isneg?1:-1;for(j=(k=xc.length)<(l=yc.length)?k:l,i=-1;++iyc[i]^isneg?1:-1;return k==l?0:k>l^isneg?1:-1},P.eq=function(y){return 0===this.cmp(y)},P.gt=function(y){return this.cmp(y)>0},P.gte=function(y){return this.cmp(y)>-1},P.lt=function(y){return this.cmp(y)<0},P.lte=function(y){return this.cmp(y)<1},P.minus=P.sub=function(y){let i,j,t,xlty,x=this,Big=x.constructor,a=x.s,b=(y=new Big(y)).s;if(a!=b)return y.s=-b,x.plus(y);let xc=x.c.slice(),xe=x.e,yc=y.c,ye=y.e;if(!xc[0]||!yc[0])return yc[0]?y.s=-b:xc[0]?y=new Big(x):y.s=1,y;if(a=xe-ye){for((xlty=a<0)?(a=-a,t=xc):(ye=xe,t=yc),t.reverse(),b=a;b--;)t.push(0);t.reverse();}else for(j=((xlty=xc.length0)for(;b--;)xc[i++]=0;for(b=i;j>a;){if(xc[--j]0?(ye=xe,t=yc):(e=-e,t=xc),t.reverse();e--;)t.push(0);t.reverse();}for(xc.length-yc.length<0&&(t=yc,yc=xc,xc=t),e=yc.length,k=0;e;xc[e]%=10)k=(xc[--e]=xc[e]+yc[e]+k)/10|0;for(k&&(xc.unshift(k),++ye),e=xc.length;0===xc[--e];)xc.pop();return y.c=xc,y.e=ye,y},P.round=function(dp,rm){if(void 0===dp)dp=0;else if(dp!==~~dp||dp<-MAX_DP||dp>MAX_DP)throw Error(INVALID_DP);return round(new this.constructor(this),dp+this.e+1,rm)},P.toFixed=function(dp,rm){let x=this,n=x.c[0];if(void 0!==dp){if(dp!==~~dp||dp<0||dp>MAX_DP)throw Error(INVALID_DP);for(x=round(new x.constructor(x),dp+x.e+1,rm),dp=dp+x.e+1;x.c.length=Big.PE,!!x.c[0])},P.toNumber=function(){let n=Number(stringify(this,!0,!0));if(!0===this.constructor.strict&&!this.eq(n.toString()))throw Error(NAME+"Imprecise conversion");return n};const Big=_Big_(); + + /** + * [BaseEx|BasePhi Converter]{@link https://github.com/UmamiAppearance/BaseExJS/blob/main/src/converters/base-phi.js} + * + * @version 0.6.1 + * @author UmamiAppearance [mail@umamiappearance.eu] + * @license GPL-3.0 + */ + + /** + * BaseEx Base Phi Converter. + * ------------------------ + * + * This is a base phi converter. Various input can be + * converted to a base phi string or a base phi string + * can be decoded into various formats. + * + */ + class BasePhi extends BaseTemplate { + + #Phi = Big("1.618033988749894848204586834365638117720309179805762862135448622705260462818902449707207204189391137484754088075386891752"); + + /** + * BaseEx basE91 Constructor. + * @param {...string} [args] - Converter settings. + */ + constructor(...args) { + super(); + + // converter (properties only) + this.converter = { + radix: 2, // radix is Phi, but the normalized representation allows two chars + bsEnc: 0, + bsDec: 0 + }; + + // base10 converter to have always have a numerical input + this.b10 = new BaseConverter(10, 0, 0); + + // charsets + this.charsets.default = ["0", "1"]; + + this.version = "default"; + this.signed = true; + this.hasDecimalMode = true; + + // apply user settings + this.utils.validateArgs(args, true); + } + + + /** + * BaseEx BasePhi Encoder. + * @param {*} input - Input according to the used byte converter. + * @param {...string} [args] - Converter settings. + * @returns {string} - BasePhi encoded string. + */ + encode(input, ...args) { + + // argument validation and input settings + const settings = this.utils.validateArgs(args); + const charset = this.charsets[settings.version]; + + let inputBytes; + let negative; + let n; + let output = ""; + + // Base Phi allows direct encoding of rational + // and irrational numbers, which can be enabled + // by using the special type "decimal". Input + // type must be "Number" for this mode. + if (settings.decimalMode) { + if (Number.isFinite(input)) { + if (input < 0) { + negative = true; + n = Big(-input); + } else { + negative = false; + n = Big(input); + } + } + + else { + throw new TypeError("When running the converter in decimal-mode, only input of type 'Number' is allowed.") + } + } + + // Every other type first converts the byte representation + // of the input to base 10. + else { + [ inputBytes, negative, ] = this.utils.inputHandler.toBytes(input, settings); + n = Big( + this.b10.encode(inputBytes, null, settings.littleEndian)[0] + ); + } + + // if "n" if 0 or 1 stop here and return 0 or 1 (according to the charset) + if (n.eq(0) || n.eq(1)) { + output = charset[n.toNumber()]; + if (negative) { + output = `-${output}`; + } + return output; + } + + // create two arrays to store all exponents + const exponents = []; + const decExponents = []; + + + // The very first step is to find the highest exponent + // of Phi which fits into "n" (the rounded highest exponent + // is also the highest Lucas number which fits into "n") + // To find the highest fitting exponent start with + // Phi^0 (1) and Phi^1 (Phi). + + let last = Big(1); + let cur = this.#Phi; + let exp = 0; + + // Now add the result with the last higher value "cur", + // util "cur" is bigger than "n" + while (cur.lt(n)) { + [ last, cur ] = this.#nextPhiExp(last, cur); + exp++; + } + + /** + * Recursive reduction function for "n". Finds the largest + * fitting exponent of Phi (Lucas index), stores that index + * in the exponent arrays and reduces "n" by the current exponents + * power. + * Once started, it calls itself until "n" is zero. + * @param {Object} cur - Current result of Phi^exp as a Big.js object. + * @param {Object} prev - Previous result of Phi^exp as a Big.js object. + * @param {number} exp - Exponent of Phi/Lucas index. + */ + const reduceN = (cur, prev, exp) => { + + // Due to the high floating point precision "n" should + // be exactly zero, but if not, an approximation is + // sufficient. + if (this.#approxNull(n)) return; + + // Reduce the exponents of Phi until it power fits into "n" + while (cur.gt(n)) { + [ cur, prev ] = this.#prevPhiExp(cur, prev); + + // if "cur" gets negative return immediately + // prevent an infinite loop + if (cur.lte(0)) { + console.warn("Could not find an exact base-phi representation. Value is approximated."); + return; + } + exp--; + } + + // Store the exponents + if (exp > -1) { + exponents.unshift(exp); + } else { + decExponents.push(exp); + } + + // Reduce "n" + n = n.minus(cur); + + reduceN(cur, prev, exp); + }; + + // Initial call of the reduction function + reduceN(last, cur, exp); + + + // Create a BasePhi string by setting a "1" at every + // index stored in the "exponent" array. for every + // number between two indices a zero is added. + exp = 0; + exponents.forEach(nExp => { + while (exp < nExp) { + output = `${charset[0]}${output}`; + exp++; + } + output = `${charset[1]}${output}`; + exp++; + }); + + // Add a decimal point + if (!output) { + output = "0."; + } else { + output += "."; + } + + // Proceed with the decimal exponents + exp = -1; + decExponents.forEach(nExp => { + while (exp > nExp) { + output += charset[0]; + exp--; + } + output += charset[1]; + exp--; + }); + + // Add a "-" if the input is negative. + if (negative) { + output = `-${output}`; + } + + return output; + } + + + /** + * BaseEx Base Phi Decoder. + * @param {string} input - Base Phi String. + * @param {...any} [args] - Converter settings. + * @returns {*} - Output according to converter settings. + */ + decode(input, ...args) { + + // Argument validation and output settings + const settings = this.utils.validateArgs(args); + const charset = this.charsets[settings.version]; + + let negative; + [ input, negative ] = this.utils.extractSign( + this.utils.normalizeInput(input) + ); + + // remove unwanted characters if integrity is false + if (!settings.integrity) { + const testChars = [...charset, "."]; + input = [...input].filter(c => testChars.includes(c)).join(""); + } + + // Split the input String at the decimal sign + // and initialize a big.js-object with value 0 + const inputSplit = input.split("."); + if (settings.integrity && inputSplit.length > 2) { + throw new DecodingError(null, "There are multiple decimal points in the input."); + } + + const [ posExpStr, decExpStr ] = inputSplit; + let n = Big(0); + + // Initialize two variables "last" and "cur" + // for Phi^exp-1 and Phi^exp + let last = this.#Phi.minus(1); + let cur = Big(1); + + // Convert the left side of the input string + // to an array of chars and reverse it. Raise + // the exponent of Phi and its values until a + // one is found in the array, if a "1" was found + // add the value "cur" to number "n" (one can + // also be another corresponding char of the set + // which represents 1). + [...posExpStr].reverse().forEach((char) => { + const charIndex = charset.indexOf(char); + if (charIndex === 1) { + n = n.plus(cur); + } else if (charIndex !== 0) { + throw new DecodingError(char); + } + [ last, cur ] = this.#nextPhiExp(last, cur); + }); + + // Now also add the values for the decimal places. + if (decExpStr) { + let prev = Big(1); + cur = this.#Phi.minus(prev); + + [...decExpStr].forEach((char) => { + const charIndex = charset.indexOf(char); + if (charIndex === 1) { + n = n.plus(cur); + } else if (charIndex !== 0) { + throw new DecodingError(char); + } + [ cur, prev ] = this.#prevPhiExp(cur, prev); + }); + } + + // If running in decimal mode return n as a Number + if (settings.decimalMode) { + return n.toNumber(); + } + + // For every other case round "n" and turn it + // into a string of an integer. + n = n.round().toFixed(); + + // Use the base 10 decoder to get the byte + // representation of "n". + const output = this.b10.decode(n, [..."0123456789"], [], settings.integrity, settings.littleEndian); + + // Return the output according to the settings. + return this.utils.outputHandler.compile(output, settings.outputType, settings.littleEndian, negative); + } + + /** + * Test if n is approximately zero. + * @param {Object} n - Big.js Object. + * @returns {Boolean} + */ + #approxNull(n) { + return !(n.round(50) + .abs() + .toNumber() + ); + } + + /** + * Get the results of of the following exponents of Phi + * from the predecessors. + * @param {Object} last - Phi^exp-1 as a big.js-object + * @param {Object} cur - Phi^exp as a big.js-object + * @returns {Object[]} - Array with Phi^exp and Phi^exp+1 + */ + #nextPhiExp(last, cur) { + return [ cur, last.plus(cur) ]; + } + + /** + * Get the results of of the previous exponents of Phi + * from the predecessors. + * @param {Object} cur - Phi^exp as a big.js-object + * @param {Object} prev - Phi^exp-1 as a big.js-object + * @returns {Object[]} - Array with Phi^exp-1 and Phi^exp + */ + #prevPhiExp(cur, prev) { + return [ prev.minus(cur), cur ]; + } + } + + /** + * [BaseEx|Byte Converter]{@link https://github.com/UmamiAppearance/BaseExJS/blob/main/src/converters/byte-converter.js} + * + * @version 0.6.1 + * @author UmamiAppearance [mail@umamiappearance.eu] + * @license GPL-3.0 + */ + + // Endianness of the system + const LITTLE_ENDIAN = (() => { + const testInt = new Uint16Array([1]); + const byteRepresentation = new Uint8Array(testInt.buffer); + return Boolean(byteRepresentation.at(0)); + })(); + + + /** + * BaseEx Byte Converter. + * --------------------- + * + * This is a byte converter. Various input can be + * converted to a bytes or bytes can be decoded into + * various formats. + * + * As en- and decoder were already available, for the + * use of converting in- and output for the base + * converters, this is just a little extra tool, which + * was fast and easy to create. + */ + class ByteConverter { + + /** + * BaseEx ByteConverter Constructor. + * @param {...string} [args] - Converter settings. + */ + constructor(...args) { + + // predefined settings + this.littleEndian = LITTLE_ENDIAN; + this.numberMode = false; + this.outputType = "buffer"; + + // simplified utils + this.utils = { + validateArgs: (args, initial=false) => { + + const parameters = { + littleEndian: this.littleEndian, + numberMode: this.numberMode, + outputType: this.outputType, + signed: false, + }; + + if (!args.length) { + return parameters; + } + + if (args.includes("number")) { + args.splice(args.indexOf("number"), 1); + parameters.numberMode = true; + parameters.outputType = "float_n"; + } + + const outTypes = SmartOutput.typeList.map(s => `'${s}'`).join(", "); + + args.forEach((arg) => { + arg = String(arg).toLowerCase(); + + if (arg === "le") { + parameters.littleEndian = true; + } else if (arg === "be") { + parameters.littleEndian = false; + } else if (SmartOutput.typeList.includes(arg)) { + parameters.outputType = arg; + } else { + throw new TypeError(`Invalid argument: '${arg}.\nValid arguments are:\n'le', 'be', ${outTypes}`); + } + }); + + if (initial) { + for (const param in parameters) { + this[param] = parameters[param]; + } + } + + return parameters; + } + }; + + // apply user settings + this.utils.validateArgs(args, true); + } + + + /** + * BaseEx Byte Encoder. + * @param {*} input - Almost any input. + * @param {...str} [args] - Converter settings. + * @returns {{ buffer: ArrayBufferLike; }} - Bytes of Input. + */ + encode(input, ...args) { + const settings = this.utils.validateArgs(args); + return SmartInput.toBytes(input, settings)[0]; + } + + + /** + * BaseEx Byte Decoder. + * @param {{ buffer: ArrayBufferLike; }} input - Bytes/Buffer/View + * @param {...any} [args] - Converter settings. + * @returns {*} - Output of requested type. + */ + decode(input, ...args) { + const settings = this.utils.validateArgs(args); + return SmartOutput.compile(input, settings.outputType, settings.littleEndian); + } + } + + /** + * [BaseEx]{@link https://github.com/UmamiAppearance/BaseExJS} + * + * @version 0.6.1 + * @author UmamiAppearance [mail@umamiappearance.eu] + * @license GPL-3.0 AND BSD-3-Clause (only regarding Base91, Copyright (c) 2000-2006 Joachim Henke) + */ /** * BaseEx Converter Collection. @@ -2548,15 +3881,21 @@ var BrowserSHAObj = (function () { this.base58_flickr = new Base58("flickr", outputType); this.base64 = new Base64("default", outputType); this.base64_urlsafe = new Base64("urlsafe", outputType); + this.uuencode = new UUencode("default", outputType); + this.xxencode = new UUencode("xx", outputType); this.base85_adobe = new Base85("adobe", outputType); this.base85_ascii = new Base85("ascii85", outputType); this.base85_z85 = new Base85("z85", outputType); this.base91 = new Base91("default",outputType); this.leb128 = new LEB128("default", outputType); + this.ecoji_v1 = new Ecoji("emojis_v1", outputType); + this.ecoji_v2 = new Ecoji("emojis_v2", outputType); + this.base2048 = new Base2048("default", outputType); + this.basePhi = new BasePhi("default", outputType); this.byteConverter = new ByteConverter(outputType); this.simpleBase = {}; - for (let i=2; i<37; i++) { + for (let i=2; i<=62; i++) { this.simpleBase[`base${i}`] = new SimpleBase(i, outputType); } } @@ -2565,7 +3904,7 @@ var BrowserSHAObj = (function () { /** * [BrowserSHAObj]{@link https://github.com/UmamiAppearance/BrowserSHAObj} * - * @version 0.3.2 + * @version 0.3.3 * @author UmamiAppearance [mail@umamiappearance.eu] * @license GPL-3.0 */ diff --git a/dist/BrowserSHAObj.iife.min.js b/dist/BrowserSHAObj.iife.min.js index a2dfbe2..c2a5791 100644 --- a/dist/BrowserSHAObj.iife.min.js +++ b/dist/BrowserSHAObj.iife.min.js @@ -1,16 +1,16 @@ -var BrowserSHAObj=function(){"use strict";class t{static toBytes(t){return ArrayBuffer.isView(t)&&(t=t.buffer),[new Uint8Array(t),!1,"bytes"]}}class e{static get typeList(){return["buffer","bytes","uint8","view"]}static getType(t){if(!e.typeList.includes(t))throw new TypeError(`Unknown output type: '${t}'`);return t}static compile(t,s){let i;return i="buffer"===(s=e.getType(s))?t.buffer:"view"===s?new DataView(t.buffer):t,i}}class s{static makeDataView(t){const e=new ArrayBuffer(t);return new DataView(e)}static floatingPoints(t,e=!1){const s=this.makeDataView(8);return s.setFloat64(0,t,e),s}static numbers(t,e=!1){let s,i;if(Number.isInteger(t)){if(i="int",!Number.isSafeInteger(t)){let e,s,i;throw t<0?(e=Number.MIN_SAFE_INTEGER,s="smaller",i="MIN"):(e=Number.MAX_SAFE_INTEGER,s="bigger",i="MAX"),new RangeError(`The provided integer is ${s} than ${i}_SAFE_INTEGER: '${e}'\nData integrity is not guaranteed. Use a BigInt to avoid this issue.\n(If you see this error although a float was provided, the input has to many digits before the decimal point to store the decimal places in a float with 64 bits.)`)}t<0?t<-2147483648?(s=this.makeDataView(8),s.setBigInt64(0,BigInt(t),e)):t<-32768?(s=this.makeDataView(4),s.setInt32(0,t,e)):(s=this.makeDataView(2),s.setInt16(0,t,e)):t>0?t>4294967295?(s=this.makeDataView(8),s.setBigUint64(0,BigInt(t),e)):t>65535?(s=this.makeDataView(4),s.setUint32(0,t,e)):(s=this.makeDataView(2),s.setInt16(0,t,e)):s=new Uint16Array([0])}else i="float",s=this.floatingPoints(t,e);return[new Uint8Array(s.buffer),i]}static bigInts(t,e=!1){const s=new Array,i=e?"push":"unshift",n=18446744073709551616n;if(t<0)for(;t<-9223372036854775808n;)s[i](t%n),t>>=64n;else for(;t>=n;)s[i](t%n),t>>=64n;s[i](t);const r=8*s.length,a=this.makeDataView(r);return s.forEach(((t,s)=>{const i=8*s;a.setBigUint64(i,t,e)})),new Uint8Array(a.buffer)}static toBytes(t,e){let s,i=!1,n="bytes";if(t instanceof ArrayBuffer)s=new Uint8Array(t.slice());else if(ArrayBuffer.isView(t))s=new Uint8Array(t.buffer.slice());else if("string"==typeof t||t instanceof String)s=(new TextEncoder).encode(t);else if("number"==typeof t){if(isNaN(t))throw new TypeError("Cannot proceed. Input is NaN.");if(t==1/0)throw new TypeError("Cannot proceed. Input is Infinity.");if(e.signed&&t<0&&(i=!0,t=-t),e.numberMode){const i=this.floatingPoints(t,e.littleEndian);s=new Uint8Array(i.buffer),n="float"}else[s,n]=this.numbers(t,e.littleEndian)}else if("bigint"==typeof t)e.signed&&t<0&&(i=!0,t*=-1n),s=this.bigInts(t,e.littleEndian),n="int";else{if(!Array.isArray(t))throw new TypeError("The provided input type can not be processed.");{const i=new Array;for(const s of t)i.push(...this.toBytes(s,e)[0]);s=Uint8Array.from(i)}}return[s,i,n]}}class i{static get typeList(){return["bigint64","bigint_n","biguint64","buffer","bytes","float32","float64","float_n","int8","int16","int32","int_n","str","uint8","uint16","uint32","uint_n","view"]}static getType(t){if(!this.typeList.includes(t))throw new TypeError(`Unknown output type: '${t}'`);return t}static makeTypedArrayBuffer(t,e,s,i){const n=t.byteLength,r=(e-t.byteLength%e)%e,a=i&&n>1?255:0;let o=t;if(r){o=new Uint8Array(n+r),o.fill(a);const e=s?0:r;o.set(t,e)}return o.buffer}static makeTypedArray(t,e,s,i){let n;if("int16"===e||"uint16"===e){const r=this.makeTypedArrayBuffer(t,2,s,i);n="int16"===e?new Int16Array(r):new Uint16Array(r)}else if("int32"===e||"uint32"===e||"float32"===e){const r=this.makeTypedArrayBuffer(t,4,s,i);n="int32"===e?new Int32Array(r):"uint32"===e?new Uint32Array(r):new Float32Array(r)}else if("bigint64"===e||"biguint64"===e||"float64"===e){const r=this.makeTypedArrayBuffer(t,8,s,i);n="bigint64"===e?new BigInt64Array(r):"biguint64"===e?new BigUint64Array(r):new Float64Array(r)}return n}static compile(t,e,i=!1,n=!1){let r;if(e=this.getType(e),n){let n;if(n=e.match(/^float/)?-this.compile(t,"float_n",i):-this.compile(t,"uint_n",i),"float_n"===e)return n;t=s.toBytes(n,{littleEndian:i,numberMode:!1,signed:!1})[0]}if("buffer"===e)r=t.buffer;else if("bytes"===e||"uint8"===e)r=t;else if("int8"===e)r=new Int8Array(t.buffer);else if("view"===e)r=new DataView(t.buffer);else if("str"===e)r=(new TextDecoder).decode(t);else if("uint_n"===e||"int_n"===e||"bigint_n"===e){if(1===t.length){const e=this.makeTypedArrayBuffer(t,2,i,n);t=new Uint8Array(e)}i&&t.reverse();let s=0n;t.forEach((t=>s=(s<<8n)+BigInt(t))),"uint_n"!==e&&(s=BigInt.asIntN(8*t.length,s)),r="bigint_n"!==e&&s>=Number.MIN_SAFE_INTEGER&&s<=Number.MAX_SAFE_INTEGER?Number(s):s}else if("float_n"===e)if(t.length<=4){let e;e=4===t.length?t:this.makeTypedArray(t,"float32",!1,n);r=new DataView(e.buffer).getFloat32(0,i)}else{if(!(t.length<=8))throw new RangeError("The provided input is to complex to be converted into a floating point.");{let e;e=8===t.length?t:this.makeTypedArray(t,"float64",!1,n);r=new DataView(e.buffer).getFloat64(0,i)}}else if("number"===e){if(8!==t.length)throw new TypeError("Type mismatch. Cannot convert into number.");const e=new Float64Array(t.buffer);r=Number(e)}else r=this.makeTypedArray(t,e,i,n);return r}}const n=s,r=i;class a{constructor(t,e=!0){this.root=t,"charsets"in t&&e&&this.#t()}setIOHandlers(t=n,e=r){this.inputHandler=t,this.outputHandler=e}#t(){this.root.addCharset=(t,e)=>{if("string"!=typeof t)throw new TypeError("The charset name must be a string.");const s=this.root.converter.radix;let i=s;if("string"==typeof e||Array.isArray(e))i=e.length,e=new Set(e);else if(!(e instanceof Set))throw new TypeError("The charset must be one of the types:\n'str', 'set', 'array'.");if(e.size!==s)throw i===s?new Error("There were repetitive chars found in your charset. Make sure each char is unique."):new Error(`The length of the charset must be ${s}.`);e=[...e].join(""),this.root.charsets[t]=e,console.info(`New charset '${t}' was added and is ready to use`)},this.root.setDefaultCharset=t=>{({version:t}=this.validateArgs([t])),this.root.version=t}}makeArgList(t){return t.map((t=>`'${t}'`)).join(", ")}toSignedStr(t,e){return t=t.replace(/^0+(?!$)/,""),e&&(t="-".concat(t)),t}extractSign(t){let e=!1;return"-"===t[0]&&(e=!0,t=t.slice(1)),[t,e]}invalidArgument(t,e,s,i){const n=i?"\n * valid declarations for IO handlers are 'bytesOnly', 'bytesIn', 'bytesOut'":"",r=this.root.isMutable.signed?"\n * pass 'signed' to disable, 'unsigned' to enable the use of the twos's complement for negative integers":"",a=this.root.isMutable.littleEndian?"\n * 'be' for big , 'le' for little endian byte order for case conversion":"",o=this.root.isMutable.padding?"\n * pass 'pad' to fill up, 'nopad' to not fill up the output with the particular padding":"",l=this.root.isMutable.upper?"\n * valid args for changing the encoded output case are 'upper' and 'lower'":"",h=`\n * valid args for the output type are ${this.makeArgList(s)}`,u=e?`\n * the options for version (charset) are: ${this.makeArgList(e)}`:"";throw new TypeError(`'${t}'\n\nInput parameters:${n}${r}${a}${o}${l}${h}${u}\n * 'number' for number-mode (converts every number into a Float64Array to keep the natural js number type)\n\nTraceback:`)}validateArgs(s,i=!1){const a={littleEndian:this.root.littleEndian,numberMode:this.root.numberMode,outputType:this.root.outputType,padding:this.root.padding,signed:this.root.signed,upper:this.root.upper,version:this.root.version};if(!s.length)return i&&this.setIOHandlers(),a;const o=t=>!!s.includes(t)&&(s.splice(s.indexOf(t),1),!0),l=Object.prototype.hasOwnProperty.call(this.root,"charsets")?Object.keys(this.root.charsets):[],h={littleEndian:["be","le"],padding:["nopad","pad"],signed:["unsigned","signed"],upper:["lower","upper"]};if(i)if(o("bytes_only"))this.setIOHandlers(t,e);else{const s=o("bytes_in")?t:n,i=o("bytes_out")?e:r;this.setIOHandlers(s,i)}const u=this.outputHandler.typeList;if(o("number")&&(a.numberMode=!0,a.outputType="float_n"),s.forEach((t=>{if(t=String(t).toLowerCase(),l.includes(t))a.version=t;else if(u.includes(t))a.outputType=t;else{let e=!0;for(const s in h)if(h[s].includes(t)){if(e=!1,!this.root.isMutable[s])throw TypeError(`Argument '${t}' is not allowed for this type of converter.`);a[s]=Boolean(h[s].indexOf(t))}e&&this.invalidArgument(t,l,u,i)}})),a.padding&&a.signed&&(a.padding=!1,this.constructor.warning("Padding was set to false due to the signed conversion.")),i)for(const t in a)this.root[t]=a[t];return a}signError(){throw new TypeError("The input is signed but the converter is not set to treat input as signed.\nYou can pass the string 'signed' to the decode function or when constructing the converter.")}static warning(t){Object.prototype.hasOwnProperty.call(console,"warn")?console.warn(t):console.log(`___\n${t}\n`)}}class o{constructor(t,e=null,s=null,i=0){this.radix=t,null!==e&&null!==s?(this.bsEnc=e,this.bsDec=s):[this.bsEnc,this.bsDec]=this.constructor.guessBS(t),this.decPadVal=i}static guessBS(t){let e=t<8?t:Math.ceil(256/t);for(;e>8&&!(e%8);)e/=8;let s=0;for(;8*s*Math.log(2)/Math.log(t)=this.radix;)[u,h]=this.divmod(u,this.radix),o.unshift(parseInt(h,10));for(o.unshift(parseInt(u,10));o.lengthc=c.concat(e[t]))),i&&(c=i(c,a)),r=r.concat(c)}return[r,a]}decode(t,e,s=!1){if(!t)return new Uint8Array(0);let i=this.bsDec;const n=new Array;let r;if(t.split("").forEach((t=>{const s=e.indexOf(t);s>-1&&n.push(s)})),0===i)i=n.length;else{r=(i-n.length%i)%i;const t=new Array(r).fill(this.decPadVal);s?n.unshift(...t):n.push(...t)}let a=new Array;for(let t=0,e=n.length;t=256;)[o,r]=this.divmod(o,256),s.unshift(parseInt(r,10));for(s.unshift(parseInt(o,10));s.length1){for(;!a[0];)a.shift();a.length||a.push(0),a.reverse()}}else if(this.bsDec){const t=this.padChars(r);a.splice(a.length-t)}return Uint8Array.from(a)}padBytes(t){return Math.floor(t*this.bsDec/this.bsEnc)}padChars(t){return Math.ceil(t*this.bsEnc/this.bsDec)}pow(t){return BigInt(this.radix)**BigInt(t)}divmod(t,e){return[t,e]=[BigInt(t),BigInt(e)],[t/e,t%e]}}class l{constructor(t=!0){this.charsets={},this.hasSignedMode=!1,this.littleEndian=!1,this.numberMode=!1,this.outputType="buffer",this.padding=!1,this.signed=!1,this.upper=null,t&&(this.utils=new a(this)),this.version="default",this.isMutable={littleEndian:!1,padding:!1,signed:!1,upper:!1}}encode(t,e,s,...i){const n=this.utils.validateArgs(i);let r,a,o;[r,a,o]=this.utils.inputHandler.toBytes(t,n);let l,h,u=null;return e&&(u=e(n)),[l,h]=this.converter.encode(r,this.charsets[n.version],n.littleEndian,u),n.signed&&(l=this.utils.toSignedStr(l,a)),n.upper&&(l=l.toUpperCase()),s&&(l=s({inputBytes:r,output:l,settings:n,zeroPadding:h,type:o})),l}decode(t,e,s,...i){const n=this.utils.validateArgs(i);let r=String(t),a=!1;this.hasSignedMode&&([r,a]=this.utils.extractSign(r),a&&!n.signed&&this.utils.signError()),this.isMutable.upper&&(r=r.toLowerCase()),e&&(r=e({input:r,settings:n}));let o=this.converter.decode(r,this.charsets[n.version],n.littleEndian);return s&&(o=s({input:r,output:o,settings:n})),this.utils.outputHandler.compile(o,n.outputType,n.littleEndian,a)}}class h extends l{constructor(...t){super(),delete this.addCharset,this.charsets.all=" !\"#$%&'()*+,./0123456789:;<=>?@ABCDEFGHIJKLMNOPQRSTUVWXYZ[\\]^_`abcdefghijklmnopqrstuvwxyz{|}~",this.charsets.sequence="Hello World!",this.charsets.default="1",this.charsets.tmark="|#",this.converter=new o(10,0,0),this.hasSignedMode=!0,this.littleEndian=!0,this.signed=!0,this.isMutable.signed=!0,this.isMutable.upper=!0,this.utils.validateArgs(t,!0)}encode(t,...e){const s=this.utils.validateArgs(e);let i,n;[i,n]=this.utils.inputHandler.toBytes(t,s);let r=this.converter.encode(i,null,s.littleEndian)[0],a=BigInt(r);if(a>Number.MAX_SAFE_INTEGER)throw new RangeError("Invalid string length.");a>16777216&&this.utils.constructor.warning("The string length is really long. The JavaScript engine may have memory issues generating the output string."),a=Number(a);const o=this.charsets[s.version],l=o.length;let h="";if(1===l)h=o.repeat(a);else if("all"===s.version)for(let t=0;t4&&(h=o[1].repeat((a-t)/5)),h+=o[0].repeat(t)}else for(let t=0;t{let{input:e}=t;return e=e.replace(/^0x/,""),e.length%2&&(e="0".concat(e)),e}),null,...e)}}class c extends l{constructor(...t){super(),this.charsets.crockford="0123456789abcdefghjkmnpqrstvwxyz",this.charsets.rfc3548="abcdefghijklmnopqrstuvwxyz234567",this.charsets.rfc4648="0123456789abcdefghijklmnopqrstuv",this.charsets.zbase32="ybndrfg8ejkmcpqxot1uwisza345h769",this.converter=new o(32,5,8),this.hasSignedMode=!0,this.padding=!0,this.version="rfc4648",this.isMutable.littleEndian=!0,this.isMutable.padding=!0,this.isMutable.signed=!0,this.isMutable.upper=!0,this.utils.validateArgs(t,!0)}encode(t,...e){return super.encode(t,null,(t=>{let{output:e,settings:s,zeroPadding:i}=t;if(!s.littleEndian&&i){const t=this.converter.padBytes(i);e=e.slice(0,e.length-t),s.padding&&(e=e.concat("=".repeat(t)))}return e}),...e)}decode(t,...e){return super.decode(t,null,null,...e)}}class d extends l{constructor(...t){super(),this.charsets.default="123456789abcdefghijkmnopqrstuvwxyzABCDEFGHJKLMNPQRSTUVWXYZ",this.charsets.bitcoin="123456789ABCDEFGHJKLMNPQRSTUVWXYZabcdefghijkmnopqrstuvwxyz",this.charsets.flickr="123456789abcdefghijkmnopqrstuvwxyzABCDEFGHJKLMNPQRSTUVWXYZ",this.converter=new o(58,0,0),this.padding=!0,this.version="bitcoin",this.isMutable.padding=!0,this.isMutable.signed=!0,this.utils.validateArgs(t,!0)}encode(t,...e){return super.encode(t,null,(t=>{let{inputBytes:e,output:s,settings:i,type:n}=t;if(i.padding&&"int"!==n){let t=0;const i=e.length;if(i){for(;!e[t];)if(t++,t===i){t=0;break}const n=t;n&&(s="1".repeat(n).concat(s))}}return s}),...e)}decode(t,...e){return super.decode(t,null,(t=>{let{input:e,output:s,settings:i}=t;if(i.padding&&e.length>1){let t=0;for(;"1"===e[t];)t++;const i=t;i&&(s=Uint8Array.from([...new Array(i).fill(0),...s]))}return s}),...e)}}class f extends l{constructor(...t){super();const e="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789";this.charsets.default=e.concat("+/"),this.charsets.urlsafe=e.concat("-_"),this.converter=new o(64,3,4),this.padding=!0,this.isMutable.padding=!0,this.utils.validateArgs(t,!0)}encode(t,...e){return super.encode(t,null,(t=>{let{output:e,settings:s,zeroPadding:i}=t;if(i){const t=this.converter.padBytes(i);e=e.slice(0,e.length-t),s.padding&&(e=e.concat("=".repeat(t)))}return e}),...e)}decode(t,...e){return super.decode(t,null,null,...e)}}class p extends l{constructor(...t){super(),this.charsets.adobe="!\"#$%&'()*+,-./0123456789:;<=>?@ABCDEFGHIJKLMNOPQRSTUVWXYZ[\\]^_`abcdefghijklmnopqrstu",this.charsets.ascii85=this.charsets.adobe,this.charsets.rfc1924="0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz!#$%&()*+-;<=>?@^_`{|}~",this.charsets.z85="0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ.-:+=^!/*?&<>()[]{}@%$#",this.converter=new o(85,4,5,84),this.version="ascii85",this.utils.validateArgs(t,!0)}encode(t,...e){return super.encode(t,(t=>{let e;return t.version.match(/adobe|ascii85/)&&(e=(t,e)=>e||"!!!!!"!==t?t:"z"),e}),(t=>{let{output:e,settings:s,zeroPadding:i}=t;if(i){const t=this.converter.padBytes(i);e=e.slice(0,e.length-t)}return"adobe"===s.version&&(e=`<~${e}~>`),e}),...e)}decode(t,...e){return super.decode(t,(t=>{let{input:e,settings:s}=t;return s.version.match(/adobe|ascii85/)&&(e=e.replace(/z/g,"!!!!!"),"adobe"===s.version&&(e=e.replace(/^<~|~>$/g,""))),e}),null,...e)}}class g extends l{constructor(...t){super(),this.charsets.default='ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789!#$%&()*+,./:;<=>?@[]^_`{|}~"',this.utils.validateArgs(t,!0)}encode(t,...e){const s=this.utils.validateArgs(e),i=this.utils.inputHandler.toBytes(t,s)[0];let n=0,r=0,a="";const o=this.charsets[s.version];if(i.forEach((t=>{if(r+=t<13){let t,e,s=13,i=r%8192;i<89&&(s=14,i=r%16384),r>>=s,n-=s,[t,e]=this.divmod(i,91),a=`${a}${o[e]}${o[t]}`}})),n){let t,e;[t,e]=this.divmod(r,91),a=a.concat(o[e]),(n>7||r>90)&&(a=a.concat(o[t]))}return a}decode(t,...e){const s=this.utils.validateArgs(e);let i=(t=String(t)).length,n=!1;i%2&&(n=!0,i--);let r=0,a=0;const o=this.charsets[s.version],l=new Array;for(let e=0;e88?13:14;do{l.push(r%256),r>>=8,a-=8}while(a>7)}if(n){const e=t.charAt(i),s=o.indexOf(e);l.push(((s<{const s={littleEndian:this.littleEndian,numberMode:this.numberMode,outputType:this.outputType,signed:!1};if(!t.length)return s;t.includes("number")&&(t.splice(t.indexOf("number"),1),s.numberMode=!0,s.outputType="float_n");const n=i.typeList.map((t=>`'${t}'`)).join(", ");if(t.forEach((t=>{if("le"===(t=String(t).toLowerCase()))s.littleEndian=!0;else if("be"===t)s.littleEndian=!1;else{if(!i.typeList.includes(t))throw new TypeError(`Invalid argument: '${t}.\nValid arguments are:\n'le', 'be', ${n}`);s.outputType=t}})),e)for(const t in s)this[t]=s[t];return s}},this.utils.validateArgs(t,!0)}encode(t,...e){const i=this.utils.validateArgs(e);return s.toBytes(t,i)[0]}decode(t,...e){const s=this.utils.validateArgs(e);return i.compile(t,s.outputType,s.littleEndian)}}class y extends l{constructor(...t){super(!1),this.charsets.default="",this.charsets.hex="",this.version="default",this.converter=new o(10,0,0),this.hexlify=new o(16,1,2),this.utils=new a(this,!1),this.littleEndian=!0,this.hasSignedMode=!0,this.isMutable.signed=!0,this.utils.validateArgs(t,!0)}encode(t,...e){const s=this.utils.validateArgs(e);let i,n;const r=s.signed;s.signed=!0,[i,n]=this.utils.inputHandler.toBytes(t,s);let a=this.converter.encode(i,null,s.littleEndian)[0],o=BigInt(a),l=new Array;if(n){if(!r)throw new TypeError("Negative values in unsigned mode are invalid.");o=-o}if(r)for(;;){const t=Number(127n&o);if(o>>=7n,0==o&&0==(64&t)||-1==o&&0!=(64&t)){l.push(t);break}l.push(128|t)}else for(;;){const t=Number(127n&o);if(o>>=7n,0==o){l.push(t);break}l.push(128|t)}const h=Uint8Array.from(l);return"hex"===s.version?this.hexlify.encode(h,"0123456789abcdef",!1)[0]:h}decode(t,...e){const s=this.utils.validateArgs(e);if("hex"===s.version?t=this.hexlify.decode(String(t).toLowerCase(),"0123456789abcdef",!1):t instanceof ArrayBuffer&&(t=new Uint8Array(t)),1===t.length&&!t[0])return this.utils.outputHandler.compile(new Uint8Array(1),s.outputType,!0);t=Array.from(t);let i,n,r,a=0n,o=-7n;for(i of t)o+=7n,a+=BigInt(127&i)<36)throw new RangeError("Radix argument must be provided and has to be an integer between 2 and 36.");this.charsets.default="0123456789abcdefghijklmnopqrstuvwxyz".substring(0,t),this.converter=new o(t,0,0),this.hasSignedMode=!0,this.littleEndian=!(2===t||16===t),this.signed=!0,this.version="default",this.isMutable.littleEndian=!0,this.isMutable.upper=!0,this.utils.validateArgs(e,!0)}encode(t,...e){return super.encode(t,null,null,...e)}decode(t,...e){return super.decode(t,(t=>{let{input:e}=t;if(2===this.converter.radix){const t=(8-e.length%8)%8;e=`${"0".repeat(t)}${e}`}else if(16===this.converter.radix){const t=e.length%2;e=`${"0".repeat(t)}${e}`}return e}),null,...e)}} +var BrowserSHAObj=function(){"use strict";class t{static toBytes(t){return ArrayBuffer.isView(t)&&(t=t.buffer),[new Uint8Array(t),!1,"bytes"]}}class e{static get typeList(){return["buffer","bytes","uint8","view"]}static getType(t){if(!e.typeList.includes(t))throw new TypeError(`Unknown output type: '${t}'`);return t}static compile(t,i){let s;return s="buffer"===(i=e.getType(i))?t.buffer:"view"===i?new DataView(t.buffer):t,s}}class i{static makeDataView(t){const e=new ArrayBuffer(t);return new DataView(e)}static floatingPoints(t,e=!1){const i=this.makeDataView(8);return i.setFloat64(0,t,e),i}static numbers(t,e=!1){let i,s;if(Number.isInteger(t)){if(s="int",!Number.isSafeInteger(t)){let e,i,s;throw t<0?(e=Number.MIN_SAFE_INTEGER,i="smaller",s="MIN"):(e=Number.MAX_SAFE_INTEGER,i="bigger",s="MAX"),new RangeError(`The provided integer is ${i} than ${s}_SAFE_INTEGER: '${e}'\nData integrity is not guaranteed. Use a BigInt to avoid this issue.\n(If you see this error although a float was provided, the input has to many digits before the decimal point to store the decimal places in a float with 64 bits.)`)}t<0?t<-2147483648?(i=this.makeDataView(8),i.setBigInt64(0,BigInt(t),e)):t<-32768?(i=this.makeDataView(4),i.setInt32(0,t,e)):(i=this.makeDataView(2),i.setInt16(0,t,e)):t>0?t>4294967295?(i=this.makeDataView(8),i.setBigUint64(0,BigInt(t),e)):t>65535?(i=this.makeDataView(4),i.setUint32(0,t,e)):(i=this.makeDataView(2),i.setInt16(0,t,e)):i=new Uint16Array([0])}else s="float",i=this.floatingPoints(t,e);return[new Uint8Array(i.buffer),s]}static bigInts(t,e=!1){const i=new Array,s=e?"push":"unshift",r=18446744073709551616n;if(t<0)for(;t<-9223372036854775808n;)i[s](t%r),t>>=64n;else for(;t>=r;)i[s](t%r),t>>=64n;i[s](t);const n=8*i.length,o=this.makeDataView(n);return i.forEach(((t,i)=>{const s=8*i;o.setBigUint64(s,t,e)})),new Uint8Array(o.buffer)}static toBytes(t,e){let i,s=!1,r="bytes";if(t instanceof ArrayBuffer)i=new Uint8Array(t.slice());else if(ArrayBuffer.isView(t))i=new Uint8Array(t.buffer.slice());else if("string"==typeof t||t instanceof String)i=(new TextEncoder).encode(t);else if("number"==typeof t){if(isNaN(t))throw new TypeError("Cannot proceed. Input is NaN.");if(t==1/0)throw new TypeError("Cannot proceed. Input is Infinity.");if(e.signed&&t<0&&(s=!0,t=-t),e.numberMode){const s=this.floatingPoints(t,e.littleEndian);i=new Uint8Array(s.buffer),r="float"}else[i,r]=this.numbers(t,e.littleEndian)}else if("bigint"==typeof t)e.signed&&t<0&&(s=!0,t*=-1n),i=this.bigInts(t,e.littleEndian),r="int";else{if(!Array.isArray(t))throw new TypeError("The provided input type can not be processed.");{const s=new Array;for(const i of t)s.push(...this.toBytes(i,e)[0]);i=Uint8Array.from(s)}}return[i,s,r]}}class s{static get typeList(){return["bigint64","bigint_n","biguint64","buffer","bytes","float32","float64","float_n","int8","int16","int32","int_n","str","uint8","uint16","uint32","uint_n","view"]}static getType(t){if(!this.typeList.includes(t))throw new TypeError(`Unknown output type: '${t}'`);return t}static makeTypedArrayBuffer(t,e,i,s){const r=t.byteLength,n=(e-t.byteLength%e)%e,o=s&&r>1?255:0;let a=t;if(n){a=new Uint8Array(r+n),a.fill(o);const e=i?0:n;a.set(t,e)}return a.buffer}static makeTypedArray(t,e,i,s){let r;if("int16"===e||"uint16"===e){const n=this.makeTypedArrayBuffer(t,2,i,s);r="int16"===e?new Int16Array(n):new Uint16Array(n)}else if("int32"===e||"uint32"===e||"float32"===e){const n=this.makeTypedArrayBuffer(t,4,i,s);r="int32"===e?new Int32Array(n):"uint32"===e?new Uint32Array(n):new Float32Array(n)}else if("bigint64"===e||"biguint64"===e||"float64"===e){const n=this.makeTypedArrayBuffer(t,8,i,s);r="bigint64"===e?new BigInt64Array(n):"biguint64"===e?new BigUint64Array(n):new Float64Array(n)}return r}static compile(t,e,s=!1,r=!1){let n;if(e=this.getType(e),r){let r;if(r=e.match(/^float/)?-this.compile(t,"float_n",s):-this.compile(t,"uint_n",s),"float_n"===e)return r;t=i.toBytes(r,{littleEndian:s,numberMode:!1,signed:!1})[0]}if("buffer"===e)n=t.buffer;else if("bytes"===e||"uint8"===e)n=t;else if("int8"===e)n=new Int8Array(t.buffer);else if("view"===e)n=new DataView(t.buffer);else if("str"===e)n=(new TextDecoder).decode(t);else if("uint_n"===e||"int_n"===e||"bigint_n"===e){if(1===t.length){const e=this.makeTypedArrayBuffer(t,2,s,r);t=new Uint8Array(e)}s&&t.reverse();let i=0n;t.forEach((t=>i=(i<<8n)+BigInt(t))),"uint_n"!==e&&(i=BigInt.asIntN(8*t.length,i)),n="bigint_n"!==e&&i>=Number.MIN_SAFE_INTEGER&&i<=Number.MAX_SAFE_INTEGER?Number(i):i}else if("float_n"===e)if(t.length<=4){let e;e=4===t.length?t:this.makeTypedArray(t,"float32",!1,r);n=new DataView(e.buffer).getFloat32(0,s)}else{if(!(t.length<=8))throw new RangeError("The provided input is to complex to be converted into a floating point.");{let e;e=8===t.length?t:this.makeTypedArray(t,"float64",!1,r);n=new DataView(e.buffer).getFloat64(0,s)}}else if("number"===e){if(8!==t.length)throw new TypeError("Type mismatch. Cannot convert into number.");const e=new Float64Array(t.buffer);n=Number(e)}else n=this.makeTypedArray(t,e,s,r);return n}}const r=i,n=s;class o extends TypeError{constructor(){super("The input is signed but the converter is not set to treat input as signed.\nYou can pass the string 'signed' to the decode function or when constructing the converter."),this.name="SignError"}}class a extends TypeError{constructor(t,e=null){null===e&&(e=`Character '${t}' is not part of the charset.`),super(e),this.name="DecodingError"}}class h{constructor(t){this.root=t,this.converterArgs={},this.#t()}setIOHandlers(t=r,e=n){this.inputHandler=t,this.outputHandler=e}#t(){this.root.addCharset=(t,e,i=[],s=!0)=>{const r=(t,i,s)=>{if(0===s&&i.length)return console.warn(`This converter has no ${t}. The following argument was ignored:\n'${i}'`),[];let r=s;if("string"==typeof i&&(i=[...i]),Array.isArray(i))r=i.length,i=new Set(i);else if(!(i instanceof Set))throw new TypeError(`The ${t} must be one of the types:\n'str', 'set', 'array'."`);if(i.size===s)return[...i];if(r!==s)throw new Error(`Your ${t} has a length of ${r}. The converter requires a length of ${s}.`);{const i={};(e=[...e]).forEach((t=>{t in i?i[t]++:i[t]=1}));let r="";s<100&&(r=`${e.join("")}\n`,e.forEach((t=>{i[t]>1?r+="^":r+=" "})));const n=Object.keys(i).filter((t=>i[t]>1));throw new Error(`You have repetitive char(s) [ ${n.join(" | ")} ] in your ${t}. Make sure each character is unique.\n${r}`)}};if(this.root.frozenCharsets)throw new Error("The charsets of this converter cannot be changed.");if("string"!=typeof t)throw new TypeError("The charset name must be a string.");s&&t in this.root.charsets&&console.warn(`An existing charset with name ${t} will get replaced.`);const n=r("charset",e,this.root.converter.radix),o=r("padding set",i,this.root.padCharAmount);this.root.charsets[t]=n,o.length&&(this.root.padChars[t]=o),s&&console.info(`New charset '${t}' was added and is ready to use`)},this.root.setDefaultCharset=t=>{if(!(t in this.root.charsets)){const e=Object.keys(this.root.charsets).join("\n * ");throw new TypeError(`Charset ${t} was not found. Available charsets are:\n * ${e}`)}this.root.version=t}}#e(t){return t.map((t=>`'${t}'`)).join(", ")}toSignedStr(t,e){return t=t.replace(/^0+(?!$)/,""),e&&(t="-".concat(t)),t}extractSign(t){let e=!1;return"-"===t[0]&&(e=!0,t=t.slice(1)),[t,e]}#i(t,e,i,s){throw new TypeError([`'${t}'\n\nParameters:`,s?"\n * valid declarations for IO handlers are 'bytesOnly', 'bytesIn', 'bytesOut'":"",this.root.isMutable.signed?"\n * pass 'signed' to disable, 'unsigned' to enable the use of the twos's complement for negative integers":"",this.root.isMutable.littleEndian?"\n * 'be' for big , 'le' for little endian byte order for case conversion":"",this.root.isMutable.padding?"\n * pass 'pad' to fill up, 'nopad' to not fill up the output with the particular padding":"",this.root.isMutable.upper?"\n * valid args for changing the encoded output case are 'upper' and 'lower'":"",`\n * valid args for the output type are ${this.#e(i)}`,e?`\n * the option(s) for version/charset are: ${this.#e(e)}`:"","\n * valid args for integrity check are: 'integrity' and 'nointegrity'",this.root.hasDecimalMode?"\n * 'decimal' for decimal-mode (directly converts Numbers including decimal values, without byte-conversion)":"","\n * 'number' for number-mode (converts every number into a Float64Array to keep the natural js number type)",Object.keys(this.converterArgs).length?`\n * converter specific args:\n - ${(()=>Object.keys(this.converterArgs).map((t=>this.converterArgs[t].map((t=>`'${t}'`)).join(" and "))).join("\n - "))()}`:"","\n\nTraceback:"].join(""))}validateArgs(i,s=!1){const o={decimalMode:this.root.decimalMode,integrity:this.root.integrity,littleEndian:this.root.littleEndian,numberMode:this.root.numberMode,options:this.root.options,outputType:this.root.outputType,padding:this.root.padding,signed:this.root.signed,upper:this.root.upper,version:this.root.version};for(const t in this.converterArgs)o[t]=this.root[t];if(!i.length)return s&&this.setIOHandlers(),o;const a=t=>!!i.includes(t)&&(i.splice(i.indexOf(t),1),!0),h=Object.keys(this.root.charsets),l={integrity:["nointegrity","integrity"],littleEndian:["be","le"],padding:["nopad","pad"],signed:["unsigned","signed"],upper:["lower","upper"],...this.converterArgs};if(s)if(a("bytes_only"))this.setIOHandlers(t,e);else{const i=a("bytes_in")?t:r,s=a("bytes_out")?e:n;this.setIOHandlers(i,s)}const c=this.outputHandler.typeList;if(a("number")&&(o.numberMode=!0,o.outputType="float_n"),a("decimal")){if(!this.root.hasDecimalMode)throw TypeError("Argument 'decimal' is only allowed for converters with a non-integer base.");o.decimalMode=!0,o.outputType="decimal",o.numberMode&&(o.numberMode=!1,console.warn("-> number-mode was disabled due to the decimal-mode"))}if(i.forEach((t=>{if("object"!=typeof t)if(t=String(t).toLowerCase(),h.includes(t))o.version=t;else if(c.includes(t))o.outputType=t;else{let e=!0;for(const i in l)if(l[i].includes(t)){if(e=!1,!this.root.isMutable[i])throw TypeError(`Argument '${t}' is not allowed for this type of converter.`);o[i]=Boolean(l[i].indexOf(t))}e&&this.#i(t,h,c,s)}else o.options={...o.options,...t}})),o.padding&&o.signed&&(o.padding=!1,console.warn("-> padding was set to false due to the signed conversion")),s)for(const t in o)this.root[t]=o[t];return o}signError(){throw new o}wrapOutput(t,e=0){if(!e)return t;const i=new RegExp(`.{1,${e}}`,"gu");return t.match(i).join("\n")}normalizeInput(t,e=!1){return e?String(t):String(t).replace(/\s/g,"")}}class l{constructor(t,e=null,i=null,s=0){this.radix=t,null!==e&&null!==i?(this.bsEnc=e,this.bsDec=i):[this.bsEnc,this.bsDec]=this.constructor.guessBS(t),this.decPadVal=s}static guessBS(t){let e=t<8?t:Math.ceil(256/t);for(;e>8&&!(e%8);)e/=8;let i=0;for(;8*i*Math.log(2)/Math.log(t)=this.radix;)[c,l]=this.divmod(c,this.radix),a.unshift(parseInt(l,10));for(a.unshift(parseInt(c,10));a.lengthu=u.concat(e[t]))),s&&(u=s(u,o)),n=n.concat(u)}return[n,o]}decode(t,e,i=[],s=!0,r=!1){if(!t)return new Uint8Array(0);let n=this.bsDec;const o=new Array;let h;if([...t].forEach((t=>{const r=e.indexOf(t);if(r>-1)o.push(r);else if(s&&-1===i.indexOf(t))throw new a(t)})),0===n)n=o.length;else{h=(n-o.length%n)%n;const t=new Array(h).fill(this.decPadVal);r?o.unshift(...t):o.push(...t)}let l=new Array;for(let t=0,e=o.length;t=256;)[r,s]=this.divmod(r,256),i.unshift(parseInt(s,10));for(i.unshift(parseInt(r,10));i.length1){for(;!l[0];)l.shift();l.length||l.push(0),l.reverse()}}else if(this.bsDec){const t=this.padChars(h);l.splice(l.length-t)}return Uint8Array.from(l)}padBytes(t){return Math.floor(t*this.bsDec/this.bsEnc)}padChars(t){return Math.ceil(t*this.bsEnc/this.bsDec)}pow(t){return BigInt(this.radix)**BigInt(t)}divmod(t,e){return[t,e]=[BigInt(t),BigInt(e)],[t/e,t%e]}}class c{constructor(t=!0){this.charsets={},this.decimalMode=!1,this.frozenCharsets=!1,this.hasDecimalMode=!1,this.hasSignedMode=!1,this.integrity=!0,this.littleEndian=!1,this.numberMode=!1,this.outputType="buffer",this.padding=!1,this.padCharAmount=0,this.padChars={},this.signed=!1,this.upper=null,t&&(this.utils=new h(this)),this.version="default",this.options={lineWrap:0},this.isMutable={integrity:!0,littleEndian:!1,padding:!1,signed:!1,upper:!1}}encode(t,e,i,...s){const r=this.utils.validateArgs(s);let[n,o,a]=this.utils.inputHandler.toBytes(t,r),h=null;e&&(h=e(r));let[l,c]=this.converter.encode(n,this.charsets[r.version],r.littleEndian,h);return r.signed&&(l=this.utils.toSignedStr(l,o)),r.upper&&(l=l.toUpperCase()),i&&(l=i({inputBytes:n,output:l,settings:r,zeroPadding:c,type:a})),this.utils.wrapOutput(l,r.options.lineWrap)}decode(t,e,i,s,...r){const n=this.utils.validateArgs(r);t=this.utils.normalizeInput(t,s);let o=!1;this.hasSignedMode&&([t,o]=this.utils.extractSign(t),o&&!n.signed&&this.utils.signError()),this.isMutable.upper&&(t=t.toLowerCase()),e&&(t=e({input:t,settings:n}));let a=this.converter.decode(t,this.charsets[n.version],this.padChars[n.version],n.integrity,n.littleEndian);return i&&(a=i({input:t,output:a,settings:n})),this.utils.outputHandler.compile(a,n.outputType,n.littleEndian,o)}}class u extends c{constructor(...t){super(),this.charsets.all=[..." !\"#$%&'()*+,-./0123456789:;<=>?@ABCDEFGHIJKLMNOPQRSTUVWXYZ[\\]^_`abcdefghijklmnopqrstuvwxyz{|}~"],this.charsets.sequence=[..."Hello World!"],this.charsets.default=["1"],this.charsets.tmark=["|","#"],this.converter=new l(10,0,0),this.hasSignedMode=!0,this.littleEndian=!0,this.signed=!0,this.isMutable.charsets=!1,this.isMutable.signed=!0,this.isMutable.upper=!0,this.utils.validateArgs(t,!0)}encode(t,...e){const i=this.utils.validateArgs(e);let s,r;[s,r]=this.utils.inputHandler.toBytes(t,i);let n=this.converter.encode(s,null,i.littleEndian)[0],o=BigInt(n);if(o>Number.MAX_SAFE_INTEGER)throw new RangeError("Invalid string length.");o>16777216&&console.warn("The string length is really long. The JavaScript engine may have memory issues generating the output string."),o=Number(o);const a=this.charsets[i.version],h=a.length;let l="";if(1===h)l=a.at(0).repeat(o);else if("all"===i.version)for(let t=0;t4&&(l=a.at(1).repeat((o-t)/5)),l+=a.at(0).repeat(t)}else for(let t=0;t(t=t.replace(/^0x/,""),e.integrity||(t=t.toLowerCase().replace(/[^0-9a-f]/g,"")),t.length%2&&(t="0".concat(t)),t)),null,!1,...e)}}class f extends c{constructor(...t){super(),this.converter=new l(32,5,8),this.charsets.crockford=[..."0123456789abcdefghjkmnpqrstvwxyz"],this.padChars.crockford=["="],this.charsets.rfc3548=[..."abcdefghijklmnopqrstuvwxyz234567"],this.padChars.rfc3548=["="],this.charsets.rfc4648=[..."0123456789abcdefghijklmnopqrstuv"],this.padChars.rfc4648=["="],this.charsets.zbase32=[..."ybndrfg8ejkmcpqxot1uwisza345h769"],this.padChars.zbase32=["="],this.padCharAmount=1,this.hasSignedMode=!0,this.version="rfc4648",this.isMutable.littleEndian=!0,this.isMutable.padding=!0,this.isMutable.signed=!0,this.isMutable.upper=!0,this.utils.validateArgs(t,!0),this.padding=/rfc3548|rfc4648/.test(this.version),this.upper="crockford"===this.version}encode(t,...e){return super.encode(t,null,(({output:t,settings:e,zeroPadding:i})=>{if(!e.littleEndian&&i){const s=this.converter.padBytes(i),r=this.padChars[e.version].at(0);t=t.slice(0,-s),e.padding&&(t=t.concat(r.repeat(s)))}return t}),...e)}decode(t,...e){return super.decode(t,null,null,!1,...e)}}class p extends c{constructor(...t){super(),this.converter=new l(58,0,0),this.charsets.default=[..."123456789abcdefghijkmnopqrstuvwxyzABCDEFGHJKLMNPQRSTUVWXYZ"],Object.defineProperty(this.padChars,"default",{get:()=>[this.charsets.default.at(0)]}),this.charsets.bitcoin=[..."123456789ABCDEFGHJKLMNPQRSTUVWXYZabcdefghijkmnopqrstuvwxyz"],Object.defineProperty(this.padChars,"bitcoin",{get:()=>[this.charsets.bitcoin.at(0)]}),this.charsets.flickr=[..."123456789abcdefghijkmnopqrstuvwxyzABCDEFGHJKLMNPQRSTUVWXYZ"],Object.defineProperty(this.padChars,"flickr",{get:()=>[this.charsets.flickr.at(0)]}),this.padding=!0,this.version="bitcoin",this.isMutable.padding=!0,this.isMutable.signed=!0,this.utils.validateArgs(t,!0)}encode(t,...e){return super.encode(t,null,(({inputBytes:t,output:e,settings:i,type:s})=>{if(i.padding&&"int"!==s){let s=0;const r=t.length,n=this.charsets[i.version].at(0);if(r){for(;!t[s];)if(s++,s===r){s=0;break}const i=s;i&&(e=n.repeat(i).concat(e))}}return e}),...e)}decode(t,...e){return super.decode(t,null,(({input:t,output:e,settings:i})=>{const s=this.charsets[i.version].at(0);if(i.padding&&t.length>1){let i=0;for(;t[i]===s;)i++;const r=i;r&&(e=Uint8Array.from([...new Array(r).fill(0),...e]))}return e}),!1,...e)}}class g extends c{constructor(...t){super(),this.converter=new l(64,3,4),this.charsets.default=[..."ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/"],this.padChars.default=["="],this.charsets.urlsafe=this.charsets.default.slice(0,-2).concat(["-","_"]),this.padChars.urlsafe=["="],this.padCharAmount=1,this.padding=!0,this.isMutable.padding=!0,this.utils.validateArgs(t,!0)}encode(t,...e){return super.encode(t,null,(({output:t,settings:e,zeroPadding:i})=>{if(i){const s=this.converter.padBytes(i),r=this.padChars[e.version].at(0);t=t.slice(0,-s),e.padding&&(t=t.concat(r.repeat(s)))}return t}),...e)}decode(t,...e){return super.decode(t,null,null,!1,...e)}}class b extends c{constructor(...t){super(),this.converter=new l(64,3,4),this.charsets.default=[..."`!\"#$%&'()*+,-./0123456789:;<=>?@ABCDEFGHIJKLMNOPQRSTUVWXYZ[\\]^_"],Object.defineProperty(this.padChars,"default",{get:()=>[this.charsets.default.at(0)]}),this.charsets.original=[" ",...this.charsets.default.slice(1)],Object.defineProperty(this.padChars,"original",{get:()=>[this.charsets.original.at(0)]}),this.charsets.xx=[..."+-0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz"],Object.defineProperty(this.padChars,"xx",{get:()=>[this.charsets.xx.at(0)]}),this.padding=!0,this.header=!1,this.utils.converterArgs.header=["noheader","header"],this.isMutable.header=!0,this.isMutable.integrity=!1,this.utils.validateArgs(t,!0)}encode(t,...e){return super.encode(t,null,(({output:t,settings:e,zeroPadding:i})=>{const s=this.charsets[e.version],r=[...t];if(e.header){t=`begin ${e.options.permissions||y()} ${e.options.file||m()}\n`}else t="";for(;;){const e=r.splice(0,60);if(!r.length){const r=this.converter.padChars(e.length)-i;t+=`${s.at(r)}${e.join("")}\n`;break}t+=`${s.at(45)}${e.join("")}\n`}return t+=`${s.at(0)}\n`,e.header&&(t+="\nend"),t}),...e)}decode(t,...e){let i=0;return super.decode(t,(({input:t,settings:e})=>{const s=this.charsets[e.version],r=t.trim().split("\n"),n=[];/^begin/i.test(r.at(0))&&r.shift();for(const t of r){const e=[...t],r=s.indexOf(e.shift());if(!(r>0))break;if(n.push(...e),45!==r){i=this.converter.padChars(e.length)-r;break}}return n.join("")}),(({output:t})=>(i&&(t=new Uint8Array(t.slice(0,-i))),t)),!0,...e)}}const y=()=>{const t=()=>Math.floor(8*Math.random());return`${t()}${t()}${t()}`},m=()=>{const t=t=>t.at(Math.floor(Math.random()*t.length));return`${t(["unchronological","unconditionally","underemphasized","underprivileged","undistinguished","unsophisticated","untitled","untitled-1","untitled-3","uuencode"])}.${t(["applescript","bat","beam","bin","exe","js","mam","py","sh","vdo","wiz"])}`};class w extends c{constructor(...t){super(),this.converter=new l(85,4,5,84),this.charsets.adobe=[..."!\"#$%&'()*+,-./0123456789:;<=>?@ABCDEFGHIJKLMNOPQRSTUVWXYZ[\\]^_`abcdefghijklmnopqrstu"],this.charsets.ascii85=this.charsets.adobe.slice(),this.charsets.rfc1924=[..."0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz!#$%&()*+-;<=>?@^_`{|}~"],this.charsets.z85=[..."0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ.-:+=^!/*?&<>()[]{}@%$#"],this.version="ascii85",this.utils.validateArgs(t,!0)}encode(t,...e){return super.encode(t,(t=>{let e;return t.version.match(/adobe|ascii85/)&&(e=(t,e)=>e||"!!!!!"!==t?t:"z"),e}),(({output:t,settings:e,zeroPadding:i})=>{if(i){const e=this.converter.padBytes(i);t=t.slice(0,-e)}return"adobe"===e.version&&(t=`<~${t}~>`),t}),...e)}decode(t,...e){return super.decode(t,(({input:t,settings:e})=>(e.version.match(/adobe|ascii85/)&&(t=t.replace(/z/g,"!!!!!"),"adobe"===e.version&&(t=t.replace(/^<~|~>$/g,""))),t)),null,!1,...e)}}class v extends c{constructor(...t){super(),this.converter={radix:91,bsEnc:0,bsDec:0},this.charsets.default=[...'ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789!#$%&()*+,./:;<=>?@[]^_`{|}~"'],this.version="default",this.utils.validateArgs(t,!0)}encode(t,...e){const i=this.utils.validateArgs(e),s=this.utils.inputHandler.toBytes(t,i)[0];let r=0,n=0,o="";const a=this.charsets[i.version];if(s.forEach((t=>{if(n+=t<13){let t,e,i=13,s=n%8192;s<89&&(i=14,s=n%16384),n>>=i,r-=i,[t,e]=this.#s(s,91),o=`${o}${a[e]}${a[t]}`}})),r){let t,e;[t,e]=this.#s(n,91),o=o.concat(a[e]),(r>7||n>90)&&(o=o.concat(a[t]))}return this.utils.wrapOutput(o,i.options.lineWrap)}decode(t,...e){const i=this.utils.validateArgs(e),s=this.charsets[i.version];t=this.utils.normalizeInput(t);let r=[...t];i.integrity||(r=r.filter((t=>s.includes(t))));let n=r.length,o=!1;n%2&&(o=!0,n--);let h=0,l=0;const c=new Array;for(let t=0;t88?13:14;do{c.push(h%256),h>>=8,l-=8}while(l>7)}if(o){const t=r.at(n),e=s.indexOf(t);c.push(((e<>=7n,0==a&&0==(64&t)||-1==a&&0!=(64&t)){h.push(t);break}h.push(128|t)}else for(;;){const t=Number(127n&a);if(a>>=7n,0==a){h.push(t);break}h.push(128|t)}const l=Uint8Array.from(h);return"hex"===i.version?this.hexlify.encode(l,[..."0123456789abcdef"],!1)[0]:l}decode(e,...i){const s=this.utils.validateArgs(i);if("hex"===s.version)e=this.hexlify.decode(this.utils.normalizeInput(e).toLowerCase(),[..."0123456789abcdef"],[],s.integrity,!1);else{if(void 0===e.byteLength)throw new TypeError("Input must be a bytes like object.");e=t.toBytes(e)[0]}if(1===e.length&&!e[0])return this.utils.outputHandler.compile(new Uint8Array(1),s.outputType,!0);e=Array.from(e);let r,n,o,a=0n,h=-7n;for(r of e)h+=7n,a+=BigInt(127&r)<{e.forEach((e=>{e in this.#r?this.#r[e].version+=t:this.#r[e]={version:t}}))},i=(e,i,s)=>{i.forEach((i=>{i in t?this.#r[i].version=3:(this.#r[i]={version:e,padding:s},t[i]=s)}))};e(1,this.charsets.emojis_v1),e(2,this.charsets.emojis_v2),i(1,this.padChars.emojis_v1.slice(0,-1),"last"),i(2,this.padChars.emojis_v2.slice(0,-1),"last"),i(1,this.padChars.emojis_v1.slice(-1),"fill"),i(2,this.padChars.emojis_v2.slice(-1),"fill");const s=[];for(const e in t)"last"===t[e]?s.push(e):s.push(`${e}+`);this.#n=new RegExp(s.join("|"),"g")}encode(t,...e){return super.encode(t,null,(({output:t,settings:e,zeroPadding:i})=>{const s=this.charsets[e.version];let r=[...t];if(i>1){const t=this.converter.padBytes(i);if(e.padding){const i=e.trim?1:t,s=new Array(i).fill(this.padChars[e.version].at(-1));r.splice(r.length-t,t,...s)}else r.splice(r.length-t,t)}else if(1===i){const t=s.indexOf(r.pop())>>8;r.push(this.padChars[e.version].at(t))}return r.join("")}),...e)}decode(t,...e){const i=this.utils.validateArgs(e);t=this.utils.normalizeInput(t);let s=i.version,r=null;"emojis_v1"!==i.version&&"emojis_v2"!==i.version||(r=3);const n=t=>{null!==r&&(r=this.#a(t,r,i.integrity),s=3===r?i.version:`emojis_v${r}`);const e=this.charsets[s],n=[...t],o=n.at(-1);let a=!1;for(let i=0;i{const r=s.index+s.at(0).length;e.push(...n(t.slice(i,r))),i=r})),i!==t.length&&e.push(...n(t.slice(i,t.length))),a=Uint8Array.from(e)}return this.utils.outputHandler.compile(a,i.outputType)}#a(t,e,i){const s=[...t];let r;if(s.forEach(((t,s)=>{if(!(t in this.#r))throw new a(t);{const n=this.#r[t].version;if(3!==n)if(3===e)e=n;else if(e!==n)throw new TypeError(`Emojis from different ecoji versions seen : ${t} from emojis_v${n}`);if(i){const e=this.#r[t].padding;if(e){const i=s%4;if(r=!0,"fill"===e){if(0===i)throw new TypeError(`Padding unexpectedly seen in first position ${t}`)}else if(3!==i)throw new TypeError(`Last padding seen in unexpected position ${t}`)}else if(r)throw new TypeError("Unexpectedly saw non-padding after padding")}}})),i&&s.length%4&&(1===e||"fill"!==this.#r[s.at(-1)].padding))throw new TypeError("Unexpected end of data, input data size not multiple of 4");return e}}class x extends c{constructor(...t){super(),this.converter={radix:2048,bsEnc:11,bsEncPad:3,bsDec:8},this.charsets.default=[..."89ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyzÆÐØÞßæðøþĐđĦħıĸŁłŊŋŒœŦŧƀƁƂƃƄƅƆƇƈƉƊƋƌƍƎƏƐƑƒƓƔƕƖƗƘƙƚƛƜƝƞƟƢƣƤƥƦƧƨƩƪƫƬƭƮƱƲƳƴƵƶƷƸƹƺƻƼƽƾƿǀǁǂǃǝǤǥǶǷȜȝȠȡȢȣȤȥȴȵȶȷȸȹȺȻȼȽȾȿɀɁɂɃɄɅɆɇɈɉɊɋɌɍɎɏɐɑɒɓɔɕɖɗɘəɚɛɜɝɞɟɠɡɢɣɤɥɦɧɨɩɪɫɬɭɮɯɰɱɲɳɴɵɶɷɸɹɺɻɼɽɾɿʀʁʂʃʄʅʆʇʈʉʊʋʌʍʎʏʐʑʒʓʔʕʖʗʘʙʚʛʜʝʞʟʠʡʢʣʤʥʦʧʨʩʪʫʬʭʮʯͰͱͲͳͶͷͻͼͽͿΑΒΓΔΕΖΗΘΙΚΛΜΝΞΟΠΡΣΤΥΦΧΨΩαβγδεζηθικλμνξοπρςστυφχψωϏϗϘϙϚϛϜϝϞϟϠϡϢϣϤϥϦϧϨϩϪϫϬϭϮϯϳϷϸϺϻϼϽϾϿЂЄЅІЈЉЊЋЏАБВГДЕЖЗИКЛМНОПРСТУФХЦЧШЩЪЫЬЭЮЯабвгдежзиклмнопрстуфхцчшщъыьэюяђєѕіјљњћџѠѡѢѣѤѥѦѧѨѩѪѫѬѭѮѯѰѱѲѳѴѵѸѹѺѻѼѽѾѿҀҁҊҋҌҍҎҏҐґҒғҔҕҖҗҘҙҚқҜҝҞҟҠҡҢңҤҥҦҧҨҩҪҫҬҭҮүҰұҲҳҴҵҶҷҸҹҺһҼҽҾҿӀӃӄӅӆӇӈӉӊӋӌӍӎӏӔӕӘәӠӡӨөӶӷӺӻӼӽӾӿԀԁԂԃԄԅԆԇԈԉԊԋԌԍԎԏԐԑԒԓԔԕԖԗԘԙԚԛԜԝԞԟԠԡԢԣԤԥԦԧԨԩԪԫԬԭԮԯԱԲԳԴԵԶԷԸԹԺԻԼԽԾԿՀՁՂՃՄՅՆՇՈՉՊՋՌՍՎՏՐՑՒՓՔՕՖաբգդեզէըթժիլխծկհձղճմյնշոչպջռսվտրցւփքօֆאבגדהוזחטיךכלםמןנסעףפץצקרשתװױײؠءابةتثجحخدذرزسشصضطظعغػؼؽؾؿفقكلمنهوىي٠١٢٣٤٥٦٧٨٩ٮٯٱٲٳٴٹٺٻټٽپٿڀځڂڃڄڅچڇڈډڊڋڌڍڎڏڐڑڒړڔڕږڗژڙښڛڜڝڞڟڠڡڢڣڤڥڦڧڨکڪګڬڭڮگڰڱڲڳڴڵڶڷڸڹںڻڼڽھڿہۃۄۅۆۇۈۉۊۋیۍێۏېۑےەۮۯ۰۱۲۳۴۵۶۷۸۹ۺۻۼۿܐܒܓܔܕܖܗܘܙܚܛܜܝܞܟܠܡܢܣܤܥܦܧܨܩܪܫܬܭܮܯݍݎݏݐݑݒݓݔݕݖݗݘݙݚݛݜݝݞݟݠݡݢݣݤݥݦݧݨݩݪݫݬݭݮݯݰݱݲݳݴݵݶݷݸݹݺݻݼݽݾݿހށނރބޅކއވމފދތލގޏސޑޒޓޔޕޖޗޘޙޚޛޜޝޞޟޠޡޢޣޤޥޱ߀߁߂߃߄߅߆߇߈߉ߊߋߌߍߎߏߐߑߒߓߔߕߖߗߘߙߚߛߜߝߞߟߠߡߢߣߤߥߦߧߨߩߪࠀࠁࠂࠃࠄࠅࠆࠇࠈࠉࠊࠋࠌࠍࠎࠏࠐࠑࠒࠓࠔࠕࡀࡁࡂࡃࡄࡅࡆࡇࡈࡉࡊࡋࡌࡍࡎࡏࡐࡑࡒࡓࡔࡕࡖࡗࡘࡠࡡࡢࡣࡤࡥࡦࡧࡨࡩࡪࢠࢡࢢࢣࢤࢥࢦࢧࢨࢩࢪࢫࢬࢭࢮࢯࢰࢱࢲࢳࢴࢶࢷࢸࢹࢺࢻࢼࢽऄअआइईउऊऋऌऍऎएऐऑऒओऔकखगघङचछजझञटठडढणतथदधनपफबभमयरलळवशषसहऽॐॠॡ०१२३४५६७८९ॲॳॴॵॶॷॸॹॺॻॼॽॾॿঀঅআইঈউঊঋঌএঐওঔকখগঘঙচছজঝঞটঠডঢণতথদধনপফবভমযরলশষসহঽৎৠৡ০১২৩৪৫৬৭৮৯ৰৱ৴৵৶৷৸৹ৼਅਆਇਈਉਊਏਐਓਔਕਖਗਘਙਚਛਜਝਞਟਠਡਢਣਤਥਦਧਨਪਫਬਭਮਯਰਲਵਸਹੜ੦੧੨੩੪੫੬੭੮੯ੲੳੴઅઆઇઈઉઊઋઌઍએઐઑઓઔકખગઘઙચછજઝઞટઠડઢણતથદધનપફબભમયરલળવશષસહઽૐૠૡ૦૧૨૩૪૫૬૭૮૯ૹଅଆଇଈଉଊଋଌଏଐଓଔକଖଗଘଙଚଛଜଝଞଟଠଡଢଣତଥଦଧନପଫବଭମଯରଲଳଵଶଷସହଽୟୠୡ୦୧୨୩୪୫୬୭୮୯ୱ୲୳୴୵୶୷ஃஅஆஇஈஉஊஎஏஐஒஓகஙசஜஞடணதநனபமயரறலளழவஶஷஸஹௐ௦௧௨௩௪௫௬௭௮௯௰௱௲అఆఇఈఉఊఋఌఎఏఐఒఓఔకఖగఘఙచఛజఝఞటఠడఢణతథదధనపఫబభమయరఱలళఴవశషసహఽౘౙౚౠౡ౦౧౨౩౪౫౬౭౮౯౸౹౺౻౼౽౾ಀಅಆಇಈಉಊಋಌಎಏಐಒಓಔಕಖಗಘಙಚಛಜಝಞಟಠಡಢಣತಥದಧನಪಫಬಭಮಯರಱಲಳವಶಷಸಹಽೞೠೡ೦೧೨೩೪೫೬೭೮೯ೱೲഅആഇഈഉഊഋഌഎഏഐഒഓഔകഖഗഘങചഛജഝഞടഠഡഢണതഥദധനഩപഫബഭമയരറലളഴവശഷസഹഺഽൎൔൕൖ൘൙൚൛൜൝൞ൟൠൡ൦൧൨൩൪൫൬൭൮൯൰൱൲൳൴൵൶൷൸ൺൻർൽൾൿඅආඇඈඉඊඋඌඍඎඏඐඑඒඓඔඕඖකඛගඝඞඟචඡජඣඤඥඦටඨඩඪණඬතථදධනඳපඵබභමඹයරලවශෂසහළෆ෦෧෨෩෪෫෬෭෮෯กขฃคฅฆงจฉชซฌญฎฏฐฑฒณดตถทธนบปผฝพฟภมยรฤลฦวศษสหฬอฮฯะาเแโใไๅ๐๑๒๓๔๕๖๗๘๙ກຂຄງຈຊຍດຕຖທນບປຜຝພຟມຢຣລວສຫອຮຯະາຽເແໂໃໄ໐໑໒໓໔໕໖໗໘໙ໞໟༀ༠༡༢༣༤༥༦༧༨༩༪༫༬༭༮༯༰༱༲༳ཀཁགངཅཆཇཉཊཋཌཎཏཐདནཔཕབམཙཚཛཝཞཟའཡརལཤཥསཧཨཪཫཬྈྉྊྋྌကခဂဃငစဆဇဈဉညဋဌဍဎဏတထဒဓနပဖဗဘမယရလဝသဟဠအဢဣဤဥဧဨဩဪဿ၀၁၂၃၄၅၆၇၈၉ၐၑၒၓၔၕ"],this.padChars.default=[..."01234567"],this.padCharAmount=8,this.hasSignedMode=!0,this.littleEndian=!1,this.utils.validateArgs(t,!0)}encode(t,...e){const i=this.utils.validateArgs(e);let s=this.utils.inputHandler.toBytes(t,i).at(0);const r=this.charsets[i.version],n=this.padChars[i.version];let o="",a=0,h=0;if(s.forEach((t=>{for(let e=this.converter.bsDec-1;e>=0;e--)a=(a<<1)+(t>>e&1),h++,h===this.converter.bsEnc&&(o+=r.at(a),a=0,h=0)})),0!==h){let t,e;for(h<=this.converter.bsEncPad?(t=this.converter.bsEncPad,e=!0):(t=this.converter.bsEnc,e=!1);h!==t;)if(a=1+(a<<1),h++,h>this.converter.bsEnc)throw new Error("Cannot process input. This is a bug!");o+=e?n.at(a):r.at(a)}return this.utils.wrapOutput(o,i.options.lineWrap)}decode(t,...e){const i=this.utils.validateArgs(e);t=this.utils.normalizeInput(t);const s=[...t],r=this.charsets[i.version],n=this.padChars[i.version],o=new Array;let h=0,l=0;return s.forEach(((t,e)=>{let c,u=r.indexOf(t);if(u>-1)c=this.converter.bsEnc;else if(u=n.indexOf(t),u>-1){if(e+1!==s.length)throw new a(null,`Secondary character found before end of input, index: ${e}`);c=this.converter.bsEncPad}else if(i.integrity)throw new a(t);for(let t=c-1;t>=0;t--)h=(h<<1)+(u>>t&1),l++,l===this.converter.bsDec&&(o.push(h),h=0,l=0)})),this.utils.outputHandler.compile(Uint8Array.from(o),i.outputType)}}class T extends c{constructor(t,...e){if(super(),!t||!Number.isInteger(t)||t<2||t>62)throw new RangeError("Radix argument must be provided and has to be an integer between 2 and 62.");this.converter=new l(t,0,0),this.charsets.default=[..."0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ"].slice(0,t),this.frozenCharsets=!0,this.hasSignedMode=!0,this.littleEndian=!(2===t||16===t),this.signed=!0,this.version="default",this.isMutable.littleEndian=!0,this.isMutable.upper=t<=36,this.utils.validateArgs(e,!0)}encode(t,...e){return super.encode(t,null,null,...e)}decode(t,...e){return super.decode(t,(({input:t})=>{if(2===this.converter.radix){const e=(8-t.length%8)%8;t=`${"0".repeat(e)}${t}`}else if(16===this.converter.radix){const e=t.length%2;t=`${"0".repeat(e)}${t}`}return t}),null,!1,...e)}}let M=1e6,j="[big.js] ",C=j+"Invalid ",$=C+"decimal places",I=C+"rounding mode",B={},S=/^-?(\d+(\.\d*)?|\.\d+)(e[+-]?\d+)?$/i;function k(t,e,i,s){let r=t.c;if(void 0===i&&(i=t.constructor.RM),0!==i&&1!==i&&2!==i&&3!==i)throw Error(I);if(e<1)s=3===i&&(s||!!r[0])||0===e&&(1===i&&r[0]>=5||2===i&&(r[0]>5||5===r[0]&&(s||void 0!==r[1]))),r.length=1,s?(t.e=t.e-e+1,r[0]=1):r[0]=t.e=0;else if(e=5||2===i&&(r[e]>5||5===r[e]&&(s||void 0!==r[e+1]||1&r[e-1]))||3===i&&(s||!!r[0]),r.length=e,s)for(;++r[--e]>9;)if(r[e]=0,0===e){++t.e,r.unshift(1);break}for(e=r.length;!r[--e];)r.pop()}return t}function _(t,e,i){let s=t.e,r=t.c.join(""),n=r.length;if(e)r=r.charAt(0)+(n>1?"."+r.slice(1):"")+(s<0?"e":"e+")+s;else if(s<0){for(;++s;)r="0"+r;r="0."+r}else if(s>0)if(++s>n)for(s-=n;s--;)r+="0";else s1&&(r=r.charAt(0)+"."+r.slice(1));return t.s<0&&i?"-"+r:r}B.abs=function(){let t=new this.constructor(this);return t.s=1,t},B.cmp=function(t){let e,i=this,s=i.c,r=(t=new i.constructor(t)).c,n=i.s,o=t.s,a=i.e,h=t.e;if(!s[0]||!r[0])return s[0]?n:r[0]?-o:0;if(n!=o)return n;if(e=n<0,a!=h)return a>h^e?1:-1;for(o=(a=s.length)<(h=r.length)?a:h,n=-1;++nr[n]^e?1:-1;return a==h?0:a>h^e?1:-1},B.eq=function(t){return 0===this.cmp(t)},B.gt=function(t){return this.cmp(t)>0},B.gte=function(t){return this.cmp(t)>-1},B.lt=function(t){return this.cmp(t)<0},B.lte=function(t){return this.cmp(t)<1},B.minus=B.sub=function(t){let e,i,s,r,n=this,o=n.constructor,a=n.s,h=(t=new o(t)).s;if(a!=h)return t.s=-h,n.plus(t);let l=n.c.slice(),c=n.e,u=t.c,d=t.e;if(!l[0]||!u[0])return u[0]?t.s=-h:l[0]?t=new o(n):t.s=1,t;if(a=c-d){for((r=a<0)?(a=-a,s=l):(d=c,s=u),s.reverse(),h=a;h--;)s.push(0);s.reverse()}else for(i=((r=l.length0)for(;h--;)l[e++]=0;for(h=e;i>a;){if(l[--i]0?(h=o,s=l):(e=-e,s=a),s.reverse();e--;)s.push(0);s.reverse()}for(a.length-l.length<0&&(s=l,l=a,a=s),e=l.length,i=0;e;a[e]%=10)i=(a[--e]=a[e]+l[e]+i)/10|0;for(i&&(a.unshift(i),++h),e=a.length;0===a[--e];)a.pop();return t.c=a,t.e=h,t},B.round=function(t,e){if(void 0===t)t=0;else if(t!==~~t||t<-M||t>M)throw Error($);return k(new this.constructor(this),t+this.e+1,e)},B.toFixed=function(t,e){let i=this,s=i.c[0];if(void 0!==t){if(t!==~~t||t<0||t>M)throw Error($);for(i=k(new i.constructor(i),t+i.e+1,e),t=t+i.e+1;i.c.length=e.PE,!!t.c[0])},B.toNumber=function(){let t=Number(_(this,!0,!0));if(!0===this.constructor.strict&&!this.eq(t.toString()))throw Error(j+"Imprecise conversion");return t};const U=function t(){function e(i){let s=this;if(!(s instanceof e))return void 0===i?t():new e(i);if(i instanceof e)s.s=i.s,s.e=i.e,s.c=i.c.slice();else{if("string"!=typeof i){if(!0===e.strict&&"bigint"!=typeof i)throw TypeError(C+"value");i=0===i&&1/i<0?"-0":String(i)}!function(t,e){let i,s,r;if(!S.test(e))throw Error(`${C}number`);for(t.s="-"==e.charAt(0)?(e=e.slice(1),-1):1,(i=e.indexOf("."))>-1&&(e=e.replace(".","")),(s=e.search(/e/i))>0?(i<0&&(i=s),i+=+e.slice(s+1),e=e.substring(0,s)):i<0&&(i=e.length),r=e.length,s=0;s0&&"0"==e.charAt(--r););for(t.e=i-s-1,t.c=[],i=0;s<=r;)t.c[i++]=+e.charAt(s++)}}(s,i)}s.constructor=e}return e.prototype=B,e.DP=20,e.RM=1,e.NE=-7,e.PE=21,e.strict=false,e.roundDown=0,e.roundHalfUp=1,e.roundHalfEven=2,e.roundUp=3,e}();class N extends c{#h=U("1.618033988749894848204586834365638117720309179805762862135448622705260462818902449707207204189391137484754088075386891752");constructor(...t){super(),this.converter={radix:2,bsEnc:0,bsDec:0},this.b10=new l(10,0,0),this.charsets.default=["0","1"],this.version="default",this.signed=!0,this.hasDecimalMode=!0,this.utils.validateArgs(t,!0)}encode(t,...e){const i=this.utils.validateArgs(e),s=this.charsets[i.version];let r,n,o,a="";if(i.decimalMode){if(!Number.isFinite(t))throw new TypeError("When running the converter in decimal-mode, only input of type 'Number' is allowed.");t<0?(n=!0,o=U(-t)):(n=!1,o=U(t))}else[r,n]=this.utils.inputHandler.toBytes(t,i),o=U(this.b10.encode(r,null,i.littleEndian)[0]);if(o.eq(0)||o.eq(1))return a=s[o.toNumber()],n&&(a=`-${a}`),a;const h=[],l=[];let c=U(1),u=this.#h,d=0;for(;u.lt(o);)[c,u]=this.#l(c,u),d++;const f=(t,e,i)=>{if(!this.#c(o)){for(;t.gt(o);){if([t,e]=this.#u(t,e),t.lte(0))return void console.warn("Could not find an exact base-phi representation. Value is approximated.");i--}i>-1?h.unshift(i):l.push(i),o=o.minus(t),f(t,e,i)}};return f(c,u,d),d=0,h.forEach((t=>{for(;d{for(;d>t;)a+=s[0],d--;a+=s[1],d--})),n&&(a=`-${a}`),a}decode(t,...e){const i=this.utils.validateArgs(e),s=this.charsets[i.version];let r;if([t,r]=this.utils.extractSign(this.utils.normalizeInput(t)),!i.integrity){const e=[...s,"."];t=[...t].filter((t=>e.includes(t))).join("")}const n=t.split(".");if(i.integrity&&n.length>2)throw new a(null,"There are multiple decimal points in the input.");const[o,h]=n;let l=U(0),c=this.#h.minus(1),u=U(1);if([...o].reverse().forEach((t=>{const e=s.indexOf(t);if(1===e)l=l.plus(u);else if(0!==e)throw new a(t);[c,u]=this.#l(c,u)})),h){let t=U(1);u=this.#h.minus(t),[...h].forEach((e=>{const i=s.indexOf(e);if(1===i)l=l.plus(u);else if(0!==i)throw new a(e);[u,t]=this.#u(u,t)}))}if(i.decimalMode)return l.toNumber();l=l.round().toFixed();const d=this.b10.decode(l,[..."0123456789"],[],i.integrity,i.littleEndian);return this.utils.outputHandler.compile(d,i.outputType,i.littleEndian,r)}#c(t){return!t.round(50).abs().toNumber()}#l(t,e){return[e,t.plus(e)]}#u(t,e){return[e.minus(t),t]}}const D=(()=>{const t=new Uint16Array([1]),e=new Uint8Array(t.buffer);return Boolean(e.at(0))})();class O{constructor(...t){this.littleEndian=D,this.numberMode=!1,this.outputType="buffer",this.utils={validateArgs:(t,e=!1)=>{const i={littleEndian:this.littleEndian,numberMode:this.numberMode,outputType:this.outputType,signed:!1};if(!t.length)return i;t.includes("number")&&(t.splice(t.indexOf("number"),1),i.numberMode=!0,i.outputType="float_n");const r=s.typeList.map((t=>`'${t}'`)).join(", ");if(t.forEach((t=>{if("le"===(t=String(t).toLowerCase()))i.littleEndian=!0;else if("be"===t)i.littleEndian=!1;else{if(!s.typeList.includes(t))throw new TypeError(`Invalid argument: '${t}.\nValid arguments are:\n'le', 'be', ${r}`);i.outputType=t}})),e)for(const t in i)this[t]=i[t];return i}},this.utils.validateArgs(t,!0)}encode(t,...e){const s=this.utils.validateArgs(e);return i.toBytes(t,s)[0]}decode(t,...e){const i=this.utils.validateArgs(e);return s.compile(t,i.outputType,i.littleEndian)}} /** * [BaseEx]{@link https://github.com/UmamiAppearance/BaseExJS} * - * @version 0.4.3 + * @version 0.6.1 * @author UmamiAppearance [mail@umamiappearance.eu] * @license GPL-3.0 AND BSD-3-Clause (only regarding Base91, Copyright (c) 2000-2006 Joachim Henke) */ /** * [BrowserSHAObj]{@link https://github.com/UmamiAppearance/BrowserSHAObj} * - * @version 0.3.2 + * @version 0.3.3 * @author UmamiAppearance [mail@umamiappearance.eu] * @license GPL-3.0 */ -const m=["SHA-1","SHA-256","SHA-384","SHA-512"],v=new class{constructor(t="buffer"){if(!r.typeList.includes(t)){let e=`Invalid argument '${t}' for output type. Allowed types are:\n`;throw e=e.concat(r.typeList.join(", ")),new TypeError(e)}this.base1=new h("default",t),this.base16=new u("default",t),this.base32_crockford=new c("rfc4648",t),this.base32_rfc3548=new c("rfc3548",t),this.base32_rfc4648=new c("rfc4648",t),this.base32_zbase32=new c("zbase32",t),this.base58=new d("default",t),this.base58_bitcoin=new d("bitcoin",t),this.base58_flickr=new d("flickr",t),this.base64=new f("default",t),this.base64_urlsafe=new f("urlsafe",t),this.base85_adobe=new p("adobe",t),this.base85_ascii=new p("ascii85",t),this.base85_z85=new p("z85",t),this.base91=new g("default",t),this.leb128=new y("default",t),this.byteConverter=new b(t),this.simpleBase={};for(let e=2;e<37;e++)this.simpleBase[`base${e}`]=new w(e,t)}};return class{#e=null;#s=null;#i=null;#n=[];constructor(t="SHA-256"){const e=this.constructor.algorithmsAvailable();if(this.#s=0|[].concat(String(t).match(/[0-9]+/)).at(0),this.#e=`SHA-${this.#s}`,1===this.#s&&(this.#s=160),!e.has(this.#e))throw new TypeError(`Available algorithms are: '${m.join(", ")}'.`);this.#r()}static baseEx=v;static algorithmsAvailable(){return new Set(m)}static algorithmsGuaranteed(){return this.constructor.algorithmsAvailable()}static async new(t="SHA-256",e=null){const s=new this(t);return null!==e&&await s.update(e),s}get digestSize(){return this.#s/8}get blockSize(){return this.#s>256?128:64}get name(){return this.#e}async copy(){const t=this.#n.length?Uint8Array.from(this.#n):null;return this.constructor.new(this.#e,t)}async update(t,e=!1){let s;(t=t instanceof ArrayBuffer?new Uint8Array(t):ArrayBuffer.isView(t)?new Uint8Array(t.buffer):v.byteConverter.encode(t,"uint8")).byteLength<2e8?(this.#n=e?Array.from(t):this.#n.concat(Array.from(t)),s=Uint8Array.from(this.#n),s.byteLength>5e8&&!this.warned&&(console.warn("The stored input is getting really big. Dependent from your environment this can lead to memory issues."),this.warned=!0)):(console.warn("Input gets too big to safely store it in memory. It will get processed directly and neither stored nor concatenated to previous input. If the operation fails, it is due to memory issues."),s=t),this.#i=await window.crypto.subtle.digest(this.#e,s)}async replace(t){await this.update(t,!0)}digest(){return this.#i}#r(){const t=(t,e)=>t.splice(t.indexOf(e),1),e=t=>t.charAt(0).toUpperCase().concat(t.slice(1));this.hexdigest=()=>this.#i?v.base16.encode(this.#i):null;const s=Object.keys(v);this.basedigest={toSimpleBase:{}},t(s,"base1"),t(s,"byteConverter"),t(s,"simpleBase");for(const t of s)this.basedigest[`to${e(t)}`]=(...e)=>this.#i?v[t].encode(this.#i,...e):null;for(const t in v.simpleBase)this.basedigest.toSimpleBase[e(t)]=(...e)=>this.#i?v.simpleBase[t].encode(this.#i,...e):null;this.basedigest.toBytes=(...t)=>this.#i?v.byteConverter.encode(this.#i,...t):null}}}(); +const P=["SHA-1","SHA-256","SHA-384","SHA-512"],z=new class{constructor(t="buffer"){if(!n.typeList.includes(t)){let e=`Invalid argument '${t}' for output type. Allowed types are:\n`;throw e=e.concat(n.typeList.join(", ")),new TypeError(e)}this.base1=new u("default",t),this.base16=new d("default",t),this.base32_crockford=new f("rfc4648",t),this.base32_rfc3548=new f("rfc3548",t),this.base32_rfc4648=new f("rfc4648",t),this.base32_zbase32=new f("zbase32",t),this.base58=new p("default",t),this.base58_bitcoin=new p("bitcoin",t),this.base58_flickr=new p("flickr",t),this.base64=new g("default",t),this.base64_urlsafe=new g("urlsafe",t),this.uuencode=new b("default",t),this.xxencode=new b("xx",t),this.base85_adobe=new w("adobe",t),this.base85_ascii=new w("ascii85",t),this.base85_z85=new w("z85",t),this.base91=new v("default",t),this.leb128=new A("default",t),this.ecoji_v1=new E("emojis_v1",t),this.ecoji_v2=new E("emojis_v2",t),this.base2048=new x("default",t),this.basePhi=new N("default",t),this.byteConverter=new O(t),this.simpleBase={};for(let e=2;e<=62;e++)this.simpleBase[`base${e}`]=new T(e,t)}};return class{#d=null;#f=null;#p=null;#g=[];constructor(t="SHA-256"){const e=this.constructor.algorithmsAvailable();if(this.#f=0|[].concat(String(t).match(/[0-9]+/)).at(0),this.#d=`SHA-${this.#f}`,1===this.#f&&(this.#f=160),!e.has(this.#d))throw new TypeError(`Available algorithms are: '${P.join(", ")}'.`);this.#b()}static baseEx=z;static algorithmsAvailable(){return new Set(P)}static algorithmsGuaranteed(){return this.constructor.algorithmsAvailable()}static async new(t="SHA-256",e=null){const i=new this(t);return null!==e&&await i.update(e),i}get digestSize(){return this.#f/8}get blockSize(){return this.#f>256?128:64}get name(){return this.#d}async copy(){const t=this.#g.length?Uint8Array.from(this.#g):null;return this.constructor.new(this.#d,t)}async update(t,e=!1){let i;(t=t instanceof ArrayBuffer?new Uint8Array(t):ArrayBuffer.isView(t)?new Uint8Array(t.buffer):z.byteConverter.encode(t,"uint8")).byteLength<2e8?(this.#g=e?Array.from(t):this.#g.concat(Array.from(t)),i=Uint8Array.from(this.#g),i.byteLength>5e8&&!this.warned&&(console.warn("The stored input is getting really big. Dependent from your environment this can lead to memory issues."),this.warned=!0)):(console.warn("Input gets too big to safely store it in memory. It will get processed directly and neither stored nor concatenated to previous input. If the operation fails, it is due to memory issues."),i=t),this.#p=await window.crypto.subtle.digest(this.#d,i)}async replace(t){await this.update(t,!0)}digest(){return this.#p}#b(){const t=(t,e)=>t.splice(t.indexOf(e),1),e=t=>t.charAt(0).toUpperCase().concat(t.slice(1));this.hexdigest=()=>this.#p?z.base16.encode(this.#p):null;const i=Object.keys(z);this.basedigest={toSimpleBase:{}},t(i,"base1"),t(i,"byteConverter"),t(i,"simpleBase");for(const t of i)this.basedigest[`to${e(t)}`]=(...e)=>this.#p?z[t].encode(this.#p,...e):null;for(const t in z.simpleBase)this.basedigest.toSimpleBase[e(t)]=(...e)=>this.#p?z.simpleBase[t].encode(this.#p,...e):null;this.basedigest.toBytes=(...t)=>this.#p?z.byteConverter.encode(this.#p,...t):null}}}(); diff --git a/package-lock.json b/package-lock.json index 62b4917..8525057 100644 --- a/package-lock.json +++ b/package-lock.json @@ -1,20 +1,20 @@ { "name": "browser-sha-obj", - "version": "0.3.2", - "lockfileVersion": 2, + "version": "0.3.3", + "lockfileVersion": 3, "requires": true, "packages": { "": { "name": "browser-sha-obj", - "version": "0.3.2", + "version": "0.3.3", "license": "GPL-3.0", "devDependencies": { "@rollup/plugin-terser": "^0.1.0", - "base-ex": "^0.4.3", - "eslint": "^8.27.0", + "base-ex": "^0.6.1", + "eslint": "^8.29.0", "http-server": "^14.1.1", - "no-bro-cote": "^0.2.6", - "rollup": "^3.2.5" + "no-bro-cote": "^0.2.7", + "rollup": "^3.7.1" } }, "node_modules/@babel/code-frame": { @@ -293,18 +293,12 @@ } }, "node_modules/@types/node": { - "version": "18.11.9", - "resolved": "https://registry.npmjs.org/@types/node/-/node-18.11.9.tgz", - "integrity": "sha512-CRpX21/kGdzjOpFsZSkcrXMGIBWMGNIHXXBVFSH+ggkftxg+XYP20TESbh+zFvFj3EQOl5byk0HTRn1IL6hbqg==", + "version": "18.11.12", + "resolved": "https://registry.npmjs.org/@types/node/-/node-18.11.12.tgz", + "integrity": "sha512-FgD3NtTAKvyMmD44T07zz2fEf+OKwutgBCEVM8GcvMGVGaDktiLNTDvPwC/LUe3PinMW+X6CuLOF2Ui1mAlSXg==", "dev": true, "optional": true }, - "node_modules/@types/parse-json": { - "version": "4.0.0", - "resolved": "https://registry.npmjs.org/@types/parse-json/-/parse-json-4.0.0.tgz", - "integrity": "sha512-//oorEZjL6sbPcKUaCdIGlIUeH26mgzimjBB77G6XRgnDl/L5wOnpyBGRe/Mmf5CVW3PwEBE1NjiMZ/ssFh4wA==", - "dev": true - }, "node_modules/@types/yauzl": { "version": "2.10.0", "resolved": "https://registry.npmjs.org/@types/yauzl/-/yauzl-2.10.0.tgz", @@ -431,9 +425,9 @@ "dev": true }, "node_modules/base-ex": { - "version": "0.4.3", - "resolved": "https://registry.npmjs.org/base-ex/-/base-ex-0.4.3.tgz", - "integrity": "sha512-yj+1wOjny1dfr0AEsp8+O6i1iAxUzpCe6fvwSGtHRK7z6giJPLfXPsxHnybvkd92EX9Fkq64ku3jhiO/MTsORw==", + "version": "0.6.1", + "resolved": "https://registry.npmjs.org/base-ex/-/base-ex-0.6.1.tgz", + "integrity": "sha512-Rd49Su3LpSRx75QPS9bWo68gfWKSITFdTOvTvCU3sjyuzd0TP3BgQmkEdiy3C7iPde/Nx8WBpwmsrx62x13K8Q==", "dev": true }, "node_modules/base64-js": { @@ -632,19 +626,18 @@ } }, "node_modules/cosmiconfig": { - "version": "7.0.1", - "resolved": "https://registry.npmjs.org/cosmiconfig/-/cosmiconfig-7.0.1.tgz", - "integrity": "sha512-a1YWNUV2HwGimB7dU2s1wUMurNKjpx60HxBB6xUM8Re+2s1g1IIfJvFR0/iCF+XHdE0GMTKTuLR32UQff4TEyQ==", + "version": "8.0.0", + "resolved": "https://registry.npmjs.org/cosmiconfig/-/cosmiconfig-8.0.0.tgz", + "integrity": "sha512-da1EafcpH6b/TD8vDRaWV7xFINlHlF6zKsGwS1TsuVJTZRkquaS5HTMq7uq6h31619QjbsYl21gVDOm32KM1vQ==", "dev": true, "dependencies": { - "@types/parse-json": "^4.0.0", "import-fresh": "^3.2.1", + "js-yaml": "^4.1.0", "parse-json": "^5.0.0", - "path-type": "^4.0.0", - "yaml": "^1.10.0" + "path-type": "^4.0.0" }, "engines": { - "node": ">=10" + "node": ">=14" } }, "node_modules/cross-fetch": { @@ -703,9 +696,9 @@ "dev": true }, "node_modules/devtools-protocol": { - "version": "0.0.1056733", - "resolved": "https://registry.npmjs.org/devtools-protocol/-/devtools-protocol-0.0.1056733.tgz", - "integrity": "sha512-CmTu6SQx2g3TbZzDCAV58+LTxVdKplS7xip0g5oDXpZ+isr0rv5dDP8ToyVRywzPHkCCPKgKgScEcwz4uPWDIA==", + "version": "0.0.1068969", + "resolved": "https://registry.npmjs.org/devtools-protocol/-/devtools-protocol-0.0.1068969.tgz", + "integrity": "sha512-ATFTrPbY1dKYhPPvpjtwWKSK2mIwGmRwX54UASn9THEuIZCe2n9k3vVuMmt6jWeL+e5QaaguEv/pMyR+JQB7VQ==", "dev": true }, "node_modules/doctrine": { @@ -766,9 +759,9 @@ } }, "node_modules/eslint": { - "version": "8.27.0", - "resolved": "https://registry.npmjs.org/eslint/-/eslint-8.27.0.tgz", - "integrity": "sha512-0y1bfG2ho7mty+SiILVf9PfuRA49ek4Nc60Wmmu62QlobNR+CeXa4xXIJgcuwSQgZiWaPH+5BDsctpIW0PR/wQ==", + "version": "8.29.0", + "resolved": "https://registry.npmjs.org/eslint/-/eslint-8.29.0.tgz", + "integrity": "sha512-isQ4EEiyUjZFbEKvEGJKKGBwXtvXX+zJbkVKCgTuB9t/+jUBcy8avhkEwWJecI15BkRkOYmvIM5ynbhRjEkoeg==", "dev": true, "dependencies": { "@eslint/eslintrc": "^1.3.3", @@ -983,9 +976,9 @@ "dev": true }, "node_modules/fastq": { - "version": "1.13.0", - "resolved": "https://registry.npmjs.org/fastq/-/fastq-1.13.0.tgz", - "integrity": "sha512-YpkpUnK8od0o1hmeSc7UUs/eB/vIPWJYjKck2QKIzAf71Vm1AAQ3EbuZB3g2JIy+pg+ERD0vqI79KyZiB2e2Nw==", + "version": "1.14.0", + "resolved": "https://registry.npmjs.org/fastq/-/fastq-1.14.0.tgz", + "integrity": "sha512-eR2D+V9/ExcbF9ls441yIuN6TI2ED1Y2ZcA5BmMtJsOkWOFRJQ0Jt0g1UwqXJJVAb+V+umH5Dfr8oh4EVP7VVg==", "dev": true, "dependencies": { "reusify": "^1.0.4" @@ -1205,9 +1198,9 @@ } }, "node_modules/globals": { - "version": "13.17.0", - "resolved": "https://registry.npmjs.org/globals/-/globals-13.17.0.tgz", - "integrity": "sha512-1C+6nQRb1GwGMKm2dH/E7enFAMxGTmGI7/dEdhy/DNelv85w9B72t3uc5frtMNXIbzrarJJ/lTCjcaZwbLJmyw==", + "version": "13.18.0", + "resolved": "https://registry.npmjs.org/globals/-/globals-13.18.0.tgz", + "integrity": "sha512-/mR4KI8Ps2spmoc0Ulu9L7agOF0du1CZNQ3dke8yItYlyKNmGrkONemBbd6V8UTc1Wgcqn21t3WYB7dbRmh6/A==", "dev": true, "dependencies": { "type-fest": "^0.20.2" @@ -1366,9 +1359,9 @@ ] }, "node_modules/ignore": { - "version": "5.2.0", - "resolved": "https://registry.npmjs.org/ignore/-/ignore-5.2.0.tgz", - "integrity": "sha512-CmxgYGiEPCLhfLnpPp1MoRmifwEIOgjcHXxOBjv7mY96c+eWScsOP9c112ZyLdWHi0FxHjI+4uVhKYp/gcdRmQ==", + "version": "5.2.1", + "resolved": "https://registry.npmjs.org/ignore/-/ignore-5.2.1.tgz", + "integrity": "sha512-d2qQLzTJ9WxQftPAuEQpSPmKqzxePjzVbpAVv62AQ64NTL+wR4JkrVqR/LqFsFEUsHDAiId52mJteHDFuDkElA==", "dev": true, "engines": { "node": ">= 4" @@ -1391,15 +1384,15 @@ } }, "node_modules/import-manager": { - "version": "0.1.3", - "resolved": "https://registry.npmjs.org/import-manager/-/import-manager-0.1.3.tgz", - "integrity": "sha512-wVJhQ1G55yla0jA3rDsU1irf2NI1ueRPcz57OJ+kspez1NvNzupk6iBM+HYZenCTi1XPHHTeoNDs8F8w3xlVnA==", + "version": "0.1.5", + "resolved": "https://registry.npmjs.org/import-manager/-/import-manager-0.1.5.tgz", + "integrity": "sha512-cVepG8BChdWdNMd2DpbdVRbJRIPlghkPghWvKA1SeRUgCMMZMDCjFSalePnFtfwLcBIKi0cNMcS89N7IqtrIoA==", "dev": true, "dependencies": { - "acorn": "^8.8.0", + "acorn": "^8.8.1", "acorn-walk": "^8.2.0", "colorette": "^2.0.19", - "magic-string": "^0.26.7" + "magic-string": "^0.27.0" } }, "node_modules/imurmurhash": { @@ -1491,10 +1484,14 @@ "dev": true }, "node_modules/js-sdsl": { - "version": "4.1.5", - "resolved": "https://registry.npmjs.org/js-sdsl/-/js-sdsl-4.1.5.tgz", - "integrity": "sha512-08bOAKweV2NUC1wqTtf3qZlnpOX/R2DU9ikpjOHs0H+ibQv3zpncVQg6um4uYtRtrwIX8M4Nh3ytK4HGlYAq7Q==", - "dev": true + "version": "4.2.0", + "resolved": "https://registry.npmjs.org/js-sdsl/-/js-sdsl-4.2.0.tgz", + "integrity": "sha512-dyBIzQBDkCqCu+0upx25Y2jGdbTGxE9fshMsCdK0ViOongpV+n5tXRcZY9v7CaVQ79AGS9KA1KHtojxiM7aXSQ==", + "dev": true, + "funding": { + "type": "opencollective", + "url": "https://opencollective.com/js-sdsl" + } }, "node_modules/js-tokens": { "version": "4.0.0", @@ -1570,9 +1567,9 @@ } }, "node_modules/ky-universal/node_modules/node-fetch": { - "version": "3.2.10", - "resolved": "https://registry.npmjs.org/node-fetch/-/node-fetch-3.2.10.tgz", - "integrity": "sha512-MhuzNwdURnZ1Cp4XTazr69K0BTizsBroX7Zx3UgDSVcZYKF/6p0CBe4EUb/hLqmzVhl0UpYfgRljQ4yxE+iCxA==", + "version": "3.3.0", + "resolved": "https://registry.npmjs.org/node-fetch/-/node-fetch-3.3.0.tgz", + "integrity": "sha512-BKwRP/O0UvoMKp7GNdwPlObhYGB5DQqwhEDQlNKuoqwVYSxkSZCSbHjnFFmUEtwSKRPU4kNK8PbDYYitwaE3QA==", "dev": true, "dependencies": { "data-uri-to-buffer": "^4.0.0", @@ -1634,12 +1631,12 @@ "dev": true }, "node_modules/magic-string": { - "version": "0.26.7", - "resolved": "https://registry.npmjs.org/magic-string/-/magic-string-0.26.7.tgz", - "integrity": "sha512-hX9XH3ziStPoPhJxLq1syWuZMxbDvGNbVchfrdCtanC7D13888bMFow61x8axrx+GfHLtVeAx2kxL7tTGRl+Ow==", + "version": "0.27.0", + "resolved": "https://registry.npmjs.org/magic-string/-/magic-string-0.27.0.tgz", + "integrity": "sha512-8UnnX2PeRAPZuN12svgR9j7M1uWMovg/CEnIwIG0LFkXSJJe4PdfUGiTGl8V9bsBHFUtfVINcSyYxd7q+kx9fA==", "dev": true, "dependencies": { - "sourcemap-codec": "^1.4.8" + "@jridgewell/sourcemap-codec": "^1.4.13" }, "engines": { "node": ">=12" @@ -1709,16 +1706,16 @@ "dev": true }, "node_modules/no-bro-cote": { - "version": "0.2.6", - "resolved": "https://registry.npmjs.org/no-bro-cote/-/no-bro-cote-0.2.6.tgz", - "integrity": "sha512-EG7CzfpRTga+cVhJB2g96y/i/S4284VWXM0Sd43vROW30aKunFQ1nhwK9A/dK70A/mRKMIhudfyaCHqrQohctg==", + "version": "0.2.7", + "resolved": "https://registry.npmjs.org/no-bro-cote/-/no-bro-cote-0.2.7.tgz", + "integrity": "sha512-0uTBw2ijod5JAg3Vjd9suDMEFE6oIQ1cR+5fBodb2V+73BXZLNTRvaKtSx9ZL67tuDTq/0DWhryii55dNR6ZWw==", "dev": true, "dependencies": { "colorette": "^2.0.19", - "import-manager": "^0.1.3", + "import-manager": "^0.1.5", "picomatch": "^2.3.1", "promise-abortable": "^1.2.6", - "puppeteer": "^19.2.2", + "puppeteer": "^19.4.0", "url-exist": "^3.0.1", "yargs": "^17.6.2" }, @@ -1996,32 +1993,32 @@ } }, "node_modules/puppeteer": { - "version": "19.2.2", - "resolved": "https://registry.npmjs.org/puppeteer/-/puppeteer-19.2.2.tgz", - "integrity": "sha512-m1T5Mog5qu5+dMBptWYTn6pXRdnFbydbVUCthqwbfd8/kOiMlzZBR9ywjX79LpvI1Sj+/z8+FKeIsjnMul8ZYA==", + "version": "19.4.0", + "resolved": "https://registry.npmjs.org/puppeteer/-/puppeteer-19.4.0.tgz", + "integrity": "sha512-sRzWEfFSZCCcFUJflGtYI2V7A6qK4Jht+2JiI2LZgn+Nv/LOZZsBDEaGl98ZrS8oEcUA5on4p2yJbE0nzHNzIg==", "dev": true, "hasInstallScript": true, "dependencies": { - "cosmiconfig": "7.0.1", - "devtools-protocol": "0.0.1056733", + "cosmiconfig": "8.0.0", + "devtools-protocol": "0.0.1068969", "https-proxy-agent": "5.0.1", "progress": "2.0.3", "proxy-from-env": "1.1.0", - "puppeteer-core": "19.2.2" + "puppeteer-core": "19.4.0" }, "engines": { "node": ">=14.1.0" } }, "node_modules/puppeteer-core": { - "version": "19.2.2", - "resolved": "https://registry.npmjs.org/puppeteer-core/-/puppeteer-core-19.2.2.tgz", - "integrity": "sha512-faojf+1pZ/tHXSr4x1q+9MVd9FrL3rpdbC0w7qN7MNClMoLuCvMbpR4vzcjoiJYgclt1n+SOPUOmHQViTw6frw==", + "version": "19.4.0", + "resolved": "https://registry.npmjs.org/puppeteer-core/-/puppeteer-core-19.4.0.tgz", + "integrity": "sha512-gG/jxseleZStinBn86x8r7trjcE4jcjx1hIQWOpACQhquHYMuKnrWxkzg+EDn8sN3wUtF/Ry9mtJgjM49oUOFQ==", "dev": true, "dependencies": { "cross-fetch": "3.1.5", "debug": "4.3.4", - "devtools-protocol": "0.0.1056733", + "devtools-protocol": "0.0.1068969", "extract-zip": "2.0.1", "https-proxy-agent": "5.0.1", "proxy-from-env": "1.1.0", @@ -2145,9 +2142,9 @@ } }, "node_modules/rollup": { - "version": "3.2.5", - "resolved": "https://registry.npmjs.org/rollup/-/rollup-3.2.5.tgz", - "integrity": "sha512-/Ha7HhVVofduy+RKWOQJrxe4Qb3xyZo+chcpYiD8SoQa4AG7llhupUtyfKSSrdBM2mWJjhM8wZwmbY23NmlIYw==", + "version": "3.7.1", + "resolved": "https://registry.npmjs.org/rollup/-/rollup-3.7.1.tgz", + "integrity": "sha512-ek6+FORvI79VQTNlIYtXpIrGEPRlYSNZO+5EcmaozKkRL5L6KLvGDUbM5E+bd6jnHW9fgcK0DKTdWjIsEmNb4g==", "dev": true, "bin": { "rollup": "dist/bin/rollup" @@ -2255,12 +2252,6 @@ "source-map": "^0.6.0" } }, - "node_modules/sourcemap-codec": { - "version": "1.4.8", - "resolved": "https://registry.npmjs.org/sourcemap-codec/-/sourcemap-codec-1.4.8.tgz", - "integrity": "sha512-9NykojV5Uih4lgo5So5dtw+f0JgJX30KCNI8gwhz2J9A15wD0Ml6tjHKwf6fTSa6fAdVBdZeNOs9eJ71qCk8vA==", - "dev": true - }, "node_modules/string_decoder": { "version": "1.3.0", "resolved": "https://registry.npmjs.org/string_decoder/-/string_decoder-1.3.0.tgz", @@ -2369,9 +2360,9 @@ } }, "node_modules/terser": { - "version": "5.15.1", - "resolved": "https://registry.npmjs.org/terser/-/terser-5.15.1.tgz", - "integrity": "sha512-K1faMUvpm/FBxjBXud0LWVAGxmvoPbZbfTCYbSgaaYQaIXI3/TdI7a7ZGA73Zrou6Q8Zmz3oeUTsp/dj+ag2Xw==", + "version": "5.16.1", + "resolved": "https://registry.npmjs.org/terser/-/terser-5.16.1.tgz", + "integrity": "sha512-xvQfyfA1ayT0qdK47zskQgRZeWLoOQ8JQ6mIgRGVNwZKdQMU+5FkCBjmv4QjcrTzyZquRw2FVtlJSRUmMKQslw==", "dev": true, "dependencies": { "@jridgewell/source-map": "^0.3.2", @@ -2599,15 +2590,6 @@ "node": ">=10" } }, - "node_modules/yaml": { - "version": "1.10.2", - "resolved": "https://registry.npmjs.org/yaml/-/yaml-1.10.2.tgz", - "integrity": "sha512-r3vXyErRCYJ7wg28yvBY5VSoAF8ZvlcW9/BwUzEtUsjvX/DKs24dIkuwjtuprwJJHsbyUbLApepYTR1BN4uHrg==", - "dev": true, - "engines": { - "node": ">= 6" - } - }, "node_modules/yargs": { "version": "17.6.2", "resolved": "https://registry.npmjs.org/yargs/-/yargs-17.6.2.tgz", @@ -2657,1929 +2639,5 @@ "url": "https://github.com/sponsors/sindresorhus" } } - }, - "dependencies": { - "@babel/code-frame": { - "version": "7.18.6", - "resolved": "https://registry.npmjs.org/@babel/code-frame/-/code-frame-7.18.6.tgz", - "integrity": "sha512-TDCmlK5eOvH+eH7cdAFlNXeVJqWIQ7gW9tY1GJIpUtFb6CmjVyq2VM3u71bOyR8CRihcCgMUYoDNyLXao3+70Q==", - "dev": true, - "requires": { - "@babel/highlight": "^7.18.6" - } - }, - "@babel/helper-validator-identifier": { - "version": "7.19.1", - "resolved": "https://registry.npmjs.org/@babel/helper-validator-identifier/-/helper-validator-identifier-7.19.1.tgz", - "integrity": "sha512-awrNfaMtnHUr653GgGEs++LlAvW6w+DcPrOliSMXWCKo597CwL5Acf/wWdNkf/tfEQE3mjkeD1YOVZOUV/od1w==", - "dev": true - }, - "@babel/highlight": { - "version": "7.18.6", - "resolved": "https://registry.npmjs.org/@babel/highlight/-/highlight-7.18.6.tgz", - "integrity": "sha512-u7stbOuYjaPezCuLj29hNW1v64M2Md2qupEKP1fHc7WdOA3DgLh37suiSrZYY7haUB7iBeQZ9P1uiRF359do3g==", - "dev": true, - "requires": { - "@babel/helper-validator-identifier": "^7.18.6", - "chalk": "^2.0.0", - "js-tokens": "^4.0.0" - }, - "dependencies": { - "ansi-styles": { - "version": "3.2.1", - "resolved": "https://registry.npmjs.org/ansi-styles/-/ansi-styles-3.2.1.tgz", - "integrity": "sha512-VT0ZI6kZRdTh8YyJw3SMbYm/u+NqfsAxEpWO0Pf9sq8/e94WxxOpPKx9FR1FlyCtOVDNOQ+8ntlqFxiRc+r5qA==", - "dev": true, - "requires": { - "color-convert": "^1.9.0" - } - }, - "chalk": { - "version": "2.4.2", - "resolved": "https://registry.npmjs.org/chalk/-/chalk-2.4.2.tgz", - "integrity": "sha512-Mti+f9lpJNcwF4tWV8/OrTTtF1gZi+f8FqlyAdouralcFWFQWF2+NgCHShjkCb+IFBLq9buZwE1xckQU4peSuQ==", - "dev": true, - "requires": { - "ansi-styles": "^3.2.1", - "escape-string-regexp": "^1.0.5", - "supports-color": "^5.3.0" - } - }, - "color-convert": { - "version": "1.9.3", - "resolved": "https://registry.npmjs.org/color-convert/-/color-convert-1.9.3.tgz", - "integrity": "sha512-QfAUtd+vFdAtFQcC8CCyYt1fYWxSqAiK2cSD6zDB8N3cpsEBAvRxp9zOGg6G/SHHJYAT88/az/IuDGALsNVbGg==", - "dev": true, - "requires": { - "color-name": "1.1.3" - } - }, - "color-name": { - "version": "1.1.3", - "resolved": "https://registry.npmjs.org/color-name/-/color-name-1.1.3.tgz", - "integrity": "sha512-72fSenhMw2HZMTVHeCA9KCmpEIbzWiQsjN+BHcBbS9vr1mtt+vJjPdksIBNUmKAW8TFUDPJK5SUU3QhE9NEXDw==", - "dev": true - }, - "escape-string-regexp": { - "version": "1.0.5", - "resolved": "https://registry.npmjs.org/escape-string-regexp/-/escape-string-regexp-1.0.5.tgz", - "integrity": "sha512-vbRorB5FUQWvla16U8R/qgaFIya2qGzwDrNmCZuYKrbdSUMG6I1ZCGQRefkRVhuOkIGVne7BQ35DSfo1qvJqFg==", - "dev": true - }, - "has-flag": { - "version": "3.0.0", - "resolved": "https://registry.npmjs.org/has-flag/-/has-flag-3.0.0.tgz", - "integrity": "sha512-sKJf1+ceQBr4SMkvQnBDNDtf4TXpVhVGateu0t918bl30FnbE2m4vNLX+VWe/dpjlb+HugGYzW7uQXH98HPEYw==", - "dev": true - }, - "supports-color": { - "version": "5.5.0", - "resolved": "https://registry.npmjs.org/supports-color/-/supports-color-5.5.0.tgz", - "integrity": "sha512-QjVjwdXIt408MIiAqCX4oUKsgU2EqAGzs2Ppkm4aQYbjm+ZEWEcW4SfFNTr4uMNZma0ey4f5lgLrkB0aX0QMow==", - "dev": true, - "requires": { - "has-flag": "^3.0.0" - } - } - } - }, - "@eslint/eslintrc": { - "version": "1.3.3", - "resolved": "https://registry.npmjs.org/@eslint/eslintrc/-/eslintrc-1.3.3.tgz", - "integrity": "sha512-uj3pT6Mg+3t39fvLrj8iuCIJ38zKO9FpGtJ4BBJebJhEwjoT+KLVNCcHT5QC9NGRIEi7fZ0ZR8YRb884auB4Lg==", - "dev": true, - "requires": { - "ajv": "^6.12.4", - "debug": "^4.3.2", - "espree": "^9.4.0", - "globals": "^13.15.0", - "ignore": "^5.2.0", - "import-fresh": "^3.2.1", - "js-yaml": "^4.1.0", - "minimatch": "^3.1.2", - "strip-json-comments": "^3.1.1" - } - }, - "@humanwhocodes/config-array": { - "version": "0.11.7", - "resolved": "https://registry.npmjs.org/@humanwhocodes/config-array/-/config-array-0.11.7.tgz", - "integrity": "sha512-kBbPWzN8oVMLb0hOUYXhmxggL/1cJE6ydvjDIGi9EnAGUyA7cLVKQg+d/Dsm+KZwx2czGHrCmMVLiyg8s5JPKw==", - "dev": true, - "requires": { - "@humanwhocodes/object-schema": "^1.2.1", - "debug": "^4.1.1", - "minimatch": "^3.0.5" - } - }, - "@humanwhocodes/module-importer": { - "version": "1.0.1", - "resolved": "https://registry.npmjs.org/@humanwhocodes/module-importer/-/module-importer-1.0.1.tgz", - "integrity": "sha512-bxveV4V8v5Yb4ncFTT3rPSgZBOpCkjfK0y4oVVVJwIuDVBRMDXrPyXRL988i5ap9m9bnyEEjWfm5WkBmtffLfA==", - "dev": true - }, - "@humanwhocodes/object-schema": { - "version": "1.2.1", - "resolved": "https://registry.npmjs.org/@humanwhocodes/object-schema/-/object-schema-1.2.1.tgz", - "integrity": "sha512-ZnQMnLV4e7hDlUvw8H+U8ASL02SS2Gn6+9Ac3wGGLIe7+je2AeAOxPY+izIPJDfFDb7eDjev0Us8MO1iFRN8hA==", - "dev": true - }, - "@jridgewell/gen-mapping": { - "version": "0.3.2", - "resolved": "https://registry.npmjs.org/@jridgewell/gen-mapping/-/gen-mapping-0.3.2.tgz", - "integrity": "sha512-mh65xKQAzI6iBcFzwv28KVWSmCkdRBWoOh+bYQGW3+6OZvbbN3TqMGo5hqYxQniRcH9F2VZIoJCm4pa3BPDK/A==", - "dev": true, - "requires": { - "@jridgewell/set-array": "^1.0.1", - "@jridgewell/sourcemap-codec": "^1.4.10", - "@jridgewell/trace-mapping": "^0.3.9" - } - }, - "@jridgewell/resolve-uri": { - "version": "3.1.0", - "resolved": "https://registry.npmjs.org/@jridgewell/resolve-uri/-/resolve-uri-3.1.0.tgz", - "integrity": "sha512-F2msla3tad+Mfht5cJq7LSXcdudKTWCVYUgw6pLFOOHSTtZlj6SWNYAp+AhuqLmWdBO2X5hPrLcu8cVP8fy28w==", - "dev": true - }, - "@jridgewell/set-array": { - "version": "1.1.2", - "resolved": "https://registry.npmjs.org/@jridgewell/set-array/-/set-array-1.1.2.tgz", - "integrity": "sha512-xnkseuNADM0gt2bs+BvhO0p78Mk762YnZdsuzFV018NoG1Sj1SCQvpSqa7XUaTam5vAGasABV9qXASMKnFMwMw==", - "dev": true - }, - "@jridgewell/source-map": { - "version": "0.3.2", - "resolved": "https://registry.npmjs.org/@jridgewell/source-map/-/source-map-0.3.2.tgz", - "integrity": "sha512-m7O9o2uR8k2ObDysZYzdfhb08VuEml5oWGiosa1VdaPZ/A6QyPkAJuwN0Q1lhULOf6B7MtQmHENS743hWtCrgw==", - "dev": true, - "requires": { - "@jridgewell/gen-mapping": "^0.3.0", - "@jridgewell/trace-mapping": "^0.3.9" - } - }, - "@jridgewell/sourcemap-codec": { - "version": "1.4.14", - "resolved": "https://registry.npmjs.org/@jridgewell/sourcemap-codec/-/sourcemap-codec-1.4.14.tgz", - "integrity": "sha512-XPSJHWmi394fuUuzDnGz1wiKqWfo1yXecHQMRf2l6hztTO+nPru658AyDngaBe7isIxEkRsPR3FZh+s7iVa4Uw==", - "dev": true - }, - "@jridgewell/trace-mapping": { - "version": "0.3.17", - "resolved": "https://registry.npmjs.org/@jridgewell/trace-mapping/-/trace-mapping-0.3.17.tgz", - "integrity": "sha512-MCNzAp77qzKca9+W/+I0+sEpaUnZoeasnghNeVc41VZCEKaCH73Vq3BZZ/SzWIgrqE4H4ceI+p+b6C0mHf9T4g==", - "dev": true, - "requires": { - "@jridgewell/resolve-uri": "3.1.0", - "@jridgewell/sourcemap-codec": "1.4.14" - } - }, - "@nodelib/fs.scandir": { - "version": "2.1.5", - "resolved": "https://registry.npmjs.org/@nodelib/fs.scandir/-/fs.scandir-2.1.5.tgz", - "integrity": "sha512-vq24Bq3ym5HEQm2NKCr3yXDwjc7vTsEThRDnkp2DK9p1uqLR+DHurm/NOTo0KG7HYHU7eppKZj3MyqYuMBf62g==", - "dev": true, - "requires": { - "@nodelib/fs.stat": "2.0.5", - "run-parallel": "^1.1.9" - } - }, - "@nodelib/fs.stat": { - "version": "2.0.5", - "resolved": "https://registry.npmjs.org/@nodelib/fs.stat/-/fs.stat-2.0.5.tgz", - "integrity": "sha512-RkhPPp2zrqDAQA/2jNhnztcPAlv64XdhIp7a7454A5ovI7Bukxgt7MX7udwAu3zg1DcpPU0rz3VV1SeaqvY4+A==", - "dev": true - }, - "@nodelib/fs.walk": { - "version": "1.2.8", - "resolved": "https://registry.npmjs.org/@nodelib/fs.walk/-/fs.walk-1.2.8.tgz", - "integrity": "sha512-oGB+UxlgWcgQkgwo8GcEGwemoTFt3FIO9ababBmaGwXIoBKZ+GTy0pP185beGg7Llih/NSHSV2XAs1lnznocSg==", - "dev": true, - "requires": { - "@nodelib/fs.scandir": "2.1.5", - "fastq": "^1.6.0" - } - }, - "@rollup/plugin-terser": { - "version": "0.1.0", - "resolved": "https://registry.npmjs.org/@rollup/plugin-terser/-/plugin-terser-0.1.0.tgz", - "integrity": "sha512-N2KK+qUfHX2hBzVzM41UWGLrEmcjVC37spC8R3c9mt3oEDFKh3N2e12/lLp9aVSt86veR0TQiCNQXrm8C6aiUQ==", - "dev": true, - "requires": { - "terser": "^5.15.1" - } - }, - "@types/node": { - "version": "18.11.9", - "resolved": "https://registry.npmjs.org/@types/node/-/node-18.11.9.tgz", - "integrity": "sha512-CRpX21/kGdzjOpFsZSkcrXMGIBWMGNIHXXBVFSH+ggkftxg+XYP20TESbh+zFvFj3EQOl5byk0HTRn1IL6hbqg==", - "dev": true, - "optional": true - }, - "@types/parse-json": { - "version": "4.0.0", - "resolved": "https://registry.npmjs.org/@types/parse-json/-/parse-json-4.0.0.tgz", - "integrity": "sha512-//oorEZjL6sbPcKUaCdIGlIUeH26mgzimjBB77G6XRgnDl/L5wOnpyBGRe/Mmf5CVW3PwEBE1NjiMZ/ssFh4wA==", - "dev": true - }, - "@types/yauzl": { - "version": "2.10.0", - "resolved": "https://registry.npmjs.org/@types/yauzl/-/yauzl-2.10.0.tgz", - "integrity": "sha512-Cn6WYCm0tXv8p6k+A8PvbDG763EDpBoTzHdA+Q/MF6H3sapGjCm9NzoaJncJS9tUKSuCoDs9XHxYYsQDgxR6kw==", - "dev": true, - "optional": true, - "requires": { - "@types/node": "*" - } - }, - "abort-controller": { - "version": "3.0.0", - "resolved": "https://registry.npmjs.org/abort-controller/-/abort-controller-3.0.0.tgz", - "integrity": "sha512-h8lQ8tacZYnR3vNQTgibj+tODHI5/+l06Au2Pcriv/Gmet0eaj4TwWH41sO9wnHDiQsEj19q0drzdWdeAHtweg==", - "dev": true, - "requires": { - "event-target-shim": "^5.0.0" - } - }, - "acorn": { - "version": "8.8.1", - "resolved": "https://registry.npmjs.org/acorn/-/acorn-8.8.1.tgz", - "integrity": "sha512-7zFpHzhnqYKrkYdUjF1HI1bzd0VygEGX8lFk4k5zVMqHEoES+P+7TKI+EvLO9WVMJ8eekdO0aDEK044xTXwPPA==", - "dev": true - }, - "acorn-jsx": { - "version": "5.3.2", - "resolved": "https://registry.npmjs.org/acorn-jsx/-/acorn-jsx-5.3.2.tgz", - "integrity": "sha512-rq9s+JNhf0IChjtDXxllJ7g41oZk5SlXtp0LHwyA5cejwn7vKmKp4pPri6YEePv2PU65sAsegbXtIinmDFDXgQ==", - "dev": true, - "requires": {} - }, - "acorn-walk": { - "version": "8.2.0", - "resolved": "https://registry.npmjs.org/acorn-walk/-/acorn-walk-8.2.0.tgz", - "integrity": "sha512-k+iyHEuPgSw6SbuDpGQM+06HQUa04DZ3o+F6CSzXMvvI5KMvnaEqXe+YVe555R9nn6GPt404fos4wcgpw12SDA==", - "dev": true - }, - "agent-base": { - "version": "6.0.2", - "resolved": "https://registry.npmjs.org/agent-base/-/agent-base-6.0.2.tgz", - "integrity": "sha512-RZNwNclF7+MS/8bDg70amg32dyeZGZxiDuQmZxKLAlQjr3jGyLx+4Kkk58UO7D2QdgFIQCovuSuZESne6RG6XQ==", - "dev": true, - "requires": { - "debug": "4" - } - }, - "ajv": { - "version": "6.12.6", - "resolved": "https://registry.npmjs.org/ajv/-/ajv-6.12.6.tgz", - "integrity": "sha512-j3fVLgvTo527anyYyJOGTYJbG+vnnQYvE0m5mmkc1TK+nxAppkCLMIL0aZ4dblVCNoGShhm+kzE4ZUykBoMg4g==", - "dev": true, - "requires": { - "fast-deep-equal": "^3.1.1", - "fast-json-stable-stringify": "^2.0.0", - "json-schema-traverse": "^0.4.1", - "uri-js": "^4.2.2" - } - }, - "ansi-regex": { - "version": "5.0.1", - "resolved": "https://registry.npmjs.org/ansi-regex/-/ansi-regex-5.0.1.tgz", - "integrity": "sha512-quJQXlTSUGL2LH9SUXo8VwsY4soanhgo6LNSm84E1LBcE8s3O0wpdiRzyR9z/ZZJMlMWv37qOOb9pdJlMUEKFQ==", - "dev": true - }, - "ansi-styles": { - "version": "4.3.0", - "resolved": "https://registry.npmjs.org/ansi-styles/-/ansi-styles-4.3.0.tgz", - "integrity": "sha512-zbB9rCJAT1rbjiVDb2hqKFHNYLxgtk8NURxZ3IZwD3F6NtxbXZQCnnSi1Lkx+IDohdPlFp222wVALIheZJQSEg==", - "dev": true, - "requires": { - "color-convert": "^2.0.1" - } - }, - "argparse": { - "version": "2.0.1", - "resolved": "https://registry.npmjs.org/argparse/-/argparse-2.0.1.tgz", - "integrity": "sha512-8+9WqebbFzpX9OR+Wa6O29asIogeRMzcGtAINdpMHHyAg10f05aSFVBbcEqGf/PXw1EjAZ+q2/bEBg3DvurK3Q==", - "dev": true - }, - "async": { - "version": "2.6.4", - "resolved": "https://registry.npmjs.org/async/-/async-2.6.4.tgz", - "integrity": "sha512-mzo5dfJYwAn29PeiJ0zvwTo04zj8HDJj0Mn8TD7sno7q12prdbnasKJHhkm2c1LgrhlJ0teaea8860oxi51mGA==", - "dev": true, - "requires": { - "lodash": "^4.17.14" - } - }, - "balanced-match": { - "version": "1.0.2", - "resolved": "https://registry.npmjs.org/balanced-match/-/balanced-match-1.0.2.tgz", - "integrity": "sha512-3oSeUO0TMV67hN1AmbXsK4yaqU7tjiHlbxRDZOpH0KW9+CeX4bRAaX0Anxt0tx2MrpRpWwQaPwIlISEJhYU5Pw==", - "dev": true - }, - "base-ex": { - "version": "0.4.3", - "resolved": "https://registry.npmjs.org/base-ex/-/base-ex-0.4.3.tgz", - "integrity": "sha512-yj+1wOjny1dfr0AEsp8+O6i1iAxUzpCe6fvwSGtHRK7z6giJPLfXPsxHnybvkd92EX9Fkq64ku3jhiO/MTsORw==", - "dev": true - }, - "base64-js": { - "version": "1.5.1", - "resolved": "https://registry.npmjs.org/base64-js/-/base64-js-1.5.1.tgz", - "integrity": "sha512-AKpaYlHn8t4SVbOHCy+b5+KKgvR4vrsD8vbvrbiQJps7fKDTkjkDry6ji0rUJjC0kzbNePLwzxq8iypo41qeWA==", - "dev": true - }, - "basic-auth": { - "version": "2.0.1", - "resolved": "https://registry.npmjs.org/basic-auth/-/basic-auth-2.0.1.tgz", - "integrity": "sha512-NF+epuEdnUYVlGuhaxbbq+dvJttwLnGY+YixlXlME5KpQ5W3CnXA5cVTneY3SPbPDRkcjMbifrwmFYcClgOZeg==", - "dev": true, - "requires": { - "safe-buffer": "5.1.2" - } - }, - "bl": { - "version": "4.1.0", - "resolved": "https://registry.npmjs.org/bl/-/bl-4.1.0.tgz", - "integrity": "sha512-1W07cM9gS6DcLperZfFSj+bWLtaPGSOHWhPiGzXmvVJbRLdG82sH/Kn8EtW1VqWVA54AKf2h5k5BbnIbwF3h6w==", - "dev": true, - "requires": { - "buffer": "^5.5.0", - "inherits": "^2.0.4", - "readable-stream": "^3.4.0" - } - }, - "brace-expansion": { - "version": "1.1.11", - "resolved": "https://registry.npmjs.org/brace-expansion/-/brace-expansion-1.1.11.tgz", - "integrity": "sha512-iCuPHDFgrHX7H2vEI/5xpz07zSHB00TpugqhmYtVmMO6518mCuRMoOYFldEBl0g187ufozdaHgWKcYFb61qGiA==", - "dev": true, - "requires": { - "balanced-match": "^1.0.0", - "concat-map": "0.0.1" - } - }, - "buffer": { - "version": "5.7.1", - "resolved": "https://registry.npmjs.org/buffer/-/buffer-5.7.1.tgz", - "integrity": "sha512-EHcyIPBQ4BSGlvjB16k5KgAJ27CIsHY/2JBmCRReo48y9rQ3MaUzWX3KVlBa4U7MyX02HdVj0K7C3WaB3ju7FQ==", - "dev": true, - "requires": { - "base64-js": "^1.3.1", - "ieee754": "^1.1.13" - } - }, - "buffer-crc32": { - "version": "0.2.13", - "resolved": "https://registry.npmjs.org/buffer-crc32/-/buffer-crc32-0.2.13.tgz", - "integrity": "sha512-VO9Ht/+p3SN7SKWqcrgEzjGbRSJYTx+Q1pTQC0wrWqHx0vpJraQ6GtHx8tvcg1rlK1byhU5gccxgOgj7B0TDkQ==", - "dev": true - }, - "buffer-from": { - "version": "1.1.2", - "resolved": "https://registry.npmjs.org/buffer-from/-/buffer-from-1.1.2.tgz", - "integrity": "sha512-E+XQCRwSbaaiChtv6k6Dwgc+bx+Bs6vuKJHHl5kox/BaKbhiXzqQOwK4cO22yElGp2OCmjwVhT3HmxgyPGnJfQ==", - "dev": true - }, - "call-bind": { - "version": "1.0.2", - "resolved": "https://registry.npmjs.org/call-bind/-/call-bind-1.0.2.tgz", - "integrity": "sha512-7O+FbCihrB5WGbFYesctwmTKae6rOiIzmz1icreWJ+0aA7LJfuqhEso2T9ncpcFtzMQtzXf2QGGueWJGTYsqrA==", - "dev": true, - "requires": { - "function-bind": "^1.1.1", - "get-intrinsic": "^1.0.2" - } - }, - "callsites": { - "version": "3.1.0", - "resolved": "https://registry.npmjs.org/callsites/-/callsites-3.1.0.tgz", - "integrity": "sha512-P8BjAsXvZS+VIDUI11hHCQEv74YT67YUi5JJFNWIqL235sBmjX4+qx9Muvls5ivyNENctx46xQLQ3aTuE7ssaQ==", - "dev": true - }, - "chalk": { - "version": "4.1.2", - "resolved": "https://registry.npmjs.org/chalk/-/chalk-4.1.2.tgz", - "integrity": "sha512-oKnbhFyRIXpUuez8iBMmyEa4nbj4IOQyuhc/wy9kY7/WVPcwIO9VA668Pu8RkO7+0G76SLROeyw9CpQ061i4mA==", - "dev": true, - "requires": { - "ansi-styles": "^4.1.0", - "supports-color": "^7.1.0" - } - }, - "chownr": { - "version": "1.1.4", - "resolved": "https://registry.npmjs.org/chownr/-/chownr-1.1.4.tgz", - "integrity": "sha512-jJ0bqzaylmJtVnNgzTeSOs8DPavpbYgEr/b0YL8/2GO3xJEhInFmhKMUnEJQjZumK7KXGFhUy89PrsJWlakBVg==", - "dev": true - }, - "cliui": { - "version": "8.0.1", - "resolved": "https://registry.npmjs.org/cliui/-/cliui-8.0.1.tgz", - "integrity": "sha512-BSeNnyus75C4//NQ9gQt1/csTXyo/8Sb+afLAkzAptFuMsod9HFokGNudZpi/oQV73hnVK+sR+5PVRMd+Dr7YQ==", - "dev": true, - "requires": { - "string-width": "^4.2.0", - "strip-ansi": "^6.0.1", - "wrap-ansi": "^7.0.0" - } - }, - "color-convert": { - "version": "2.0.1", - "resolved": "https://registry.npmjs.org/color-convert/-/color-convert-2.0.1.tgz", - "integrity": "sha512-RRECPsj7iu/xb5oKYcsFHSppFNnsj/52OVTRKb4zP5onXwVF3zVmmToNcOfGC+CRDpfK/U584fMg38ZHCaElKQ==", - "dev": true, - "requires": { - "color-name": "~1.1.4" - } - }, - "color-name": { - "version": "1.1.4", - "resolved": "https://registry.npmjs.org/color-name/-/color-name-1.1.4.tgz", - "integrity": "sha512-dOy+3AuW3a2wNbZHIuMZpTcgjGuLU/uBL/ubcZF9OXbDo8ff4O8yVp5Bf0efS8uEoYo5q4Fx7dY9OgQGXgAsQA==", - "dev": true - }, - "colorette": { - "version": "2.0.19", - "resolved": "https://registry.npmjs.org/colorette/-/colorette-2.0.19.tgz", - "integrity": "sha512-3tlv/dIP7FWvj3BsbHrGLJ6l/oKh1O3TcgBqMn+yyCagOxc23fyzDS6HypQbgxWbkpDnf52p1LuR4eWDQ/K9WQ==", - "dev": true - }, - "commander": { - "version": "2.20.3", - "resolved": "https://registry.npmjs.org/commander/-/commander-2.20.3.tgz", - "integrity": "sha512-GpVkmM8vF2vQUkj2LvZmD35JxeJOLCwJ9cUkugyk2nuhbv3+mJvpLYYt+0+USMxE+oj+ey/lJEnhZw75x/OMcQ==", - "dev": true - }, - "concat-map": { - "version": "0.0.1", - "resolved": "https://registry.npmjs.org/concat-map/-/concat-map-0.0.1.tgz", - "integrity": "sha512-/Srv4dswyQNBfohGpz9o6Yb3Gz3SrUDqBH5rTuhGR7ahtlbYKnVxw2bCFMRljaA7EXHaXZ8wsHdodFvbkhKmqg==", - "dev": true - }, - "corser": { - "version": "2.0.1", - "resolved": "https://registry.npmjs.org/corser/-/corser-2.0.1.tgz", - "integrity": "sha512-utCYNzRSQIZNPIcGZdQc92UVJYAhtGAteCFg0yRaFm8f0P+CPtyGyHXJcGXnffjCybUCEx3FQ2G7U3/o9eIkVQ==", - "dev": true - }, - "cosmiconfig": { - "version": "7.0.1", - "resolved": "https://registry.npmjs.org/cosmiconfig/-/cosmiconfig-7.0.1.tgz", - "integrity": "sha512-a1YWNUV2HwGimB7dU2s1wUMurNKjpx60HxBB6xUM8Re+2s1g1IIfJvFR0/iCF+XHdE0GMTKTuLR32UQff4TEyQ==", - "dev": true, - "requires": { - "@types/parse-json": "^4.0.0", - "import-fresh": "^3.2.1", - "parse-json": "^5.0.0", - "path-type": "^4.0.0", - "yaml": "^1.10.0" - } - }, - "cross-fetch": { - "version": "3.1.5", - "resolved": "https://registry.npmjs.org/cross-fetch/-/cross-fetch-3.1.5.tgz", - "integrity": "sha512-lvb1SBsI0Z7GDwmuid+mU3kWVBwTVUbe7S0H52yaaAdQOXq2YktTCZdlAcNKFzE6QtRz0snpw9bNiPeOIkkQvw==", - "dev": true, - "requires": { - "node-fetch": "2.6.7" - } - }, - "cross-spawn": { - "version": "7.0.3", - "resolved": "https://registry.npmjs.org/cross-spawn/-/cross-spawn-7.0.3.tgz", - "integrity": "sha512-iRDPJKUPVEND7dHPO8rkbOnPpyDygcDFtWjpeWNCgy8WP2rXcxXL8TskReQl6OrB2G7+UJrags1q15Fudc7G6w==", - "dev": true, - "requires": { - "path-key": "^3.1.0", - "shebang-command": "^2.0.0", - "which": "^2.0.1" - } - }, - "data-uri-to-buffer": { - "version": "4.0.0", - "resolved": "https://registry.npmjs.org/data-uri-to-buffer/-/data-uri-to-buffer-4.0.0.tgz", - "integrity": "sha512-Vr3mLBA8qWmcuschSLAOogKgQ/Jwxulv3RNE4FXnYWRGujzrRWQI4m12fQqRkwX06C0KanhLr4hK+GydchZsaA==", - "dev": true - }, - "debug": { - "version": "4.3.4", - "resolved": "https://registry.npmjs.org/debug/-/debug-4.3.4.tgz", - "integrity": "sha512-PRWFHuSU3eDtQJPvnNY7Jcket1j0t5OuOsFzPPzsekD52Zl8qUfFIPEiswXqIvHWGVHOgX+7G/vCNNhehwxfkQ==", - "dev": true, - "requires": { - "ms": "2.1.2" - } - }, - "deep-is": { - "version": "0.1.4", - "resolved": "https://registry.npmjs.org/deep-is/-/deep-is-0.1.4.tgz", - "integrity": "sha512-oIPzksmTg4/MriiaYGO+okXDT7ztn/w3Eptv/+gSIdMdKsJo0u4CfYNFJPy+4SKMuCqGw2wxnA+URMg3t8a/bQ==", - "dev": true - }, - "devtools-protocol": { - "version": "0.0.1056733", - "resolved": "https://registry.npmjs.org/devtools-protocol/-/devtools-protocol-0.0.1056733.tgz", - "integrity": "sha512-CmTu6SQx2g3TbZzDCAV58+LTxVdKplS7xip0g5oDXpZ+isr0rv5dDP8ToyVRywzPHkCCPKgKgScEcwz4uPWDIA==", - "dev": true - }, - "doctrine": { - "version": "3.0.0", - "resolved": "https://registry.npmjs.org/doctrine/-/doctrine-3.0.0.tgz", - "integrity": "sha512-yS+Q5i3hBf7GBkd4KG8a7eBNNWNGLTaEwwYWUijIYM7zrlYDM0BFXHjjPWlWZ1Rg7UaddZeIDmi9jF3HmqiQ2w==", - "dev": true, - "requires": { - "esutils": "^2.0.2" - } - }, - "emoji-regex": { - "version": "8.0.0", - "resolved": "https://registry.npmjs.org/emoji-regex/-/emoji-regex-8.0.0.tgz", - "integrity": "sha512-MSjYzcWNOA0ewAHpz0MxpYFvwg6yjy1NG3xteoqz644VCo/RPgnr1/GGt+ic3iJTzQ8Eu3TdM14SawnVUmGE6A==", - "dev": true - }, - "end-of-stream": { - "version": "1.4.4", - "resolved": "https://registry.npmjs.org/end-of-stream/-/end-of-stream-1.4.4.tgz", - "integrity": "sha512-+uw1inIHVPQoaVuHzRyXd21icM+cnt4CzD5rW+NC1wjOUSTOs+Te7FOv7AhN7vS9x/oIyhLP5PR1H+phQAHu5Q==", - "dev": true, - "requires": { - "once": "^1.4.0" - } - }, - "error-ex": { - "version": "1.3.2", - "resolved": "https://registry.npmjs.org/error-ex/-/error-ex-1.3.2.tgz", - "integrity": "sha512-7dFHNmqeFSEt2ZBsCriorKnn3Z2pj+fd9kmI6QoWw4//DL+icEBfc0U7qJCisqrTsKTjw4fNFy2pW9OqStD84g==", - "dev": true, - "requires": { - "is-arrayish": "^0.2.1" - } - }, - "escalade": { - "version": "3.1.1", - "resolved": "https://registry.npmjs.org/escalade/-/escalade-3.1.1.tgz", - "integrity": "sha512-k0er2gUkLf8O0zKJiAhmkTnJlTvINGv7ygDNPbeIsX/TJjGJZHuh9B2UxbsaEkmlEo9MfhrSzmhIlhRlI2GXnw==", - "dev": true - }, - "escape-string-regexp": { - "version": "4.0.0", - "resolved": "https://registry.npmjs.org/escape-string-regexp/-/escape-string-regexp-4.0.0.tgz", - "integrity": "sha512-TtpcNJ3XAzx3Gq8sWRzJaVajRs0uVxA2YAkdb1jm2YkPz4G6egUFAyA3n5vtEIZefPk5Wa4UXbKuS5fKkJWdgA==", - "dev": true - }, - "eslint": { - "version": "8.27.0", - "resolved": "https://registry.npmjs.org/eslint/-/eslint-8.27.0.tgz", - "integrity": "sha512-0y1bfG2ho7mty+SiILVf9PfuRA49ek4Nc60Wmmu62QlobNR+CeXa4xXIJgcuwSQgZiWaPH+5BDsctpIW0PR/wQ==", - "dev": true, - "requires": { - "@eslint/eslintrc": "^1.3.3", - "@humanwhocodes/config-array": "^0.11.6", - "@humanwhocodes/module-importer": "^1.0.1", - "@nodelib/fs.walk": "^1.2.8", - "ajv": "^6.10.0", - "chalk": "^4.0.0", - "cross-spawn": "^7.0.2", - "debug": "^4.3.2", - "doctrine": "^3.0.0", - "escape-string-regexp": "^4.0.0", - "eslint-scope": "^7.1.1", - "eslint-utils": "^3.0.0", - "eslint-visitor-keys": "^3.3.0", - "espree": "^9.4.0", - "esquery": "^1.4.0", - "esutils": "^2.0.2", - "fast-deep-equal": "^3.1.3", - "file-entry-cache": "^6.0.1", - "find-up": "^5.0.0", - "glob-parent": "^6.0.2", - "globals": "^13.15.0", - "grapheme-splitter": "^1.0.4", - "ignore": "^5.2.0", - "import-fresh": "^3.0.0", - "imurmurhash": "^0.1.4", - "is-glob": "^4.0.0", - "is-path-inside": "^3.0.3", - "js-sdsl": "^4.1.4", - "js-yaml": "^4.1.0", - "json-stable-stringify-without-jsonify": "^1.0.1", - "levn": "^0.4.1", - "lodash.merge": "^4.6.2", - "minimatch": "^3.1.2", - "natural-compare": "^1.4.0", - "optionator": "^0.9.1", - "regexpp": "^3.2.0", - "strip-ansi": "^6.0.1", - "strip-json-comments": "^3.1.0", - "text-table": "^0.2.0" - } - }, - "eslint-scope": { - "version": "7.1.1", - "resolved": "https://registry.npmjs.org/eslint-scope/-/eslint-scope-7.1.1.tgz", - "integrity": "sha512-QKQM/UXpIiHcLqJ5AOyIW7XZmzjkzQXYE54n1++wb0u9V/abW3l9uQnxX8Z5Xd18xyKIMTUAyQ0k1e8pz6LUrw==", - "dev": true, - "requires": { - "esrecurse": "^4.3.0", - "estraverse": "^5.2.0" - } - }, - "eslint-utils": { - "version": "3.0.0", - "resolved": "https://registry.npmjs.org/eslint-utils/-/eslint-utils-3.0.0.tgz", - "integrity": "sha512-uuQC43IGctw68pJA1RgbQS8/NP7rch6Cwd4j3ZBtgo4/8Flj4eGE7ZYSZRN3iq5pVUv6GPdW5Z1RFleo84uLDA==", - "dev": true, - "requires": { - "eslint-visitor-keys": "^2.0.0" - }, - "dependencies": { - "eslint-visitor-keys": { - "version": "2.1.0", - "resolved": "https://registry.npmjs.org/eslint-visitor-keys/-/eslint-visitor-keys-2.1.0.tgz", - "integrity": "sha512-0rSmRBzXgDzIsD6mGdJgevzgezI534Cer5L/vyMX0kHzT/jiB43jRhd9YUlMGYLQy2zprNmoT8qasCGtY+QaKw==", - "dev": true - } - } - }, - "eslint-visitor-keys": { - "version": "3.3.0", - "resolved": "https://registry.npmjs.org/eslint-visitor-keys/-/eslint-visitor-keys-3.3.0.tgz", - "integrity": "sha512-mQ+suqKJVyeuwGYHAdjMFqjCyfl8+Ldnxuyp3ldiMBFKkvytrXUZWaiPCEav8qDHKty44bD+qV1IP4T+w+xXRA==", - "dev": true - }, - "espree": { - "version": "9.4.1", - "resolved": "https://registry.npmjs.org/espree/-/espree-9.4.1.tgz", - "integrity": "sha512-XwctdmTO6SIvCzd9810yyNzIrOrqNYV9Koizx4C/mRhf9uq0o4yHoCEU/670pOxOL/MSraektvSAji79kX90Vg==", - "dev": true, - "requires": { - "acorn": "^8.8.0", - "acorn-jsx": "^5.3.2", - "eslint-visitor-keys": "^3.3.0" - } - }, - "esquery": { - "version": "1.4.0", - "resolved": "https://registry.npmjs.org/esquery/-/esquery-1.4.0.tgz", - "integrity": "sha512-cCDispWt5vHHtwMY2YrAQ4ibFkAL8RbH5YGBnZBc90MolvvfkkQcJro/aZiAQUlQ3qgrYS6D6v8Gc5G5CQsc9w==", - "dev": true, - "requires": { - "estraverse": "^5.1.0" - } - }, - "esrecurse": { - "version": "4.3.0", - "resolved": "https://registry.npmjs.org/esrecurse/-/esrecurse-4.3.0.tgz", - "integrity": "sha512-KmfKL3b6G+RXvP8N1vr3Tq1kL/oCFgn2NYXEtqP8/L3pKapUA4G8cFVaoF3SU323CD4XypR/ffioHmkti6/Tag==", - "dev": true, - "requires": { - "estraverse": "^5.2.0" - } - }, - "estraverse": { - "version": "5.3.0", - "resolved": "https://registry.npmjs.org/estraverse/-/estraverse-5.3.0.tgz", - "integrity": "sha512-MMdARuVEQziNTeJD8DgMqmhwR11BRQ/cBP+pLtYdSTnf3MIO8fFeiINEbX36ZdNlfU/7A9f3gUw49B3oQsvwBA==", - "dev": true - }, - "esutils": { - "version": "2.0.3", - "resolved": "https://registry.npmjs.org/esutils/-/esutils-2.0.3.tgz", - "integrity": "sha512-kVscqXk4OCp68SZ0dkgEKVi6/8ij300KBWTJq32P/dYeWTSwK41WyTxalN1eRmA5Z9UU/LX9D7FWSmV9SAYx6g==", - "dev": true - }, - "event-target-shim": { - "version": "5.0.1", - "resolved": "https://registry.npmjs.org/event-target-shim/-/event-target-shim-5.0.1.tgz", - "integrity": "sha512-i/2XbnSz/uxRCU6+NdVJgKWDTM427+MqYbkQzD321DuCQJUqOuJKIA0IM2+W2xtYHdKOmZ4dR6fExsd4SXL+WQ==", - "dev": true - }, - "eventemitter3": { - "version": "4.0.7", - "resolved": "https://registry.npmjs.org/eventemitter3/-/eventemitter3-4.0.7.tgz", - "integrity": "sha512-8guHBZCwKnFhYdHr2ysuRWErTwhoN2X8XELRlrRwpmfeY2jjuUN4taQMsULKUVo1K4DvZl+0pgfyoysHxvmvEw==", - "dev": true - }, - "extract-zip": { - "version": "2.0.1", - "resolved": "https://registry.npmjs.org/extract-zip/-/extract-zip-2.0.1.tgz", - "integrity": "sha512-GDhU9ntwuKyGXdZBUgTIe+vXnWj0fppUEtMDL0+idd5Sta8TGpHssn/eusA9mrPr9qNDym6SxAYZjNvCn/9RBg==", - "dev": true, - "requires": { - "@types/yauzl": "^2.9.1", - "debug": "^4.1.1", - "get-stream": "^5.1.0", - "yauzl": "^2.10.0" - } - }, - "fast-deep-equal": { - "version": "3.1.3", - "resolved": "https://registry.npmjs.org/fast-deep-equal/-/fast-deep-equal-3.1.3.tgz", - "integrity": "sha512-f3qQ9oQy9j2AhBe/H9VC91wLmKBCCU/gDOnKNAYG5hswO7BLKj09Hc5HYNz9cGI++xlpDCIgDaitVs03ATR84Q==", - "dev": true - }, - "fast-json-stable-stringify": { - "version": "2.1.0", - "resolved": "https://registry.npmjs.org/fast-json-stable-stringify/-/fast-json-stable-stringify-2.1.0.tgz", - "integrity": "sha512-lhd/wF+Lk98HZoTCtlVraHtfh5XYijIjalXck7saUtuanSDyLMxnHhSXEDJqHxD7msR8D0uCmqlkwjCV8xvwHw==", - "dev": true - }, - "fast-levenshtein": { - "version": "2.0.6", - "resolved": "https://registry.npmjs.org/fast-levenshtein/-/fast-levenshtein-2.0.6.tgz", - "integrity": "sha512-DCXu6Ifhqcks7TZKY3Hxp3y6qphY5SJZmrWMDrKcERSOXWQdMhU9Ig/PYrzyw/ul9jOIyh0N4M0tbC5hodg8dw==", - "dev": true - }, - "fastq": { - "version": "1.13.0", - "resolved": "https://registry.npmjs.org/fastq/-/fastq-1.13.0.tgz", - "integrity": "sha512-YpkpUnK8od0o1hmeSc7UUs/eB/vIPWJYjKck2QKIzAf71Vm1AAQ3EbuZB3g2JIy+pg+ERD0vqI79KyZiB2e2Nw==", - "dev": true, - "requires": { - "reusify": "^1.0.4" - } - }, - "fd-slicer": { - "version": "1.1.0", - "resolved": "https://registry.npmjs.org/fd-slicer/-/fd-slicer-1.1.0.tgz", - "integrity": "sha512-cE1qsB/VwyQozZ+q1dGxR8LBYNZeofhEdUNGSMbQD3Gw2lAzX9Zb3uIU6Ebc/Fmyjo9AWWfnn0AUCHqtevs/8g==", - "dev": true, - "requires": { - "pend": "~1.2.0" - } - }, - "fetch-blob": { - "version": "3.2.0", - "resolved": "https://registry.npmjs.org/fetch-blob/-/fetch-blob-3.2.0.tgz", - "integrity": "sha512-7yAQpD2UMJzLi1Dqv7qFYnPbaPx7ZfFK6PiIxQ4PfkGPyNyl2Ugx+a/umUonmKqjhM4DnfbMvdX6otXq83soQQ==", - "dev": true, - "requires": { - "node-domexception": "^1.0.0", - "web-streams-polyfill": "^3.0.3" - } - }, - "file-entry-cache": { - "version": "6.0.1", - "resolved": "https://registry.npmjs.org/file-entry-cache/-/file-entry-cache-6.0.1.tgz", - "integrity": "sha512-7Gps/XWymbLk2QLYK4NzpMOrYjMhdIxXuIvy2QBsLE6ljuodKvdkWs/cpyJJ3CVIVpH0Oi1Hvg1ovbMzLdFBBg==", - "dev": true, - "requires": { - "flat-cache": "^3.0.4" - } - }, - "find-up": { - "version": "5.0.0", - "resolved": "https://registry.npmjs.org/find-up/-/find-up-5.0.0.tgz", - "integrity": "sha512-78/PXT1wlLLDgTzDs7sjq9hzz0vXD+zn+7wypEe4fXQxCmdmqfGsEPQxmiCSQI3ajFV91bVSsvNtrJRiW6nGng==", - "dev": true, - "requires": { - "locate-path": "^6.0.0", - "path-exists": "^4.0.0" - } - }, - "flat-cache": { - "version": "3.0.4", - "resolved": "https://registry.npmjs.org/flat-cache/-/flat-cache-3.0.4.tgz", - "integrity": "sha512-dm9s5Pw7Jc0GvMYbshN6zchCA9RgQlzzEZX3vylR9IqFfS8XciblUXOKfW6SiuJ0e13eDYZoZV5wdrev7P3Nwg==", - "dev": true, - "requires": { - "flatted": "^3.1.0", - "rimraf": "^3.0.2" - } - }, - "flatted": { - "version": "3.2.7", - "resolved": "https://registry.npmjs.org/flatted/-/flatted-3.2.7.tgz", - "integrity": "sha512-5nqDSxl8nn5BSNxyR3n4I6eDmbolI6WT+QqR547RwxQapgjQBmtktdP+HTBb/a/zLsbzERTONyUB5pefh5TtjQ==", - "dev": true - }, - "follow-redirects": { - "version": "1.15.2", - "resolved": "https://registry.npmjs.org/follow-redirects/-/follow-redirects-1.15.2.tgz", - "integrity": "sha512-VQLG33o04KaQ8uYi2tVNbdrWp1QWxNNea+nmIB4EVM28v0hmP17z7aG1+wAkNzVq4KeXTq3221ye5qTJP91JwA==", - "dev": true - }, - "formdata-polyfill": { - "version": "4.0.10", - "resolved": "https://registry.npmjs.org/formdata-polyfill/-/formdata-polyfill-4.0.10.tgz", - "integrity": "sha512-buewHzMvYL29jdeQTVILecSaZKnt/RJWjoZCF5OW60Z67/GmSLBkOFM7qh1PI3zFNtJbaZL5eQu1vLfazOwj4g==", - "dev": true, - "requires": { - "fetch-blob": "^3.1.2" - } - }, - "fs-constants": { - "version": "1.0.0", - "resolved": "https://registry.npmjs.org/fs-constants/-/fs-constants-1.0.0.tgz", - "integrity": "sha512-y6OAwoSIf7FyjMIv94u+b5rdheZEjzR63GTyZJm5qh4Bi+2YgwLCcI/fPFZkL5PSixOt6ZNKm+w+Hfp/Bciwow==", - "dev": true - }, - "fs.realpath": { - "version": "1.0.0", - "resolved": "https://registry.npmjs.org/fs.realpath/-/fs.realpath-1.0.0.tgz", - "integrity": "sha512-OO0pH2lK6a0hZnAdau5ItzHPI6pUlvI7jMVnxUQRtw4owF2wk8lOSabtGDCTP4Ggrg2MbGnWO9X8K1t4+fGMDw==", - "dev": true - }, - "fsevents": { - "version": "2.3.2", - "resolved": "https://registry.npmjs.org/fsevents/-/fsevents-2.3.2.tgz", - "integrity": "sha512-xiqMQR4xAeHTuB9uWm+fFRcIOgKBMiOBP+eXiyT7jsgVCq1bkVygt00oASowB7EdtpOHaaPgKt812P9ab+DDKA==", - "dev": true, - "optional": true - }, - "function-bind": { - "version": "1.1.1", - "resolved": "https://registry.npmjs.org/function-bind/-/function-bind-1.1.1.tgz", - "integrity": "sha512-yIovAzMX49sF8Yl58fSCWJ5svSLuaibPxXQJFLmBObTuCr0Mf1KiPopGM9NiFjiYBCbfaa2Fh6breQ6ANVTI0A==", - "dev": true - }, - "get-caller-file": { - "version": "2.0.5", - "resolved": "https://registry.npmjs.org/get-caller-file/-/get-caller-file-2.0.5.tgz", - "integrity": "sha512-DyFP3BM/3YHTQOCUL/w0OZHR0lpKeGrxotcHWcqNEdnltqFwXVfhEBQ94eIo34AfQpo0rGki4cyIiftY06h2Fg==", - "dev": true - }, - "get-intrinsic": { - "version": "1.1.3", - "resolved": "https://registry.npmjs.org/get-intrinsic/-/get-intrinsic-1.1.3.tgz", - "integrity": "sha512-QJVz1Tj7MS099PevUG5jvnt9tSkXN8K14dxQlikJuPt4uD9hHAHjLyLBiLR5zELelBdD9QNRAXZzsJx0WaDL9A==", - "dev": true, - "requires": { - "function-bind": "^1.1.1", - "has": "^1.0.3", - "has-symbols": "^1.0.3" - } - }, - "get-stream": { - "version": "5.2.0", - "resolved": "https://registry.npmjs.org/get-stream/-/get-stream-5.2.0.tgz", - "integrity": "sha512-nBF+F1rAZVCu/p7rjzgA+Yb4lfYXrpl7a6VmJrU8wF9I1CKvP/QwPNZHnOlwbTkY6dvtFIzFMSyQXbLoTQPRpA==", - "dev": true, - "requires": { - "pump": "^3.0.0" - } - }, - "glob": { - "version": "7.2.3", - "resolved": "https://registry.npmjs.org/glob/-/glob-7.2.3.tgz", - "integrity": "sha512-nFR0zLpU2YCaRxwoCJvL6UvCH2JFyFVIvwTLsIf21AuHlMskA1hhTdk+LlYJtOlYt9v6dvszD2BGRqBL+iQK9Q==", - "dev": true, - "requires": { - "fs.realpath": "^1.0.0", - "inflight": "^1.0.4", - "inherits": "2", - "minimatch": "^3.1.1", - "once": "^1.3.0", - "path-is-absolute": "^1.0.0" - } - }, - "glob-parent": { - "version": "6.0.2", - "resolved": "https://registry.npmjs.org/glob-parent/-/glob-parent-6.0.2.tgz", - "integrity": "sha512-XxwI8EOhVQgWp6iDL+3b0r86f4d6AX6zSU55HfB4ydCEuXLXc5FcYeOu+nnGftS4TEju/11rt4KJPTMgbfmv4A==", - "dev": true, - "requires": { - "is-glob": "^4.0.3" - } - }, - "globals": { - "version": "13.17.0", - "resolved": "https://registry.npmjs.org/globals/-/globals-13.17.0.tgz", - "integrity": "sha512-1C+6nQRb1GwGMKm2dH/E7enFAMxGTmGI7/dEdhy/DNelv85w9B72t3uc5frtMNXIbzrarJJ/lTCjcaZwbLJmyw==", - "dev": true, - "requires": { - "type-fest": "^0.20.2" - } - }, - "grapheme-splitter": { - "version": "1.0.4", - "resolved": "https://registry.npmjs.org/grapheme-splitter/-/grapheme-splitter-1.0.4.tgz", - "integrity": "sha512-bzh50DW9kTPM00T8y4o8vQg89Di9oLJVLW/KaOGIXJWP/iqCN6WKYkbNOF04vFLJhwcpYUh9ydh/+5vpOqV4YQ==", - "dev": true - }, - "has": { - "version": "1.0.3", - "resolved": "https://registry.npmjs.org/has/-/has-1.0.3.tgz", - "integrity": "sha512-f2dvO0VU6Oej7RkWJGrehjbzMAjFp5/VKPp5tTpWIV4JHHZK1/BxbFRtf/siA2SWTe09caDmVtYYzWEIbBS4zw==", - "dev": true, - "requires": { - "function-bind": "^1.1.1" - } - }, - "has-flag": { - "version": "4.0.0", - "resolved": "https://registry.npmjs.org/has-flag/-/has-flag-4.0.0.tgz", - "integrity": "sha512-EykJT/Q1KjTWctppgIAgfSO0tKVuZUjhgMr17kqTumMl6Afv3EISleU7qZUzoXDFTAHTDC4NOoG/ZxU3EvlMPQ==", - "dev": true - }, - "has-symbols": { - "version": "1.0.3", - "resolved": "https://registry.npmjs.org/has-symbols/-/has-symbols-1.0.3.tgz", - "integrity": "sha512-l3LCuF6MgDNwTDKkdYGEihYjt5pRPbEg46rtlmnSPlUbgmB8LOIrKJbYYFBSbnPaJexMKtiPO8hmeRjRz2Td+A==", - "dev": true - }, - "he": { - "version": "1.2.0", - "resolved": "https://registry.npmjs.org/he/-/he-1.2.0.tgz", - "integrity": "sha512-F/1DnUGPopORZi0ni+CvrCgHQ5FyEAHRLSApuYWMmrbSwoN2Mn/7k+Gl38gJnR7yyDZk6WLXwiGod1JOWNDKGw==", - "dev": true - }, - "html-encoding-sniffer": { - "version": "3.0.0", - "resolved": "https://registry.npmjs.org/html-encoding-sniffer/-/html-encoding-sniffer-3.0.0.tgz", - "integrity": "sha512-oWv4T4yJ52iKrufjnyZPkrN0CH3QnrUqdB6In1g5Fe1mia8GmF36gnfNySxoZtxD5+NmYw1EElVXiBk93UeskA==", - "dev": true, - "requires": { - "whatwg-encoding": "^2.0.0" - } - }, - "http-proxy": { - "version": "1.18.1", - "resolved": "https://registry.npmjs.org/http-proxy/-/http-proxy-1.18.1.tgz", - "integrity": "sha512-7mz/721AbnJwIVbnaSv1Cz3Am0ZLT/UBwkC92VlxhXv/k/BBQfM2fXElQNC27BVGr0uwUpplYPQM9LnaBMR5NQ==", - "dev": true, - "requires": { - "eventemitter3": "^4.0.0", - "follow-redirects": "^1.0.0", - "requires-port": "^1.0.0" - } - }, - "http-server": { - "version": "14.1.1", - "resolved": "https://registry.npmjs.org/http-server/-/http-server-14.1.1.tgz", - "integrity": "sha512-+cbxadF40UXd9T01zUHgA+rlo2Bg1Srer4+B4NwIHdaGxAGGv59nYRnGGDJ9LBk7alpS0US+J+bLLdQOOkJq4A==", - "dev": true, - "requires": { - "basic-auth": "^2.0.1", - "chalk": "^4.1.2", - "corser": "^2.0.1", - "he": "^1.2.0", - "html-encoding-sniffer": "^3.0.0", - "http-proxy": "^1.18.1", - "mime": "^1.6.0", - "minimist": "^1.2.6", - "opener": "^1.5.1", - "portfinder": "^1.0.28", - "secure-compare": "3.0.1", - "union": "~0.5.0", - "url-join": "^4.0.1" - } - }, - "https-proxy-agent": { - "version": "5.0.1", - "resolved": "https://registry.npmjs.org/https-proxy-agent/-/https-proxy-agent-5.0.1.tgz", - "integrity": "sha512-dFcAjpTQFgoLMzC2VwU+C/CbS7uRL0lWmxDITmqm7C+7F0Odmj6s9l6alZc6AELXhrnggM2CeWSXHGOdX2YtwA==", - "dev": true, - "requires": { - "agent-base": "6", - "debug": "4" - } - }, - "iconv-lite": { - "version": "0.6.3", - "resolved": "https://registry.npmjs.org/iconv-lite/-/iconv-lite-0.6.3.tgz", - "integrity": "sha512-4fCk79wshMdzMp2rH06qWrJE4iolqLhCUH+OiuIgU++RB0+94NlDL81atO7GX55uUKueo0txHNtvEyI6D7WdMw==", - "dev": true, - "requires": { - "safer-buffer": ">= 2.1.2 < 3.0.0" - } - }, - "ieee754": { - "version": "1.2.1", - "resolved": "https://registry.npmjs.org/ieee754/-/ieee754-1.2.1.tgz", - "integrity": "sha512-dcyqhDvX1C46lXZcVqCpK+FtMRQVdIMN6/Df5js2zouUsqG7I6sFxitIC+7KYK29KdXOLHdu9zL4sFnoVQnqaA==", - "dev": true - }, - "ignore": { - "version": "5.2.0", - "resolved": "https://registry.npmjs.org/ignore/-/ignore-5.2.0.tgz", - "integrity": "sha512-CmxgYGiEPCLhfLnpPp1MoRmifwEIOgjcHXxOBjv7mY96c+eWScsOP9c112ZyLdWHi0FxHjI+4uVhKYp/gcdRmQ==", - "dev": true - }, - "import-fresh": { - "version": "3.3.0", - "resolved": "https://registry.npmjs.org/import-fresh/-/import-fresh-3.3.0.tgz", - "integrity": "sha512-veYYhQa+D1QBKznvhUHxb8faxlrwUnxseDAbAp457E0wLNio2bOSKnjYDhMj+YiAq61xrMGhQk9iXVk5FzgQMw==", - "dev": true, - "requires": { - "parent-module": "^1.0.0", - "resolve-from": "^4.0.0" - } - }, - "import-manager": { - "version": "0.1.3", - "resolved": "https://registry.npmjs.org/import-manager/-/import-manager-0.1.3.tgz", - "integrity": "sha512-wVJhQ1G55yla0jA3rDsU1irf2NI1ueRPcz57OJ+kspez1NvNzupk6iBM+HYZenCTi1XPHHTeoNDs8F8w3xlVnA==", - "dev": true, - "requires": { - "acorn": "^8.8.0", - "acorn-walk": "^8.2.0", - "colorette": "^2.0.19", - "magic-string": "^0.26.7" - } - }, - "imurmurhash": { - "version": "0.1.4", - "resolved": "https://registry.npmjs.org/imurmurhash/-/imurmurhash-0.1.4.tgz", - "integrity": "sha512-JmXMZ6wuvDmLiHEml9ykzqO6lwFbof0GG4IkcGaENdCRDDmMVnny7s5HsIgHCbaq0w2MyPhDqkhTUgS2LU2PHA==", - "dev": true - }, - "inflight": { - "version": "1.0.6", - "resolved": "https://registry.npmjs.org/inflight/-/inflight-1.0.6.tgz", - "integrity": "sha512-k92I/b08q4wvFscXCLvqfsHCrjrF7yiXsQuIVvVE7N82W3+aqpzuUdBbfhWcy/FZR3/4IgflMgKLOsvPDrGCJA==", - "dev": true, - "requires": { - "once": "^1.3.0", - "wrappy": "1" - } - }, - "inherits": { - "version": "2.0.4", - "resolved": "https://registry.npmjs.org/inherits/-/inherits-2.0.4.tgz", - "integrity": "sha512-k/vGaX4/Yla3WzyMCvTQOXYeIHvqOKtnqBduzTHpzpQZzAskKMhZ2K+EnBiSM9zGSoIFeMpXKxa4dYeZIQqewQ==", - "dev": true - }, - "is-arrayish": { - "version": "0.2.1", - "resolved": "https://registry.npmjs.org/is-arrayish/-/is-arrayish-0.2.1.tgz", - "integrity": "sha512-zz06S8t0ozoDXMG+ube26zeCTNXcKIPJZJi8hBrF4idCLms4CG9QtK7qBl1boi5ODzFpjswb5JPmHCbMpjaYzg==", - "dev": true - }, - "is-extglob": { - "version": "2.1.1", - "resolved": "https://registry.npmjs.org/is-extglob/-/is-extglob-2.1.1.tgz", - "integrity": "sha512-SbKbANkN603Vi4jEZv49LeVJMn4yGwsbzZworEoyEiutsN3nJYdbO36zfhGJ6QEDpOZIFkDtnq5JRxmvl3jsoQ==", - "dev": true - }, - "is-fullwidth-code-point": { - "version": "3.0.0", - "resolved": "https://registry.npmjs.org/is-fullwidth-code-point/-/is-fullwidth-code-point-3.0.0.tgz", - "integrity": "sha512-zymm5+u+sCsSWyD9qNaejV3DFvhCKclKdizYaJUuHA83RLjb7nSuGnddCHGv0hk+KY7BMAlsWeK4Ueg6EV6XQg==", - "dev": true - }, - "is-glob": { - "version": "4.0.3", - "resolved": "https://registry.npmjs.org/is-glob/-/is-glob-4.0.3.tgz", - "integrity": "sha512-xelSayHH36ZgE7ZWhli7pW34hNbNl8Ojv5KVmkJD4hBdD3th8Tfk9vYasLM+mXWOZhFkgZfxhLSnrwRr4elSSg==", - "dev": true, - "requires": { - "is-extglob": "^2.1.1" - } - }, - "is-path-inside": { - "version": "3.0.3", - "resolved": "https://registry.npmjs.org/is-path-inside/-/is-path-inside-3.0.3.tgz", - "integrity": "sha512-Fd4gABb+ycGAmKou8eMftCupSir5lRxqf4aD/vd0cD2qc4HL07OjCeuHMr8Ro4CoMaeCKDB0/ECBOVWjTwUvPQ==", - "dev": true - }, - "is-url-superb": { - "version": "6.1.0", - "resolved": "https://registry.npmjs.org/is-url-superb/-/is-url-superb-6.1.0.tgz", - "integrity": "sha512-LXdhGlYqUPdvEyIhWPEEwYYK3yrUiPcBjmFGlZNv1u5GtIL5qQRf7ddDyPNAvsMFqdzS923FROpTQU97tLe3JQ==", - "dev": true - }, - "isexe": { - "version": "2.0.0", - "resolved": "https://registry.npmjs.org/isexe/-/isexe-2.0.0.tgz", - "integrity": "sha512-RHxMLp9lnKHGHRng9QFhRCMbYAcVpn69smSGcq3f36xjgVVWThj4qqLbTLlq7Ssj8B+fIQ1EuCEGI2lKsyQeIw==", - "dev": true - }, - "js-sdsl": { - "version": "4.1.5", - "resolved": "https://registry.npmjs.org/js-sdsl/-/js-sdsl-4.1.5.tgz", - "integrity": "sha512-08bOAKweV2NUC1wqTtf3qZlnpOX/R2DU9ikpjOHs0H+ibQv3zpncVQg6um4uYtRtrwIX8M4Nh3ytK4HGlYAq7Q==", - "dev": true - }, - "js-tokens": { - "version": "4.0.0", - "resolved": "https://registry.npmjs.org/js-tokens/-/js-tokens-4.0.0.tgz", - "integrity": "sha512-RdJUflcE3cUzKiMqQgsCu06FPu9UdIJO0beYbPhHN4k6apgJtifcoCtT9bcxOpYBtpD2kCM6Sbzg4CausW/PKQ==", - "dev": true - }, - "js-yaml": { - "version": "4.1.0", - "resolved": "https://registry.npmjs.org/js-yaml/-/js-yaml-4.1.0.tgz", - "integrity": "sha512-wpxZs9NoxZaJESJGIZTyDEaYpl0FKSA+FB9aJiyemKhMwkxQg63h4T1KJgUGHpTqPDNRcmmYLugrRjJlBtWvRA==", - "dev": true, - "requires": { - "argparse": "^2.0.1" - } - }, - "json-parse-even-better-errors": { - "version": "2.3.1", - "resolved": "https://registry.npmjs.org/json-parse-even-better-errors/-/json-parse-even-better-errors-2.3.1.tgz", - "integrity": "sha512-xyFwyhro/JEof6Ghe2iz2NcXoj2sloNsWr/XsERDK/oiPCfaNhl5ONfp+jQdAZRQQ0IJWNzH9zIZF7li91kh2w==", - "dev": true - }, - "json-schema-traverse": { - "version": "0.4.1", - "resolved": "https://registry.npmjs.org/json-schema-traverse/-/json-schema-traverse-0.4.1.tgz", - "integrity": "sha512-xbbCH5dCYU5T8LcEhhuh7HJ88HXuW3qsI3Y0zOZFKfZEHcpWiHU/Jxzk629Brsab/mMiHQti9wMP+845RPe3Vg==", - "dev": true - }, - "json-stable-stringify-without-jsonify": { - "version": "1.0.1", - "resolved": "https://registry.npmjs.org/json-stable-stringify-without-jsonify/-/json-stable-stringify-without-jsonify-1.0.1.tgz", - "integrity": "sha512-Bdboy+l7tA3OGW6FjyFHWkP5LuByj1Tk33Ljyq0axyzdk9//JSi2u3fP1QSmd1KNwq6VOKYGlAu87CisVir6Pw==", - "dev": true - }, - "ky": { - "version": "0.27.0", - "resolved": "https://registry.npmjs.org/ky/-/ky-0.27.0.tgz", - "integrity": "sha512-pgaBuB6wI9DdMSOZBVh2WkcbkAdEG5AUEWuNhtThu6FLIpDbzqzC/fSMmqr/j1wwQyW3SP3KGau7EbzWNkQ/yg==", - "dev": true - }, - "ky-universal": { - "version": "0.10.1", - "resolved": "https://registry.npmjs.org/ky-universal/-/ky-universal-0.10.1.tgz", - "integrity": "sha512-r8909k+ELKZAxhVA5c440x22hqw5XcMRwLRbgpPQk4JHy3/ddJnvzcnSo5Ww3HdKdNeS3Y8dBgcIYyVahMa46g==", - "dev": true, - "requires": { - "abort-controller": "^3.0.0", - "node-fetch": "^3.2.2" - }, - "dependencies": { - "node-fetch": { - "version": "3.2.10", - "resolved": "https://registry.npmjs.org/node-fetch/-/node-fetch-3.2.10.tgz", - "integrity": "sha512-MhuzNwdURnZ1Cp4XTazr69K0BTizsBroX7Zx3UgDSVcZYKF/6p0CBe4EUb/hLqmzVhl0UpYfgRljQ4yxE+iCxA==", - "dev": true, - "requires": { - "data-uri-to-buffer": "^4.0.0", - "fetch-blob": "^3.1.4", - "formdata-polyfill": "^4.0.10" - } - } - } - }, - "levn": { - "version": "0.4.1", - "resolved": "https://registry.npmjs.org/levn/-/levn-0.4.1.tgz", - "integrity": "sha512-+bT2uH4E5LGE7h/n3evcS/sQlJXCpIp6ym8OWJ5eV6+67Dsql/LaaT7qJBAt2rzfoa/5QBGBhxDix1dMt2kQKQ==", - "dev": true, - "requires": { - "prelude-ls": "^1.2.1", - "type-check": "~0.4.0" - } - }, - "lines-and-columns": { - "version": "1.2.4", - "resolved": "https://registry.npmjs.org/lines-and-columns/-/lines-and-columns-1.2.4.tgz", - "integrity": "sha512-7ylylesZQ/PV29jhEDl3Ufjo6ZX7gCqJr5F7PKrqc93v7fzSymt1BpwEU8nAUXs8qzzvqhbjhK5QZg6Mt/HkBg==", - "dev": true - }, - "locate-path": { - "version": "6.0.0", - "resolved": "https://registry.npmjs.org/locate-path/-/locate-path-6.0.0.tgz", - "integrity": "sha512-iPZK6eYjbxRu3uB4/WZ3EsEIMJFMqAoopl3R+zuq0UjcAm/MO6KCweDgPfP3elTztoKP3KtnVHxTn2NHBSDVUw==", - "dev": true, - "requires": { - "p-locate": "^5.0.0" - } - }, - "lodash": { - "version": "4.17.21", - "resolved": "https://registry.npmjs.org/lodash/-/lodash-4.17.21.tgz", - "integrity": "sha512-v2kDEe57lecTulaDIuNTPy3Ry4gLGJ6Z1O3vE1krgXZNrsQ+LFTGHVxVjcXPs17LhbZVGedAJv8XZ1tvj5FvSg==", - "dev": true - }, - "lodash.merge": { - "version": "4.6.2", - "resolved": "https://registry.npmjs.org/lodash.merge/-/lodash.merge-4.6.2.tgz", - "integrity": "sha512-0KpjqXRVvrYyCsX1swR/XTK0va6VQkQM6MNo7PqW77ByjAhoARA8EfrP1N4+KlKj8YS0ZUCtRT/YUuhyYDujIQ==", - "dev": true - }, - "magic-string": { - "version": "0.26.7", - "resolved": "https://registry.npmjs.org/magic-string/-/magic-string-0.26.7.tgz", - "integrity": "sha512-hX9XH3ziStPoPhJxLq1syWuZMxbDvGNbVchfrdCtanC7D13888bMFow61x8axrx+GfHLtVeAx2kxL7tTGRl+Ow==", - "dev": true, - "requires": { - "sourcemap-codec": "^1.4.8" - } - }, - "mime": { - "version": "1.6.0", - "resolved": "https://registry.npmjs.org/mime/-/mime-1.6.0.tgz", - "integrity": "sha512-x0Vn8spI+wuJ1O6S7gnbaQg8Pxh4NNHb7KSINmEWKiPE4RKOplvijn+NkmYmmRgP68mc70j2EbeTFRsrswaQeg==", - "dev": true - }, - "minimatch": { - "version": "3.1.2", - "resolved": "https://registry.npmjs.org/minimatch/-/minimatch-3.1.2.tgz", - "integrity": "sha512-J7p63hRiAjw1NDEww1W7i37+ByIrOWO5XQQAzZ3VOcL0PNybwpfmV/N05zFAzwQ9USyEcX6t3UO+K5aqBQOIHw==", - "dev": true, - "requires": { - "brace-expansion": "^1.1.7" - } - }, - "minimist": { - "version": "1.2.7", - "resolved": "https://registry.npmjs.org/minimist/-/minimist-1.2.7.tgz", - "integrity": "sha512-bzfL1YUZsP41gmu/qjrEk0Q6i2ix/cVeAhbCbqH9u3zYutS1cLg00qhrD0M2MVdCcx4Sc0UpP2eBWo9rotpq6g==", - "dev": true - }, - "mkdirp": { - "version": "0.5.6", - "resolved": "https://registry.npmjs.org/mkdirp/-/mkdirp-0.5.6.tgz", - "integrity": "sha512-FP+p8RB8OWpF3YZBCrP5gtADmtXApB5AMLn+vdyA+PyxCjrCs00mjyUozssO33cwDeT3wNGdLxJ5M//YqtHAJw==", - "dev": true, - "requires": { - "minimist": "^1.2.6" - } - }, - "mkdirp-classic": { - "version": "0.5.3", - "resolved": "https://registry.npmjs.org/mkdirp-classic/-/mkdirp-classic-0.5.3.tgz", - "integrity": "sha512-gKLcREMhtuZRwRAfqP3RFW+TK4JqApVBtOIftVgjuABpAtpxhPGaDcfvbhNvD0B8iD1oUr/txX35NjcaY6Ns/A==", - "dev": true - }, - "ms": { - "version": "2.1.2", - "resolved": "https://registry.npmjs.org/ms/-/ms-2.1.2.tgz", - "integrity": "sha512-sGkPx+VjMtmA6MX27oA4FBFELFCZZ4S4XqeGOXCv68tT+jb3vk/RyaKWP0PTKyWtmLSM0b+adUTEvbs1PEaH2w==", - "dev": true - }, - "natural-compare": { - "version": "1.4.0", - "resolved": "https://registry.npmjs.org/natural-compare/-/natural-compare-1.4.0.tgz", - "integrity": "sha512-OWND8ei3VtNC9h7V60qff3SVobHr996CTwgxubgyQYEpg290h9J0buyECNNJexkFm5sOajh5G116RYA1c8ZMSw==", - "dev": true - }, - "no-bro-cote": { - "version": "0.2.6", - "resolved": "https://registry.npmjs.org/no-bro-cote/-/no-bro-cote-0.2.6.tgz", - "integrity": "sha512-EG7CzfpRTga+cVhJB2g96y/i/S4284VWXM0Sd43vROW30aKunFQ1nhwK9A/dK70A/mRKMIhudfyaCHqrQohctg==", - "dev": true, - "requires": { - "colorette": "^2.0.19", - "import-manager": "^0.1.3", - "picomatch": "^2.3.1", - "promise-abortable": "^1.2.6", - "puppeteer": "^19.2.2", - "url-exist": "^3.0.1", - "yargs": "^17.6.2" - } - }, - "node-domexception": { - "version": "1.0.0", - "resolved": "https://registry.npmjs.org/node-domexception/-/node-domexception-1.0.0.tgz", - "integrity": "sha512-/jKZoMpw0F8GRwl4/eLROPA3cfcXtLApP0QzLmUT/HuPCZWyB7IY9ZrMeKw2O/nFIqPQB3PVM9aYm0F312AXDQ==", - "dev": true - }, - "node-fetch": { - "version": "2.6.7", - "resolved": "https://registry.npmjs.org/node-fetch/-/node-fetch-2.6.7.tgz", - "integrity": "sha512-ZjMPFEfVx5j+y2yF35Kzx5sF7kDzxuDj6ziH4FFbOp87zKDZNx8yExJIb05OGF4Nlt9IHFIMBkRl41VdvcNdbQ==", - "dev": true, - "requires": { - "whatwg-url": "^5.0.0" - } - }, - "object-inspect": { - "version": "1.12.2", - "resolved": "https://registry.npmjs.org/object-inspect/-/object-inspect-1.12.2.tgz", - "integrity": "sha512-z+cPxW0QGUp0mcqcsgQyLVRDoXFQbXOwBaqyF7VIgI4TWNQsDHrBpUQslRmIfAoYWdYzs6UlKJtB2XJpTaNSpQ==", - "dev": true - }, - "once": { - "version": "1.4.0", - "resolved": "https://registry.npmjs.org/once/-/once-1.4.0.tgz", - "integrity": "sha512-lNaJgI+2Q5URQBkccEKHTQOPaXdUxnZZElQTZY0MFUAuaEqe1E+Nyvgdz/aIyNi6Z9MzO5dv1H8n58/GELp3+w==", - "dev": true, - "requires": { - "wrappy": "1" - } - }, - "opener": { - "version": "1.5.2", - "resolved": "https://registry.npmjs.org/opener/-/opener-1.5.2.tgz", - "integrity": "sha512-ur5UIdyw5Y7yEj9wLzhqXiy6GZ3Mwx0yGI+5sMn2r0N0v3cKJvUmFH5yPP+WXh9e0xfyzyJX95D8l088DNFj7A==", - "dev": true - }, - "optionator": { - "version": "0.9.1", - "resolved": "https://registry.npmjs.org/optionator/-/optionator-0.9.1.tgz", - "integrity": "sha512-74RlY5FCnhq4jRxVUPKDaRwrVNXMqsGsiW6AJw4XK8hmtm10wC0ypZBLw5IIp85NZMr91+qd1RvvENwg7jjRFw==", - "dev": true, - "requires": { - "deep-is": "^0.1.3", - "fast-levenshtein": "^2.0.6", - "levn": "^0.4.1", - "prelude-ls": "^1.2.1", - "type-check": "^0.4.0", - "word-wrap": "^1.2.3" - } - }, - "p-limit": { - "version": "3.1.0", - "resolved": "https://registry.npmjs.org/p-limit/-/p-limit-3.1.0.tgz", - "integrity": "sha512-TYOanM3wGwNGsZN2cVTYPArw454xnXj5qmWF1bEoAc4+cU/ol7GVh7odevjp1FNHduHc3KZMcFduxU5Xc6uJRQ==", - "dev": true, - "requires": { - "yocto-queue": "^0.1.0" - } - }, - "p-locate": { - "version": "5.0.0", - "resolved": "https://registry.npmjs.org/p-locate/-/p-locate-5.0.0.tgz", - "integrity": "sha512-LaNjtRWUBY++zB5nE/NwcaoMylSPk+S+ZHNB1TzdbMJMny6dynpAGt7X/tl/QYq3TIeE6nxHppbo2LGymrG5Pw==", - "dev": true, - "requires": { - "p-limit": "^3.0.2" - } - }, - "parent-module": { - "version": "1.0.1", - "resolved": "https://registry.npmjs.org/parent-module/-/parent-module-1.0.1.tgz", - "integrity": "sha512-GQ2EWRpQV8/o+Aw8YqtfZZPfNRWZYkbidE9k5rpl/hC3vtHHBfGm2Ifi6qWV+coDGkrUKZAxE3Lot5kcsRlh+g==", - "dev": true, - "requires": { - "callsites": "^3.0.0" - } - }, - "parse-json": { - "version": "5.2.0", - "resolved": "https://registry.npmjs.org/parse-json/-/parse-json-5.2.0.tgz", - "integrity": "sha512-ayCKvm/phCGxOkYRSCM82iDwct8/EonSEgCSxWxD7ve6jHggsFl4fZVQBPRNgQoKiuV/odhFrGzQXZwbifC8Rg==", - "dev": true, - "requires": { - "@babel/code-frame": "^7.0.0", - "error-ex": "^1.3.1", - "json-parse-even-better-errors": "^2.3.0", - "lines-and-columns": "^1.1.6" - } - }, - "path-exists": { - "version": "4.0.0", - "resolved": "https://registry.npmjs.org/path-exists/-/path-exists-4.0.0.tgz", - "integrity": "sha512-ak9Qy5Q7jYb2Wwcey5Fpvg2KoAc/ZIhLSLOSBmRmygPsGwkVVt0fZa0qrtMz+m6tJTAHfZQ8FnmB4MG4LWy7/w==", - "dev": true - }, - "path-is-absolute": { - "version": "1.0.1", - "resolved": "https://registry.npmjs.org/path-is-absolute/-/path-is-absolute-1.0.1.tgz", - "integrity": "sha512-AVbw3UJ2e9bq64vSaS9Am0fje1Pa8pbGqTTsmXfaIiMpnr5DlDhfJOuLj9Sf95ZPVDAUerDfEk88MPmPe7UCQg==", - "dev": true - }, - "path-key": { - "version": "3.1.1", - "resolved": "https://registry.npmjs.org/path-key/-/path-key-3.1.1.tgz", - "integrity": "sha512-ojmeN0qd+y0jszEtoY48r0Peq5dwMEkIlCOu6Q5f41lfkswXuKtYrhgoTpLnyIcHm24Uhqx+5Tqm2InSwLhE6Q==", - "dev": true - }, - "path-type": { - "version": "4.0.0", - "resolved": "https://registry.npmjs.org/path-type/-/path-type-4.0.0.tgz", - "integrity": "sha512-gDKb8aZMDeD/tZWs9P6+q0J9Mwkdl6xMV8TjnGP3qJVJ06bdMgkbBlLU8IdfOsIsFz2BW1rNVT3XuNEl8zPAvw==", - "dev": true - }, - "pend": { - "version": "1.2.0", - "resolved": "https://registry.npmjs.org/pend/-/pend-1.2.0.tgz", - "integrity": "sha512-F3asv42UuXchdzt+xXqfW1OGlVBe+mxa2mqI0pg5yAHZPvFmY3Y6drSf/GQ1A86WgWEN9Kzh/WrgKa6iGcHXLg==", - "dev": true - }, - "picomatch": { - "version": "2.3.1", - "resolved": "https://registry.npmjs.org/picomatch/-/picomatch-2.3.1.tgz", - "integrity": "sha512-JU3teHTNjmE2VCGFzuY8EXzCDVwEqB2a8fsIvwaStHhAWJEeVd1o1QD80CU6+ZdEXXSLbSsuLwJjkCBWqRQUVA==", - "dev": true - }, - "portfinder": { - "version": "1.0.32", - "resolved": "https://registry.npmjs.org/portfinder/-/portfinder-1.0.32.tgz", - "integrity": "sha512-on2ZJVVDXRADWE6jnQaX0ioEylzgBpQk8r55NE4wjXW1ZxO+BgDlY6DXwj20i0V8eB4SenDQ00WEaxfiIQPcxg==", - "dev": true, - "requires": { - "async": "^2.6.4", - "debug": "^3.2.7", - "mkdirp": "^0.5.6" - }, - "dependencies": { - "debug": { - "version": "3.2.7", - "resolved": "https://registry.npmjs.org/debug/-/debug-3.2.7.tgz", - "integrity": "sha512-CFjzYYAi4ThfiQvizrFQevTTXHtnCqWfe7x1AhgEscTz6ZbLbfoLRLPugTQyBth6f8ZERVUSyWHFD/7Wu4t1XQ==", - "dev": true, - "requires": { - "ms": "^2.1.1" - } - } - } - }, - "prelude-ls": { - "version": "1.2.1", - "resolved": "https://registry.npmjs.org/prelude-ls/-/prelude-ls-1.2.1.tgz", - "integrity": "sha512-vkcDPrRZo1QZLbn5RLGPpg/WmIQ65qoWWhcGKf/b5eplkkarX0m9z8ppCat4mlOqUsWpyNuYgO3VRyrYHSzX5g==", - "dev": true - }, - "progress": { - "version": "2.0.3", - "resolved": "https://registry.npmjs.org/progress/-/progress-2.0.3.tgz", - "integrity": "sha512-7PiHtLll5LdnKIMw100I+8xJXR5gW2QwWYkT6iJva0bXitZKa/XMrSbdmg3r2Xnaidz9Qumd0VPaMrZlF9V9sA==", - "dev": true - }, - "promise-abortable": { - "version": "1.2.6", - "resolved": "https://registry.npmjs.org/promise-abortable/-/promise-abortable-1.2.6.tgz", - "integrity": "sha512-H8rMbU9rSohpqHNrgR0DMAE9XRzMNMyhCdpdhkxdqU5sqqzwqvN24+OCQZ5VZTBVw+Qc8DSX40RFivyBbH7GTw==", - "dev": true - }, - "proxy-from-env": { - "version": "1.1.0", - "resolved": "https://registry.npmjs.org/proxy-from-env/-/proxy-from-env-1.1.0.tgz", - "integrity": "sha512-D+zkORCbA9f1tdWRK0RaCR3GPv50cMxcrz4X8k5LTSUD1Dkw47mKJEZQNunItRTkWwgtaUSo1RVFRIG9ZXiFYg==", - "dev": true - }, - "pump": { - "version": "3.0.0", - "resolved": "https://registry.npmjs.org/pump/-/pump-3.0.0.tgz", - "integrity": "sha512-LwZy+p3SFs1Pytd/jYct4wpv49HiYCqd9Rlc5ZVdk0V+8Yzv6jR5Blk3TRmPL1ft69TxP0IMZGJ+WPFU2BFhww==", - "dev": true, - "requires": { - "end-of-stream": "^1.1.0", - "once": "^1.3.1" - } - }, - "punycode": { - "version": "2.1.1", - "resolved": "https://registry.npmjs.org/punycode/-/punycode-2.1.1.tgz", - "integrity": "sha512-XRsRjdf+j5ml+y/6GKHPZbrF/8p2Yga0JPtdqTIY2Xe5ohJPD9saDJJLPvp9+NSBprVvevdXZybnj2cv8OEd0A==", - "dev": true - }, - "puppeteer": { - "version": "19.2.2", - "resolved": "https://registry.npmjs.org/puppeteer/-/puppeteer-19.2.2.tgz", - "integrity": "sha512-m1T5Mog5qu5+dMBptWYTn6pXRdnFbydbVUCthqwbfd8/kOiMlzZBR9ywjX79LpvI1Sj+/z8+FKeIsjnMul8ZYA==", - "dev": true, - "requires": { - "cosmiconfig": "7.0.1", - "devtools-protocol": "0.0.1056733", - "https-proxy-agent": "5.0.1", - "progress": "2.0.3", - "proxy-from-env": "1.1.0", - "puppeteer-core": "19.2.2" - } - }, - "puppeteer-core": { - "version": "19.2.2", - "resolved": "https://registry.npmjs.org/puppeteer-core/-/puppeteer-core-19.2.2.tgz", - "integrity": "sha512-faojf+1pZ/tHXSr4x1q+9MVd9FrL3rpdbC0w7qN7MNClMoLuCvMbpR4vzcjoiJYgclt1n+SOPUOmHQViTw6frw==", - "dev": true, - "requires": { - "cross-fetch": "3.1.5", - "debug": "4.3.4", - "devtools-protocol": "0.0.1056733", - "extract-zip": "2.0.1", - "https-proxy-agent": "5.0.1", - "proxy-from-env": "1.1.0", - "rimraf": "3.0.2", - "tar-fs": "2.1.1", - "unbzip2-stream": "1.4.3", - "ws": "8.10.0" - } - }, - "qs": { - "version": "6.11.0", - "resolved": "https://registry.npmjs.org/qs/-/qs-6.11.0.tgz", - "integrity": "sha512-MvjoMCJwEarSbUYk5O+nmoSzSutSsTwF85zcHPQ9OrlFoZOYIjaqBAJIqIXjptyD5vThxGq52Xu/MaJzRkIk4Q==", - "dev": true, - "requires": { - "side-channel": "^1.0.4" - } - }, - "queue-microtask": { - "version": "1.2.3", - "resolved": "https://registry.npmjs.org/queue-microtask/-/queue-microtask-1.2.3.tgz", - "integrity": "sha512-NuaNSa6flKT5JaSYQzJok04JzTL1CA6aGhv5rfLW3PgqA+M2ChpZQnAC8h8i4ZFkBS8X5RqkDBHA7r4hej3K9A==", - "dev": true - }, - "readable-stream": { - "version": "3.6.0", - "resolved": "https://registry.npmjs.org/readable-stream/-/readable-stream-3.6.0.tgz", - "integrity": "sha512-BViHy7LKeTz4oNnkcLJ+lVSL6vpiFeX6/d3oSH8zCW7UxP2onchk+vTGB143xuFjHS3deTgkKoXXymXqymiIdA==", - "dev": true, - "requires": { - "inherits": "^2.0.3", - "string_decoder": "^1.1.1", - "util-deprecate": "^1.0.1" - } - }, - "regexpp": { - "version": "3.2.0", - "resolved": "https://registry.npmjs.org/regexpp/-/regexpp-3.2.0.tgz", - "integrity": "sha512-pq2bWo9mVD43nbts2wGv17XLiNLya+GklZ8kaDLV2Z08gDCsGpnKn9BFMepvWuHCbyVvY7J5o5+BVvoQbmlJLg==", - "dev": true - }, - "require-directory": { - "version": "2.1.1", - "resolved": "https://registry.npmjs.org/require-directory/-/require-directory-2.1.1.tgz", - "integrity": "sha512-fGxEI7+wsG9xrvdjsrlmL22OMTTiHRwAMroiEeMgq8gzoLC/PQr7RsRDSTLUg/bZAZtF+TVIkHc6/4RIKrui+Q==", - "dev": true - }, - "requires-port": { - "version": "1.0.0", - "resolved": "https://registry.npmjs.org/requires-port/-/requires-port-1.0.0.tgz", - "integrity": "sha512-KigOCHcocU3XODJxsu8i/j8T9tzT4adHiecwORRQ0ZZFcp7ahwXuRU1m+yuO90C5ZUyGeGfocHDI14M3L3yDAQ==", - "dev": true - }, - "resolve-from": { - "version": "4.0.0", - "resolved": "https://registry.npmjs.org/resolve-from/-/resolve-from-4.0.0.tgz", - "integrity": "sha512-pb/MYmXstAkysRFx8piNI1tGFNQIFA3vkE3Gq4EuA1dF6gHp/+vgZqsCGJapvy8N3Q+4o7FwvquPJcnZ7RYy4g==", - "dev": true - }, - "reusify": { - "version": "1.0.4", - "resolved": "https://registry.npmjs.org/reusify/-/reusify-1.0.4.tgz", - "integrity": "sha512-U9nH88a3fc/ekCF1l0/UP1IosiuIjyTh7hBvXVMHYgVcfGvt897Xguj2UOLDeI5BG2m7/uwyaLVT6fbtCwTyzw==", - "dev": true - }, - "rimraf": { - "version": "3.0.2", - "resolved": "https://registry.npmjs.org/rimraf/-/rimraf-3.0.2.tgz", - "integrity": "sha512-JZkJMZkAGFFPP2YqXZXPbMlMBgsxzE8ILs4lMIX/2o0L9UBw9O/Y3o6wFw/i9YLapcUJWwqbi3kdxIPdC62TIA==", - "dev": true, - "requires": { - "glob": "^7.1.3" - } - }, - "rollup": { - "version": "3.2.5", - "resolved": "https://registry.npmjs.org/rollup/-/rollup-3.2.5.tgz", - "integrity": "sha512-/Ha7HhVVofduy+RKWOQJrxe4Qb3xyZo+chcpYiD8SoQa4AG7llhupUtyfKSSrdBM2mWJjhM8wZwmbY23NmlIYw==", - "dev": true, - "requires": { - "fsevents": "~2.3.2" - } - }, - "run-parallel": { - "version": "1.2.0", - "resolved": "https://registry.npmjs.org/run-parallel/-/run-parallel-1.2.0.tgz", - "integrity": "sha512-5l4VyZR86LZ/lDxZTR6jqL8AFE2S0IFLMP26AbjsLVADxHdhB/c0GUsH+y39UfCi3dzz8OlQuPmnaJOMoDHQBA==", - "dev": true, - "requires": { - "queue-microtask": "^1.2.2" - } - }, - "safe-buffer": { - "version": "5.1.2", - "resolved": "https://registry.npmjs.org/safe-buffer/-/safe-buffer-5.1.2.tgz", - "integrity": "sha512-Gd2UZBJDkXlY7GbJxfsE8/nvKkUEU1G38c1siN6QP6a9PT9MmHB8GnpscSmMJSoF8LOIrt8ud/wPtojys4G6+g==", - "dev": true - }, - "safer-buffer": { - "version": "2.1.2", - "resolved": "https://registry.npmjs.org/safer-buffer/-/safer-buffer-2.1.2.tgz", - "integrity": "sha512-YZo3K82SD7Riyi0E1EQPojLz7kpepnSQI9IyPbHHg1XXXevb5dJI7tpyN2ADxGcQbHG7vcyRHk0cbwqcQriUtg==", - "dev": true - }, - "secure-compare": { - "version": "3.0.1", - "resolved": "https://registry.npmjs.org/secure-compare/-/secure-compare-3.0.1.tgz", - "integrity": "sha512-AckIIV90rPDcBcglUwXPF3kg0P0qmPsPXAj6BBEENQE1p5yA1xfmDJzfi1Tappj37Pv2mVbKpL3Z1T+Nn7k1Qw==", - "dev": true - }, - "shebang-command": { - "version": "2.0.0", - "resolved": "https://registry.npmjs.org/shebang-command/-/shebang-command-2.0.0.tgz", - "integrity": "sha512-kHxr2zZpYtdmrN1qDjrrX/Z1rR1kG8Dx+gkpK1G4eXmvXswmcE1hTWBWYUzlraYw1/yZp6YuDY77YtvbN0dmDA==", - "dev": true, - "requires": { - "shebang-regex": "^3.0.0" - } - }, - "shebang-regex": { - "version": "3.0.0", - "resolved": "https://registry.npmjs.org/shebang-regex/-/shebang-regex-3.0.0.tgz", - "integrity": "sha512-7++dFhtcx3353uBaq8DDR4NuxBetBzC7ZQOhmTQInHEd6bSrXdiEyzCvG07Z44UYdLShWUyXt5M/yhz8ekcb1A==", - "dev": true - }, - "side-channel": { - "version": "1.0.4", - "resolved": "https://registry.npmjs.org/side-channel/-/side-channel-1.0.4.tgz", - "integrity": "sha512-q5XPytqFEIKHkGdiMIrY10mvLRvnQh42/+GoBlFW3b2LXLE2xxJpZFdm94we0BaoV3RwJyGqg5wS7epxTv0Zvw==", - "dev": true, - "requires": { - "call-bind": "^1.0.0", - "get-intrinsic": "^1.0.2", - "object-inspect": "^1.9.0" - } - }, - "source-map": { - "version": "0.6.1", - "resolved": "https://registry.npmjs.org/source-map/-/source-map-0.6.1.tgz", - "integrity": "sha512-UjgapumWlbMhkBgzT7Ykc5YXUT46F0iKu8SGXq0bcwP5dz/h0Plj6enJqjz1Zbq2l5WaqYnrVbwWOWMyF3F47g==", - "dev": true - }, - "source-map-support": { - "version": "0.5.21", - "resolved": "https://registry.npmjs.org/source-map-support/-/source-map-support-0.5.21.tgz", - "integrity": "sha512-uBHU3L3czsIyYXKX88fdrGovxdSCoTGDRZ6SYXtSRxLZUzHg5P/66Ht6uoUlHu9EZod+inXhKo3qQgwXUT/y1w==", - "dev": true, - "requires": { - "buffer-from": "^1.0.0", - "source-map": "^0.6.0" - } - }, - "sourcemap-codec": { - "version": "1.4.8", - "resolved": "https://registry.npmjs.org/sourcemap-codec/-/sourcemap-codec-1.4.8.tgz", - "integrity": "sha512-9NykojV5Uih4lgo5So5dtw+f0JgJX30KCNI8gwhz2J9A15wD0Ml6tjHKwf6fTSa6fAdVBdZeNOs9eJ71qCk8vA==", - "dev": true - }, - "string_decoder": { - "version": "1.3.0", - "resolved": "https://registry.npmjs.org/string_decoder/-/string_decoder-1.3.0.tgz", - "integrity": "sha512-hkRX8U1WjJFd8LsDJ2yQ/wWWxaopEsABU1XfkM8A+j0+85JAGppt16cr1Whg6KIbb4okU6Mql6BOj+uup/wKeA==", - "dev": true, - "requires": { - "safe-buffer": "~5.2.0" - }, - "dependencies": { - "safe-buffer": { - "version": "5.2.1", - "resolved": "https://registry.npmjs.org/safe-buffer/-/safe-buffer-5.2.1.tgz", - "integrity": "sha512-rp3So07KcdmmKbGvgaNxQSJr7bGVSVk5S9Eq1F+ppbRo70+YeaDxkw5Dd8NPN+GD6bjnYm2VuPuCXmpuYvmCXQ==", - "dev": true - } - } - }, - "string-width": { - "version": "4.2.3", - "resolved": "https://registry.npmjs.org/string-width/-/string-width-4.2.3.tgz", - "integrity": "sha512-wKyQRQpjJ0sIp62ErSZdGsjMJWsap5oRNihHhu6G7JVO/9jIB6UyevL+tXuOqrng8j/cxKTWyWUwvSTriiZz/g==", - "dev": true, - "requires": { - "emoji-regex": "^8.0.0", - "is-fullwidth-code-point": "^3.0.0", - "strip-ansi": "^6.0.1" - } - }, - "strip-ansi": { - "version": "6.0.1", - "resolved": "https://registry.npmjs.org/strip-ansi/-/strip-ansi-6.0.1.tgz", - "integrity": "sha512-Y38VPSHcqkFrCpFnQ9vuSXmquuv5oXOKpGeT6aGrr3o3Gc9AlVa6JBfUSOCnbxGGZF+/0ooI7KrPuUSztUdU5A==", - "dev": true, - "requires": { - "ansi-regex": "^5.0.1" - } - }, - "strip-json-comments": { - "version": "3.1.1", - "resolved": "https://registry.npmjs.org/strip-json-comments/-/strip-json-comments-3.1.1.tgz", - "integrity": "sha512-6fPc+R4ihwqP6N/aIv2f1gMH8lOVtWQHoqC4yK6oSDVVocumAsfCqjkXnqiYMhmMwS/mEHLp7Vehlt3ql6lEig==", - "dev": true - }, - "supports-color": { - "version": "7.2.0", - "resolved": "https://registry.npmjs.org/supports-color/-/supports-color-7.2.0.tgz", - "integrity": "sha512-qpCAvRl9stuOHveKsn7HncJRvv501qIacKzQlO/+Lwxc9+0q2wLyv4Dfvt80/DPn2pqOBsJdDiogXGR9+OvwRw==", - "dev": true, - "requires": { - "has-flag": "^4.0.0" - } - }, - "tar-fs": { - "version": "2.1.1", - "resolved": "https://registry.npmjs.org/tar-fs/-/tar-fs-2.1.1.tgz", - "integrity": "sha512-V0r2Y9scmbDRLCNex/+hYzvp/zyYjvFbHPNgVTKfQvVrb6guiE/fxP+XblDNR011utopbkex2nM4dHNV6GDsng==", - "dev": true, - "requires": { - "chownr": "^1.1.1", - "mkdirp-classic": "^0.5.2", - "pump": "^3.0.0", - "tar-stream": "^2.1.4" - } - }, - "tar-stream": { - "version": "2.2.0", - "resolved": "https://registry.npmjs.org/tar-stream/-/tar-stream-2.2.0.tgz", - "integrity": "sha512-ujeqbceABgwMZxEJnk2HDY2DlnUZ+9oEcb1KzTVfYHio0UE6dG71n60d8D2I4qNvleWrrXpmjpt7vZeF1LnMZQ==", - "dev": true, - "requires": { - "bl": "^4.0.3", - "end-of-stream": "^1.4.1", - "fs-constants": "^1.0.0", - "inherits": "^2.0.3", - "readable-stream": "^3.1.1" - } - }, - "terser": { - "version": "5.15.1", - "resolved": "https://registry.npmjs.org/terser/-/terser-5.15.1.tgz", - "integrity": "sha512-K1faMUvpm/FBxjBXud0LWVAGxmvoPbZbfTCYbSgaaYQaIXI3/TdI7a7ZGA73Zrou6Q8Zmz3oeUTsp/dj+ag2Xw==", - "dev": true, - "requires": { - "@jridgewell/source-map": "^0.3.2", - "acorn": "^8.5.0", - "commander": "^2.20.0", - "source-map-support": "~0.5.20" - } - }, - "text-table": { - "version": "0.2.0", - "resolved": "https://registry.npmjs.org/text-table/-/text-table-0.2.0.tgz", - "integrity": "sha512-N+8UisAXDGk8PFXP4HAzVR9nbfmVJ3zYLAWiTIoqC5v5isinhr+r5uaO8+7r3BMfuNIufIsA7RdpVgacC2cSpw==", - "dev": true - }, - "through": { - "version": "2.3.8", - "resolved": "https://registry.npmjs.org/through/-/through-2.3.8.tgz", - "integrity": "sha512-w89qg7PI8wAdvX60bMDP+bFoD5Dvhm9oLheFp5O4a2QF0cSBGsBX4qZmadPMvVqlLJBBci+WqGGOAPvcDeNSVg==", - "dev": true - }, - "tr46": { - "version": "0.0.3", - "resolved": "https://registry.npmjs.org/tr46/-/tr46-0.0.3.tgz", - "integrity": "sha512-N3WMsuqV66lT30CrXNbEjx4GEwlow3v6rr4mCcv6prnfwhS01rkgyFdjPNBYd9br7LpXV1+Emh01fHnq2Gdgrw==", - "dev": true - }, - "type-check": { - "version": "0.4.0", - "resolved": "https://registry.npmjs.org/type-check/-/type-check-0.4.0.tgz", - "integrity": "sha512-XleUoc9uwGXqjWwXaUTZAmzMcFZ5858QA2vvx1Ur5xIcixXIP+8LnFDgRplU30us6teqdlskFfu+ae4K79Ooew==", - "dev": true, - "requires": { - "prelude-ls": "^1.2.1" - } - }, - "type-fest": { - "version": "0.20.2", - "resolved": "https://registry.npmjs.org/type-fest/-/type-fest-0.20.2.tgz", - "integrity": "sha512-Ne+eE4r0/iWnpAxD852z3A+N0Bt5RN//NjJwRd2VFHEmrywxf5vsZlh4R6lixl6B+wz/8d+maTSAkN1FIkI3LQ==", - "dev": true - }, - "unbzip2-stream": { - "version": "1.4.3", - "resolved": "https://registry.npmjs.org/unbzip2-stream/-/unbzip2-stream-1.4.3.tgz", - "integrity": "sha512-mlExGW4w71ebDJviH16lQLtZS32VKqsSfk80GCfUlwT/4/hNRFsoscrF/c++9xinkMzECL1uL9DDwXqFWkruPg==", - "dev": true, - "requires": { - "buffer": "^5.2.1", - "through": "^2.3.8" - } - }, - "union": { - "version": "0.5.0", - "resolved": "https://registry.npmjs.org/union/-/union-0.5.0.tgz", - "integrity": "sha512-N6uOhuW6zO95P3Mel2I2zMsbsanvvtgn6jVqJv4vbVcz/JN0OkL9suomjQGmWtxJQXOCqUJvquc1sMeNz/IwlA==", - "dev": true, - "requires": { - "qs": "^6.4.0" - } - }, - "uri-js": { - "version": "4.4.1", - "resolved": "https://registry.npmjs.org/uri-js/-/uri-js-4.4.1.tgz", - "integrity": "sha512-7rKUyy33Q1yc98pQ1DAmLtwX109F7TIfWlW1Ydo8Wl1ii1SeHieeh0HHfPeL2fMXK6z0s8ecKs9frCuLJvndBg==", - "dev": true, - "requires": { - "punycode": "^2.1.0" - } - }, - "url-exist": { - "version": "3.0.1", - "resolved": "https://registry.npmjs.org/url-exist/-/url-exist-3.0.1.tgz", - "integrity": "sha512-37KEE2gj60C4hTh2mGkFeqODO2KVG9TOJWpE3sOLEeLGt/p50VxemPiJ30v4m1dcw/wDEGUpYcmBV2e8jM5/FA==", - "dev": true, - "requires": { - "is-url-superb": "^6.1.0", - "ky": "^0.27.0", - "ky-universal": "^0.10.1" - } - }, - "url-join": { - "version": "4.0.1", - "resolved": "https://registry.npmjs.org/url-join/-/url-join-4.0.1.tgz", - "integrity": "sha512-jk1+QP6ZJqyOiuEI9AEWQfju/nB2Pw466kbA0LEZljHwKeMgd9WrAEgEGxjPDD2+TNbbb37rTyhEfrCXfuKXnA==", - "dev": true - }, - "util-deprecate": { - "version": "1.0.2", - "resolved": "https://registry.npmjs.org/util-deprecate/-/util-deprecate-1.0.2.tgz", - "integrity": "sha512-EPD5q1uXyFxJpCrLnCc1nHnq3gOa6DZBocAIiI2TaSCA7VCJ1UJDMagCzIkXNsUYfD1daK//LTEQ8xiIbrHtcw==", - "dev": true - }, - "web-streams-polyfill": { - "version": "3.2.1", - "resolved": "https://registry.npmjs.org/web-streams-polyfill/-/web-streams-polyfill-3.2.1.tgz", - "integrity": "sha512-e0MO3wdXWKrLbL0DgGnUV7WHVuw9OUvL4hjgnPkIeEvESk74gAITi5G606JtZPp39cd8HA9VQzCIvA49LpPN5Q==", - "dev": true - }, - "webidl-conversions": { - "version": "3.0.1", - "resolved": "https://registry.npmjs.org/webidl-conversions/-/webidl-conversions-3.0.1.tgz", - "integrity": "sha512-2JAn3z8AR6rjK8Sm8orRC0h/bcl/DqL7tRPdGZ4I1CjdF+EaMLmYxBHyXuKL849eucPFhvBoxMsflfOb8kxaeQ==", - "dev": true - }, - "whatwg-encoding": { - "version": "2.0.0", - "resolved": "https://registry.npmjs.org/whatwg-encoding/-/whatwg-encoding-2.0.0.tgz", - "integrity": "sha512-p41ogyeMUrw3jWclHWTQg1k05DSVXPLcVxRTYsXUk+ZooOCZLcoYgPZ/HL/D/N+uQPOtcp1me1WhBEaX02mhWg==", - "dev": true, - "requires": { - "iconv-lite": "0.6.3" - } - }, - "whatwg-url": { - "version": "5.0.0", - "resolved": "https://registry.npmjs.org/whatwg-url/-/whatwg-url-5.0.0.tgz", - "integrity": "sha512-saE57nupxk6v3HY35+jzBwYa0rKSy0XR8JSxZPwgLr7ys0IBzhGviA1/TUGJLmSVqs8pb9AnvICXEuOHLprYTw==", - "dev": true, - "requires": { - "tr46": "~0.0.3", - "webidl-conversions": "^3.0.0" - } - }, - "which": { - "version": "2.0.2", - "resolved": "https://registry.npmjs.org/which/-/which-2.0.2.tgz", - "integrity": "sha512-BLI3Tl1TW3Pvl70l3yq3Y64i+awpwXqsGBYWkkqMtnbXgrMD+yj7rhW0kuEDxzJaYXGjEW5ogapKNMEKNMjibA==", - "dev": true, - "requires": { - "isexe": "^2.0.0" - } - }, - "word-wrap": { - "version": "1.2.3", - "resolved": "https://registry.npmjs.org/word-wrap/-/word-wrap-1.2.3.tgz", - "integrity": "sha512-Hz/mrNwitNRh/HUAtM/VT/5VH+ygD6DV7mYKZAtHOrbs8U7lvPS6xf7EJKMF0uW1KJCl0H701g3ZGus+muE5vQ==", - "dev": true - }, - "wrap-ansi": { - "version": "7.0.0", - "resolved": "https://registry.npmjs.org/wrap-ansi/-/wrap-ansi-7.0.0.tgz", - "integrity": "sha512-YVGIj2kamLSTxw6NsZjoBxfSwsn0ycdesmc4p+Q21c5zPuZ1pl+NfxVdxPtdHvmNVOQ6XSYG4AUtyt/Fi7D16Q==", - "dev": true, - "requires": { - "ansi-styles": "^4.0.0", - "string-width": "^4.1.0", - "strip-ansi": "^6.0.0" - } - }, - "wrappy": { - "version": "1.0.2", - "resolved": "https://registry.npmjs.org/wrappy/-/wrappy-1.0.2.tgz", - "integrity": "sha512-l4Sp/DRseor9wL6EvV2+TuQn63dMkPjZ/sp9XkghTEbV9KlPS1xUsZ3u7/IQO4wxtcFB4bgpQPRcR3QCvezPcQ==", - "dev": true - }, - "ws": { - "version": "8.10.0", - "resolved": "https://registry.npmjs.org/ws/-/ws-8.10.0.tgz", - "integrity": "sha512-+s49uSmZpvtAsd2h37vIPy1RBusaLawVe8of+GyEPsaJTCMpj/2v8NpeK1SHXjBlQ95lQTmQofOJnFiLoaN3yw==", - "dev": true, - "requires": {} - }, - "y18n": { - "version": "5.0.8", - "resolved": "https://registry.npmjs.org/y18n/-/y18n-5.0.8.tgz", - "integrity": "sha512-0pfFzegeDWJHJIAmTLRP2DwHjdF5s7jo9tuztdQxAhINCdvS+3nGINqPd00AphqJR/0LhANUS6/+7SCb98YOfA==", - "dev": true - }, - "yaml": { - "version": "1.10.2", - "resolved": "https://registry.npmjs.org/yaml/-/yaml-1.10.2.tgz", - "integrity": "sha512-r3vXyErRCYJ7wg28yvBY5VSoAF8ZvlcW9/BwUzEtUsjvX/DKs24dIkuwjtuprwJJHsbyUbLApepYTR1BN4uHrg==", - "dev": true - }, - "yargs": { - "version": "17.6.2", - "resolved": "https://registry.npmjs.org/yargs/-/yargs-17.6.2.tgz", - "integrity": "sha512-1/9UrdHjDZc0eOU0HxOHoS78C69UD3JRMvzlJ7S79S2nTaWRA/whGCTV8o9e/N/1Va9YIV7Q4sOxD8VV4pCWOw==", - "dev": true, - "requires": { - "cliui": "^8.0.1", - "escalade": "^3.1.1", - "get-caller-file": "^2.0.5", - "require-directory": "^2.1.1", - "string-width": "^4.2.3", - "y18n": "^5.0.5", - "yargs-parser": "^21.1.1" - } - }, - "yargs-parser": { - "version": "21.1.1", - "resolved": "https://registry.npmjs.org/yargs-parser/-/yargs-parser-21.1.1.tgz", - "integrity": "sha512-tVpsJW7DdjecAiFpbIB1e3qxIQsE6NoPc5/eTdrbbIC4h0LVsWhnoa3g+m2HclBIujHzsxZ4VJVA+GUuc2/LBw==", - "dev": true - }, - "yauzl": { - "version": "2.10.0", - "resolved": "https://registry.npmjs.org/yauzl/-/yauzl-2.10.0.tgz", - "integrity": "sha512-p4a9I6X6nu6IhoGmBqAcbJy1mlC4j27vEPZX9F4L4/vZT3Lyq1VkFHw/V/PUcB9Buo+DG3iHkT0x3Qya58zc3g==", - "dev": true, - "requires": { - "buffer-crc32": "~0.2.3", - "fd-slicer": "~1.1.0" - } - }, - "yocto-queue": { - "version": "0.1.0", - "resolved": "https://registry.npmjs.org/yocto-queue/-/yocto-queue-0.1.0.tgz", - "integrity": "sha512-rVksvsnNCdJ/ohGc6xgPwyN8eheCxsiLM8mxuE/t/mOVqJewPuO1miLpTHQiRgTKCLexL4MeAFVagts7HmNZ2Q==", - "dev": true - } } } diff --git a/package.json b/package.json index 8a9c103..3eb4401 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "browser-sha-obj", - "version": "0.3.2", + "version": "0.3.3", "description": "JavaScript implementation of SHA (1/256/384/512) checksum calculation for the browser.", "browser": "./dist/BrowserSHAObj.esm.js", "type": "module", @@ -34,10 +34,10 @@ "homepage": "https://github.com/UmamiAppearance/BrowserSHAObj#readme", "devDependencies": { "@rollup/plugin-terser": "^0.1.0", - "base-ex": "^0.4.3", - "eslint": "^8.27.0", + "base-ex": "^0.6.1", + "eslint": "^8.29.0", "http-server": "^14.1.1", - "no-bro-cote": "^0.2.6", - "rollup": "^3.2.5" + "no-bro-cote": "^0.2.7", + "rollup": "^3.7.1" } } diff --git a/src/index.js b/src/index.js index 2a5e419..435d56d 100644 --- a/src/index.js +++ b/src/index.js @@ -1,7 +1,7 @@ /** * [BrowserSHAObj]{@link https://github.com/UmamiAppearance/BrowserSHAObj} * - * @version 0.3.2 + * @version 0.3.3 * @author UmamiAppearance [mail@umamiappearance.eu] * @license GPL-3.0 */