package B3;

import A1.H;
import java.util.Iterator;
import java.util.NoSuchElementException;
import u.AbstractC1563h;
import v0.AbstractC1664c;

/* JADX INFO: loaded from: classes.dex */
public final class k implements Iterator {

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

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

    /* JADX INFO: renamed from: t, reason: collision with root package name */
    public final d f981t;

    /* JADX INFO: renamed from: v, reason: collision with root package name */
    public int f983v;

    /* JADX INFO: renamed from: w, reason: collision with root package name */
    public final /* synthetic */ K4.c f984w;

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

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

    public k(K4.c cVar, H h8, CharSequence charSequence) {
        this.f984w = cVar;
        this.f981t = (d) h8.f66s;
        this.f983v = h8.f65r;
        this.f980s = charSequence;
    }

    @Override // java.util.Iterator
    public final boolean hasNext() {
        String string;
        int i = this.f978q;
        if (i == 4) {
            throw new IllegalStateException();
        }
        int iC = AbstractC1563h.c(i);
        if (iC == 0) {
            return true;
        }
        if (iC == 2) {
            return false;
        }
        this.f978q = 4;
        int i5 = this.f982u;
        while (true) {
            int length = this.f982u;
            if (length == -1) {
                this.f978q = 3;
                string = null;
                break;
            }
            c cVar = (c) this.f984w.f3604r;
            CharSequence charSequence = this.f980s;
            int length2 = charSequence.length();
            AbstractC1664c.h(length, length2);
            while (true) {
                if (length >= length2) {
                    length = -1;
                    break;
                }
                if (cVar.a(charSequence.charAt(length))) {
                    break;
                }
                length++;
            }
            if (length == -1) {
                length = charSequence.length();
                this.f982u = -1;
            } else {
                this.f982u = length + 1;
            }
            int i8 = this.f982u;
            if (i8 == i5) {
                int i9 = i8 + 1;
                this.f982u = i9;
                if (i9 > charSequence.length()) {
                    this.f982u = -1;
                }
            } else {
                d dVar = this.f981t;
                if (i5 < length) {
                    charSequence.charAt(i5);
                    dVar.getClass();
                }
                if (length > i5) {
                    charSequence.charAt(length - 1);
                    dVar.getClass();
                }
                int i10 = this.f983v;
                if (i10 == 1) {
                    length = charSequence.length();
                    this.f982u = -1;
                    if (length > i5) {
                        charSequence.charAt(length - 1);
                        dVar.getClass();
                    }
                } else {
                    this.f983v = i10 - 1;
                }
                string = charSequence.subSequence(i5, length).toString();
            }
        }
        this.f979r = string;
        if (this.f978q == 3) {
            return false;
        }
        this.f978q = 1;
        return true;
    }

    @Override // java.util.Iterator
    public final Object next() {
        if (!hasNext()) {
            throw new NoSuchElementException();
        }
        this.f978q = 2;
        String str = this.f979r;
        this.f979r = null;
        return str;
    }

    @Override // java.util.Iterator
    public final void remove() {
        throw new UnsupportedOperationException();
    }
}
