package kotlinx.serialization.json.internal;

import io.netty.handler.codec.rtsp.RtspHeaders;
import java.util.Iterator;
import kotlin.Metadata;
import kotlin.NoWhenBranchMatchedException;
import kotlin.jvm.internal.o;
import kotlinx.serialization.DeserializationStrategy;
import kotlinx.serialization.json.DecodeSequenceMode;
import kotlinx.serialization.json.Json;

/* JADX INFO: loaded from: classes2.dex */
@Metadata(d1 = {"\u00000\n\u0000\n\u0002\u0010(\n\u0002\b\u0002\n\u0002\u0018\u0002\n\u0000\n\u0002\u0018\u0002\n\u0000\n\u0002\u0018\u0002\n\u0000\n\u0002\u0018\u0002\n\u0000\n\u0002\u0018\u0002\n\u0002\b\u0002\n\u0002\u0010\u000b\n\u0000\u001a:\u0010\u0000\u001a\b\u0012\u0004\u0012\u0002H\u00020\u0001\"\u0004\b\u0000\u0010\u00022\u0006\u0010\u0003\u001a\u00020\u00042\u0006\u0010\u0005\u001a\u00020\u00062\u0006\u0010\u0007\u001a\u00020\b2\f\u0010\t\u001a\b\u0012\u0004\u0012\u0002H\u00020\nH\u0000\u001a\u0014\u0010\u000b\u001a\u00020\u0004*\u00020\f2\u0006\u0010\r\u001a\u00020\u0004H\u0002\u001a\f\u0010\u000e\u001a\u00020\u000f*\u00020\fH\u0002¨\u0006\u0010"}, d2 = {"JsonIterator", "", "T", RtspHeaders.Values.MODE, "Lkotlinx/serialization/json/DecodeSequenceMode;", "json", "Lkotlinx/serialization/json/Json;", "lexer", "Lkotlinx/serialization/json/internal/ReaderJsonLexer;", "deserializer", "Lkotlinx/serialization/DeserializationStrategy;", "determineFormat", "Lkotlinx/serialization/json/internal/AbstractJsonLexer;", "suggested", "tryConsumeStartArray", "", "kotlinx-serialization-json"}, k = 2, mv = {1, 7, 1}, xi = 48)
public final class JsonIteratorKt {

    @Metadata(k = 3, mv = {1, 7, 1}, xi = 48)
    public /* synthetic */ class WhenMappings {
        public static final /* synthetic */ int[] $EnumSwitchMapping$0;

        static {
            DecodeSequenceMode.values();
            int[] iArr = new int[3];
            try {
                iArr[DecodeSequenceMode.WHITESPACE_SEPARATED.ordinal()] = 1;
            } catch (NoSuchFieldError unused) {
            }
            try {
                iArr[DecodeSequenceMode.ARRAY_WRAPPED.ordinal()] = 2;
            } catch (NoSuchFieldError unused2) {
            }
            try {
                iArr[DecodeSequenceMode.AUTO_DETECT.ordinal()] = 3;
            } catch (NoSuchFieldError unused3) {
            }
            $EnumSwitchMapping$0 = iArr;
        }
    }

    public static final <T> Iterator<T> JsonIterator(DecodeSequenceMode decodeSequenceMode, Json json, ReaderJsonLexer readerJsonLexer, DeserializationStrategy<T> deserializationStrategy) {
        o.f(decodeSequenceMode, RtspHeaders.Values.MODE);
        o.f(json, "json");
        o.f(readerJsonLexer, "lexer");
        o.f(deserializationStrategy, "deserializer");
        int iOrdinal = determineFormat(readerJsonLexer, decodeSequenceMode).ordinal();
        if (iOrdinal == 0) {
            return new JsonIteratorWsSeparated(json, readerJsonLexer, deserializationStrategy);
        }
        if (iOrdinal == 1) {
            return new JsonIteratorArrayWrapped(json, readerJsonLexer, deserializationStrategy);
        }
        if (iOrdinal != 2) {
            throw new NoWhenBranchMatchedException();
        }
        throw new IllegalStateException("AbstractJsonLexer.determineFormat must be called beforehand.".toString());
    }

    /* JADX WARN: Code restructure failed: missing block: B:9:0x0010, code lost:
    
        if (tryConsumeStartArray(r1) != false) goto L15;
     */
    /*
        Code decompiled incorrectly, please refer to instructions dump.
        To view partially-correct add '--show-bad-code' argument
    */
    private static final kotlinx.serialization.json.DecodeSequenceMode determineFormat(kotlinx.serialization.json.internal.AbstractJsonLexer r1, kotlinx.serialization.json.DecodeSequenceMode r2) {
        /*
            int r2 = r2.ordinal()
            if (r2 == 0) goto L2d
            r0 = 1
            if (r2 == r0) goto L19
            r0 = 2
            if (r2 != r0) goto L13
            boolean r1 = tryConsumeStartArray(r1)
            if (r1 == 0) goto L2d
            goto L1f
        L13:
            r.i r1 = new r.i
            r1.<init>()
            throw r1
        L19:
            boolean r2 = tryConsumeStartArray(r1)
            if (r2 == 0) goto L22
        L1f:
            kotlinx.serialization.json.DecodeSequenceMode r1 = kotlinx.serialization.json.DecodeSequenceMode.ARRAY_WRAPPED
            goto L2f
        L22:
            r2 = 8
            r1.fail$kotlinx_serialization_json(r2)
            r.e r1 = new r.e
            r1.<init>()
            throw r1
        L2d:
            kotlinx.serialization.json.DecodeSequenceMode r1 = kotlinx.serialization.json.DecodeSequenceMode.WHITESPACE_SEPARATED
        L2f:
            return r1
        */
        throw new UnsupportedOperationException("Method not decompiled: kotlinx.serialization.json.internal.JsonIteratorKt.determineFormat(kotlinx.serialization.json.internal.AbstractJsonLexer, kotlinx.serialization.json.DecodeSequenceMode):kotlinx.serialization.json.DecodeSequenceMode");
    }

    private static final boolean tryConsumeStartArray(AbstractJsonLexer abstractJsonLexer) {
        if (abstractJsonLexer.peekNextToken() != 8) {
            return false;
        }
        abstractJsonLexer.consumeNextToken((byte) 8);
        return true;
    }
}
