content: package kotlin.collections.builders;
  
  import java.io.Externalizable;
  import java.io.InvalidObjectException;
  import java.io.ObjectInput;
  import java.io.ObjectOutput;
  import java.util.Collection;
  import java.util.List;
  import java.util.Set;
  import kotlin.Metadata;
  import kotlin.collections.CollectionsKt;
  import kotlin.collections.SetsKt;
  import kotlin.jvm.internal.DefaultConstructorMarker;
  import kotlin.jvm.internal.Intrinsics;
  
  @Metadata(d1 = {"\u00006\n\u0002\u0018\u0002\n\u0002\u0018\u0002\n\u0002\b\u0002\n\u0002\u0010\u001e\n\u0000\n\u0002\u0010\b\n\u0002\b\u0002\n\u0002\u0010\u0002\n\u0000\n\u0002\u0018\u0002\n\u0000\n\u0002\u0010\u0000\n\u0002\b\u0002\n\u0002\u0018\u0002\n\u0002\b\u0002\b\u0000\u0018\u0000 \u00112\u00020\u0001:\u0001\u0011B\u0007\b\u0016¢\u0006\u0002\u0010\u0002B\u0019\u0012\n\u0010\u0003\u001a\u0006\u0012\u0002\b\u00030\u0004\u0012\u0006\u0010\u0005\u001a\u00020\u0006¢\u0006\u0002\u0010\u0007J\u0010\u0010\b\u001a\u00020\t2\u0006\u0010\n\u001a\u00020\u000bH\u0016J\b\u0010\f\u001a\u00020\rH\u0002J\u0010\u0010\u000e\u001a\u00020\t2\u0006\u0010\u000f\u001a\u00020\u0010H\u0016R\u0012\u0010\u0003\u001a\u0006\u0012\u0002\b\u00030\u0004X\u000e¢\u0006\u0002\n\u0000R\u000e\u0010\u0005\u001a\u00020\u0006X\u0004¢\u0006\u0002\n\u0000¨\u0006\u0012"}, d2 = {"Lkotlin/collections/builders/SerializedCollection;", "Ljava/io/Externalizable;", "()V", "collection", "", "tag", "", "(Ljava/util/Collection;I)V", "readExternal", "", "input", "Ljava/io/ObjectInput;", "readResolve", "", "writeExternal", "output", "Ljava/io/ObjectOutput;", "Companion", "kotlin-stdlib"}, k = 1, mv = {1, 7, 1}, xi = 48)
  /* compiled from: ListBuilder.kt */
  public final class SerializedCollection implements Externalizable {
      public static final Companion Companion = new Companion((DefaultConstructorMarker) null);
      private static final long serialVersionUID = 0;
      public static final int tagList = 0;
      public static final int tagSet = 1;
      private Collection<?> collection;
      private final int tag;
  
      @Metadata(d1 = {"\u0000\u001a\n\u0002\u0018\u0002\n\u0002\u0010\u0000\n\u0002\b\u0002\n\u0002\u0010\t\n\u0000\n\u0002\u0010\b\n\u0002\b\u0002\b\u0003\u0018\u00002\u00020\u0001B\u0007\b\u0002¢\u0006\u0002\u0010\u0002R\u000e\u0010\u0003\u001a\u00020\u0004XT¢\u0006\u0002\n\u0000R\u000e\u0010\u0005\u001a\u00020\u0006XT¢\u0006\u0002\n\u0000R\u000e\u0010\u0007\u001a\u00020\u0006XT¢\u0006\u0002\n\u0000¨\u0006\b"}, d2 = {"Lkotlin/collections/builders/SerializedCollection$Companion;", "", "()V", "serialVersionUID", "", "tagList", "", "tagSet", "kotlin-stdlib"}, k = 1, mv = {1, 7, 1}, xi = 48)
      /* compiled from: ListBuilder.kt */
      public static final class Companion {
          private Companion() {
          }
  
          public /* synthetic */ Companion(DefaultConstructorMarker defaultConstructorMarker) {
              this();
          }
      }
  
      public SerializedCollection() {
          this(CollectionsKt.emptyList(), 0);
      }
  
      public SerializedCollection(Collection<?> collection2, int tag2) {
          Intrinsics.checkNotNullParameter(collection2, "collection");
          this.collection = collection2;
          this.tag = tag2;
      }
  
      private final Object readResolve() {
          return this.collection;
      }
  
      public void readExternal(ObjectInput input) {
          Collection<?> collection2;
          Intrinsics.checkNotNullParameter(input, "input");
          byte readByte = input.readByte();
          byte b = readByte & 1;
          if ((readByte & -2) == 0) {
              int readInt = input.readInt();
              if (readInt >= 0) {
                  int i = 0;
                  switch (b) {
                      case 0:
                          List createListBuilder = CollectionsKt.createListBuilder(readInt);
                          List list = createListBuilder;
                          while (i < readInt) {
                              int i2 = i;
                              list.add(input.readObject());
                              i++;
                          }
                          collection2 = CollectionsKt.build(createListBuilder);
                          break;
                      case 1:
                          Set createSetBuilder = SetsKt.createSetBuilder(readInt);
                          Set set = createSetBuilder;
                          while (i < readInt) {
                              int i3 = i;
                              set.add(input.readObject());
                              i++;
                          }
                          collection2 = SetsKt.build(createSetBuilder);
                          break;
                      default:
                          throw new InvalidObjectException("Unsupported collection type tag: " + b + '.');
                  }
                  this.collection = collection2;
                  return;
              }
              throw new InvalidObjectException("Illegal size value: " + readInt + '.');
          }
          throw new InvalidObjectException("Unsupported flags value: " + readByte + '.');
      }
  
      public void writeExternal(ObjectOutput output) {
          Intrinsics.checkNotNullParameter(output, "output");
          output.writeByte(this.tag);
          output.writeInt(this.collection.size());
          for (Object writeObject : this.collection) {
              output.writeObject(writeObject);
          }
      }
  }
  