package X6;

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

/* JADX INFO: loaded from: classes.dex */
public final class c implements Iterator, Q6.a {

    /* JADX INFO: renamed from: q, reason: collision with root package name */
    public final String f7243q;

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

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

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

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

    public c(String str) {
        P6.g.e(str, "string");
        this.f7243q = str;
    }

    @Override // java.util.Iterator
    public final boolean hasNext() {
        int i;
        int i5;
        int i8 = this.f7244r;
        if (i8 != 0) {
            return i8 == 1;
        }
        if (this.f7247u < 0) {
            this.f7244r = 2;
            return false;
        }
        String str = this.f7243q;
        int length = str.length();
        int length2 = str.length();
        for (int i9 = this.f7245s; i9 < length2; i9++) {
            char cCharAt = str.charAt(i9);
            if (cCharAt == '\n' || cCharAt == '\r') {
                i = (cCharAt == '\r' && (i5 = i9 + 1) < str.length() && str.charAt(i5) == '\n') ? 2 : 1;
                length = i9;
                this.f7244r = 1;
                this.f7247u = i;
                this.f7246t = length;
                return true;
            }
        }
        i = -1;
        this.f7244r = 1;
        this.f7247u = i;
        this.f7246t = length;
        return true;
    }

    @Override // java.util.Iterator
    public final Object next() {
        if (!hasNext()) {
            throw new NoSuchElementException();
        }
        this.f7244r = 0;
        int i = this.f7246t;
        int i5 = this.f7245s;
        this.f7245s = this.f7247u + i;
        return this.f7243q.subSequence(i5, i).toString();
    }

    @Override // java.util.Iterator
    public final void remove() {
        throw new UnsupportedOperationException("Operation is not supported for read-only collection");
    }
}
