package pl;

import java.util.Collection;
import java.util.Map;
import java.util.regex.Pattern;

/* loaded from: classes3.dex */
public abstract class s implements yk.u {

    /* renamed from: a, reason: collision with root package name */
    private static final Pattern f32908a = Pattern.compile("[0-9]+");

    /* JADX INFO: Access modifiers changed from: protected */
    public static int b(boolean[] zArr, int i10, int[] iArr, boolean z10) {
        int i11 = 0;
        for (int i12 : iArr) {
            int i13 = 0;
            while (i13 < i12) {
                zArr[i10] = z10;
                i13++;
                i10++;
            }
            i11 += i12;
            z10 = !z10;
        }
        return i11;
    }

    /* JADX INFO: Access modifiers changed from: protected */
    public static void c(String str) {
        if (!f32908a.matcher(str).matches()) {
            throw new IllegalArgumentException("Input should only contain digits 0-9");
        }
    }

    private static fl.b g(boolean[] zArr, int i10, int i11, int i12) {
        int length = zArr.length;
        int i13 = i12 + length;
        int max = Math.max(i10, i13);
        int max2 = Math.max(1, i11);
        int i14 = max / i13;
        int i15 = (max - (length * i14)) / 2;
        fl.b bVar = new fl.b(max, max2);
        int i16 = 0;
        while (i16 < length) {
            if (zArr[i16]) {
                bVar.q(i15, 0, i14, max2);
            }
            i16++;
            i15 += i14;
        }
        return bVar;
    }

    @Override // yk.u
    public fl.b a(String str, yk.a aVar, int i10, int i11, Map map) {
        if (str.isEmpty()) {
            throw new IllegalArgumentException("Found empty contents");
        }
        if (i10 < 0 || i11 < 0) {
            throw new IllegalArgumentException("Negative size is not allowed. Input: " + i10 + 'x' + i11);
        }
        Collection f10 = f();
        if (f10 != null && !f10.contains(aVar)) {
            throw new IllegalArgumentException("Can only encode " + f10 + ", but got " + aVar);
        }
        int e10 = e();
        if (map != null) {
            yk.g gVar = yk.g.MARGIN;
            if (map.containsKey(gVar)) {
                e10 = Integer.parseInt(map.get(gVar).toString());
            }
        }
        return g(d(str), i10, i11, e10);
    }

    public abstract boolean[] d(String str);

    public int e() {
        return 10;
    }

    protected abstract Collection f();
}
