Orders by {@link FinderPattern#getCount()}, descending.
\n */\n // CenterComparator implements Comparator\n (center1, center2) => {\n if (center2.getCount() === center1.getCount()) {\n const dA = Math.abs(center2.getEstimatedModuleSize() - average);\n const dB = Math.abs(center1.getEstimatedModuleSize() - average);\n return dA < dB ? 1 : dA > dB ? -1 : 0;\n }\n else {\n return center2.getCount() - center1.getCount();\n }\n });\n possibleCenters.splice(3); // this is not realy necessary as we only return first 3 anyway\n }\n return [\n possibleCenters[0],\n possibleCenters[1],\n possibleCenters[2]\n ];\n }\n }\n FinderPatternFinder.CENTER_QUORUM = 2;\n FinderPatternFinder.MIN_SKIP = 3; // 1 pixel/module times 3 modules/center\n FinderPatternFinder.MAX_MODULES = 57; // support up to version 10 for mobile clients\n\n /*\n * Copyright 2007 ZXing authors\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n /*import java.util.Map;*/\n /**\n * Encapsulates logic that can detect a QR Code in an image, even if the QR Code\n * is rotated or skewed, or partially obscured.
\n *\n * @author Sean Owen\n */\n class Detector$2 {\n constructor(image) {\n this.image = image;\n }\n getImage() {\n return this.image;\n }\n getResultPointCallback() {\n return this.resultPointCallback;\n }\n /**\n * Detects a QR Code in an image.
\n *\n * @return {@link DetectorResult} encapsulating results of detecting a QR Code\n * @throws NotFoundException if QR Code cannot be found\n * @throws FormatException if a QR Code cannot be decoded\n */\n // public detect(): DetectorResult /*throws NotFoundException, FormatException*/ {\n // return detect(null)\n // }\n /**\n * Detects a QR Code in an image.
\n *\n * @param hints optional hints to detector\n * @return {@link DetectorResult} encapsulating results of detecting a QR Code\n * @throws NotFoundException if QR Code cannot be found\n * @throws FormatException if a QR Code cannot be decoded\n */\n detect(hints) {\n this.resultPointCallback = (hints === null || hints === undefined) ? null :\n /*(ResultPointCallback) */ hints.get(DecodeHintType$1.NEED_RESULT_POINT_CALLBACK);\n const finder = new FinderPatternFinder(this.image, this.resultPointCallback);\n const info = finder.find(hints);\n return this.processFinderPatternInfo(info);\n }\n processFinderPatternInfo(info) {\n const topLeft = info.getTopLeft();\n const topRight = info.getTopRight();\n const bottomLeft = info.getBottomLeft();\n const moduleSize = this.calculateModuleSize(topLeft, topRight, bottomLeft);\n if (moduleSize < 1.0) {\n throw new NotFoundException('No pattern found in proccess finder.');\n }\n const dimension = Detector$2.computeDimension(topLeft, topRight, bottomLeft, moduleSize);\n const provisionalVersion = Version$1.getProvisionalVersionForDimension(dimension);\n const modulesBetweenFPCenters = provisionalVersion.getDimensionForVersion() - 7;\n let alignmentPattern = null;\n // Anything above version 1 has an alignment pattern\n if (provisionalVersion.getAlignmentPatternCenters().length > 0) {\n // Guess where a \"bottom right\" finder pattern would have been\n const bottomRightX = topRight.getX() - topLeft.getX() + bottomLeft.getX();\n const bottomRightY = topRight.getY() - topLeft.getY() + bottomLeft.getY();\n // Estimate that alignment pattern is closer by 3 modules\n // from \"bottom right\" to known top left location\n const correctionToTopLeft = 1.0 - 3.0 / modulesBetweenFPCenters;\n const estAlignmentX = /*(int) */ Math.floor(topLeft.getX() + correctionToTopLeft * (bottomRightX - topLeft.getX()));\n const estAlignmentY = /*(int) */ Math.floor(topLeft.getY() + correctionToTopLeft * (bottomRightY - topLeft.getY()));\n // Kind of arbitrary -- expand search radius before giving up\n for (let i = 4; i <= 16; i <<= 1) {\n try {\n alignmentPattern = this.findAlignmentInRegion(moduleSize, estAlignmentX, estAlignmentY, i);\n break;\n }\n catch (re /*NotFoundException*/) {\n if (!(re instanceof NotFoundException)) {\n throw re;\n }\n // try next round\n }\n }\n // If we didn't find alignment pattern... well try anyway without it\n }\n const transform = Detector$2.createTransform(topLeft, topRight, bottomLeft, alignmentPattern, dimension);\n const bits = Detector$2.sampleGrid(this.image, transform, dimension);\n let points;\n if (alignmentPattern === null) {\n points = [bottomLeft, topLeft, topRight];\n }\n else {\n points = [bottomLeft, topLeft, topRight, alignmentPattern];\n }\n return new DetectorResult(bits, points);\n }\n static createTransform(topLeft, topRight, bottomLeft, alignmentPattern, dimension /*int*/) {\n const dimMinusThree = dimension - 3.5;\n let bottomRightX; /*float*/\n let bottomRightY; /*float*/\n let sourceBottomRightX; /*float*/\n let sourceBottomRightY; /*float*/\n if (alignmentPattern !== null) {\n bottomRightX = alignmentPattern.getX();\n bottomRightY = alignmentPattern.getY();\n sourceBottomRightX = dimMinusThree - 3.0;\n sourceBottomRightY = sourceBottomRightX;\n }\n else {\n // Don't have an alignment pattern, just make up the bottom-right point\n bottomRightX = (topRight.getX() - topLeft.getX()) + bottomLeft.getX();\n bottomRightY = (topRight.getY() - topLeft.getY()) + bottomLeft.getY();\n sourceBottomRightX = dimMinusThree;\n sourceBottomRightY = dimMinusThree;\n }\n return PerspectiveTransform.quadrilateralToQuadrilateral(3.5, 3.5, dimMinusThree, 3.5, sourceBottomRightX, sourceBottomRightY, 3.5, dimMinusThree, topLeft.getX(), topLeft.getY(), topRight.getX(), topRight.getY(), bottomRightX, bottomRightY, bottomLeft.getX(), bottomLeft.getY());\n }\n static sampleGrid(image, transform, dimension /*int*/) {\n const sampler = GridSamplerInstance.getInstance();\n return sampler.sampleGridWithTransform(image, dimension, dimension, transform);\n }\n /**\n * Computes the dimension (number of modules on a size) of the QR Code based on the position\n * of the finder patterns and estimated module size.
\n */\n static computeDimension(topLeft, topRight, bottomLeft, moduleSize /*float*/) {\n const tltrCentersDimension = MathUtils.round(ResultPoint.distance(topLeft, topRight) / moduleSize);\n const tlblCentersDimension = MathUtils.round(ResultPoint.distance(topLeft, bottomLeft) / moduleSize);\n let dimension = Math.floor((tltrCentersDimension + tlblCentersDimension) / 2) + 7;\n switch (dimension & 0x03) { // mod 4\n case 0:\n dimension++;\n break;\n // 1? do nothing\n case 2:\n dimension--;\n break;\n case 3:\n throw new NotFoundException('Dimensions could be not found.');\n }\n return dimension;\n }\n /**\n * Computes an average estimated module size based on estimated derived from the positions\n * of the three finder patterns.
\n *\n * @param topLeft detected top-left finder pattern center\n * @param topRight detected top-right finder pattern center\n * @param bottomLeft detected bottom-left finder pattern center\n * @return estimated module size\n */\n calculateModuleSize(topLeft, topRight, bottomLeft) {\n // Take the average\n return (this.calculateModuleSizeOneWay(topLeft, topRight) +\n this.calculateModuleSizeOneWay(topLeft, bottomLeft)) / 2.0;\n }\n /**\n * Estimates module size based on two finder patterns -- it uses\n * {@link #sizeOfBlackWhiteBlackRunBothWays(int, int, int, int)} to figure the\n * width of each, measuring along the axis between their centers.
\n */\n calculateModuleSizeOneWay(pattern, otherPattern) {\n const moduleSizeEst1 = this.sizeOfBlackWhiteBlackRunBothWays(/*(int) */ Math.floor(pattern.getX()), \n /*(int) */ Math.floor(pattern.getY()), \n /*(int) */ Math.floor(otherPattern.getX()), \n /*(int) */ Math.floor(otherPattern.getY()));\n const moduleSizeEst2 = this.sizeOfBlackWhiteBlackRunBothWays(/*(int) */ Math.floor(otherPattern.getX()), \n /*(int) */ Math.floor(otherPattern.getY()), \n /*(int) */ Math.floor(pattern.getX()), \n /*(int) */ Math.floor(pattern.getY()));\n if (isNaN(moduleSizeEst1)) {\n return moduleSizeEst2 / 7.0;\n }\n if (isNaN(moduleSizeEst2)) {\n return moduleSizeEst1 / 7.0;\n }\n // Average them, and divide by 7 since we've counted the width of 3 black modules,\n // and 1 white and 1 black module on either side. Ergo, divide sum by 14.\n return (moduleSizeEst1 + moduleSizeEst2) / 14.0;\n }\n /**\n * See {@link #sizeOfBlackWhiteBlackRun(int, int, int, int)}; computes the total width of\n * a finder pattern by looking for a black-white-black run from the center in the direction\n * of another point (another finder pattern center), and in the opposite direction too.\n */\n sizeOfBlackWhiteBlackRunBothWays(fromX /*int*/, fromY /*int*/, toX /*int*/, toY /*int*/) {\n let result = this.sizeOfBlackWhiteBlackRun(fromX, fromY, toX, toY);\n // Now count other way -- don't run off image though of course\n let scale = 1.0;\n let otherToX = fromX - (toX - fromX);\n if (otherToX < 0) {\n scale = fromX / /*(float) */ (fromX - otherToX);\n otherToX = 0;\n }\n else if (otherToX >= this.image.getWidth()) {\n scale = (this.image.getWidth() - 1 - fromX) / /*(float) */ (otherToX - fromX);\n otherToX = this.image.getWidth() - 1;\n }\n let otherToY = /*(int) */ Math.floor(fromY - (toY - fromY) * scale);\n scale = 1.0;\n if (otherToY < 0) {\n scale = fromY / /*(float) */ (fromY - otherToY);\n otherToY = 0;\n }\n else if (otherToY >= this.image.getHeight()) {\n scale = (this.image.getHeight() - 1 - fromY) / /*(float) */ (otherToY - fromY);\n otherToY = this.image.getHeight() - 1;\n }\n otherToX = /*(int) */ Math.floor(fromX + (otherToX - fromX) * scale);\n result += this.sizeOfBlackWhiteBlackRun(fromX, fromY, otherToX, otherToY);\n // Middle pixel is double-counted this way; subtract 1\n return result - 1.0;\n }\n /**\n * This method traces a line from a point in the image, in the direction towards another point.\n * It begins in a black region, and keeps going until it finds white, then black, then white again.\n * It reports the distance from the start to this point.
\n *\n * This is used when figuring out how wide a finder pattern is, when the finder pattern\n * may be skewed or rotated.
\n */\n sizeOfBlackWhiteBlackRun(fromX /*int*/, fromY /*int*/, toX /*int*/, toY /*int*/) {\n // Mild variant of Bresenham's algorithm\n // see http://en.wikipedia.org/wiki/Bresenham's_line_algorithm\n const steep = Math.abs(toY - fromY) > Math.abs(toX - fromX);\n if (steep) {\n let temp = fromX;\n fromX = fromY;\n fromY = temp;\n temp = toX;\n toX = toY;\n toY = temp;\n }\n const dx = Math.abs(toX - fromX);\n const dy = Math.abs(toY - fromY);\n let error = -dx / 2;\n const xstep = fromX < toX ? 1 : -1;\n const ystep = fromY < toY ? 1 : -1;\n // In black pixels, looking for white, first or second time.\n let state = 0;\n // Loop up until x == toX, but not beyond\n const xLimit = toX + xstep;\n for (let x = fromX, y = fromY; x !== xLimit; x += xstep) {\n const realX = steep ? y : x;\n const realY = steep ? x : y;\n // Does current pixel mean we have moved white to black or vice versa?\n // Scanning black in state 0,2 and white in state 1, so if we find the wrong\n // color, advance to next state or end if we are in state 2 already\n if ((state === 1) === this.image.get(realX, realY)) {\n if (state === 2) {\n return MathUtils.distance(x, y, fromX, fromY);\n }\n state++;\n }\n error += dy;\n if (error > 0) {\n if (y === toY) {\n break;\n }\n y += ystep;\n error -= dx;\n }\n }\n // Found black-white-black; give the benefit of the doubt that the next pixel outside the image\n // is \"white\" so this last point at (toX+xStep,toY) is the right ending. This is really a\n // small approximation; (toX+xStep,toY+yStep) might be really correct. Ignore this.\n if (state === 2) {\n return MathUtils.distance(toX + xstep, toY, fromX, fromY);\n }\n // else we didn't find even black-white-black; no estimate is really possible\n return NaN;\n }\n /**\n * Attempts to locate an alignment pattern in a limited region of the image, which is\n * guessed to contain it. This method uses {@link AlignmentPattern}.
\n *\n * @param overallEstModuleSize estimated module size so far\n * @param estAlignmentX x coordinate of center of area probably containing alignment pattern\n * @param estAlignmentY y coordinate of above\n * @param allowanceFactor number of pixels in all directions to search from the center\n * @return {@link AlignmentPattern} if found, or null otherwise\n * @throws NotFoundException if an unexpected error occurs during detection\n */\n findAlignmentInRegion(overallEstModuleSize /*float*/, estAlignmentX /*int*/, estAlignmentY /*int*/, allowanceFactor /*float*/) {\n // Look for an alignment pattern (3 modules in size) around where it\n // should be\n const allowance = /*(int) */ Math.floor(allowanceFactor * overallEstModuleSize);\n const alignmentAreaLeftX = Math.max(0, estAlignmentX - allowance);\n const alignmentAreaRightX = Math.min(this.image.getWidth() - 1, estAlignmentX + allowance);\n if (alignmentAreaRightX - alignmentAreaLeftX < overallEstModuleSize * 3) {\n throw new NotFoundException('Alignment top exceeds estimated module size.');\n }\n const alignmentAreaTopY = Math.max(0, estAlignmentY - allowance);\n const alignmentAreaBottomY = Math.min(this.image.getHeight() - 1, estAlignmentY + allowance);\n if (alignmentAreaBottomY - alignmentAreaTopY < overallEstModuleSize * 3) {\n throw new NotFoundException('Alignment bottom exceeds estimated module size.');\n }\n const alignmentFinder = new AlignmentPatternFinder(this.image, alignmentAreaLeftX, alignmentAreaTopY, alignmentAreaRightX - alignmentAreaLeftX, alignmentAreaBottomY - alignmentAreaTopY, overallEstModuleSize, this.resultPointCallback);\n return alignmentFinder.find();\n }\n }\n\n /*\n * Copyright 2007 ZXing authors\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n /*import java.util.List;*/\n /*import java.util.Map;*/\n /**\n * This implementation can detect and decode QR Codes in an image.\n *\n * @author Sean Owen\n */\n class QRCodeReader {\n constructor() {\n this.decoder = new Decoder$2();\n }\n getDecoder() {\n return this.decoder;\n }\n /**\n * Locates and decodes a QR code in an image.\n *\n * @return a representing: string the content encoded by the QR code\n * @throws NotFoundException if a QR code cannot be found\n * @throws FormatException if a QR code cannot be decoded\n * @throws ChecksumException if error correction fails\n */\n /*@Override*/\n // public decode(image: BinaryBitmap): Result /*throws NotFoundException, ChecksumException, FormatException */ {\n // return this.decode(image, null)\n // }\n /*@Override*/\n decode(image, hints) {\n let decoderResult;\n let points;\n if (hints !== undefined && hints !== null && undefined !== hints.get(DecodeHintType$1.PURE_BARCODE)) {\n const bits = QRCodeReader.extractPureBits(image.getBlackMatrix());\n decoderResult = this.decoder.decodeBitMatrix(bits, hints);\n points = QRCodeReader.NO_POINTS;\n }\n else {\n const detectorResult = new Detector$2(image.getBlackMatrix()).detect(hints);\n decoderResult = this.decoder.decodeBitMatrix(detectorResult.getBits(), hints);\n points = detectorResult.getPoints();\n }\n // If the code was mirrored: swap the bottom-left and the top-right points.\n if (decoderResult.getOther() instanceof QRCodeDecoderMetaData) {\n decoderResult.getOther().applyMirroredCorrection(points);\n }\n const result = new Result(decoderResult.getText(), decoderResult.getRawBytes(), undefined, points, BarcodeFormat$1.QR_CODE, undefined);\n const byteSegments = decoderResult.getByteSegments();\n if (byteSegments !== null) {\n result.putMetadata(ResultMetadataType$1.BYTE_SEGMENTS, byteSegments);\n }\n const ecLevel = decoderResult.getECLevel();\n if (ecLevel !== null) {\n result.putMetadata(ResultMetadataType$1.ERROR_CORRECTION_LEVEL, ecLevel);\n }\n if (decoderResult.hasStructuredAppend()) {\n result.putMetadata(ResultMetadataType$1.STRUCTURED_APPEND_SEQUENCE, decoderResult.getStructuredAppendSequenceNumber());\n result.putMetadata(ResultMetadataType$1.STRUCTURED_APPEND_PARITY, decoderResult.getStructuredAppendParity());\n }\n return result;\n }\n /*@Override*/\n reset() {\n // do nothing\n }\n /**\n * This method detects a code in a \"pure\" image -- that is, pure monochrome image\n * which contains only an unrotated, unskewed, image of a code, with some white border\n * around it. This is a specialized method that works exceptionally fast in this special\n * case.\n *\n * @see com.google.zxing.datamatrix.DataMatrixReader#extractPureBits(BitMatrix)\n */\n static extractPureBits(image) {\n const leftTopBlack = image.getTopLeftOnBit();\n const rightBottomBlack = image.getBottomRightOnBit();\n if (leftTopBlack === null || rightBottomBlack === null) {\n throw new NotFoundException();\n }\n const moduleSize = this.moduleSize(leftTopBlack, image);\n let top = leftTopBlack[1];\n let bottom = rightBottomBlack[1];\n let left = leftTopBlack[0];\n let right = rightBottomBlack[0];\n // Sanity check!\n if (left >= right || top >= bottom) {\n throw new NotFoundException();\n }\n if (bottom - top !== right - left) {\n // Special case, where bottom-right module wasn't black so we found something else in the last row\n // Assume it's a square, so use height as the width\n right = left + (bottom - top);\n if (right >= image.getWidth()) {\n // Abort if that would not make sense -- off image\n throw new NotFoundException();\n }\n }\n const matrixWidth = Math.round((right - left + 1) / moduleSize);\n const matrixHeight = Math.round((bottom - top + 1) / moduleSize);\n if (matrixWidth <= 0 || matrixHeight <= 0) {\n throw new NotFoundException();\n }\n if (matrixHeight !== matrixWidth) {\n // Only possibly decode square regions\n throw new NotFoundException();\n }\n // Push in the \"border\" by half the module width so that we start\n // sampling in the middle of the module. Just in case the image is a\n // little off, this will help recover.\n const nudge = /*(int) */ Math.floor(moduleSize / 2.0);\n top += nudge;\n left += nudge;\n // But careful that this does not sample off the edge\n // \"right\" is the farthest-right valid pixel location -- right+1 is not necessarily\n // This is positive by how much the inner x loop below would be too large\n const nudgedTooFarRight = left + /*(int) */ Math.floor((matrixWidth - 1) * moduleSize) - right;\n if (nudgedTooFarRight > 0) {\n if (nudgedTooFarRight > nudge) {\n // Neither way fits; abort\n throw new NotFoundException();\n }\n left -= nudgedTooFarRight;\n }\n // See logic above\n const nudgedTooFarDown = top + /*(int) */ Math.floor((matrixHeight - 1) * moduleSize) - bottom;\n if (nudgedTooFarDown > 0) {\n if (nudgedTooFarDown > nudge) {\n // Neither way fits; abort\n throw new NotFoundException();\n }\n top -= nudgedTooFarDown;\n }\n // Now just read off the bits\n const bits = new BitMatrix(matrixWidth, matrixHeight);\n for (let y = 0; y < matrixHeight; y++) {\n const iOffset = top + /*(int) */ Math.floor(y * moduleSize);\n for (let x = 0; x < matrixWidth; x++) {\n if (image.get(left + /*(int) */ Math.floor(x * moduleSize), iOffset)) {\n bits.set(x, y);\n }\n }\n }\n return bits;\n }\n static moduleSize(leftTopBlack, image) {\n const height = image.getHeight();\n const width = image.getWidth();\n let x = leftTopBlack[0];\n let y = leftTopBlack[1];\n let inBlack = true;\n let transitions = 0;\n while (x < width && y < height) {\n if (inBlack !== image.get(x, y)) {\n if (++transitions === 5) {\n break;\n }\n inBlack = !inBlack;\n }\n x++;\n y++;\n }\n if (x === width || y === height) {\n throw new NotFoundException();\n }\n return (x - leftTopBlack[0]) / 7.0;\n }\n }\n QRCodeReader.NO_POINTS = new Array();\n\n /*\n * Copyright 2009 ZXing authors\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n /**\n * @author SITA Lab (kevin.osullivan@sita.aero)\n * @author Guenther Grau\n */\n /*public final*/ class PDF417Common {\n PDF417Common() {\n }\n /**\n * @param moduleBitCount values to sum\n * @return sum of values\n * @deprecated call {@link MathUtils#sum(int[])}\n */\n // @Deprecated\n static getBitCountSum(moduleBitCount) {\n return MathUtils.sum(moduleBitCount);\n }\n static toIntArray(list) {\n if (list == null || !list.length) {\n return PDF417Common.EMPTY_INT_ARRAY;\n }\n const result = new Int32Array(list.length);\n let i = 0;\n for (const integer of list) {\n result[i++] = integer;\n }\n return result;\n }\n /**\n * @param symbol encoded symbol to translate to a codeword\n * @return the codeword corresponding to the symbol.\n */\n static getCodeword(symbol /*int*/) {\n const i = Arrays.binarySearch(PDF417Common.SYMBOL_TABLE, symbol & 0x3FFFF);\n if (i < 0) {\n return -1;\n }\n return (PDF417Common.CODEWORD_TABLE[i] - 1) % PDF417Common.NUMBER_OF_CODEWORDS;\n }\n }\n PDF417Common.NUMBER_OF_CODEWORDS = 929;\n // Maximum Codewords (Data + Error).\n PDF417Common.MAX_CODEWORDS_IN_BARCODE = PDF417Common.NUMBER_OF_CODEWORDS - 1;\n PDF417Common.MIN_ROWS_IN_BARCODE = 3;\n PDF417Common.MAX_ROWS_IN_BARCODE = 90;\n // One left row indication column + max 30 data columns + one right row indicator column\n // public static /*final*/ MAX_CODEWORDS_IN_ROW: /*int*/ number = 32;\n PDF417Common.MODULES_IN_CODEWORD = 17;\n PDF417Common.MODULES_IN_STOP_PATTERN = 18;\n PDF417Common.BARS_IN_MODULE = 8;\n PDF417Common.EMPTY_INT_ARRAY = new Int32Array([]);\n /**\n * The sorted table of all possible symbols. Extracted from the PDF417\n * specification. The index of a symbol in this table corresponds to the\n * index into the codeword table.\n */\n PDF417Common.SYMBOL_TABLE = Int32Array.from([\n 0x1025e, 0x1027a, 0x1029e, 0x102bc, 0x102f2, 0x102f4, 0x1032e, 0x1034e, 0x1035c, 0x10396, 0x103a6, 0x103ac,\n 0x10422, 0x10428, 0x10436, 0x10442, 0x10444, 0x10448, 0x10450, 0x1045e, 0x10466, 0x1046c, 0x1047a, 0x10482,\n 0x1049e, 0x104a0, 0x104bc, 0x104c6, 0x104d8, 0x104ee, 0x104f2, 0x104f4, 0x10504, 0x10508, 0x10510, 0x1051e,\n 0x10520, 0x1053c, 0x10540, 0x10578, 0x10586, 0x1058c, 0x10598, 0x105b0, 0x105be, 0x105ce, 0x105dc, 0x105e2,\n 0x105e4, 0x105e8, 0x105f6, 0x1062e, 0x1064e, 0x1065c, 0x1068e, 0x1069c, 0x106b8, 0x106de, 0x106fa, 0x10716,\n 0x10726, 0x1072c, 0x10746, 0x1074c, 0x10758, 0x1076e, 0x10792, 0x10794, 0x107a2, 0x107a4, 0x107a8, 0x107b6,\n 0x10822, 0x10828, 0x10842, 0x10848, 0x10850, 0x1085e, 0x10866, 0x1086c, 0x1087a, 0x10882, 0x10884, 0x10890,\n 0x1089e, 0x108a0, 0x108bc, 0x108c6, 0x108cc, 0x108d8, 0x108ee, 0x108f2, 0x108f4, 0x10902, 0x10908, 0x1091e,\n 0x10920, 0x1093c, 0x10940, 0x10978, 0x10986, 0x10998, 0x109b0, 0x109be, 0x109ce, 0x109dc, 0x109e2, 0x109e4,\n 0x109e8, 0x109f6, 0x10a08, 0x10a10, 0x10a1e, 0x10a20, 0x10a3c, 0x10a40, 0x10a78, 0x10af0, 0x10b06, 0x10b0c,\n 0x10b18, 0x10b30, 0x10b3e, 0x10b60, 0x10b7c, 0x10b8e, 0x10b9c, 0x10bb8, 0x10bc2, 0x10bc4, 0x10bc8, 0x10bd0,\n 0x10bde, 0x10be6, 0x10bec, 0x10c2e, 0x10c4e, 0x10c5c, 0x10c62, 0x10c64, 0x10c68, 0x10c76, 0x10c8e, 0x10c9c,\n 0x10cb8, 0x10cc2, 0x10cc4, 0x10cc8, 0x10cd0, 0x10cde, 0x10ce6, 0x10cec, 0x10cfa, 0x10d0e, 0x10d1c, 0x10d38,\n 0x10d70, 0x10d7e, 0x10d82, 0x10d84, 0x10d88, 0x10d90, 0x10d9e, 0x10da0, 0x10dbc, 0x10dc6, 0x10dcc, 0x10dd8,\n 0x10dee, 0x10df2, 0x10df4, 0x10e16, 0x10e26, 0x10e2c, 0x10e46, 0x10e58, 0x10e6e, 0x10e86, 0x10e8c, 0x10e98,\n 0x10eb0, 0x10ebe, 0x10ece, 0x10edc, 0x10f0a, 0x10f12, 0x10f14, 0x10f22, 0x10f28, 0x10f36, 0x10f42, 0x10f44,\n 0x10f48, 0x10f50, 0x10f5e, 0x10f66, 0x10f6c, 0x10fb2, 0x10fb4, 0x11022, 0x11028, 0x11042, 0x11048, 0x11050,\n 0x1105e, 0x1107a, 0x11082, 0x11084, 0x11090, 0x1109e, 0x110a0, 0x110bc, 0x110c6, 0x110cc, 0x110d8, 0x110ee,\n 0x110f2, 0x110f4, 0x11102, 0x1111e, 0x11120, 0x1113c, 0x11140, 0x11178, 0x11186, 0x11198, 0x111b0, 0x111be,\n 0x111ce, 0x111dc, 0x111e2, 0x111e4, 0x111e8, 0x111f6, 0x11208, 0x1121e, 0x11220, 0x11278, 0x112f0, 0x1130c,\n 0x11330, 0x1133e, 0x11360, 0x1137c, 0x1138e, 0x1139c, 0x113b8, 0x113c2, 0x113c8, 0x113d0, 0x113de, 0x113e6,\n 0x113ec, 0x11408, 0x11410, 0x1141e, 0x11420, 0x1143c, 0x11440, 0x11478, 0x114f0, 0x115e0, 0x1160c, 0x11618,\n 0x11630, 0x1163e, 0x11660, 0x1167c, 0x116c0, 0x116f8, 0x1171c, 0x11738, 0x11770, 0x1177e, 0x11782, 0x11784,\n 0x11788, 0x11790, 0x1179e, 0x117a0, 0x117bc, 0x117c6, 0x117cc, 0x117d8, 0x117ee, 0x1182e, 0x11834, 0x1184e,\n 0x1185c, 0x11862, 0x11864, 0x11868, 0x11876, 0x1188e, 0x1189c, 0x118b8, 0x118c2, 0x118c8, 0x118d0, 0x118de,\n 0x118e6, 0x118ec, 0x118fa, 0x1190e, 0x1191c, 0x11938, 0x11970, 0x1197e, 0x11982, 0x11984, 0x11990, 0x1199e,\n 0x119a0, 0x119bc, 0x119c6, 0x119cc, 0x119d8, 0x119ee, 0x119f2, 0x119f4, 0x11a0e, 0x11a1c, 0x11a38, 0x11a70,\n 0x11a7e, 0x11ae0, 0x11afc, 0x11b08, 0x11b10, 0x11b1e, 0x11b20, 0x11b3c, 0x11b40, 0x11b78, 0x11b8c, 0x11b98,\n 0x11bb0, 0x11bbe, 0x11bce, 0x11bdc, 0x11be2, 0x11be4, 0x11be8, 0x11bf6, 0x11c16, 0x11c26, 0x11c2c, 0x11c46,\n 0x11c4c, 0x11c58, 0x11c6e, 0x11c86, 0x11c98, 0x11cb0, 0x11cbe, 0x11cce, 0x11cdc, 0x11ce2, 0x11ce4, 0x11ce8,\n 0x11cf6, 0x11d06, 0x11d0c, 0x11d18, 0x11d30, 0x11d3e, 0x11d60, 0x11d7c, 0x11d8e, 0x11d9c, 0x11db8, 0x11dc4,\n 0x11dc8, 0x11dd0, 0x11dde, 0x11de6, 0x11dec, 0x11dfa, 0x11e0a, 0x11e12, 0x11e14, 0x11e22, 0x11e24, 0x11e28,\n 0x11e36, 0x11e42, 0x11e44, 0x11e50, 0x11e5e, 0x11e66, 0x11e6c, 0x11e82, 0x11e84, 0x11e88, 0x11e90, 0x11e9e,\n 0x11ea0, 0x11ebc, 0x11ec6, 0x11ecc, 0x11ed8, 0x11eee, 0x11f1a, 0x11f2e, 0x11f32, 0x11f34, 0x11f4e, 0x11f5c,\n 0x11f62, 0x11f64, 0x11f68, 0x11f76, 0x12048, 0x1205e, 0x12082, 0x12084, 0x12090, 0x1209e, 0x120a0, 0x120bc,\n 0x120d8, 0x120f2, 0x120f4, 0x12108, 0x1211e, 0x12120, 0x1213c, 0x12140, 0x12178, 0x12186, 0x12198, 0x121b0,\n 0x121be, 0x121e2, 0x121e4, 0x121e8, 0x121f6, 0x12204, 0x12210, 0x1221e, 0x12220, 0x12278, 0x122f0, 0x12306,\n 0x1230c, 0x12330, 0x1233e, 0x12360, 0x1237c, 0x1238e, 0x1239c, 0x123b8, 0x123c2, 0x123c8, 0x123d0, 0x123e6,\n 0x123ec, 0x1241e, 0x12420, 0x1243c, 0x124f0, 0x125e0, 0x12618, 0x1263e, 0x12660, 0x1267c, 0x126c0, 0x126f8,\n 0x12738, 0x12770, 0x1277e, 0x12782, 0x12784, 0x12790, 0x1279e, 0x127a0, 0x127bc, 0x127c6, 0x127cc, 0x127d8,\n 0x127ee, 0x12820, 0x1283c, 0x12840, 0x12878, 0x128f0, 0x129e0, 0x12bc0, 0x12c18, 0x12c30, 0x12c3e, 0x12c60,\n 0x12c7c, 0x12cc0, 0x12cf8, 0x12df0, 0x12e1c, 0x12e38, 0x12e70, 0x12e7e, 0x12ee0, 0x12efc, 0x12f04, 0x12f08,\n 0x12f10, 0x12f20, 0x12f3c, 0x12f40, 0x12f78, 0x12f86, 0x12f8c, 0x12f98, 0x12fb0, 0x12fbe, 0x12fce, 0x12fdc,\n 0x1302e, 0x1304e, 0x1305c, 0x13062, 0x13068, 0x1308e, 0x1309c, 0x130b8, 0x130c2, 0x130c8, 0x130d0, 0x130de,\n 0x130ec, 0x130fa, 0x1310e, 0x13138, 0x13170, 0x1317e, 0x13182, 0x13184, 0x13190, 0x1319e, 0x131a0, 0x131bc,\n 0x131c6, 0x131cc, 0x131d8, 0x131f2, 0x131f4, 0x1320e, 0x1321c, 0x13270, 0x1327e, 0x132e0, 0x132fc, 0x13308,\n 0x1331e, 0x13320, 0x1333c, 0x13340, 0x13378, 0x13386, 0x13398, 0x133b0, 0x133be, 0x133ce, 0x133dc, 0x133e2,\n 0x133e4, 0x133e8, 0x133f6, 0x1340e, 0x1341c, 0x13438, 0x13470, 0x1347e, 0x134e0, 0x134fc, 0x135c0, 0x135f8,\n 0x13608, 0x13610, 0x1361e, 0x13620, 0x1363c, 0x13640, 0x13678, 0x136f0, 0x1370c, 0x13718, 0x13730, 0x1373e,\n 0x13760, 0x1377c, 0x1379c, 0x137b8, 0x137c2, 0x137c4, 0x137c8, 0x137d0, 0x137de, 0x137e6, 0x137ec, 0x13816,\n 0x13826, 0x1382c, 0x13846, 0x1384c, 0x13858, 0x1386e, 0x13874, 0x13886, 0x13898, 0x138b0, 0x138be, 0x138ce,\n 0x138dc, 0x138e2, 0x138e4, 0x138e8, 0x13906, 0x1390c, 0x13930, 0x1393e, 0x13960, 0x1397c, 0x1398e, 0x1399c,\n 0x139b8, 0x139c8, 0x139d0, 0x139de, 0x139e6, 0x139ec, 0x139fa, 0x13a06, 0x13a0c, 0x13a18, 0x13a30, 0x13a3e,\n 0x13a60, 0x13a7c, 0x13ac0, 0x13af8, 0x13b0e, 0x13b1c, 0x13b38, 0x13b70, 0x13b7e, 0x13b88, 0x13b90, 0x13b9e,\n 0x13ba0, 0x13bbc, 0x13bcc, 0x13bd8, 0x13bee, 0x13bf2, 0x13bf4, 0x13c12, 0x13c14, 0x13c22, 0x13c24, 0x13c28,\n 0x13c36, 0x13c42, 0x13c48, 0x13c50, 0x13c5e, 0x13c66, 0x13c6c, 0x13c82, 0x13c84, 0x13c90, 0x13c9e, 0x13ca0,\n 0x13cbc, 0x13cc6, 0x13ccc, 0x13cd8, 0x13cee, 0x13d02, 0x13d04, 0x13d08, 0x13d10, 0x13d1e, 0x13d20, 0x13d3c,\n 0x13d40, 0x13d78, 0x13d86, 0x13d8c, 0x13d98, 0x13db0, 0x13dbe, 0x13dce, 0x13ddc, 0x13de4, 0x13de8, 0x13df6,\n 0x13e1a, 0x13e2e, 0x13e32, 0x13e34, 0x13e4e, 0x13e5c, 0x13e62, 0x13e64, 0x13e68, 0x13e76, 0x13e8e, 0x13e9c,\n 0x13eb8, 0x13ec2, 0x13ec4, 0x13ec8, 0x13ed0, 0x13ede, 0x13ee6, 0x13eec, 0x13f26, 0x13f2c, 0x13f3a, 0x13f46,\n 0x13f4c, 0x13f58, 0x13f6e, 0x13f72, 0x13f74, 0x14082, 0x1409e, 0x140a0, 0x140bc, 0x14104, 0x14108, 0x14110,\n 0x1411e, 0x14120, 0x1413c, 0x14140, 0x14178, 0x1418c, 0x14198, 0x141b0, 0x141be, 0x141e2, 0x141e4, 0x141e8,\n 0x14208, 0x14210, 0x1421e, 0x14220, 0x1423c, 0x14240, 0x14278, 0x142f0, 0x14306, 0x1430c, 0x14318, 0x14330,\n 0x1433e, 0x14360, 0x1437c, 0x1438e, 0x143c2, 0x143c4, 0x143c8, 0x143d0, 0x143e6, 0x143ec, 0x14408, 0x14410,\n 0x1441e, 0x14420, 0x1443c, 0x14440, 0x14478, 0x144f0, 0x145e0, 0x1460c, 0x14618, 0x14630, 0x1463e, 0x14660,\n 0x1467c, 0x146c0, 0x146f8, 0x1471c, 0x14738, 0x14770, 0x1477e, 0x14782, 0x14784, 0x14788, 0x14790, 0x147a0,\n 0x147bc, 0x147c6, 0x147cc, 0x147d8, 0x147ee, 0x14810, 0x14820, 0x1483c, 0x14840, 0x14878, 0x148f0, 0x149e0,\n 0x14bc0, 0x14c30, 0x14c3e, 0x14c60, 0x14c7c, 0x14cc0, 0x14cf8, 0x14df0, 0x14e38, 0x14e70, 0x14e7e, 0x14ee0,\n 0x14efc, 0x14f04, 0x14f08, 0x14f10, 0x14f1e, 0x14f20, 0x14f3c, 0x14f40, 0x14f78, 0x14f86, 0x14f8c, 0x14f98,\n 0x14fb0, 0x14fce, 0x14fdc, 0x15020, 0x15040, 0x15078, 0x150f0, 0x151e0, 0x153c0, 0x15860, 0x1587c, 0x158c0,\n 0x158f8, 0x159f0, 0x15be0, 0x15c70, 0x15c7e, 0x15ce0, 0x15cfc, 0x15dc0, 0x15df8, 0x15e08, 0x15e10, 0x15e20,\n 0x15e40, 0x15e78, 0x15ef0, 0x15f0c, 0x15f18, 0x15f30, 0x15f60, 0x15f7c, 0x15f8e, 0x15f9c, 0x15fb8, 0x1604e,\n 0x1605c, 0x1608e, 0x1609c, 0x160b8, 0x160c2, 0x160c4, 0x160c8, 0x160de, 0x1610e, 0x1611c, 0x16138, 0x16170,\n 0x1617e, 0x16184, 0x16188, 0x16190, 0x1619e, 0x161a0, 0x161bc, 0x161c6, 0x161cc, 0x161d8, 0x161f2, 0x161f4,\n 0x1620e, 0x1621c, 0x16238, 0x16270, 0x1627e, 0x162e0, 0x162fc, 0x16304, 0x16308, 0x16310, 0x1631e, 0x16320,\n 0x1633c, 0x16340, 0x16378, 0x16386, 0x1638c, 0x16398, 0x163b0, 0x163be, 0x163ce, 0x163dc, 0x163e2, 0x163e4,\n 0x163e8, 0x163f6, 0x1640e, 0x1641c, 0x16438, 0x16470, 0x1647e, 0x164e0, 0x164fc, 0x165c0, 0x165f8, 0x16610,\n 0x1661e, 0x16620, 0x1663c, 0x16640, 0x16678, 0x166f0, 0x16718, 0x16730, 0x1673e, 0x16760, 0x1677c, 0x1678e,\n 0x1679c, 0x167b8, 0x167c2, 0x167c4, 0x167c8, 0x167d0, 0x167de, 0x167e6, 0x167ec, 0x1681c, 0x16838, 0x16870,\n 0x168e0, 0x168fc, 0x169c0, 0x169f8, 0x16bf0, 0x16c10, 0x16c1e, 0x16c20, 0x16c3c, 0x16c40, 0x16c78, 0x16cf0,\n 0x16de0, 0x16e18, 0x16e30, 0x16e3e, 0x16e60, 0x16e7c, 0x16ec0, 0x16ef8, 0x16f1c, 0x16f38, 0x16f70, 0x16f7e,\n 0x16f84, 0x16f88, 0x16f90, 0x16f9e, 0x16fa0, 0x16fbc, 0x16fc6, 0x16fcc, 0x16fd8, 0x17026, 0x1702c, 0x17046,\n 0x1704c, 0x17058, 0x1706e, 0x17086, 0x1708c, 0x17098, 0x170b0, 0x170be, 0x170ce, 0x170dc, 0x170e8, 0x17106,\n 0x1710c, 0x17118, 0x17130, 0x1713e, 0x17160, 0x1717c, 0x1718e, 0x1719c, 0x171b8, 0x171c2, 0x171c4, 0x171c8,\n 0x171d0, 0x171de, 0x171e6, 0x171ec, 0x171fa, 0x17206, 0x1720c, 0x17218, 0x17230, 0x1723e, 0x17260, 0x1727c,\n 0x172c0, 0x172f8, 0x1730e, 0x1731c, 0x17338, 0x17370, 0x1737e, 0x17388, 0x17390, 0x1739e, 0x173a0, 0x173bc,\n 0x173cc, 0x173d8, 0x173ee, 0x173f2, 0x173f4, 0x1740c, 0x17418, 0x17430, 0x1743e, 0x17460, 0x1747c, 0x174c0,\n 0x174f8, 0x175f0, 0x1760e, 0x1761c, 0x17638, 0x17670, 0x1767e, 0x176e0, 0x176fc, 0x17708, 0x17710, 0x1771e,\n 0x17720, 0x1773c, 0x17740, 0x17778, 0x17798, 0x177b0, 0x177be, 0x177dc, 0x177e2, 0x177e4, 0x177e8, 0x17822,\n 0x17824, 0x17828, 0x17836, 0x17842, 0x17844, 0x17848, 0x17850, 0x1785e, 0x17866, 0x1786c, 0x17882, 0x17884,\n 0x17888, 0x17890, 0x1789e, 0x178a0, 0x178bc, 0x178c6, 0x178cc, 0x178d8, 0x178ee, 0x178f2, 0x178f4, 0x17902,\n 0x17904, 0x17908, 0x17910, 0x1791e, 0x17920, 0x1793c, 0x17940, 0x17978, 0x17986, 0x1798c, 0x17998, 0x179b0,\n 0x179be, 0x179ce, 0x179dc, 0x179e2, 0x179e4, 0x179e8, 0x179f6, 0x17a04, 0x17a08, 0x17a10, 0x17a1e, 0x17a20,\n 0x17a3c, 0x17a40, 0x17a78, 0x17af0, 0x17b06, 0x17b0c, 0x17b18, 0x17b30, 0x17b3e, 0x17b60, 0x17b7c, 0x17b8e,\n 0x17b9c, 0x17bb8, 0x17bc4, 0x17bc8, 0x17bd0, 0x17bde, 0x17be6, 0x17bec, 0x17c2e, 0x17c32, 0x17c34, 0x17c4e,\n 0x17c5c, 0x17c62, 0x17c64, 0x17c68, 0x17c76, 0x17c8e, 0x17c9c, 0x17cb8, 0x17cc2, 0x17cc4, 0x17cc8, 0x17cd0,\n 0x17cde, 0x17ce6, 0x17cec, 0x17d0e, 0x17d1c, 0x17d38, 0x17d70, 0x17d82, 0x17d84, 0x17d88, 0x17d90, 0x17d9e,\n 0x17da0, 0x17dbc, 0x17dc6, 0x17dcc, 0x17dd8, 0x17dee, 0x17e26, 0x17e2c, 0x17e3a, 0x17e46, 0x17e4c, 0x17e58,\n 0x17e6e, 0x17e72, 0x17e74, 0x17e86, 0x17e8c, 0x17e98, 0x17eb0, 0x17ece, 0x17edc, 0x17ee2, 0x17ee4, 0x17ee8,\n 0x17ef6, 0x1813a, 0x18172, 0x18174, 0x18216, 0x18226, 0x1823a, 0x1824c, 0x18258, 0x1826e, 0x18272, 0x18274,\n 0x18298, 0x182be, 0x182e2, 0x182e4, 0x182e8, 0x182f6, 0x1835e, 0x1837a, 0x183ae, 0x183d6, 0x18416, 0x18426,\n 0x1842c, 0x1843a, 0x18446, 0x18458, 0x1846e, 0x18472, 0x18474, 0x18486, 0x184b0, 0x184be, 0x184ce, 0x184dc,\n 0x184e2, 0x184e4, 0x184e8, 0x184f6, 0x18506, 0x1850c, 0x18518, 0x18530, 0x1853e, 0x18560, 0x1857c, 0x1858e,\n 0x1859c, 0x185b8, 0x185c2, 0x185c4, 0x185c8, 0x185d0, 0x185de, 0x185e6, 0x185ec, 0x185fa, 0x18612, 0x18614,\n 0x18622, 0x18628, 0x18636, 0x18642, 0x18650, 0x1865e, 0x1867a, 0x18682, 0x18684, 0x18688, 0x18690, 0x1869e,\n 0x186a0, 0x186bc, 0x186c6, 0x186cc, 0x186d8, 0x186ee, 0x186f2, 0x186f4, 0x1872e, 0x1874e, 0x1875c, 0x18796,\n 0x187a6, 0x187ac, 0x187d2, 0x187d4, 0x18826, 0x1882c, 0x1883a, 0x18846, 0x1884c, 0x18858, 0x1886e, 0x18872,\n 0x18874, 0x18886, 0x18898, 0x188b0, 0x188be, 0x188ce, 0x188dc, 0x188e2, 0x188e4, 0x188e8, 0x188f6, 0x1890c,\n 0x18930, 0x1893e, 0x18960, 0x1897c, 0x1898e, 0x189b8, 0x189c2, 0x189c8, 0x189d0, 0x189de, 0x189e6, 0x189ec,\n 0x189fa, 0x18a18, 0x18a30, 0x18a3e, 0x18a60, 0x18a7c, 0x18ac0, 0x18af8, 0x18b1c, 0x18b38, 0x18b70, 0x18b7e,\n 0x18b82, 0x18b84, 0x18b88, 0x18b90, 0x18b9e, 0x18ba0, 0x18bbc, 0x18bc6, 0x18bcc, 0x18bd8, 0x18bee, 0x18bf2,\n 0x18bf4, 0x18c22, 0x18c24, 0x18c28, 0x18c36, 0x18c42, 0x18c48, 0x18c50, 0x18c5e, 0x18c66, 0x18c7a, 0x18c82,\n 0x18c84, 0x18c90, 0x18c9e, 0x18ca0, 0x18cbc, 0x18ccc, 0x18cf2, 0x18cf4, 0x18d04, 0x18d08, 0x18d10, 0x18d1e,\n 0x18d20, 0x18d3c, 0x18d40, 0x18d78, 0x18d86, 0x18d98, 0x18dce, 0x18de2, 0x18de4, 0x18de8, 0x18e2e, 0x18e32,\n 0x18e34, 0x18e4e, 0x18e5c, 0x18e62, 0x18e64, 0x18e68, 0x18e8e, 0x18e9c, 0x18eb8, 0x18ec2, 0x18ec4, 0x18ec8,\n 0x18ed0, 0x18efa, 0x18f16, 0x18f26, 0x18f2c, 0x18f46, 0x18f4c, 0x18f58, 0x18f6e, 0x18f8a, 0x18f92, 0x18f94,\n 0x18fa2, 0x18fa4, 0x18fa8, 0x18fb6, 0x1902c, 0x1903a, 0x19046, 0x1904c, 0x19058, 0x19072, 0x19074, 0x19086,\n 0x19098, 0x190b0, 0x190be, 0x190ce, 0x190dc, 0x190e2, 0x190e8, 0x190f6, 0x19106, 0x1910c, 0x19130, 0x1913e,\n 0x19160, 0x1917c, 0x1918e, 0x1919c, 0x191b8, 0x191c2, 0x191c8, 0x191d0, 0x191de, 0x191e6, 0x191ec, 0x191fa,\n 0x19218, 0x1923e, 0x19260, 0x1927c, 0x192c0, 0x192f8, 0x19338, 0x19370, 0x1937e, 0x19382, 0x19384, 0x19390,\n 0x1939e, 0x193a0, 0x193bc, 0x193c6, 0x193cc, 0x193d8, 0x193ee, 0x193f2, 0x193f4, 0x19430, 0x1943e, 0x19460,\n 0x1947c, 0x194c0, 0x194f8, 0x195f0, 0x19638, 0x19670, 0x1967e, 0x196e0, 0x196fc, 0x19702, 0x19704, 0x19708,\n 0x19710, 0x19720, 0x1973c, 0x19740, 0x19778, 0x19786, 0x1978c, 0x19798, 0x197b0, 0x197be, 0x197ce, 0x197dc,\n 0x197e2, 0x197e4, 0x197e8, 0x19822, 0x19824, 0x19842, 0x19848, 0x19850, 0x1985e, 0x19866, 0x1987a, 0x19882,\n 0x19884, 0x19890, 0x1989e, 0x198a0, 0x198bc, 0x198cc, 0x198f2, 0x198f4, 0x19902, 0x19908, 0x1991e, 0x19920,\n 0x1993c, 0x19940, 0x19978, 0x19986, 0x19998, 0x199ce, 0x199e2, 0x199e4, 0x199e8, 0x19a08, 0x19a10, 0x19a1e,\n 0x19a20, 0x19a3c, 0x19a40, 0x19a78, 0x19af0, 0x19b18, 0x19b3e, 0x19b60, 0x19b9c, 0x19bc2, 0x19bc4, 0x19bc8,\n 0x19bd0, 0x19be6, 0x19c2e, 0x19c34, 0x19c4e, 0x19c5c, 0x19c62, 0x19c64, 0x19c68, 0x19c8e, 0x19c9c, 0x19cb8,\n 0x19cc2, 0x19cc8, 0x19cd0, 0x19ce6, 0x19cfa, 0x19d0e, 0x19d1c, 0x19d38, 0x19d70, 0x19d7e, 0x19d82, 0x19d84,\n 0x19d88, 0x19d90, 0x19da0, 0x19dcc, 0x19df2, 0x19df4, 0x19e16, 0x19e26, 0x19e2c, 0x19e46, 0x19e4c, 0x19e58,\n 0x19e74, 0x19e86, 0x19e8c, 0x19e98, 0x19eb0, 0x19ebe, 0x19ece, 0x19ee2, 0x19ee4, 0x19ee8, 0x19f0a, 0x19f12,\n 0x19f14, 0x19f22, 0x19f24, 0x19f28, 0x19f42, 0x19f44, 0x19f48, 0x19f50, 0x19f5e, 0x19f6c, 0x19f9a, 0x19fae,\n 0x19fb2, 0x19fb4, 0x1a046, 0x1a04c, 0x1a072, 0x1a074, 0x1a086, 0x1a08c, 0x1a098, 0x1a0b0, 0x1a0be, 0x1a0e2,\n 0x1a0e4, 0x1a0e8, 0x1a0f6, 0x1a106, 0x1a10c, 0x1a118, 0x1a130, 0x1a13e, 0x1a160, 0x1a17c, 0x1a18e, 0x1a19c,\n 0x1a1b8, 0x1a1c2, 0x1a1c4, 0x1a1c8, 0x1a1d0, 0x1a1de, 0x1a1e6, 0x1a1ec, 0x1a218, 0x1a230, 0x1a23e, 0x1a260,\n 0x1a27c, 0x1a2c0, 0x1a2f8, 0x1a31c, 0x1a338, 0x1a370, 0x1a37e, 0x1a382, 0x1a384, 0x1a388, 0x1a390, 0x1a39e,\n 0x1a3a0, 0x1a3bc, 0x1a3c6, 0x1a3cc, 0x1a3d8, 0x1a3ee, 0x1a3f2, 0x1a3f4, 0x1a418, 0x1a430, 0x1a43e, 0x1a460,\n 0x1a47c, 0x1a4c0, 0x1a4f8, 0x1a5f0, 0x1a61c, 0x1a638, 0x1a670, 0x1a67e, 0x1a6e0, 0x1a6fc, 0x1a702, 0x1a704,\n 0x1a708, 0x1a710, 0x1a71e, 0x1a720, 0x1a73c, 0x1a740, 0x1a778, 0x1a786, 0x1a78c, 0x1a798, 0x1a7b0, 0x1a7be,\n 0x1a7ce, 0x1a7dc, 0x1a7e2, 0x1a7e4, 0x1a7e8, 0x1a830, 0x1a860, 0x1a87c, 0x1a8c0, 0x1a8f8, 0x1a9f0, 0x1abe0,\n 0x1ac70, 0x1ac7e, 0x1ace0, 0x1acfc, 0x1adc0, 0x1adf8, 0x1ae04, 0x1ae08, 0x1ae10, 0x1ae20, 0x1ae3c, 0x1ae40,\n 0x1ae78, 0x1aef0, 0x1af06, 0x1af0c, 0x1af18, 0x1af30, 0x1af3e, 0x1af60, 0x1af7c, 0x1af8e, 0x1af9c, 0x1afb8,\n 0x1afc4, 0x1afc8, 0x1afd0, 0x1afde, 0x1b042, 0x1b05e, 0x1b07a, 0x1b082, 0x1b084, 0x1b088, 0x1b090, 0x1b09e,\n 0x1b0a0, 0x1b0bc, 0x1b0cc, 0x1b0f2, 0x1b0f4, 0x1b102, 0x1b104, 0x1b108, 0x1b110, 0x1b11e, 0x1b120, 0x1b13c,\n 0x1b140, 0x1b178, 0x1b186, 0x1b198, 0x1b1ce, 0x1b1e2, 0x1b1e4, 0x1b1e8, 0x1b204, 0x1b208, 0x1b210, 0x1b21e,\n 0x1b220, 0x1b23c, 0x1b240, 0x1b278, 0x1b2f0, 0x1b30c, 0x1b33e, 0x1b360, 0x1b39c, 0x1b3c2, 0x1b3c4, 0x1b3c8,\n 0x1b3d0, 0x1b3e6, 0x1b410, 0x1b41e, 0x1b420, 0x1b43c, 0x1b440, 0x1b478, 0x1b4f0, 0x1b5e0, 0x1b618, 0x1b660,\n 0x1b67c, 0x1b6c0, 0x1b738, 0x1b782, 0x1b784, 0x1b788, 0x1b790, 0x1b79e, 0x1b7a0, 0x1b7cc, 0x1b82e, 0x1b84e,\n 0x1b85c, 0x1b88e, 0x1b89c, 0x1b8b8, 0x1b8c2, 0x1b8c4, 0x1b8c8, 0x1b8d0, 0x1b8e6, 0x1b8fa, 0x1b90e, 0x1b91c,\n 0x1b938, 0x1b970, 0x1b97e, 0x1b982, 0x1b984, 0x1b988, 0x1b990, 0x1b99e, 0x1b9a0, 0x1b9cc, 0x1b9f2, 0x1b9f4,\n 0x1ba0e, 0x1ba1c, 0x1ba38, 0x1ba70, 0x1ba7e, 0x1bae0, 0x1bafc, 0x1bb08, 0x1bb10, 0x1bb20, 0x1bb3c, 0x1bb40,\n 0x1bb98, 0x1bbce, 0x1bbe2, 0x1bbe4, 0x1bbe8, 0x1bc16, 0x1bc26, 0x1bc2c, 0x1bc46, 0x1bc4c, 0x1bc58, 0x1bc72,\n 0x1bc74, 0x1bc86, 0x1bc8c, 0x1bc98, 0x1bcb0, 0x1bcbe, 0x1bcce, 0x1bce2, 0x1bce4, 0x1bce8, 0x1bd06, 0x1bd0c,\n 0x1bd18, 0x1bd30, 0x1bd3e, 0x1bd60, 0x1bd7c, 0x1bd9c, 0x1bdc2, 0x1bdc4, 0x1bdc8, 0x1bdd0, 0x1bde6, 0x1bdfa,\n 0x1be12, 0x1be14, 0x1be22, 0x1be24, 0x1be28, 0x1be42, 0x1be44, 0x1be48, 0x1be50, 0x1be5e, 0x1be66, 0x1be82,\n 0x1be84, 0x1be88, 0x1be90, 0x1be9e, 0x1bea0, 0x1bebc, 0x1becc, 0x1bef4, 0x1bf1a, 0x1bf2e, 0x1bf32, 0x1bf34,\n 0x1bf4e, 0x1bf5c, 0x1bf62, 0x1bf64, 0x1bf68, 0x1c09a, 0x1c0b2, 0x1c0b4, 0x1c11a, 0x1c132, 0x1c134, 0x1c162,\n 0x1c164, 0x1c168, 0x1c176, 0x1c1ba, 0x1c21a, 0x1c232, 0x1c234, 0x1c24e, 0x1c25c, 0x1c262, 0x1c264, 0x1c268,\n 0x1c276, 0x1c28e, 0x1c2c2, 0x1c2c4, 0x1c2c8, 0x1c2d0, 0x1c2de, 0x1c2e6, 0x1c2ec, 0x1c2fa, 0x1c316, 0x1c326,\n 0x1c33a, 0x1c346, 0x1c34c, 0x1c372, 0x1c374, 0x1c41a, 0x1c42e, 0x1c432, 0x1c434, 0x1c44e, 0x1c45c, 0x1c462,\n 0x1c464, 0x1c468, 0x1c476, 0x1c48e, 0x1c49c, 0x1c4b8, 0x1c4c2, 0x1c4c8, 0x1c4d0, 0x1c4de, 0x1c4e6, 0x1c4ec,\n 0x1c4fa, 0x1c51c, 0x1c538, 0x1c570, 0x1c57e, 0x1c582, 0x1c584, 0x1c588, 0x1c590, 0x1c59e, 0x1c5a0, 0x1c5bc,\n 0x1c5c6, 0x1c5cc, 0x1c5d8, 0x1c5ee, 0x1c5f2, 0x1c5f4, 0x1c616, 0x1c626, 0x1c62c, 0x1c63a, 0x1c646, 0x1c64c,\n 0x1c658, 0x1c66e, 0x1c672, 0x1c674, 0x1c686, 0x1c68c, 0x1c698, 0x1c6b0, 0x1c6be, 0x1c6ce, 0x1c6dc, 0x1c6e2,\n 0x1c6e4, 0x1c6e8, 0x1c712, 0x1c714, 0x1c722, 0x1c728, 0x1c736, 0x1c742, 0x1c744, 0x1c748, 0x1c750, 0x1c75e,\n 0x1c766, 0x1c76c, 0x1c77a, 0x1c7ae, 0x1c7d6, 0x1c7ea, 0x1c81a, 0x1c82e, 0x1c832, 0x1c834, 0x1c84e, 0x1c85c,\n 0x1c862, 0x1c864, 0x1c868, 0x1c876, 0x1c88e, 0x1c89c, 0x1c8b8, 0x1c8c2, 0x1c8c8, 0x1c8d0, 0x1c8de, 0x1c8e6,\n 0x1c8ec, 0x1c8fa, 0x1c90e, 0x1c938, 0x1c970, 0x1c97e, 0x1c982, 0x1c984, 0x1c990, 0x1c99e, 0x1c9a0, 0x1c9bc,\n 0x1c9c6, 0x1c9cc, 0x1c9d8, 0x1c9ee, 0x1c9f2, 0x1c9f4, 0x1ca38, 0x1ca70, 0x1ca7e, 0x1cae0, 0x1cafc, 0x1cb02,\n 0x1cb04, 0x1cb08, 0x1cb10, 0x1cb20, 0x1cb3c, 0x1cb40, 0x1cb78, 0x1cb86, 0x1cb8c, 0x1cb98, 0x1cbb0, 0x1cbbe,\n 0x1cbce, 0x1cbdc, 0x1cbe2, 0x1cbe4, 0x1cbe8, 0x1cbf6, 0x1cc16, 0x1cc26, 0x1cc2c, 0x1cc3a, 0x1cc46, 0x1cc58,\n 0x1cc72, 0x1cc74, 0x1cc86, 0x1ccb0, 0x1ccbe, 0x1ccce, 0x1cce2, 0x1cce4, 0x1cce8, 0x1cd06, 0x1cd0c, 0x1cd18,\n 0x1cd30, 0x1cd3e, 0x1cd60, 0x1cd7c, 0x1cd9c, 0x1cdc2, 0x1cdc4, 0x1cdc8, 0x1cdd0, 0x1cdde, 0x1cde6, 0x1cdfa,\n 0x1ce22, 0x1ce28, 0x1ce42, 0x1ce50, 0x1ce5e, 0x1ce66, 0x1ce7a, 0x1ce82, 0x1ce84, 0x1ce88, 0x1ce90, 0x1ce9e,\n 0x1cea0, 0x1cebc, 0x1cecc, 0x1cef2, 0x1cef4, 0x1cf2e, 0x1cf32, 0x1cf34, 0x1cf4e, 0x1cf5c, 0x1cf62, 0x1cf64,\n 0x1cf68, 0x1cf96, 0x1cfa6, 0x1cfac, 0x1cfca, 0x1cfd2, 0x1cfd4, 0x1d02e, 0x1d032, 0x1d034, 0x1d04e, 0x1d05c,\n 0x1d062, 0x1d064, 0x1d068, 0x1d076, 0x1d08e, 0x1d09c, 0x1d0b8, 0x1d0c2, 0x1d0c4, 0x1d0c8, 0x1d0d0, 0x1d0de,\n 0x1d0e6, 0x1d0ec, 0x1d0fa, 0x1d11c, 0x1d138, 0x1d170, 0x1d17e, 0x1d182, 0x1d184, 0x1d188, 0x1d190, 0x1d19e,\n 0x1d1a0, 0x1d1bc, 0x1d1c6, 0x1d1cc, 0x1d1d8, 0x1d1ee, 0x1d1f2, 0x1d1f4, 0x1d21c, 0x1d238, 0x1d270, 0x1d27e,\n 0x1d2e0, 0x1d2fc, 0x1d302, 0x1d304, 0x1d308, 0x1d310, 0x1d31e, 0x1d320, 0x1d33c, 0x1d340, 0x1d378, 0x1d386,\n 0x1d38c, 0x1d398, 0x1d3b0, 0x1d3be, 0x1d3ce, 0x1d3dc, 0x1d3e2, 0x1d3e4, 0x1d3e8, 0x1d3f6, 0x1d470, 0x1d47e,\n 0x1d4e0, 0x1d4fc, 0x1d5c0, 0x1d5f8, 0x1d604, 0x1d608, 0x1d610, 0x1d620, 0x1d640, 0x1d678, 0x1d6f0, 0x1d706,\n 0x1d70c, 0x1d718, 0x1d730, 0x1d73e, 0x1d760, 0x1d77c, 0x1d78e, 0x1d79c, 0x1d7b8, 0x1d7c2, 0x1d7c4, 0x1d7c8,\n 0x1d7d0, 0x1d7de, 0x1d7e6, 0x1d7ec, 0x1d826, 0x1d82c, 0x1d83a, 0x1d846, 0x1d84c, 0x1d858, 0x1d872, 0x1d874,\n 0x1d886, 0x1d88c, 0x1d898, 0x1d8b0, 0x1d8be, 0x1d8ce, 0x1d8e2, 0x1d8e4, 0x1d8e8, 0x1d8f6, 0x1d90c, 0x1d918,\n 0x1d930, 0x1d93e, 0x1d960, 0x1d97c, 0x1d99c, 0x1d9c2, 0x1d9c4, 0x1d9c8, 0x1d9d0, 0x1d9e6, 0x1d9fa, 0x1da0c,\n 0x1da18, 0x1da30, 0x1da3e, 0x1da60, 0x1da7c, 0x1dac0, 0x1daf8, 0x1db38, 0x1db82, 0x1db84, 0x1db88, 0x1db90,\n 0x1db9e, 0x1dba0, 0x1dbcc, 0x1dbf2, 0x1dbf4, 0x1dc22, 0x1dc42, 0x1dc44, 0x1dc48, 0x1dc50, 0x1dc5e, 0x1dc66,\n 0x1dc7a, 0x1dc82, 0x1dc84, 0x1dc88, 0x1dc90, 0x1dc9e, 0x1dca0, 0x1dcbc, 0x1dccc, 0x1dcf2, 0x1dcf4, 0x1dd04,\n 0x1dd08, 0x1dd10, 0x1dd1e, 0x1dd20, 0x1dd3c, 0x1dd40, 0x1dd78, 0x1dd86, 0x1dd98, 0x1ddce, 0x1dde2, 0x1dde4,\n 0x1dde8, 0x1de2e, 0x1de32, 0x1de34, 0x1de4e, 0x1de5c, 0x1de62, 0x1de64, 0x1de68, 0x1de8e, 0x1de9c, 0x1deb8,\n 0x1dec2, 0x1dec4, 0x1dec8, 0x1ded0, 0x1dee6, 0x1defa, 0x1df16, 0x1df26, 0x1df2c, 0x1df46, 0x1df4c, 0x1df58,\n 0x1df72, 0x1df74, 0x1df8a, 0x1df92, 0x1df94, 0x1dfa2, 0x1dfa4, 0x1dfa8, 0x1e08a, 0x1e092, 0x1e094, 0x1e0a2,\n 0x1e0a4, 0x1e0a8, 0x1e0b6, 0x1e0da, 0x1e10a, 0x1e112, 0x1e114, 0x1e122, 0x1e124, 0x1e128, 0x1e136, 0x1e142,\n 0x1e144, 0x1e148, 0x1e150, 0x1e166, 0x1e16c, 0x1e17a, 0x1e19a, 0x1e1b2, 0x1e1b4, 0x1e20a, 0x1e212, 0x1e214,\n 0x1e222, 0x1e224, 0x1e228, 0x1e236, 0x1e242, 0x1e248, 0x1e250, 0x1e25e, 0x1e266, 0x1e26c, 0x1e27a, 0x1e282,\n 0x1e284, 0x1e288, 0x1e290, 0x1e2a0, 0x1e2bc, 0x1e2c6, 0x1e2cc, 0x1e2d8, 0x1e2ee, 0x1e2f2, 0x1e2f4, 0x1e31a,\n 0x1e332, 0x1e334, 0x1e35c, 0x1e362, 0x1e364, 0x1e368, 0x1e3ba, 0x1e40a, 0x1e412, 0x1e414, 0x1e422, 0x1e428,\n 0x1e436, 0x1e442, 0x1e448, 0x1e450, 0x1e45e, 0x1e466, 0x1e46c, 0x1e47a, 0x1e482, 0x1e484, 0x1e490, 0x1e49e,\n 0x1e4a0, 0x1e4bc, 0x1e4c6, 0x1e4cc, 0x1e4d8, 0x1e4ee, 0x1e4f2, 0x1e4f4, 0x1e502, 0x1e504, 0x1e508, 0x1e510,\n 0x1e51e, 0x1e520, 0x1e53c, 0x1e540, 0x1e578, 0x1e586, 0x1e58c, 0x1e598, 0x1e5b0, 0x1e5be, 0x1e5ce, 0x1e5dc,\n 0x1e5e2, 0x1e5e4, 0x1e5e8, 0x1e5f6, 0x1e61a, 0x1e62e, 0x1e632, 0x1e634, 0x1e64e, 0x1e65c, 0x1e662, 0x1e668,\n 0x1e68e, 0x1e69c, 0x1e6b8, 0x1e6c2, 0x1e6c4, 0x1e6c8, 0x1e6d0, 0x1e6e6, 0x1e6fa, 0x1e716, 0x1e726, 0x1e72c,\n 0x1e73a, 0x1e746, 0x1e74c, 0x1e758, 0x1e772, 0x1e774, 0x1e792, 0x1e794, 0x1e7a2, 0x1e7a4, 0x1e7a8, 0x1e7b6,\n 0x1e812, 0x1e814, 0x1e822, 0x1e824, 0x1e828, 0x1e836, 0x1e842, 0x1e844, 0x1e848, 0x1e850, 0x1e85e, 0x1e866,\n 0x1e86c, 0x1e87a, 0x1e882, 0x1e884, 0x1e888, 0x1e890, 0x1e89e, 0x1e8a0, 0x1e8bc, 0x1e8c6, 0x1e8cc, 0x1e8d8,\n 0x1e8ee, 0x1e8f2, 0x1e8f4, 0x1e902, 0x1e904, 0x1e908, 0x1e910, 0x1e920, 0x1e93c, 0x1e940, 0x1e978, 0x1e986,\n 0x1e98c, 0x1e998, 0x1e9b0, 0x1e9be, 0x1e9ce, 0x1e9dc, 0x1e9e2, 0x1e9e4, 0x1e9e8, 0x1e9f6, 0x1ea04, 0x1ea08,\n 0x1ea10, 0x1ea20, 0x1ea40, 0x1ea78, 0x1eaf0, 0x1eb06, 0x1eb0c, 0x1eb18, 0x1eb30, 0x1eb3e, 0x1eb60, 0x1eb7c,\n 0x1eb8e, 0x1eb9c, 0x1ebb8, 0x1ebc2, 0x1ebc4, 0x1ebc8, 0x1ebd0, 0x1ebde, 0x1ebe6, 0x1ebec, 0x1ec1a, 0x1ec2e,\n 0x1ec32, 0x1ec34, 0x1ec4e, 0x1ec5c, 0x1ec62, 0x1ec64, 0x1ec68, 0x1ec8e, 0x1ec9c, 0x1ecb8, 0x1ecc2, 0x1ecc4,\n 0x1ecc8, 0x1ecd0, 0x1ece6, 0x1ecfa, 0x1ed0e, 0x1ed1c, 0x1ed38, 0x1ed70, 0x1ed7e, 0x1ed82, 0x1ed84, 0x1ed88,\n 0x1ed90, 0x1ed9e, 0x1eda0, 0x1edcc, 0x1edf2, 0x1edf4, 0x1ee16, 0x1ee26, 0x1ee2c, 0x1ee3a, 0x1ee46, 0x1ee4c,\n 0x1ee58, 0x1ee6e, 0x1ee72, 0x1ee74, 0x1ee86, 0x1ee8c, 0x1ee98, 0x1eeb0, 0x1eebe, 0x1eece, 0x1eedc, 0x1eee2,\n 0x1eee4, 0x1eee8, 0x1ef12, 0x1ef22, 0x1ef24, 0x1ef28, 0x1ef36, 0x1ef42, 0x1ef44, 0x1ef48, 0x1ef50, 0x1ef5e,\n 0x1ef66, 0x1ef6c, 0x1ef7a, 0x1efae, 0x1efb2, 0x1efb4, 0x1efd6, 0x1f096, 0x1f0a6, 0x1f0ac, 0x1f0ba, 0x1f0ca,\n 0x1f0d2, 0x1f0d4, 0x1f116, 0x1f126, 0x1f12c, 0x1f13a, 0x1f146, 0x1f14c, 0x1f158, 0x1f16e, 0x1f172, 0x1f174,\n 0x1f18a, 0x1f192, 0x1f194, 0x1f1a2, 0x1f1a4, 0x1f1a8, 0x1f1da, 0x1f216, 0x1f226, 0x1f22c, 0x1f23a, 0x1f246,\n 0x1f258, 0x1f26e, 0x1f272, 0x1f274, 0x1f286, 0x1f28c, 0x1f298, 0x1f2b0, 0x1f2be, 0x1f2ce, 0x1f2dc, 0x1f2e2,\n 0x1f2e4, 0x1f2e8, 0x1f2f6, 0x1f30a, 0x1f312, 0x1f314, 0x1f322, 0x1f328, 0x1f342, 0x1f344, 0x1f348, 0x1f350,\n 0x1f35e, 0x1f366, 0x1f37a, 0x1f39a, 0x1f3ae, 0x1f3b2, 0x1f3b4, 0x1f416, 0x1f426, 0x1f42c, 0x1f43a, 0x1f446,\n 0x1f44c, 0x1f458, 0x1f46e, 0x1f472, 0x1f474, 0x1f486, 0x1f48c, 0x1f498, 0x1f4b0, 0x1f4be, 0x1f4ce, 0x1f4dc,\n 0x1f4e2, 0x1f4e4, 0x1f4e8, 0x1f4f6, 0x1f506, 0x1f50c, 0x1f518, 0x1f530, 0x1f53e, 0x1f560, 0x1f57c, 0x1f58e,\n 0x1f59c, 0x1f5b8, 0x1f5c2, 0x1f5c4, 0x1f5c8, 0x1f5d0, 0x1f5de, 0x1f5e6, 0x1f5ec, 0x1f5fa, 0x1f60a, 0x1f612,\n 0x1f614, 0x1f622, 0x1f624, 0x1f628, 0x1f636, 0x1f642, 0x1f644, 0x1f648, 0x1f650, 0x1f65e, 0x1f666, 0x1f67a,\n 0x1f682, 0x1f684, 0x1f688, 0x1f690, 0x1f69e, 0x1f6a0, 0x1f6bc, 0x1f6cc, 0x1f6f2, 0x1f6f4, 0x1f71a, 0x1f72e,\n 0x1f732, 0x1f734, 0x1f74e, 0x1f75c, 0x1f762, 0x1f764, 0x1f768, 0x1f776, 0x1f796, 0x1f7a6, 0x1f7ac, 0x1f7ba,\n 0x1f7d2, 0x1f7d4, 0x1f89a, 0x1f8ae, 0x1f8b2, 0x1f8b4, 0x1f8d6, 0x1f8ea, 0x1f91a, 0x1f92e, 0x1f932, 0x1f934,\n 0x1f94e, 0x1f95c, 0x1f962, 0x1f964, 0x1f968, 0x1f976, 0x1f996, 0x1f9a6, 0x1f9ac, 0x1f9ba, 0x1f9ca, 0x1f9d2,\n 0x1f9d4, 0x1fa1a, 0x1fa2e, 0x1fa32, 0x1fa34, 0x1fa4e, 0x1fa5c, 0x1fa62, 0x1fa64, 0x1fa68, 0x1fa76, 0x1fa8e,\n 0x1fa9c, 0x1fab8, 0x1fac2, 0x1fac4, 0x1fac8, 0x1fad0, 0x1fade, 0x1fae6, 0x1faec, 0x1fb16, 0x1fb26, 0x1fb2c,\n 0x1fb3a, 0x1fb46, 0x1fb4c, 0x1fb58, 0x1fb6e, 0x1fb72, 0x1fb74, 0x1fb8a, 0x1fb92, 0x1fb94, 0x1fba2, 0x1fba4,\n 0x1fba8, 0x1fbb6, 0x1fbda\n ]);\n /**\n * This table contains to codewords for all symbols.\n */\n PDF417Common.CODEWORD_TABLE = Int32Array.from([\n 2627, 1819, 2622, 2621, 1813, 1812, 2729, 2724, 2723, 2779, 2774, 2773, 902, 896, 908, 868, 865, 861, 859, 2511,\n 873, 871, 1780, 835, 2493, 825, 2491, 842, 837, 844, 1764, 1762, 811, 810, 809, 2483, 807, 2482, 806, 2480, 815,\n 814, 813, 812, 2484, 817, 816, 1745, 1744, 1742, 1746, 2655, 2637, 2635, 2626, 2625, 2623, 2628, 1820, 2752,\n 2739, 2737, 2728, 2727, 2725, 2730, 2785, 2783, 2778, 2777, 2775, 2780, 787, 781, 747, 739, 736, 2413, 754, 752,\n 1719, 692, 689, 681, 2371, 678, 2369, 700, 697, 694, 703, 1688, 1686, 642, 638, 2343, 631, 2341, 627, 2338, 651,\n 646, 643, 2345, 654, 652, 1652, 1650, 1647, 1654, 601, 599, 2322, 596, 2321, 594, 2319, 2317, 611, 610, 608, 606,\n 2324, 603, 2323, 615, 614, 612, 1617, 1616, 1614, 1612, 616, 1619, 1618, 2575, 2538, 2536, 905, 901, 898, 909,\n 2509, 2507, 2504, 870, 867, 864, 860, 2512, 875, 872, 1781, 2490, 2489, 2487, 2485, 1748, 836, 834, 832, 830,\n 2494, 827, 2492, 843, 841, 839, 845, 1765, 1763, 2701, 2676, 2674, 2653, 2648, 2656, 2634, 2633, 2631, 2629,\n 1821, 2638, 2636, 2770, 2763, 2761, 2750, 2745, 2753, 2736, 2735, 2733, 2731, 1848, 2740, 2738, 2786, 2784, 591,\n 588, 576, 569, 566, 2296, 1590, 537, 534, 526, 2276, 522, 2274, 545, 542, 539, 548, 1572, 1570, 481, 2245, 466,\n 2242, 462, 2239, 492, 485, 482, 2249, 496, 494, 1534, 1531, 1528, 1538, 413, 2196, 406, 2191, 2188, 425, 419,\n 2202, 415, 2199, 432, 430, 427, 1472, 1467, 1464, 433, 1476, 1474, 368, 367, 2160, 365, 2159, 362, 2157, 2155,\n 2152, 378, 377, 375, 2166, 372, 2165, 369, 2162, 383, 381, 379, 2168, 1419, 1418, 1416, 1414, 385, 1411, 384,\n 1423, 1422, 1420, 1424, 2461, 802, 2441, 2439, 790, 786, 783, 794, 2409, 2406, 2403, 750, 742, 738, 2414, 756,\n 753, 1720, 2367, 2365, 2362, 2359, 1663, 693, 691, 684, 2373, 680, 2370, 702, 699, 696, 704, 1690, 1687, 2337,\n 2336, 2334, 2332, 1624, 2329, 1622, 640, 637, 2344, 634, 2342, 630, 2340, 650, 648, 645, 2346, 655, 653, 1653,\n 1651, 1649, 1655, 2612, 2597, 2595, 2571, 2568, 2565, 2576, 2534, 2529, 2526, 1787, 2540, 2537, 907, 904, 900,\n 910, 2503, 2502, 2500, 2498, 1768, 2495, 1767, 2510, 2508, 2506, 869, 866, 863, 2513, 876, 874, 1782, 2720, 2713,\n 2711, 2697, 2694, 2691, 2702, 2672, 2670, 2664, 1828, 2678, 2675, 2647, 2646, 2644, 2642, 1823, 2639, 1822, 2654,\n 2652, 2650, 2657, 2771, 1855, 2765, 2762, 1850, 1849, 2751, 2749, 2747, 2754, 353, 2148, 344, 342, 336, 2142,\n 332, 2140, 345, 1375, 1373, 306, 2130, 299, 2128, 295, 2125, 319, 314, 311, 2132, 1354, 1352, 1349, 1356, 262,\n 257, 2101, 253, 2096, 2093, 274, 273, 267, 2107, 263, 2104, 280, 278, 275, 1316, 1311, 1308, 1320, 1318, 2052,\n 202, 2050, 2044, 2040, 219, 2063, 212, 2060, 208, 2055, 224, 221, 2066, 1260, 1258, 1252, 231, 1248, 229, 1266,\n 1264, 1261, 1268, 155, 1998, 153, 1996, 1994, 1991, 1988, 165, 164, 2007, 162, 2006, 159, 2003, 2000, 172, 171,\n 169, 2012, 166, 2010, 1186, 1184, 1182, 1179, 175, 1176, 173, 1192, 1191, 1189, 1187, 176, 1194, 1193, 2313,\n 2307, 2305, 592, 589, 2294, 2292, 2289, 578, 572, 568, 2297, 580, 1591, 2272, 2267, 2264, 1547, 538, 536, 529,\n 2278, 525, 2275, 547, 544, 541, 1574, 1571, 2237, 2235, 2229, 1493, 2225, 1489, 478, 2247, 470, 2244, 465, 2241,\n 493, 488, 484, 2250, 498, 495, 1536, 1533, 1530, 1539, 2187, 2186, 2184, 2182, 1432, 2179, 1430, 2176, 1427, 414,\n 412, 2197, 409, 2195, 405, 2193, 2190, 426, 424, 421, 2203, 418, 2201, 431, 429, 1473, 1471, 1469, 1466, 434,\n 1477, 1475, 2478, 2472, 2470, 2459, 2457, 2454, 2462, 803, 2437, 2432, 2429, 1726, 2443, 2440, 792, 789, 785,\n 2401, 2399, 2393, 1702, 2389, 1699, 2411, 2408, 2405, 745, 741, 2415, 758, 755, 1721, 2358, 2357, 2355, 2353,\n 1661, 2350, 1660, 2347, 1657, 2368, 2366, 2364, 2361, 1666, 690, 687, 2374, 683, 2372, 701, 698, 705, 1691, 1689,\n 2619, 2617, 2610, 2608, 2605, 2613, 2593, 2588, 2585, 1803, 2599, 2596, 2563, 2561, 2555, 1797, 2551, 1795, 2573,\n 2570, 2567, 2577, 2525, 2524, 2522, 2520, 1786, 2517, 1785, 2514, 1783, 2535, 2533, 2531, 2528, 1788, 2541, 2539,\n 906, 903, 911, 2721, 1844, 2715, 2712, 1838, 1836, 2699, 2696, 2693, 2703, 1827, 1826, 1824, 2673, 2671, 2669,\n 2666, 1829, 2679, 2677, 1858, 1857, 2772, 1854, 1853, 1851, 1856, 2766, 2764, 143, 1987, 139, 1986, 135, 133,\n 131, 1984, 128, 1983, 125, 1981, 138, 137, 136, 1985, 1133, 1132, 1130, 112, 110, 1974, 107, 1973, 104, 1971,\n 1969, 122, 121, 119, 117, 1977, 114, 1976, 124, 1115, 1114, 1112, 1110, 1117, 1116, 84, 83, 1953, 81, 1952, 78,\n 1950, 1948, 1945, 94, 93, 91, 1959, 88, 1958, 85, 1955, 99, 97, 95, 1961, 1086, 1085, 1083, 1081, 1078, 100,\n 1090, 1089, 1087, 1091, 49, 47, 1917, 44, 1915, 1913, 1910, 1907, 59, 1926, 56, 1925, 53, 1922, 1919, 66, 64,\n 1931, 61, 1929, 1042, 1040, 1038, 71, 1035, 70, 1032, 68, 1048, 1047, 1045, 1043, 1050, 1049, 12, 10, 1869, 1867,\n 1864, 1861, 21, 1880, 19, 1877, 1874, 1871, 28, 1888, 25, 1886, 22, 1883, 982, 980, 977, 974, 32, 30, 991, 989,\n 987, 984, 34, 995, 994, 992, 2151, 2150, 2147, 2146, 2144, 356, 355, 354, 2149, 2139, 2138, 2136, 2134, 1359,\n 343, 341, 338, 2143, 335, 2141, 348, 347, 346, 1376, 1374, 2124, 2123, 2121, 2119, 1326, 2116, 1324, 310, 308,\n 305, 2131, 302, 2129, 298, 2127, 320, 318, 316, 313, 2133, 322, 321, 1355, 1353, 1351, 1357, 2092, 2091, 2089,\n 2087, 1276, 2084, 1274, 2081, 1271, 259, 2102, 256, 2100, 252, 2098, 2095, 272, 269, 2108, 266, 2106, 281, 279,\n 277, 1317, 1315, 1313, 1310, 282, 1321, 1319, 2039, 2037, 2035, 2032, 1203, 2029, 1200, 1197, 207, 2053, 205,\n 2051, 201, 2049, 2046, 2043, 220, 218, 2064, 215, 2062, 211, 2059, 228, 226, 223, 2069, 1259, 1257, 1254, 232,\n 1251, 230, 1267, 1265, 1263, 2316, 2315, 2312, 2311, 2309, 2314, 2304, 2303, 2301, 2299, 1593, 2308, 2306, 590,\n 2288, 2287, 2285, 2283, 1578, 2280, 1577, 2295, 2293, 2291, 579, 577, 574, 571, 2298, 582, 581, 1592, 2263, 2262,\n 2260, 2258, 1545, 2255, 1544, 2252, 1541, 2273, 2271, 2269, 2266, 1550, 535, 532, 2279, 528, 2277, 546, 543, 549,\n 1575, 1573, 2224, 2222, 2220, 1486, 2217, 1485, 2214, 1482, 1479, 2238, 2236, 2234, 2231, 1496, 2228, 1492, 480,\n 477, 2248, 473, 2246, 469, 2243, 490, 487, 2251, 497, 1537, 1535, 1532, 2477, 2476, 2474, 2479, 2469, 2468, 2466,\n 2464, 1730, 2473, 2471, 2453, 2452, 2450, 2448, 1729, 2445, 1728, 2460, 2458, 2456, 2463, 805, 804, 2428, 2427,\n 2425, 2423, 1725, 2420, 1724, 2417, 1722, 2438, 2436, 2434, 2431, 1727, 2444, 2442, 793, 791, 788, 795, 2388,\n 2386, 2384, 1697, 2381, 1696, 2378, 1694, 1692, 2402, 2400, 2398, 2395, 1703, 2392, 1701, 2412, 2410, 2407, 751,\n 748, 744, 2416, 759, 757, 1807, 2620, 2618, 1806, 1805, 2611, 2609, 2607, 2614, 1802, 1801, 1799, 2594, 2592,\n 2590, 2587, 1804, 2600, 2598, 1794, 1793, 1791, 1789, 2564, 2562, 2560, 2557, 1798, 2554, 1796, 2574, 2572, 2569,\n 2578, 1847, 1846, 2722, 1843, 1842, 1840, 1845, 2716, 2714, 1835, 1834, 1832, 1830, 1839, 1837, 2700, 2698, 2695,\n 2704, 1817, 1811, 1810, 897, 862, 1777, 829, 826, 838, 1760, 1758, 808, 2481, 1741, 1740, 1738, 1743, 2624, 1818,\n 2726, 2776, 782, 740, 737, 1715, 686, 679, 695, 1682, 1680, 639, 628, 2339, 647, 644, 1645, 1643, 1640, 1648,\n 602, 600, 597, 595, 2320, 593, 2318, 609, 607, 604, 1611, 1610, 1608, 1606, 613, 1615, 1613, 2328, 926, 924, 892,\n 886, 899, 857, 850, 2505, 1778, 824, 823, 821, 819, 2488, 818, 2486, 833, 831, 828, 840, 1761, 1759, 2649, 2632,\n 2630, 2746, 2734, 2732, 2782, 2781, 570, 567, 1587, 531, 527, 523, 540, 1566, 1564, 476, 467, 463, 2240, 486,\n 483, 1524, 1521, 1518, 1529, 411, 403, 2192, 399, 2189, 423, 416, 1462, 1457, 1454, 428, 1468, 1465, 2210, 366,\n 363, 2158, 360, 2156, 357, 2153, 376, 373, 370, 2163, 1410, 1409, 1407, 1405, 382, 1402, 380, 1417, 1415, 1412,\n 1421, 2175, 2174, 777, 774, 771, 784, 732, 725, 722, 2404, 743, 1716, 676, 674, 668, 2363, 665, 2360, 685, 1684,\n 1681, 626, 624, 622, 2335, 620, 2333, 617, 2330, 641, 635, 649, 1646, 1644, 1642, 2566, 928, 925, 2530, 2527,\n 894, 891, 888, 2501, 2499, 2496, 858, 856, 854, 851, 1779, 2692, 2668, 2665, 2645, 2643, 2640, 2651, 2768, 2759,\n 2757, 2744, 2743, 2741, 2748, 352, 1382, 340, 337, 333, 1371, 1369, 307, 300, 296, 2126, 315, 312, 1347, 1342,\n 1350, 261, 258, 250, 2097, 246, 2094, 271, 268, 264, 1306, 1301, 1298, 276, 1312, 1309, 2115, 203, 2048, 195,\n 2045, 191, 2041, 213, 209, 2056, 1246, 1244, 1238, 225, 1234, 222, 1256, 1253, 1249, 1262, 2080, 2079, 154, 1997,\n 150, 1995, 147, 1992, 1989, 163, 160, 2004, 156, 2001, 1175, 1174, 1172, 1170, 1167, 170, 1164, 167, 1185, 1183,\n 1180, 1177, 174, 1190, 1188, 2025, 2024, 2022, 587, 586, 564, 559, 556, 2290, 573, 1588, 520, 518, 512, 2268,\n 508, 2265, 530, 1568, 1565, 461, 457, 2233, 450, 2230, 446, 2226, 479, 471, 489, 1526, 1523, 1520, 397, 395,\n 2185, 392, 2183, 389, 2180, 2177, 410, 2194, 402, 422, 1463, 1461, 1459, 1456, 1470, 2455, 799, 2433, 2430, 779,\n 776, 773, 2397, 2394, 2390, 734, 728, 724, 746, 1717, 2356, 2354, 2351, 2348, 1658, 677, 675, 673, 670, 667, 688,\n 1685, 1683, 2606, 2589, 2586, 2559, 2556, 2552, 927, 2523, 2521, 2518, 2515, 1784, 2532, 895, 893, 890, 2718,\n 2709, 2707, 2689, 2687, 2684, 2663, 2662, 2660, 2658, 1825, 2667, 2769, 1852, 2760, 2758, 142, 141, 1139, 1138,\n 134, 132, 129, 126, 1982, 1129, 1128, 1126, 1131, 113, 111, 108, 105, 1972, 101, 1970, 120, 118, 115, 1109, 1108,\n 1106, 1104, 123, 1113, 1111, 82, 79, 1951, 75, 1949, 72, 1946, 92, 89, 86, 1956, 1077, 1076, 1074, 1072, 98,\n 1069, 96, 1084, 1082, 1079, 1088, 1968, 1967, 48, 45, 1916, 42, 1914, 39, 1911, 1908, 60, 57, 54, 1923, 50, 1920,\n 1031, 1030, 1028, 1026, 67, 1023, 65, 1020, 62, 1041, 1039, 1036, 1033, 69, 1046, 1044, 1944, 1943, 1941, 11, 9,\n 1868, 7, 1865, 1862, 1859, 20, 1878, 16, 1875, 13, 1872, 970, 968, 966, 963, 29, 960, 26, 23, 983, 981, 978, 975,\n 33, 971, 31, 990, 988, 985, 1906, 1904, 1902, 993, 351, 2145, 1383, 331, 330, 328, 326, 2137, 323, 2135, 339,\n 1372, 1370, 294, 293, 291, 289, 2122, 286, 2120, 283, 2117, 309, 303, 317, 1348, 1346, 1344, 245, 244, 242, 2090,\n 239, 2088, 236, 2085, 2082, 260, 2099, 249, 270, 1307, 1305, 1303, 1300, 1314, 189, 2038, 186, 2036, 183, 2033,\n 2030, 2026, 206, 198, 2047, 194, 216, 1247, 1245, 1243, 1240, 227, 1237, 1255, 2310, 2302, 2300, 2286, 2284,\n 2281, 565, 563, 561, 558, 575, 1589, 2261, 2259, 2256, 2253, 1542, 521, 519, 517, 514, 2270, 511, 533, 1569,\n 1567, 2223, 2221, 2218, 2215, 1483, 2211, 1480, 459, 456, 453, 2232, 449, 474, 491, 1527, 1525, 1522, 2475, 2467,\n 2465, 2451, 2449, 2446, 801, 800, 2426, 2424, 2421, 2418, 1723, 2435, 780, 778, 775, 2387, 2385, 2382, 2379,\n 1695, 2375, 1693, 2396, 735, 733, 730, 727, 749, 1718, 2616, 2615, 2604, 2603, 2601, 2584, 2583, 2581, 2579,\n 1800, 2591, 2550, 2549, 2547, 2545, 1792, 2542, 1790, 2558, 929, 2719, 1841, 2710, 2708, 1833, 1831, 2690, 2688,\n 2686, 1815, 1809, 1808, 1774, 1756, 1754, 1737, 1736, 1734, 1739, 1816, 1711, 1676, 1674, 633, 629, 1638, 1636,\n 1633, 1641, 598, 1605, 1604, 1602, 1600, 605, 1609, 1607, 2327, 887, 853, 1775, 822, 820, 1757, 1755, 1584, 524,\n 1560, 1558, 468, 464, 1514, 1511, 1508, 1519, 408, 404, 400, 1452, 1447, 1444, 417, 1458, 1455, 2208, 364, 361,\n 358, 2154, 1401, 1400, 1398, 1396, 374, 1393, 371, 1408, 1406, 1403, 1413, 2173, 2172, 772, 726, 723, 1712, 672,\n 669, 666, 682, 1678, 1675, 625, 623, 621, 618, 2331, 636, 632, 1639, 1637, 1635, 920, 918, 884, 880, 889, 849,\n 848, 847, 846, 2497, 855, 852, 1776, 2641, 2742, 2787, 1380, 334, 1367, 1365, 301, 297, 1340, 1338, 1335, 1343,\n 255, 251, 247, 1296, 1291, 1288, 265, 1302, 1299, 2113, 204, 196, 192, 2042, 1232, 1230, 1224, 214, 1220, 210,\n 1242, 1239, 1235, 1250, 2077, 2075, 151, 148, 1993, 144, 1990, 1163, 1162, 1160, 1158, 1155, 161, 1152, 157,\n 1173, 1171, 1168, 1165, 168, 1181, 1178, 2021, 2020, 2018, 2023, 585, 560, 557, 1585, 516, 509, 1562, 1559, 458,\n 447, 2227, 472, 1516, 1513, 1510, 398, 396, 393, 390, 2181, 386, 2178, 407, 1453, 1451, 1449, 1446, 420, 1460,\n 2209, 769, 764, 720, 712, 2391, 729, 1713, 664, 663, 661, 659, 2352, 656, 2349, 671, 1679, 1677, 2553, 922, 919,\n 2519, 2516, 885, 883, 881, 2685, 2661, 2659, 2767, 2756, 2755, 140, 1137, 1136, 130, 127, 1125, 1124, 1122, 1127,\n 109, 106, 102, 1103, 1102, 1100, 1098, 116, 1107, 1105, 1980, 80, 76, 73, 1947, 1068, 1067, 1065, 1063, 90, 1060,\n 87, 1075, 1073, 1070, 1080, 1966, 1965, 46, 43, 40, 1912, 36, 1909, 1019, 1018, 1016, 1014, 58, 1011, 55, 1008,\n 51, 1029, 1027, 1024, 1021, 63, 1037, 1034, 1940, 1939, 1937, 1942, 8, 1866, 4, 1863, 1, 1860, 956, 954, 952,\n 949, 946, 17, 14, 969, 967, 964, 961, 27, 957, 24, 979, 976, 972, 1901, 1900, 1898, 1896, 986, 1905, 1903, 350,\n 349, 1381, 329, 327, 324, 1368, 1366, 292, 290, 287, 284, 2118, 304, 1341, 1339, 1337, 1345, 243, 240, 237, 2086,\n 233, 2083, 254, 1297, 1295, 1293, 1290, 1304, 2114, 190, 187, 184, 2034, 180, 2031, 177, 2027, 199, 1233, 1231,\n 1229, 1226, 217, 1223, 1241, 2078, 2076, 584, 555, 554, 552, 550, 2282, 562, 1586, 507, 506, 504, 502, 2257, 499,\n 2254, 515, 1563, 1561, 445, 443, 441, 2219, 438, 2216, 435, 2212, 460, 454, 475, 1517, 1515, 1512, 2447, 798,\n 797, 2422, 2419, 770, 768, 766, 2383, 2380, 2376, 721, 719, 717, 714, 731, 1714, 2602, 2582, 2580, 2548, 2546,\n 2543, 923, 921, 2717, 2706, 2705, 2683, 2682, 2680, 1771, 1752, 1750, 1733, 1732, 1731, 1735, 1814, 1707, 1670,\n 1668, 1631, 1629, 1626, 1634, 1599, 1598, 1596, 1594, 1603, 1601, 2326, 1772, 1753, 1751, 1581, 1554, 1552, 1504,\n 1501, 1498, 1509, 1442, 1437, 1434, 401, 1448, 1445, 2206, 1392, 1391, 1389, 1387, 1384, 359, 1399, 1397, 1394,\n 1404, 2171, 2170, 1708, 1672, 1669, 619, 1632, 1630, 1628, 1773, 1378, 1363, 1361, 1333, 1328, 1336, 1286, 1281,\n 1278, 248, 1292, 1289, 2111, 1218, 1216, 1210, 197, 1206, 193, 1228, 1225, 1221, 1236, 2073, 2071, 1151, 1150,\n 1148, 1146, 152, 1143, 149, 1140, 145, 1161, 1159, 1156, 1153, 158, 1169, 1166, 2017, 2016, 2014, 2019, 1582,\n 510, 1556, 1553, 452, 448, 1506, 1500, 394, 391, 387, 1443, 1441, 1439, 1436, 1450, 2207, 765, 716, 713, 1709,\n 662, 660, 657, 1673, 1671, 916, 914, 879, 878, 877, 882, 1135, 1134, 1121, 1120, 1118, 1123, 1097, 1096, 1094,\n 1092, 103, 1101, 1099, 1979, 1059, 1058, 1056, 1054, 77, 1051, 74, 1066, 1064, 1061, 1071, 1964, 1963, 1007,\n 1006, 1004, 1002, 999, 41, 996, 37, 1017, 1015, 1012, 1009, 52, 1025, 1022, 1936, 1935, 1933, 1938, 942, 940,\n 938, 935, 932, 5, 2, 955, 953, 950, 947, 18, 943, 15, 965, 962, 958, 1895, 1894, 1892, 1890, 973, 1899, 1897,\n 1379, 325, 1364, 1362, 288, 285, 1334, 1332, 1330, 241, 238, 234, 1287, 1285, 1283, 1280, 1294, 2112, 188, 185,\n 181, 178, 2028, 1219, 1217, 1215, 1212, 200, 1209, 1227, 2074, 2072, 583, 553, 551, 1583, 505, 503, 500, 513,\n 1557, 1555, 444, 442, 439, 436, 2213, 455, 451, 1507, 1505, 1502, 796, 763, 762, 760, 767, 711, 710, 708, 706,\n 2377, 718, 715, 1710, 2544, 917, 915, 2681, 1627, 1597, 1595, 2325, 1769, 1749, 1747, 1499, 1438, 1435, 2204,\n 1390, 1388, 1385, 1395, 2169, 2167, 1704, 1665, 1662, 1625, 1623, 1620, 1770, 1329, 1282, 1279, 2109, 1214, 1207,\n 1222, 2068, 2065, 1149, 1147, 1144, 1141, 146, 1157, 1154, 2013, 2011, 2008, 2015, 1579, 1549, 1546, 1495, 1487,\n 1433, 1431, 1428, 1425, 388, 1440, 2205, 1705, 658, 1667, 1664, 1119, 1095, 1093, 1978, 1057, 1055, 1052, 1062,\n 1962, 1960, 1005, 1003, 1000, 997, 38, 1013, 1010, 1932, 1930, 1927, 1934, 941, 939, 936, 933, 6, 930, 3, 951,\n 948, 944, 1889, 1887, 1884, 1881, 959, 1893, 1891, 35, 1377, 1360, 1358, 1327, 1325, 1322, 1331, 1277, 1275,\n 1272, 1269, 235, 1284, 2110, 1205, 1204, 1201, 1198, 182, 1195, 179, 1213, 2070, 2067, 1580, 501, 1551, 1548,\n 440, 437, 1497, 1494, 1490, 1503, 761, 709, 707, 1706, 913, 912, 2198, 1386, 2164, 2161, 1621, 1766, 2103, 1208,\n 2058, 2054, 1145, 1142, 2005, 2002, 1999, 2009, 1488, 1429, 1426, 2200, 1698, 1659, 1656, 1975, 1053, 1957, 1954,\n 1001, 998, 1924, 1921, 1918, 1928, 937, 934, 931, 1879, 1876, 1873, 1870, 945, 1885, 1882, 1323, 1273, 1270,\n 2105, 1202, 1199, 1196, 1211, 2061, 2057, 1576, 1543, 1540, 1484, 1481, 1478, 1491, 1700\n ]);\n\n /*\n * Copyright 2007 ZXing authors\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n // import java.util.List;\n /**\n * @author Guenther Grau\n */\n /*public final*/ class PDF417DetectorResult {\n constructor(bits, points) {\n this.bits = bits;\n this.points = points;\n }\n getBits() {\n return this.bits;\n }\n getPoints() {\n return this.points;\n }\n }\n\n /*\n * Copyright 2009 ZXing authors\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n // import java.util.ArrayList;\n // import java.util.Arrays;\n // import java.util.List;\n // import java.util.Map;\n /**\n * Encapsulates logic that can detect a PDF417 Code in an image, even if the\n * PDF417 Code is rotated or skewed, or partially obscured.
\n *\n * @author SITA Lab (kevin.osullivan@sita.aero)\n * @author dswitkin@google.com (Daniel Switkin)\n * @author Guenther Grau\n */\n /*public*/ /*final*/ class Detector$3 {\n /**\n * Detects a PDF417 Code in an image. Only checks 0 and 180 degree rotations.
\n *\n * @param image barcode image to decode\n * @param hints optional hints to detector\n * @param multiple if true, then the image is searched for multiple codes. If false, then at most one code will\n * be found and returned\n * @return {@link PDF417DetectorResult} encapsulating results of detecting a PDF417 code\n * @throws NotFoundException if no PDF417 Code can be found\n */\n static detectMultiple(image, hints, multiple) {\n // TODO detection improvement, tryHarder could try several different luminance thresholds/blackpoints or even\n // different binarizers\n // boolean tryHarder = hints != null && hints.containsKey(DecodeHintType.TRY_HARDER);\n let bitMatrix = image.getBlackMatrix();\n let barcodeCoordinates = Detector$3.detect(multiple, bitMatrix);\n if (!barcodeCoordinates.length) {\n bitMatrix = bitMatrix.clone();\n bitMatrix.rotate180();\n barcodeCoordinates = Detector$3.detect(multiple, bitMatrix);\n }\n return new PDF417DetectorResult(bitMatrix, barcodeCoordinates);\n }\n /**\n * Detects PDF417 codes in an image. Only checks 0 degree rotation\n * @param multiple if true, then the image is searched for multiple codes. If false, then at most one code will\n * be found and returned\n * @param bitMatrix bit matrix to detect barcodes in\n * @return List of ResultPoint arrays containing the coordinates of found barcodes\n */\n static detect(multiple, bitMatrix) {\n const barcodeCoordinates = new Array();\n let row = 0;\n let column = 0;\n let foundBarcodeInRow = false;\n while (row < bitMatrix.getHeight()) {\n const vertices = Detector$3.findVertices(bitMatrix, row, column);\n if (vertices[0] == null && vertices[3] == null) {\n if (!foundBarcodeInRow) {\n // we didn't find any barcode so that's the end of searching\n break;\n }\n // we didn't find a barcode starting at the given column and row. Try again from the first column and slightly\n // below the lowest barcode we found so far.\n foundBarcodeInRow = false;\n column = 0;\n for (const barcodeCoordinate of barcodeCoordinates) {\n if (barcodeCoordinate[1] != null) {\n row = Math.trunc(Math.max(row, barcodeCoordinate[1].getY()));\n }\n if (barcodeCoordinate[3] != null) {\n row = Math.max(row, Math.trunc(barcodeCoordinate[3].getY()));\n }\n }\n row += Detector$3.ROW_STEP;\n continue;\n }\n foundBarcodeInRow = true;\n barcodeCoordinates.push(vertices);\n if (!multiple) {\n break;\n }\n // if we didn't find a right row indicator column, then continue the search for the next barcode after the\n // start pattern of the barcode just found.\n if (vertices[2] != null) {\n column = Math.trunc(vertices[2].getX());\n row = Math.trunc(vertices[2].getY());\n }\n else {\n column = Math.trunc(vertices[4].getX());\n row = Math.trunc(vertices[4].getY());\n }\n }\n return barcodeCoordinates;\n }\n /**\n * Locate the vertices and the codewords area of a black blob using the Start\n * and Stop patterns as locators.\n *\n * @param matrix the scanned barcode image.\n * @return an array containing the vertices:\n * vertices[0] x, y top left barcode\n * vertices[1] x, y bottom left barcode\n * vertices[2] x, y top right barcode\n * vertices[3] x, y bottom right barcode\n * vertices[4] x, y top left codeword area\n * vertices[5] x, y bottom left codeword area\n * vertices[6] x, y top right codeword area\n * vertices[7] x, y bottom right codeword area\n */\n static findVertices(matrix, startRow, startColumn) {\n const height = matrix.getHeight();\n const width = matrix.getWidth();\n // const result = new ResultPoint[8];\n const result = new Array(8);\n Detector$3.copyToResult(result, Detector$3.findRowsWithPattern(matrix, height, width, startRow, startColumn, Detector$3.START_PATTERN), Detector$3.INDEXES_START_PATTERN);\n if (result[4] != null) {\n startColumn = Math.trunc(result[4].getX());\n startRow = Math.trunc(result[4].getY());\n }\n Detector$3.copyToResult(result, Detector$3.findRowsWithPattern(matrix, height, width, startRow, startColumn, Detector$3.STOP_PATTERN), Detector$3.INDEXES_STOP_PATTERN);\n return result;\n }\n static copyToResult(result, tmpResult, destinationIndexes) {\n for (let i = 0; i < destinationIndexes.length; i++) {\n result[destinationIndexes[i]] = tmpResult[i];\n }\n }\n static findRowsWithPattern(matrix, height, width, startRow, startColumn, pattern) {\n // const result = new ResultPoint[4];\n const result = new Array(4);\n let found = false;\n const counters = new Int32Array(pattern.length);\n for (; startRow < height; startRow += Detector$3.ROW_STEP) {\n let loc = Detector$3.findGuardPattern(matrix, startColumn, startRow, width, false, pattern, counters);\n if (loc != null) {\n while (startRow > 0) {\n const previousRowLoc = Detector$3.findGuardPattern(matrix, startColumn, --startRow, width, false, pattern, counters);\n if (previousRowLoc != null) {\n loc = previousRowLoc;\n }\n else {\n startRow++;\n break;\n }\n }\n result[0] = new ResultPoint(loc[0], startRow);\n result[1] = new ResultPoint(loc[1], startRow);\n found = true;\n break;\n }\n }\n let stopRow = startRow + 1;\n // Last row of the current symbol that contains pattern\n if (found) {\n let skippedRowCount = 0;\n let previousRowLoc = Int32Array.from([Math.trunc(result[0].getX()), Math.trunc(result[1].getX())]);\n for (; stopRow < height; stopRow++) {\n const loc = Detector$3.findGuardPattern(matrix, previousRowLoc[0], stopRow, width, false, pattern, counters);\n // a found pattern is only considered to belong to the same barcode if the start and end positions\n // don't differ too much. Pattern drift should be not bigger than two for consecutive rows. With\n // a higher number of skipped rows drift could be larger. To keep it simple for now, we allow a slightly\n // larger drift and don't check for skipped rows.\n if (loc != null &&\n Math.abs(previousRowLoc[0] - loc[0]) < Detector$3.MAX_PATTERN_DRIFT &&\n Math.abs(previousRowLoc[1] - loc[1]) < Detector$3.MAX_PATTERN_DRIFT) {\n previousRowLoc = loc;\n skippedRowCount = 0;\n }\n else {\n if (skippedRowCount > Detector$3.SKIPPED_ROW_COUNT_MAX) {\n break;\n }\n else {\n skippedRowCount++;\n }\n }\n }\n stopRow -= skippedRowCount + 1;\n result[2] = new ResultPoint(previousRowLoc[0], stopRow);\n result[3] = new ResultPoint(previousRowLoc[1], stopRow);\n }\n if (stopRow - startRow < Detector$3.BARCODE_MIN_HEIGHT) {\n Arrays.fill(result, null);\n }\n return result;\n }\n /**\n * @param matrix row of black/white values to search\n * @param column x position to start search\n * @param row y position to start search\n * @param width the number of pixels to search on this row\n * @param pattern pattern of counts of number of black and white pixels that are\n * being searched for as a pattern\n * @param counters array of counters, as long as pattern, to re-use\n * @return start/end horizontal offset of guard pattern, as an array of two ints.\n */\n static findGuardPattern(matrix, column, row, width, whiteFirst, pattern, counters) {\n Arrays.fillWithin(counters, 0, counters.length, 0);\n let patternStart = column;\n let pixelDrift = 0;\n // if there are black pixels left of the current pixel shift to the left, but only for MAX_PIXEL_DRIFT pixels\n while (matrix.get(patternStart, row) && patternStart > 0 && pixelDrift++ < Detector$3.MAX_PIXEL_DRIFT) {\n patternStart--;\n }\n let x = patternStart;\n let counterPosition = 0;\n let patternLength = pattern.length;\n for (let isWhite = whiteFirst; x < width; x++) {\n let pixel = matrix.get(x, row);\n if (pixel !== isWhite) {\n counters[counterPosition]++;\n }\n else {\n if (counterPosition === patternLength - 1) {\n if (Detector$3.patternMatchVariance(counters, pattern, Detector$3.MAX_INDIVIDUAL_VARIANCE) < Detector$3.MAX_AVG_VARIANCE) {\n return new Int32Array([patternStart, x]);\n }\n patternStart += counters[0] + counters[1];\n System.arraycopy(counters, 2, counters, 0, counterPosition - 1);\n counters[counterPosition - 1] = 0;\n counters[counterPosition] = 0;\n counterPosition--;\n }\n else {\n counterPosition++;\n }\n counters[counterPosition] = 1;\n isWhite = !isWhite;\n }\n }\n if (counterPosition === patternLength - 1 &&\n Detector$3.patternMatchVariance(counters, pattern, Detector$3.MAX_INDIVIDUAL_VARIANCE) < Detector$3.MAX_AVG_VARIANCE) {\n return new Int32Array([patternStart, x - 1]);\n }\n return null;\n }\n /**\n * Determines how closely a set of observed counts of runs of black/white\n * values matches a given target pattern. This is reported as the ratio of\n * the total variance from the expected pattern proportions across all\n * pattern elements, to the length of the pattern.\n *\n * @param counters observed counters\n * @param pattern expected pattern\n * @param maxIndividualVariance The most any counter can differ before we give up\n * @return ratio of total variance between counters and pattern compared to total pattern size\n */\n static patternMatchVariance(counters, pattern, maxIndividualVariance) {\n let numCounters = counters.length;\n let total = 0;\n let patternLength = 0;\n for (let i = 0; i < numCounters; i++) {\n total += counters[i];\n patternLength += pattern[i];\n }\n if (total < patternLength) {\n // If we don't even have one pixel per unit of bar width, assume this\n // is too small to reliably match, so fail:\n return /*Float.POSITIVE_INFINITY*/ Infinity;\n }\n // We're going to fake floating-point math in integers. We just need to use more bits.\n // Scale up patternLength so that intermediate values below like scaledCounter will have\n // more \"significant digits\".\n let unitBarWidth = total / patternLength;\n maxIndividualVariance *= unitBarWidth;\n let totalVariance = 0.0;\n for (let x = 0; x < numCounters; x++) {\n let counter = counters[x];\n let scaledPattern = pattern[x] * unitBarWidth;\n let variance = counter > scaledPattern ? counter - scaledPattern : scaledPattern - counter;\n if (variance > maxIndividualVariance) {\n return /*Float.POSITIVE_INFINITY*/ Infinity;\n }\n totalVariance += variance;\n }\n return totalVariance / total;\n }\n }\n Detector$3.INDEXES_START_PATTERN = Int32Array.from([0, 4, 1, 5]);\n Detector$3.INDEXES_STOP_PATTERN = Int32Array.from([6, 2, 7, 3]);\n Detector$3.MAX_AVG_VARIANCE = 0.42;\n Detector$3.MAX_INDIVIDUAL_VARIANCE = 0.8;\n // B S B S B S B S Bar/Space pattern\n // 11111111 0 1 0 1 0 1 000\n Detector$3.START_PATTERN = Int32Array.from([8, 1, 1, 1, 1, 1, 1, 3]);\n // 1111111 0 1 000 1 0 1 00 1\n Detector$3.STOP_PATTERN = Int32Array.from([7, 1, 1, 3, 1, 1, 1, 2, 1]);\n Detector$3.MAX_PIXEL_DRIFT = 3;\n Detector$3.MAX_PATTERN_DRIFT = 5;\n // if we set the value too low, then we don't detect the correct height of the bar if the start patterns are damaged.\n // if we set the value too high, then we might detect the start pattern from a neighbor barcode.\n Detector$3.SKIPPED_ROW_COUNT_MAX = 25;\n // A PDF471 barcode should have at least 3 rows, with each row being >= 3 times the module width. Therefore it should be at least\n // 9 pixels tall. To be conservative, we use about half the size to ensure we don't miss it.\n Detector$3.ROW_STEP = 5;\n Detector$3.BARCODE_MIN_HEIGHT = 10;\n\n /*\n * Copyright 2012 ZXing authors\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n /**\n * @author Sean Owen\n * @see com.google.zxing.common.reedsolomon.GenericGFPoly\n */\n /*final*/ class ModulusPoly {\n constructor(field, coefficients) {\n if (coefficients.length === 0) {\n throw new IllegalArgumentException();\n }\n this.field = field;\n let coefficientsLength = /*int*/ coefficients.length;\n if (coefficientsLength > 1 && coefficients[0] === 0) {\n // Leading term must be non-zero for anything except the constant polynomial \"0\"\n let firstNonZero = /*int*/ 1;\n while (firstNonZero < coefficientsLength && coefficients[firstNonZero] === 0) {\n firstNonZero++;\n }\n if (firstNonZero === coefficientsLength) {\n this.coefficients = new Int32Array([0]);\n }\n else {\n this.coefficients = new Int32Array(coefficientsLength - firstNonZero);\n System.arraycopy(coefficients, firstNonZero, this.coefficients, 0, this.coefficients.length);\n }\n }\n else {\n this.coefficients = coefficients;\n }\n }\n getCoefficients() {\n return this.coefficients;\n }\n /**\n * @return degree of this polynomial\n */\n getDegree() {\n return this.coefficients.length - 1;\n }\n /**\n * @return true iff this polynomial is the monomial \"0\"\n */\n isZero() {\n return this.coefficients[0] === 0;\n }\n /**\n * @return coefficient of x^degree term in this polynomial\n */\n getCoefficient(degree) {\n return this.coefficients[this.coefficients.length - 1 - degree];\n }\n /**\n * @return evaluation of this polynomial at a given point\n */\n evaluateAt(a) {\n if (a === 0) {\n // Just return the x^0 coefficient\n return this.getCoefficient(0);\n }\n if (a === 1) {\n // Just the sum of the coefficients\n let sum = /*int*/ 0;\n for (let coefficient /*int*/ of this.coefficients) {\n sum = this.field.add(sum, coefficient);\n }\n return sum;\n }\n let result = /*int*/ this.coefficients[0];\n let size = /*int*/ this.coefficients.length;\n for (let i /*int*/ = 1; i < size; i++) {\n result = this.field.add(this.field.multiply(a, result), this.coefficients[i]);\n }\n return result;\n }\n add(other) {\n if (!this.field.equals(other.field)) {\n throw new IllegalArgumentException('ModulusPolys do not have same ModulusGF field');\n }\n if (this.isZero()) {\n return other;\n }\n if (other.isZero()) {\n return this;\n }\n let smallerCoefficients = this.coefficients;\n let largerCoefficients = other.coefficients;\n if (smallerCoefficients.length > largerCoefficients.length) {\n let temp = smallerCoefficients;\n smallerCoefficients = largerCoefficients;\n largerCoefficients = temp;\n }\n let sumDiff = new Int32Array(largerCoefficients.length);\n let lengthDiff = /*int*/ largerCoefficients.length - smallerCoefficients.length;\n // Copy high-order terms only found in higher-degree polynomial's coefficients\n System.arraycopy(largerCoefficients, 0, sumDiff, 0, lengthDiff);\n for (let i /*int*/ = lengthDiff; i < largerCoefficients.length; i++) {\n sumDiff[i] = this.field.add(smallerCoefficients[i - lengthDiff], largerCoefficients[i]);\n }\n return new ModulusPoly(this.field, sumDiff);\n }\n subtract(other) {\n if (!this.field.equals(other.field)) {\n throw new IllegalArgumentException('ModulusPolys do not have same ModulusGF field');\n }\n if (other.isZero()) {\n return this;\n }\n return this.add(other.negative());\n }\n multiply(other) {\n if (other instanceof ModulusPoly) {\n return this.multiplyOther(other);\n }\n return this.multiplyScalar(other);\n }\n multiplyOther(other) {\n if (!this.field.equals(other.field)) {\n throw new IllegalArgumentException('ModulusPolys do not have same ModulusGF field');\n }\n if (this.isZero() || other.isZero()) {\n // return this.field.getZero();\n return new ModulusPoly(this.field, new Int32Array([0]));\n }\n let aCoefficients = this.coefficients;\n let aLength = /*int*/ aCoefficients.length;\n let bCoefficients = other.coefficients;\n let bLength = /*int*/ bCoefficients.length;\n let product = new Int32Array(aLength + bLength - 1);\n for (let i /*int*/ = 0; i < aLength; i++) {\n let aCoeff = /*int*/ aCoefficients[i];\n for (let j /*int*/ = 0; j < bLength; j++) {\n product[i + j] = this.field.add(product[i + j], this.field.multiply(aCoeff, bCoefficients[j]));\n }\n }\n return new ModulusPoly(this.field, product);\n }\n negative() {\n let size = /*int*/ this.coefficients.length;\n let negativeCoefficients = new Int32Array(size);\n for (let i /*int*/ = 0; i < size; i++) {\n negativeCoefficients[i] = this.field.subtract(0, this.coefficients[i]);\n }\n return new ModulusPoly(this.field, negativeCoefficients);\n }\n multiplyScalar(scalar) {\n if (scalar === 0) {\n return new ModulusPoly(this.field, new Int32Array([0]));\n }\n if (scalar === 1) {\n return this;\n }\n let size = /*int*/ this.coefficients.length;\n let product = new Int32Array(size);\n for (let i /*int*/ = 0; i < size; i++) {\n product[i] = this.field.multiply(this.coefficients[i], scalar);\n }\n return new ModulusPoly(this.field, product);\n }\n multiplyByMonomial(degree, coefficient) {\n if (degree < 0) {\n throw new IllegalArgumentException();\n }\n if (coefficient === 0) {\n return new ModulusPoly(this.field, new Int32Array([0]));\n }\n let size = /*int*/ this.coefficients.length;\n let product = new Int32Array(size + degree);\n for (let i /*int*/ = 0; i < size; i++) {\n product[i] = this.field.multiply(this.coefficients[i], coefficient);\n }\n return new ModulusPoly(this.field, product);\n }\n /*\n ModulusPoly[] divide(other: ModulusPoly) {\n if (!field.equals(other.field)) {\n throw new IllegalArgumentException(\"ModulusPolys do not have same ModulusGF field\");\n }\n if (other.isZero()) {\n throw new IllegalArgumentException(\"Divide by 0\");\n }\n \n let quotient: ModulusPoly = field.getZero();\n let remainder: ModulusPoly = this;\n \n let denominatorLeadingTerm: /*int/ number = other.getCoefficient(other.getDegree());\n let inverseDenominatorLeadingTerm: /*int/ number = field.inverse(denominatorLeadingTerm);\n \n while (remainder.getDegree() >= other.getDegree() && !remainder.isZero()) {\n let degreeDifference: /*int/ number = remainder.getDegree() - other.getDegree();\n let scale: /*int/ number = field.multiply(remainder.getCoefficient(remainder.getDegree()), inverseDenominatorLeadingTerm);\n let term: ModulusPoly = other.multiplyByMonomial(degreeDifference, scale);\n let iterationQuotient: ModulusPoly = field.buildMonomial(degreeDifference, scale);\n quotient = quotient.add(iterationQuotient);\n remainder = remainder.subtract(term);\n }\n \n return new ModulusPoly[] { quotient, remainder };\n }\n */\n // @Override\n toString() {\n let result = new StringBuilder( /*8 * this.getDegree()*/); // dynamic string size in JS\n for (let degree /*int*/ = this.getDegree(); degree >= 0; degree--) {\n let coefficient = /*int*/ this.getCoefficient(degree);\n if (coefficient !== 0) {\n if (coefficient < 0) {\n result.append(' - ');\n coefficient = -coefficient;\n }\n else {\n if (result.length() > 0) {\n result.append(' + ');\n }\n }\n if (degree === 0 || coefficient !== 1) {\n result.append(coefficient);\n }\n if (degree !== 0) {\n if (degree === 1) {\n result.append('x');\n }\n else {\n result.append('x^');\n result.append(degree);\n }\n }\n }\n }\n return result.toString();\n }\n }\n\n class ModulusBase {\n add(a, b) {\n return (a + b) % this.modulus;\n }\n subtract(a, b) {\n return (this.modulus + a - b) % this.modulus;\n }\n exp(a) {\n return this.expTable[a];\n }\n log(a) {\n if (a === 0) {\n throw new IllegalArgumentException();\n }\n return this.logTable[a];\n }\n inverse(a) {\n if (a === 0) {\n throw new ArithmeticException();\n }\n return this.expTable[this.modulus - this.logTable[a] - 1];\n }\n multiply(a, b) {\n if (a === 0 || b === 0) {\n return 0;\n }\n return this.expTable[(this.logTable[a] + this.logTable[b]) % (this.modulus - 1)];\n }\n getSize() {\n return this.modulus;\n }\n equals(o) {\n return o === this;\n }\n }\n\n /*\n * Copyright 2012 ZXing authors\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n /**\n * A field based on powers of a generator integer, modulo some modulus.
\n *\n * @author Sean Owen\n * @see com.google.zxing.common.reedsolomon.GenericGF\n */\n /*public final*/ class ModulusGF extends ModulusBase {\n // private /*final*/ modulus: /*int*/ number;\n constructor(modulus, generator) {\n super();\n this.modulus = modulus;\n this.expTable = new Int32Array(modulus);\n this.logTable = new Int32Array(modulus);\n let x = /*int*/ 1;\n for (let i /*int*/ = 0; i < modulus; i++) {\n this.expTable[i] = x;\n x = (x * generator) % modulus;\n }\n for (let i /*int*/ = 0; i < modulus - 1; i++) {\n this.logTable[this.expTable[i]] = i;\n }\n // logTable[0] == 0 but this should never be used\n this.zero = new ModulusPoly(this, new Int32Array([0]));\n this.one = new ModulusPoly(this, new Int32Array([1]));\n }\n getZero() {\n return this.zero;\n }\n getOne() {\n return this.one;\n }\n buildMonomial(degree, coefficient) {\n if (degree < 0) {\n throw new IllegalArgumentException();\n }\n if (coefficient === 0) {\n return this.zero;\n }\n let coefficients = new Int32Array(degree + 1);\n coefficients[0] = coefficient;\n return new ModulusPoly(this, coefficients);\n }\n }\n ModulusGF.PDF417_GF = new ModulusGF(PDF417Common.NUMBER_OF_CODEWORDS, 3);\n\n /*\n * Copyright 2012 ZXing authors\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n /**\n * PDF417 error correction implementation.
\n *\n * This example\n * is quite useful in understanding the algorithm.
\n *\n * @author Sean Owen\n * @see com.google.zxing.common.reedsolomon.ReedSolomonDecoder\n */\n /*public final*/ class ErrorCorrection {\n constructor() {\n this.field = ModulusGF.PDF417_GF;\n }\n /**\n * @param received received codewords\n * @param numECCodewords number of those codewords used for EC\n * @param erasures location of erasures\n * @return number of errors\n * @throws ChecksumException if errors cannot be corrected, maybe because of too many errors\n */\n decode(received, numECCodewords, erasures) {\n let poly = new ModulusPoly(this.field, received);\n let S = new Int32Array(numECCodewords);\n let error = false;\n for (let i /*int*/ = numECCodewords; i > 0; i--) {\n let evaluation = poly.evaluateAt(this.field.exp(i));\n S[numECCodewords - i] = evaluation;\n if (evaluation !== 0) {\n error = true;\n }\n }\n if (!error) {\n return 0;\n }\n let knownErrors = this.field.getOne();\n if (erasures != null) {\n for (const erasure of erasures) {\n let b = this.field.exp(received.length - 1 - erasure);\n // Add (1 - bx) term:\n let term = new ModulusPoly(this.field, new Int32Array([this.field.subtract(0, b), 1]));\n knownErrors = knownErrors.multiply(term);\n }\n }\n let syndrome = new ModulusPoly(this.field, S);\n // syndrome = syndrome.multiply(knownErrors);\n let sigmaOmega = this.runEuclideanAlgorithm(this.field.buildMonomial(numECCodewords, 1), syndrome, numECCodewords);\n let sigma = sigmaOmega[0];\n let omega = sigmaOmega[1];\n // sigma = sigma.multiply(knownErrors);\n let errorLocations = this.findErrorLocations(sigma);\n let errorMagnitudes = this.findErrorMagnitudes(omega, sigma, errorLocations);\n for (let i /*int*/ = 0; i < errorLocations.length; i++) {\n let position = received.length - 1 - this.field.log(errorLocations[i]);\n if (position < 0) {\n throw ChecksumException.getChecksumInstance();\n }\n received[position] = this.field.subtract(received[position], errorMagnitudes[i]);\n }\n return errorLocations.length;\n }\n /**\n *\n * @param ModulusPoly\n * @param a\n * @param ModulusPoly\n * @param b\n * @param int\n * @param R\n * @throws ChecksumException\n */\n runEuclideanAlgorithm(a, b, R) {\n // Assume a's degree is >= b's\n if (a.getDegree() < b.getDegree()) {\n let temp = a;\n a = b;\n b = temp;\n }\n let rLast = a;\n let r = b;\n let tLast = this.field.getZero();\n let t = this.field.getOne();\n // Run Euclidean algorithm until r's degree is less than R/2\n while (r.getDegree() >= Math.round(R / 2)) {\n let rLastLast = rLast;\n let tLastLast = tLast;\n rLast = r;\n tLast = t;\n // Divide rLastLast by rLast, with quotient in q and remainder in r\n if (rLast.isZero()) {\n // Oops, Euclidean algorithm already terminated?\n throw ChecksumException.getChecksumInstance();\n }\n r = rLastLast;\n let q = this.field.getZero();\n let denominatorLeadingTerm = rLast.getCoefficient(rLast.getDegree());\n let dltInverse = this.field.inverse(denominatorLeadingTerm);\n while (r.getDegree() >= rLast.getDegree() && !r.isZero()) {\n let degreeDiff = r.getDegree() - rLast.getDegree();\n let scale = this.field.multiply(r.getCoefficient(r.getDegree()), dltInverse);\n q = q.add(this.field.buildMonomial(degreeDiff, scale));\n r = r.subtract(rLast.multiplyByMonomial(degreeDiff, scale));\n }\n t = q.multiply(tLast).subtract(tLastLast).negative();\n }\n let sigmaTildeAtZero = t.getCoefficient(0);\n if (sigmaTildeAtZero === 0) {\n throw ChecksumException.getChecksumInstance();\n }\n let inverse = this.field.inverse(sigmaTildeAtZero);\n let sigma = t.multiply(inverse);\n let omega = r.multiply(inverse);\n return [sigma, omega];\n }\n /**\n *\n * @param errorLocator\n * @throws ChecksumException\n */\n findErrorLocations(errorLocator) {\n // This is a direct application of Chien's search\n let numErrors = errorLocator.getDegree();\n let result = new Int32Array(numErrors);\n let e = 0;\n for (let i /*int*/ = 1; i < this.field.getSize() && e < numErrors; i++) {\n if (errorLocator.evaluateAt(i) === 0) {\n result[e] = this.field.inverse(i);\n e++;\n }\n }\n if (e !== numErrors) {\n throw ChecksumException.getChecksumInstance();\n }\n return result;\n }\n findErrorMagnitudes(errorEvaluator, errorLocator, errorLocations) {\n let errorLocatorDegree = errorLocator.getDegree();\n let formalDerivativeCoefficients = new Int32Array(errorLocatorDegree);\n for (let i /*int*/ = 1; i <= errorLocatorDegree; i++) {\n formalDerivativeCoefficients[errorLocatorDegree - i] =\n this.field.multiply(i, errorLocator.getCoefficient(i));\n }\n let formalDerivative = new ModulusPoly(this.field, formalDerivativeCoefficients);\n // This is directly applying Forney's Formula\n let s = errorLocations.length;\n let result = new Int32Array(s);\n for (let i /*int*/ = 0; i < s; i++) {\n let xiInverse = this.field.inverse(errorLocations[i]);\n let numerator = this.field.subtract(0, errorEvaluator.evaluateAt(xiInverse));\n let denominator = this.field.inverse(formalDerivative.evaluateAt(xiInverse));\n result[i] = this.field.multiply(numerator, denominator);\n }\n return result;\n }\n }\n\n /*\n * Copyright 2013 ZXing authors\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n /**\n * @author Guenther Grau\n */\n /*final*/ class BoundingBox {\n constructor(image, topLeft, bottomLeft, topRight, bottomRight) {\n if (image instanceof BoundingBox) {\n this.constructor_2(image);\n }\n else {\n this.constructor_1(image, topLeft, bottomLeft, topRight, bottomRight);\n }\n }\n /**\n *\n * @param image\n * @param topLeft\n * @param bottomLeft\n * @param topRight\n * @param bottomRight\n *\n * @throws NotFoundException\n */\n constructor_1(image, topLeft, bottomLeft, topRight, bottomRight) {\n const leftUnspecified = topLeft == null || bottomLeft == null;\n const rightUnspecified = topRight == null || bottomRight == null;\n if (leftUnspecified && rightUnspecified) {\n throw new NotFoundException();\n }\n if (leftUnspecified) {\n topLeft = new ResultPoint(0, topRight.getY());\n bottomLeft = new ResultPoint(0, bottomRight.getY());\n }\n else if (rightUnspecified) {\n topRight = new ResultPoint(image.getWidth() - 1, topLeft.getY());\n bottomRight = new ResultPoint(image.getWidth() - 1, bottomLeft.getY());\n }\n this.image = image;\n this.topLeft = topLeft;\n this.bottomLeft = bottomLeft;\n this.topRight = topRight;\n this.bottomRight = bottomRight;\n this.minX = Math.trunc(Math.min(topLeft.getX(), bottomLeft.getX()));\n this.maxX = Math.trunc(Math.max(topRight.getX(), bottomRight.getX()));\n this.minY = Math.trunc(Math.min(topLeft.getY(), topRight.getY()));\n this.maxY = Math.trunc(Math.max(bottomLeft.getY(), bottomRight.getY()));\n }\n constructor_2(boundingBox) {\n this.image = boundingBox.image;\n this.topLeft = boundingBox.getTopLeft();\n this.bottomLeft = boundingBox.getBottomLeft();\n this.topRight = boundingBox.getTopRight();\n this.bottomRight = boundingBox.getBottomRight();\n this.minX = boundingBox.getMinX();\n this.maxX = boundingBox.getMaxX();\n this.minY = boundingBox.getMinY();\n this.maxY = boundingBox.getMaxY();\n }\n /**\n * @throws NotFoundException\n */\n static merge(leftBox, rightBox) {\n if (leftBox == null) {\n return rightBox;\n }\n if (rightBox == null) {\n return leftBox;\n }\n return new BoundingBox(leftBox.image, leftBox.topLeft, leftBox.bottomLeft, rightBox.topRight, rightBox.bottomRight);\n }\n /**\n * @throws NotFoundException\n */\n addMissingRows(missingStartRows, missingEndRows, isLeft) {\n let newTopLeft = this.topLeft;\n let newBottomLeft = this.bottomLeft;\n let newTopRight = this.topRight;\n let newBottomRight = this.bottomRight;\n if (missingStartRows > 0) {\n let top = isLeft ? this.topLeft : this.topRight;\n let newMinY = Math.trunc(top.getY() - missingStartRows);\n if (newMinY < 0) {\n newMinY = 0;\n }\n let newTop = new ResultPoint(top.getX(), newMinY);\n if (isLeft) {\n newTopLeft = newTop;\n }\n else {\n newTopRight = newTop;\n }\n }\n if (missingEndRows > 0) {\n let bottom = isLeft ? this.bottomLeft : this.bottomRight;\n let newMaxY = Math.trunc(bottom.getY() + missingEndRows);\n if (newMaxY >= this.image.getHeight()) {\n newMaxY = this.image.getHeight() - 1;\n }\n let newBottom = new ResultPoint(bottom.getX(), newMaxY);\n if (isLeft) {\n newBottomLeft = newBottom;\n }\n else {\n newBottomRight = newBottom;\n }\n }\n return new BoundingBox(this.image, newTopLeft, newBottomLeft, newTopRight, newBottomRight);\n }\n getMinX() {\n return this.minX;\n }\n getMaxX() {\n return this.maxX;\n }\n getMinY() {\n return this.minY;\n }\n getMaxY() {\n return this.maxY;\n }\n getTopLeft() {\n return this.topLeft;\n }\n getTopRight() {\n return this.topRight;\n }\n getBottomLeft() {\n return this.bottomLeft;\n }\n getBottomRight() {\n return this.bottomRight;\n }\n }\n\n /*\n * Copyright 2013 ZXing authors\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n // package com.google.zxing.pdf417.decoder;\n /**\n * @author Guenther Grau\n */\n /*final*/ class BarcodeMetadata {\n constructor(columnCount, rowCountUpperPart, rowCountLowerPart, errorCorrectionLevel) {\n this.columnCount = columnCount;\n this.errorCorrectionLevel = errorCorrectionLevel;\n this.rowCountUpperPart = rowCountUpperPart;\n this.rowCountLowerPart = rowCountLowerPart;\n this.rowCount = rowCountUpperPart + rowCountLowerPart;\n }\n getColumnCount() {\n return this.columnCount;\n }\n getErrorCorrectionLevel() {\n return this.errorCorrectionLevel;\n }\n getRowCount() {\n return this.rowCount;\n }\n getRowCountUpperPart() {\n return this.rowCountUpperPart;\n }\n getRowCountLowerPart() {\n return this.rowCountLowerPart;\n }\n }\n\n /**\n * Java Formatter class polyfill that works in the JS way.\n */\n class Formatter {\n constructor() {\n this.buffer = '';\n }\n /**\n *\n * @see https://stackoverflow.com/a/13439711/4367683\n *\n * @param str\n * @param arr\n */\n static form(str, arr) {\n let i = -1;\n function callback(exp, p0, p1, p2, p3, p4) {\n if (exp === '%%')\n return '%';\n if (arr[++i] === undefined)\n return undefined;\n exp = p2 ? parseInt(p2.substr(1)) : undefined;\n let base = p3 ? parseInt(p3.substr(1)) : undefined;\n let val;\n switch (p4) {\n case 's':\n val = arr[i];\n break;\n case 'c':\n val = arr[i][0];\n break;\n case 'f':\n val = parseFloat(arr[i]).toFixed(exp);\n break;\n case 'p':\n val = parseFloat(arr[i]).toPrecision(exp);\n break;\n case 'e':\n val = parseFloat(arr[i]).toExponential(exp);\n break;\n case 'x':\n val = parseInt(arr[i]).toString(base ? base : 16);\n break;\n case 'd':\n val = parseFloat(parseInt(arr[i], base ? base : 10).toPrecision(exp)).toFixed(0);\n break;\n }\n val = typeof val === 'object' ? JSON.stringify(val) : (+val).toString(base);\n let size = parseInt(p1); /* padding size */\n let ch = p1 && (p1[0] + '') === '0' ? '0' : ' '; /* isnull? */\n while (val.length < size)\n val = p0 !== undefined ? val + ch : ch + val; /* isminus? */\n return val;\n }\n let regex = /%(-)?(0?[0-9]+)?([.][0-9]+)?([#][0-9]+)?([scfpexd%])/g;\n return str.replace(regex, callback);\n }\n /**\n *\n * @param append The new string to append.\n * @param args Argumets values to be formated.\n */\n format(append, ...args) {\n this.buffer += Formatter.form(append, args);\n }\n /**\n * Returns the Formatter string value.\n */\n toString() {\n return this.buffer;\n }\n }\n\n /*\n * Copyright 2013 ZXing authors\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n /**\n * @author Guenther Grau\n */\n class DetectionResultColumn {\n constructor(boundingBox) {\n this.boundingBox = new BoundingBox(boundingBox);\n // this.codewords = new Codeword[boundingBox.getMaxY() - boundingBox.getMinY() + 1];\n this.codewords = new Array(boundingBox.getMaxY() - boundingBox.getMinY() + 1);\n }\n /*final*/ getCodewordNearby(imageRow) {\n let codeword = this.getCodeword(imageRow);\n if (codeword != null) {\n return codeword;\n }\n for (let i = 1; i < DetectionResultColumn.MAX_NEARBY_DISTANCE; i++) {\n let nearImageRow = this.imageRowToCodewordIndex(imageRow) - i;\n if (nearImageRow >= 0) {\n codeword = this.codewords[nearImageRow];\n if (codeword != null) {\n return codeword;\n }\n }\n nearImageRow = this.imageRowToCodewordIndex(imageRow) + i;\n if (nearImageRow < this.codewords.length) {\n codeword = this.codewords[nearImageRow];\n if (codeword != null) {\n return codeword;\n }\n }\n }\n return null;\n }\n /*final int*/ imageRowToCodewordIndex(imageRow) {\n return imageRow - this.boundingBox.getMinY();\n }\n /*final void*/ setCodeword(imageRow, codeword) {\n this.codewords[this.imageRowToCodewordIndex(imageRow)] = codeword;\n }\n /*final*/ getCodeword(imageRow) {\n return this.codewords[this.imageRowToCodewordIndex(imageRow)];\n }\n /*final*/ getBoundingBox() {\n return this.boundingBox;\n }\n /*final*/ getCodewords() {\n return this.codewords;\n }\n // @Override\n toString() {\n const formatter = new Formatter();\n let row = 0;\n for (const codeword of this.codewords) {\n if (codeword == null) {\n formatter.format('%3d: | %n', row++);\n continue;\n }\n formatter.format('%3d: %3d|%3d%n', row++, codeword.getRowNumber(), codeword.getValue());\n }\n return formatter.toString();\n }\n }\n DetectionResultColumn.MAX_NEARBY_DISTANCE = 5;\n\n /*\n * Copyright 2013 ZXing authors\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n // import java.util.ArrayList;\n // import java.util.Collection;\n // import java.util.HashMap;\n // import java.util.Map;\n // import java.util.Map.Entry;\n /**\n * @author Guenther Grau\n */\n /*final*/ class BarcodeValue {\n constructor() {\n this.values = new Map();\n }\n /**\n * Add an occurrence of a value\n */\n setValue(value) {\n value = Math.trunc(value);\n let confidence = this.values.get(value);\n if (confidence == null) {\n confidence = 0;\n }\n confidence++;\n this.values.set(value, confidence);\n }\n /**\n * Determines the maximum occurrence of a set value and returns all values which were set with this occurrence.\n * @return an array of int, containing the values with the highest occurrence, or null, if no value was set\n */\n getValue() {\n let maxConfidence = -1;\n let result = new Array();\n for (const [key, value] of this.values.entries()) {\n const entry = {\n getKey: () => key,\n getValue: () => value,\n };\n if (entry.getValue() > maxConfidence) {\n maxConfidence = entry.getValue();\n result = [];\n result.push(entry.getKey());\n }\n else if (entry.getValue() === maxConfidence) {\n result.push(entry.getKey());\n }\n }\n return PDF417Common.toIntArray(result);\n }\n getConfidence(value) {\n return this.values.get(value);\n }\n }\n\n /*\n * Copyright 2013 ZXing authors\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n /**\n * @author Guenther Grau\n */\n /*final*/ class DetectionResultRowIndicatorColumn extends DetectionResultColumn {\n constructor(boundingBox, isLeft) {\n super(boundingBox);\n this._isLeft = isLeft;\n }\n setRowNumbers() {\n for (let codeword /*Codeword*/ of this.getCodewords()) {\n if (codeword != null) {\n codeword.setRowNumberAsRowIndicatorColumn();\n }\n }\n }\n // TODO implement properly\n // TODO maybe we should add missing codewords to store the correct row number to make\n // finding row numbers for other columns easier\n // use row height count to make detection of invalid row numbers more reliable\n adjustCompleteIndicatorColumnRowNumbers(barcodeMetadata) {\n let codewords = this.getCodewords();\n this.setRowNumbers();\n this.removeIncorrectCodewords(codewords, barcodeMetadata);\n let boundingBox = this.getBoundingBox();\n let top = this._isLeft ? boundingBox.getTopLeft() : boundingBox.getTopRight();\n let bottom = this._isLeft ? boundingBox.getBottomLeft() : boundingBox.getBottomRight();\n let firstRow = this.imageRowToCodewordIndex(Math.trunc(top.getY()));\n let lastRow = this.imageRowToCodewordIndex(Math.trunc(bottom.getY()));\n // We need to be careful using the average row height. Barcode could be skewed so that we have smaller and\n // taller rows\n // float averageRowHeight = (lastRow - firstRow) / /*(float)*/ barcodeMetadata.getRowCount();\n let barcodeRow = -1;\n let maxRowHeight = 1;\n let currentRowHeight = 0;\n for (let codewordsRow /*int*/ = firstRow; codewordsRow < lastRow; codewordsRow++) {\n if (codewords[codewordsRow] == null) {\n continue;\n }\n let codeword = codewords[codewordsRow];\n // float expectedRowNumber = (codewordsRow - firstRow) / averageRowHeight;\n // if (Math.abs(codeword.getRowNumber() - expectedRowNumber) > 2) {\n // SimpleLog.log(LEVEL.WARNING,\n // \"Removing codeword, rowNumberSkew too high, codeword[\" + codewordsRow + \"]: Expected Row: \" +\n // expectedRowNumber + \", RealRow: \" + codeword.getRowNumber() + \", value: \" + codeword.getValue());\n // codewords[codewordsRow] = null;\n // }\n let rowDifference = codeword.getRowNumber() - barcodeRow;\n // TODO improve handling with case where first row indicator doesn't start with 0\n if (rowDifference === 0) {\n currentRowHeight++;\n }\n else if (rowDifference === 1) {\n maxRowHeight = Math.max(maxRowHeight, currentRowHeight);\n currentRowHeight = 1;\n barcodeRow = codeword.getRowNumber();\n }\n else if (rowDifference < 0 ||\n codeword.getRowNumber() >= barcodeMetadata.getRowCount() ||\n rowDifference > codewordsRow) {\n codewords[codewordsRow] = null;\n }\n else {\n let checkedRows;\n if (maxRowHeight > 2) {\n checkedRows = (maxRowHeight - 2) * rowDifference;\n }\n else {\n checkedRows = rowDifference;\n }\n let closePreviousCodewordFound = checkedRows >= codewordsRow;\n for (let i /*int*/ = 1; i <= checkedRows && !closePreviousCodewordFound; i++) {\n // there must be (height * rowDifference) number of codewords missing. For now we assume height = 1.\n // This should hopefully get rid of most problems already.\n closePreviousCodewordFound = codewords[codewordsRow - i] != null;\n }\n if (closePreviousCodewordFound) {\n codewords[codewordsRow] = null;\n }\n else {\n barcodeRow = codeword.getRowNumber();\n currentRowHeight = 1;\n }\n }\n }\n // return (int) (averageRowHeight + 0.5);\n }\n getRowHeights() {\n let barcodeMetadata = this.getBarcodeMetadata();\n if (barcodeMetadata == null) {\n return null;\n }\n this.adjustIncompleteIndicatorColumnRowNumbers(barcodeMetadata);\n let result = new Int32Array(barcodeMetadata.getRowCount());\n for (let codeword /*Codeword*/ of this.getCodewords()) {\n if (codeword != null) {\n let rowNumber = codeword.getRowNumber();\n if (rowNumber >= result.length) {\n // We have more rows than the barcode metadata allows for, ignore them.\n continue;\n }\n result[rowNumber]++;\n } // else throw exception?\n }\n return result;\n }\n // TODO maybe we should add missing codewords to store the correct row number to make\n // finding row numbers for other columns easier\n // use row height count to make detection of invalid row numbers more reliable\n adjustIncompleteIndicatorColumnRowNumbers(barcodeMetadata) {\n let boundingBox = this.getBoundingBox();\n let top = this._isLeft ? boundingBox.getTopLeft() : boundingBox.getTopRight();\n let bottom = this._isLeft ? boundingBox.getBottomLeft() : boundingBox.getBottomRight();\n let firstRow = this.imageRowToCodewordIndex(Math.trunc(top.getY()));\n let lastRow = this.imageRowToCodewordIndex(Math.trunc(bottom.getY()));\n // float averageRowHeight = (lastRow - firstRow) / /*(float)*/ barcodeMetadata.getRowCount();\n let codewords = this.getCodewords();\n let barcodeRow = -1;\n for (let codewordsRow /*int*/ = firstRow; codewordsRow < lastRow; codewordsRow++) {\n if (codewords[codewordsRow] == null) {\n continue;\n }\n let codeword = codewords[codewordsRow];\n codeword.setRowNumberAsRowIndicatorColumn();\n let rowDifference = codeword.getRowNumber() - barcodeRow;\n // TODO improve handling with case where first row indicator doesn't start with 0\n if (rowDifference === 0) ;\n else if (rowDifference === 1) {\n barcodeRow = codeword.getRowNumber();\n }\n else if (codeword.getRowNumber() >= barcodeMetadata.getRowCount()) {\n codewords[codewordsRow] = null;\n }\n else {\n barcodeRow = codeword.getRowNumber();\n }\n }\n // return (int) (averageRowHeight + 0.5);\n }\n getBarcodeMetadata() {\n let codewords = this.getCodewords();\n let barcodeColumnCount = new BarcodeValue();\n let barcodeRowCountUpperPart = new BarcodeValue();\n let barcodeRowCountLowerPart = new BarcodeValue();\n let barcodeECLevel = new BarcodeValue();\n for (let codeword /*Codeword*/ of codewords) {\n if (codeword == null) {\n continue;\n }\n codeword.setRowNumberAsRowIndicatorColumn();\n let rowIndicatorValue = codeword.getValue() % 30;\n let codewordRowNumber = codeword.getRowNumber();\n if (!this._isLeft) {\n codewordRowNumber += 2;\n }\n switch (codewordRowNumber % 3) {\n case 0:\n barcodeRowCountUpperPart.setValue(rowIndicatorValue * 3 + 1);\n break;\n case 1:\n barcodeECLevel.setValue(rowIndicatorValue / 3);\n barcodeRowCountLowerPart.setValue(rowIndicatorValue % 3);\n break;\n case 2:\n barcodeColumnCount.setValue(rowIndicatorValue + 1);\n break;\n }\n }\n // Maybe we should check if we have ambiguous values?\n if ((barcodeColumnCount.getValue().length === 0) ||\n (barcodeRowCountUpperPart.getValue().length === 0) ||\n (barcodeRowCountLowerPart.getValue().length === 0) ||\n (barcodeECLevel.getValue().length === 0) ||\n barcodeColumnCount.getValue()[0] < 1 ||\n barcodeRowCountUpperPart.getValue()[0] + barcodeRowCountLowerPart.getValue()[0] < PDF417Common.MIN_ROWS_IN_BARCODE ||\n barcodeRowCountUpperPart.getValue()[0] + barcodeRowCountLowerPart.getValue()[0] > PDF417Common.MAX_ROWS_IN_BARCODE) {\n return null;\n }\n let barcodeMetadata = new BarcodeMetadata(barcodeColumnCount.getValue()[0], barcodeRowCountUpperPart.getValue()[0], barcodeRowCountLowerPart.getValue()[0], barcodeECLevel.getValue()[0]);\n this.removeIncorrectCodewords(codewords, barcodeMetadata);\n return barcodeMetadata;\n }\n removeIncorrectCodewords(codewords, barcodeMetadata) {\n // Remove codewords which do not match the metadata\n // TODO Maybe we should keep the incorrect codewords for the start and end positions?\n for (let codewordRow /*int*/ = 0; codewordRow < codewords.length; codewordRow++) {\n let codeword = codewords[codewordRow];\n if (codewords[codewordRow] == null) {\n continue;\n }\n let rowIndicatorValue = codeword.getValue() % 30;\n let codewordRowNumber = codeword.getRowNumber();\n if (codewordRowNumber > barcodeMetadata.getRowCount()) {\n codewords[codewordRow] = null;\n continue;\n }\n if (!this._isLeft) {\n codewordRowNumber += 2;\n }\n switch (codewordRowNumber % 3) {\n case 0:\n if (rowIndicatorValue * 3 + 1 !== barcodeMetadata.getRowCountUpperPart()) {\n codewords[codewordRow] = null;\n }\n break;\n case 1:\n if (Math.trunc(rowIndicatorValue / 3) !== barcodeMetadata.getErrorCorrectionLevel() ||\n rowIndicatorValue % 3 !== barcodeMetadata.getRowCountLowerPart()) {\n codewords[codewordRow] = null;\n }\n break;\n case 2:\n if (rowIndicatorValue + 1 !== barcodeMetadata.getColumnCount()) {\n codewords[codewordRow] = null;\n }\n break;\n }\n }\n }\n isLeft() {\n return this._isLeft;\n }\n // @Override\n toString() {\n return 'IsLeft: ' + this._isLeft + '\\n' + super.toString();\n }\n }\n\n /*\n * Copyright 2013 ZXing authors\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n /**\n * @author Guenther Grau\n */\n /*final*/ class DetectionResult {\n constructor(barcodeMetadata, boundingBox) {\n /*final*/ this.ADJUST_ROW_NUMBER_SKIP = 2;\n this.barcodeMetadata = barcodeMetadata;\n this.barcodeColumnCount = barcodeMetadata.getColumnCount();\n this.boundingBox = boundingBox;\n // this.detectionResultColumns = new DetectionResultColumn[this.barcodeColumnCount + 2];\n this.detectionResultColumns = new Array(this.barcodeColumnCount + 2);\n }\n getDetectionResultColumns() {\n this.adjustIndicatorColumnRowNumbers(this.detectionResultColumns[0]);\n this.adjustIndicatorColumnRowNumbers(this.detectionResultColumns[this.barcodeColumnCount + 1]);\n let unadjustedCodewordCount = PDF417Common.MAX_CODEWORDS_IN_BARCODE;\n let previousUnadjustedCount;\n do {\n previousUnadjustedCount = unadjustedCodewordCount;\n unadjustedCodewordCount = this.adjustRowNumbersAndGetCount();\n } while (unadjustedCodewordCount > 0 && unadjustedCodewordCount < previousUnadjustedCount);\n return this.detectionResultColumns;\n }\n adjustIndicatorColumnRowNumbers(detectionResultColumn) {\n if (detectionResultColumn != null) {\n detectionResultColumn\n .adjustCompleteIndicatorColumnRowNumbers(this.barcodeMetadata);\n }\n }\n // TODO ensure that no detected codewords with unknown row number are left\n // we should be able to estimate the row height and use it as a hint for the row number\n // we should also fill the rows top to bottom and bottom to top\n /**\n * @return number of codewords which don't have a valid row number. Note that the count is not accurate as codewords\n * will be counted several times. It just serves as an indicator to see when we can stop adjusting row numbers\n */\n adjustRowNumbersAndGetCount() {\n let unadjustedCount = this.adjustRowNumbersByRow();\n if (unadjustedCount === 0) {\n return 0;\n }\n for (let barcodeColumn /*int*/ = 1; barcodeColumn < this.barcodeColumnCount + 1; barcodeColumn++) {\n let codewords = this.detectionResultColumns[barcodeColumn].getCodewords();\n for (let codewordsRow /*int*/ = 0; codewordsRow < codewords.length; codewordsRow++) {\n if (codewords[codewordsRow] == null) {\n continue;\n }\n if (!codewords[codewordsRow].hasValidRowNumber()) {\n this.adjustRowNumbers(barcodeColumn, codewordsRow, codewords);\n }\n }\n }\n return unadjustedCount;\n }\n adjustRowNumbersByRow() {\n this.adjustRowNumbersFromBothRI();\n // TODO we should only do full row adjustments if row numbers of left and right row indicator column match.\n // Maybe it's even better to calculated the height (rows: d) and divide it by the number of barcode\n // rows. This, together with the LRI and RRI row numbers should allow us to get a good estimate where a row\n // number starts and ends.\n let unadjustedCount = this.adjustRowNumbersFromLRI();\n return unadjustedCount + this.adjustRowNumbersFromRRI();\n }\n adjustRowNumbersFromBothRI() {\n if (this.detectionResultColumns[0] == null || this.detectionResultColumns[this.barcodeColumnCount + 1] == null) {\n return;\n }\n let LRIcodewords = this.detectionResultColumns[0].getCodewords();\n let RRIcodewords = this.detectionResultColumns[this.barcodeColumnCount + 1].getCodewords();\n for (let codewordsRow /*int*/ = 0; codewordsRow < LRIcodewords.length; codewordsRow++) {\n if (LRIcodewords[codewordsRow] != null &&\n RRIcodewords[codewordsRow] != null &&\n LRIcodewords[codewordsRow].getRowNumber() === RRIcodewords[codewordsRow].getRowNumber()) {\n for (let barcodeColumn /*int*/ = 1; barcodeColumn <= this.barcodeColumnCount; barcodeColumn++) {\n let codeword = this.detectionResultColumns[barcodeColumn].getCodewords()[codewordsRow];\n if (codeword == null) {\n continue;\n }\n codeword.setRowNumber(LRIcodewords[codewordsRow].getRowNumber());\n if (!codeword.hasValidRowNumber()) {\n this.detectionResultColumns[barcodeColumn].getCodewords()[codewordsRow] = null;\n }\n }\n }\n }\n }\n adjustRowNumbersFromRRI() {\n if (this.detectionResultColumns[this.barcodeColumnCount + 1] == null) {\n return 0;\n }\n let unadjustedCount = 0;\n let codewords = this.detectionResultColumns[this.barcodeColumnCount + 1].getCodewords();\n for (let codewordsRow /*int*/ = 0; codewordsRow < codewords.length; codewordsRow++) {\n if (codewords[codewordsRow] == null) {\n continue;\n }\n let rowIndicatorRowNumber = codewords[codewordsRow].getRowNumber();\n let invalidRowCounts = 0;\n for (let barcodeColumn /*int*/ = this.barcodeColumnCount + 1; barcodeColumn > 0 && invalidRowCounts < this.ADJUST_ROW_NUMBER_SKIP; barcodeColumn--) {\n let codeword = this.detectionResultColumns[barcodeColumn].getCodewords()[codewordsRow];\n if (codeword != null) {\n invalidRowCounts = DetectionResult.adjustRowNumberIfValid(rowIndicatorRowNumber, invalidRowCounts, codeword);\n if (!codeword.hasValidRowNumber()) {\n unadjustedCount++;\n }\n }\n }\n }\n return unadjustedCount;\n }\n adjustRowNumbersFromLRI() {\n if (this.detectionResultColumns[0] == null) {\n return 0;\n }\n let unadjustedCount = 0;\n let codewords = this.detectionResultColumns[0].getCodewords();\n for (let codewordsRow /*int*/ = 0; codewordsRow < codewords.length; codewordsRow++) {\n if (codewords[codewordsRow] == null) {\n continue;\n }\n let rowIndicatorRowNumber = codewords[codewordsRow].getRowNumber();\n let invalidRowCounts = 0;\n for (let barcodeColumn /*int*/ = 1; barcodeColumn < this.barcodeColumnCount + 1 && invalidRowCounts < this.ADJUST_ROW_NUMBER_SKIP; barcodeColumn++) {\n let codeword = this.detectionResultColumns[barcodeColumn].getCodewords()[codewordsRow];\n if (codeword != null) {\n invalidRowCounts = DetectionResult.adjustRowNumberIfValid(rowIndicatorRowNumber, invalidRowCounts, codeword);\n if (!codeword.hasValidRowNumber()) {\n unadjustedCount++;\n }\n }\n }\n }\n return unadjustedCount;\n }\n static adjustRowNumberIfValid(rowIndicatorRowNumber, invalidRowCounts, codeword) {\n if (codeword == null) {\n return invalidRowCounts;\n }\n if (!codeword.hasValidRowNumber()) {\n if (codeword.isValidRowNumber(rowIndicatorRowNumber)) {\n codeword.setRowNumber(rowIndicatorRowNumber);\n invalidRowCounts = 0;\n }\n else {\n ++invalidRowCounts;\n }\n }\n return invalidRowCounts;\n }\n adjustRowNumbers(barcodeColumn, codewordsRow, codewords) {\n if (!this.detectionResultColumns[barcodeColumn - 1]) {\n return;\n }\n let codeword = codewords[codewordsRow];\n let previousColumnCodewords = this.detectionResultColumns[barcodeColumn - 1].getCodewords();\n let nextColumnCodewords = previousColumnCodewords;\n if (this.detectionResultColumns[barcodeColumn + 1] != null) {\n nextColumnCodewords = this.detectionResultColumns[barcodeColumn + 1].getCodewords();\n }\n // let otherCodewords: Codeword[] = new Codeword[14];\n let otherCodewords = new Array(14);\n otherCodewords[2] = previousColumnCodewords[codewordsRow];\n otherCodewords[3] = nextColumnCodewords[codewordsRow];\n if (codewordsRow > 0) {\n otherCodewords[0] = codewords[codewordsRow - 1];\n otherCodewords[4] = previousColumnCodewords[codewordsRow - 1];\n otherCodewords[5] = nextColumnCodewords[codewordsRow - 1];\n }\n if (codewordsRow > 1) {\n otherCodewords[8] = codewords[codewordsRow - 2];\n otherCodewords[10] = previousColumnCodewords[codewordsRow - 2];\n otherCodewords[11] = nextColumnCodewords[codewordsRow - 2];\n }\n if (codewordsRow < codewords.length - 1) {\n otherCodewords[1] = codewords[codewordsRow + 1];\n otherCodewords[6] = previousColumnCodewords[codewordsRow + 1];\n otherCodewords[7] = nextColumnCodewords[codewordsRow + 1];\n }\n if (codewordsRow < codewords.length - 2) {\n otherCodewords[9] = codewords[codewordsRow + 2];\n otherCodewords[12] = previousColumnCodewords[codewordsRow + 2];\n otherCodewords[13] = nextColumnCodewords[codewordsRow + 2];\n }\n for (let otherCodeword of otherCodewords) {\n if (DetectionResult.adjustRowNumber(codeword, otherCodeword)) {\n return;\n }\n }\n }\n /**\n * @return true, if row number was adjusted, false otherwise\n */\n static adjustRowNumber(codeword, otherCodeword) {\n if (otherCodeword == null) {\n return false;\n }\n if (otherCodeword.hasValidRowNumber() && otherCodeword.getBucket() === codeword.getBucket()) {\n codeword.setRowNumber(otherCodeword.getRowNumber());\n return true;\n }\n return false;\n }\n getBarcodeColumnCount() {\n return this.barcodeColumnCount;\n }\n getBarcodeRowCount() {\n return this.barcodeMetadata.getRowCount();\n }\n getBarcodeECLevel() {\n return this.barcodeMetadata.getErrorCorrectionLevel();\n }\n setBoundingBox(boundingBox) {\n this.boundingBox = boundingBox;\n }\n getBoundingBox() {\n return this.boundingBox;\n }\n setDetectionResultColumn(barcodeColumn, detectionResultColumn) {\n this.detectionResultColumns[barcodeColumn] = detectionResultColumn;\n }\n getDetectionResultColumn(barcodeColumn) {\n return this.detectionResultColumns[barcodeColumn];\n }\n // @Override\n toString() {\n let rowIndicatorColumn = this.detectionResultColumns[0];\n if (rowIndicatorColumn == null) {\n rowIndicatorColumn = this.detectionResultColumns[this.barcodeColumnCount + 1];\n }\n // try (\n let formatter = new Formatter();\n // ) {\n for (let codewordsRow /*int*/ = 0; codewordsRow < rowIndicatorColumn.getCodewords().length; codewordsRow++) {\n formatter.format('CW %3d:', codewordsRow);\n for (let barcodeColumn /*int*/ = 0; barcodeColumn < this.barcodeColumnCount + 2; barcodeColumn++) {\n if (this.detectionResultColumns[barcodeColumn] == null) {\n formatter.format(' | ');\n continue;\n }\n let codeword = this.detectionResultColumns[barcodeColumn].getCodewords()[codewordsRow];\n if (codeword == null) {\n formatter.format(' | ');\n continue;\n }\n formatter.format(' %3d|%3d', codeword.getRowNumber(), codeword.getValue());\n }\n formatter.format('%n');\n }\n return formatter.toString();\n // }\n }\n }\n\n /*\n * Copyright 2013 ZXing authors\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n // package com.google.zxing.pdf417.decoder;\n /**\n * @author Guenther Grau\n */\n /*final*/ class Codeword {\n constructor(startX, endX, bucket, value) {\n this.rowNumber = Codeword.BARCODE_ROW_UNKNOWN;\n this.startX = Math.trunc(startX);\n this.endX = Math.trunc(endX);\n this.bucket = Math.trunc(bucket);\n this.value = Math.trunc(value);\n }\n hasValidRowNumber() {\n return this.isValidRowNumber(this.rowNumber);\n }\n isValidRowNumber(rowNumber) {\n return rowNumber !== Codeword.BARCODE_ROW_UNKNOWN && this.bucket === (rowNumber % 3) * 3;\n }\n setRowNumberAsRowIndicatorColumn() {\n this.rowNumber = Math.trunc((Math.trunc(this.value / 30)) * 3 + Math.trunc(this.bucket / 3));\n }\n getWidth() {\n return this.endX - this.startX;\n }\n getStartX() {\n return this.startX;\n }\n getEndX() {\n return this.endX;\n }\n getBucket() {\n return this.bucket;\n }\n getValue() {\n return this.value;\n }\n getRowNumber() {\n return this.rowNumber;\n }\n setRowNumber(rowNumber) {\n this.rowNumber = rowNumber;\n }\n // @Override\n toString() {\n return this.rowNumber + '|' + this.value;\n }\n }\n Codeword.BARCODE_ROW_UNKNOWN = -1;\n\n /*\n * Copyright 2013 ZXing authors\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n /**\n * @author Guenther Grau\n * @author creatale GmbH (christoph.schulz@creatale.de)\n */\n /*final*/ class PDF417CodewordDecoder {\n /* @note\n * this action have to be performed before first use of class\n * - static constructor\n * working with 32bit float (based from Java logic)\n */\n static initialize() {\n // Pre-computes the symbol ratio table.\n for ( /*int*/let i = 0; i < PDF417Common.SYMBOL_TABLE.length; i++) {\n let currentSymbol = PDF417Common.SYMBOL_TABLE[i];\n let currentBit = currentSymbol & 0x1;\n for ( /*int*/let j = 0; j < PDF417Common.BARS_IN_MODULE; j++) {\n let size = 0.0;\n while ((currentSymbol & 0x1) === currentBit) {\n size += 1.0;\n currentSymbol >>= 1;\n }\n currentBit = currentSymbol & 0x1;\n if (!PDF417CodewordDecoder.RATIOS_TABLE[i]) {\n PDF417CodewordDecoder.RATIOS_TABLE[i] = new Array(PDF417Common.BARS_IN_MODULE);\n }\n PDF417CodewordDecoder.RATIOS_TABLE[i][PDF417Common.BARS_IN_MODULE - j - 1] = Math.fround(size / PDF417Common.MODULES_IN_CODEWORD);\n }\n }\n this.bSymbolTableReady = true;\n }\n static getDecodedValue(moduleBitCount) {\n let decodedValue = PDF417CodewordDecoder.getDecodedCodewordValue(PDF417CodewordDecoder.sampleBitCounts(moduleBitCount));\n if (decodedValue !== -1) {\n return decodedValue;\n }\n return PDF417CodewordDecoder.getClosestDecodedValue(moduleBitCount);\n }\n static sampleBitCounts(moduleBitCount) {\n let bitCountSum = MathUtils.sum(moduleBitCount);\n let result = new Int32Array(PDF417Common.BARS_IN_MODULE);\n let bitCountIndex = 0;\n let sumPreviousBits = 0;\n for ( /*int*/let i = 0; i < PDF417Common.MODULES_IN_CODEWORD; i++) {\n let sampleIndex = bitCountSum / (2 * PDF417Common.MODULES_IN_CODEWORD) +\n (i * bitCountSum) / PDF417Common.MODULES_IN_CODEWORD;\n if (sumPreviousBits + moduleBitCount[bitCountIndex] <= sampleIndex) {\n sumPreviousBits += moduleBitCount[bitCountIndex];\n bitCountIndex++;\n }\n result[bitCountIndex]++;\n }\n return result;\n }\n static getDecodedCodewordValue(moduleBitCount) {\n let decodedValue = PDF417CodewordDecoder.getBitValue(moduleBitCount);\n return PDF417Common.getCodeword(decodedValue) === -1 ? -1 : decodedValue;\n }\n static getBitValue(moduleBitCount) {\n let result = /*long*/ 0;\n for (let /*int*/ i = 0; i < moduleBitCount.length; i++) {\n for ( /*int*/let bit = 0; bit < moduleBitCount[i]; bit++) {\n result = (result << 1) | (i % 2 === 0 ? 1 : 0);\n }\n }\n return Math.trunc(result);\n }\n // working with 32bit float (as in Java)\n static getClosestDecodedValue(moduleBitCount) {\n let bitCountSum = MathUtils.sum(moduleBitCount);\n let bitCountRatios = new Array(PDF417Common.BARS_IN_MODULE);\n if (bitCountSum > 1) {\n for (let /*int*/ i = 0; i < bitCountRatios.length; i++) {\n bitCountRatios[i] = Math.fround(moduleBitCount[i] / bitCountSum);\n }\n }\n let bestMatchError = Float.MAX_VALUE;\n let bestMatch = -1;\n if (!this.bSymbolTableReady) {\n PDF417CodewordDecoder.initialize();\n }\n for ( /*int*/let j = 0; j < PDF417CodewordDecoder.RATIOS_TABLE.length; j++) {\n let error = 0.0;\n let ratioTableRow = PDF417CodewordDecoder.RATIOS_TABLE[j];\n for ( /*int*/let k = 0; k < PDF417Common.BARS_IN_MODULE; k++) {\n let diff = Math.fround(ratioTableRow[k] - bitCountRatios[k]);\n error += Math.fround(diff * diff);\n if (error >= bestMatchError) {\n break;\n }\n }\n if (error < bestMatchError) {\n bestMatchError = error;\n bestMatch = PDF417Common.SYMBOL_TABLE[j];\n }\n }\n return bestMatch;\n }\n }\n // flag that the table is ready for use\n PDF417CodewordDecoder.bSymbolTableReady = false;\n PDF417CodewordDecoder.RATIOS_TABLE = new Array(PDF417Common.SYMBOL_TABLE.length).map(x => x = new Array(PDF417Common.BARS_IN_MODULE));\n\n /*\n * Copyright 2013 ZXing authors\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n // package com.google.zxing.pdf417;\n /**\n * @author Guenther Grau\n */\n /*public final*/ class PDF417ResultMetadata {\n constructor() {\n this.segmentCount = -1;\n this.fileSize = -1;\n this.timestamp = -1;\n this.checksum = -1;\n }\n /**\n * The Segment ID represents the segment of the whole file distributed over different symbols.\n *\n * @return File segment index\n */\n getSegmentIndex() {\n return this.segmentIndex;\n }\n setSegmentIndex(segmentIndex) {\n this.segmentIndex = segmentIndex;\n }\n /**\n * Is the same for each related PDF417 symbol\n *\n * @return File ID\n */\n getFileId() {\n return this.fileId;\n }\n setFileId(fileId) {\n this.fileId = fileId;\n }\n /**\n * @return always null\n * @deprecated use dedicated already parsed fields\n */\n // @Deprecated\n getOptionalData() {\n return this.optionalData;\n }\n /**\n * @param optionalData old optional data format as int array\n * @deprecated parse and use new fields\n */\n // @Deprecated\n setOptionalData(optionalData) {\n this.optionalData = optionalData;\n }\n /**\n * @return true if it is the last segment\n */\n isLastSegment() {\n return this.lastSegment;\n }\n setLastSegment(lastSegment) {\n this.lastSegment = lastSegment;\n }\n /**\n * @return count of segments, -1 if not set\n */\n getSegmentCount() {\n return this.segmentCount;\n }\n setSegmentCount(segmentCount /*int*/) {\n this.segmentCount = segmentCount;\n }\n getSender() {\n return this.sender || null;\n }\n setSender(sender) {\n this.sender = sender;\n }\n getAddressee() {\n return this.addressee || null;\n }\n setAddressee(addressee) {\n this.addressee = addressee;\n }\n /**\n * Filename of the encoded file\n *\n * @return filename\n */\n getFileName() {\n return this.fileName;\n }\n setFileName(fileName) {\n this.fileName = fileName;\n }\n /**\n * filesize in bytes of the encoded file\n *\n * @return filesize in bytes, -1 if not set\n */\n getFileSize() {\n return this.fileSize;\n }\n setFileSize(fileSize /*long*/) {\n this.fileSize = fileSize;\n }\n /**\n * 16-bit CRC checksum using CCITT-16\n *\n * @return crc checksum, -1 if not set\n */\n getChecksum() {\n return this.checksum;\n }\n setChecksum(checksum /*int*/) {\n this.checksum = checksum;\n }\n /**\n * unix epock timestamp, elapsed seconds since 1970-01-01\n *\n * @return elapsed seconds, -1 if not set\n */\n getTimestamp() {\n return this.timestamp;\n }\n setTimestamp(timestamp /*long*/) {\n this.timestamp = timestamp;\n }\n }\n\n /**\n * Ponyfill for Java's Long class.\n */\n class Long {\n /**\n * Parses a string to a number, since JS has no really Int64.\n *\n * @param num Numeric string.\n * @param radix Destination radix.\n */\n static parseLong(num, radix = undefined) {\n return parseInt(num, radix);\n }\n }\n\n /**\n * Custom Error class of type Exception.\n */\n class NullPointerException extends Exception {\n }\n NullPointerException.kind = 'NullPointerException';\n\n /*\n * Copyright (c) 1994, 2004, Oracle and/or its affiliates. All rights reserved.\n * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.\n *\n * This code is free software; you can redistribute it and/or modify it\n * under the terms of the GNU General Public License version 2 only, as\n * published by the Free Software Foundation. Oracle designates this\n * particular file as subject to the \"Classpath\" exception as provided\n * by Oracle in the LICENSE file that accompanied this code.\n *\n * This code is distributed in the hope that it will be useful, but WITHOUT\n * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or\n * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License\n * version 2 for more details (a copy is included in the LICENSE file that\n * accompanied this code).\n *\n * You should have received a copy of the GNU General Public License version\n * 2 along with this work; if not, write to the Free Software Foundation,\n * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.\n *\n * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA\n * or visit www.oracle.com if you need additional information or have any\n * questions.\n */\n // package java.io;\n /**\n * This abstract class is the superclass of all classes representing\n * an output stream of bytes. An output stream accepts output bytes\n * and sends them to some sink.\n * \n * Applications that need to define a subclass of\n * OutputStream
must always provide at least a method\n * that writes one byte of output.\n *\n * @author Arthur van Hoff\n * @see java.io.BufferedOutputStream\n * @see java.io.ByteArrayOutputStream\n * @see java.io.DataOutputStream\n * @see java.io.FilterOutputStream\n * @see java.io.InputStream\n * @see java.io.OutputStream#write(int)\n * @since JDK1.0\n */\n /*public*/ class OutputStream /*implements Closeable, Flushable*/ {\n /**\n * Writes b.length
bytes from the specified byte array\n * to this output stream. The general contract for write(b)
\n * is that it should have exactly the same effect as the call\n * write(b, 0, b.length)
.\n *\n * @param b the data.\n * @exception IOException if an I/O error occurs.\n * @see java.io.OutputStream#write(byte[], int, int)\n */\n writeBytes(b) {\n this.writeBytesOffset(b, 0, b.length);\n }\n /**\n * Writes len
bytes from the specified byte array\n * starting at offset off
to this output stream.\n * The general contract for write(b, off, len)
is that\n * some of the bytes in the array b
are written to the\n * output stream in order; element b[off]
is the first\n * byte written and b[off+len-1]
is the last byte written\n * by this operation.\n *
\n * The write
method of OutputStream
calls\n * the write method of one argument on each of the bytes to be\n * written out. Subclasses are encouraged to override this method and\n * provide a more efficient implementation.\n *
\n * If b
is null
, a\n * NullPointerException
is thrown.\n *
\n * If off
is negative, or len
is negative, or\n * off+len
is greater than the length of the array\n * b
, then an IndexOutOfBoundsException is thrown.\n *\n * @param b the data.\n * @param off the start offset in the data.\n * @param len the number of bytes to write.\n * @exception IOException if an I/O error occurs. In particular,\n * an IOException
is thrown if the output\n * stream is closed.\n */\n writeBytesOffset(b, off, len) {\n if (b == null) {\n throw new NullPointerException();\n }\n else if ((off < 0) || (off > b.length) || (len < 0) ||\n ((off + len) > b.length) || ((off + len) < 0)) {\n throw new IndexOutOfBoundsException();\n }\n else if (len === 0) {\n return;\n }\n for (let i = 0; i < len; i++) {\n this.write(b[off + i]);\n }\n }\n /**\n * Flushes this output stream and forces any buffered output bytes\n * to be written out. The general contract of flush
is\n * that calling it is an indication that, if any bytes previously\n * written have been buffered by the implementation of the output\n * stream, such bytes should immediately be written to their\n * intended destination.\n *
\n * If the intended destination of this stream is an abstraction provided by\n * the underlying operating system, for example a file, then flushing the\n * stream guarantees only that bytes previously written to the stream are\n * passed to the operating system for writing; it does not guarantee that\n * they are actually written to a physical device such as a disk drive.\n *
\n * The flush
method of OutputStream
does nothing.\n *\n * @exception IOException if an I/O error occurs.\n */\n flush() {\n }\n /**\n * Closes this output stream and releases any system resources\n * associated with this stream. The general contract of close
\n * is that it closes the output stream. A closed stream cannot perform\n * output operations and cannot be reopened.\n *
\n * The close
method of OutputStream
does nothing.\n *\n * @exception IOException if an I/O error occurs.\n */\n close() {\n }\n }\n\n /**\n * Custom Error class of type Exception.\n */\n class OutOfMemoryError extends Exception {\n }\n\n /*\n * Copyright (c) 1994, 2010, Oracle and/or its affiliates. All rights reserved.\n * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.\n *\n * This code is free software; you can redistribute it and/or modify it\n * under the terms of the GNU General Public License version 2 only, as\n * published by the Free Software Foundation. Oracle designates this\n * particular file as subject to the \"Classpath\" exception as provided\n * by Oracle in the LICENSE file that accompanied this code.\n *\n * This code is distributed in the hope that it will be useful, but WITHOUT\n * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or\n * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License\n * version 2 for more details (a copy is included in the LICENSE file that\n * accompanied this code).\n *\n * You should have received a copy of the GNU General Public License version\n * 2 along with this work; if not, write to the Free Software Foundation,\n * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.\n *\n * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA\n * or visit www.oracle.com if you need additional information or have any\n * questions.\n */\n /**\n * This class implements an output stream in which the data is\n * written into a byte array. The buffer automatically grows as data\n * is written to it.\n * The data can be retrieved using toByteArray()
and\n * toString()
.\n *
\n * Closing a ByteArrayOutputStream has no effect. The methods in\n * this class can be called after the stream has been closed without\n * generating an IOException.\n *\n * @author Arthur van Hoff\n * @since JDK1.0\n */\n /*public*/ class ByteArrayOutputStream extends OutputStream {\n /**\n * Creates a new byte array output stream. The buffer capacity is\n * initially 32 bytes, though its size increases if necessary.\n */\n // public constructor() {\n // this(32);\n // }\n /**\n * Creates a new byte array output stream, with a buffer capacity of\n * the specified size, in bytes.\n *\n * @param size the initial size.\n * @exception IllegalArgumentException if size is negative.\n */\n constructor(size = 32) {\n super();\n /**\n * The number of valid bytes in the buffer.\n */\n this.count = 0;\n if (size < 0) {\n throw new IllegalArgumentException('Negative initial size: '\n + size);\n }\n this.buf = new Uint8Array(size);\n }\n /**\n * Increases the capacity if necessary to ensure that it can hold\n * at least the number of elements specified by the minimum\n * capacity argument.\n *\n * @param minCapacity the desired minimum capacity\n * @throws OutOfMemoryError if {@code minCapacity < 0}. This is\n * interpreted as a request for the unsatisfiably large capacity\n * {@code (long) Integer.MAX_VALUE + (minCapacity - Integer.MAX_VALUE)}.\n */\n ensureCapacity(minCapacity) {\n // overflow-conscious code\n if (minCapacity - this.buf.length > 0)\n this.grow(minCapacity);\n }\n /**\n * Increases the capacity to ensure that it can hold at least the\n * number of elements specified by the minimum capacity argument.\n *\n * @param minCapacity the desired minimum capacity\n */\n grow(minCapacity) {\n // overflow-conscious code\n let oldCapacity = this.buf.length;\n let newCapacity = oldCapacity << 1;\n if (newCapacity - minCapacity < 0)\n newCapacity = minCapacity;\n if (newCapacity < 0) {\n if (minCapacity < 0) // overflow\n throw new OutOfMemoryError();\n newCapacity = Integer.MAX_VALUE;\n }\n this.buf = Arrays.copyOfUint8Array(this.buf, newCapacity);\n }\n /**\n * Writes the specified byte to this byte array output stream.\n *\n * @param b the byte to be written.\n */\n write(b) {\n this.ensureCapacity(this.count + 1);\n this.buf[this.count] = /*(byte)*/ b;\n this.count += 1;\n }\n /**\n * Writes len
bytes from the specified byte array\n * starting at offset off
to this byte array output stream.\n *\n * @param b the data.\n * @param off the start offset in the data.\n * @param len the number of bytes to write.\n */\n writeBytesOffset(b, off, len) {\n if ((off < 0) || (off > b.length) || (len < 0) ||\n ((off + len) - b.length > 0)) {\n throw new IndexOutOfBoundsException();\n }\n this.ensureCapacity(this.count + len);\n System.arraycopy(b, off, this.buf, this.count, len);\n this.count += len;\n }\n /**\n * Writes the complete contents of this byte array output stream to\n * the specified output stream argument, as if by calling the output\n * stream's write method using out.write(buf, 0, count)
.\n *\n * @param out the output stream to which to write the data.\n * @exception IOException if an I/O error occurs.\n */\n writeTo(out) {\n out.writeBytesOffset(this.buf, 0, this.count);\n }\n /**\n * Resets the count
field of this byte array output\n * stream to zero, so that all currently accumulated output in the\n * output stream is discarded. The output stream can be used again,\n * reusing the already allocated buffer space.\n *\n * @see java.io.ByteArrayInputStream#count\n */\n reset() {\n this.count = 0;\n }\n /**\n * Creates a newly allocated byte array. Its size is the current\n * size of this output stream and the valid contents of the buffer\n * have been copied into it.\n *\n * @return the current contents of this output stream, as a byte array.\n * @see java.io.ByteArrayOutputStream#size()\n */\n toByteArray() {\n return Arrays.copyOfUint8Array(this.buf, this.count);\n }\n /**\n * Returns the current size of the buffer.\n *\n * @return the value of the count
field, which is the number\n * of valid bytes in this output stream.\n * @see java.io.ByteArrayOutputStream#count\n */\n size() {\n return this.count;\n }\n toString(param) {\n if (!param) {\n return this.toString_void();\n }\n if (typeof param === 'string') {\n return this.toString_string(param);\n }\n return this.toString_number(param);\n }\n /**\n * Converts the buffer's contents into a string decoding bytes using the\n * platform's default character set. The length of the new String\n * is a function of the character set, and hence may not be equal to the\n * size of the buffer.\n *\n *
This method always replaces malformed-input and unmappable-character\n * sequences with the default replacement string for the platform's\n * default character set. The {@linkplain java.nio.charset.CharsetDecoder}\n * class should be used when more control over the decoding process is\n * required.\n *\n * @return String decoded from the buffer's contents.\n * @since JDK1.1\n */\n toString_void() {\n return new String(this.buf /*, 0, this.count*/).toString();\n }\n /**\n * Converts the buffer's contents into a string by decoding the bytes using\n * the specified {@link java.nio.charset.Charset charsetName}. The length of\n * the new String is a function of the charset, and hence may not be\n * equal to the length of the byte array.\n *\n *
This method always replaces malformed-input and unmappable-character\n * sequences with this charset's default replacement string. The {@link\n * java.nio.charset.CharsetDecoder} class should be used when more control\n * over the decoding process is required.\n *\n * @param charsetName the name of a supported\n * {@linkplain java.nio.charset.Charset charset}\n * @return String decoded from the buffer's contents.\n * @exception UnsupportedEncodingException\n * If the named charset is not supported\n * @since JDK1.1\n */\n toString_string(charsetName) {\n return new String(this.buf /*, 0, this.count, charsetName*/).toString();\n }\n /**\n * Creates a newly allocated string. Its size is the current size of\n * the output stream and the valid contents of the buffer have been\n * copied into it. Each character c in the resulting string is\n * constructed from the corresponding element b in the byte\n * array such that:\n * \n * c == (char)(((hibyte & 0xff) << 8) | (b & 0xff))\n *
\n *\n * @deprecated This method does not properly convert bytes into characters.\n * As of JDK 1.1, the preferred way to do this is via the\n * toString(String enc)
method, which takes an encoding-name\n * argument, or the toString()
method, which uses the\n * platform's default character encoding.\n *\n * @param hibyte the high byte of each resulting Unicode character.\n * @return the current contents of the output stream, as a string.\n * @see java.io.ByteArrayOutputStream#size()\n * @see java.io.ByteArrayOutputStream#toString(String)\n * @see java.io.ByteArrayOutputStream#toString()\n */\n // @Deprecated\n toString_number(hibyte) {\n return new String(this.buf /*, hibyte, 0, this.count*/).toString();\n }\n /**\n * Closing a ByteArrayOutputStream has no effect. The methods in\n * this class can be called after the stream has been closed without\n * generating an IOException.\n * \n *\n * @throws IOException\n */\n close() {\n }\n }\n\n /*\n * Copyright 2009 ZXing authors\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n /*private*/ var Mode$2;\n (function (Mode) {\n Mode[Mode[\"ALPHA\"] = 0] = \"ALPHA\";\n Mode[Mode[\"LOWER\"] = 1] = \"LOWER\";\n Mode[Mode[\"MIXED\"] = 2] = \"MIXED\";\n Mode[Mode[\"PUNCT\"] = 3] = \"PUNCT\";\n Mode[Mode[\"ALPHA_SHIFT\"] = 4] = \"ALPHA_SHIFT\";\n Mode[Mode[\"PUNCT_SHIFT\"] = 5] = \"PUNCT_SHIFT\";\n })(Mode$2 || (Mode$2 = {}));\n /**\n * Indirectly access the global BigInt constructor, it\n * allows browsers that doesn't support BigInt to run\n * the library without breaking due to \"undefined BigInt\"\n * errors.\n */\n function getBigIntConstructor() {\n if (typeof window !== 'undefined') {\n return window['BigInt'] || null;\n }\n if (typeof global !== 'undefined') {\n return global['BigInt'] || null;\n }\n if (typeof self !== 'undefined') {\n return self['BigInt'] || null;\n }\n throw new Error('Can\\'t search globals for BigInt!');\n }\n /**\n * Used to store the BigInt constructor.\n */\n let BigInteger;\n /**\n * This function creates a bigint value. It allows browsers\n * that doesn't support BigInt to run the rest of the library\n * by not directly accessing the BigInt constructor.\n */\n function createBigInt(num) {\n if (typeof BigInteger === 'undefined') {\n BigInteger = getBigIntConstructor();\n }\n if (BigInteger === null) {\n throw new Error('BigInt is not supported!');\n }\n return BigInteger(num);\n }\n function getEXP900() {\n // in Java - array with length = 16\n let EXP900 = [];\n EXP900[0] = createBigInt(1);\n let nineHundred = createBigInt(900);\n EXP900[1] = nineHundred;\n // in Java - array with length = 16\n for (let i /*int*/ = 2; i < 16; i++) {\n EXP900[i] = EXP900[i - 1] * nineHundred;\n }\n return EXP900;\n }\n /**\n *
This class contains the methods for decoding the PDF417 codewords.
\n *\n * @author SITA Lab (kevin.osullivan@sita.aero)\n * @author Guenther Grau\n */\n /*final*/ class DecodedBitStreamParser$2 {\n // private DecodedBitStreamParser() {\n // }\n /**\n *\n * @param codewords\n * @param ecLevel\n *\n * @throws FormatException\n */\n static decode(codewords, ecLevel) {\n // pass encoding to result (will be used for decode symbols in byte mode)\n let result = new StringBuilder('');\n // let encoding: Charset = StandardCharsets.ISO_8859_1;\n let encoding = CharacterSetECI.ISO8859_1;\n /**\n * @note the next command is specific from this TypeScript library\n * because TS can't properly cast some values to char and\n * convert it to string later correctly due to encoding\n * differences from Java version. As reported here:\n * https://github.com/zxing-js/library/pull/264/files#r382831593\n */\n result.enableDecoding(encoding);\n // Get compaction mode\n let codeIndex = 1;\n let code = codewords[codeIndex++];\n let resultMetadata = new PDF417ResultMetadata();\n while (codeIndex < codewords[0]) {\n switch (code) {\n case DecodedBitStreamParser$2.TEXT_COMPACTION_MODE_LATCH:\n codeIndex = DecodedBitStreamParser$2.textCompaction(codewords, codeIndex, result);\n break;\n case DecodedBitStreamParser$2.BYTE_COMPACTION_MODE_LATCH:\n case DecodedBitStreamParser$2.BYTE_COMPACTION_MODE_LATCH_6:\n codeIndex = DecodedBitStreamParser$2.byteCompaction(code, codewords, encoding, codeIndex, result);\n break;\n case DecodedBitStreamParser$2.MODE_SHIFT_TO_BYTE_COMPACTION_MODE:\n result.append(/*(char)*/ codewords[codeIndex++]);\n break;\n case DecodedBitStreamParser$2.NUMERIC_COMPACTION_MODE_LATCH:\n codeIndex = DecodedBitStreamParser$2.numericCompaction(codewords, codeIndex, result);\n break;\n case DecodedBitStreamParser$2.ECI_CHARSET:\n let charsetECI = CharacterSetECI.getCharacterSetECIByValue(codewords[codeIndex++]);\n // encoding = Charset.forName(charsetECI.getName());\n break;\n case DecodedBitStreamParser$2.ECI_GENERAL_PURPOSE:\n // Can't do anything with generic ECI; skip its 2 characters\n codeIndex += 2;\n break;\n case DecodedBitStreamParser$2.ECI_USER_DEFINED:\n // Can't do anything with user ECI; skip its 1 character\n codeIndex++;\n break;\n case DecodedBitStreamParser$2.BEGIN_MACRO_PDF417_CONTROL_BLOCK:\n codeIndex = DecodedBitStreamParser$2.decodeMacroBlock(codewords, codeIndex, resultMetadata);\n break;\n case DecodedBitStreamParser$2.BEGIN_MACRO_PDF417_OPTIONAL_FIELD:\n case DecodedBitStreamParser$2.MACRO_PDF417_TERMINATOR:\n // Should not see these outside a macro block\n throw new FormatException();\n default:\n // Default to text compaction. During testing numerous barcodes\n // appeared to be missing the starting mode. In these cases defaulting\n // to text compaction seems to work.\n codeIndex--;\n codeIndex = DecodedBitStreamParser$2.textCompaction(codewords, codeIndex, result);\n break;\n }\n if (codeIndex < codewords.length) {\n code = codewords[codeIndex++];\n }\n else {\n throw FormatException.getFormatInstance();\n }\n }\n if (result.length() === 0) {\n throw FormatException.getFormatInstance();\n }\n let decoderResult = new DecoderResult(null, result.toString(), null, ecLevel);\n decoderResult.setOther(resultMetadata);\n return decoderResult;\n }\n /**\n *\n * @param int\n * @param param1\n * @param codewords\n * @param int\n * @param codeIndex\n * @param PDF417ResultMetadata\n * @param resultMetadata\n *\n * @throws FormatException\n */\n // @SuppressWarnings(\"deprecation\")\n static decodeMacroBlock(codewords, codeIndex, resultMetadata) {\n if (codeIndex + DecodedBitStreamParser$2.NUMBER_OF_SEQUENCE_CODEWORDS > codewords[0]) {\n // we must have at least two bytes left for the segment index\n throw FormatException.getFormatInstance();\n }\n let segmentIndexArray = new Int32Array(DecodedBitStreamParser$2.NUMBER_OF_SEQUENCE_CODEWORDS);\n for (let i /*int*/ = 0; i < DecodedBitStreamParser$2.NUMBER_OF_SEQUENCE_CODEWORDS; i++, codeIndex++) {\n segmentIndexArray[i] = codewords[codeIndex];\n }\n resultMetadata.setSegmentIndex(Integer.parseInt(DecodedBitStreamParser$2.decodeBase900toBase10(segmentIndexArray, DecodedBitStreamParser$2.NUMBER_OF_SEQUENCE_CODEWORDS)));\n let fileId = new StringBuilder();\n codeIndex = DecodedBitStreamParser$2.textCompaction(codewords, codeIndex, fileId);\n resultMetadata.setFileId(fileId.toString());\n let optionalFieldsStart = -1;\n if (codewords[codeIndex] === DecodedBitStreamParser$2.BEGIN_MACRO_PDF417_OPTIONAL_FIELD) {\n optionalFieldsStart = codeIndex + 1;\n }\n while (codeIndex < codewords[0]) {\n switch (codewords[codeIndex]) {\n case DecodedBitStreamParser$2.BEGIN_MACRO_PDF417_OPTIONAL_FIELD:\n codeIndex++;\n switch (codewords[codeIndex]) {\n case DecodedBitStreamParser$2.MACRO_PDF417_OPTIONAL_FIELD_FILE_NAME:\n let fileName = new StringBuilder();\n codeIndex = DecodedBitStreamParser$2.textCompaction(codewords, codeIndex + 1, fileName);\n resultMetadata.setFileName(fileName.toString());\n break;\n case DecodedBitStreamParser$2.MACRO_PDF417_OPTIONAL_FIELD_SENDER:\n let sender = new StringBuilder();\n codeIndex = DecodedBitStreamParser$2.textCompaction(codewords, codeIndex + 1, sender);\n resultMetadata.setSender(sender.toString());\n break;\n case DecodedBitStreamParser$2.MACRO_PDF417_OPTIONAL_FIELD_ADDRESSEE:\n let addressee = new StringBuilder();\n codeIndex = DecodedBitStreamParser$2.textCompaction(codewords, codeIndex + 1, addressee);\n resultMetadata.setAddressee(addressee.toString());\n break;\n case DecodedBitStreamParser$2.MACRO_PDF417_OPTIONAL_FIELD_SEGMENT_COUNT:\n let segmentCount = new StringBuilder();\n codeIndex = DecodedBitStreamParser$2.numericCompaction(codewords, codeIndex + 1, segmentCount);\n resultMetadata.setSegmentCount(Integer.parseInt(segmentCount.toString()));\n break;\n case DecodedBitStreamParser$2.MACRO_PDF417_OPTIONAL_FIELD_TIME_STAMP:\n let timestamp = new StringBuilder();\n codeIndex = DecodedBitStreamParser$2.numericCompaction(codewords, codeIndex + 1, timestamp);\n resultMetadata.setTimestamp(Long.parseLong(timestamp.toString()));\n break;\n case DecodedBitStreamParser$2.MACRO_PDF417_OPTIONAL_FIELD_CHECKSUM:\n let checksum = new StringBuilder();\n codeIndex = DecodedBitStreamParser$2.numericCompaction(codewords, codeIndex + 1, checksum);\n resultMetadata.setChecksum(Integer.parseInt(checksum.toString()));\n break;\n case DecodedBitStreamParser$2.MACRO_PDF417_OPTIONAL_FIELD_FILE_SIZE:\n let fileSize = new StringBuilder();\n codeIndex = DecodedBitStreamParser$2.numericCompaction(codewords, codeIndex + 1, fileSize);\n resultMetadata.setFileSize(Long.parseLong(fileSize.toString()));\n break;\n default:\n throw FormatException.getFormatInstance();\n }\n break;\n case DecodedBitStreamParser$2.MACRO_PDF417_TERMINATOR:\n codeIndex++;\n resultMetadata.setLastSegment(true);\n break;\n default:\n throw FormatException.getFormatInstance();\n }\n }\n // copy optional fields to additional options\n if (optionalFieldsStart !== -1) {\n let optionalFieldsLength = codeIndex - optionalFieldsStart;\n if (resultMetadata.isLastSegment()) {\n // do not include terminator\n optionalFieldsLength--;\n }\n resultMetadata.setOptionalData(Arrays.copyOfRange(codewords, optionalFieldsStart, optionalFieldsStart + optionalFieldsLength));\n }\n return codeIndex;\n }\n /**\n * Text Compaction mode (see 5.4.1.5) permits all printable ASCII characters to be\n * encoded, i.e. values 32 - 126 inclusive in accordance with ISO/IEC 646 (IRV), as\n * well as selected control characters.\n *\n * @param codewords The array of codewords (data + error)\n * @param codeIndex The current index into the codeword array.\n * @param result The decoded data is appended to the result.\n * @return The next index into the codeword array.\n */\n static textCompaction(codewords, codeIndex, result) {\n // 2 character per codeword\n let textCompactionData = new Int32Array((codewords[0] - codeIndex) * 2);\n // Used to hold the byte compaction value if there is a mode shift\n let byteCompactionData = new Int32Array((codewords[0] - codeIndex) * 2);\n let index = 0;\n let end = false;\n while ((codeIndex < codewords[0]) && !end) {\n let code = codewords[codeIndex++];\n if (code < DecodedBitStreamParser$2.TEXT_COMPACTION_MODE_LATCH) {\n textCompactionData[index] = code / 30;\n textCompactionData[index + 1] = code % 30;\n index += 2;\n }\n else {\n switch (code) {\n case DecodedBitStreamParser$2.TEXT_COMPACTION_MODE_LATCH:\n // reinitialize text compaction mode to alpha sub mode\n textCompactionData[index++] = DecodedBitStreamParser$2.TEXT_COMPACTION_MODE_LATCH;\n break;\n case DecodedBitStreamParser$2.BYTE_COMPACTION_MODE_LATCH:\n case DecodedBitStreamParser$2.BYTE_COMPACTION_MODE_LATCH_6:\n case DecodedBitStreamParser$2.NUMERIC_COMPACTION_MODE_LATCH:\n case DecodedBitStreamParser$2.BEGIN_MACRO_PDF417_CONTROL_BLOCK:\n case DecodedBitStreamParser$2.BEGIN_MACRO_PDF417_OPTIONAL_FIELD:\n case DecodedBitStreamParser$2.MACRO_PDF417_TERMINATOR:\n codeIndex--;\n end = true;\n break;\n case DecodedBitStreamParser$2.MODE_SHIFT_TO_BYTE_COMPACTION_MODE:\n // The Mode Shift codeword 913 shall cause a temporary\n // switch from Text Compaction mode to Byte Compaction mode.\n // This switch shall be in effect for only the next codeword,\n // after which the mode shall revert to the prevailing sub-mode\n // of the Text Compaction mode. Codeword 913 is only available\n // in Text Compaction mode; its use is described in 5.4.2.4.\n textCompactionData[index] = DecodedBitStreamParser$2.MODE_SHIFT_TO_BYTE_COMPACTION_MODE;\n code = codewords[codeIndex++];\n byteCompactionData[index] = code;\n index++;\n break;\n }\n }\n }\n DecodedBitStreamParser$2.decodeTextCompaction(textCompactionData, byteCompactionData, index, result);\n return codeIndex;\n }\n /**\n * The Text Compaction mode includes all the printable ASCII characters\n * (i.e. values from 32 to 126) and three ASCII control characters: HT or tab\n * (9: e), LF or line feed (10: e), and CR or carriage\n * return (13: e). The Text Compaction mode also includes various latch\n * and shift characters which are used exclusively within the mode. The Text\n * Compaction mode encodes up to 2 characters per codeword. The compaction rules\n * for converting data into PDF417 codewords are defined in 5.4.2.2. The sub-mode\n * switches are defined in 5.4.2.3.\n *\n * @param textCompactionData The text compaction data.\n * @param byteCompactionData The byte compaction data if there\n * was a mode shift.\n * @param length The size of the text compaction and byte compaction data.\n * @param result The decoded data is appended to the result.\n */\n static decodeTextCompaction(textCompactionData, byteCompactionData, length, result) {\n // Beginning from an initial state of the Alpha sub-mode\n // The default compaction mode for PDF417 in effect at the start of each symbol shall always be Text\n // Compaction mode Alpha sub-mode (alphabetic: uppercase). A latch codeword from another mode to the Text\n // Compaction mode shall always switch to the Text Compaction Alpha sub-mode.\n let subMode = Mode$2.ALPHA;\n let priorToShiftMode = Mode$2.ALPHA;\n let i = 0;\n while (i < length) {\n let subModeCh = textCompactionData[i];\n let ch = /*char*/ '';\n switch (subMode) {\n case Mode$2.ALPHA:\n // Alpha (alphabetic: uppercase)\n if (subModeCh < 26) {\n // Upper case Alpha Character\n // Note: 65 = 'A' ASCII -> there is byte code of symbol\n ch = /*(char)('A' + subModeCh) */ String.fromCharCode(65 + subModeCh);\n }\n else {\n switch (subModeCh) {\n case 26:\n ch = ' ';\n break;\n case DecodedBitStreamParser$2.LL:\n subMode = Mode$2.LOWER;\n break;\n case DecodedBitStreamParser$2.ML:\n subMode = Mode$2.MIXED;\n break;\n case DecodedBitStreamParser$2.PS:\n // Shift to punctuation\n priorToShiftMode = subMode;\n subMode = Mode$2.PUNCT_SHIFT;\n break;\n case DecodedBitStreamParser$2.MODE_SHIFT_TO_BYTE_COMPACTION_MODE:\n result.append(/*(char)*/ byteCompactionData[i]);\n break;\n case DecodedBitStreamParser$2.TEXT_COMPACTION_MODE_LATCH:\n subMode = Mode$2.ALPHA;\n break;\n }\n }\n break;\n case Mode$2.LOWER:\n // Lower (alphabetic: lowercase)\n if (subModeCh < 26) {\n ch = /*(char)('a' + subModeCh)*/ String.fromCharCode(97 + subModeCh);\n }\n else {\n switch (subModeCh) {\n case 26:\n ch = ' ';\n break;\n case DecodedBitStreamParser$2.AS:\n // Shift to alpha\n priorToShiftMode = subMode;\n subMode = Mode$2.ALPHA_SHIFT;\n break;\n case DecodedBitStreamParser$2.ML:\n subMode = Mode$2.MIXED;\n break;\n case DecodedBitStreamParser$2.PS:\n // Shift to punctuation\n priorToShiftMode = subMode;\n subMode = Mode$2.PUNCT_SHIFT;\n break;\n case DecodedBitStreamParser$2.MODE_SHIFT_TO_BYTE_COMPACTION_MODE:\n // TODO Does this need to use the current character encoding? See other occurrences below\n result.append(/*(char)*/ byteCompactionData[i]);\n break;\n case DecodedBitStreamParser$2.TEXT_COMPACTION_MODE_LATCH:\n subMode = Mode$2.ALPHA;\n break;\n }\n }\n break;\n case Mode$2.MIXED:\n // Mixed (punctuation: e)\n if (subModeCh < DecodedBitStreamParser$2.PL) {\n ch = DecodedBitStreamParser$2.MIXED_CHARS[subModeCh];\n }\n else {\n switch (subModeCh) {\n case DecodedBitStreamParser$2.PL:\n subMode = Mode$2.PUNCT;\n break;\n case 26:\n ch = ' ';\n break;\n case DecodedBitStreamParser$2.LL:\n subMode = Mode$2.LOWER;\n break;\n case DecodedBitStreamParser$2.AL:\n subMode = Mode$2.ALPHA;\n break;\n case DecodedBitStreamParser$2.PS:\n // Shift to punctuation\n priorToShiftMode = subMode;\n subMode = Mode$2.PUNCT_SHIFT;\n break;\n case DecodedBitStreamParser$2.MODE_SHIFT_TO_BYTE_COMPACTION_MODE:\n result.append(/*(char)*/ byteCompactionData[i]);\n break;\n case DecodedBitStreamParser$2.TEXT_COMPACTION_MODE_LATCH:\n subMode = Mode$2.ALPHA;\n break;\n }\n }\n break;\n case Mode$2.PUNCT:\n // Punctuation\n if (subModeCh < DecodedBitStreamParser$2.PAL) {\n ch = DecodedBitStreamParser$2.PUNCT_CHARS[subModeCh];\n }\n else {\n switch (subModeCh) {\n case DecodedBitStreamParser$2.PAL:\n subMode = Mode$2.ALPHA;\n break;\n case DecodedBitStreamParser$2.MODE_SHIFT_TO_BYTE_COMPACTION_MODE:\n result.append(/*(char)*/ byteCompactionData[i]);\n break;\n case DecodedBitStreamParser$2.TEXT_COMPACTION_MODE_LATCH:\n subMode = Mode$2.ALPHA;\n break;\n }\n }\n break;\n case Mode$2.ALPHA_SHIFT:\n // Restore sub-mode\n subMode = priorToShiftMode;\n if (subModeCh < 26) {\n ch = /*(char)('A' + subModeCh)*/ String.fromCharCode(65 + subModeCh);\n }\n else {\n switch (subModeCh) {\n case 26:\n ch = ' ';\n break;\n case DecodedBitStreamParser$2.TEXT_COMPACTION_MODE_LATCH:\n subMode = Mode$2.ALPHA;\n break;\n }\n }\n break;\n case Mode$2.PUNCT_SHIFT:\n // Restore sub-mode\n subMode = priorToShiftMode;\n if (subModeCh < DecodedBitStreamParser$2.PAL) {\n ch = DecodedBitStreamParser$2.PUNCT_CHARS[subModeCh];\n }\n else {\n switch (subModeCh) {\n case DecodedBitStreamParser$2.PAL:\n subMode = Mode$2.ALPHA;\n break;\n case DecodedBitStreamParser$2.MODE_SHIFT_TO_BYTE_COMPACTION_MODE:\n // PS before Shift-to-Byte is used as a padding character,\n // see 5.4.2.4 of the specification\n result.append(/*(char)*/ byteCompactionData[i]);\n break;\n case DecodedBitStreamParser$2.TEXT_COMPACTION_MODE_LATCH:\n subMode = Mode$2.ALPHA;\n break;\n }\n }\n break;\n }\n // if (ch !== 0) {\n if (ch !== '') {\n // Append decoded character to result\n result.append(ch);\n }\n i++;\n }\n }\n /**\n * Byte Compaction mode (see 5.4.3) permits all 256 possible 8-bit byte values to be encoded.\n * This includes all ASCII characters value 0 to 127 inclusive and provides for international\n * character set support.\n *\n * @param mode The byte compaction mode i.e. 901 or 924\n * @param codewords The array of codewords (data + error)\n * @param encoding Currently active character encoding\n * @param codeIndex The current index into the codeword array.\n * @param result The decoded data is appended to the result.\n * @return The next index into the codeword array.\n */\n static /*int*/ byteCompaction(mode, codewords, encoding, codeIndex, result) {\n let decodedBytes = new ByteArrayOutputStream();\n let count = 0;\n let value = /*long*/ 0;\n let end = false;\n switch (mode) {\n case DecodedBitStreamParser$2.BYTE_COMPACTION_MODE_LATCH:\n // Total number of Byte Compaction characters to be encoded\n // is not a multiple of 6\n let byteCompactedCodewords = new Int32Array(6);\n let nextCode = codewords[codeIndex++];\n while ((codeIndex < codewords[0]) && !end) {\n byteCompactedCodewords[count++] = nextCode;\n // Base 900\n value = 900 * value + nextCode;\n nextCode = codewords[codeIndex++];\n // perhaps it should be ok to check only nextCode >= TEXT_COMPACTION_MODE_LATCH\n switch (nextCode) {\n case DecodedBitStreamParser$2.TEXT_COMPACTION_MODE_LATCH:\n case DecodedBitStreamParser$2.BYTE_COMPACTION_MODE_LATCH:\n case DecodedBitStreamParser$2.NUMERIC_COMPACTION_MODE_LATCH:\n case DecodedBitStreamParser$2.BYTE_COMPACTION_MODE_LATCH_6:\n case DecodedBitStreamParser$2.BEGIN_MACRO_PDF417_CONTROL_BLOCK:\n case DecodedBitStreamParser$2.BEGIN_MACRO_PDF417_OPTIONAL_FIELD:\n case DecodedBitStreamParser$2.MACRO_PDF417_TERMINATOR:\n codeIndex--;\n end = true;\n break;\n default:\n if ((count % 5 === 0) && (count > 0)) {\n // Decode every 5 codewords\n // Convert to Base 256\n for (let j /*int*/ = 0; j < 6; ++j) {\n /* @note\n * JavaScript stores numbers as 64 bits floating point numbers, but all bitwise operations are performed on 32 bits binary numbers.\n * So the next bitwise operation could not be done with simple numbers\n */\n decodedBytes.write(/*(byte)*/ Number(createBigInt(value) >> createBigInt(8 * (5 - j))));\n }\n value = 0;\n count = 0;\n }\n break;\n }\n }\n // if the end of all codewords is reached the last codeword needs to be added\n if (codeIndex === codewords[0] && nextCode < DecodedBitStreamParser$2.TEXT_COMPACTION_MODE_LATCH) {\n byteCompactedCodewords[count++] = nextCode;\n }\n // If Byte Compaction mode is invoked with codeword 901,\n // the last group of codewords is interpreted directly\n // as one byte per codeword, without compaction.\n for (let i /*int*/ = 0; i < count; i++) {\n decodedBytes.write(/*(byte)*/ byteCompactedCodewords[i]);\n }\n break;\n case DecodedBitStreamParser$2.BYTE_COMPACTION_MODE_LATCH_6:\n // Total number of Byte Compaction characters to be encoded\n // is an integer multiple of 6\n while (codeIndex < codewords[0] && !end) {\n let code = codewords[codeIndex++];\n if (code < DecodedBitStreamParser$2.TEXT_COMPACTION_MODE_LATCH) {\n count++;\n // Base 900\n value = 900 * value + code;\n }\n else {\n switch (code) {\n case DecodedBitStreamParser$2.TEXT_COMPACTION_MODE_LATCH:\n case DecodedBitStreamParser$2.BYTE_COMPACTION_MODE_LATCH:\n case DecodedBitStreamParser$2.NUMERIC_COMPACTION_MODE_LATCH:\n case DecodedBitStreamParser$2.BYTE_COMPACTION_MODE_LATCH_6:\n case DecodedBitStreamParser$2.BEGIN_MACRO_PDF417_CONTROL_BLOCK:\n case DecodedBitStreamParser$2.BEGIN_MACRO_PDF417_OPTIONAL_FIELD:\n case DecodedBitStreamParser$2.MACRO_PDF417_TERMINATOR:\n codeIndex--;\n end = true;\n break;\n }\n }\n if ((count % 5 === 0) && (count > 0)) {\n // Decode every 5 codewords\n // Convert to Base 256\n /* @note\n * JavaScript stores numbers as 64 bits floating point numbers, but all bitwise operations are performed on 32 bits binary numbers.\n * So the next bitwise operation could not be done with simple numbers\n */\n for (let j /*int*/ = 0; j < 6; ++j) {\n decodedBytes.write(/*(byte)*/ Number(createBigInt(value) >> createBigInt(8 * (5 - j))));\n }\n value = 0;\n count = 0;\n }\n }\n break;\n }\n result.append(StringEncoding.decode(decodedBytes.toByteArray(), encoding));\n return codeIndex;\n }\n /**\n * Numeric Compaction mode (see 5.4.4) permits efficient encoding of numeric data strings.\n *\n * @param codewords The array of codewords (data + error)\n * @param codeIndex The current index into the codeword array.\n * @param result The decoded data is appended to the result.\n * @return The next index into the codeword array.\n *\n * @throws FormatException\n */\n static numericCompaction(codewords, codeIndex /*int*/, result) {\n let count = 0;\n let end = false;\n let numericCodewords = new Int32Array(DecodedBitStreamParser$2.MAX_NUMERIC_CODEWORDS);\n while (codeIndex < codewords[0] && !end) {\n let code = codewords[codeIndex++];\n if (codeIndex === codewords[0]) {\n end = true;\n }\n if (code < DecodedBitStreamParser$2.TEXT_COMPACTION_MODE_LATCH) {\n numericCodewords[count] = code;\n count++;\n }\n else {\n switch (code) {\n case DecodedBitStreamParser$2.TEXT_COMPACTION_MODE_LATCH:\n case DecodedBitStreamParser$2.BYTE_COMPACTION_MODE_LATCH:\n case DecodedBitStreamParser$2.BYTE_COMPACTION_MODE_LATCH_6:\n case DecodedBitStreamParser$2.BEGIN_MACRO_PDF417_CONTROL_BLOCK:\n case DecodedBitStreamParser$2.BEGIN_MACRO_PDF417_OPTIONAL_FIELD:\n case DecodedBitStreamParser$2.MACRO_PDF417_TERMINATOR:\n codeIndex--;\n end = true;\n break;\n }\n }\n if ((count % DecodedBitStreamParser$2.MAX_NUMERIC_CODEWORDS === 0 || code === DecodedBitStreamParser$2.NUMERIC_COMPACTION_MODE_LATCH || end) && count > 0) {\n // Re-invoking Numeric Compaction mode (by using codeword 902\n // while in Numeric Compaction mode) serves to terminate the\n // current Numeric Compaction mode grouping as described in 5.4.4.2,\n // and then to start a new one grouping.\n result.append(DecodedBitStreamParser$2.decodeBase900toBase10(numericCodewords, count));\n count = 0;\n }\n }\n return codeIndex;\n }\n /**\n * Convert a list of Numeric Compacted codewords from Base 900 to Base 10.\n *\n * @param codewords The array of codewords\n * @param count The number of codewords\n * @return The decoded string representing the Numeric data.\n *\n * EXAMPLE\n * Encode the fifteen digit numeric string 000213298174000\n * Prefix the numeric string with a 1 and set the initial value of\n * t = 1 000 213 298 174 000\n * Calculate codeword 0\n * d0 = 1 000 213 298 174 000 mod 900 = 200\n *\n * t = 1 000 213 298 174 000 div 900 = 1 111 348 109 082\n * Calculate codeword 1\n * d1 = 1 111 348 109 082 mod 900 = 282\n *\n * t = 1 111 348 109 082 div 900 = 1 234 831 232\n * Calculate codeword 2\n * d2 = 1 234 831 232 mod 900 = 632\n *\n * t = 1 234 831 232 div 900 = 1 372 034\n * Calculate codeword 3\n * d3 = 1 372 034 mod 900 = 434\n *\n * t = 1 372 034 div 900 = 1 524\n * Calculate codeword 4\n * d4 = 1 524 mod 900 = 624\n *\n * t = 1 524 div 900 = 1\n * Calculate codeword 5\n * d5 = 1 mod 900 = 1\n * t = 1 div 900 = 0\n * Codeword sequence is: 1, 624, 434, 632, 282, 200\n *\n * Decode the above codewords involves\n * 1 x 900 power of 5 + 624 x 900 power of 4 + 434 x 900 power of 3 +\n * 632 x 900 power of 2 + 282 x 900 power of 1 + 200 x 900 power of 0 = 1000213298174000\n *\n * Remove leading 1 => Result is 000213298174000\n *\n * @throws FormatException\n */\n static decodeBase900toBase10(codewords, count) {\n let result = createBigInt(0);\n for (let i /*int*/ = 0; i < count; i++) {\n result += DecodedBitStreamParser$2.EXP900[count - i - 1] * createBigInt(codewords[i]);\n }\n let resultString = result.toString();\n if (resultString.charAt(0) !== '1') {\n throw new FormatException();\n }\n return resultString.substring(1);\n }\n }\n DecodedBitStreamParser$2.TEXT_COMPACTION_MODE_LATCH = 900;\n DecodedBitStreamParser$2.BYTE_COMPACTION_MODE_LATCH = 901;\n DecodedBitStreamParser$2.NUMERIC_COMPACTION_MODE_LATCH = 902;\n DecodedBitStreamParser$2.BYTE_COMPACTION_MODE_LATCH_6 = 924;\n DecodedBitStreamParser$2.ECI_USER_DEFINED = 925;\n DecodedBitStreamParser$2.ECI_GENERAL_PURPOSE = 926;\n DecodedBitStreamParser$2.ECI_CHARSET = 927;\n DecodedBitStreamParser$2.BEGIN_MACRO_PDF417_CONTROL_BLOCK = 928;\n DecodedBitStreamParser$2.BEGIN_MACRO_PDF417_OPTIONAL_FIELD = 923;\n DecodedBitStreamParser$2.MACRO_PDF417_TERMINATOR = 922;\n DecodedBitStreamParser$2.MODE_SHIFT_TO_BYTE_COMPACTION_MODE = 913;\n DecodedBitStreamParser$2.MAX_NUMERIC_CODEWORDS = 15;\n DecodedBitStreamParser$2.MACRO_PDF417_OPTIONAL_FIELD_FILE_NAME = 0;\n DecodedBitStreamParser$2.MACRO_PDF417_OPTIONAL_FIELD_SEGMENT_COUNT = 1;\n DecodedBitStreamParser$2.MACRO_PDF417_OPTIONAL_FIELD_TIME_STAMP = 2;\n DecodedBitStreamParser$2.MACRO_PDF417_OPTIONAL_FIELD_SENDER = 3;\n DecodedBitStreamParser$2.MACRO_PDF417_OPTIONAL_FIELD_ADDRESSEE = 4;\n DecodedBitStreamParser$2.MACRO_PDF417_OPTIONAL_FIELD_FILE_SIZE = 5;\n DecodedBitStreamParser$2.MACRO_PDF417_OPTIONAL_FIELD_CHECKSUM = 6;\n DecodedBitStreamParser$2.PL = 25;\n DecodedBitStreamParser$2.LL = 27;\n DecodedBitStreamParser$2.AS = 27;\n DecodedBitStreamParser$2.ML = 28;\n DecodedBitStreamParser$2.AL = 28;\n DecodedBitStreamParser$2.PS = 29;\n DecodedBitStreamParser$2.PAL = 29;\n DecodedBitStreamParser$2.PUNCT_CHARS = ';<>@[\\\\]_`~!\\r\\t,:\\n-.$/\"|*()?{}\\'';\n DecodedBitStreamParser$2.MIXED_CHARS = '0123456789&\\r\\t,:#-.$/+%*=^';\n /**\n * Table containing values for the exponent of 900.\n * This is used in the numeric compaction decode algorithm.\n */\n DecodedBitStreamParser$2.EXP900 = getBigIntConstructor() ? getEXP900() : [];\n DecodedBitStreamParser$2.NUMBER_OF_SEQUENCE_CODEWORDS = 2;\n\n /*\n * Copyright 2013 ZXing authors\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n // import java.util.ArrayList;\n // import java.util.Collection;\n // import java.util.Formatter;\n // import java.util.List;\n /**\n * @author Guenther Grau\n */\n /*public final*/ class PDF417ScanningDecoder {\n constructor() { }\n /**\n * @TODO don't pass in minCodewordWidth and maxCodewordWidth, pass in barcode columns for start and stop pattern\n *\n * columns. That way width can be deducted from the pattern column.\n * This approach also allows to detect more details about the barcode, e.g. if a bar type (white or black) is wider\n * than it should be. This can happen if the scanner used a bad blackpoint.\n *\n * @param BitMatrix\n * @param image\n * @param ResultPoint\n * @param imageTopLeft\n * @param ResultPoint\n * @param imageBottomLeft\n * @param ResultPoint\n * @param imageTopRight\n * @param ResultPoint\n * @param imageBottomRight\n * @param int\n * @param minCodewordWidth\n * @param int\n * @param maxCodewordWidth\n *\n * @throws NotFoundException\n * @throws FormatException\n * @throws ChecksumException\n */\n static decode(image, imageTopLeft, imageBottomLeft, imageTopRight, imageBottomRight, minCodewordWidth, maxCodewordWidth) {\n let boundingBox = new BoundingBox(image, imageTopLeft, imageBottomLeft, imageTopRight, imageBottomRight);\n let leftRowIndicatorColumn = null;\n let rightRowIndicatorColumn = null;\n let detectionResult;\n for (let firstPass /*boolean*/ = true;; firstPass = false) {\n if (imageTopLeft != null) {\n leftRowIndicatorColumn = PDF417ScanningDecoder.getRowIndicatorColumn(image, boundingBox, imageTopLeft, true, minCodewordWidth, maxCodewordWidth);\n }\n if (imageTopRight != null) {\n rightRowIndicatorColumn = PDF417ScanningDecoder.getRowIndicatorColumn(image, boundingBox, imageTopRight, false, minCodewordWidth, maxCodewordWidth);\n }\n detectionResult = PDF417ScanningDecoder.merge(leftRowIndicatorColumn, rightRowIndicatorColumn);\n if (detectionResult == null) {\n throw NotFoundException.getNotFoundInstance();\n }\n let resultBox = detectionResult.getBoundingBox();\n if (firstPass && resultBox != null &&\n (resultBox.getMinY() < boundingBox.getMinY() || resultBox.getMaxY() > boundingBox.getMaxY())) {\n boundingBox = resultBox;\n }\n else {\n break;\n }\n }\n detectionResult.setBoundingBox(boundingBox);\n let maxBarcodeColumn = detectionResult.getBarcodeColumnCount() + 1;\n detectionResult.setDetectionResultColumn(0, leftRowIndicatorColumn);\n detectionResult.setDetectionResultColumn(maxBarcodeColumn, rightRowIndicatorColumn);\n let leftToRight = leftRowIndicatorColumn != null;\n for (let barcodeColumnCount /*int*/ = 1; barcodeColumnCount <= maxBarcodeColumn; barcodeColumnCount++) {\n let barcodeColumn = leftToRight ? barcodeColumnCount : maxBarcodeColumn - barcodeColumnCount;\n if (detectionResult.getDetectionResultColumn(barcodeColumn) !== /* null */ undefined) {\n // This will be the case for the opposite row indicator column, which doesn't need to be decoded again.\n continue;\n }\n let detectionResultColumn;\n if (barcodeColumn === 0 || barcodeColumn === maxBarcodeColumn) {\n detectionResultColumn = new DetectionResultRowIndicatorColumn(boundingBox, barcodeColumn === 0);\n }\n else {\n detectionResultColumn = new DetectionResultColumn(boundingBox);\n }\n detectionResult.setDetectionResultColumn(barcodeColumn, detectionResultColumn);\n let startColumn = -1;\n let previousStartColumn = startColumn;\n // TODO start at a row for which we know the start position, then detect upwards and downwards from there.\n for (let imageRow /*int*/ = boundingBox.getMinY(); imageRow <= boundingBox.getMaxY(); imageRow++) {\n startColumn = PDF417ScanningDecoder.getStartColumn(detectionResult, barcodeColumn, imageRow, leftToRight);\n if (startColumn < 0 || startColumn > boundingBox.getMaxX()) {\n if (previousStartColumn === -1) {\n continue;\n }\n startColumn = previousStartColumn;\n }\n let codeword = PDF417ScanningDecoder.detectCodeword(image, boundingBox.getMinX(), boundingBox.getMaxX(), leftToRight, startColumn, imageRow, minCodewordWidth, maxCodewordWidth);\n if (codeword != null) {\n detectionResultColumn.setCodeword(imageRow, codeword);\n previousStartColumn = startColumn;\n minCodewordWidth = Math.min(minCodewordWidth, codeword.getWidth());\n maxCodewordWidth = Math.max(maxCodewordWidth, codeword.getWidth());\n }\n }\n }\n return PDF417ScanningDecoder.createDecoderResult(detectionResult);\n }\n /**\n *\n * @param leftRowIndicatorColumn\n * @param rightRowIndicatorColumn\n *\n * @throws NotFoundException\n */\n static merge(leftRowIndicatorColumn, rightRowIndicatorColumn) {\n if (leftRowIndicatorColumn == null && rightRowIndicatorColumn == null) {\n return null;\n }\n let barcodeMetadata = PDF417ScanningDecoder.getBarcodeMetadata(leftRowIndicatorColumn, rightRowIndicatorColumn);\n if (barcodeMetadata == null) {\n return null;\n }\n let boundingBox = BoundingBox.merge(PDF417ScanningDecoder.adjustBoundingBox(leftRowIndicatorColumn), PDF417ScanningDecoder.adjustBoundingBox(rightRowIndicatorColumn));\n return new DetectionResult(barcodeMetadata, boundingBox);\n }\n /**\n *\n * @param rowIndicatorColumn\n *\n * @throws NotFoundException\n */\n static adjustBoundingBox(rowIndicatorColumn) {\n if (rowIndicatorColumn == null) {\n return null;\n }\n let rowHeights = rowIndicatorColumn.getRowHeights();\n if (rowHeights == null) {\n return null;\n }\n let maxRowHeight = PDF417ScanningDecoder.getMax(rowHeights);\n let missingStartRows = 0;\n for (let rowHeight /*int*/ of rowHeights) {\n missingStartRows += maxRowHeight - rowHeight;\n if (rowHeight > 0) {\n break;\n }\n }\n let codewords = rowIndicatorColumn.getCodewords();\n for (let row /*int*/ = 0; missingStartRows > 0 && codewords[row] == null; row++) {\n missingStartRows--;\n }\n let missingEndRows = 0;\n for (let row /*int*/ = rowHeights.length - 1; row >= 0; row--) {\n missingEndRows += maxRowHeight - rowHeights[row];\n if (rowHeights[row] > 0) {\n break;\n }\n }\n for (let row /*int*/ = codewords.length - 1; missingEndRows > 0 && codewords[row] == null; row--) {\n missingEndRows--;\n }\n return rowIndicatorColumn.getBoundingBox().addMissingRows(missingStartRows, missingEndRows, rowIndicatorColumn.isLeft());\n }\n static getMax(values) {\n let maxValue = -1;\n for (let value /*int*/ of values) {\n maxValue = Math.max(maxValue, value);\n }\n return maxValue;\n }\n static getBarcodeMetadata(leftRowIndicatorColumn, rightRowIndicatorColumn) {\n let leftBarcodeMetadata;\n if (leftRowIndicatorColumn == null ||\n (leftBarcodeMetadata = leftRowIndicatorColumn.getBarcodeMetadata()) == null) {\n return rightRowIndicatorColumn == null ? null : rightRowIndicatorColumn.getBarcodeMetadata();\n }\n let rightBarcodeMetadata;\n if (rightRowIndicatorColumn == null ||\n (rightBarcodeMetadata = rightRowIndicatorColumn.getBarcodeMetadata()) == null) {\n return leftBarcodeMetadata;\n }\n if (leftBarcodeMetadata.getColumnCount() !== rightBarcodeMetadata.getColumnCount() &&\n leftBarcodeMetadata.getErrorCorrectionLevel() !== rightBarcodeMetadata.getErrorCorrectionLevel() &&\n leftBarcodeMetadata.getRowCount() !== rightBarcodeMetadata.getRowCount()) {\n return null;\n }\n return leftBarcodeMetadata;\n }\n static getRowIndicatorColumn(image, boundingBox, startPoint, leftToRight, minCodewordWidth, maxCodewordWidth) {\n let rowIndicatorColumn = new DetectionResultRowIndicatorColumn(boundingBox, leftToRight);\n for (let i /*int*/ = 0; i < 2; i++) {\n let increment = i === 0 ? 1 : -1;\n let startColumn = Math.trunc(Math.trunc(startPoint.getX()));\n for (let imageRow /*int*/ = Math.trunc(Math.trunc(startPoint.getY())); imageRow <= boundingBox.getMaxY() &&\n imageRow >= boundingBox.getMinY(); imageRow += increment) {\n let codeword = PDF417ScanningDecoder.detectCodeword(image, 0, image.getWidth(), leftToRight, startColumn, imageRow, minCodewordWidth, maxCodewordWidth);\n if (codeword != null) {\n rowIndicatorColumn.setCodeword(imageRow, codeword);\n if (leftToRight) {\n startColumn = codeword.getStartX();\n }\n else {\n startColumn = codeword.getEndX();\n }\n }\n }\n }\n return rowIndicatorColumn;\n }\n /**\n *\n * @param detectionResult\n * @param BarcodeValue\n * @param param2\n * @param param3\n * @param barcodeMatrix\n *\n * @throws NotFoundException\n */\n static adjustCodewordCount(detectionResult, barcodeMatrix) {\n let barcodeMatrix01 = barcodeMatrix[0][1];\n let numberOfCodewords = barcodeMatrix01.getValue();\n let calculatedNumberOfCodewords = detectionResult.getBarcodeColumnCount() *\n detectionResult.getBarcodeRowCount() -\n PDF417ScanningDecoder.getNumberOfECCodeWords(detectionResult.getBarcodeECLevel());\n if (numberOfCodewords.length === 0) {\n if (calculatedNumberOfCodewords < 1 || calculatedNumberOfCodewords > PDF417Common.MAX_CODEWORDS_IN_BARCODE) {\n throw NotFoundException.getNotFoundInstance();\n }\n barcodeMatrix01.setValue(calculatedNumberOfCodewords);\n }\n else if (numberOfCodewords[0] !== calculatedNumberOfCodewords) {\n // The calculated one is more reliable as it is derived from the row indicator columns\n barcodeMatrix01.setValue(calculatedNumberOfCodewords);\n }\n }\n /**\n *\n * @param detectionResult\n *\n * @throws FormatException\n * @throws ChecksumException\n * @throws NotFoundException\n */\n static createDecoderResult(detectionResult) {\n let barcodeMatrix = PDF417ScanningDecoder.createBarcodeMatrix(detectionResult);\n PDF417ScanningDecoder.adjustCodewordCount(detectionResult, barcodeMatrix);\n let erasures /*Collection*/ = new Array();\n let codewords = new Int32Array(detectionResult.getBarcodeRowCount() * detectionResult.getBarcodeColumnCount());\n let ambiguousIndexValuesList = /*List*/ [];\n let ambiguousIndexesList = /*Collection*/ new Array();\n for (let row /*int*/ = 0; row < detectionResult.getBarcodeRowCount(); row++) {\n for (let column /*int*/ = 0; column < detectionResult.getBarcodeColumnCount(); column++) {\n let values = barcodeMatrix[row][column + 1].getValue();\n let codewordIndex = row * detectionResult.getBarcodeColumnCount() + column;\n if (values.length === 0) {\n erasures.push(codewordIndex);\n }\n else if (values.length === 1) {\n codewords[codewordIndex] = values[0];\n }\n else {\n ambiguousIndexesList.push(codewordIndex);\n ambiguousIndexValuesList.push(values);\n }\n }\n }\n let ambiguousIndexValues = new Array(ambiguousIndexValuesList.length);\n for (let i /*int*/ = 0; i < ambiguousIndexValues.length; i++) {\n ambiguousIndexValues[i] = ambiguousIndexValuesList[i];\n }\n return PDF417ScanningDecoder.createDecoderResultFromAmbiguousValues(detectionResult.getBarcodeECLevel(), codewords, PDF417Common.toIntArray(erasures), PDF417Common.toIntArray(ambiguousIndexesList), ambiguousIndexValues);\n }\n /**\n * This method deals with the fact, that the decoding process doesn't always yield a single most likely value. The\n * current error correction implementation doesn't deal with erasures very well, so it's better to provide a value\n * for these ambiguous codewords instead of treating it as an erasure. The problem is that we don't know which of\n * the ambiguous values to choose. We try decode using the first value, and if that fails, we use another of the\n * ambiguous values and try to decode again. This usually only happens on very hard to read and decode barcodes,\n * so decoding the normal barcodes is not affected by this.\n *\n * @param erasureArray contains the indexes of erasures\n * @param ambiguousIndexes array with the indexes that have more than one most likely value\n * @param ambiguousIndexValues two dimensional array that contains the ambiguous values. The first dimension must\n * be the same length as the ambiguousIndexes array\n *\n * @throws FormatException\n * @throws ChecksumException\n */\n static createDecoderResultFromAmbiguousValues(ecLevel, codewords, erasureArray, ambiguousIndexes, ambiguousIndexValues) {\n let ambiguousIndexCount = new Int32Array(ambiguousIndexes.length);\n let tries = 100;\n while (tries-- > 0) {\n for (let i /*int*/ = 0; i < ambiguousIndexCount.length; i++) {\n codewords[ambiguousIndexes[i]] = ambiguousIndexValues[i][ambiguousIndexCount[i]];\n }\n try {\n return PDF417ScanningDecoder.decodeCodewords(codewords, ecLevel, erasureArray);\n }\n catch (err) {\n let ignored = err instanceof ChecksumException;\n if (!ignored) {\n throw err;\n }\n }\n if (ambiguousIndexCount.length === 0) {\n throw ChecksumException.getChecksumInstance();\n }\n for (let i /*int*/ = 0; i < ambiguousIndexCount.length; i++) {\n if (ambiguousIndexCount[i] < ambiguousIndexValues[i].length - 1) {\n ambiguousIndexCount[i]++;\n break;\n }\n else {\n ambiguousIndexCount[i] = 0;\n if (i === ambiguousIndexCount.length - 1) {\n throw ChecksumException.getChecksumInstance();\n }\n }\n }\n }\n throw ChecksumException.getChecksumInstance();\n }\n static createBarcodeMatrix(detectionResult) {\n // let barcodeMatrix: BarcodeValue[][] =\n // new BarcodeValue[detectionResult.getBarcodeRowCount()][detectionResult.getBarcodeColumnCount() + 2];\n let barcodeMatrix = Array.from({ length: detectionResult.getBarcodeRowCount() }, () => new Array(detectionResult.getBarcodeColumnCount() + 2));\n for (let row /*int*/ = 0; row < barcodeMatrix.length; row++) {\n for (let column /*int*/ = 0; column < barcodeMatrix[row].length; column++) {\n barcodeMatrix[row][column] = new BarcodeValue();\n }\n }\n let column = 0;\n for (let detectionResultColumn /*DetectionResultColumn*/ of detectionResult.getDetectionResultColumns()) {\n if (detectionResultColumn != null) {\n for (let codeword /*Codeword*/ of detectionResultColumn.getCodewords()) {\n if (codeword != null) {\n let rowNumber = codeword.getRowNumber();\n if (rowNumber >= 0) {\n if (rowNumber >= barcodeMatrix.length) {\n // We have more rows than the barcode metadata allows for, ignore them.\n continue;\n }\n barcodeMatrix[rowNumber][column].setValue(codeword.getValue());\n }\n }\n }\n }\n column++;\n }\n return barcodeMatrix;\n }\n static isValidBarcodeColumn(detectionResult, barcodeColumn) {\n return barcodeColumn >= 0 && barcodeColumn <= detectionResult.getBarcodeColumnCount() + 1;\n }\n static getStartColumn(detectionResult, barcodeColumn, imageRow, leftToRight) {\n let offset = leftToRight ? 1 : -1;\n let codeword = null;\n if (PDF417ScanningDecoder.isValidBarcodeColumn(detectionResult, barcodeColumn - offset)) {\n codeword = detectionResult.getDetectionResultColumn(barcodeColumn - offset).getCodeword(imageRow);\n }\n if (codeword != null) {\n return leftToRight ? codeword.getEndX() : codeword.getStartX();\n }\n codeword = detectionResult.getDetectionResultColumn(barcodeColumn).getCodewordNearby(imageRow);\n if (codeword != null) {\n return leftToRight ? codeword.getStartX() : codeword.getEndX();\n }\n if (PDF417ScanningDecoder.isValidBarcodeColumn(detectionResult, barcodeColumn - offset)) {\n codeword = detectionResult.getDetectionResultColumn(barcodeColumn - offset).getCodewordNearby(imageRow);\n }\n if (codeword != null) {\n return leftToRight ? codeword.getEndX() : codeword.getStartX();\n }\n let skippedColumns = 0;\n while (PDF417ScanningDecoder.isValidBarcodeColumn(detectionResult, barcodeColumn - offset)) {\n barcodeColumn -= offset;\n for (let previousRowCodeword /*Codeword*/ of detectionResult.getDetectionResultColumn(barcodeColumn).getCodewords()) {\n if (previousRowCodeword != null) {\n return (leftToRight ? previousRowCodeword.getEndX() : previousRowCodeword.getStartX()) +\n offset *\n skippedColumns *\n (previousRowCodeword.getEndX() - previousRowCodeword.getStartX());\n }\n }\n skippedColumns++;\n }\n return leftToRight ? detectionResult.getBoundingBox().getMinX() : detectionResult.getBoundingBox().getMaxX();\n }\n static detectCodeword(image, minColumn, maxColumn, leftToRight, startColumn, imageRow, minCodewordWidth, maxCodewordWidth) {\n startColumn = PDF417ScanningDecoder.adjustCodewordStartColumn(image, minColumn, maxColumn, leftToRight, startColumn, imageRow);\n // we usually know fairly exact now how long a codeword is. We should provide minimum and maximum expected length\n // and try to adjust the read pixels, e.g. remove single pixel errors or try to cut off exceeding pixels.\n // min and maxCodewordWidth should not be used as they are calculated for the whole barcode an can be inaccurate\n // for the current position\n let moduleBitCount = PDF417ScanningDecoder.getModuleBitCount(image, minColumn, maxColumn, leftToRight, startColumn, imageRow);\n if (moduleBitCount == null) {\n return null;\n }\n let endColumn;\n let codewordBitCount = MathUtils.sum(moduleBitCount);\n if (leftToRight) {\n endColumn = startColumn + codewordBitCount;\n }\n else {\n for (let i /*int*/ = 0; i < moduleBitCount.length / 2; i++) {\n let tmpCount = moduleBitCount[i];\n moduleBitCount[i] = moduleBitCount[moduleBitCount.length - 1 - i];\n moduleBitCount[moduleBitCount.length - 1 - i] = tmpCount;\n }\n endColumn = startColumn;\n startColumn = endColumn - codewordBitCount;\n }\n // TODO implement check for width and correction of black and white bars\n // use start (and maybe stop pattern) to determine if black bars are wider than white bars. If so, adjust.\n // should probably done only for codewords with a lot more than 17 bits.\n // The following fixes 10-1.png, which has wide black bars and small white bars\n // for (let i /*int*/ = 0; i < moduleBitCount.length; i++) {\n // if (i % 2 === 0) {\n // moduleBitCount[i]--;\n // } else {\n // moduleBitCount[i]++;\n // }\n // }\n // We could also use the width of surrounding codewords for more accurate results, but this seems\n // sufficient for now\n if (!PDF417ScanningDecoder.checkCodewordSkew(codewordBitCount, minCodewordWidth, maxCodewordWidth)) {\n // We could try to use the startX and endX position of the codeword in the same column in the previous row,\n // create the bit count from it and normalize it to 8. This would help with single pixel errors.\n return null;\n }\n let decodedValue = PDF417CodewordDecoder.getDecodedValue(moduleBitCount);\n let codeword = PDF417Common.getCodeword(decodedValue);\n if (codeword === -1) {\n return null;\n }\n return new Codeword(startColumn, endColumn, PDF417ScanningDecoder.getCodewordBucketNumber(decodedValue), codeword);\n }\n static getModuleBitCount(image, minColumn, maxColumn, leftToRight, startColumn, imageRow) {\n let imageColumn = startColumn;\n let moduleBitCount = new Int32Array(8);\n let moduleNumber = 0;\n let increment = leftToRight ? 1 : -1;\n let previousPixelValue = leftToRight;\n while ((leftToRight ? imageColumn < maxColumn : imageColumn >= minColumn) &&\n moduleNumber < moduleBitCount.length) {\n if (image.get(imageColumn, imageRow) === previousPixelValue) {\n moduleBitCount[moduleNumber]++;\n imageColumn += increment;\n }\n else {\n moduleNumber++;\n previousPixelValue = !previousPixelValue;\n }\n }\n if (moduleNumber === moduleBitCount.length ||\n ((imageColumn === (leftToRight ? maxColumn : minColumn)) &&\n moduleNumber === moduleBitCount.length - 1)) {\n return moduleBitCount;\n }\n return null;\n }\n static getNumberOfECCodeWords(barcodeECLevel) {\n return 2 << barcodeECLevel;\n }\n static adjustCodewordStartColumn(image, minColumn, maxColumn, leftToRight, codewordStartColumn, imageRow) {\n let correctedStartColumn = codewordStartColumn;\n let increment = leftToRight ? -1 : 1;\n // there should be no black pixels before the start column. If there are, then we need to start earlier.\n for (let i /*int*/ = 0; i < 2; i++) {\n while ((leftToRight ? correctedStartColumn >= minColumn : correctedStartColumn < maxColumn) &&\n leftToRight === image.get(correctedStartColumn, imageRow)) {\n if (Math.abs(codewordStartColumn - correctedStartColumn) > PDF417ScanningDecoder.CODEWORD_SKEW_SIZE) {\n return codewordStartColumn;\n }\n correctedStartColumn += increment;\n }\n increment = -increment;\n leftToRight = !leftToRight;\n }\n return correctedStartColumn;\n }\n static checkCodewordSkew(codewordSize, minCodewordWidth, maxCodewordWidth) {\n return minCodewordWidth - PDF417ScanningDecoder.CODEWORD_SKEW_SIZE <= codewordSize &&\n codewordSize <= maxCodewordWidth + PDF417ScanningDecoder.CODEWORD_SKEW_SIZE;\n }\n /**\n * @throws FormatException,\n * @throws ChecksumException\n */\n static decodeCodewords(codewords, ecLevel, erasures) {\n if (codewords.length === 0) {\n throw FormatException.getFormatInstance();\n }\n let numECCodewords = 1 << (ecLevel + 1);\n let correctedErrorsCount = PDF417ScanningDecoder.correctErrors(codewords, erasures, numECCodewords);\n PDF417ScanningDecoder.verifyCodewordCount(codewords, numECCodewords);\n // Decode the codewords\n let decoderResult = DecodedBitStreamParser$2.decode(codewords, '' + ecLevel);\n decoderResult.setErrorsCorrected(correctedErrorsCount);\n decoderResult.setErasures(erasures.length);\n return decoderResult;\n }\n /**\n * Given data and error-correction codewords received, possibly corrupted by errors, attempts to\n * correct the errors in-place.
\n *\n * @param codewords data and error correction codewords\n * @param erasures positions of any known erasures\n * @param numECCodewords number of error correction codewords that are available in codewords\n * @throws ChecksumException if error correction fails\n */\n static correctErrors(codewords, erasures, numECCodewords) {\n if (erasures != null &&\n erasures.length > numECCodewords / 2 + PDF417ScanningDecoder.MAX_ERRORS ||\n numECCodewords < 0 ||\n numECCodewords > PDF417ScanningDecoder.MAX_EC_CODEWORDS) {\n // Too many errors or EC Codewords is corrupted\n throw ChecksumException.getChecksumInstance();\n }\n return PDF417ScanningDecoder.errorCorrection.decode(codewords, numECCodewords, erasures);\n }\n /**\n * Verify that all is OK with the codeword array.\n * @throws FormatException\n */\n static verifyCodewordCount(codewords, numECCodewords) {\n if (codewords.length < 4) {\n // Codeword array size should be at least 4 allowing for\n // Count CW, At least one Data CW, Error Correction CW, Error Correction CW\n throw FormatException.getFormatInstance();\n }\n // The first codeword, the Symbol Length Descriptor, shall always encode the total number of data\n // codewords in the symbol, including the Symbol Length Descriptor itself, data codewords and pad\n // codewords, but excluding the number of error correction codewords.\n let numberOfCodewords = codewords[0];\n if (numberOfCodewords > codewords.length) {\n throw FormatException.getFormatInstance();\n }\n if (numberOfCodewords === 0) {\n // Reset to the length of the array - 8 (Allow for at least level 3 Error Correction (8 Error Codewords)\n if (numECCodewords < codewords.length) {\n codewords[0] = codewords.length - numECCodewords;\n }\n else {\n throw FormatException.getFormatInstance();\n }\n }\n }\n static getBitCountForCodeword(codeword) {\n let result = new Int32Array(8);\n let previousValue = 0;\n let i = result.length - 1;\n while (true) {\n if ((codeword & 0x1) !== previousValue) {\n previousValue = codeword & 0x1;\n i--;\n if (i < 0) {\n break;\n }\n }\n result[i]++;\n codeword >>= 1;\n }\n return result;\n }\n static getCodewordBucketNumber(codeword) {\n if (codeword instanceof Int32Array) {\n return this.getCodewordBucketNumber_Int32Array(codeword);\n }\n return this.getCodewordBucketNumber_number(codeword);\n }\n static getCodewordBucketNumber_number(codeword) {\n return PDF417ScanningDecoder.getCodewordBucketNumber(PDF417ScanningDecoder.getBitCountForCodeword(codeword));\n }\n static getCodewordBucketNumber_Int32Array(moduleBitCount) {\n return (moduleBitCount[0] - moduleBitCount[2] + moduleBitCount[4] - moduleBitCount[6] + 9) % 9;\n }\n static toString(barcodeMatrix) {\n let formatter = new Formatter();\n // try (let formatter = new Formatter()) {\n for (let row /*int*/ = 0; row < barcodeMatrix.length; row++) {\n formatter.format('Row %2d: ', row);\n for (let column /*int*/ = 0; column < barcodeMatrix[row].length; column++) {\n let barcodeValue = barcodeMatrix[row][column];\n if (barcodeValue.getValue().length === 0) {\n formatter.format(' ', null);\n }\n else {\n formatter.format('%4d(%2d)', barcodeValue.getValue()[0], barcodeValue.getConfidence(barcodeValue.getValue()[0]));\n }\n }\n formatter.format('%n');\n }\n return formatter.toString();\n // }\n }\n }\n /*final*/ PDF417ScanningDecoder.CODEWORD_SKEW_SIZE = 2;\n /*final*/ PDF417ScanningDecoder.MAX_ERRORS = 3;\n /*final*/ PDF417ScanningDecoder.MAX_EC_CODEWORDS = 512;\n /*final*/ PDF417ScanningDecoder.errorCorrection = new ErrorCorrection();\n\n /*\n * Copyright 2009 ZXing authors\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n // import java.util.ArrayList;\n // import java.util.List;\n // import java.util.Map;\n /**\n * This implementation can detect and decode PDF417 codes in an image.\n *\n * @author Guenther Grau\n */\n /*public final*/ class PDF417Reader {\n // private static /*final Result[]*/ EMPTY_RESULT_ARRAY: Result[] = new Result([0]);\n /**\n * Locates and decodes a PDF417 code in an image.\n *\n * @return a String representing the content encoded by the PDF417 code\n * @throws NotFoundException if a PDF417 code cannot be found,\n * @throws FormatException if a PDF417 cannot be decoded\n * @throws ChecksumException\n */\n // @Override\n decode(image, hints = null) {\n let result = PDF417Reader.decode(image, hints, false);\n if (result == null || result.length === 0 || result[0] == null) {\n throw NotFoundException.getNotFoundInstance();\n }\n return result[0];\n }\n /**\n *\n * @param BinaryBitmap\n * @param image\n * @throws NotFoundException\n */\n // @Override\n decodeMultiple(image, hints = null) {\n try {\n return PDF417Reader.decode(image, hints, true);\n }\n catch (ignored) {\n if (ignored instanceof FormatException || ignored instanceof ChecksumException) {\n throw NotFoundException.getNotFoundInstance();\n }\n throw ignored;\n }\n }\n /**\n *\n * @param image\n * @param hints\n * @param multiple\n *\n * @throws NotFoundException\n * @throws FormatExceptionß\n * @throws ChecksumException\n */\n static decode(image, hints, multiple) {\n const results = new Array();\n const detectorResult = Detector$3.detectMultiple(image, hints, multiple);\n for (const points of detectorResult.getPoints()) {\n const decoderResult = PDF417ScanningDecoder.decode(detectorResult.getBits(), points[4], points[5], points[6], points[7], PDF417Reader.getMinCodewordWidth(points), PDF417Reader.getMaxCodewordWidth(points));\n const result = new Result(decoderResult.getText(), decoderResult.getRawBytes(), undefined, points, BarcodeFormat$1.PDF_417);\n result.putMetadata(ResultMetadataType$1.ERROR_CORRECTION_LEVEL, decoderResult.getECLevel());\n const pdf417ResultMetadata = decoderResult.getOther();\n if (pdf417ResultMetadata != null) {\n result.putMetadata(ResultMetadataType$1.PDF417_EXTRA_METADATA, pdf417ResultMetadata);\n }\n results.push(result);\n }\n return results.map(x => x);\n }\n static getMaxWidth(p1, p2) {\n if (p1 == null || p2 == null) {\n return 0;\n }\n return Math.trunc(Math.abs(p1.getX() - p2.getX()));\n }\n static getMinWidth(p1, p2) {\n if (p1 == null || p2 == null) {\n return Integer.MAX_VALUE;\n }\n return Math.trunc(Math.abs(p1.getX() - p2.getX()));\n }\n static getMaxCodewordWidth(p) {\n return Math.floor(Math.max(Math.max(PDF417Reader.getMaxWidth(p[0], p[4]), PDF417Reader.getMaxWidth(p[6], p[2]) * PDF417Common.MODULES_IN_CODEWORD /\n PDF417Common.MODULES_IN_STOP_PATTERN), Math.max(PDF417Reader.getMaxWidth(p[1], p[5]), PDF417Reader.getMaxWidth(p[7], p[3]) * PDF417Common.MODULES_IN_CODEWORD /\n PDF417Common.MODULES_IN_STOP_PATTERN)));\n }\n static getMinCodewordWidth(p) {\n return Math.floor(Math.min(Math.min(PDF417Reader.getMinWidth(p[0], p[4]), PDF417Reader.getMinWidth(p[6], p[2]) * PDF417Common.MODULES_IN_CODEWORD /\n PDF417Common.MODULES_IN_STOP_PATTERN), Math.min(PDF417Reader.getMinWidth(p[1], p[5]), PDF417Reader.getMinWidth(p[7], p[3]) * PDF417Common.MODULES_IN_CODEWORD /\n PDF417Common.MODULES_IN_STOP_PATTERN)));\n }\n // @Override\n reset() {\n // nothing needs to be reset\n }\n }\n\n /**\n * Custom Error class of type Exception.\n */\n class ReaderException extends Exception {\n }\n ReaderException.kind = 'ReaderException';\n\n /*\n * Copyright 2009 ZXing authors\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n /*namespace com.google.zxing {*/\n /**\n * MultiFormatReader is a convenience class and the main entry point into the library for most uses.\n * By default it attempts to decode all barcode formats that the library supports. Optionally, you\n * can provide a hints object to request different behavior, for example only decoding QR codes.\n *\n * @author Sean Owen\n * @author dswitkin@google.com (Daniel Switkin)\n */\n class MultiFormatReader {\n /**\n * Creates an instance of this class\n * \n * @param {Boolean} verbose if 'true' logs will be dumped to console, otherwise hidden.\n * @param hints The hints to use, clearing the previous state.\n */\n constructor(verbose, hints) {\n this.verbose = (verbose === true);\n if (hints) {\n this.setHints(hints);\n }\n }\n /**\n * This version of decode honors the intent of Reader.decode(BinaryBitmap) in that it\n * passes null as a hint to the decoders. However, that makes it inefficient to call repeatedly.\n * Use setHints() followed by decodeWithState() for continuous scan applications.\n *\n * @param image The pixel data to decode\n * @return The contents of the image\n *\n * @throws NotFoundException Any errors which occurred\n */\n /*@Override*/\n // public decode(image: BinaryBitmap): Result {\n // setHints(null)\n // return decodeInternal(image)\n // }\n /**\n * Decode an image using the hints provided. Does not honor existing state.\n *\n * @param image The pixel data to decode\n * @param hints The hints to use, clearing the previous state.\n * @return The contents of the image\n *\n * @throws NotFoundException Any errors which occurred\n */\n /*@Override*/\n decode(image, hints) {\n if (hints) {\n this.setHints(hints);\n }\n return this.decodeInternal(image);\n }\n /**\n * Decode an image using the state set up by calling setHints() previously. Continuous scan\n * clients will get a large speed increase by using this instead of decode().\n *\n * @param image The pixel data to decode\n * @return The contents of the image\n *\n * @throws NotFoundException Any errors which occurred\n */\n decodeWithState(image) {\n // Make sure to set up the default state so we don't crash\n if (this.readers === null || this.readers === undefined) {\n this.setHints(null);\n }\n return this.decodeInternal(image);\n }\n /**\n * This method adds state to the MultiFormatReader. By setting the hints once, subsequent calls\n * to decodeWithState(image) can reuse the same set of readers without reallocating memory. This\n * is important for performance in continuous scan clients.\n *\n * @param hints The set of hints to use for subsequent calls to decode(image)\n */\n setHints(hints) {\n this.hints = hints;\n const tryHarder = !isNullOrUndefined(hints)\n && hints.get(DecodeHintType$1.TRY_HARDER) === true;\n const formats = isNullOrUndefined(hints) ? null : hints.get(DecodeHintType$1.POSSIBLE_FORMATS);\n const readers = new Array();\n if (!isNullOrUndefined(formats)) {\n const addOneDReader = formats.some(f => {\n return (\n f === BarcodeFormat$1.UPC_A ||\n f === BarcodeFormat$1.UPC_E ||\n f === BarcodeFormat$1.EAN_13 ||\n f === BarcodeFormat$1.EAN_8 ||\n f === BarcodeFormat$1.CODABAR ||\n f === BarcodeFormat$1.CODE_39 ||\n f === BarcodeFormat$1.CODE_93 ||\n f === BarcodeFormat$1.CODE_128 ||\n f === BarcodeFormat$1.ITF ||\n f === BarcodeFormat$1.RSS_14 ||\n f === BarcodeFormat$1.RSS_EXPANDED);\n });\n // Put 1D readers upfront in \"normal\" mode\n if (addOneDReader && !tryHarder) {\n readers.push(new MultiFormatOneDReader(hints, this.verbose));\n }\n if (formats.includes(BarcodeFormat$1.QR_CODE)) {\n readers.push(new QRCodeReader());\n }\n if (formats.includes(BarcodeFormat$1.DATA_MATRIX)) {\n readers.push(new DataMatrixReader());\n }\n if (formats.includes(BarcodeFormat$1.AZTEC)) {\n readers.push(new AztecReader());\n }\n if (formats.includes(BarcodeFormat$1.PDF_417)) {\n readers.push(new PDF417Reader());\n }\n // if (formats.includes(BarcodeFormat.MAXICODE)) {\n // readers.push(new MaxiCodeReader())\n // }\n // At end in \"try harder\" mode\n if (addOneDReader && tryHarder) {\n readers.push(new MultiFormatOneDReader(hints, this.verbose));\n }\n }\n if (readers.length === 0) {\n if (!tryHarder) {\n readers.push(new MultiFormatOneDReader(hints, this.verbose));\n }\n readers.push(new QRCodeReader());\n readers.push(new DataMatrixReader());\n readers.push(new AztecReader());\n readers.push(new PDF417Reader());\n // readers.push(new MaxiCodeReader())\n if (tryHarder) {\n readers.push(new MultiFormatOneDReader(hints, this.verbose));\n }\n }\n this.readers = readers; // .toArray(new Reader[readers.size()])\n }\n /*@Override*/\n reset() {\n if (this.readers !== null) {\n for (const reader of this.readers) {\n reader.reset();\n }\n }\n }\n /**\n * @throws NotFoundException\n */\n decodeInternal(image) {\n if (this.readers === null) {\n throw new ReaderException('No readers where selected, nothing can be read.');\n }\n for (const reader of this.readers) {\n // Trying to decode with ${reader} reader.\n try {\n return reader.decode(image, this.hints);\n }\n catch (ex) {\n if (ex instanceof ReaderException) {\n continue;\n }\n // Bad Exception.\n }\n }\n throw new NotFoundException('No MultiFormat Readers were able to detect the code.');\n }\n }\n\n class BrowserMultiFormatReader extends BrowserCodeReader {\n constructor(hints = null, timeBetweenScansMillis = 500) {\n const reader = new MultiFormatReader();\n reader.setHints(hints);\n super(reader, timeBetweenScansMillis);\n }\n /**\n * Overwrite decodeBitmap to call decodeWithState, which will pay\n * attention to the hints set in the constructor function\n */\n decodeBitmap(binaryBitmap) {\n return this.reader.decodeWithState(binaryBitmap);\n }\n }\n\n /**\n * @deprecated Moving to @zxing/browser\n *\n * QR Code reader to use from browser.\n */\n class BrowserPDF417Reader extends BrowserCodeReader {\n /**\n * Creates an instance of BrowserPDF417Reader.\n * @param {number} [timeBetweenScansMillis=500] the time delay between subsequent decode tries\n */\n constructor(timeBetweenScansMillis = 500) {\n super(new PDF417Reader(), timeBetweenScansMillis);\n }\n }\n\n /**\n * @deprecated Moving to @zxing/browser\n *\n * QR Code reader to use from browser.\n */\n class BrowserQRCodeReader extends BrowserCodeReader {\n /**\n * Creates an instance of BrowserQRCodeReader.\n * @param {number} [timeBetweenScansMillis=500] the time delay between subsequent decode tries\n */\n constructor(timeBetweenScansMillis = 500) {\n super(new QRCodeReader(), timeBetweenScansMillis);\n }\n }\n\n /*\n * Copyright 2009 ZXing authors\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n /*namespace com.google.zxing {*/\n /**\n * These are a set of hints that you may pass to Writers to specify their behavior.\n *\n * @author dswitkin@google.com (Daniel Switkin)\n */\n var EncodeHintType;\n (function (EncodeHintType) {\n /**\n * Specifies what degree of error correction to use, for example in QR Codes.\n * Type depends on the encoder. For example for QR codes it's type\n * {@link com.google.zxing.qrcode.decoder.ErrorCorrectionLevel ErrorCorrectionLevel}.\n * For Aztec it is of type {@link Integer}, representing the minimal percentage of error correction words.\n * For PDF417 it is of type {@link Integer}, valid values being 0 to 8.\n * In all cases, it can also be a {@link String} representation of the desired value as well.\n * Note: an Aztec symbol should have a minimum of 25% EC words.\n */\n EncodeHintType[EncodeHintType[\"ERROR_CORRECTION\"] = 0] = \"ERROR_CORRECTION\";\n /**\n * Specifies what character encoding to use where applicable (type {@link String})\n */\n EncodeHintType[EncodeHintType[\"CHARACTER_SET\"] = 1] = \"CHARACTER_SET\";\n /**\n * Specifies the matrix shape for Data Matrix (type {@link com.google.zxing.datamatrix.encoder.SymbolShapeHint})\n */\n EncodeHintType[EncodeHintType[\"DATA_MATRIX_SHAPE\"] = 2] = \"DATA_MATRIX_SHAPE\";\n /**\n * Specifies a minimum barcode size (type {@link Dimension}). Only applicable to Data Matrix now.\n *\n * @deprecated use width/height params in\n * {@link com.google.zxing.datamatrix.DataMatrixWriter#encode(String, BarcodeFormat, int, int)}\n */\n /*@Deprecated*/\n EncodeHintType[EncodeHintType[\"MIN_SIZE\"] = 3] = \"MIN_SIZE\";\n /**\n * Specifies a maximum barcode size (type {@link Dimension}). Only applicable to Data Matrix now.\n *\n * @deprecated without replacement\n */\n /*@Deprecated*/\n EncodeHintType[EncodeHintType[\"MAX_SIZE\"] = 4] = \"MAX_SIZE\";\n /**\n * Specifies margin, in pixels, to use when generating the barcode. The meaning can vary\n * by format; for example it controls margin before and after the barcode horizontally for\n * most 1D formats. (Type {@link Integer}, or {@link String} representation of the integer value).\n */\n EncodeHintType[EncodeHintType[\"MARGIN\"] = 5] = \"MARGIN\";\n /**\n * Specifies whether to use compact mode for PDF417 (type {@link Boolean}, or \"true\" or \"false\"\n * {@link String} value).\n */\n EncodeHintType[EncodeHintType[\"PDF417_COMPACT\"] = 6] = \"PDF417_COMPACT\";\n /**\n * Specifies what compaction mode to use for PDF417 (type\n * {@link com.google.zxing.pdf417.encoder.Compaction Compaction} or {@link String} value of one of its\n * enum values).\n */\n EncodeHintType[EncodeHintType[\"PDF417_COMPACTION\"] = 7] = \"PDF417_COMPACTION\";\n /**\n * Specifies the minimum and maximum number of rows and columns for PDF417 (type\n * {@link com.google.zxing.pdf417.encoder.Dimensions Dimensions}).\n */\n EncodeHintType[EncodeHintType[\"PDF417_DIMENSIONS\"] = 8] = \"PDF417_DIMENSIONS\";\n /**\n * Specifies the required number of layers for an Aztec code.\n * A negative number (-1, -2, -3, -4) specifies a compact Aztec code.\n * 0 indicates to use the minimum number of layers (the default).\n * A positive number (1, 2, .. 32) specifies a normal (non-compact) Aztec code.\n * (Type {@link Integer}, or {@link String} representation of the integer value).\n */\n EncodeHintType[EncodeHintType[\"AZTEC_LAYERS\"] = 9] = \"AZTEC_LAYERS\";\n /**\n * Specifies the exact version of QR code to be encoded.\n * (Type {@link Integer}, or {@link String} representation of the integer value).\n */\n EncodeHintType[EncodeHintType[\"QR_VERSION\"] = 10] = \"QR_VERSION\";\n })(EncodeHintType || (EncodeHintType = {}));\n var EncodeHintType$1 = EncodeHintType;\n\n /**\n * Implements Reed-Solomon encoding, as the name implies.
\n *\n * @author Sean Owen\n * @author William Rucklidge\n */\n class ReedSolomonEncoder {\n /**\n * A reed solomon error-correcting encoding constructor is created by\n * passing as Galois Field with of size equal to the number of code\n * words (symbols) in the alphabet (the number of values in each\n * element of arrays that are encoded/decoded).\n * @param field A galois field with a number of elements equal to the size\n * of the alphabet of symbols to encode.\n */\n constructor(field) {\n this.field = field;\n this.cachedGenerators = [];\n this.cachedGenerators.push(new GenericGFPoly(field, Int32Array.from([1])));\n }\n buildGenerator(degree /*int*/) {\n const cachedGenerators = this.cachedGenerators;\n if (degree >= cachedGenerators.length) {\n let lastGenerator = cachedGenerators[cachedGenerators.length - 1];\n const field = this.field;\n for (let d = cachedGenerators.length; d <= degree; d++) {\n const nextGenerator = lastGenerator.multiply(new GenericGFPoly(field, Int32Array.from([1, field.exp(d - 1 + field.getGeneratorBase())])));\n cachedGenerators.push(nextGenerator);\n lastGenerator = nextGenerator;\n }\n }\n return cachedGenerators[degree];\n }\n /**\n * Encode a sequence of code words (symbols) using Reed-Solomon to allow decoders\n * to detect and correct errors that may have been introduced when the resulting\n * data is stored or transmitted.
\n *\n * @param toEncode array used for both and output. Caller initializes the array with\n * the code words (symbols) to be encoded followed by empty elements allocated to make\n * space for error-correction code words in the encoded output. The array contains\n * the encdoded output when encode returns. Code words are encoded as numbers from\n * 0 to n-1, where n is the number of possible code words (symbols), as determined\n * by the size of the Galois Field passed in the constructor of this object.\n * @param ecBytes the number of elements reserved in the array (first parameter)\n * to store error-correction code words. Thus, the number of code words (symbols)\n * to encode in the first parameter is thus toEncode.length - ecBytes.\n * Note, the use of \"bytes\" in the name of this parameter is misleading, as there may\n * be more or fewer than 256 symbols being encoded, as determined by the number of\n * elements in the Galois Field passed as a constructor to this object.\n * @throws IllegalArgumentException thrown in response to validation errros.\n */\n encode(toEncode, ecBytes /*int*/) {\n if (ecBytes === 0) {\n throw new IllegalArgumentException('No error correction bytes');\n }\n const dataBytes = toEncode.length - ecBytes;\n if (dataBytes <= 0) {\n throw new IllegalArgumentException('No data bytes provided');\n }\n const generator = this.buildGenerator(ecBytes);\n const infoCoefficients = new Int32Array(dataBytes);\n System.arraycopy(toEncode, 0, infoCoefficients, 0, dataBytes);\n let info = new GenericGFPoly(this.field, infoCoefficients);\n info = info.multiplyByMonomial(ecBytes, 1);\n const remainder = info.divide(generator)[1];\n const coefficients = remainder.getCoefficients();\n const numZeroCoefficients = ecBytes - coefficients.length;\n for (let i = 0; i < numZeroCoefficients; i++) {\n toEncode[dataBytes + i] = 0;\n }\n System.arraycopy(coefficients, 0, toEncode, dataBytes + numZeroCoefficients, coefficients.length);\n }\n }\n\n /**\n * @author Satoru Takabayashi\n * @author Daniel Switkin\n * @author Sean Owen\n */\n class MaskUtil {\n constructor() {\n // do nothing\n }\n /**\n * Apply mask penalty rule 1 and return the penalty. Find repetitive cells with the same color and\n * give penalty to them. Example: 00000 or 11111.\n */\n static applyMaskPenaltyRule1(matrix) {\n return MaskUtil.applyMaskPenaltyRule1Internal(matrix, true) + MaskUtil.applyMaskPenaltyRule1Internal(matrix, false);\n }\n /**\n * Apply mask penalty rule 2 and return the penalty. Find 2x2 blocks with the same color and give\n * penalty to them. This is actually equivalent to the spec's rule, which is to find MxN blocks and give a\n * penalty proportional to (M-1)x(N-1), because this is the number of 2x2 blocks inside such a block.\n */\n static applyMaskPenaltyRule2(matrix) {\n let penalty = 0;\n const array = matrix.getArray();\n const width = matrix.getWidth();\n const height = matrix.getHeight();\n for (let y = 0; y < height - 1; y++) {\n const arrayY = array[y];\n for (let x = 0; x < width - 1; x++) {\n const value = arrayY[x];\n if (value === arrayY[x + 1] && value === array[y + 1][x] && value === array[y + 1][x + 1]) {\n penalty++;\n }\n }\n }\n return MaskUtil.N2 * penalty;\n }\n /**\n * Apply mask penalty rule 3 and return the penalty. Find consecutive runs of 1:1:3:1:1:4\n * starting with black, or 4:1:1:3:1:1 starting with white, and give penalty to them. If we\n * find patterns like 000010111010000, we give penalty once.\n */\n static applyMaskPenaltyRule3(matrix) {\n let numPenalties = 0;\n const array = matrix.getArray();\n const width = matrix.getWidth();\n const height = matrix.getHeight();\n for (let y = 0; y < height; y++) {\n for (let x = 0; x < width; x++) {\n const arrayY = array[y]; // We can at least optimize this access\n if (x + 6 < width &&\n arrayY[x] === 1 &&\n arrayY[x + 1] === 0 &&\n arrayY[x + 2] === 1 &&\n arrayY[x + 3] === 1 &&\n arrayY[x + 4] === 1 &&\n arrayY[x + 5] === 0 &&\n arrayY[x + 6] === 1 &&\n (MaskUtil.isWhiteHorizontal(arrayY, x - 4, x) || MaskUtil.isWhiteHorizontal(arrayY, x + 7, x + 11))) {\n numPenalties++;\n }\n if (y + 6 < height &&\n array[y][x] === 1 &&\n array[y + 1][x] === 0 &&\n array[y + 2][x] === 1 &&\n array[y + 3][x] === 1 &&\n array[y + 4][x] === 1 &&\n array[y + 5][x] === 0 &&\n array[y + 6][x] === 1 &&\n (MaskUtil.isWhiteVertical(array, x, y - 4, y) || MaskUtil.isWhiteVertical(array, x, y + 7, y + 11))) {\n numPenalties++;\n }\n }\n }\n return numPenalties * MaskUtil.N3;\n }\n static isWhiteHorizontal(rowArray, from /*int*/, to /*int*/) {\n from = Math.max(from, 0);\n to = Math.min(to, rowArray.length);\n for (let i = from; i < to; i++) {\n if (rowArray[i] === 1) {\n return false;\n }\n }\n return true;\n }\n static isWhiteVertical(array, col /*int*/, from /*int*/, to /*int*/) {\n from = Math.max(from, 0);\n to = Math.min(to, array.length);\n for (let i = from; i < to; i++) {\n if (array[i][col] === 1) {\n return false;\n }\n }\n return true;\n }\n /**\n * Apply mask penalty rule 4 and return the penalty. Calculate the ratio of dark cells and give\n * penalty if the ratio is far from 50%. It gives 10 penalty for 5% distance.\n */\n static applyMaskPenaltyRule4(matrix) {\n let numDarkCells = 0;\n const array = matrix.getArray();\n const width = matrix.getWidth();\n const height = matrix.getHeight();\n for (let y = 0; y < height; y++) {\n const arrayY = array[y];\n for (let x = 0; x < width; x++) {\n if (arrayY[x] === 1) {\n numDarkCells++;\n }\n }\n }\n const numTotalCells = matrix.getHeight() * matrix.getWidth();\n const fivePercentVariances = Math.floor(Math.abs(numDarkCells * 2 - numTotalCells) * 10 / numTotalCells);\n return fivePercentVariances * MaskUtil.N4;\n }\n /**\n * Return the mask bit for \"getMaskPattern\" at \"x\" and \"y\". See 8.8 of JISX0510:2004 for mask\n * pattern conditions.\n */\n static getDataMaskBit(maskPattern /*int*/, x /*int*/, y /*int*/) {\n let intermediate; /*int*/\n let temp; /*int*/\n switch (maskPattern) {\n case 0:\n intermediate = (y + x) & 0x1;\n break;\n case 1:\n intermediate = y & 0x1;\n break;\n case 2:\n intermediate = x % 3;\n break;\n case 3:\n intermediate = (y + x) % 3;\n break;\n case 4:\n intermediate = (Math.floor(y / 2) + Math.floor(x / 3)) & 0x1;\n break;\n case 5:\n temp = y * x;\n intermediate = (temp & 0x1) + (temp % 3);\n break;\n case 6:\n temp = y * x;\n intermediate = ((temp & 0x1) + (temp % 3)) & 0x1;\n break;\n case 7:\n temp = y * x;\n intermediate = ((temp % 3) + ((y + x) & 0x1)) & 0x1;\n break;\n default:\n throw new IllegalArgumentException('Invalid mask pattern: ' + maskPattern);\n }\n return intermediate === 0;\n }\n /**\n * Helper function for applyMaskPenaltyRule1. We need this for doing this calculation in both\n * vertical and horizontal orders respectively.\n */\n static applyMaskPenaltyRule1Internal(matrix, isHorizontal) {\n let penalty = 0;\n const iLimit = isHorizontal ? matrix.getHeight() : matrix.getWidth();\n const jLimit = isHorizontal ? matrix.getWidth() : matrix.getHeight();\n const array = matrix.getArray();\n for (let i = 0; i < iLimit; i++) {\n let numSameBitCells = 0;\n let prevBit = -1;\n for (let j = 0; j < jLimit; j++) {\n const bit = isHorizontal ? array[i][j] : array[j][i];\n if (bit === prevBit) {\n numSameBitCells++;\n }\n else {\n if (numSameBitCells >= 5) {\n penalty += MaskUtil.N1 + (numSameBitCells - 5);\n }\n numSameBitCells = 1; // Include the cell itself.\n prevBit = bit;\n }\n }\n if (numSameBitCells >= 5) {\n penalty += MaskUtil.N1 + (numSameBitCells - 5);\n }\n }\n return penalty;\n }\n }\n // Penalty weights from section 6.8.2.1\n MaskUtil.N1 = 3;\n MaskUtil.N2 = 3;\n MaskUtil.N3 = 40;\n MaskUtil.N4 = 10;\n\n /**\n * JAVAPORT: The original code was a 2D array of ints, but since it only ever gets assigned\n * -1, 0, and 1, I'm going to use less memory and go with bytes.\n *\n * @author dswitkin@google.com (Daniel Switkin)\n */\n class ByteMatrix {\n constructor(width /*int*/, height /*int*/) {\n this.width = width;\n this.height = height;\n const bytes = new Array(height); // [height][width]\n for (let i = 0; i !== height; i++) {\n bytes[i] = new Uint8Array(width);\n }\n this.bytes = bytes;\n }\n getHeight() {\n return this.height;\n }\n getWidth() {\n return this.width;\n }\n get(x /*int*/, y /*int*/) {\n return this.bytes[y][x];\n }\n /**\n * @return an internal representation as bytes, in row-major order. array[y][x] represents point (x,y)\n */\n getArray() {\n return this.bytes;\n }\n // TYPESCRIPTPORT: preffer to let two methods instead of override to avoid type comparison inside\n setNumber(x /*int*/, y /*int*/, value /*byte|int*/) {\n this.bytes[y][x] = value;\n }\n // public set(x: number /*int*/, y: number /*int*/, value: number /*int*/): void {\n // bytes[y][x] = (byte) value\n // }\n setBoolean(x /*int*/, y /*int*/, value) {\n this.bytes[y][x] = /*(byte) */ (value ? 1 : 0);\n }\n clear(value /*byte*/) {\n for (const aByte of this.bytes) {\n Arrays.fill(aByte, value);\n }\n }\n equals(o) {\n if (!(o instanceof ByteMatrix)) {\n return false;\n }\n const other = o;\n if (this.width !== other.width) {\n return false;\n }\n if (this.height !== other.height) {\n return false;\n }\n for (let y = 0, height = this.height; y < height; ++y) {\n const bytesY = this.bytes[y];\n const otherBytesY = other.bytes[y];\n for (let x = 0, width = this.width; x < width; ++x) {\n if (bytesY[x] !== otherBytesY[x]) {\n return false;\n }\n }\n }\n return true;\n }\n /*@Override*/\n toString() {\n const result = new StringBuilder(); // (2 * width * height + 2)\n for (let y = 0, height = this.height; y < height; ++y) {\n const bytesY = this.bytes[y];\n for (let x = 0, width = this.width; x < width; ++x) {\n switch (bytesY[x]) {\n case 0:\n result.append(' 0');\n break;\n case 1:\n result.append(' 1');\n break;\n default:\n result.append(' ');\n break;\n }\n }\n result.append('\\n');\n }\n return result.toString();\n }\n }\n\n /**\n * @author satorux@google.com (Satoru Takabayashi) - creator\n * @author dswitkin@google.com (Daniel Switkin) - ported from C++\n */\n class QRCode {\n constructor() {\n this.maskPattern = -1;\n }\n getMode() {\n return this.mode;\n }\n getECLevel() {\n return this.ecLevel;\n }\n getVersion() {\n return this.version;\n }\n getMaskPattern() {\n return this.maskPattern;\n }\n getMatrix() {\n return this.matrix;\n }\n /*@Override*/\n toString() {\n const result = new StringBuilder(); // (200)\n result.append('<<\\n');\n result.append(' mode: ');\n result.append(this.mode ? this.mode.toString() : 'null');\n result.append('\\n ecLevel: ');\n result.append(this.ecLevel ? this.ecLevel.toString() : 'null');\n result.append('\\n version: ');\n result.append(this.version ? this.version.toString() : 'null');\n result.append('\\n maskPattern: ');\n result.append(this.maskPattern.toString());\n if (this.matrix) {\n result.append('\\n matrix:\\n');\n result.append(this.matrix.toString());\n }\n else {\n result.append('\\n matrix: null\\n');\n }\n result.append('>>\\n');\n return result.toString();\n }\n setMode(value) {\n this.mode = value;\n }\n setECLevel(value) {\n this.ecLevel = value;\n }\n setVersion(version) {\n this.version = version;\n }\n setMaskPattern(value /*int*/) {\n this.maskPattern = value;\n }\n setMatrix(value) {\n this.matrix = value;\n }\n // Check if \"mask_pattern\" is valid.\n static isValidMaskPattern(maskPattern /*int*/) {\n return maskPattern >= 0 && maskPattern < QRCode.NUM_MASK_PATTERNS;\n }\n }\n QRCode.NUM_MASK_PATTERNS = 8;\n\n /**\n * Custom Error class of type Exception.\n */\n class WriterException extends Exception {\n }\n WriterException.kind = 'WriterException';\n\n /**\n * @author satorux@google.com (Satoru Takabayashi) - creator\n * @author dswitkin@google.com (Daniel Switkin) - ported from C++\n */\n class MatrixUtil {\n constructor() {\n // do nothing\n }\n // Set all cells to -1 (TYPESCRIPTPORT: 255). -1 (TYPESCRIPTPORT: 255) means that the cell is empty (not set yet).\n //\n // JAVAPORT: We shouldn't need to do this at all. The code should be rewritten to begin encoding\n // with the ByteMatrix initialized all to zero.\n static clearMatrix(matrix) {\n // TYPESCRIPTPORT: we use UintArray se changed here from -1 to 255\n matrix.clear(/*(byte) */ /*-1*/ 255);\n }\n // Build 2D matrix of QR Code from \"dataBits\" with \"ecLevel\", \"version\" and \"getMaskPattern\". On\n // success, store the result in \"matrix\" and return true.\n static buildMatrix(dataBits, ecLevel, version, maskPattern /*int*/, matrix) {\n MatrixUtil.clearMatrix(matrix);\n MatrixUtil.embedBasicPatterns(version, matrix);\n // Type information appear with any version.\n MatrixUtil.embedTypeInfo(ecLevel, maskPattern, matrix);\n // Version info appear if version >= 7.\n MatrixUtil.maybeEmbedVersionInfo(version, matrix);\n // Data should be embedded at end.\n MatrixUtil.embedDataBits(dataBits, maskPattern, matrix);\n }\n // Embed basic patterns. On success, modify the matrix and return true.\n // The basic patterns are:\n // - Position detection patterns\n // - Timing patterns\n // - Dark dot at the left bottom corner\n // - Position adjustment patterns, if need be\n static embedBasicPatterns(version, matrix) {\n // Let's get started with embedding big squares at corners.\n MatrixUtil.embedPositionDetectionPatternsAndSeparators(matrix);\n // Then, embed the dark dot at the left bottom corner.\n MatrixUtil.embedDarkDotAtLeftBottomCorner(matrix);\n // Position adjustment patterns appear if version >= 2.\n MatrixUtil.maybeEmbedPositionAdjustmentPatterns(version, matrix);\n // Timing patterns should be embedded after position adj. patterns.\n MatrixUtil.embedTimingPatterns(matrix);\n }\n // Embed type information. On success, modify the matrix.\n static embedTypeInfo(ecLevel, maskPattern /*int*/, matrix) {\n const typeInfoBits = new BitArray();\n MatrixUtil.makeTypeInfoBits(ecLevel, maskPattern, typeInfoBits);\n for (let i = 0, size = typeInfoBits.getSize(); i < size; ++i) {\n // Place bits in LSB to MSB order. LSB (least significant bit) is the last value in\n // \"typeInfoBits\".\n const bit = typeInfoBits.get(typeInfoBits.getSize() - 1 - i);\n // Type info bits at the left top corner. See 8.9 of JISX0510:2004 (p.46).\n const coordinates = MatrixUtil.TYPE_INFO_COORDINATES[i];\n const x1 = coordinates[0];\n const y1 = coordinates[1];\n matrix.setBoolean(x1, y1, bit);\n if (i < 8) {\n // Right top corner.\n const x2 = matrix.getWidth() - i - 1;\n const y2 = 8;\n matrix.setBoolean(x2, y2, bit);\n }\n else {\n // Left bottom corner.\n const x2 = 8;\n const y2 = matrix.getHeight() - 7 + (i - 8);\n matrix.setBoolean(x2, y2, bit);\n }\n }\n }\n // Embed version information if need be. On success, modify the matrix and return true.\n // See 8.10 of JISX0510:2004 (p.47) for how to embed version information.\n static maybeEmbedVersionInfo(version, matrix) {\n if (version.getVersionNumber() < 7) { // Version info is necessary if version >= 7.\n return; // Don't need version info.\n }\n const versionInfoBits = new BitArray();\n MatrixUtil.makeVersionInfoBits(version, versionInfoBits);\n let bitIndex = 6 * 3 - 1; // It will decrease from 17 to 0.\n for (let i = 0; i < 6; ++i) {\n for (let j = 0; j < 3; ++j) {\n // Place bits in LSB (least significant bit) to MSB order.\n const bit = versionInfoBits.get(bitIndex);\n bitIndex--;\n // Left bottom corner.\n matrix.setBoolean(i, matrix.getHeight() - 11 + j, bit);\n // Right bottom corner.\n matrix.setBoolean(matrix.getHeight() - 11 + j, i, bit);\n }\n }\n }\n // Embed \"dataBits\" using \"getMaskPattern\". On success, modify the matrix and return true.\n // For debugging purposes, it skips masking process if \"getMaskPattern\" is -1(TYPESCRIPTPORT: 255).\n // See 8.7 of JISX0510:2004 (p.38) for how to embed data bits.\n static embedDataBits(dataBits, maskPattern /*int*/, matrix) {\n let bitIndex = 0;\n let direction = -1;\n // Start from the right bottom cell.\n let x = matrix.getWidth() - 1;\n let y = matrix.getHeight() - 1;\n while (x > 0) {\n // Skip the vertical timing pattern.\n if (x === 6) {\n x -= 1;\n }\n while (y >= 0 && y < matrix.getHeight()) {\n for (let i = 0; i < 2; ++i) {\n const xx = x - i;\n // Skip the cell if it's not empty.\n if (!MatrixUtil.isEmpty(matrix.get(xx, y))) {\n continue;\n }\n let bit;\n if (bitIndex < dataBits.getSize()) {\n bit = dataBits.get(bitIndex);\n ++bitIndex;\n }\n else {\n // Padding bit. If there is no bit left, we'll fill the left cells with 0, as described\n // in 8.4.9 of JISX0510:2004 (p. 24).\n bit = false;\n }\n // Skip masking if mask_pattern is -1 (TYPESCRIPTPORT: 255).\n if (maskPattern !== 255 && MaskUtil.getDataMaskBit(maskPattern, xx, y)) {\n bit = !bit;\n }\n matrix.setBoolean(xx, y, bit);\n }\n y += direction;\n }\n direction = -direction; // Reverse the direction.\n y += direction;\n x -= 2; // Move to the left.\n }\n // All bits should be consumed.\n if (bitIndex !== dataBits.getSize()) {\n throw new WriterException('Not all bits consumed: ' + bitIndex + '/' + dataBits.getSize());\n }\n }\n // Return the position of the most significant bit set (one: to) in the \"value\". The most\n // significant bit is position 32. If there is no bit set, return 0. Examples:\n // - findMSBSet(0) => 0\n // - findMSBSet(1) => 1\n // - findMSBSet(255) => 8\n static findMSBSet(value /*int*/) {\n return 32 - Integer.numberOfLeadingZeros(value);\n }\n // Calculate BCH (Bose-Chaudhuri-Hocquenghem) code for \"value\" using polynomial \"poly\". The BCH\n // code is used for encoding type information and version information.\n // Example: Calculation of version information of 7.\n // f(x) is created from 7.\n // - 7 = 000111 in 6 bits\n // - f(x) = x^2 + x^1 + x^0\n // g(x) is given by the standard (p. 67)\n // - g(x) = x^12 + x^11 + x^10 + x^9 + x^8 + x^5 + x^2 + 1\n // Multiply f(x) by x^(18 - 6)\n // - f'(x) = f(x) * x^(18 - 6)\n // - f'(x) = x^14 + x^13 + x^12\n // Calculate the remainder of f'(x) / g(x)\n // x^2\n // __________________________________________________\n // g(x) )x^14 + x^13 + x^12\n // x^14 + x^13 + x^12 + x^11 + x^10 + x^7 + x^4 + x^2\n // --------------------------------------------------\n // x^11 + x^10 + x^7 + x^4 + x^2\n //\n // The remainder is x^11 + x^10 + x^7 + x^4 + x^2\n // Encode it in binary: 110010010100\n // The return value is 0xc94 (1100 1001 0100)\n //\n // Since all coefficients in the polynomials are 1 or 0, we can do the calculation by bit\n // operations. We don't care if coefficients are positive or negative.\n static calculateBCHCode(value /*int*/, poly /*int*/) {\n if (poly === 0) {\n throw new IllegalArgumentException('0 polynomial');\n }\n // If poly is \"1 1111 0010 0101\" (version info poly), msbSetInPoly is 13. We'll subtract 1\n // from 13 to make it 12.\n const msbSetInPoly = MatrixUtil.findMSBSet(poly);\n value <<= msbSetInPoly - 1;\n // Do the division business using exclusive-or operations.\n while (MatrixUtil.findMSBSet(value) >= msbSetInPoly) {\n value ^= poly << (MatrixUtil.findMSBSet(value) - msbSetInPoly);\n }\n // Now the \"value\" is the remainder (i.e. the BCH code)\n return value;\n }\n // Make bit vector of type information. On success, store the result in \"bits\" and return true.\n // Encode error correction level and mask pattern. See 8.9 of\n // JISX0510:2004 (p.45) for details.\n static makeTypeInfoBits(ecLevel, maskPattern /*int*/, bits) {\n if (!QRCode.isValidMaskPattern(maskPattern)) {\n throw new WriterException('Invalid mask pattern');\n }\n const typeInfo = (ecLevel.getBits() << 3) | maskPattern;\n bits.appendBits(typeInfo, 5);\n const bchCode = MatrixUtil.calculateBCHCode(typeInfo, MatrixUtil.TYPE_INFO_POLY);\n bits.appendBits(bchCode, 10);\n const maskBits = new BitArray();\n maskBits.appendBits(MatrixUtil.TYPE_INFO_MASK_PATTERN, 15);\n bits.xor(maskBits);\n if (bits.getSize() !== 15) { // Just in case.\n throw new WriterException('should not happen but we got: ' + bits.getSize());\n }\n }\n // Make bit vector of version information. On success, store the result in \"bits\" and return true.\n // See 8.10 of JISX0510:2004 (p.45) for details.\n static makeVersionInfoBits(version, bits) {\n bits.appendBits(version.getVersionNumber(), 6);\n const bchCode = MatrixUtil.calculateBCHCode(version.getVersionNumber(), MatrixUtil.VERSION_INFO_POLY);\n bits.appendBits(bchCode, 12);\n if (bits.getSize() !== 18) { // Just in case.\n throw new WriterException('should not happen but we got: ' + bits.getSize());\n }\n }\n // Check if \"value\" is empty.\n static isEmpty(value /*int*/) {\n return value === 255; // -1\n }\n static embedTimingPatterns(matrix) {\n // -8 is for skipping position detection patterns (7: size), and two horizontal/vertical\n // separation patterns (1: size). Thus, 8 = 7 + 1.\n for (let i = 8; i < matrix.getWidth() - 8; ++i) {\n const bit = (i + 1) % 2;\n // Horizontal line.\n if (MatrixUtil.isEmpty(matrix.get(i, 6))) {\n matrix.setNumber(i, 6, bit);\n }\n // Vertical line.\n if (MatrixUtil.isEmpty(matrix.get(6, i))) {\n matrix.setNumber(6, i, bit);\n }\n }\n }\n // Embed the lonely dark dot at left bottom corner. JISX0510:2004 (p.46)\n static embedDarkDotAtLeftBottomCorner(matrix) {\n if (matrix.get(8, matrix.getHeight() - 8) === 0) {\n throw new WriterException();\n }\n matrix.setNumber(8, matrix.getHeight() - 8, 1);\n }\n static embedHorizontalSeparationPattern(xStart /*int*/, yStart /*int*/, matrix) {\n for (let x = 0; x < 8; ++x) {\n if (!MatrixUtil.isEmpty(matrix.get(xStart + x, yStart))) {\n throw new WriterException();\n }\n matrix.setNumber(xStart + x, yStart, 0);\n }\n }\n static embedVerticalSeparationPattern(xStart /*int*/, yStart /*int*/, matrix) {\n for (let y = 0; y < 7; ++y) {\n if (!MatrixUtil.isEmpty(matrix.get(xStart, yStart + y))) {\n throw new WriterException();\n }\n matrix.setNumber(xStart, yStart + y, 0);\n }\n }\n static embedPositionAdjustmentPattern(xStart /*int*/, yStart /*int*/, matrix) {\n for (let y = 0; y < 5; ++y) {\n const patternY = MatrixUtil.POSITION_ADJUSTMENT_PATTERN[y];\n for (let x = 0; x < 5; ++x) {\n matrix.setNumber(xStart + x, yStart + y, patternY[x]);\n }\n }\n }\n static embedPositionDetectionPattern(xStart /*int*/, yStart /*int*/, matrix) {\n for (let y = 0; y < 7; ++y) {\n const patternY = MatrixUtil.POSITION_DETECTION_PATTERN[y];\n for (let x = 0; x < 7; ++x) {\n matrix.setNumber(xStart + x, yStart + y, patternY[x]);\n }\n }\n }\n // Embed position detection patterns and surrounding vertical/horizontal separators.\n static embedPositionDetectionPatternsAndSeparators(matrix) {\n // Embed three big squares at corners.\n const pdpWidth = MatrixUtil.POSITION_DETECTION_PATTERN[0].length;\n // Left top corner.\n MatrixUtil.embedPositionDetectionPattern(0, 0, matrix);\n // Right top corner.\n MatrixUtil.embedPositionDetectionPattern(matrix.getWidth() - pdpWidth, 0, matrix);\n // Left bottom corner.\n MatrixUtil.embedPositionDetectionPattern(0, matrix.getWidth() - pdpWidth, matrix);\n // Embed horizontal separation patterns around the squares.\n const hspWidth = 8;\n // Left top corner.\n MatrixUtil.embedHorizontalSeparationPattern(0, hspWidth - 1, matrix);\n // Right top corner.\n MatrixUtil.embedHorizontalSeparationPattern(matrix.getWidth() - hspWidth, hspWidth - 1, matrix);\n // Left bottom corner.\n MatrixUtil.embedHorizontalSeparationPattern(0, matrix.getWidth() - hspWidth, matrix);\n // Embed vertical separation patterns around the squares.\n const vspSize = 7;\n // Left top corner.\n MatrixUtil.embedVerticalSeparationPattern(vspSize, 0, matrix);\n // Right top corner.\n MatrixUtil.embedVerticalSeparationPattern(matrix.getHeight() - vspSize - 1, 0, matrix);\n // Left bottom corner.\n MatrixUtil.embedVerticalSeparationPattern(vspSize, matrix.getHeight() - vspSize, matrix);\n }\n // Embed position adjustment patterns if need be.\n static maybeEmbedPositionAdjustmentPatterns(version, matrix) {\n if (version.getVersionNumber() < 2) { // The patterns appear if version >= 2\n return;\n }\n const index = version.getVersionNumber() - 1;\n const coordinates = MatrixUtil.POSITION_ADJUSTMENT_PATTERN_COORDINATE_TABLE[index];\n for (let i = 0, length = coordinates.length; i !== length; i++) {\n const y = coordinates[i];\n if (y >= 0) {\n for (let j = 0; j !== length; j++) {\n const x = coordinates[j];\n if (x >= 0 && MatrixUtil.isEmpty(matrix.get(x, y))) {\n // If the cell is unset, we embed the position adjustment pattern here.\n // -2 is necessary since the x/y coordinates point to the center of the pattern, not the\n // left top corner.\n MatrixUtil.embedPositionAdjustmentPattern(x - 2, y - 2, matrix);\n }\n }\n }\n }\n }\n }\n MatrixUtil.POSITION_DETECTION_PATTERN = Array.from([\n Int32Array.from([1, 1, 1, 1, 1, 1, 1]),\n Int32Array.from([1, 0, 0, 0, 0, 0, 1]),\n Int32Array.from([1, 0, 1, 1, 1, 0, 1]),\n Int32Array.from([1, 0, 1, 1, 1, 0, 1]),\n Int32Array.from([1, 0, 1, 1, 1, 0, 1]),\n Int32Array.from([1, 0, 0, 0, 0, 0, 1]),\n Int32Array.from([1, 1, 1, 1, 1, 1, 1]),\n ]);\n MatrixUtil.POSITION_ADJUSTMENT_PATTERN = Array.from([\n Int32Array.from([1, 1, 1, 1, 1]),\n Int32Array.from([1, 0, 0, 0, 1]),\n Int32Array.from([1, 0, 1, 0, 1]),\n Int32Array.from([1, 0, 0, 0, 1]),\n Int32Array.from([1, 1, 1, 1, 1]),\n ]);\n // From Appendix E. Table 1, JIS0510X:2004 (71: p). The table was double-checked by komatsu.\n MatrixUtil.POSITION_ADJUSTMENT_PATTERN_COORDINATE_TABLE = Array.from([\n Int32Array.from([-1, -1, -1, -1, -1, -1, -1]),\n Int32Array.from([6, 18, -1, -1, -1, -1, -1]),\n Int32Array.from([6, 22, -1, -1, -1, -1, -1]),\n Int32Array.from([6, 26, -1, -1, -1, -1, -1]),\n Int32Array.from([6, 30, -1, -1, -1, -1, -1]),\n Int32Array.from([6, 34, -1, -1, -1, -1, -1]),\n Int32Array.from([6, 22, 38, -1, -1, -1, -1]),\n Int32Array.from([6, 24, 42, -1, -1, -1, -1]),\n Int32Array.from([6, 26, 46, -1, -1, -1, -1]),\n Int32Array.from([6, 28, 50, -1, -1, -1, -1]),\n Int32Array.from([6, 30, 54, -1, -1, -1, -1]),\n Int32Array.from([6, 32, 58, -1, -1, -1, -1]),\n Int32Array.from([6, 34, 62, -1, -1, -1, -1]),\n Int32Array.from([6, 26, 46, 66, -1, -1, -1]),\n Int32Array.from([6, 26, 48, 70, -1, -1, -1]),\n Int32Array.from([6, 26, 50, 74, -1, -1, -1]),\n Int32Array.from([6, 30, 54, 78, -1, -1, -1]),\n Int32Array.from([6, 30, 56, 82, -1, -1, -1]),\n Int32Array.from([6, 30, 58, 86, -1, -1, -1]),\n Int32Array.from([6, 34, 62, 90, -1, -1, -1]),\n Int32Array.from([6, 28, 50, 72, 94, -1, -1]),\n Int32Array.from([6, 26, 50, 74, 98, -1, -1]),\n Int32Array.from([6, 30, 54, 78, 102, -1, -1]),\n Int32Array.from([6, 28, 54, 80, 106, -1, -1]),\n Int32Array.from([6, 32, 58, 84, 110, -1, -1]),\n Int32Array.from([6, 30, 58, 86, 114, -1, -1]),\n Int32Array.from([6, 34, 62, 90, 118, -1, -1]),\n Int32Array.from([6, 26, 50, 74, 98, 122, -1]),\n Int32Array.from([6, 30, 54, 78, 102, 126, -1]),\n Int32Array.from([6, 26, 52, 78, 104, 130, -1]),\n Int32Array.from([6, 30, 56, 82, 108, 134, -1]),\n Int32Array.from([6, 34, 60, 86, 112, 138, -1]),\n Int32Array.from([6, 30, 58, 86, 114, 142, -1]),\n Int32Array.from([6, 34, 62, 90, 118, 146, -1]),\n Int32Array.from([6, 30, 54, 78, 102, 126, 150]),\n Int32Array.from([6, 24, 50, 76, 102, 128, 154]),\n Int32Array.from([6, 28, 54, 80, 106, 132, 158]),\n Int32Array.from([6, 32, 58, 84, 110, 136, 162]),\n Int32Array.from([6, 26, 54, 82, 110, 138, 166]),\n Int32Array.from([6, 30, 58, 86, 114, 142, 170]),\n ]);\n // Type info cells at the left top corner.\n MatrixUtil.TYPE_INFO_COORDINATES = Array.from([\n Int32Array.from([8, 0]),\n Int32Array.from([8, 1]),\n Int32Array.from([8, 2]),\n Int32Array.from([8, 3]),\n Int32Array.from([8, 4]),\n Int32Array.from([8, 5]),\n Int32Array.from([8, 7]),\n Int32Array.from([8, 8]),\n Int32Array.from([7, 8]),\n Int32Array.from([5, 8]),\n Int32Array.from([4, 8]),\n Int32Array.from([3, 8]),\n Int32Array.from([2, 8]),\n Int32Array.from([1, 8]),\n Int32Array.from([0, 8]),\n ]);\n // From Appendix D in JISX0510:2004 (p. 67)\n MatrixUtil.VERSION_INFO_POLY = 0x1f25; // 1 1111 0010 0101\n // From Appendix C in JISX0510:2004 (p.65).\n MatrixUtil.TYPE_INFO_POLY = 0x537;\n MatrixUtil.TYPE_INFO_MASK_PATTERN = 0x5412;\n\n /*namespace com.google.zxing.qrcode.encoder {*/\n class BlockPair {\n constructor(dataBytes, errorCorrectionBytes) {\n this.dataBytes = dataBytes;\n this.errorCorrectionBytes = errorCorrectionBytes;\n }\n getDataBytes() {\n return this.dataBytes;\n }\n getErrorCorrectionBytes() {\n return this.errorCorrectionBytes;\n }\n }\n\n /*import java.io.UnsupportedEncodingException;*/\n /*import java.util.ArrayList;*/\n /*import java.util.Collection;*/\n /*import java.util.Map;*/\n /**\n * @author satorux@google.com (Satoru Takabayashi) - creator\n * @author dswitkin@google.com (Daniel Switkin) - ported from C++\n */\n class Encoder {\n // TYPESCRIPTPORT: changed to UTF8, the default for js\n constructor() { }\n // The mask penalty calculation is complicated. See Table 21 of JISX0510:2004 (p.45) for details.\n // Basically it applies four rules and summate all penalties.\n static calculateMaskPenalty(matrix) {\n return MaskUtil.applyMaskPenaltyRule1(matrix)\n + MaskUtil.applyMaskPenaltyRule2(matrix)\n + MaskUtil.applyMaskPenaltyRule3(matrix)\n + MaskUtil.applyMaskPenaltyRule4(matrix);\n }\n /**\n * @param content text to encode\n * @param ecLevel error correction level to use\n * @return {@link QRCode} representing the encoded QR code\n * @throws WriterException if encoding can't succeed, because of for example invalid content\n * or configuration\n */\n // public static encode(content: string, ecLevel: ErrorCorrectionLevel): QRCode /*throws WriterException*/ {\n // return encode(content, ecLevel, null)\n // }\n static encode(content, ecLevel, hints = null) {\n // Determine what character encoding has been specified by the caller, if any\n let encoding = Encoder.DEFAULT_BYTE_MODE_ENCODING;\n const hasEncodingHint = hints !== null && undefined !== hints.get(EncodeHintType$1.CHARACTER_SET);\n if (hasEncodingHint) {\n encoding = hints.get(EncodeHintType$1.CHARACTER_SET).toString();\n }\n // Pick an encoding mode appropriate for the content. Note that this will not attempt to use\n // multiple modes / segments even if that were more efficient. Twould be nice.\n const mode = this.chooseMode(content, encoding);\n // This will store the header information, like mode and\n // length, as well as \"header\" segments like an ECI segment.\n const headerBits = new BitArray();\n // Append ECI segment if applicable\n if (mode === Mode$1.BYTE && (hasEncodingHint || Encoder.DEFAULT_BYTE_MODE_ENCODING !== encoding)) {\n const eci = CharacterSetECI.getCharacterSetECIByName(encoding);\n if (eci !== undefined) {\n this.appendECI(eci, headerBits);\n }\n }\n // (With ECI in place,) Write the mode marker\n this.appendModeInfo(mode, headerBits);\n // Collect data within the main segment, separately, to count its size if needed. Don't add it to\n // main payload yet.\n const dataBits = new BitArray();\n this.appendBytes(content, mode, dataBits, encoding);\n let version;\n if (hints !== null && undefined !== hints.get(EncodeHintType$1.QR_VERSION)) {\n const versionNumber = Number.parseInt(hints.get(EncodeHintType$1.QR_VERSION).toString(), 10);\n version = Version$1.getVersionForNumber(versionNumber);\n const bitsNeeded = this.calculateBitsNeeded(mode, headerBits, dataBits, version);\n if (!this.willFit(bitsNeeded, version, ecLevel)) {\n throw new WriterException('Data too big for requested version');\n }\n }\n else {\n version = this.recommendVersion(ecLevel, mode, headerBits, dataBits);\n }\n const headerAndDataBits = new BitArray();\n headerAndDataBits.appendBitArray(headerBits);\n // Find \"length\" of main segment and write it\n const numLetters = mode === Mode$1.BYTE ? dataBits.getSizeInBytes() : content.length;\n this.appendLengthInfo(numLetters, version, mode, headerAndDataBits);\n // Put data together into the overall payload\n headerAndDataBits.appendBitArray(dataBits);\n const ecBlocks = version.getECBlocksForLevel(ecLevel);\n const numDataBytes = version.getTotalCodewords() - ecBlocks.getTotalECCodewords();\n // Terminate the bits properly.\n this.terminateBits(numDataBytes, headerAndDataBits);\n // Interleave data bits with error correction code.\n const finalBits = this.interleaveWithECBytes(headerAndDataBits, version.getTotalCodewords(), numDataBytes, ecBlocks.getNumBlocks());\n const qrCode = new QRCode();\n qrCode.setECLevel(ecLevel);\n qrCode.setMode(mode);\n qrCode.setVersion(version);\n // Choose the mask pattern and set to \"qrCode\".\n const dimension = version.getDimensionForVersion();\n const matrix = new ByteMatrix(dimension, dimension);\n const maskPattern = this.chooseMaskPattern(finalBits, ecLevel, version, matrix);\n qrCode.setMaskPattern(maskPattern);\n // Build the matrix and set it to \"qrCode\".\n MatrixUtil.buildMatrix(finalBits, ecLevel, version, maskPattern, matrix);\n qrCode.setMatrix(matrix);\n return qrCode;\n }\n /**\n * Decides the smallest version of QR code that will contain all of the provided data.\n *\n * @throws WriterException if the data cannot fit in any version\n */\n static recommendVersion(ecLevel, mode, headerBits, dataBits) {\n // Hard part: need to know version to know how many bits length takes. But need to know how many\n // bits it takes to know version. First we take a guess at version by assuming version will be\n // the minimum, 1:\n const provisionalBitsNeeded = this.calculateBitsNeeded(mode, headerBits, dataBits, Version$1.getVersionForNumber(1));\n const provisionalVersion = this.chooseVersion(provisionalBitsNeeded, ecLevel);\n // Use that guess to calculate the right version. I am still not sure this works in 100% of cases.\n const bitsNeeded = this.calculateBitsNeeded(mode, headerBits, dataBits, provisionalVersion);\n return this.chooseVersion(bitsNeeded, ecLevel);\n }\n static calculateBitsNeeded(mode, headerBits, dataBits, version) {\n return headerBits.getSize() + mode.getCharacterCountBits(version) + dataBits.getSize();\n }\n /**\n * @return the code point of the table used in alphanumeric mode or\n * -1 if there is no corresponding code in the table.\n */\n static getAlphanumericCode(code /*int*/) {\n if (code < Encoder.ALPHANUMERIC_TABLE.length) {\n return Encoder.ALPHANUMERIC_TABLE[code];\n }\n return -1;\n }\n // public static chooseMode(content: string): Mode {\n // return chooseMode(content, null);\n // }\n /**\n * Choose the best mode by examining the content. Note that 'encoding' is used as a hint;\n * if it is Shift_JIS, and the input is only double-byte Kanji, then we return {@link Mode#KANJI}.\n */\n static chooseMode(content, encoding = null) {\n if (CharacterSetECI.SJIS.getName() === encoding && this.isOnlyDoubleByteKanji(content)) {\n // Choose Kanji mode if all input are double-byte characters\n return Mode$1.KANJI;\n }\n let hasNumeric = false;\n let hasAlphanumeric = false;\n for (let i = 0, length = content.length; i < length; ++i) {\n const c = content.charAt(i);\n if (Encoder.isDigit(c)) {\n hasNumeric = true;\n }\n else if (this.getAlphanumericCode(c.charCodeAt(0)) !== -1) {\n hasAlphanumeric = true;\n }\n else {\n return Mode$1.BYTE;\n }\n }\n if (hasAlphanumeric) {\n return Mode$1.ALPHANUMERIC;\n }\n if (hasNumeric) {\n return Mode$1.NUMERIC;\n }\n return Mode$1.BYTE;\n }\n static isOnlyDoubleByteKanji(content) {\n let bytes;\n try {\n bytes = StringEncoding.encode(content, CharacterSetECI.SJIS); // content.getBytes(\"Shift_JIS\"))\n }\n catch (ignored /*: UnsupportedEncodingException*/) {\n return false;\n }\n const length = bytes.length;\n if (length % 2 !== 0) {\n return false;\n }\n for (let i = 0; i < length; i += 2) {\n const byte1 = bytes[i] & 0xFF;\n if ((byte1 < 0x81 || byte1 > 0x9F) && (byte1 < 0xE0 || byte1 > 0xEB)) {\n return false;\n }\n }\n return true;\n }\n static chooseMaskPattern(bits, ecLevel, version, matrix) {\n let minPenalty = Number.MAX_SAFE_INTEGER; // Lower penalty is better.\n let bestMaskPattern = -1;\n // We try all mask patterns to choose the best one.\n for (let maskPattern = 0; maskPattern < QRCode.NUM_MASK_PATTERNS; maskPattern++) {\n MatrixUtil.buildMatrix(bits, ecLevel, version, maskPattern, matrix);\n let penalty = this.calculateMaskPenalty(matrix);\n if (penalty < minPenalty) {\n minPenalty = penalty;\n bestMaskPattern = maskPattern;\n }\n }\n return bestMaskPattern;\n }\n static chooseVersion(numInputBits /*int*/, ecLevel) {\n for (let versionNum = 1; versionNum <= 40; versionNum++) {\n const version = Version$1.getVersionForNumber(versionNum);\n if (Encoder.willFit(numInputBits, version, ecLevel)) {\n return version;\n }\n }\n throw new WriterException('Data too big');\n }\n /**\n * @return true if the number of input bits will fit in a code with the specified version and\n * error correction level.\n */\n static willFit(numInputBits /*int*/, version, ecLevel) {\n // In the following comments, we use numbers of Version 7-H.\n // numBytes = 196\n const numBytes = version.getTotalCodewords();\n // getNumECBytes = 130\n const ecBlocks = version.getECBlocksForLevel(ecLevel);\n const numEcBytes = ecBlocks.getTotalECCodewords();\n // getNumDataBytes = 196 - 130 = 66\n const numDataBytes = numBytes - numEcBytes;\n const totalInputBytes = (numInputBits + 7) / 8;\n return numDataBytes >= totalInputBytes;\n }\n /**\n * Terminate bits as described in 8.4.8 and 8.4.9 of JISX0510:2004 (p.24).\n */\n static terminateBits(numDataBytes /*int*/, bits) {\n const capacity = numDataBytes * 8;\n if (bits.getSize() > capacity) {\n throw new WriterException('data bits cannot fit in the QR Code' + bits.getSize() + ' > ' +\n capacity);\n }\n for (let i = 0; i < 4 && bits.getSize() < capacity; ++i) {\n bits.appendBit(false);\n }\n // Append termination bits. See 8.4.8 of JISX0510:2004 (p.24) for details.\n // If the last byte isn't 8-bit aligned, we'll add padding bits.\n const numBitsInLastByte = bits.getSize() & 0x07;\n if (numBitsInLastByte > 0) {\n for (let i = numBitsInLastByte; i < 8; i++) {\n bits.appendBit(false);\n }\n }\n // If we have more space, we'll fill the space with padding patterns defined in 8.4.9 (p.24).\n const numPaddingBytes = numDataBytes - bits.getSizeInBytes();\n for (let i = 0; i < numPaddingBytes; ++i) {\n bits.appendBits((i & 0x01) === 0 ? 0xEC : 0x11, 8);\n }\n if (bits.getSize() !== capacity) {\n throw new WriterException('Bits size does not equal capacity');\n }\n }\n /**\n * Get number of data bytes and number of error correction bytes for block id \"blockID\". Store\n * the result in \"numDataBytesInBlock\", and \"numECBytesInBlock\". See table 12 in 8.5.1 of\n * JISX0510:2004 (p.30)\n */\n static getNumDataBytesAndNumECBytesForBlockID(numTotalBytes /*int*/, numDataBytes /*int*/, numRSBlocks /*int*/, blockID /*int*/, numDataBytesInBlock, numECBytesInBlock) {\n if (blockID >= numRSBlocks) {\n throw new WriterException('Block ID too large');\n }\n // numRsBlocksInGroup2 = 196 % 5 = 1\n const numRsBlocksInGroup2 = numTotalBytes % numRSBlocks;\n // numRsBlocksInGroup1 = 5 - 1 = 4\n const numRsBlocksInGroup1 = numRSBlocks - numRsBlocksInGroup2;\n // numTotalBytesInGroup1 = 196 / 5 = 39\n const numTotalBytesInGroup1 = Math.floor(numTotalBytes / numRSBlocks);\n // numTotalBytesInGroup2 = 39 + 1 = 40\n const numTotalBytesInGroup2 = numTotalBytesInGroup1 + 1;\n // numDataBytesInGroup1 = 66 / 5 = 13\n const numDataBytesInGroup1 = Math.floor(numDataBytes / numRSBlocks);\n // numDataBytesInGroup2 = 13 + 1 = 14\n const numDataBytesInGroup2 = numDataBytesInGroup1 + 1;\n // numEcBytesInGroup1 = 39 - 13 = 26\n const numEcBytesInGroup1 = numTotalBytesInGroup1 - numDataBytesInGroup1;\n // numEcBytesInGroup2 = 40 - 14 = 26\n const numEcBytesInGroup2 = numTotalBytesInGroup2 - numDataBytesInGroup2;\n // Sanity checks.\n // 26 = 26\n if (numEcBytesInGroup1 !== numEcBytesInGroup2) {\n throw new WriterException('EC bytes mismatch');\n }\n // 5 = 4 + 1.\n if (numRSBlocks !== numRsBlocksInGroup1 + numRsBlocksInGroup2) {\n throw new WriterException('RS blocks mismatch');\n }\n // 196 = (13 + 26) * 4 + (14 + 26) * 1\n if (numTotalBytes !==\n ((numDataBytesInGroup1 + numEcBytesInGroup1) *\n numRsBlocksInGroup1) +\n ((numDataBytesInGroup2 + numEcBytesInGroup2) *\n numRsBlocksInGroup2)) {\n throw new WriterException('Total bytes mismatch');\n }\n if (blockID < numRsBlocksInGroup1) {\n numDataBytesInBlock[0] = numDataBytesInGroup1;\n numECBytesInBlock[0] = numEcBytesInGroup1;\n }\n else {\n numDataBytesInBlock[0] = numDataBytesInGroup2;\n numECBytesInBlock[0] = numEcBytesInGroup2;\n }\n }\n /**\n * Interleave \"bits\" with corresponding error correction bytes. On success, store the result in\n * \"result\". The interleave rule is complicated. See 8.6 of JISX0510:2004 (p.37) for details.\n */\n static interleaveWithECBytes(bits, numTotalBytes /*int*/, numDataBytes /*int*/, numRSBlocks /*int*/) {\n // \"bits\" must have \"getNumDataBytes\" bytes of data.\n if (bits.getSizeInBytes() !== numDataBytes) {\n throw new WriterException('Number of bits and data bytes does not match');\n }\n // Step 1. Divide data bytes into blocks and generate error correction bytes for them. We'll\n // store the divided data bytes blocks and error correction bytes blocks into \"blocks\".\n let dataBytesOffset = 0;\n let maxNumDataBytes = 0;\n let maxNumEcBytes = 0;\n // Since, we know the number of reedsolmon blocks, we can initialize the vector with the number.\n const blocks = new Array(); // new Array(numRSBlocks)\n for (let i = 0; i < numRSBlocks; ++i) {\n const numDataBytesInBlock = new Int32Array(1);\n const numEcBytesInBlock = new Int32Array(1);\n Encoder.getNumDataBytesAndNumECBytesForBlockID(numTotalBytes, numDataBytes, numRSBlocks, i, numDataBytesInBlock, numEcBytesInBlock);\n const size = numDataBytesInBlock[0];\n const dataBytes = new Uint8Array(size);\n bits.toBytes(8 * dataBytesOffset, dataBytes, 0, size);\n const ecBytes = Encoder.generateECBytes(dataBytes, numEcBytesInBlock[0]);\n blocks.push(new BlockPair(dataBytes, ecBytes));\n maxNumDataBytes = Math.max(maxNumDataBytes, size);\n maxNumEcBytes = Math.max(maxNumEcBytes, ecBytes.length);\n dataBytesOffset += numDataBytesInBlock[0];\n }\n if (numDataBytes !== dataBytesOffset) {\n throw new WriterException('Data bytes does not match offset');\n }\n const result = new BitArray();\n // First, place data blocks.\n for (let i = 0; i < maxNumDataBytes; ++i) {\n for (const block of blocks) {\n const dataBytes = block.getDataBytes();\n if (i < dataBytes.length) {\n result.appendBits(dataBytes[i], 8);\n }\n }\n }\n // Then, place error correction blocks.\n for (let i = 0; i < maxNumEcBytes; ++i) {\n for (const block of blocks) {\n const ecBytes = block.getErrorCorrectionBytes();\n if (i < ecBytes.length) {\n result.appendBits(ecBytes[i], 8);\n }\n }\n }\n if (numTotalBytes !== result.getSizeInBytes()) { // Should be same.\n throw new WriterException('Interleaving error: ' + numTotalBytes + ' and ' +\n result.getSizeInBytes() + ' differ.');\n }\n return result;\n }\n static generateECBytes(dataBytes, numEcBytesInBlock /*int*/) {\n const numDataBytes = dataBytes.length;\n const toEncode = new Int32Array(numDataBytes + numEcBytesInBlock); // int[numDataBytes + numEcBytesInBlock]\n for (let i = 0; i < numDataBytes; i++) {\n toEncode[i] = dataBytes[i] & 0xFF;\n }\n new ReedSolomonEncoder(GenericGF.QR_CODE_FIELD_256).encode(toEncode, numEcBytesInBlock);\n const ecBytes = new Uint8Array(numEcBytesInBlock);\n for (let i = 0; i < numEcBytesInBlock; i++) {\n ecBytes[i] = /*(byte) */ toEncode[numDataBytes + i];\n }\n return ecBytes;\n }\n /**\n * Append mode info. On success, store the result in \"bits\".\n */\n static appendModeInfo(mode, bits) {\n bits.appendBits(mode.getBits(), 4);\n }\n /**\n * Append length info. On success, store the result in \"bits\".\n */\n static appendLengthInfo(numLetters /*int*/, version, mode, bits) {\n const numBits = mode.getCharacterCountBits(version);\n if (numLetters >= (1 << numBits)) {\n throw new WriterException(numLetters + ' is bigger than ' + ((1 << numBits) - 1));\n }\n bits.appendBits(numLetters, numBits);\n }\n /**\n * Append \"bytes\" in \"mode\" mode (encoding) into \"bits\". On success, store the result in \"bits\".\n */\n static appendBytes(content, mode, bits, encoding) {\n switch (mode) {\n case Mode$1.NUMERIC:\n Encoder.appendNumericBytes(content, bits);\n break;\n case Mode$1.ALPHANUMERIC:\n Encoder.appendAlphanumericBytes(content, bits);\n break;\n case Mode$1.BYTE:\n Encoder.append8BitBytes(content, bits, encoding);\n break;\n case Mode$1.KANJI:\n Encoder.appendKanjiBytes(content, bits);\n break;\n default:\n throw new WriterException('Invalid mode: ' + mode);\n }\n }\n static getDigit(singleCharacter) {\n return singleCharacter.charCodeAt(0) - 48;\n }\n static isDigit(singleCharacter) {\n const cn = Encoder.getDigit(singleCharacter);\n return cn >= 0 && cn <= 9;\n }\n static appendNumericBytes(content, bits) {\n const length = content.length;\n let i = 0;\n while (i < length) {\n const num1 = Encoder.getDigit(content.charAt(i));\n if (i + 2 < length) {\n // Encode three numeric letters in ten bits.\n const num2 = Encoder.getDigit(content.charAt(i + 1));\n const num3 = Encoder.getDigit(content.charAt(i + 2));\n bits.appendBits(num1 * 100 + num2 * 10 + num3, 10);\n i += 3;\n }\n else if (i + 1 < length) {\n // Encode two numeric letters in seven bits.\n const num2 = Encoder.getDigit(content.charAt(i + 1));\n bits.appendBits(num1 * 10 + num2, 7);\n i += 2;\n }\n else {\n // Encode one numeric letter in four bits.\n bits.appendBits(num1, 4);\n i++;\n }\n }\n }\n static appendAlphanumericBytes(content, bits) {\n const length = content.length;\n let i = 0;\n while (i < length) {\n const code1 = Encoder.getAlphanumericCode(content.charCodeAt(i));\n if (code1 === -1) {\n throw new WriterException();\n }\n if (i + 1 < length) {\n const code2 = Encoder.getAlphanumericCode(content.charCodeAt(i + 1));\n if (code2 === -1) {\n throw new WriterException();\n }\n // Encode two alphanumeric letters in 11 bits.\n bits.appendBits(code1 * 45 + code2, 11);\n i += 2;\n }\n else {\n // Encode one alphanumeric letter in six bits.\n bits.appendBits(code1, 6);\n i++;\n }\n }\n }\n static append8BitBytes(content, bits, encoding) {\n let bytes;\n try {\n bytes = StringEncoding.encode(content, encoding);\n }\n catch (uee /*: UnsupportedEncodingException*/) {\n throw new WriterException(uee);\n }\n for (let i = 0, length = bytes.length; i !== length; i++) {\n const b = bytes[i];\n bits.appendBits(b, 8);\n }\n }\n /**\n * @throws WriterException\n */\n static appendKanjiBytes(content, bits) {\n let bytes;\n try {\n bytes = StringEncoding.encode(content, CharacterSetECI.SJIS);\n }\n catch (uee /*: UnsupportedEncodingException*/) {\n throw new WriterException(uee);\n }\n const length = bytes.length;\n for (let i = 0; i < length; i += 2) {\n const byte1 = bytes[i] & 0xFF;\n const byte2 = bytes[i + 1] & 0xFF;\n const code = ((byte1 << 8) & 0xFFFFFFFF) | byte2;\n let subtracted = -1;\n if (code >= 0x8140 && code <= 0x9ffc) {\n subtracted = code - 0x8140;\n }\n else if (code >= 0xe040 && code <= 0xebbf) {\n subtracted = code - 0xc140;\n }\n if (subtracted === -1) {\n throw new WriterException('Invalid byte sequence');\n }\n const encoded = ((subtracted >> 8) * 0xc0) + (subtracted & 0xff);\n bits.appendBits(encoded, 13);\n }\n }\n static appendECI(eci, bits) {\n bits.appendBits(Mode$1.ECI.getBits(), 4);\n // This is correct for values up to 127, which is all we need now.\n bits.appendBits(eci.getValue(), 8);\n }\n }\n // The original table is defined in the table 5 of JISX0510:2004 (p.19).\n Encoder.ALPHANUMERIC_TABLE = Int32Array.from([\n -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,\n -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,\n 36, -1, -1, -1, 37, 38, -1, -1, -1, -1, 39, 40, -1, 41, 42, 43,\n 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 44, -1, -1, -1, -1, -1,\n -1, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24,\n 25, 26, 27, 28, 29, 30, 31, 32, 33, 34, 35, -1, -1, -1, -1, -1,\n ]);\n Encoder.DEFAULT_BYTE_MODE_ENCODING = CharacterSetECI.UTF8.getName(); // \"ISO-8859-1\"\n\n /**\n * @deprecated Moving to @zxing/browser\n */\n class BrowserQRCodeSvgWriter {\n /**\n * Writes and renders a QRCode SVG element.\n *\n * @param contents\n * @param width\n * @param height\n * @param hints\n */\n write(contents, width, height, hints = null) {\n if (contents.length === 0) {\n throw new IllegalArgumentException('Found empty contents');\n }\n // if (format != BarcodeFormat.QR_CODE) {\n // throw new IllegalArgumentException(\"Can only encode QR_CODE, but got \" + format)\n // }\n if (width < 0 || height < 0) {\n throw new IllegalArgumentException('Requested dimensions are too small: ' + width + 'x' + height);\n }\n let errorCorrectionLevel = ErrorCorrectionLevel.L;\n let quietZone = BrowserQRCodeSvgWriter.QUIET_ZONE_SIZE;\n if (hints !== null) {\n if (undefined !== hints.get(EncodeHintType$1.ERROR_CORRECTION)) {\n errorCorrectionLevel = ErrorCorrectionLevel.fromString(hints.get(EncodeHintType$1.ERROR_CORRECTION).toString());\n }\n if (undefined !== hints.get(EncodeHintType$1.MARGIN)) {\n quietZone = Number.parseInt(hints.get(EncodeHintType$1.MARGIN).toString(), 10);\n }\n }\n const code = Encoder.encode(contents, errorCorrectionLevel, hints);\n return this.renderResult(code, width, height, quietZone);\n }\n /**\n * Renders the result and then appends it to the DOM.\n */\n writeToDom(containerElement, contents, width, height, hints = null) {\n if (typeof containerElement === 'string') {\n containerElement = document.querySelector(containerElement);\n }\n const svgElement = this.write(contents, width, height, hints);\n if (containerElement)\n containerElement.appendChild(svgElement);\n }\n /**\n * Note that the input matrix uses 0 == white, 1 == black.\n * The output matrix uses 0 == black, 255 == white (i.e. an 8 bit greyscale bitmap).\n */\n renderResult(code, width /*int*/, height /*int*/, quietZone /*int*/) {\n const input = code.getMatrix();\n if (input === null) {\n throw new IllegalStateException();\n }\n const inputWidth = input.getWidth();\n const inputHeight = input.getHeight();\n const qrWidth = inputWidth + (quietZone * 2);\n const qrHeight = inputHeight + (quietZone * 2);\n const outputWidth = Math.max(width, qrWidth);\n const outputHeight = Math.max(height, qrHeight);\n const multiple = Math.min(Math.floor(outputWidth / qrWidth), Math.floor(outputHeight / qrHeight));\n // Padding includes both the quiet zone and the extra white pixels to accommodate the requested\n // dimensions. For example, if input is 25x25 the QR will be 33x33 including the quiet zone.\n // If the requested size is 200x160, the multiple will be 4, for a QR of 132x132. These will\n // handle all the padding from 100x100 (the actual QR) up to 200x160.\n const leftPadding = Math.floor((outputWidth - (inputWidth * multiple)) / 2);\n const topPadding = Math.floor((outputHeight - (inputHeight * multiple)) / 2);\n const svgElement = this.createSVGElement(outputWidth, outputHeight);\n for (let inputY = 0, outputY = topPadding; inputY < inputHeight; inputY++, outputY += multiple) {\n // Write the contents of this row of the barcode\n for (let inputX = 0, outputX = leftPadding; inputX < inputWidth; inputX++, outputX += multiple) {\n if (input.get(inputX, inputY) === 1) {\n const svgRectElement = this.createSvgRectElement(outputX, outputY, multiple, multiple);\n svgElement.appendChild(svgRectElement);\n }\n }\n }\n return svgElement;\n }\n /**\n * Creates a SVG element.\n *\n * @param w SVG's width attribute\n * @param h SVG's height attribute\n */\n createSVGElement(w, h) {\n const svgElement = document.createElementNS(BrowserQRCodeSvgWriter.SVG_NS, 'svg');\n svgElement.setAttributeNS(null, 'height', w.toString());\n svgElement.setAttributeNS(null, 'width', h.toString());\n return svgElement;\n }\n /**\n * Creates a SVG rect element.\n *\n * @param x Element's x coordinate\n * @param y Element's y coordinate\n * @param w Element's width attribute\n * @param h Element's height attribute\n */\n createSvgRectElement(x, y, w, h) {\n const rect = document.createElementNS(BrowserQRCodeSvgWriter.SVG_NS, 'rect');\n rect.setAttributeNS(null, 'x', x.toString());\n rect.setAttributeNS(null, 'y', y.toString());\n rect.setAttributeNS(null, 'height', w.toString());\n rect.setAttributeNS(null, 'width', h.toString());\n rect.setAttributeNS(null, 'fill', '#000000');\n return rect;\n }\n }\n BrowserQRCodeSvgWriter.QUIET_ZONE_SIZE = 4;\n /**\n * SVG markup NameSpace\n */\n BrowserQRCodeSvgWriter.SVG_NS = 'http://www.w3.org/2000/svg';\n\n /*import java.util.Map;*/\n /**\n * This object renders a QR Code as a BitMatrix 2D array of greyscale values.\n *\n * @author dswitkin@google.com (Daniel Switkin)\n */\n class QRCodeWriter {\n /*@Override*/\n // public encode(contents: string, format: BarcodeFormat, width: number /*int*/, height: number /*int*/): BitMatrix\n // /*throws WriterException */ {\n // return encode(contents, format, width, height, null)\n // }\n /*@Override*/\n encode(contents, format, width /*int*/, height /*int*/, hints) {\n if (contents.length === 0) {\n throw new IllegalArgumentException('Found empty contents');\n }\n if (format !== BarcodeFormat$1.QR_CODE) {\n throw new IllegalArgumentException('Can only encode QR_CODE, but got ' + format);\n }\n if (width < 0 || height < 0) {\n throw new IllegalArgumentException(`Requested dimensions are too small: ${width}x${height}`);\n }\n let errorCorrectionLevel = ErrorCorrectionLevel.L;\n let quietZone = QRCodeWriter.QUIET_ZONE_SIZE;\n if (hints !== null) {\n if (undefined !== hints.get(EncodeHintType$1.ERROR_CORRECTION)) {\n errorCorrectionLevel = ErrorCorrectionLevel.fromString(hints.get(EncodeHintType$1.ERROR_CORRECTION).toString());\n }\n if (undefined !== hints.get(EncodeHintType$1.MARGIN)) {\n quietZone = Number.parseInt(hints.get(EncodeHintType$1.MARGIN).toString(), 10);\n }\n }\n const code = Encoder.encode(contents, errorCorrectionLevel, hints);\n return QRCodeWriter.renderResult(code, width, height, quietZone);\n }\n // Note that the input matrix uses 0 == white, 1 == black, while the output matrix uses\n // 0 == black, 255 == white (i.e. an 8 bit greyscale bitmap).\n static renderResult(code, width /*int*/, height /*int*/, quietZone /*int*/) {\n const input = code.getMatrix();\n if (input === null) {\n throw new IllegalStateException();\n }\n const inputWidth = input.getWidth();\n const inputHeight = input.getHeight();\n const qrWidth = inputWidth + (quietZone * 2);\n const qrHeight = inputHeight + (quietZone * 2);\n const outputWidth = Math.max(width, qrWidth);\n const outputHeight = Math.max(height, qrHeight);\n const multiple = Math.min(Math.floor(outputWidth / qrWidth), Math.floor(outputHeight / qrHeight));\n // Padding includes both the quiet zone and the extra white pixels to accommodate the requested\n // dimensions. For example, if input is 25x25 the QR will be 33x33 including the quiet zone.\n // If the requested size is 200x160, the multiple will be 4, for a QR of 132x132. These will\n // handle all the padding from 100x100 (the actual QR) up to 200x160.\n const leftPadding = Math.floor((outputWidth - (inputWidth * multiple)) / 2);\n const topPadding = Math.floor((outputHeight - (inputHeight * multiple)) / 2);\n const output = new BitMatrix(outputWidth, outputHeight);\n for (let inputY = 0, outputY = topPadding; inputY < inputHeight; inputY++, outputY += multiple) {\n // Write the contents of this row of the barcode\n for (let inputX = 0, outputX = leftPadding; inputX < inputWidth; inputX++, outputX += multiple) {\n if (input.get(inputX, inputY) === 1) {\n output.setRegion(outputX, outputY, multiple, multiple);\n }\n }\n }\n return output;\n }\n }\n QRCodeWriter.QUIET_ZONE_SIZE = 4;\n\n /*import java.util.Map;*/\n /**\n * This is a factory class which finds the appropriate Writer subclass for the BarcodeFormat\n * requested and encodes the barcode with the supplied contents.\n *\n * @author dswitkin@google.com (Daniel Switkin)\n */\n class MultiFormatWriter {\n /*@Override*/\n // public encode(contents: string,\n // format: BarcodeFormat,\n // width: number /*int*/,\n // height: number /*int*/): BitMatrix /*throws WriterException */ {\n // return encode(contents, format, width, height, null)\n // }\n /*@Override*/\n encode(contents, format, width /*int*/, height /*int*/, hints) {\n let writer;\n switch (format) {\n // case BarcodeFormat.EAN_8:\n // writer = new EAN8Writer()\n // break\n // case BarcodeFormat.UPC_E:\n // writer = new UPCEWriter()\n // break\n // case BarcodeFormat.EAN_13:\n // writer = new EAN13Writer()\n // break\n // case BarcodeFormat.UPC_A:\n // writer = new UPCAWriter()\n // break\n case BarcodeFormat$1.QR_CODE:\n writer = new QRCodeWriter();\n break;\n // case BarcodeFormat.CODE_39:\n // writer = new Code39Writer()\n // break\n // case BarcodeFormat.CODE_93:\n // writer = new Code93Writer()\n // break\n // case BarcodeFormat.CODE_128:\n // writer = new Code128Writer()\n // break\n // case BarcodeFormat.ITF:\n // writer = new ITFWriter()\n // break\n // case BarcodeFormat.PDF_417:\n // writer = new PDF417Writer()\n // break\n // case BarcodeFormat.CODABAR:\n // writer = new CodaBarWriter()\n // break\n // case BarcodeFormat.DATA_MATRIX:\n // writer = new DataMatrixWriter()\n // break\n // case BarcodeFormat.AZTEC:\n // writer = new AztecWriter()\n // break\n default:\n throw new IllegalArgumentException('No encoder available for format ' + format);\n }\n return writer.encode(contents, format, width, height, hints);\n }\n }\n\n /*\n * Copyright 2009 ZXing authors\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n /**\n * This object extends LuminanceSource around an array of YUV data returned from the camera driver,\n * with the option to crop to a rectangle within the full data. This can be used to exclude\n * superfluous pixels around the perimeter and speed up decoding.\n *\n * It works for any pixel format where the Y channel is planar and appears first, including\n * YCbCr_420_SP and YCbCr_422_SP.\n *\n * @author dswitkin@google.com (Daniel Switkin)\n */\n class PlanarYUVLuminanceSource extends LuminanceSource {\n constructor(yuvData, dataWidth /*int*/, dataHeight /*int*/, left /*int*/, top /*int*/, width /*int*/, height /*int*/, reverseHorizontal) {\n super(width, height);\n this.yuvData = yuvData;\n this.dataWidth = dataWidth;\n this.dataHeight = dataHeight;\n this.left = left;\n this.top = top;\n if (left + width > dataWidth || top + height > dataHeight) {\n throw new IllegalArgumentException('Crop rectangle does not fit within image data.');\n }\n if (reverseHorizontal) {\n this.reverseHorizontal(width, height);\n }\n }\n /*@Override*/\n getRow(y /*int*/, row) {\n if (y < 0 || y >= this.getHeight()) {\n throw new IllegalArgumentException('Requested row is outside the image: ' + y);\n }\n const width = this.getWidth();\n if (row === null || row === undefined || row.length < width) {\n row = new Uint8ClampedArray(width);\n }\n const offset = (y + this.top) * this.dataWidth + this.left;\n System.arraycopy(this.yuvData, offset, row, 0, width);\n return row;\n }\n /*@Override*/\n getMatrix() {\n const width = this.getWidth();\n const height = this.getHeight();\n // If the caller asks for the entire underlying image, save the copy and give them the\n // original data. The docs specifically warn that result.length must be ignored.\n if (width === this.dataWidth && height === this.dataHeight) {\n return this.yuvData;\n }\n const area = width * height;\n const matrix = new Uint8ClampedArray(area);\n let inputOffset = this.top * this.dataWidth + this.left;\n // If the width matches the full width of the underlying data, perform a single copy.\n if (width === this.dataWidth) {\n System.arraycopy(this.yuvData, inputOffset, matrix, 0, area);\n return matrix;\n }\n // Otherwise copy one cropped row at a time.\n for (let y = 0; y < height; y++) {\n const outputOffset = y * width;\n System.arraycopy(this.yuvData, inputOffset, matrix, outputOffset, width);\n inputOffset += this.dataWidth;\n }\n return matrix;\n }\n /*@Override*/\n isCropSupported() {\n return true;\n }\n /*@Override*/\n crop(left /*int*/, top /*int*/, width /*int*/, height /*int*/) {\n return new PlanarYUVLuminanceSource(this.yuvData, this.dataWidth, this.dataHeight, this.left + left, this.top + top, width, height, false);\n }\n renderThumbnail() {\n const width = this.getWidth() / PlanarYUVLuminanceSource.THUMBNAIL_SCALE_FACTOR;\n const height = this.getHeight() / PlanarYUVLuminanceSource.THUMBNAIL_SCALE_FACTOR;\n const pixels = new Int32Array(width * height);\n const yuv = this.yuvData;\n let inputOffset = this.top * this.dataWidth + this.left;\n for (let y = 0; y < height; y++) {\n const outputOffset = y * width;\n for (let x = 0; x < width; x++) {\n const grey = yuv[inputOffset + x * PlanarYUVLuminanceSource.THUMBNAIL_SCALE_FACTOR] & 0xff;\n pixels[outputOffset + x] = 0xFF000000 | (grey * 0x00010101);\n }\n inputOffset += this.dataWidth * PlanarYUVLuminanceSource.THUMBNAIL_SCALE_FACTOR;\n }\n return pixels;\n }\n /**\n * @return width of image from {@link #renderThumbnail()}\n */\n getThumbnailWidth() {\n return this.getWidth() / PlanarYUVLuminanceSource.THUMBNAIL_SCALE_FACTOR;\n }\n /**\n * @return height of image from {@link #renderThumbnail()}\n */\n getThumbnailHeight() {\n return this.getHeight() / PlanarYUVLuminanceSource.THUMBNAIL_SCALE_FACTOR;\n }\n reverseHorizontal(width /*int*/, height /*int*/) {\n const yuvData = this.yuvData;\n for (let y = 0, rowStart = this.top * this.dataWidth + this.left; y < height; y++, rowStart += this.dataWidth) {\n const middle = rowStart + width / 2;\n for (let x1 = rowStart, x2 = rowStart + width - 1; x1 < middle; x1++, x2--) {\n const temp = yuvData[x1];\n yuvData[x1] = yuvData[x2];\n yuvData[x2] = temp;\n }\n }\n }\n invert() {\n return new InvertedLuminanceSource(this);\n }\n }\n PlanarYUVLuminanceSource.THUMBNAIL_SCALE_FACTOR = 2;\n\n /*\n * Copyright 2009 ZXing authors\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n /**\n * This class is used to help decode images from files which arrive as RGB data from\n * an ARGB pixel array. It does not support rotation.\n *\n * @author dswitkin@google.com (Daniel Switkin)\n * @author Betaminos\n */\n class RGBLuminanceSource extends LuminanceSource {\n constructor(luminances, width /*int*/, height /*int*/, dataWidth /*int*/, dataHeight /*int*/, left /*int*/, top /*int*/) {\n super(width, height);\n this.dataWidth = dataWidth;\n this.dataHeight = dataHeight;\n this.left = left;\n this.top = top;\n if (luminances.BYTES_PER_ELEMENT === 4) { // Int32Array\n const size = width * height;\n const luminancesUint8Array = new Uint8ClampedArray(size);\n for (let offset = 0; offset < size; offset++) {\n const pixel = luminances[offset];\n const r = (pixel >> 16) & 0xff; // red\n const g2 = (pixel >> 7) & 0x1fe; // 2 * green\n const b = pixel & 0xff; // blue\n // Calculate green-favouring average cheaply\n luminancesUint8Array[offset] = /*(byte) */ ((r + g2 + b) / 4) & 0xFF;\n }\n this.luminances = luminancesUint8Array;\n }\n else {\n this.luminances = luminances;\n }\n if (undefined === dataWidth) {\n this.dataWidth = width;\n }\n if (undefined === dataHeight) {\n this.dataHeight = height;\n }\n if (undefined === left) {\n this.left = 0;\n }\n if (undefined === top) {\n this.top = 0;\n }\n if (this.left + width > this.dataWidth || this.top + height > this.dataHeight) {\n throw new IllegalArgumentException('Crop rectangle does not fit within image data.');\n }\n }\n /*@Override*/\n getRow(y /*int*/, row) {\n if (y < 0 || y >= this.getHeight()) {\n throw new IllegalArgumentException('Requested row is outside the image: ' + y);\n }\n const width = this.getWidth();\n if (row === null || row === undefined || row.length < width) {\n row = new Uint8ClampedArray(width);\n }\n const offset = (y + this.top) * this.dataWidth + this.left;\n System.arraycopy(this.luminances, offset, row, 0, width);\n return row;\n }\n /*@Override*/\n getMatrix() {\n const width = this.getWidth();\n const height = this.getHeight();\n // If the caller asks for the entire underlying image, save the copy and give them the\n // original data. The docs specifically warn that result.length must be ignored.\n if (width === this.dataWidth && height === this.dataHeight) {\n return this.luminances;\n }\n const area = width * height;\n const matrix = new Uint8ClampedArray(area);\n let inputOffset = this.top * this.dataWidth + this.left;\n // If the width matches the full width of the underlying data, perform a single copy.\n if (width === this.dataWidth) {\n System.arraycopy(this.luminances, inputOffset, matrix, 0, area);\n return matrix;\n }\n // Otherwise copy one cropped row at a time.\n for (let y = 0; y < height; y++) {\n const outputOffset = y * width;\n System.arraycopy(this.luminances, inputOffset, matrix, outputOffset, width);\n inputOffset += this.dataWidth;\n }\n return matrix;\n }\n /*@Override*/\n isCropSupported() {\n return true;\n }\n /*@Override*/\n crop(left /*int*/, top /*int*/, width /*int*/, height /*int*/) {\n return new RGBLuminanceSource(this.luminances, width, height, this.dataWidth, this.dataHeight, this.left + left, this.top + top);\n }\n invert() {\n return new InvertedLuminanceSource(this);\n }\n }\n\n /**\n * Just to make a shortcut between Java code and TS code.\n */\n class Charset extends CharacterSetECI {\n static forName(name) {\n return this.getCharacterSetECIByName(name);\n }\n }\n\n /**\n * Just to make a shortcut between Java code and TS code.\n */\n class StandardCharsets {\n }\n StandardCharsets.ISO_8859_1 = CharacterSetECI.ISO8859_1;\n\n /*\n * Copyright 2013 ZXing authors\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n /**\n * Aztec 2D code representation\n *\n * @author Rustam Abdullaev\n */\n /*public final*/ class AztecCode {\n /**\n * @return {@code true} if compact instead of full mode\n */\n isCompact() {\n return this.compact;\n }\n setCompact(compact) {\n this.compact = compact;\n }\n /**\n * @return size in pixels (width and height)\n */\n getSize() {\n return this.size;\n }\n setSize(size) {\n this.size = size;\n }\n /**\n * @return number of levels\n */\n getLayers() {\n return this.layers;\n }\n setLayers(layers) {\n this.layers = layers;\n }\n /**\n * @return number of data codewords\n */\n getCodeWords() {\n return this.codeWords;\n }\n setCodeWords(codeWords) {\n this.codeWords = codeWords;\n }\n /**\n * @return the symbol image\n */\n getMatrix() {\n return this.matrix;\n }\n setMatrix(matrix) {\n this.matrix = matrix;\n }\n }\n\n class Collections {\n /**\n * The singletonList(T) method is used to return an immutable list containing only the specified object.\n */\n static singletonList(item) {\n return [item];\n }\n /**\n * The min(Collection extends T>, Comparator super T>) method is used to return the minimum element of the given collection, according to the order induced by the specified comparator.\n */\n static min(collection, comparator) {\n return collection.sort(comparator)[0];\n }\n }\n\n /*\n * Copyright 2013 ZXing authors\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n class Token {\n constructor(previous) {\n this.previous = previous;\n }\n getPrevious() {\n return this.previous;\n }\n }\n\n /*\n * Copyright 2013 ZXing authors\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n /*final*/ class SimpleToken extends Token {\n constructor(previous, value, bitCount) {\n super(previous);\n this.value = value;\n this.bitCount = bitCount;\n }\n /**\n * @Override\n */\n appendTo(bitArray, text) {\n bitArray.appendBits(this.value, this.bitCount);\n }\n add(value, bitCount) {\n return new SimpleToken(this, value, bitCount);\n }\n addBinaryShift(start, byteCount) {\n // no-op can't binary shift a simple token\n console.warn('addBinaryShift on SimpleToken, this simply returns a copy of this token');\n return new SimpleToken(this, start, byteCount);\n }\n /**\n * @Override\n */\n toString() {\n let value = this.value & ((1 << this.bitCount) - 1);\n value |= 1 << this.bitCount;\n return '<' + Integer.toBinaryString(value | (1 << this.bitCount)).substring(1) + '>';\n }\n }\n\n /*\n * Copyright 2013 ZXing authors\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n /*final*/ class BinaryShiftToken extends SimpleToken {\n constructor(previous, binaryShiftStart, binaryShiftByteCount) {\n super(previous, 0, 0);\n this.binaryShiftStart = binaryShiftStart;\n this.binaryShiftByteCount = binaryShiftByteCount;\n }\n /**\n * @Override\n */\n appendTo(bitArray, text) {\n for (let i = 0; i < this.binaryShiftByteCount; i++) {\n if (i === 0 || (i === 31 && this.binaryShiftByteCount <= 62)) {\n // We need a header before the first character, and before\n // character 31 when the total byte code is <= 62\n bitArray.appendBits(31, 5); // BINARY_SHIFT\n if (this.binaryShiftByteCount > 62) {\n bitArray.appendBits(this.binaryShiftByteCount - 31, 16);\n }\n else if (i === 0) {\n // 1 <= binaryShiftByteCode <= 62\n bitArray.appendBits(Math.min(this.binaryShiftByteCount, 31), 5);\n }\n else {\n // 32 <= binaryShiftCount <= 62 and i == 31\n bitArray.appendBits(this.binaryShiftByteCount - 31, 5);\n }\n }\n bitArray.appendBits(text[this.binaryShiftStart + i], 8);\n }\n }\n addBinaryShift(start, byteCount) {\n // int bitCount = (byteCount * 8) + (byteCount <= 31 ? 10 : byteCount <= 62 ? 20 : 21);\n return new BinaryShiftToken(this, start, byteCount);\n }\n /**\n * @Override\n */\n toString() {\n return '<' + this.binaryShiftStart + '::' + (this.binaryShiftStart + this.binaryShiftByteCount - 1) + '>';\n }\n }\n\n function addBinaryShift(token, start, byteCount) {\n // int bitCount = (byteCount * 8) + (byteCount <= 31 ? 10 : byteCount <= 62 ? 20 : 21);\n return new BinaryShiftToken(token, start, byteCount);\n }\n function add(token, value, bitCount) {\n return new SimpleToken(token, value, bitCount);\n }\n\n const /*final*/ MODE_NAMES = [\n 'UPPER',\n 'LOWER',\n 'DIGIT',\n 'MIXED',\n 'PUNCT'\n ];\n const /*final*/ MODE_UPPER = 0; // 5 bits\n const /*final*/ MODE_LOWER = 1; // 5 bits\n const /*final*/ MODE_DIGIT = 2; // 4 bits\n const /*final*/ MODE_MIXED = 3; // 5 bits\n const /*final*/ MODE_PUNCT = 4; // 5 bits\n const EMPTY_TOKEN = new SimpleToken(null, 0, 0);\n\n // The Latch Table shows, for each pair of Modes, the optimal method for\n // getting from one mode to another. In the worst possible case, this can\n // be up to 14 bits. In the best possible case, we are already there!\n // The high half-word of each entry gives the number of bits.\n // The low half-word of each entry are the actual bits necessary to change\n const LATCH_TABLE = [\n Int32Array.from([\n 0,\n (5 << 16) + 28,\n (5 << 16) + 30,\n (5 << 16) + 29,\n (10 << 16) + (29 << 5) + 30 // UPPER -> MIXED -> PUNCT\n ]),\n Int32Array.from([\n (9 << 16) + (30 << 4) + 14,\n 0,\n (5 << 16) + 30,\n (5 << 16) + 29,\n (10 << 16) + (29 << 5) + 30 // LOWER -> MIXED -> PUNCT\n ]),\n Int32Array.from([\n (4 << 16) + 14,\n (9 << 16) + (14 << 5) + 28,\n 0,\n (9 << 16) + (14 << 5) + 29,\n (14 << 16) + (14 << 10) + (29 << 5) + 30\n // DIGIT -> UPPER -> MIXED -> PUNCT\n ]),\n Int32Array.from([\n (5 << 16) + 29,\n (5 << 16) + 28,\n (10 << 16) + (29 << 5) + 30,\n 0,\n (5 << 16) + 30 // MIXED -> PUNCT\n ]),\n Int32Array.from([\n (5 << 16) + 31,\n (10 << 16) + (31 << 5) + 28,\n (10 << 16) + (31 << 5) + 30,\n (10 << 16) + (31 << 5) + 29,\n 0\n ])\n ];\n\n function static_SHIFT_TABLE(SHIFT_TABLE) {\n for (let table /*Int32Array*/ of SHIFT_TABLE) {\n Arrays.fill(table, -1);\n }\n SHIFT_TABLE[MODE_UPPER][MODE_PUNCT] = 0;\n SHIFT_TABLE[MODE_LOWER][MODE_PUNCT] = 0;\n SHIFT_TABLE[MODE_LOWER][MODE_UPPER] = 28;\n SHIFT_TABLE[MODE_MIXED][MODE_PUNCT] = 0;\n SHIFT_TABLE[MODE_DIGIT][MODE_PUNCT] = 0;\n SHIFT_TABLE[MODE_DIGIT][MODE_UPPER] = 15;\n return SHIFT_TABLE;\n }\n const /*final*/ SHIFT_TABLE = static_SHIFT_TABLE(Arrays.createInt32Array(6, 6)); // mode shift codes, per table\n\n /*\n * Copyright 2013 ZXing authors\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n /**\n * State represents all information about a sequence necessary to generate the current output.\n * Note that a state is immutable.\n */\n /*final*/ class State {\n constructor(token, mode, binaryBytes, bitCount) {\n this.token = token;\n this.mode = mode;\n this.binaryShiftByteCount = binaryBytes;\n this.bitCount = bitCount;\n // Make sure we match the token\n // int binaryShiftBitCount = (binaryShiftByteCount * 8) +\n // (binaryShiftByteCount === 0 ? 0 :\n // binaryShiftByteCount <= 31 ? 10 :\n // binaryShiftByteCount <= 62 ? 20 : 21);\n // assert this.bitCount === token.getTotalBitCount() + binaryShiftBitCount;\n }\n getMode() {\n return this.mode;\n }\n getToken() {\n return this.token;\n }\n getBinaryShiftByteCount() {\n return this.binaryShiftByteCount;\n }\n getBitCount() {\n return this.bitCount;\n }\n // Create a new state representing this state with a latch to a (not\n // necessary different) mode, and then a code.\n latchAndAppend(mode, value) {\n // assert binaryShiftByteCount === 0;\n let bitCount = this.bitCount;\n let token = this.token;\n if (mode !== this.mode) {\n let latch = LATCH_TABLE[this.mode][mode];\n token = add(token, latch & 0xffff, latch >> 16);\n bitCount += latch >> 16;\n }\n let latchModeBitCount = mode === MODE_DIGIT ? 4 : 5;\n token = add(token, value, latchModeBitCount);\n return new State(token, mode, 0, bitCount + latchModeBitCount);\n }\n // Create a new state representing this state, with a temporary shift\n // to a different mode to output a single value.\n shiftAndAppend(mode, value) {\n // assert binaryShiftByteCount === 0 && this.mode !== mode;\n let token = this.token;\n let thisModeBitCount = this.mode === MODE_DIGIT ? 4 : 5;\n // Shifts exist only to UPPER and PUNCT, both with tokens size 5.\n token = add(token, SHIFT_TABLE[this.mode][mode], thisModeBitCount);\n token = add(token, value, 5);\n return new State(token, this.mode, 0, this.bitCount + thisModeBitCount + 5);\n }\n // Create a new state representing this state, but an additional character\n // output in Binary Shift mode.\n addBinaryShiftChar(index) {\n let token = this.token;\n let mode = this.mode;\n let bitCount = this.bitCount;\n if (this.mode === MODE_PUNCT || this.mode === MODE_DIGIT) {\n // assert binaryShiftByteCount === 0;\n let latch = LATCH_TABLE[mode][MODE_UPPER];\n token = add(token, latch & 0xffff, latch >> 16);\n bitCount += latch >> 16;\n mode = MODE_UPPER;\n }\n let deltaBitCount = this.binaryShiftByteCount === 0 || this.binaryShiftByteCount === 31\n ? 18\n : this.binaryShiftByteCount === 62\n ? 9\n : 8;\n let result = new State(token, mode, this.binaryShiftByteCount + 1, bitCount + deltaBitCount);\n if (result.binaryShiftByteCount === 2047 + 31) {\n // The string is as long as it's allowed to be. We should end it.\n result = result.endBinaryShift(index + 1);\n }\n return result;\n }\n // Create the state identical to this one, but we are no longer in\n // Binary Shift mode.\n endBinaryShift(index) {\n if (this.binaryShiftByteCount === 0) {\n return this;\n }\n let token = this.token;\n token = addBinaryShift(token, index - this.binaryShiftByteCount, this.binaryShiftByteCount);\n // assert token.getTotalBitCount() === this.bitCount;\n return new State(token, this.mode, 0, this.bitCount);\n }\n // Returns true if \"this\" state is better (equal: or) to be in than \"that\"\n // state under all possible circumstances.\n isBetterThanOrEqualTo(other) {\n let newModeBitCount = this.bitCount + (LATCH_TABLE[this.mode][other.mode] >> 16);\n if (this.binaryShiftByteCount < other.binaryShiftByteCount) {\n // add additional B/S encoding cost of other, if any\n newModeBitCount +=\n State.calculateBinaryShiftCost(other) -\n State.calculateBinaryShiftCost(this);\n }\n else if (this.binaryShiftByteCount > other.binaryShiftByteCount &&\n other.binaryShiftByteCount > 0) {\n // maximum possible additional cost (it: h)\n newModeBitCount += 10;\n }\n return newModeBitCount <= other.bitCount;\n }\n toBitArray(text) {\n // Reverse the tokens, so that they are in the order that they should\n // be output\n let symbols = [];\n for (let token = this.endBinaryShift(text.length).token; token !== null; token = token.getPrevious()) {\n symbols.unshift(token);\n }\n let bitArray = new BitArray();\n // Add each token to the result.\n for (const symbol of symbols) {\n symbol.appendTo(bitArray, text);\n }\n // assert bitArray.getSize() === this.bitCount;\n return bitArray;\n }\n /**\n * @Override\n */\n toString() {\n return StringUtils.format('%s bits=%d bytes=%d', MODE_NAMES[this.mode], this.bitCount, this.binaryShiftByteCount);\n }\n static calculateBinaryShiftCost(state) {\n if (state.binaryShiftByteCount > 62) {\n return 21; // B/S with extended length\n }\n if (state.binaryShiftByteCount > 31) {\n return 20; // two B/S\n }\n if (state.binaryShiftByteCount > 0) {\n return 10; // one B/S\n }\n return 0;\n }\n }\n State.INITIAL_STATE = new State(EMPTY_TOKEN, MODE_UPPER, 0, 0);\n\n function static_CHAR_MAP(CHAR_MAP) {\n const spaceCharCode = StringUtils.getCharCode(' ');\n const pointCharCode = StringUtils.getCharCode('.');\n const commaCharCode = StringUtils.getCharCode(',');\n CHAR_MAP[MODE_UPPER][spaceCharCode] = 1;\n const zUpperCharCode = StringUtils.getCharCode('Z');\n const aUpperCharCode = StringUtils.getCharCode('A');\n for (let c = aUpperCharCode; c <= zUpperCharCode; c++) {\n CHAR_MAP[MODE_UPPER][c] = c - aUpperCharCode + 2;\n }\n CHAR_MAP[MODE_LOWER][spaceCharCode] = 1;\n const zLowerCharCode = StringUtils.getCharCode('z');\n const aLowerCharCode = StringUtils.getCharCode('a');\n for (let c = aLowerCharCode; c <= zLowerCharCode; c++) {\n CHAR_MAP[MODE_LOWER][c] = c - aLowerCharCode + 2;\n }\n CHAR_MAP[MODE_DIGIT][spaceCharCode] = 1;\n const nineCharCode = StringUtils.getCharCode('9');\n const zeroCharCode = StringUtils.getCharCode('0');\n for (let c = zeroCharCode; c <= nineCharCode; c++) {\n CHAR_MAP[MODE_DIGIT][c] = c - zeroCharCode + 2;\n }\n CHAR_MAP[MODE_DIGIT][commaCharCode] = 12;\n CHAR_MAP[MODE_DIGIT][pointCharCode] = 13;\n const mixedTable = [\n '\\x00',\n ' ',\n '\\x01',\n '\\x02',\n '\\x03',\n '\\x04',\n '\\x05',\n '\\x06',\n '\\x07',\n '\\b',\n '\\t',\n '\\n',\n '\\x0b',\n '\\f',\n '\\r',\n '\\x1b',\n '\\x1c',\n '\\x1d',\n '\\x1e',\n '\\x1f',\n '@',\n '\\\\',\n '^',\n '_',\n '`',\n '|',\n '~',\n '\\x7f'\n ];\n for (let i = 0; i < mixedTable.length; i++) {\n CHAR_MAP[MODE_MIXED][StringUtils.getCharCode(mixedTable[i])] = i;\n }\n const punctTable = [\n '\\x00',\n '\\r',\n '\\x00',\n '\\x00',\n '\\x00',\n '\\x00',\n '!',\n '\\'',\n '#',\n '$',\n '%',\n '&',\n '\\'',\n '(',\n ')',\n '*',\n '+',\n ',',\n '-',\n '.',\n '/',\n ':',\n ';',\n '<',\n '=',\n '>',\n '?',\n '[',\n ']',\n '{',\n '}'\n ];\n for (let i = 0; i < punctTable.length; i++) {\n if (StringUtils.getCharCode(punctTable[i]) > 0) {\n CHAR_MAP[MODE_PUNCT][StringUtils.getCharCode(punctTable[i])] = i;\n }\n }\n return CHAR_MAP;\n }\n const CHAR_MAP = static_CHAR_MAP(Arrays.createInt32Array(5, 256));\n\n /*\n * Copyright 2013 ZXing authors\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n /**\n * This produces nearly optimal encodings of text into the first-level of\n * encoding used by Aztec code.\n *\n * It uses a dynamic algorithm. For each prefix of the string, it determines\n * a set of encodings that could lead to this prefix. We repeatedly add a\n * character and generate a new set of optimal encodings until we have read\n * through the entire input.\n *\n * @author Frank Yellin\n * @author Rustam Abdullaev\n */\n /*public final*/ class HighLevelEncoder {\n constructor(text) {\n this.text = text;\n }\n /**\n * @return text represented by this encoder encoded as a {@link BitArray}\n */\n encode() {\n const spaceCharCode = StringUtils.getCharCode(' ');\n const lineBreakCharCode = StringUtils.getCharCode('\\n');\n let states = Collections.singletonList(State.INITIAL_STATE);\n for (let index = 0; index < this.text.length; index++) {\n let pairCode;\n let nextChar = index + 1 < this.text.length ? this.text[index + 1] : 0;\n switch (this.text[index]) {\n case StringUtils.getCharCode('\\r'):\n pairCode = nextChar === lineBreakCharCode ? 2 : 0;\n break;\n case StringUtils.getCharCode('.'):\n pairCode = nextChar === spaceCharCode ? 3 : 0;\n break;\n case StringUtils.getCharCode(','):\n pairCode = nextChar === spaceCharCode ? 4 : 0;\n break;\n case StringUtils.getCharCode(':'):\n pairCode = nextChar === spaceCharCode ? 5 : 0;\n break;\n default:\n pairCode = 0;\n }\n if (pairCode > 0) {\n // We have one of the four special PUNCT pairs. Treat them specially.\n // Get a new set of states for the two new characters.\n states = HighLevelEncoder.updateStateListForPair(states, index, pairCode);\n index++;\n }\n else {\n // Get a new set of states for the new character.\n states = this.updateStateListForChar(states, index);\n }\n }\n // We are left with a set of states. Find the shortest one.\n const minState = Collections.min(states, (a, b) => {\n return a.getBitCount() - b.getBitCount();\n });\n // Convert it to a bit array, and return.\n return minState.toBitArray(this.text);\n }\n // We update a set of states for a new character by updating each state\n // for the new character, merging the results, and then removing the\n // non-optimal states.\n updateStateListForChar(states, index) {\n const result = [];\n for (let state /*State*/ of states) {\n this.updateStateForChar(state, index, result);\n }\n return HighLevelEncoder.simplifyStates(result);\n }\n // Return a set of states that represent the possible ways of updating this\n // state for the next character. The resulting set of states are added to\n // the \"result\" list.\n updateStateForChar(state, index, result) {\n let ch = (this.text[index] & 0xff);\n let charInCurrentTable = CHAR_MAP[state.getMode()][ch] > 0;\n let stateNoBinary = null;\n for (let mode /*int*/ = 0; mode <= MODE_PUNCT; mode++) {\n let charInMode = CHAR_MAP[mode][ch];\n if (charInMode > 0) {\n if (stateNoBinary == null) {\n // Only create stateNoBinary the first time it's required.\n stateNoBinary = state.endBinaryShift(index);\n }\n // Try generating the character by latching to its mode\n if (!charInCurrentTable ||\n mode === state.getMode() ||\n mode === MODE_DIGIT) {\n // If the character is in the current table, we don't want to latch to\n // any other mode except possibly digit (which uses only 4 bits). Any\n // other latch would be equally successful *after* this character, and\n // so wouldn't save any bits.\n const latchState = stateNoBinary.latchAndAppend(mode, charInMode);\n result.push(latchState);\n }\n // Try generating the character by switching to its mode.\n if (!charInCurrentTable &&\n SHIFT_TABLE[state.getMode()][mode] >= 0) {\n // It never makes sense to temporarily shift to another mode if the\n // character exists in the current mode. That can never save bits.\n const shiftState = stateNoBinary.shiftAndAppend(mode, charInMode);\n result.push(shiftState);\n }\n }\n }\n if (state.getBinaryShiftByteCount() > 0 ||\n CHAR_MAP[state.getMode()][ch] === 0) {\n // It's never worthwhile to go into binary shift mode if you're not already\n // in binary shift mode, and the character exists in your current mode.\n // That can never save bits over just outputting the char in the current mode.\n let binaryState = state.addBinaryShiftChar(index);\n result.push(binaryState);\n }\n }\n static updateStateListForPair(states, index, pairCode) {\n const result = [];\n for (let state /*State*/ of states) {\n this.updateStateForPair(state, index, pairCode, result);\n }\n return this.simplifyStates(result);\n }\n static updateStateForPair(state, index, pairCode, result) {\n let stateNoBinary = state.endBinaryShift(index);\n // Possibility 1. Latch to C.MODE_PUNCT, and then append this code\n result.push(stateNoBinary.latchAndAppend(MODE_PUNCT, pairCode));\n if (state.getMode() !== MODE_PUNCT) {\n // Possibility 2. Shift to C.MODE_PUNCT, and then append this code.\n // Every state except C.MODE_PUNCT (handled above) can shift\n result.push(stateNoBinary.shiftAndAppend(MODE_PUNCT, pairCode));\n }\n if (pairCode === 3 || pairCode === 4) {\n // both characters are in DIGITS. Sometimes better to just add two digits\n let digitState = stateNoBinary\n .latchAndAppend(MODE_DIGIT, 16 - pairCode) // period or comma in DIGIT\n .latchAndAppend(MODE_DIGIT, 1); // space in DIGIT\n result.push(digitState);\n }\n if (state.getBinaryShiftByteCount() > 0) {\n // It only makes sense to do the characters as binary if we're already\n // in binary mode.\n let binaryState = state\n .addBinaryShiftChar(index)\n .addBinaryShiftChar(index + 1);\n result.push(binaryState);\n }\n }\n static simplifyStates(states) {\n let result = [];\n for (const newState of states) {\n let add = true;\n for (const oldState of result) {\n if (oldState.isBetterThanOrEqualTo(newState)) {\n add = false;\n break;\n }\n if (newState.isBetterThanOrEqualTo(oldState)) {\n // iterator.remove();\n result = result.filter(x => x !== oldState); // remove old state\n }\n }\n if (add) {\n result.push(newState);\n }\n }\n return result;\n }\n }\n\n /*\n * Copyright 2013 ZXing authors\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n // package com.google.zxing.aztec.encoder;\n // import com.google.zxing.common.BitArray;\n // import com.google.zxing.common.BitMatrix;\n // import com.google.zxing.common.reedsolomon.GenericGF;\n // import com.google.zxing.common.reedsolomon.ReedSolomonEncoder;\n /**\n * Generates Aztec 2D barcodes.\n *\n * @author Rustam Abdullaev\n */\n /*public final*/ class Encoder$1 {\n constructor() {\n }\n /**\n * Encodes the given binary content as an Aztec symbol\n *\n * @param data input data string\n * @return Aztec symbol matrix with metadata\n */\n static encodeBytes(data) {\n return Encoder$1.encode(data, Encoder$1.DEFAULT_EC_PERCENT, Encoder$1.DEFAULT_AZTEC_LAYERS);\n }\n /**\n * Encodes the given binary content as an Aztec symbol\n *\n * @param data input data string\n * @param minECCPercent minimal percentage of error check words (According to ISO/IEC 24778:2008,\n * a minimum of 23% + 3 words is recommended)\n * @param userSpecifiedLayers if non-zero, a user-specified value for the number of layers\n * @return Aztec symbol matrix with metadata\n */\n static encode(data, minECCPercent, userSpecifiedLayers) {\n // High-level encode\n let bits = new HighLevelEncoder(data).encode();\n // stuff bits and choose symbol size\n let eccBits = Integer.truncDivision((bits.getSize() * minECCPercent), 100) + 11;\n let totalSizeBits = bits.getSize() + eccBits;\n let compact;\n let layers;\n let totalBitsInLayer;\n let wordSize;\n let stuffedBits;\n if (userSpecifiedLayers !== Encoder$1.DEFAULT_AZTEC_LAYERS) {\n compact = userSpecifiedLayers < 0;\n layers = Math.abs(userSpecifiedLayers);\n if (layers > (compact ? Encoder$1.MAX_NB_BITS_COMPACT : Encoder$1.MAX_NB_BITS)) {\n throw new IllegalArgumentException(StringUtils.format('Illegal value %s for layers', userSpecifiedLayers));\n }\n totalBitsInLayer = Encoder$1.totalBitsInLayer(layers, compact);\n wordSize = Encoder$1.WORD_SIZE[layers];\n let usableBitsInLayers = totalBitsInLayer - (totalBitsInLayer % wordSize);\n stuffedBits = Encoder$1.stuffBits(bits, wordSize);\n if (stuffedBits.getSize() + eccBits > usableBitsInLayers) {\n throw new IllegalArgumentException('Data to large for user specified layer');\n }\n if (compact && stuffedBits.getSize() > wordSize * 64) {\n // Compact format only allows 64 data words, though C4 can hold more words than that\n throw new IllegalArgumentException('Data to large for user specified layer');\n }\n }\n else {\n wordSize = 0;\n stuffedBits = null;\n // We look at the possible table sizes in the order Compact1, Compact2, Compact3,\n // Compact4, Normal4,... Normal(i) for i < 4 isn't typically used since Compact(i+1)\n // is the same size, but has more data.\n for (let i /*int*/ = 0;; i++) {\n if (i > Encoder$1.MAX_NB_BITS) {\n throw new IllegalArgumentException('Data too large for an Aztec code');\n }\n compact = i <= 3;\n layers = compact ? i + 1 : i;\n totalBitsInLayer = Encoder$1.totalBitsInLayer(layers, compact);\n if (totalSizeBits > totalBitsInLayer) {\n continue;\n }\n // [Re]stuff the bits if this is the first opportunity, or if the\n // wordSize has changed\n if (stuffedBits == null || wordSize !== Encoder$1.WORD_SIZE[layers]) {\n wordSize = Encoder$1.WORD_SIZE[layers];\n stuffedBits = Encoder$1.stuffBits(bits, wordSize);\n }\n let usableBitsInLayers = totalBitsInLayer - (totalBitsInLayer % wordSize);\n if (compact && stuffedBits.getSize() > wordSize * 64) {\n // Compact format only allows 64 data words, though C4 can hold more words than that\n continue;\n }\n if (stuffedBits.getSize() + eccBits <= usableBitsInLayers) {\n break;\n }\n }\n }\n let messageBits = Encoder$1.generateCheckWords(stuffedBits, totalBitsInLayer, wordSize);\n // generate mode message\n let messageSizeInWords = stuffedBits.getSize() / wordSize;\n let modeMessage = Encoder$1.generateModeMessage(compact, layers, messageSizeInWords);\n // allocate symbol\n let baseMatrixSize = (compact ? 11 : 14) + layers * 4; // not including alignment lines\n let alignmentMap = new Int32Array(baseMatrixSize);\n let matrixSize;\n if (compact) {\n // no alignment marks in compact mode, alignmentMap is a no-op\n matrixSize = baseMatrixSize;\n for (let i /*int*/ = 0; i < alignmentMap.length; i++) {\n alignmentMap[i] = i;\n }\n }\n else {\n matrixSize = baseMatrixSize + 1 + 2 * Integer.truncDivision((Integer.truncDivision(baseMatrixSize, 2) - 1), 15);\n let origCenter = Integer.truncDivision(baseMatrixSize, 2);\n let center = Integer.truncDivision(matrixSize, 2);\n for (let i /*int*/ = 0; i < origCenter; i++) {\n let newOffset = i + Integer.truncDivision(i, 15);\n alignmentMap[origCenter - i - 1] = center - newOffset - 1;\n alignmentMap[origCenter + i] = center + newOffset + 1;\n }\n }\n let matrix = new BitMatrix(matrixSize);\n // draw data bits\n for (let i /*int*/ = 0, rowOffset = 0; i < layers; i++) {\n let rowSize = (layers - i) * 4 + (compact ? 9 : 12);\n for (let j /*int*/ = 0; j < rowSize; j++) {\n let columnOffset = j * 2;\n for (let k /*int*/ = 0; k < 2; k++) {\n if (messageBits.get(rowOffset + columnOffset + k)) {\n matrix.set(alignmentMap[i * 2 + k], alignmentMap[i * 2 + j]);\n }\n if (messageBits.get(rowOffset + rowSize * 2 + columnOffset + k)) {\n matrix.set(alignmentMap[i * 2 + j], alignmentMap[baseMatrixSize - 1 - i * 2 - k]);\n }\n if (messageBits.get(rowOffset + rowSize * 4 + columnOffset + k)) {\n matrix.set(alignmentMap[baseMatrixSize - 1 - i * 2 - k], alignmentMap[baseMatrixSize - 1 - i * 2 - j]);\n }\n if (messageBits.get(rowOffset + rowSize * 6 + columnOffset + k)) {\n matrix.set(alignmentMap[baseMatrixSize - 1 - i * 2 - j], alignmentMap[i * 2 + k]);\n }\n }\n }\n rowOffset += rowSize * 8;\n }\n // draw mode message\n Encoder$1.drawModeMessage(matrix, compact, matrixSize, modeMessage);\n // draw alignment marks\n if (compact) {\n Encoder$1.drawBullsEye(matrix, Integer.truncDivision(matrixSize, 2), 5);\n }\n else {\n Encoder$1.drawBullsEye(matrix, Integer.truncDivision(matrixSize, 2), 7);\n for (let i /*int*/ = 0, j = 0; i < Integer.truncDivision(baseMatrixSize, 2) - 1; i += 15, j += 16) {\n for (let k /*int*/ = Integer.truncDivision(matrixSize, 2) & 1; k < matrixSize; k += 2) {\n matrix.set(Integer.truncDivision(matrixSize, 2) - j, k);\n matrix.set(Integer.truncDivision(matrixSize, 2) + j, k);\n matrix.set(k, Integer.truncDivision(matrixSize, 2) - j);\n matrix.set(k, Integer.truncDivision(matrixSize, 2) + j);\n }\n }\n }\n let aztec = new AztecCode();\n aztec.setCompact(compact);\n aztec.setSize(matrixSize);\n aztec.setLayers(layers);\n aztec.setCodeWords(messageSizeInWords);\n aztec.setMatrix(matrix);\n return aztec;\n }\n static drawBullsEye(matrix, center, size) {\n for (let i /*int*/ = 0; i < size; i += 2) {\n for (let j /*int*/ = center - i; j <= center + i; j++) {\n matrix.set(j, center - i);\n matrix.set(j, center + i);\n matrix.set(center - i, j);\n matrix.set(center + i, j);\n }\n }\n matrix.set(center - size, center - size);\n matrix.set(center - size + 1, center - size);\n matrix.set(center - size, center - size + 1);\n matrix.set(center + size, center - size);\n matrix.set(center + size, center - size + 1);\n matrix.set(center + size, center + size - 1);\n }\n static generateModeMessage(compact, layers, messageSizeInWords) {\n let modeMessage = new BitArray();\n if (compact) {\n modeMessage.appendBits(layers - 1, 2);\n modeMessage.appendBits(messageSizeInWords - 1, 6);\n modeMessage = Encoder$1.generateCheckWords(modeMessage, 28, 4);\n }\n else {\n modeMessage.appendBits(layers - 1, 5);\n modeMessage.appendBits(messageSizeInWords - 1, 11);\n modeMessage = Encoder$1.generateCheckWords(modeMessage, 40, 4);\n }\n return modeMessage;\n }\n static drawModeMessage(matrix, compact, matrixSize, modeMessage) {\n let center = Integer.truncDivision(matrixSize, 2);\n if (compact) {\n for (let i /*int*/ = 0; i < 7; i++) {\n let offset = center - 3 + i;\n if (modeMessage.get(i)) {\n matrix.set(offset, center - 5);\n }\n if (modeMessage.get(i + 7)) {\n matrix.set(center + 5, offset);\n }\n if (modeMessage.get(20 - i)) {\n matrix.set(offset, center + 5);\n }\n if (modeMessage.get(27 - i)) {\n matrix.set(center - 5, offset);\n }\n }\n }\n else {\n for (let i /*int*/ = 0; i < 10; i++) {\n let offset = center - 5 + i + Integer.truncDivision(i, 5);\n if (modeMessage.get(i)) {\n matrix.set(offset, center - 7);\n }\n if (modeMessage.get(i + 10)) {\n matrix.set(center + 7, offset);\n }\n if (modeMessage.get(29 - i)) {\n matrix.set(offset, center + 7);\n }\n if (modeMessage.get(39 - i)) {\n matrix.set(center - 7, offset);\n }\n }\n }\n }\n static generateCheckWords(bitArray, totalBits, wordSize) {\n // bitArray is guaranteed to be a multiple of the wordSize, so no padding needed\n let messageSizeInWords = bitArray.getSize() / wordSize;\n let rs = new ReedSolomonEncoder(Encoder$1.getGF(wordSize));\n let totalWords = Integer.truncDivision(totalBits, wordSize);\n let messageWords = Encoder$1.bitsToWords(bitArray, wordSize, totalWords);\n rs.encode(messageWords, totalWords - messageSizeInWords);\n let startPad = totalBits % wordSize;\n let messageBits = new BitArray();\n messageBits.appendBits(0, startPad);\n for (const messageWord /*: int*/ of Array.from(messageWords)) {\n messageBits.appendBits(messageWord, wordSize);\n }\n return messageBits;\n }\n static bitsToWords(stuffedBits, wordSize, totalWords) {\n let message = new Int32Array(totalWords);\n let i;\n let n;\n for (i = 0, n = stuffedBits.getSize() / wordSize; i < n; i++) {\n let value = 0;\n for (let j /*int*/ = 0; j < wordSize; j++) {\n value |= stuffedBits.get(i * wordSize + j) ? (1 << wordSize - j - 1) : 0;\n }\n message[i] = value;\n }\n return message;\n }\n static getGF(wordSize) {\n switch (wordSize) {\n case 4:\n return GenericGF.AZTEC_PARAM;\n case 6:\n return GenericGF.AZTEC_DATA_6;\n case 8:\n return GenericGF.AZTEC_DATA_8;\n case 10:\n return GenericGF.AZTEC_DATA_10;\n case 12:\n return GenericGF.AZTEC_DATA_12;\n default:\n throw new IllegalArgumentException('Unsupported word size ' + wordSize);\n }\n }\n static stuffBits(bits, wordSize) {\n let out = new BitArray();\n let n = bits.getSize();\n let mask = (1 << wordSize) - 2;\n for (let i /*int*/ = 0; i < n; i += wordSize) {\n let word = 0;\n for (let j /*int*/ = 0; j < wordSize; j++) {\n if (i + j >= n || bits.get(i + j)) {\n word |= 1 << (wordSize - 1 - j);\n }\n }\n if ((word & mask) === mask) {\n out.appendBits(word & mask, wordSize);\n i--;\n }\n else if ((word & mask) === 0) {\n out.appendBits(word | 1, wordSize);\n i--;\n }\n else {\n out.appendBits(word, wordSize);\n }\n }\n return out;\n }\n static totalBitsInLayer(layers, compact) {\n return ((compact ? 88 : 112) + 16 * layers) * layers;\n }\n }\n Encoder$1.DEFAULT_EC_PERCENT = 33; // default minimal percentage of error check words\n Encoder$1.DEFAULT_AZTEC_LAYERS = 0;\n Encoder$1.MAX_NB_BITS = 32;\n Encoder$1.MAX_NB_BITS_COMPACT = 4;\n Encoder$1.WORD_SIZE = Int32Array.from([\n 4, 6, 6, 8, 8, 8, 8, 8, 8, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10,\n 12, 12, 12, 12, 12, 12, 12, 12, 12, 12\n ]);\n\n /*\n * Copyright 2013 ZXing authors\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n /**\n * Renders an Aztec code as a {@link BitMatrix}.\n */\n /*public final*/ class AztecWriter {\n // @Override\n encode(contents, format, width, height) {\n return this.encodeWithHints(contents, format, width, height, null);\n }\n // @Override\n encodeWithHints(contents, format, width, height, hints) {\n let charset = StandardCharsets.ISO_8859_1;\n let eccPercent = Encoder$1.DEFAULT_EC_PERCENT;\n let layers = Encoder$1.DEFAULT_AZTEC_LAYERS;\n if (hints != null) {\n if (hints.has(EncodeHintType$1.CHARACTER_SET)) {\n charset = Charset.forName(hints.get(EncodeHintType$1.CHARACTER_SET).toString());\n }\n if (hints.has(EncodeHintType$1.ERROR_CORRECTION)) {\n eccPercent = Integer.parseInt(hints.get(EncodeHintType$1.ERROR_CORRECTION).toString());\n }\n if (hints.has(EncodeHintType$1.AZTEC_LAYERS)) {\n layers = Integer.parseInt(hints.get(EncodeHintType$1.AZTEC_LAYERS).toString());\n }\n }\n return AztecWriter.encodeLayers(contents, format, width, height, charset, eccPercent, layers);\n }\n static encodeLayers(contents, format, width, height, charset, eccPercent, layers) {\n if (format !== BarcodeFormat$1.AZTEC) {\n throw new IllegalArgumentException('Can only encode AZTEC, but got ' + format);\n }\n let aztec = Encoder$1.encode(StringUtils.getBytes(contents, charset), eccPercent, layers);\n return AztecWriter.renderResult(aztec, width, height);\n }\n static renderResult(code, width, height) {\n let input = code.getMatrix();\n if (input == null) {\n throw new IllegalStateException();\n }\n let inputWidth = input.getWidth();\n let inputHeight = input.getHeight();\n let outputWidth = Math.max(width, inputWidth);\n let outputHeight = Math.max(height, inputHeight);\n let multiple = Math.min(outputWidth / inputWidth, outputHeight / inputHeight);\n let leftPadding = (outputWidth - (inputWidth * multiple)) / 2;\n let topPadding = (outputHeight - (inputHeight * multiple)) / 2;\n let output = new BitMatrix(outputWidth, outputHeight);\n for (let inputY /*int*/ = 0, outputY = topPadding; inputY < inputHeight; inputY++, outputY += multiple) {\n // Write the contents of this row of the barcode\n for (let inputX /*int*/ = 0, outputX = leftPadding; inputX < inputWidth; inputX++, outputX += multiple) {\n if (input.get(inputX, inputY)) {\n output.setRegion(outputX, outputY, multiple, multiple);\n }\n }\n }\n return output;\n }\n }\n\n exports.AbstractExpandedDecoder = AbstractExpandedDecoder;\n exports.ArgumentException = ArgumentException;\n exports.ArithmeticException = ArithmeticException;\n exports.AztecCode = AztecCode;\n exports.AztecCodeReader = AztecReader;\n exports.AztecCodeWriter = AztecWriter;\n exports.AztecDecoder = Decoder;\n exports.AztecDetector = Detector;\n exports.AztecDetectorResult = AztecDetectorResult;\n exports.AztecEncoder = Encoder$1;\n exports.AztecHighLevelEncoder = HighLevelEncoder;\n exports.AztecPoint = Point;\n exports.BarcodeFormat = BarcodeFormat$1;\n exports.Binarizer = Binarizer;\n exports.BinaryBitmap = BinaryBitmap;\n exports.BitArray = BitArray;\n exports.BitMatrix = BitMatrix;\n exports.BitSource = BitSource;\n exports.BrowserAztecCodeReader = BrowserAztecCodeReader;\n exports.BrowserBarcodeReader = BrowserBarcodeReader;\n exports.BrowserCodeReader = BrowserCodeReader;\n exports.BrowserDatamatrixCodeReader = BrowserDatamatrixCodeReader;\n exports.BrowserMultiFormatReader = BrowserMultiFormatReader;\n exports.BrowserPDF417Reader = BrowserPDF417Reader;\n exports.BrowserQRCodeReader = BrowserQRCodeReader;\n exports.BrowserQRCodeSvgWriter = BrowserQRCodeSvgWriter;\n exports.CharacterSetECI = CharacterSetECI;\n exports.ChecksumException = ChecksumException;\n exports.Code128Reader = Code128Reader;\n exports.Code39Reader = Code39Reader;\n exports.DataMatrixDecodedBitStreamParser = DecodedBitStreamParser;\n exports.DataMatrixReader = DataMatrixReader;\n exports.DecodeHintType = DecodeHintType$1;\n exports.DecoderResult = DecoderResult;\n exports.DefaultGridSampler = DefaultGridSampler;\n exports.DetectorResult = DetectorResult;\n exports.EAN13Reader = EAN13Reader;\n exports.EncodeHintType = EncodeHintType$1;\n exports.Exception = Exception;\n exports.FormatException = FormatException;\n exports.GenericGF = GenericGF;\n exports.GenericGFPoly = GenericGFPoly;\n exports.GlobalHistogramBinarizer = GlobalHistogramBinarizer;\n exports.GridSampler = GridSampler;\n exports.GridSamplerInstance = GridSamplerInstance;\n exports.HTMLCanvasElementLuminanceSource = HTMLCanvasElementLuminanceSource;\n exports.HybridBinarizer = HybridBinarizer;\n exports.ITFReader = ITFReader;\n exports.IllegalArgumentException = IllegalArgumentException;\n exports.IllegalStateException = IllegalStateException;\n exports.InvertedLuminanceSource = InvertedLuminanceSource;\n exports.LuminanceSource = LuminanceSource;\n exports.MathUtils = MathUtils;\n exports.MultiFormatOneDReader = MultiFormatOneDReader;\n exports.MultiFormatReader = MultiFormatReader;\n exports.MultiFormatWriter = MultiFormatWriter;\n exports.NotFoundException = NotFoundException;\n exports.OneDReader = OneDReader;\n exports.PDF417DecodedBitStreamParser = DecodedBitStreamParser$2;\n exports.PDF417DecoderErrorCorrection = ErrorCorrection;\n exports.PDF417Reader = PDF417Reader;\n exports.PDF417ResultMetadata = PDF417ResultMetadata;\n exports.PerspectiveTransform = PerspectiveTransform;\n exports.PlanarYUVLuminanceSource = PlanarYUVLuminanceSource;\n exports.QRCodeByteMatrix = ByteMatrix;\n exports.QRCodeDataMask = DataMask;\n exports.QRCodeDecodedBitStreamParser = DecodedBitStreamParser$1;\n exports.QRCodeDecoderErrorCorrectionLevel = ErrorCorrectionLevel;\n exports.QRCodeDecoderFormatInformation = FormatInformation;\n exports.QRCodeEncoder = Encoder;\n exports.QRCodeEncoderQRCode = QRCode;\n exports.QRCodeMaskUtil = MaskUtil;\n exports.QRCodeMatrixUtil = MatrixUtil;\n exports.QRCodeMode = Mode$1;\n exports.QRCodeReader = QRCodeReader;\n exports.QRCodeVersion = Version$1;\n exports.QRCodeWriter = QRCodeWriter;\n exports.RGBLuminanceSource = RGBLuminanceSource;\n exports.RSS14Reader = RSS14Reader;\n exports.RSSExpandedReader = RSSExpandedReader;\n exports.ReaderException = ReaderException;\n exports.ReedSolomonDecoder = ReedSolomonDecoder;\n exports.ReedSolomonEncoder = ReedSolomonEncoder;\n exports.ReedSolomonException = ReedSolomonException;\n exports.Result = Result;\n exports.ResultMetadataType = ResultMetadataType$1;\n exports.ResultPoint = ResultPoint;\n exports.StringUtils = StringUtils;\n exports.UnsupportedOperationException = UnsupportedOperationException;\n exports.VideoInputDevice = VideoInputDevice;\n exports.WhiteRectangleDetector = WhiteRectangleDetector;\n exports.WriterException = WriterException;\n exports.ZXingArrays = Arrays;\n exports.ZXingCharset = Charset;\n exports.ZXingInteger = Integer;\n exports.ZXingStandardCharsets = StandardCharsets;\n exports.ZXingStringBuilder = StringBuilder;\n exports.ZXingStringEncoding = StringEncoding;\n exports.ZXingSystem = System;\n exports.createAbstractExpandedDecoder = createDecoder;\n\n Object.defineProperty(exports, '__esModule', { value: true });\n\n})));\n","'use strict';\nvar TO_STRING_TAG_SUPPORT = require('../internals/to-string-tag-support');\nvar isCallable = require('../internals/is-callable');\nvar classofRaw = require('../internals/classof-raw');\nvar wellKnownSymbol = require('../internals/well-known-symbol');\n\nvar TO_STRING_TAG = wellKnownSymbol('toStringTag');\nvar $Object = Object;\n\n// ES3 wrong here\nvar CORRECT_ARGUMENTS = classofRaw(function () { return arguments; }()) === 'Arguments';\n\n// fallback for IE11 Script Access Denied error\nvar tryGet = function (it, key) {\n try {\n return it[key];\n } catch (error) { /* empty */ }\n};\n\n// getting tag from ES6+ `Object.prototype.toString`\nmodule.exports = TO_STRING_TAG_SUPPORT ? classofRaw : function (it) {\n var O, tag, result;\n return it === undefined ? 'Undefined' : it === null ? 'Null'\n // @@toStringTag case\n : typeof (tag = tryGet(O = $Object(it), TO_STRING_TAG)) == 'string' ? tag\n // builtinTag case\n : CORRECT_ARGUMENTS ? classofRaw(O)\n // ES3 arguments fallback\n : (result = classofRaw(O)) === 'Object' && isCallable(O.callee) ? 'Arguments' : result;\n};\n","'use strict';\n\nvar utils = require('./../utils');\n\nfunction InterceptorManager() {\n this.handlers = [];\n}\n\n/**\n * Add a new interceptor to the stack\n *\n * @param {Function} fulfilled The function to handle `then` for a `Promise`\n * @param {Function} rejected The function to handle `reject` for a `Promise`\n *\n * @return {Number} An ID used to remove interceptor later\n */\nInterceptorManager.prototype.use = function use(fulfilled, rejected, options) {\n this.handlers.push({\n fulfilled: fulfilled,\n rejected: rejected,\n synchronous: options ? options.synchronous : false,\n runWhen: options ? options.runWhen : null\n });\n return this.handlers.length - 1;\n};\n\n/**\n * Remove an interceptor from the stack\n *\n * @param {Number} id The ID that was returned by `use`\n */\nInterceptorManager.prototype.eject = function eject(id) {\n if (this.handlers[id]) {\n this.handlers[id] = null;\n }\n};\n\n/**\n * Iterate over all the registered interceptors\n *\n * This method is particularly useful for skipping over any\n * interceptors that may have become `null` calling `eject`.\n *\n * @param {Function} fn The function to call for each interceptor\n */\nInterceptorManager.prototype.forEach = function forEach(fn) {\n utils.forEach(this.handlers, function forEachHandler(h) {\n if (h !== null) {\n fn(h);\n }\n });\n};\n\nmodule.exports = InterceptorManager;\n","'use strict';\nvar shared = require('../internals/shared');\nvar uid = require('../internals/uid');\n\nvar keys = shared('keys');\n\nmodule.exports = function (key) {\n return keys[key] || (keys[key] = uid(key));\n};\n","import { toRefs, reactive, computed, ref, watch, nextTick } from 'vue';\n\nvar isBrowser = function isBrowser() {\n return typeof document !== \"undefined\" && typeof window !== \"undefined\";\n};\nvar loadScript = function loadScript(source, preconnect) {\n return new Promise(function (resolve, reject) {\n var head = document.head || document.getElementsByTagName(\"head\")[0];\n var script = document.createElement(\"script\");\n script.async = true;\n script.src = source;\n script.charset = \"utf-8\";\n\n if (preconnect) {\n var link = document.createElement(\"link\");\n link.href = preconnect;\n link.rel = \"preconnect\";\n head.appendChild(link);\n }\n\n head.appendChild(script);\n script.onload = resolve;\n script.onerror = reject;\n });\n};\nvar merge = function merge() {\n var obj = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};\n var newObj = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {};\n Object.keys(newObj).forEach(function (key) {\n obj[key] = newObj[key];\n });\n};\n\nvar state = reactive({\n property: null,\n isEnabled: true,\n disableScriptLoader: false,\n useDebugger: false,\n globalObjectName: \"gtag\",\n dataLayerName: \"dataLayer\",\n resourceURL: \"https://www.googletagmanager.com/gtag/js\",\n preconnectOrigin: \"https://www.googletagmanager.com\",\n customResource: null,\n appName: null,\n appId: null,\n appVersion: null\n});\nvar useState = function useState() {\n return toRefs(state);\n};\nvar defaultProperty = computed(function () {\n var _useState = useState(),\n property = _useState.property;\n\n if (!property.value) {\n return;\n }\n\n if (Array.isArray(property.value)) {\n return property.value.find(function (p) {\n return p[\"default\"] === true;\n }) || property.value[0];\n }\n\n return property.value;\n});\nvar hasId = computed(function () {\n var _useState2 = useState(),\n property = _useState2.property;\n\n return Boolean(property.value && property.value.id !== null);\n});\nvar allProperties = computed(function () {\n var _useState3 = useState(),\n property = _useState3.property;\n\n if (Array.isArray(property.value)) {\n return property.value;\n }\n\n return [property.value];\n});\nvar isTracking = computed(function () {\n var _useState4 = useState(),\n isEnabled = _useState4.isEnabled;\n\n var property = defaultProperty.value;\n return Boolean(property && property.id && isEnabled.value);\n});\n\nvar query = (function () {\n var _window;\n\n if (!isBrowser()) {\n return;\n }\n\n var _useState = useState(),\n globalObjectName = _useState.globalObjectName,\n useDebugger = _useState.useDebugger;\n\n for (var _len = arguments.length, args = new Array(_len), _key = 0; _key < _len; _key++) {\n args[_key] = arguments[_key];\n }\n\n if (useDebugger.value) {\n console.warn(\"[vue-gtag] Debugger:\", args);\n }\n\n (_window = window)[globalObjectName.value].apply(_window, args);\n});\n\nvar config = (function () {\n for (var _len = arguments.length, args = new Array(_len), _key = 0; _key < _len; _key++) {\n args[_key] = arguments[_key];\n }\n\n allProperties.value.forEach(function (property) {\n query.apply(void 0, [\"config\", property.id].concat(args));\n });\n});\n\nvar customMap = (function (map) {\n config({\n custom_map: map\n });\n});\n\nvar disable = (function () {\n var value = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : true;\n\n if (!isBrowser()) {\n return;\n }\n\n allProperties.value.forEach(function (property) {\n window[\"ga-disable-\".concat(property.id)] = value;\n });\n});\n\nvar event = (function (eventName) {\n var eventParams = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {};\n var params = Object.assign({}, eventParams);\n\n if (!params.send_to && allProperties.value.length > 1) {\n params.send_to = allProperties.value.map(function (property) {\n return property.id;\n });\n }\n\n query(\"event\", eventName, params);\n});\n\nvar exception = (function () {\n for (var _len = arguments.length, args = new Array(_len), _key = 0; _key < _len; _key++) {\n args[_key] = arguments[_key];\n }\n\n event.apply(void 0, [\"exception\"].concat(args));\n});\n\nvar linker = (function () {\n for (var _len = arguments.length, args = new Array(_len), _key = 0; _key < _len; _key++) {\n args[_key] = arguments[_key];\n }\n\n config.apply(void 0, [\"linker\"].concat(args));\n});\n\nvar pageview = (function (value) {\n var params = {};\n\n if (typeof value === \"string\") {\n params = {\n page_path: value,\n page_location: window.location.href\n };\n } else {\n params = value;\n }\n\n if (typeof params.send_page_view === \"undefined\") {\n params.send_page_view = true;\n }\n\n event(\"page_view\", params);\n});\n\nvar purchase = (function () {\n for (var _len = arguments.length, args = new Array(_len), _key = 0; _key < _len; _key++) {\n args[_key] = arguments[_key];\n }\n\n event.apply(void 0, [\"purchase\"].concat(args));\n});\n\nvar refund = (function () {\n for (var _len = arguments.length, args = new Array(_len), _key = 0; _key < _len; _key++) {\n args[_key] = arguments[_key];\n }\n\n event.apply(void 0, [\"refund\"].concat(args));\n});\n\nvar screenview = (function () {\n var _useState = useState(),\n appName = _useState.appName,\n appId = _useState.appId,\n appVersion = _useState.appVersion;\n\n for (var _len = arguments.length, args = new Array(_len), _key = 0; _key < _len; _key++) {\n args[_key] = arguments[_key];\n }\n\n var arg = args[0];\n var params = {};\n\n if (typeof arg === \"string\") {\n params = {\n screen_name: arg\n };\n } else {\n params = arg;\n }\n\n if (params.app_name == null && appName.value != null) {\n params.app_name = appName.value;\n }\n\n if (params.app_id == null && appId.value != null) {\n params.app_id = appId.value;\n }\n\n if (params.app_version == null && appVersion.value != null) {\n params.app_version = appVersion.value;\n }\n\n event(\"screen_view\", params);\n});\n\nvar set = (function () {\n for (var _len = arguments.length, args = new Array(_len), _key = 0; _key < _len; _key++) {\n args[_key] = arguments[_key];\n }\n\n query.apply(void 0, [\"set\"].concat(args));\n});\n\nvar time = (function () {\n for (var _len = arguments.length, args = new Array(_len), _key = 0; _key < _len; _key++) {\n args[_key] = arguments[_key];\n }\n\n event.apply(void 0, [\"timing_complete\"].concat(args));\n});\n\nvar api = /*#__PURE__*/Object.freeze({\n __proto__: null,\n config: config,\n customMap: customMap,\n disable: disable,\n event: event,\n exception: exception,\n linker: linker,\n pageview: pageview,\n purchase: purchase,\n query: query,\n refund: refund,\n screenview: screenview,\n set: set,\n time: time\n});\n\nvar isReady = ref(false);\nvar isBootstrapped = ref(false);\nvar bootstrap = function bootstrap() {\n var _useState = useState(),\n disableScriptLoader = _useState.disableScriptLoader,\n preconnectOrigin = _useState.preconnectOrigin,\n resourceURL = _useState.resourceURL,\n dataLayerName = _useState.dataLayerName;\n\n if (!isBrowser() || !hasId.value || isBootstrapped.value) {\n return;\n }\n\n isBootstrapped.value = true;\n allProperties.value.forEach(function (property) {\n var params = Object.assign({\n send_page_view: false\n }, property.params);\n query(\"config\", property.id, params);\n });\n\n if (disableScriptLoader.value) {\n isReady.value = true;\n return;\n }\n\n var resource = \"\".concat(resourceURL.value, \"?id=\").concat(defaultProperty.value.id, \"&l=\").concat(dataLayerName.value);\n loadScript(resource, preconnectOrigin.value).then(function () {\n isReady.value = true;\n });\n};\nvar useBootstrapWatcher = function useBootstrapWatcher() {\n watch(function () {\n return isTracking.value;\n }, function (val) {\n return val && bootstrap();\n }, {\n immediate: true\n });\n};\n\nvar registerGlobalObject = (function () {\n if (!isBrowser()) {\n return;\n }\n\n var _useState = useState(),\n globalObjectName = _useState.globalObjectName,\n dataLayerName = _useState.dataLayerName;\n\n if (window[globalObjectName.value] == null) {\n window[dataLayerName.value] = window[dataLayerName.value] || [];\n\n window[globalObjectName.value] = function () {\n window[dataLayerName.value].push(arguments);\n };\n }\n\n window[globalObjectName.value](\"js\", new Date());\n});\n\nvar useGtag = (function () {\n return api;\n});\n\nvar routerState = reactive({\n template: null,\n useScreenview: false,\n skipSamePath: true\n});\nvar useRouterState = function useRouterState() {\n return toRefs(routerState);\n};\n\nvar getTemplate = function getTemplate() {\n var to = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};\n var from = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {};\n\n var _useRouterState = useRouterState(),\n template = _useRouterState.template,\n useScreenview = _useRouterState.useScreenview;\n\n var customTemplate = template.value ? template.value(to, from) : null;\n\n if (customTemplate) {\n return customTemplate;\n } else if (useScreenview.value) {\n return {\n screen_name: to.name\n };\n } else {\n return {\n page_title: to.name,\n page_path: to.path,\n page_location: window.location.href\n };\n }\n};\nvar trackPage = function trackPage() {\n var to = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};\n var from = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {};\n\n var _useRouterState2 = useRouterState(),\n useScreenview = _useRouterState2.useScreenview,\n skipSamePath = _useRouterState2.skipSamePath;\n\n if (skipSamePath.value && to.path === from.path) {\n return;\n }\n\n var params = getTemplate(to, from);\n\n if (useScreenview.value) {\n screenview(params);\n } else {\n pageview(params);\n }\n};\nvar trackRouter = function trackRouter(router) {\n var newState = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {};\n merge(routerState, newState);\n watch(function () {\n return isTracking.value;\n }, function (val) {\n if (!val) {\n return;\n }\n\n router.isReady().then(function () {\n nextTick(function () {\n trackPage(router.currentRoute.value);\n });\n router.afterEach(function (to, from) {\n nextTick(function () {\n trackPage(to, from);\n });\n });\n });\n }, {\n immediate: true\n });\n};\n\nvar index = {\n install: function install(app) {\n var newState = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {};\n merge(state, newState);\n registerGlobalObject();\n useBootstrapWatcher();\n app.config.globalProperties.$gtag = api;\n }\n};\n\nexport default index;\nexport { config, customMap, disable, event, exception, isReady, isTracking, linker, pageview, purchase, query, refund, screenview, set, time, trackRouter, useGtag, useState };\n","'use strict';\n\nvar AxiosError = require('../core/AxiosError');\nvar utils = require('../utils');\n\n/**\n * A `CanceledError` is an object that is thrown when an operation is canceled.\n *\n * @class\n * @param {string=} message The message.\n */\nfunction CanceledError(message) {\n // eslint-disable-next-line no-eq-null,eqeqeq\n AxiosError.call(this, message == null ? 'canceled' : message, AxiosError.ERR_CANCELED);\n this.name = 'CanceledError';\n}\n\nutils.inherits(CanceledError, AxiosError, {\n __CANCEL__: true\n});\n\nmodule.exports = CanceledError;\n","'use strict';\n// toObject with fallback for non-array-like ES3 strings\nvar IndexedObject = require('../internals/indexed-object');\nvar requireObjectCoercible = require('../internals/require-object-coercible');\n\nmodule.exports = function (it) {\n return IndexedObject(requireObjectCoercible(it));\n};\n","'use strict';\n/* eslint-disable es/no-symbol -- required for testing */\nvar NATIVE_SYMBOL = require('../internals/symbol-constructor-detection');\n\nmodule.exports = NATIVE_SYMBOL\n && !Symbol.sham\n && typeof Symbol.iterator == 'symbol';\n"],"sourceRoot":""}