package o;

import java.io.Externalizable;
import java.io.IOException;
import java.io.InvalidObjectException;
import java.io.ObjectInput;
import java.io.ObjectOutput;
import java.util.AbstractCollection;
import java.util.Iterator;

/* compiled from: r8-map-id-3b7cc9102578c509342fa2f0fabed2bfc72239cd258d579fc679bfcbc198b048 */
/* loaded from: classes.dex */
public final class P60 implements Externalizable {
    private static final long serialVersionUID = 0;
    public AbstractCollection l;
    public final int m;

    public P60(AbstractCollection abstractCollection, int i) {
        this.l = abstractCollection;
        this.m = i;
    }

    private final Object readResolve() {
        return this.l;
    }

    @Override // java.io.Externalizable
    public final void readExternal(ObjectInput objectInput) throws IOException {
        AbstractCollection abstractCollectionI;
        byte b = objectInput.readByte();
        int i = b & 1;
        if ((b & (-2)) != 0) {
            throw new InvalidObjectException("Unsupported flags value: " + ((int) b) + '.');
        }
        int i2 = objectInput.readInt();
        if (i2 < 0) {
            throw new InvalidObjectException("Illegal size value: " + i2 + '.');
        }
        int i3 = 0;
        if (i == 0) {
            HL hl = new HL(i2);
            while (i3 < i2) {
                hl.add(objectInput.readObject());
                i3++;
            }
            abstractCollectionI = AbstractC0662Zn.i(hl);
        } else {
            if (i != 1) {
                throw new InvalidObjectException("Unsupported collection type tag: " + i + '.');
            }
            C2216q70 c2216q70 = new C2216q70(new C2803wN(i2));
            while (i3 < i2) {
                c2216q70.add(objectInput.readObject());
                i3++;
            }
            abstractCollectionI = AbstractC0940cn0.e(c2216q70);
        }
        this.l = abstractCollectionI;
    }

    @Override // java.io.Externalizable
    public final void writeExternal(ObjectOutput objectOutput) throws IOException {
        objectOutput.writeByte(this.m);
        objectOutput.writeInt(this.l.size());
        Iterator it = this.l.iterator();
        while (it.hasNext()) {
            objectOutput.writeObject(it.next());
        }
    }
}
