package com.google.android.gms.internal.measurement;

import java.io.IOException;
import java.util.List;

/* JADX INFO: loaded from: classes.dex */
public abstract class Z1 implements Cloneable {

    /* JADX INFO: renamed from: q, reason: collision with root package name */
    public final AbstractC0609a2 f9800q;

    /* JADX INFO: renamed from: r, reason: collision with root package name */
    public AbstractC0609a2 f9801r;

    public Z1(AbstractC0609a2 abstractC0609a2) {
        this.f9800q = abstractC0609a2;
        if (abstractC0609a2.l()) {
            throw new IllegalArgumentException("Default instance must be immutable.");
        }
        this.f9801r = (AbstractC0609a2) abstractC0609a2.m(4);
    }

    public static void c(int i, List list) {
        String strK = I1.a.k(list.size() - i, "Element at index ", " is null.");
        int size = list.size();
        while (true) {
            size--;
            if (size < i) {
                throw new NullPointerException(strK);
            }
            list.remove(size);
        }
    }

    /* JADX INFO: renamed from: d, reason: merged with bridge method [inline-methods] */
    public final Z1 clone() {
        Z1 z12 = (Z1) this.f9800q.m(5);
        z12.f9801r = i();
        return z12;
    }

    public final void e(AbstractC0609a2 abstractC0609a2) {
        AbstractC0609a2 abstractC0609a22 = this.f9800q;
        if (abstractC0609a22.equals(abstractC0609a2)) {
            return;
        }
        if (!this.f9801r.l()) {
            AbstractC0609a2 abstractC0609a23 = (AbstractC0609a2) abstractC0609a22.m(4);
            C0723x2.f10064c.a(abstractC0609a23.getClass()).d(abstractC0609a23, this.f9801r);
            this.f9801r = abstractC0609a23;
        }
        AbstractC0609a2 abstractC0609a24 = this.f9801r;
        C0723x2.f10064c.a(abstractC0609a24.getClass()).d(abstractC0609a24, abstractC0609a2);
    }

    public final void f(byte[] bArr, int i, U1 u12) throws C0654j2 {
        if (!this.f9801r.l()) {
            AbstractC0609a2 abstractC0609a2 = (AbstractC0609a2) this.f9800q.m(4);
            C0723x2.f10064c.a(abstractC0609a2.getClass()).d(abstractC0609a2, this.f9801r);
            this.f9801r = abstractC0609a2;
        }
        try {
            A2 a2A = C0723x2.f10064c.a(this.f9801r.getClass());
            AbstractC0609a2 abstractC0609a22 = this.f9801r;
            P1 p1 = new P1();
            u12.getClass();
            a2A.e(abstractC0609a22, bArr, 0, i, p1);
        } catch (C0654j2 e8) {
            throw e8;
        } catch (IOException e9) {
            throw new RuntimeException("Reading from byte array should not throw IOException.", e9);
        } catch (IndexOutOfBoundsException unused) {
            throw new C0654j2("While parsing a protocol message, the input ended unexpectedly in the middle of a field.  This could mean either that the input has been truncated or that an embedded message misreported its own length.");
        }
    }

    public final AbstractC0609a2 h() {
        AbstractC0609a2 abstractC0609a2I = i();
        abstractC0609a2I.getClass();
        boolean zH = true;
        byte bByteValue = ((Byte) abstractC0609a2I.m(1)).byteValue();
        if (bByteValue != 1) {
            if (bByteValue == 0) {
                zH = false;
            } else {
                zH = C0723x2.f10064c.a(abstractC0609a2I.getClass()).h(abstractC0609a2I);
                abstractC0609a2I.m(2);
            }
        }
        if (zH) {
            return abstractC0609a2I;
        }
        throw new A6.b("Message was missing required fields.  (Lite runtime could not determine which fields were missing).");
    }

    public final AbstractC0609a2 i() {
        if (!this.f9801r.l()) {
            return this.f9801r;
        }
        AbstractC0609a2 abstractC0609a2 = this.f9801r;
        abstractC0609a2.getClass();
        C0723x2.f10064c.a(abstractC0609a2.getClass()).b(abstractC0609a2);
        abstractC0609a2.i();
        return this.f9801r;
    }

    public final void k() {
        if (this.f9801r.l()) {
            return;
        }
        AbstractC0609a2 abstractC0609a2 = (AbstractC0609a2) this.f9800q.m(4);
        C0723x2.f10064c.a(abstractC0609a2.getClass()).d(abstractC0609a2, this.f9801r);
        this.f9801r = abstractC0609a2;
    }
}
