package il;

import fl.e;
import fl.g;
import java.util.List;
import java.util.Map;
import jl.d;
import yk.c;
import yk.m;
import yk.o;
import yk.q;
import yk.r;
import yk.s;

/* loaded from: classes3.dex */
public final class a implements o {

    /* renamed from: b, reason: collision with root package name */
    private static final s[] f23351b = new s[0];

    /* renamed from: a, reason: collision with root package name */
    private final d f23352a = new d();

    private static fl.b c(fl.b bVar) {
        int[] l10 = bVar.l();
        int[] h10 = bVar.h();
        if (l10 == null || h10 == null) {
            throw m.a();
        }
        int d10 = d(l10, bVar);
        int i10 = l10[1];
        int i11 = h10[1];
        int i12 = l10[0];
        int i13 = ((h10[0] - i12) + 1) / d10;
        int i14 = ((i11 - i10) + 1) / d10;
        if (i13 <= 0 || i14 <= 0) {
            throw m.a();
        }
        int i15 = d10 / 2;
        int i16 = i10 + i15;
        int i17 = i12 + i15;
        fl.b bVar2 = new fl.b(i13, i14);
        for (int i18 = 0; i18 < i14; i18++) {
            int i19 = (i18 * d10) + i16;
            for (int i20 = 0; i20 < i13; i20++) {
                if (bVar.f((i20 * d10) + i17, i19)) {
                    bVar2.p(i20, i18);
                }
            }
        }
        return bVar2;
    }

    private static int d(int[] iArr, fl.b bVar) {
        int n10 = bVar.n();
        int i10 = iArr[0];
        int i11 = iArr[1];
        while (i10 < n10 && bVar.f(i10, i11)) {
            i10++;
        }
        if (i10 == n10) {
            throw m.a();
        }
        int i12 = i10 - iArr[0];
        if (i12 != 0) {
            return i12;
        }
        throw m.a();
    }

    @Override // yk.o
    public q a(c cVar, Map map) {
        e b10;
        s[] b11;
        if (map == null || !map.containsKey(yk.e.PURE_BARCODE)) {
            g b12 = new kl.a(cVar.a()).b();
            b10 = this.f23352a.b(b12.a());
            b11 = b12.b();
        } else {
            b10 = this.f23352a.b(c(cVar.a()));
            b11 = f23351b;
        }
        q qVar = new q(b10.h(), b10.e(), b11, yk.a.DATA_MATRIX);
        List a10 = b10.a();
        if (a10 != null) {
            qVar.h(r.BYTE_SEGMENTS, a10);
        }
        String b13 = b10.b();
        if (b13 != null) {
            qVar.h(r.ERROR_CORRECTION_LEVEL, b13);
        }
        return qVar;
    }

    @Override // yk.o
    public q b(c cVar) {
        return a(cVar, null);
    }

    @Override // yk.o
    public void reset() {
    }
}
