package A1;

import B0.j0;
import android.view.View;
import java.util.Arrays;
import n4.u0;
import x0.AbstractC1709a;

/* JADX INFO: loaded from: classes.dex */
public final class x {

    /* JADX INFO: renamed from: a, reason: collision with root package name */
    public final /* synthetic */ int f356a = 2;

    /* JADX INFO: renamed from: b, reason: collision with root package name */
    public boolean f357b;

    /* JADX INFO: renamed from: c, reason: collision with root package name */
    public int f358c;

    /* JADX INFO: renamed from: d, reason: collision with root package name */
    public boolean f359d;

    /* JADX INFO: renamed from: e, reason: collision with root package name */
    public int f360e;

    /* JADX INFO: renamed from: f, reason: collision with root package name */
    public Object f361f;

    public x(int i) {
        this.f358c = i;
        byte[] bArr = new byte[131];
        this.f361f = bArr;
        bArr[2] = 1;
    }

    public void a(byte[] bArr, int i, int i5) {
        if (this.f357b) {
            int i8 = i5 - i;
            byte[] bArr2 = (byte[]) this.f361f;
            int length = bArr2.length;
            int i9 = this.f360e;
            if (length < i9 + i8) {
                this.f361f = Arrays.copyOf(bArr2, (i9 + i8) * 2);
            }
            System.arraycopy(bArr, i, (byte[]) this.f361f, this.f360e, i8);
            this.f360e += i8;
        }
    }

    public void b() {
        this.f360e = this.f357b ? ((N1.M) this.f361f).i() : ((N1.M) this.f361f).m();
    }

    public void c(View view, int i) {
        if (this.f357b) {
            this.f360e = ((N1.M) this.f361f).o() + ((N1.M) this.f361f).d(view);
        } else {
            this.f360e = ((N1.M) this.f361f).g(view);
        }
        this.f358c = i;
    }

    public void d(View view, int i) {
        int iO = ((N1.M) this.f361f).o();
        if (iO >= 0) {
            c(view, i);
            return;
        }
        this.f358c = i;
        if (!this.f357b) {
            int iG = ((N1.M) this.f361f).g(view);
            int iM = iG - ((N1.M) this.f361f).m();
            this.f360e = iG;
            if (iM > 0) {
                int i5 = (((N1.M) this.f361f).i() - Math.min(0, (((N1.M) this.f361f).i() - iO) - ((N1.M) this.f361f).d(view))) - (((N1.M) this.f361f).e(view) + iG);
                if (i5 < 0) {
                    this.f360e -= Math.min(iM, -i5);
                    return;
                }
                return;
            }
            return;
        }
        int i8 = (((N1.M) this.f361f).i() - iO) - ((N1.M) this.f361f).d(view);
        this.f360e = ((N1.M) this.f361f).i() - i8;
        if (i8 > 0) {
            int iE = this.f360e - ((N1.M) this.f361f).e(view);
            int iM2 = ((N1.M) this.f361f).m();
            int iMin = iE - (Math.min(((N1.M) this.f361f).g(view) - iM2, 0) + iM2);
            if (iMin < 0) {
                this.f360e = Math.min(i8, -iMin) + this.f360e;
            }
        }
    }

    public boolean e(int i) {
        if (!this.f357b) {
            return false;
        }
        this.f360e -= i;
        this.f357b = false;
        this.f359d = true;
        return true;
    }

    public void f(int i) {
        this.f357b |= i > 0;
        this.f358c += i;
    }

    public void g() {
        switch (this.f356a) {
            case u0.f15495q /* 0 */:
                this.f357b = false;
                this.f359d = false;
                break;
            default:
                this.f358c = -1;
                this.f360e = Integer.MIN_VALUE;
                this.f357b = false;
                this.f359d = false;
                break;
        }
    }

    public void h(int i) {
        AbstractC1709a.j(!this.f357b);
        boolean z8 = i == this.f358c;
        this.f357b = z8;
        if (z8) {
            this.f360e = 3;
            this.f359d = false;
        }
    }

    public String toString() {
        switch (this.f356a) {
            case 2:
                return "AnchorInfo{mPosition=" + this.f358c + ", mCoordinate=" + this.f360e + ", mLayoutFromEnd=" + this.f357b + ", mValid=" + this.f359d + '}';
            default:
                return super.toString();
        }
    }

    public x(j0 j0Var) {
        this.f361f = j0Var;
    }

    public x() {
        g();
    }
}
