package o; import com.google.common.primitives.UnsignedBytes; import java.io.IOException; import java.util.Enumeration; import java.util.Iterator; import java.util.Vector; import o.grK; import org.bouncycastle.asn1.ASN1Encoding; /* renamed from: o.gnI, reason: case insensitive filesystem */ /* loaded from: classes6.dex */ public abstract class AbstractC15318gnI extends AbstractC15315gnE implements InterfaceC15464grI { private boolean b; public Vector d; /* JADX INFO: Access modifiers changed from: package-private */ @Override // o.AbstractC15315gnE public abstract void c(gnG gng) throws IOException; /* JADX INFO: Access modifiers changed from: package-private */ @Override // o.AbstractC15315gnE public final boolean d() { return true; } public static AbstractC15318gnI c(Object obj) { while (obj != null && !(obj instanceof AbstractC15318gnI)) { if (obj instanceof gnJ) { obj = ((gnJ) obj).i(); } else { if (obj instanceof byte[]) { try { return c((Object) AbstractC15315gnE.b((byte[]) obj)); } catch (IOException e) { StringBuilder sb = new StringBuilder("failed to construct set from byte[]: "); sb.append(e.getMessage()); throw new IllegalArgumentException(sb.toString()); } } if (obj instanceof InterfaceC15342gnr) { AbstractC15315gnE i = ((InterfaceC15342gnr) obj).i(); if (i instanceof AbstractC15318gnI) { return (AbstractC15318gnI) i; } } StringBuilder sb2 = new StringBuilder("unknown object in getInstance: "); sb2.append(obj.getClass().getName()); throw new IllegalArgumentException(sb2.toString()); } } return (AbstractC15318gnI) obj; } /* JADX INFO: Access modifiers changed from: protected */ public AbstractC15318gnI() { this.d = new Vector(); this.b = false; } /* JADX INFO: Access modifiers changed from: protected */ public AbstractC15318gnI(InterfaceC15342gnr interfaceC15342gnr) { Vector vector = new Vector(); this.d = vector; this.b = false; vector.addElement(interfaceC15342gnr); } /* JADX INFO: Access modifiers changed from: protected */ public AbstractC15318gnI(C15343gns c15343gns, boolean z) { this.d = new Vector(); this.b = false; for (int i = 0; i != c15343gns.a.size(); i++) { this.d.addElement((InterfaceC15342gnr) c15343gns.a.elementAt(i)); } if (z) { a(); } } /* JADX INFO: Access modifiers changed from: protected */ public AbstractC15318gnI(InterfaceC15342gnr[] interfaceC15342gnrArr) { this.d = new Vector(); this.b = false; for (int i = 0; i != interfaceC15342gnrArr.length; i++) { this.d.addElement(interfaceC15342gnrArr[i]); } } private InterfaceC15342gnr[] b() { InterfaceC15342gnr[] interfaceC15342gnrArr = new InterfaceC15342gnr[this.d.size()]; for (int i = 0; i != this.d.size(); i++) { interfaceC15342gnrArr[i] = (InterfaceC15342gnr) this.d.elementAt(i); } return interfaceC15342gnrArr; } @Override // o.AbstractC15346gnv public int hashCode() { Enumeration elements = this.d.elements(); int size = this.d.size(); while (elements.hasMoreElements()) { Object obj = (InterfaceC15342gnr) elements.nextElement(); if (obj == null) { obj = C15380got.a; } size = (size * 17) ^ obj.hashCode(); } return size; } /* JADX INFO: Access modifiers changed from: package-private */ @Override // o.AbstractC15315gnE public final AbstractC15315gnE h() { if (this.b) { C15384gox c15384gox = new C15384gox(); c15384gox.d = this.d; return c15384gox; } Vector vector = new Vector(); for (int i = 0; i != this.d.size(); i++) { vector.addElement(this.d.elementAt(i)); } C15384gox c15384gox2 = new C15384gox(); c15384gox2.d = vector; c15384gox2.a(); return c15384gox2; } /* JADX INFO: Access modifiers changed from: package-private */ @Override // o.AbstractC15315gnE public final AbstractC15315gnE f() { C15356goJ c15356goJ = new C15356goJ(); c15356goJ.d = this.d; return c15356goJ; } /* JADX INFO: Access modifiers changed from: package-private */ @Override // o.AbstractC15315gnE protected final boolean e(AbstractC15315gnE abstractC15315gnE) { if (!(abstractC15315gnE instanceof AbstractC15318gnI)) { return false; } AbstractC15318gnI abstractC15318gnI = (AbstractC15318gnI) abstractC15315gnE; if (this.d.size() != abstractC15318gnI.d.size()) { return false; } Enumeration elements = this.d.elements(); Enumeration elements2 = abstractC15318gnI.d.elements(); while (elements.hasMoreElements()) { InterfaceC15342gnr interfaceC15342gnr = (InterfaceC15342gnr) elements.nextElement(); if (interfaceC15342gnr == null) { interfaceC15342gnr = C15380got.a; } InterfaceC15342gnr interfaceC15342gnr2 = (InterfaceC15342gnr) elements2.nextElement(); if (interfaceC15342gnr2 == null) { interfaceC15342gnr2 = C15380got.a; } AbstractC15315gnE i = interfaceC15342gnr.i(); AbstractC15315gnE i2 = interfaceC15342gnr2.i(); if (i != i2 && !i.equals(i2)) { return false; } } return true; } private static boolean d(byte[] bArr, byte[] bArr2) { int min = Math.min(bArr.length, bArr2.length); for (int i = 0; i != min; i++) { byte b = bArr[i]; byte b2 = bArr2[i]; if (b != b2) { return (b & UnsignedBytes.MAX_VALUE) < (b2 & UnsignedBytes.MAX_VALUE); } } return min == bArr.length; } private static byte[] c(InterfaceC15342gnr interfaceC15342gnr) { try { return interfaceC15342gnr.i().c(ASN1Encoding.DER); } catch (IOException unused) { throw new IllegalArgumentException("cannot encode object added to SET"); } } private void a() { if (this.b) { return; } this.b = true; if (this.d.size() > 1) { int size = this.d.size() - 1; boolean z = true; while (z) { int i = 0; byte[] c = c((InterfaceC15342gnr) this.d.elementAt(0)); z = false; int i2 = 0; while (i2 != size) { int i3 = i2 + 1; byte[] c2 = c((InterfaceC15342gnr) this.d.elementAt(i3)); if (d(c, c2)) { c = c2; } else { Object elementAt = this.d.elementAt(i2); Vector vector = this.d; vector.setElementAt(vector.elementAt(i3), i2); this.d.setElementAt(elementAt, i3); z = true; i = i2; } i2 = i3; } size = i; } } } public String toString() { return this.d.toString(); } @Override // java.lang.Iterable public Iterator iterator() { return new grK.RVV(b()); } public static AbstractC15318gnI b(AbstractC15321gnP abstractC15321gnP) { if (abstractC15321gnP.a) { if (abstractC15321gnP instanceof C15361goa) { InterfaceC15342gnr interfaceC15342gnr = abstractC15321gnP.d; return new C15364god(interfaceC15342gnr != null ? interfaceC15342gnr.i() : null); } InterfaceC15342gnr interfaceC15342gnr2 = abstractC15321gnP.d; return new C15356goJ(interfaceC15342gnr2 != null ? interfaceC15342gnr2.i() : null); } InterfaceC15342gnr interfaceC15342gnr3 = abstractC15321gnP.d; if ((interfaceC15342gnr3 != null ? interfaceC15342gnr3.i() : null) instanceof AbstractC15318gnI) { InterfaceC15342gnr interfaceC15342gnr4 = abstractC15321gnP.d; return (AbstractC15318gnI) (interfaceC15342gnr4 != null ? interfaceC15342gnr4.i() : null); } InterfaceC15342gnr interfaceC15342gnr5 = abstractC15321gnP.d; if ((interfaceC15342gnr5 != null ? interfaceC15342gnr5.i() : null) instanceof AbstractC15317gnH) { InterfaceC15342gnr interfaceC15342gnr6 = abstractC15321gnP.d; AbstractC15317gnH abstractC15317gnH = (AbstractC15317gnH) (interfaceC15342gnr6 != null ? interfaceC15342gnr6.i() : null); if (abstractC15321gnP instanceof C15361goa) { return new C15364god(abstractC15317gnH.a()); } return new C15356goJ(abstractC15317gnH.a()); } StringBuilder sb = new StringBuilder("unknown object in getInstance: "); sb.append(abstractC15321gnP.getClass().getName()); throw new IllegalArgumentException(sb.toString()); } }