package g2;

import i2.a;
import java.io.IOException;
import java.util.Enumeration;
import java.util.Iterator;
import java.util.NoSuchElementException;
import java.util.Objects;

/* JADX INFO: compiled from: ASN1Sequence.java */
/* JADX INFO: loaded from: classes.dex */
public abstract class t extends s implements Iterable {

    /* JADX INFO: renamed from: e, reason: collision with root package name */
    d[] f4741e;

    /* JADX INFO: compiled from: ASN1Sequence.java */
    class a implements Enumeration {

        /* JADX INFO: renamed from: a, reason: collision with root package name */
        private int f4742a = 0;

        a() {
        }

        @Override // java.util.Enumeration
        public boolean hasMoreElements() {
            return this.f4742a < t.this.f4741e.length;
        }

        @Override // java.util.Enumeration
        public Object nextElement() {
            int i3 = this.f4742a;
            d[] dVarArr = t.this.f4741e;
            if (i3 >= dVarArr.length) {
                throw new NoSuchElementException();
            }
            this.f4742a = i3 + 1;
            return dVarArr[i3];
        }
    }

    protected t() {
        this.f4741e = e.f4690d;
    }

    public static t p(Object obj) {
        if (obj == null || (obj instanceof t)) {
            return (t) obj;
        }
        if (obj instanceof u) {
            return p(((u) obj).c());
        }
        if (obj instanceof byte[]) {
            try {
                return p(s.l((byte[]) obj));
            } catch (IOException e3) {
                throw new IllegalArgumentException("failed to construct sequence from byte[]: " + e3.getMessage());
            }
        }
        if (obj instanceof d) {
            s sVarC = ((d) obj).c();
            if (sVarC instanceof t) {
                return (t) sVarC;
            }
        }
        throw new IllegalArgumentException("unknown object in getInstance: " + obj.getClass().getName());
    }

    @Override // g2.s
    boolean h(s sVar) {
        if (!(sVar instanceof t)) {
            return false;
        }
        t tVar = (t) sVar;
        int size = size();
        if (tVar.size() != size) {
            return false;
        }
        for (int i3 = 0; i3 < size; i3++) {
            s sVarC = this.f4741e[i3].c();
            s sVarC2 = tVar.f4741e[i3].c();
            if (sVarC != sVarC2 && !sVarC.h(sVarC2)) {
                return false;
            }
        }
        return true;
    }

    @Override // g2.m
    public int hashCode() {
        int length = this.f4741e.length;
        int iHashCode = length + 1;
        while (true) {
            length--;
            if (length < 0) {
                return iHashCode;
            }
            iHashCode = (iHashCode * 257) ^ this.f4741e[length].c().hashCode();
        }
    }

    @Override // java.lang.Iterable
    public Iterator<d> iterator() {
        return new a.C0067a(this.f4741e);
    }

    @Override // g2.s
    boolean m() {
        return true;
    }

    @Override // g2.s
    s n() {
        return new z0(this.f4741e, false);
    }

    @Override // g2.s
    s o() {
        return new m1(this.f4741e, false);
    }

    public d q(int i3) {
        return this.f4741e[i3];
    }

    public Enumeration r() {
        return new a();
    }

    public int size() {
        return this.f4741e.length;
    }

    public String toString() {
        int size = size();
        if (size == 0) {
            return "[]";
        }
        StringBuffer stringBuffer = new StringBuffer();
        stringBuffer.append('[');
        int i3 = 0;
        while (true) {
            stringBuffer.append(this.f4741e[i3]);
            i3++;
            if (i3 >= size) {
                stringBuffer.append(']');
                return stringBuffer.toString();
            }
            stringBuffer.append(", ");
        }
    }

    protected t(e eVar) {
        Objects.requireNonNull(eVar, "'elementVector' cannot be null");
        this.f4741e = eVar.g();
    }

    t(d[] dVarArr, boolean z2) {
        this.f4741e = z2 ? e.b(dVarArr) : dVarArr;
    }
}
