package j.u0;

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

/* JADX INFO: compiled from: Strings.kt */
/* JADX INFO: loaded from: classes.dex */
final class e implements j.t0.c<j.r0.h> {
    private final CharSequence a;
    private final int b;
    private final int c;
    private final j.p0.c.p<CharSequence, Integer, j.p<Integer, Integer>> d;

    /* JADX INFO: compiled from: Strings.kt */
    public static final class a implements Iterator<j.r0.h>, j.p0.d.i0.a {
        private int b = -1;
        private int d;
        private int e;
        private j.r0.h f;

        /* JADX INFO: renamed from: g, reason: collision with root package name */
        private int f889g;

        a() {
            int iD = j.r0.n.d(e.this.b, 0, e.this.a.length());
            this.d = iD;
            this.e = iD;
        }

        /* JADX WARN: Removed duplicated region for block: B:9:0x0023  */
        /*
            Code decompiled incorrectly, please refer to instructions dump.
            To view partially-correct add '--show-bad-code' argument
        */
        private final void b() {
            /*
                r6 = this;
                int r0 = r6.e
                r1 = 0
                if (r0 >= 0) goto Lc
                r6.b = r1
                r0 = 0
                r6.f = r0
                goto L9e
            Lc:
                j.u0.e r0 = j.u0.e.this
                int r0 = j.u0.e.d(r0)
                r2 = -1
                r3 = 1
                if (r0 <= 0) goto L23
                int r0 = r6.f889g
                int r0 = r0 + r3
                r6.f889g = r0
                j.u0.e r4 = j.u0.e.this
                int r4 = j.u0.e.d(r4)
                if (r0 >= r4) goto L31
            L23:
                int r0 = r6.e
                j.u0.e r4 = j.u0.e.this
                java.lang.CharSequence r4 = j.u0.e.c(r4)
                int r4 = r4.length()
                if (r0 <= r4) goto L47
            L31:
                j.r0.h r0 = new j.r0.h
                int r1 = r6.d
                j.u0.e r4 = j.u0.e.this
                java.lang.CharSequence r4 = j.u0.e.c(r4)
                int r4 = j.u0.h.N(r4)
                r0.<init>(r1, r4)
                r6.f = r0
                r6.e = r2
                goto L9c
            L47:
                j.u0.e r0 = j.u0.e.this
                j.p0.c.p r0 = j.u0.e.b(r0)
                j.u0.e r4 = j.u0.e.this
                java.lang.CharSequence r4 = j.u0.e.c(r4)
                int r5 = r6.e
                java.lang.Integer r5 = java.lang.Integer.valueOf(r5)
                java.lang.Object r0 = r0.d(r4, r5)
                j.p r0 = (j.p) r0
                if (r0 != 0) goto L77
                j.r0.h r0 = new j.r0.h
                int r1 = r6.d
                j.u0.e r4 = j.u0.e.this
                java.lang.CharSequence r4 = j.u0.e.c(r4)
                int r4 = j.u0.h.N(r4)
                r0.<init>(r1, r4)
                r6.f = r0
                r6.e = r2
                goto L9c
            L77:
                java.lang.Object r2 = r0.a()
                java.lang.Number r2 = (java.lang.Number) r2
                int r2 = r2.intValue()
                java.lang.Object r0 = r0.b()
                java.lang.Number r0 = (java.lang.Number) r0
                int r0 = r0.intValue()
                int r4 = r6.d
                j.r0.h r4 = j.r0.l.h(r4, r2)
                r6.f = r4
                int r2 = r2 + r0
                r6.d = r2
                if (r0 != 0) goto L99
                r1 = r3
            L99:
                int r2 = r2 + r1
                r6.e = r2
            L9c:
                r6.b = r3
            L9e:
                return
            */
            throw new UnsupportedOperationException("Method not decompiled: j.u0.e.a.b():void");
        }

        @Override // java.util.Iterator
        /* JADX INFO: renamed from: c, reason: merged with bridge method [inline-methods] */
        public j.r0.h next() {
            if (this.b == -1) {
                b();
            }
            if (this.b == 0) {
                throw new NoSuchElementException();
            }
            j.r0.h hVar = this.f;
            j.p0.d.r.d(hVar, "null cannot be cast to non-null type kotlin.ranges.IntRange");
            this.f = null;
            this.b = -1;
            return hVar;
        }

        @Override // java.util.Iterator
        public boolean hasNext() {
            if (this.b == -1) {
                b();
            }
            return this.b == 1;
        }

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

    /* JADX WARN: Multi-variable type inference failed */
    public e(CharSequence charSequence, int i2, int i3, j.p0.c.p<? super CharSequence, ? super Integer, j.p<Integer, Integer>> pVar) {
        j.p0.d.r.f(charSequence, "input");
        j.p0.d.r.f(pVar, "getNextMatch");
        this.a = charSequence;
        this.b = i2;
        this.c = i3;
        this.d = pVar;
    }

    @Override // j.t0.c
    public Iterator<j.r0.h> iterator() {
        return new a();
    }
}
