: str_replace(): Passing null to parameter #2 ($replace) of type array|string is deprecated in
class ArithmeticDecoder {
constructor(data, start, end) {
this.chigh = data[start];
this.chigh = this.chigh << 7 & 0xffff | this.clow >> 9 & 0x7f;
this.clow = this.clow << 7 & 0xffff;
if (data[bp + 1] > 0x8f) {
this.clow += data[bp] << 9;
this.clow += bp < this.dataEnd ? data[bp] << 8 : 0xff00;
if (this.clow > 0xffff) {
this.chigh += this.clow >> 16;
let cx_index = contexts[pos] >> 1,
cx_mps = contexts[pos] & 1;
const qeTableIcx = QeTable[cx_index];
const qeIcx = qeTableIcx.qe;
if (this.chigh < qeIcx) {
cx_index = qeTableIcx.nmps;
if (qeTableIcx.switchFlag === 1) {
cx_index = qeTableIcx.nlps;
if ((a & 0x8000) !== 0) {
if (qeTableIcx.switchFlag === 1) {
cx_index = qeTableIcx.nlps;
cx_index = qeTableIcx.nmps;
this.chigh = this.chigh << 1 & 0xffff | this.clow >> 15 & 1;
this.clow = this.clow << 1 & 0xffff;
} while ((a & 0x8000) === 0);
contexts[pos] = cx_index << 1 | cx_mps;
;// CONCATENATED MODULE: ./src/core/jbig2.js
class Jbig2Error extends BaseException {
super(msg, "Jbig2Error");
return this[id] = new Int8Array(1 << 16);
constructor(data, start, end) {
const decoder = new ArithmeticDecoder(this.data, this.start, this.end);
return shadow(this, "decoder", decoder);
const cache = new ContextCache();
return shadow(this, "contextCache", cache);
const MAX_INT_32 = 2 ** 31 - 1;
const MIN_INT_32 = -(2 ** 31);
function decodeInteger(contextCache, procedure, decoder) {
const contexts = contextCache.getContexts(procedure);
function readBits(length) {
for (let i = 0; i < length; i++) {
const bit = decoder.readBit(contexts, prev);
prev = prev < 256 ? prev << 1 | bit : (prev << 1 | bit) & 511 | 256;
const sign = readBits(1);
const value = readBits(1) ? readBits(1) ? readBits(1) ? readBits(1) ? readBits(1) ? readBits(32) + 4436 : readBits(12) + 340 : readBits(8) + 84 : readBits(6) + 20 : readBits(4) + 4 : readBits(2);
if (signedValue >= MIN_INT_32 && signedValue <= MAX_INT_32) {
function decodeIAID(contextCache, decoder, codeLength) {
const contexts = contextCache.getContexts("IAID");
for (let i = 0; i < codeLength; i++) {
const bit = decoder.readBit(contexts, prev);
return prev & (1 << codeLength) - 1;
return prev & 0x7fffffff;
const SegmentTypes = ["SymbolDictionary", null, null, null, "IntermediateTextRegion", null, "ImmediateTextRegion", "ImmediateLosslessTextRegion", null, null, null, null, null, null, null, null, "PatternDictionary", null, null, null, "IntermediateHalftoneRegion", null, "ImmediateHalftoneRegion", "ImmediateLosslessHalftoneRegion", null, null, null, null, null, null, null, null, null, null, null, null, "IntermediateGenericRegion", null, "ImmediateGenericRegion", "ImmediateLosslessGenericRegion", "IntermediateGenericRefinementRegion", null, "ImmediateGenericRefinementRegion", "ImmediateLosslessGenericRefinementRegion", null, null, null, null, "PageInformation", "EndOfPage", "EndOfStripe", "EndOfFile", "Profiles", "Tables", null, null, null, null, null, null, null, null, "Extension"];
const CodingTemplates = [[{
const RefinementTemplates = [{
const ReusedContexts = [0x9b25, 0x0795, 0x00e5, 0x0195];
const RefinementReusedContexts = [0x0020, 0x0008];
function decodeBitmapTemplate0(width, height, decodingContext) {
const decoder = decodingContext.decoder;
const contexts = decodingContext.contextCache.getContexts("GB");
let contextLabel, i, j, pixel, row, row1, row2;
const OLD_PIXEL_MASK = 0x7bf7;
for (i = 0; i < height; i++) {
row = bitmap[i] = new Uint8Array(width);
row1 = i < 1 ? row : bitmap[i - 1];
row2 = i < 2 ? row : bitmap[i - 2];
contextLabel = row2[0] << 13 | row2[1] << 12 | row2[2] << 11 | row1[0] << 7 | row1[1] << 6 | row1[2] << 5 | row1[3] << 4;
for (j = 0; j < width; j++) {
row[j] = pixel = decoder.readBit(contexts, contextLabel);
contextLabel = (contextLabel & OLD_PIXEL_MASK) << 1 | (j + 3 < width ? row2[j + 3] << 11 : 0) | (j + 4 < width ? row1[j + 4] << 4 : 0) | pixel;
function decodeBitmap(mmr, width, height, templateIndex, prediction, skip, at, decodingContext) {
const input = new Reader(decodingContext.data, decodingContext.start, decodingContext.end);
return decodeMMRBitmap(input, width, height, false);
if (templateIndex === 0 && !skip && !prediction && at.length === 4 && at[0].x === 3 && at[0].y === -1 && at[1].x === -3 && at[1].y === -1 && at[2].x === 2 && at[2].y === -2 && at[3].x === -2 && at[3].y === -2) {
return decodeBitmapTemplate0(width, height, decodingContext);
const template = CodingTemplates[templateIndex].concat(at);
template.sort(function (a, b) {
return a.y - b.y || a.x - b.x;
const templateLength = template.length;
const templateX = new Int8Array(templateLength);
const templateY = new Int8Array(templateLength);
const changingTemplateEntries = [];
for (k = 0; k < templateLength; k++) {
templateX[k] = template[k].x;
templateY[k] = template[k].y;
minX = Math.min(minX, template[k].x);
maxX = Math.max(maxX, template[k].x);
minY = Math.min(minY, template[k].y);
if (k < templateLength - 1 && template[k].y === template[k + 1].y && template[k].x === template[k + 1].x - 1) {
reuseMask |= 1 << templateLength - 1 - k;
changingTemplateEntries.push(k);
const changingEntriesLength = changingTemplateEntries.length;
const changingTemplateX = new Int8Array(changingEntriesLength);
const changingTemplateY = new Int8Array(changingEntriesLength);
const changingTemplateBit = new Uint16Array(changingEntriesLength);
for (c = 0; c < changingEntriesLength; c++) {
k = changingTemplateEntries[c];
changingTemplateX[c] = template[k].x;
changingTemplateY[c] = template[k].y;
changingTemplateBit[c] = 1 << templateLength - 1 - k;
const sbb_right = width - maxX;
const pseudoPixelContext = ReusedContexts[templateIndex];
let row = new Uint8Array(width);
const decoder = decodingContext.decoder;
const contexts = decodingContext.contextCache.getContexts("GB");
for (let i = 0; i < height; i++) {
const sltp = decoder.readBit(contexts, pseudoPixelContext);
row = new Uint8Array(row);
for (j = 0; j < width; j++) {
if (useskip && skip[i][j]) {
if (j >= sbb_left && j < sbb_right && i >= sbb_top) {
contextLabel = contextLabel << 1 & reuseMask;