package com.google.android.gms.internal.ads;

import java.util.Iterator;
import java.util.NoSuchElementException;

/* JADX INFO: loaded from: classes2.dex */
public abstract class sq1 implements Iterator {

    /* JADX INFO: renamed from: a, reason: collision with root package name */
    public String f16548a;

    /* JADX INFO: renamed from: c, reason: collision with root package name */
    public final CharSequence f16550c;

    /* JADX INFO: renamed from: b, reason: collision with root package name */
    public int f16549b = 2;

    /* JADX INFO: renamed from: d, reason: collision with root package name */
    public int f16551d = 0;

    /* JADX INFO: renamed from: e, reason: collision with root package name */
    public int f16552e = Integer.MAX_VALUE;

    public sq1(CharSequence charSequence) {
        this.f16550c = charSequence;
    }

    @Override // java.util.Iterator
    /* JADX INFO: renamed from: a, reason: merged with bridge method [inline-methods] */
    public final boolean hasNext() {
        int iE;
        ih1.b1(this.f16549b != 4);
        int i10 = this.f16549b;
        int i11 = i10 - 1;
        String string = null;
        if (i10 == 0) {
            throw null;
        }
        if (i11 == 0) {
            return true;
        }
        if (i11 != 2) {
            this.f16549b = 4;
            int i12 = this.f16551d;
            while (true) {
                int i13 = this.f16551d;
                if (i13 == -1) {
                    this.f16549b = 3;
                    break;
                }
                int iD = d(i13);
                CharSequence charSequence = this.f16550c;
                if (iD == -1) {
                    iD = charSequence.length();
                    this.f16551d = -1;
                    iE = -1;
                } else {
                    iE = e(iD);
                    this.f16551d = iE;
                }
                if (iE == i12) {
                    int i14 = iE + 1;
                    this.f16551d = i14;
                    if (i14 > charSequence.length()) {
                        this.f16551d = -1;
                    }
                } else {
                    if (i12 < iD) {
                        charSequence.charAt(i12);
                    }
                    if (i12 < iD) {
                        charSequence.charAt(iD - 1);
                    }
                    int i15 = this.f16552e;
                    if (i15 == 1) {
                        iD = charSequence.length();
                        this.f16551d = -1;
                        if (iD > i12) {
                            charSequence.charAt(iD - 1);
                        }
                    } else {
                        this.f16552e = i15 - 1;
                    }
                    string = charSequence.subSequence(i12, iD).toString();
                }
            }
            this.f16548a = string;
            if (this.f16549b != 3) {
                this.f16549b = 1;
                return true;
            }
        }
        return false;
    }

    @Override // java.util.Iterator
    /* JADX INFO: renamed from: b, reason: merged with bridge method [inline-methods] */
    public final Object next() {
        if (!hasNext()) {
            throw new NoSuchElementException();
        }
        this.f16549b = 2;
        String str = this.f16548a;
        this.f16548a = null;
        return str;
    }

    public final void c() {
        throw new UnsupportedOperationException();
    }

    public abstract int d(int i10);

    public abstract int e(int i10);

    @Override // java.util.Iterator
    public final /* bridge */ /* synthetic */ void remove() {
        c();
        throw null;
    }
}
