package q2;

import java.util.ArrayList;
import java.util.List;
import q2.d;

/* loaded from: classes.dex */
public abstract class e {

    /* renamed from: a */
    private static final d f33288a = new d("", null, null, 6, null);

    public static final boolean f(int i10, int i11, int i12, int i13) {
        if (i10 > i12 || i13 > i11) {
            return false;
        }
        if (i11 == i13) {
            if ((i12 == i13) != (i10 == i11)) {
                return false;
            }
        }
        return true;
    }

    public static final d g() {
        return f33288a;
    }

    public static final List h(List list, int i10, int i11) {
        if (!(i10 <= i11)) {
            throw new IllegalArgumentException(("start (" + i10 + ") should be less than or equal to end (" + i11 + ')').toString());
        }
        if (list == null) {
            return null;
        }
        ArrayList arrayList = new ArrayList(list.size());
        int size = list.size();
        for (int i12 = 0; i12 < size; i12++) {
            Object obj = list.get(i12);
            d.c cVar = (d.c) obj;
            if (l(i10, i11, cVar.h(), cVar.f())) {
                arrayList.add(obj);
            }
        }
        ArrayList arrayList2 = new ArrayList(arrayList.size());
        int size2 = arrayList.size();
        for (int i13 = 0; i13 < size2; i13++) {
            d.c cVar2 = (d.c) arrayList.get(i13);
            arrayList2.add(new d.c(cVar2.g(), Math.max(i10, cVar2.h()) - i10, Math.min(i11, cVar2.f()) - i10, cVar2.i()));
        }
        if (arrayList2.isEmpty()) {
            return null;
        }
        return arrayList2;
    }

    public static final List i(d dVar, int i10, int i11) {
        List b10;
        int k10;
        int k11;
        if (i10 == i11 || (b10 = dVar.b()) == null) {
            return null;
        }
        if (i10 == 0 && i11 >= dVar.j().length()) {
            return b10;
        }
        ArrayList arrayList = new ArrayList(b10.size());
        int size = b10.size();
        for (int i12 = 0; i12 < size; i12++) {
            Object obj = b10.get(i12);
            d.c cVar = (d.c) obj;
            if (l(i10, i11, cVar.h(), cVar.f())) {
                arrayList.add(obj);
            }
        }
        ArrayList arrayList2 = new ArrayList(arrayList.size());
        int size2 = arrayList.size();
        for (int i13 = 0; i13 < size2; i13++) {
            d.c cVar2 = (d.c) arrayList.get(i13);
            String i14 = cVar2.i();
            Object g10 = cVar2.g();
            k10 = jn.o.k(cVar2.h(), i10, i11);
            k11 = jn.o.k(cVar2.f(), i10, i11);
            arrayList2.add(new d.c(g10, k10 - i10, k11 - i10, i14));
        }
        return arrayList2;
    }

    public static final List j(d dVar, int i10, int i11) {
        List f10;
        int k10;
        int k11;
        if (i10 == i11 || (f10 = dVar.f()) == null) {
            return null;
        }
        if (i10 == 0 && i11 >= dVar.j().length()) {
            return f10;
        }
        ArrayList arrayList = new ArrayList(f10.size());
        int size = f10.size();
        for (int i12 = 0; i12 < size; i12++) {
            Object obj = f10.get(i12);
            d.c cVar = (d.c) obj;
            if (l(i10, i11, cVar.h(), cVar.f())) {
                arrayList.add(obj);
            }
        }
        ArrayList arrayList2 = new ArrayList(arrayList.size());
        int size2 = arrayList.size();
        for (int i13 = 0; i13 < size2; i13++) {
            d.c cVar2 = (d.c) arrayList.get(i13);
            Object g10 = cVar2.g();
            k10 = jn.o.k(cVar2.h(), i10, i11);
            k11 = jn.o.k(cVar2.f(), i10, i11);
            arrayList2.add(new d.c(g10, k10 - i10, k11 - i10));
        }
        return arrayList2;
    }

    public static final List k(d dVar, int i10, int i11) {
        List h10;
        int k10;
        int k11;
        if (i10 == i11 || (h10 = dVar.h()) == null) {
            return null;
        }
        if (i10 == 0 && i11 >= dVar.j().length()) {
            return h10;
        }
        ArrayList arrayList = new ArrayList(h10.size());
        int size = h10.size();
        for (int i12 = 0; i12 < size; i12++) {
            Object obj = h10.get(i12);
            d.c cVar = (d.c) obj;
            if (l(i10, i11, cVar.h(), cVar.f())) {
                arrayList.add(obj);
            }
        }
        ArrayList arrayList2 = new ArrayList(arrayList.size());
        int size2 = arrayList.size();
        for (int i13 = 0; i13 < size2; i13++) {
            d.c cVar2 = (d.c) arrayList.get(i13);
            Object g10 = cVar2.g();
            k10 = jn.o.k(cVar2.h(), i10, i11);
            k11 = jn.o.k(cVar2.f(), i10, i11);
            arrayList2.add(new d.c(g10, k10 - i10, k11 - i10));
        }
        return arrayList2;
    }

    public static final boolean l(int i10, int i11, int i12, int i13) {
        return Math.max(i10, i12) < Math.min(i11, i13) || f(i10, i11, i12, i13) || f(i12, i13, i10, i11);
    }

    public static final List m(d dVar, u uVar) {
        int length = dVar.j().length();
        List f10 = dVar.f();
        if (f10 == null) {
            f10 = sm.u.k();
        }
        ArrayList arrayList = new ArrayList();
        int size = f10.size();
        int i10 = 0;
        int i11 = 0;
        while (i10 < size) {
            d.c cVar = (d.c) f10.get(i10);
            u uVar2 = (u) cVar.a();
            int b10 = cVar.b();
            int c10 = cVar.c();
            if (b10 != i11) {
                arrayList.add(new d.c(uVar, i11, b10));
            }
            arrayList.add(new d.c(uVar.l(uVar2), b10, c10));
            i10++;
            i11 = c10;
        }
        if (i11 != length) {
            arrayList.add(new d.c(uVar, i11, length));
        }
        if (arrayList.isEmpty()) {
            arrayList.add(new d.c(uVar, 0, 0));
        }
        return arrayList;
    }

    public static final d n(d dVar, int i10, int i11) {
        String str;
        if (i10 != i11) {
            str = dVar.j().substring(i10, i11);
            kotlin.jvm.internal.t.f(str, "this as java.lang.String…ing(startIndex, endIndex)");
        } else {
            str = "";
        }
        return new d(str, k(dVar, i10, i11), null, null, 12, null);
    }
}
