UNPKG

@budibase/server

Version:
1,350 lines • 668 kB
import { Q as xn, R as di } from "./index-fc73233e.js"; function xi(A, g) { for (var h = 0; h < g.length; h++) { const m = g[h]; if (typeof m != "string" && !Array.isArray(m)) { for (const I in m) if (I !== "default" && !(I in A)) { const d = Object.getOwnPropertyDescriptor(m, I); d && Object.defineProperty(A, I, d.get ? d : { enumerable: !0, get: () => m[I] }); } } } return Object.freeze(Object.defineProperty(A, Symbol.toStringTag, { value: "Module" })); } var H; (function(A) { A[A.QR_CODE = 0] = "QR_CODE", A[A.AZTEC = 1] = "AZTEC", A[A.CODABAR = 2] = "CODABAR", A[A.CODE_39 = 3] = "CODE_39", A[A.CODE_93 = 4] = "CODE_93", A[A.CODE_128 = 5] = "CODE_128", A[A.DATA_MATRIX = 6] = "DATA_MATRIX", A[A.MAXICODE = 7] = "MAXICODE", A[A.ITF = 8] = "ITF", A[A.EAN_13 = 9] = "EAN_13", A[A.EAN_8 = 10] = "EAN_8", A[A.PDF_417 = 11] = "PDF_417", A[A.RSS_14 = 12] = "RSS_14", A[A.RSS_EXPANDED = 13] = "RSS_EXPANDED", A[A.UPC_A = 14] = "UPC_A", A[A.UPC_E = 15] = "UPC_E", A[A.UPC_EAN_EXTENSION = 16] = "UPC_EAN_EXTENSION"; })(H || (H = {})); var br = /* @__PURE__ */ new Map([ [H.QR_CODE, "QR_CODE"], [H.AZTEC, "AZTEC"], [H.CODABAR, "CODABAR"], [H.CODE_39, "CODE_39"], [H.CODE_93, "CODE_93"], [H.CODE_128, "CODE_128"], [H.DATA_MATRIX, "DATA_MATRIX"], [H.MAXICODE, "MAXICODE"], [H.ITF, "ITF"], [H.EAN_13, "EAN_13"], [H.EAN_8, "EAN_8"], [H.PDF_417, "PDF_417"], [H.RSS_14, "RSS_14"], [H.RSS_EXPANDED, "RSS_EXPANDED"], [H.UPC_A, "UPC_A"], [H.UPC_E, "UPC_E"], [H.UPC_EAN_EXTENSION, "UPC_EAN_EXTENSION"] ]), Tr; (function(A) { A[A.UNKNOWN = 0] = "UNKNOWN", A[A.URL = 1] = "URL"; })(Tr || (Tr = {})); function gi(A) { return Object.values(H).includes(A); } var _n; (function(A) { A[A.SCAN_TYPE_CAMERA = 0] = "SCAN_TYPE_CAMERA", A[A.SCAN_TYPE_FILE = 1] = "SCAN_TYPE_FILE"; })(_n || (_n = {})); var wi = function() { function A() { } return A.GITHUB_PROJECT_URL = "https://github.com/mebjas/html5-qrcode", A.SCAN_DEFAULT_FPS = 2, A.DEFAULT_DISABLE_FLIP = !1, A.DEFAULT_REMEMBER_LAST_CAMERA_USED = !0, A.DEFAULT_SUPPORTED_SCAN_TYPE = [ _n.SCAN_TYPE_CAMERA, _n.SCAN_TYPE_FILE ], A; }(), Br = function() { function A(g, h) { this.format = g, this.formatName = h; } return A.prototype.toString = function() { return this.formatName; }, A.create = function(g) { if (!br.has(g)) throw "".concat(g, " not in html5QrcodeSupportedFormatsTextMap"); return new A(g, br.get(g)); }, A; }(), yr = function() { function A() { } return A.createFromText = function(g) { var h = { text: g }; return { decodedText: g, result: h }; }, A.createFromQrcodeResult = function(g) { return { decodedText: g.text, result: g }; }, A; }(), $n; (function(A) { A[A.UNKWOWN_ERROR = 0] = "UNKWOWN_ERROR", A[A.IMPLEMENTATION_ERROR = 1] = "IMPLEMENTATION_ERROR", A[A.NO_CODE_FOUND_ERROR = 2] = "NO_CODE_FOUND_ERROR"; })($n || ($n = {})); var Ai = function() { function A() { } return A.createFrom = function(g) { return { errorMessage: g, type: $n.UNKWOWN_ERROR }; }, A; }(), Ei = function() { function A(g) { this.verbose = g; } return A.prototype.log = function(g) { this.verbose && console.log(g); }, A.prototype.warn = function(g) { this.verbose && console.warn(g); }, A.prototype.logError = function(g, h) { (this.verbose || h === !0) && console.error(g); }, A.prototype.logErrors = function(g) { if (g.length === 0) throw "Logger#logError called without arguments"; this.verbose && console.error(g); }, A; }(); function bt(A) { return typeof A > "u" || A === null; } var $t = function() { function A() { } return A.codeParseError = function(g) { return "QR code parse error, error = ".concat(g); }, A.errorGettingUserMedia = function(g) { return "Error getting userMedia, error = ".concat(g); }, A.onlyDeviceSupportedError = function() { return "The device doesn't support navigator.mediaDevices , only supported cameraIdOrConfig in this case is deviceId parameter (string)."; }, A.cameraStreamingNotSupported = function() { return "Camera streaming not supported by the browser."; }, A.unableToQuerySupportedDevices = function() { return "Unable to query supported devices, unknown error."; }, A.insecureContextCameraQueryError = function() { return "Camera access is only supported in secure context like https or localhost."; }, A.scannerPaused = function() { return "Scanner paused"; }, A; }(), vr = function() { function A() { } return A.isMediaStreamConstraintsValid = function(g, h) { if (typeof g != "object") { var m = typeof g; return h.logError("videoConstraints should be of type object, the " + "object passed is of type ".concat(m, "."), !0), !1; } for (var I = [ "autoGainControl", "channelCount", "echoCancellation", "latency", "noiseSuppression", "sampleRate", "sampleSize", "volume" ], d = new Set(I), S = Object.keys(g), P = 0, B = S; P < B.length; P++) { var w = B[P]; if (d.has(w)) return h.logError("".concat(w, " is not supported videoConstaints."), !0), !1; } return !0; }, A; }(), er = { exports: {} }; (function(A, g) { (function(h, m) { m(g); })(xn, function(h) { function m(f) { return f == null; } var I = Object.setPrototypeOf || { __proto__: [] } instanceof Array && function(f, e) { f.__proto__ = e; } || function(f, e) { for (var t in e) e.hasOwnProperty(t) && (f[t] = e[t]); }; function d(f, e) { I(f, e); function t() { this.constructor = f; } f.prototype = e === null ? Object.create(e) : (t.prototype = e.prototype, new t()); } function S(f, e) { var t = Object.setPrototypeOf; t ? t(f, e) : f.__proto__ = e; } function P(f, e) { e === void 0 && (e = f.constructor); var t = Error.captureStackTrace; t && t(f, e); } var B = function(f) { d(e, f); function e(t) { var n = this.constructor, r = f.call(this, t) || this; return Object.defineProperty(r, "name", { value: n.name, enumerable: !1 }), S(r, n.prototype), P(r), r; } return e; }(Error); class w extends B { /** * Allows Exception to be constructed directly * with some message and prototype definition. */ constructor(e = void 0) { super(e), this.message = e; } getKind() { return this.constructor.kind; } } w.kind = "Exception"; class D extends w { } D.kind = "ArgumentException"; class R extends w { } R.kind = "IllegalArgumentException"; class de { constructor(e) { if (this.binarizer = e, e === null) throw new R("Binarizer must be non-null."); } /** * @return The width of the bitmap. */ getWidth() { return this.binarizer.getWidth(); } /** * @return The height of the bitmap. */ getHeight() { return this.binarizer.getHeight(); } /** * Converts one row of luminance data to 1 bit data. May actually do the conversion, or return * cached data. Callers should assume this method is expensive and call it as seldom as possible. * This method is intended for decoding 1D barcodes and may choose to apply sharpening. * * @param y The row to fetch, which must be in [0, bitmap height) * @param row An optional preallocated array. If null or too small, it will be ignored. * If used, the Binarizer will call BitArray.clear(). Always use the returned object. * @return The array of bits for this row (true means black). * @throws NotFoundException if row can't be binarized */ getBlackRow(e, t) { return this.binarizer.getBlackRow(e, t); } /** * Converts a 2D array of luminance data to 1 bit. As above, assume this method is expensive * and do not call it repeatedly. This method is intended for decoding 2D barcodes and may or * may not apply sharpening. Therefore, a row from this matrix may not be identical to one * fetched using getBlackRow(), so don't mix and match between them. * * @return The 2D array of bits for the image (true means black). * @throws NotFoundException if image can't be binarized to make a matrix */ getBlackMatrix() { return (this.matrix === null || this.matrix === void 0) && (this.matrix = this.binarizer.getBlackMatrix()), this.matrix; } /** * @return Whether this bitmap can be cropped. */ isCropSupported() { return this.binarizer.getLuminanceSource().isCropSupported(); } /** * Returns a new object with cropped image data. Implementations may keep a reference to the * original data rather than a copy. Only callable if isCropSupported() is true. * * @param left The left coordinate, which must be in [0,getWidth()) * @param top The top coordinate, which must be in [0,getHeight()) * @param width The width of the rectangle to crop. * @param height The height of the rectangle to crop. * @return A cropped version of this object. */ crop(e, t, n, r) { const i = this.binarizer.getLuminanceSource().crop(e, t, n, r); return new de(this.binarizer.createBinarizer(i)); } /** * @return Whether this bitmap supports counter-clockwise rotation. */ isRotateSupported() { return this.binarizer.getLuminanceSource().isRotateSupported(); } /** * Returns a new object with rotated image data by 90 degrees counterclockwise. * Only callable if {@link #isRotateSupported()} is true. * * @return A rotated version of this object. */ rotateCounterClockwise() { const e = this.binarizer.getLuminanceSource().rotateCounterClockwise(); return new de(this.binarizer.createBinarizer(e)); } /** * Returns a new object with rotated image data by 45 degrees counterclockwise. * Only callable if {@link #isRotateSupported()} is true. * * @return A rotated version of this object. */ rotateCounterClockwise45() { const e = this.binarizer.getLuminanceSource().rotateCounterClockwise45(); return new de(this.binarizer.createBinarizer(e)); } /*@Override*/ toString() { try { return this.getBlackMatrix().toString(); } catch { return ""; } } } class te extends w { static getChecksumInstance() { return new te(); } } te.kind = "ChecksumException"; class Ze { constructor(e) { this.source = e; } getLuminanceSource() { return this.source; } getWidth() { return this.source.getWidth(); } getHeight() { return this.source.getHeight(); } } class re { // public static void arraycopy(Object src, int srcPos, Object dest, int destPos, int length) /** * Makes a copy of a array. */ static arraycopy(e, t, n, r, i) { for (; i--; ) n[r++] = e[t++]; } /** * Returns the current time in milliseconds. */ static currentTimeMillis() { return Date.now(); } } class xt extends w { } xt.kind = "IndexOutOfBoundsException"; class Tt extends xt { constructor(e = void 0, t = void 0) { super(t), this.index = e, this.message = t; } } Tt.kind = "ArrayIndexOutOfBoundsException"; class me { /** * Assigns the specified int value to each element of the specified array * of ints. * * @param a the array to be filled * @param val the value to be stored in all elements of the array */ static fill(e, t) { for (let n = 0, r = e.length; n < r; n++) e[n] = t; } /** * Assigns the specified int value to each element of the specified * range of the specified array of ints. The range to be filled * extends from index {@code fromIndex}, inclusive, to index * {@code toIndex}, exclusive. (If {@code fromIndex==toIndex}, the * range to be filled is empty.) * * @param a the array to be filled * @param fromIndex the index of the first element (inclusive) to be * filled with the specified value * @param toIndex the index of the last element (exclusive) to be * filled with the specified value * @param val the value to be stored in all elements of the array * @throws IllegalArgumentException if {@code fromIndex > toIndex} * @throws ArrayIndexOutOfBoundsException if {@code fromIndex < 0} or * {@code toIndex > a.length} */ static fillWithin(e, t, n, r) { me.rangeCheck(e.length, t, n); for (let i = t; i < n; i++) e[i] = r; } /** * Checks that {@code fromIndex} and {@code toIndex} are in * the range and throws an exception if they aren't. */ static rangeCheck(e, t, n) { if (t > n) throw new R("fromIndex(" + t + ") > toIndex(" + n + ")"); if (t < 0) throw new Tt(t); if (n > e) throw new Tt(n); } static asList(...e) { return e; } static create(e, t, n) { return Array.from({ length: e }).map((i) => Array.from({ length: t }).fill(n)); } static createInt32Array(e, t, n) { return Array.from({ length: e }).map((i) => Int32Array.from({ length: t }).fill(n)); } static equals(e, t) { if (!e || !t || !e.length || !t.length || e.length !== t.length) return !1; for (let n = 0, r = e.length; n < r; n++) if (e[n] !== t[n]) return !1; return !0; } static hashCode(e) { if (e === null) return 0; let t = 1; for (const n of e) t = 31 * t + n; return t; } static fillUint8Array(e, t) { for (let n = 0; n !== e.length; n++) e[n] = t; } static copyOf(e, t) { return e.slice(0, t); } static copyOfUint8Array(e, t) { if (e.length <= t) { const n = new Uint8Array(t); return n.set(e), n; } return e.slice(0, t); } static copyOfRange(e, t, n) { const r = n - t, i = new Int32Array(r); return re.arraycopy(e, t, i, 0, r), i; } /* * Returns the index of of the element in a sorted array or (-n-1) where n is the insertion point * for the new element. * Parameters: * ar - A sorted array * el - An element to search for * comparator - A comparator function. The function takes two arguments: (a, b) and returns: * a negative number if a is less than b; * 0 if a is equal to b; * a positive number of a is greater than b. * The array may contain duplicate elements. If there are more than one equal elements in the array, * the returned value can be the index of any one of the equal elements. * * http://jsfiddle.net/aryzhov/pkfst550/ */ static binarySearch(e, t, n) { n === void 0 && (n = me.numberComparator); let r = 0, i = e.length - 1; for (; r <= i; ) { const s = i + r >> 1, o = n(t, e[s]); if (o > 0) r = s + 1; else if (o < 0) i = s - 1; else return s; } return -r - 1; } static numberComparator(e, t) { return e - t; } } class j { static numberOfTrailingZeros(e) { let t; if (e === 0) return 32; let n = 31; return t = e << 16, t !== 0 && (n -= 16, e = t), t = e << 8, t !== 0 && (n -= 8, e = t), t = e << 4, t !== 0 && (n -= 4, e = t), t = e << 2, t !== 0 && (n -= 2, e = t), n - (e << 1 >>> 31); } static numberOfLeadingZeros(e) { if (e === 0) return 32; let t = 1; return e >>> 16 || (t += 16, e <<= 16), e >>> 24 || (t += 8, e <<= 8), e >>> 28 || (t += 4, e <<= 4), e >>> 30 || (t += 2, e <<= 2), t -= e >>> 31, t; } static toHexString(e) { return e.toString(16); } static toBinaryString(e) { return String(parseInt(String(e), 2)); } // Returns the number of one-bits in the two's complement binary representation of the specified int value. This function is sometimes referred to as the population count. // Returns: // the number of one-bits in the two's complement binary representation of the specified int value. static bitCount(e) { return e = e - (e >>> 1 & 1431655765), e = (e & 858993459) + (e >>> 2 & 858993459), e = e + (e >>> 4) & 252645135, e = e + (e >>> 8), e = e + (e >>> 16), e & 63; } static truncDivision(e, t) { return Math.trunc(e / t); } /** * Converts A string to an integer. * @param s A string to convert into a number. * @param radix A value between 2 and 36 that specifies the base of the number in numString. If this argument is not supplied, strings with a prefix of '0x' are considered hexadecimal. All other strings are considered decimal. */ static parseInt(e, t = void 0) { return parseInt(e, t); } } j.MIN_VALUE_32_BITS = -2147483648, j.MAX_VALUE = Number.MAX_SAFE_INTEGER; class ae { // For testing only constructor(e, t) { e === void 0 ? (this.size = 0, this.bits = new Int32Array(1)) : (this.size = e, t == null ? this.bits = ae.makeArray(e) : this.bits = t); } getSize() { return this.size; } getSizeInBytes() { return Math.floor((this.size + 7) / 8); } ensureCapacity(e) { if (e > this.bits.length * 32) { const t = ae.makeArray(e); re.arraycopy(this.bits, 0, t, 0, this.bits.length), this.bits = t; } } /** * @param i bit to get * @return true iff bit i is set */ get(e) { return (this.bits[Math.floor(e / 32)] & 1 << (e & 31)) !== 0; } /** * Sets bit i. * * @param i bit to set */ set(e) { this.bits[Math.floor(e / 32)] |= 1 << (e & 31); } /** * Flips bit i. * * @param i bit to set */ flip(e) { this.bits[Math.floor(e / 32)] ^= 1 << (e & 31); } /** * @param from first bit to check * @return index of first bit that is set, starting from the given index, or size if none are set * at or beyond this given index * @see #getNextUnset(int) */ getNextSet(e) { const t = this.size; if (e >= t) return t; const n = this.bits; let r = Math.floor(e / 32), i = n[r]; i &= ~((1 << (e & 31)) - 1); const s = n.length; for (; i === 0; ) { if (++r === s) return t; i = n[r]; } const o = r * 32 + j.numberOfTrailingZeros(i); return o > t ? t : o; } /** * @param from index to start looking for unset bit * @return index of next unset bit, or {@code size} if none are unset until the end * @see #getNextSet(int) */ getNextUnset(e) { const t = this.size; if (e >= t) return t; const n = this.bits; let r = Math.floor(e / 32), i = ~n[r]; i &= ~((1 << (e & 31)) - 1); const s = n.length; for (; i === 0; ) { if (++r === s) return t; i = ~n[r]; } const o = r * 32 + j.numberOfTrailingZeros(i); return o > t ? t : o; } /** * Sets a block of 32 bits, starting at bit i. * * @param i first bit to set * @param newBits the new value of the next 32 bits. Note again that the least-significant bit * corresponds to bit i, the next-least-significant to i+1, and so on. */ setBulk(e, t) { this.bits[Math.floor(e / 32)] = t; } /** * Sets a range of bits. * * @param start start of range, inclusive. * @param end end of range, exclusive */ setRange(e, t) { if (t < e || e < 0 || t > this.size) throw new R(); if (t === e) return; t--; const n = Math.floor(e / 32), r = Math.floor(t / 32), i = this.bits; for (let s = n; s <= r; s++) { const o = s > n ? 0 : e & 31, l = (2 << (s < r ? 31 : t & 31)) - (1 << o); i[s] |= l; } } /** * Clears all bits (sets to false). */ clear() { const e = this.bits.length, t = this.bits; for (let n = 0; n < e; n++) t[n] = 0; } /** * Efficient method to check if a range of bits is set, or not set. * * @param start start of range, inclusive. * @param end end of range, exclusive * @param value if true, checks that bits in range are set, otherwise checks that they are not set * * @return true iff all bits are set or not set in range, according to value argument * @throws IllegalArgumentException if end is less than start or the range is not contained in the array */ isRange(e, t, n) { if (t < e || e < 0 || t > this.size) throw new R(); if (t === e) return !0; t--; const r = Math.floor(e / 32), i = Math.floor(t / 32), s = this.bits; for (let o = r; o <= i; o++) { const a = o > r ? 0 : e & 31, c = (2 << (o < i ? 31 : t & 31)) - (1 << a) & 4294967295; if ((s[o] & c) !== (n ? c : 0)) return !1; } return !0; } appendBit(e) { this.ensureCapacity(this.size + 1), e && (this.bits[Math.floor(this.size / 32)] |= 1 << (this.size & 31)), this.size++; } /** * Appends the least-significant bits, from value, in order from most-significant to * least-significant. For example, appending 6 bits from 0x000001E will append the bits * 0, 1, 1, 1, 1, 0 in that order. * * @param value {@code int} containing bits to append * @param numBits bits from value to append */ appendBits(e, t) { if (t < 0 || t > 32) throw new R("Num bits must be between 0 and 32"); this.ensureCapacity(this.size + t); for (let n = t; n > 0; n--) this.appendBit((e >> n - 1 & 1) === 1); } appendBitArray(e) { const t = e.size; this.ensureCapacity(this.size + t); for (let n = 0; n < t; n++) this.appendBit(e.get(n)); } xor(e) { if (this.size !== e.size) throw new R("Sizes don't match"); const t = this.bits; for (let n = 0, r = t.length; n < r; n++) t[n] ^= e.bits[n]; } /** * * @param bitOffset first bit to start writing * @param array array to write into. Bytes are written most-significant byte first. This is the opposite * of the internal representation, which is exposed by {@link #getBitArray()} * @param offset position in array to start writing * @param numBytes how many bytes to write */ toBytes(e, t, n, r) { for (let i = 0; i < r; i++) { let s = 0; for (let o = 0; o < 8; o++) this.get(e) && (s |= 1 << 7 - o), e++; t[n + i] = /*(byte)*/ s; } } /** * @return underlying array of ints. The first element holds the first 32 bits, and the least * significant bit is bit 0. */ getBitArray() { return this.bits; } /** * Reverses all bits in the array. */ reverse() { const e = new Int32Array(this.bits.length), t = Math.floor((this.size - 1) / 32), n = t + 1, r = this.bits; for (let i = 0; i < n; i++) { let s = r[i]; s = s >> 1 & 1431655765 | (s & 1431655765) << 1, s = s >> 2 & 858993459 | (s & 858993459) << 2, s = s >> 4 & 252645135 | (s & 252645135) << 4, s = s >> 8 & 16711935 | (s & 16711935) << 8, s = s >> 16 & 65535 | (s & 65535) << 16, e[t - i] = /*(int)*/ s; } if (this.size !== n * 32) { const i = n * 32 - this.size; let s = e[0] >>> i; for (let o = 1; o < n; o++) { const a = e[o]; s |= a << 32 - i, e[o - 1] = s, s = a >>> i; } e[n - 1] = s; } this.bits = e; } static makeArray(e) { return new Int32Array(Math.floor((e + 31) / 32)); } /*@Override*/ equals(e) { if (!(e instanceof ae)) return !1; const t = e; return this.size === t.size && me.equals(this.bits, t.bits); } /*@Override*/ hashCode() { return 31 * this.size + me.hashCode(this.bits); } /*@Override*/ toString() { let e = ""; for (let t = 0, n = this.size; t < n; t++) t & 7 || (e += " "), e += this.get(t) ? "X" : "."; return e; } /*@Override*/ clone() { return new ae(this.size, this.bits.slice()); } } var yt; (function(f) { f[f.OTHER = 0] = "OTHER", f[f.PURE_BARCODE = 1] = "PURE_BARCODE", f[f.POSSIBLE_FORMATS = 2] = "POSSIBLE_FORMATS", f[f.TRY_HARDER = 3] = "TRY_HARDER", f[f.CHARACTER_SET = 4] = "CHARACTER_SET", f[f.ALLOWED_LENGTHS = 5] = "ALLOWED_LENGTHS", f[f.ASSUME_CODE_39_CHECK_DIGIT = 6] = "ASSUME_CODE_39_CHECK_DIGIT", f[f.ASSUME_GS1 = 7] = "ASSUME_GS1", f[f.RETURN_CODABAR_START_END = 8] = "RETURN_CODABAR_START_END", f[f.NEED_RESULT_POINT_CALLBACK = 9] = "NEED_RESULT_POINT_CALLBACK", f[f.ALLOWED_EAN_EXTENSIONS = 10] = "ALLOWED_EAN_EXTENSIONS"; })(yt || (yt = {})); var xe = yt; class U extends w { static getFormatInstance() { return new U(); } } U.kind = "FormatException"; var ue; (function(f) { f[f.Cp437 = 0] = "Cp437", f[f.ISO8859_1 = 1] = "ISO8859_1", f[f.ISO8859_2 = 2] = "ISO8859_2", f[f.ISO8859_3 = 3] = "ISO8859_3", f[f.ISO8859_4 = 4] = "ISO8859_4", f[f.ISO8859_5 = 5] = "ISO8859_5", f[f.ISO8859_6 = 6] = "ISO8859_6", f[f.ISO8859_7 = 7] = "ISO8859_7", f[f.ISO8859_8 = 8] = "ISO8859_8", f[f.ISO8859_9 = 9] = "ISO8859_9", f[f.ISO8859_10 = 10] = "ISO8859_10", f[f.ISO8859_11 = 11] = "ISO8859_11", f[f.ISO8859_13 = 12] = "ISO8859_13", f[f.ISO8859_14 = 13] = "ISO8859_14", f[f.ISO8859_15 = 14] = "ISO8859_15", f[f.ISO8859_16 = 15] = "ISO8859_16", f[f.SJIS = 16] = "SJIS", f[f.Cp1250 = 17] = "Cp1250", f[f.Cp1251 = 18] = "Cp1251", f[f.Cp1252 = 19] = "Cp1252", f[f.Cp1256 = 20] = "Cp1256", f[f.UnicodeBigUnmarked = 21] = "UnicodeBigUnmarked", f[f.UTF8 = 22] = "UTF8", f[f.ASCII = 23] = "ASCII", f[f.Big5 = 24] = "Big5", f[f.GB18030 = 25] = "GB18030", f[f.EUC_KR = 26] = "EUC_KR"; })(ue || (ue = {})); class k { constructor(e, t, n, ...r) { this.valueIdentifier = e, this.name = n, typeof t == "number" ? this.values = Int32Array.from([t]) : this.values = t, this.otherEncodingNames = r, k.VALUE_IDENTIFIER_TO_ECI.set(e, this), k.NAME_TO_ECI.set(n, this); const i = this.values; for (let s = 0, o = i.length; s !== o; s++) { const a = i[s]; k.VALUES_TO_ECI.set(a, this); } for (const s of r) k.NAME_TO_ECI.set(s, this); } // CharacterSetECI(value: number /*int*/) { // this(new Int32Array {value}) // } // CharacterSetECI(value: number /*int*/, String... otherEncodingNames) { // this.values = new Int32Array {value} // this.otherEncodingNames = otherEncodingNames // } // CharacterSetECI(values: Int32Array, String... otherEncodingNames) { // this.values = values // this.otherEncodingNames = otherEncodingNames // } getValueIdentifier() { return this.valueIdentifier; } getName() { return this.name; } getValue() { return this.values[0]; } /** * @param value character set ECI value * @return {@code CharacterSetECI} representing ECI of given value, or null if it is legal but * unsupported * @throws FormatException if ECI value is invalid */ static getCharacterSetECIByValue(e) { if (e < 0 || e >= 900) throw new U("incorect value"); const t = k.VALUES_TO_ECI.get(e); if (t === void 0) throw new U("incorect value"); return t; } /** * @param name character set ECI encoding name * @return CharacterSetECI representing ECI for character encoding, or null if it is legal * but unsupported */ static getCharacterSetECIByName(e) { const t = k.NAME_TO_ECI.get(e); if (t === void 0) throw new U("incorect value"); return t; } equals(e) { if (!(e instanceof k)) return !1; const t = e; return this.getName() === t.getName(); } } k.VALUE_IDENTIFIER_TO_ECI = /* @__PURE__ */ new Map(), k.VALUES_TO_ECI = /* @__PURE__ */ new Map(), k.NAME_TO_ECI = /* @__PURE__ */ new Map(), k.Cp437 = new k(ue.Cp437, Int32Array.from([0, 2]), "Cp437"), k.ISO8859_1 = new k(ue.ISO8859_1, Int32Array.from([1, 3]), "ISO-8859-1", "ISO88591", "ISO8859_1"), k.ISO8859_2 = new k(ue.ISO8859_2, 4, "ISO-8859-2", "ISO88592", "ISO8859_2"), k.ISO8859_3 = new k(ue.ISO8859_3, 5, "ISO-8859-3", "ISO88593", "ISO8859_3"), k.ISO8859_4 = new k(ue.ISO8859_4, 6, "ISO-8859-4", "ISO88594", "ISO8859_4"), k.ISO8859_5 = new k(ue.ISO8859_5, 7, "ISO-8859-5", "ISO88595", "ISO8859_5"), k.ISO8859_6 = new k(ue.ISO8859_6, 8, "ISO-8859-6", "ISO88596", "ISO8859_6"), k.ISO8859_7 = new k(ue.ISO8859_7, 9, "ISO-8859-7", "ISO88597", "ISO8859_7"), k.ISO8859_8 = new k(ue.ISO8859_8, 10, "ISO-8859-8", "ISO88598", "ISO8859_8"), k.ISO8859_9 = new k(ue.ISO8859_9, 11, "ISO-8859-9", "ISO88599", "ISO8859_9"), k.ISO8859_10 = new k(ue.ISO8859_10, 12, "ISO-8859-10", "ISO885910", "ISO8859_10"), k.ISO8859_11 = new k(ue.ISO8859_11, 13, "ISO-8859-11", "ISO885911", "ISO8859_11"), k.ISO8859_13 = new k(ue.ISO8859_13, 15, "ISO-8859-13", "ISO885913", "ISO8859_13"), k.ISO8859_14 = new k(ue.ISO8859_14, 16, "ISO-8859-14", "ISO885914", "ISO8859_14"), k.ISO8859_15 = new k(ue.ISO8859_15, 17, "ISO-8859-15", "ISO885915", "ISO8859_15"), k.ISO8859_16 = new k(ue.ISO8859_16, 18, "ISO-8859-16", "ISO885916", "ISO8859_16"), k.SJIS = new k(ue.SJIS, 20, "SJIS", "Shift_JIS"), k.Cp1250 = new k(ue.Cp1250, 21, "Cp1250", "windows-1250"), k.Cp1251 = new k(ue.Cp1251, 22, "Cp1251", "windows-1251"), k.Cp1252 = new k(ue.Cp1252, 23, "Cp1252", "windows-1252"), k.Cp1256 = new k(ue.Cp1256, 24, "Cp1256", "windows-1256"), k.UnicodeBigUnmarked = new k(ue.UnicodeBigUnmarked, 25, "UnicodeBigUnmarked", "UTF-16BE", "UnicodeBig"), k.UTF8 = new k(ue.UTF8, 26, "UTF8", "UTF-8"), k.ASCII = new k(ue.ASCII, Int32Array.from([27, 170]), "ASCII", "US-ASCII"), k.Big5 = new k(ue.Big5, 28, "Big5"), k.GB18030 = new k(ue.GB18030, 29, "GB18030", "GB2312", "EUC_CN", "GBK"), k.EUC_KR = new k(ue.EUC_KR, 30, "EUC_KR", "EUC-KR"); class Ht extends w { } Ht.kind = "UnsupportedOperationException"; class Je { /** * Decodes some Uint8Array to a string format. */ static decode(e, t) { const n = this.encodingName(t); return this.customDecoder ? this.customDecoder(e, n) : typeof TextDecoder > "u" || this.shouldDecodeOnFallback(n) ? this.decodeFallback(e, n) : new TextDecoder(n).decode(e); } /** * Checks if the decoding method should use the fallback for decoding * once Node TextDecoder doesn't support all encoding formats. * * @param encodingName */ static shouldDecodeOnFallback(e) { return !Je.isBrowser() && e === "ISO-8859-1"; } /** * Encodes some string into a Uint8Array. */ static encode(e, t) { const n = this.encodingName(t); return this.customEncoder ? this.customEncoder(e, n) : typeof TextEncoder > "u" ? this.encodeFallback(e) : new TextEncoder().encode(e); } static isBrowser() { return typeof window < "u" && {}.toString.call(window) === "[object Window]"; } /** * Returns the string value from some encoding character set. */ static encodingName(e) { return typeof e == "string" ? e : e.getName(); } /** * Returns character set from some encoding character set. */ static encodingCharacterSet(e) { return e instanceof k ? e : k.getCharacterSetECIByName(e); } /** * Runs a fallback for the native decoding funcion. */ static decodeFallback(e, t) { const n = this.encodingCharacterSet(t); if (Je.isDecodeFallbackSupported(n)) { let r = ""; for (let i = 0, s = e.length; i < s; i++) { let o = e[i].toString(16); o.length < 2 && (o = "0" + o), r += "%" + o; } return decodeURIComponent(r); } if (n.equals(k.UnicodeBigUnmarked)) return String.fromCharCode.apply(null, new Uint16Array(e.buffer)); throw new Ht(`Encoding ${this.encodingName(t)} not supported by fallback.`); } static isDecodeFallbackSupported(e) { return e.equals(k.UTF8) || e.equals(k.ISO8859_1) || e.equals(k.ASCII); } /** * Runs a fallback for the native encoding funcion. * * @see https://stackoverflow.com/a/17192845/4367683 */ static encodeFallback(e) { const n = btoa(unescape(encodeURIComponent(e))).split(""), r = []; for (let i = 0; i < n.length; i++) r.push(n[i].charCodeAt(0)); return new Uint8Array(r); } } class q { // SHIFT_JIS.equalsIgnoreCase(PLATFORM_DEFAULT_ENCODING) || // EUC_JP.equalsIgnoreCase(PLATFORM_DEFAULT_ENCODING); static castAsNonUtf8Char(e, t = null) { const n = t ? t.getName() : this.ISO88591; return Je.decode(new Uint8Array([e]), n); } /** * @param bytes bytes encoding a string, whose encoding should be guessed * @param hints decode hints if applicable * @return name of guessed encoding; at the moment will only guess one of: * {@link #SHIFT_JIS}, {@link #UTF8}, {@link #ISO88591}, or the platform * default encoding if none of these can possibly be correct */ static guessEncoding(e, t) { if (t != null && t.get(xe.CHARACTER_SET) !== void 0) return t.get(xe.CHARACTER_SET).toString(); const n = e.length; let r = !0, i = !0, s = !0, o = 0, a = 0, l = 0, c = 0, u = 0, x = 0, C = 0, p = 0, b = 0, T = 0, _ = 0; const L = e.length > 3 && e[0] === /*(byte) */ 239 && e[1] === /*(byte) */ 187 && e[2] === /*(byte) */ 191; for (let F = 0; F < n && (r || i || s); F++) { const v = e[F] & 255; s && (o > 0 ? v & 128 ? o-- : s = !1 : v & 128 && (v & 64 ? (o++, v & 32 ? (o++, v & 16 ? (o++, v & 8 ? s = !1 : c++) : l++) : a++) : s = !1)), r && (v > 127 && v < 160 ? r = !1 : v > 159 && (v < 192 || v === 215 || v === 247) && _++), i && (u > 0 ? v < 64 || v === 127 || v > 252 ? i = !1 : u-- : v === 128 || v === 160 || v > 239 ? i = !1 : v > 160 && v < 224 ? (x++, p = 0, C++, C > b && (b = C)) : v > 127 ? (u++, C = 0, p++, p > T && (T = p)) : (C = 0, p = 0)); } return s && o > 0 && (s = !1), i && u > 0 && (i = !1), s && (L || a + l + c > 0) ? q.UTF8 : i && (q.ASSUME_SHIFT_JIS || b >= 3 || T >= 3) ? q.SHIFT_JIS : r && i ? b === 2 && x === 2 || _ * 10 >= n ? q.SHIFT_JIS : q.ISO88591 : r ? q.ISO88591 : i ? q.SHIFT_JIS : s ? q.UTF8 : q.PLATFORM_DEFAULT_ENCODING; } /** * * @see https://stackoverflow.com/a/13439711/4367683 * * @param append The new string to append. * @param args Argumets values to be formated. */ static format(e, ...t) { let n = -1; function r(s, o, a, l, c, u) { if (s === "%%") return "%"; if (t[++n] === void 0) return; s = l ? parseInt(l.substr(1)) : void 0; let x = c ? parseInt(c.substr(1)) : void 0, C; switch (u) { case "s": C = t[n]; break; case "c": C = t[n][0]; break; case "f": C = parseFloat(t[n]).toFixed(s); break; case "p": C = parseFloat(t[n]).toPrecision(s); break; case "e": C = parseFloat(t[n]).toExponential(s); break; case "x": C = parseInt(t[n]).toString(x || 16); break; case "d": C = parseFloat(parseInt(t[n], x || 10).toPrecision(s)).toFixed(0); break; } C = typeof C == "object" ? JSON.stringify(C) : (+C).toString(x); let p = parseInt(a), b = a && a[0] + "" == "0" ? "0" : " "; for (; C.length < p; ) C = o !== void 0 ? C + b : b + C; return C; } let i = /%(-)?(0?[0-9]+)?([.][0-9]+)?([#][0-9]+)?([scfpexd%])/g; return e.replace(i, r); } /** * */ static getBytes(e, t) { return Je.encode(e, t); } /** * Returns the charcode at the specified index or at index zero. */ static getCharCode(e, t = 0) { return e.charCodeAt(t); } /** * Returns char for given charcode */ static getCharAt(e) { return String.fromCharCode(e); } } q.SHIFT_JIS = k.SJIS.getName(), q.GB2312 = "GB2312", q.ISO88591 = k.ISO8859_1.getName(), q.EUC_JP = "EUC_JP", q.UTF8 = k.UTF8.getName(), q.PLATFORM_DEFAULT_ENCODING = q.UTF8, q.ASSUME_SHIFT_JIS = !1; class ge { constructor(e = "") { this.value = e; } enableDecoding(e) { return this.encoding = e, this; } append(e) { return typeof e == "string" ? this.value += e.toString() : this.encoding ? this.value += q.castAsNonUtf8Char(e, this.encoding) : this.value += String.fromCharCode(e), this; } appendChars(e, t, n) { for (let r = t; t < t + n; r++) this.append(e[r]); return this; } length() { return this.value.length; } charAt(e) { return this.value.charAt(e); } deleteCharAt(e) { this.value = this.value.substr(0, e) + this.value.substring(e + 1); } setCharAt(e, t) { this.value = this.value.substr(0, e) + t + this.value.substr(e + 1); } substring(e, t) { return this.value.substring(e, t); } /** * @note helper method for RSS Expanded */ setLengthToZero() { this.value = ""; } toString() { return this.value; } insert(e, t) { this.value = this.value.substr(0, e) + t + this.value.substr(e + t.length); } } class Le { /** * Creates an empty square {@link BitMatrix}. * * @param dimension height and width */ // public constructor(dimension: number /*int*/) { // this(dimension, dimension) // } /** * Creates an empty {@link BitMatrix}. * * @param width bit matrix width * @param height bit matrix height */ // public constructor(width: number /*int*/, height: number /*int*/) { // if (width < 1 || height < 1) { // throw new IllegalArgumentException("Both dimensions must be greater than 0") // } // this.width = width // this.height = height // this.rowSize = (width + 31) / 32 // bits = new int[rowSize * height]; // } constructor(e, t, n, r) { if (this.width = e, this.height = t, this.rowSize = n, this.bits = r, t == null && (t = e), this.height = t, e < 1 || t < 1) throw new R("Both dimensions must be greater than 0"); n == null && (n = Math.floor((e + 31) / 32)), this.rowSize = n, r == null && (this.bits = new Int32Array(this.rowSize * this.height)); } /** * Interprets a 2D array of booleans as a {@link BitMatrix}, where "true" means an "on" bit. * * @function parse * @param image bits of the image, as a row-major 2D array. Elements are arrays representing rows * @return {@link BitMatrix} representation of image */ static parseFromBooleanArray(e) { const t = e.length, n = e[0].length, r = new Le(n, t); for (let i = 0; i < t; i++) { const s = e[i]; for (let o = 0; o < n; o++) s[o] && r.set(o, i); } return r; } /** * * @function parse * @param stringRepresentation * @param setString * @param unsetString */ static parseFromString(e, t, n) { if (e === null) throw new R("stringRepresentation cannot be null"); const r = new Array(e.length); let i = 0, s = 0, o = -1, a = 0, l = 0; for (; l < e.length; ) if (e.charAt(l) === ` ` || e.charAt(l) === "\r") { if (i > s) { if (o === -1) o = i - s; else if (i - s !== o) throw new R("row lengths do not match"); s = i, a++; } l++; } else if (e.substring(l, l + t.length) === t) l += t.length, r[i] = !0, i++; else if (e.substring(l, l + n.length) === n) l += n.length, r[i] = !1, i++; else throw new R("illegal character encountered: " + e.substring(l)); if (i > s) { if (o === -1) o = i - s; else if (i - s !== o) throw new R("row lengths do not match"); a++; } const c = new Le(o, a); for (let u = 0; u < i; u++) r[u] && c.set(Math.floor(u % o), Math.floor(u / o)); return c; } /** * <p>Gets the requested bit, where true means black.</p> * * @param x The horizontal component (i.e. which column) * @param y The vertical component (i.e. which row) * @return value of given bit in matrix */ get(e, t) { const n = t * this.rowSize + Math.floor(e / 32); return (this.bits[n] >>> (e & 31) & 1) !== 0; } /** * <p>Sets the given bit to true.</p> * * @param x The horizontal component (i.e. which column) * @param y The vertical component (i.e. which row) */ set(e, t) { const n = t * this.rowSize + Math.floor(e / 32); this.bits[n] |= 1 << (e & 31) & 4294967295; } unset(e, t) { const n = t * this.rowSize + Math.floor(e / 32); this.bits[n] &= ~(1 << (e & 31) & 4294967295); } /** * <p>Flips the given bit.</p> * * @param x The horizontal component (i.e. which column) * @param y The vertical component (i.e. which row) */ flip(e, t) { const n = t * this.rowSize + Math.floor(e / 32); this.bits[n] ^= 1 << (e & 31) & 4294967295; } /** * Exclusive-or (XOR): Flip the bit in this {@code BitMatrix} if the corresponding * mask bit is set. * * @param mask XOR mask */ xor(e) { if (this.width !== e.getWidth() || this.height !== e.getHeight() || this.rowSize !== e.getRowSize()) throw new R("input matrix dimensions do not match"); const t = new ae(Math.floor(this.width / 32) + 1), n = this.rowSize, r = this.bits; for (let i = 0, s = this.height; i < s; i++) { const o = i * n, a = e.getRow(i, t).getBitArray(); for (let l = 0; l < n; l++) r[o + l] ^= a[l]; } } /** * Clears all bits (sets to false). */ clear() { const e = this.bits, t = e.length; for (let n = 0; n < t; n++) e[n] = 0; } /** * <p>Sets a square region of the bit matrix to true.</p> * * @param left The horizontal position to begin at (inclusive) * @param top The vertical position to begin at (inclusive) * @param width The width of the region * @param height The height of the region */ setRegion(e, t, n, r) { if (t < 0 || e < 0) throw new R("Left and top must be nonnegative"); if (r < 1 || n < 1) throw new R("Height and width must be at least 1"); const i = e + n, s = t + r; if (s > this.height || i > this.width) throw new R("The region must fit inside the matrix"); const o = this.rowSize, a = this.bits; for (let l = t; l < s; l++) { const c = l * o; for (let u = e; u < i; u++) a[c + Math.floor(u / 32)] |= 1 << (u & 31) & 4294967295; } } /** * A fast method to retrieve one row of data from the matrix as a BitArray. * * @param y The row to retrieve * @param row An optional caller-allocated BitArray, will be allocated if null or too small * @return The resulting BitArray - this reference should always be used even when passing * your own row */ getRow(e, t) { t == null || t.getSize() < this.width ? t = new ae(this.width) : t.clear(); const n = this.rowSize, r = this.bits, i = e * n; for (let s = 0; s < n; s++) t.setBulk(s * 32, r[i + s]); return t; } /** * @param y row to set * @param row {@link BitArray} to copy from */ setRow(e, t) { re.arraycopy(t.getBitArray(), 0, this.bits, e * this.rowSize, this.rowSize); } /** * Modifies this {@code BitMatrix} to represent the same but rotated 180 degrees */ rotate180() { const e = this.getWidth(), t = this.getHeight(); let n = new ae(e), r = new ae(e); for (let i = 0, s = Math.floor((t + 1) / 2); i < s; i++) n = this.getRow(i, n), r = this.getRow(t - 1 - i, r), n.reverse(), r.reverse(), this.setRow(i, r), this.setRow(t - 1 - i, n); } /** * This is useful in detecting the enclosing rectangle of a 'pure' barcode. * * @return {@code left,top,width,height} enclosing rectangle of all 1 bits, or null if it is all white */ getEnclosingRectangle() { const e = this.width, t = this.height, n = this.rowSize, r = this.bits; let i = e, s = t, o = -1, a = -1; for (let l = 0; l < t; l++) for (let c = 0; c < n; c++) { const u = r[l * n + c]; if (u !== 0) { if (l < s && (s = l), l > a && (a = l), c * 32 < i) { let x = 0; for (; !(u << 31 - x & 4294967295); ) x++; c * 32 + x < i && (i = c * 32 + x); } if (c * 32 + 31 > o) { let x = 31; for (; !(u >>> x); ) x--; c * 32 + x > o && (o = c * 32 + x); } } } return o < i || a < s ? null : Int32Array.from([i, s, o - i + 1, a - s + 1]); } /** * This is useful in detecting a corner of a 'pure' barcode. * * @return {@code x,y} coordinate of top-left-most 1 bit, or null if it is all white */ getTopLeftOnBit() { const e = this.rowSize, t = this.bits; let n = 0; for (; n < t.length && t[n] === 0; ) n++; if (n === t.length) return null; const r = n / e; let i = n % e * 32; const s = t[n]; let o = 0; for (; !(s << 31 - o & 4294967295); ) o++; return i += o, Int32Array.from([i, r]); } getBottomRightOnBit() { const e = this.rowSize, t = this.bits; let n = t.length - 1; for (; n >= 0 && t[n] === 0; ) n--; if (n < 0) return null; const r = Math.floor(n / e); let i = Math.floor(n % e) * 32; const s = t[n]; let o = 31; for (; !(s >>> o); ) o--; return i += o, Int32Array.from([i, r]); } /** * @return The width of the matrix */ getWidth() { return this.width; } /** * @return The height of the matrix */ getHeight() { return this.height; } /** * @return The row size of the matrix */ getRowSize() { return this.rowSize; } /*@Override*/ equals(e) { if (!(e instanceof Le)) return !1; const t = e; return this.width === t.width && this.height === t.height && this.rowSize === t.rowSize && me.equals(this.bits, t.bits); } /*@Override*/ hashCo