package S4;

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

/* JADX INFO: loaded from: classes3.dex */
public final class h implements Iterator, K4.a {

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

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

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

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

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

    public h(String string) {
        kotlin.jvm.internal.o.h(string, "string");
        this.f6278a = string;
    }

    @Override // java.util.Iterator
    public final boolean hasNext() {
        int i6;
        int i7;
        int i8 = this.f6279b;
        if (i8 != 0) {
            return i8 == 1;
        }
        if (this.f6282e < 0) {
            this.f6279b = 2;
            return false;
        }
        String str = this.f6278a;
        int length = str.length();
        int length2 = str.length();
        for (int i9 = this.f6280c; i9 < length2; i9++) {
            char cCharAt = str.charAt(i9);
            if (cCharAt == '\n' || cCharAt == '\r') {
                i6 = (cCharAt == '\r' && (i7 = i9 + 1) < str.length() && str.charAt(i7) == '\n') ? 2 : 1;
                length = i9;
                this.f6279b = 1;
                this.f6282e = i6;
                this.f6281d = length;
                return true;
            }
        }
        i6 = -1;
        this.f6279b = 1;
        this.f6282e = i6;
        this.f6281d = length;
        return true;
    }

    @Override // java.util.Iterator
    public final Object next() {
        if (!hasNext()) {
            throw new NoSuchElementException();
        }
        this.f6279b = 0;
        int i6 = this.f6281d;
        int i7 = this.f6280c;
        this.f6280c = this.f6282e + i6;
        return this.f6278a.subSequence(i7, i6).toString();
    }

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