package p138.p176.p177.p190;

import android.util.Pair;
import p000.p001.p002.p003.p004.C0567;
import p138.p176.p177.p190.AbstractC3457;
import p138.p176.p177.p190.p217.InterfaceC3800;
import p138.p176.p177.p190.p217.p218.C3831;

/* JADX INFO: renamed from: ދ.ހ.֏.ؠ.ޟ, reason: contains not printable characters */
/* JADX INFO: loaded from: classes.dex */
public final class C3437 {

    /* JADX INFO: renamed from: ހ, reason: contains not printable characters */
    public long f10138;

    /* JADX INFO: renamed from: ނ, reason: contains not printable characters */
    public int f10140;

    /* JADX INFO: renamed from: ރ, reason: contains not printable characters */
    public boolean f10141;

    /* JADX INFO: renamed from: ބ, reason: contains not printable characters */
    public C3435 f10142;

    /* JADX INFO: renamed from: ޅ, reason: contains not printable characters */
    public C3435 f10143;

    /* JADX INFO: renamed from: ކ, reason: contains not printable characters */
    public C3435 f10144;

    /* JADX INFO: renamed from: އ, reason: contains not printable characters */
    public int f10145;

    /* JADX INFO: renamed from: ވ, reason: contains not printable characters */
    public Object f10146;

    /* JADX INFO: renamed from: މ, reason: contains not printable characters */
    public long f10147;

    /* JADX INFO: renamed from: ֏, reason: contains not printable characters */
    public final AbstractC3457.C3459 f10136 = new AbstractC3457.C3459();

    /* JADX INFO: renamed from: ؠ, reason: contains not printable characters */
    public final AbstractC3457.C3460 f10137 = new AbstractC3457.C3460();

    /* JADX INFO: renamed from: ށ, reason: contains not printable characters */
    public AbstractC3457 f10139 = AbstractC3457.f10223;

    /* JADX INFO: renamed from: ֏, reason: contains not printable characters */
    public C3435 m5612() {
        C3435 c3435 = this.f10142;
        if (c3435 == null) {
            return null;
        }
        if (c3435 == this.f10143) {
            this.f10143 = c3435.f10125;
        }
        this.f10142.m5611();
        int i = this.f10145 - 1;
        this.f10145 = i;
        if (i == 0) {
            this.f10144 = null;
            C3435 c34352 = this.f10142;
            this.f10146 = c34352.f10116;
            this.f10147 = c34352.f10120.f10129.f11632;
        }
        C3435 c34353 = this.f10142.f10125;
        this.f10142 = c34353;
        return c34353;
    }

    /* JADX INFO: renamed from: ֏, reason: contains not printable characters */
    public final C3436 m5613(Object obj, int i, int i2, long j, long j2) {
        InterfaceC3800.C3801 c3801 = new InterfaceC3800.C3801(obj, i, i2, j2);
        return new C3436(c3801, i2 == this.f10136.f10228.f11791[i].m6210(-1) ? this.f10136.f10228.f11792 : 0L, j, -9223372036854775807L, this.f10139.m5683(c3801.f11629, this.f10136).m5689(c3801.f11630, c3801.f11631), false, false);
    }

    /* JADX INFO: renamed from: ֏, reason: contains not printable characters */
    public final C3436 m5614(Object obj, long j, long j2) {
        int iM5687 = this.f10136.m5687(j);
        InterfaceC3800.C3801 c3801 = new InterfaceC3800.C3801(obj, j2, iM5687);
        boolean z = !c3801.m6122() && c3801.f11633 == -1;
        boolean zM5622 = m5622(c3801, z);
        long jM5688 = iM5687 != -1 ? this.f10136.m5688(iM5687) : -9223372036854775807L;
        return new C3436(c3801, j, -9223372036854775807L, jM5688, (jM5688 == -9223372036854775807L || jM5688 == Long.MIN_VALUE) ? this.f10136.f10226 : jM5688, z, zM5622);
    }

    /* JADX INFO: renamed from: ֏, reason: contains not printable characters */
    public final C3436 m5615(C3435 c3435, long j) {
        long jLongValue;
        Object obj;
        long j2;
        long j3;
        long j4;
        C3436 c3436 = c3435.f10120;
        long j5 = (c3435.f10128 + c3436.f10133) - j;
        long j6 = 0;
        if (c3436.f10134) {
            int iM5679 = this.f10139.m5679(this.f10139.mo1223(c3436.f10129.f11629), this.f10136, this.f10137, this.f10140, this.f10141);
            if (iM5679 == -1) {
                return null;
            }
            int i = this.f10139.mo1225(iM5679, this.f10136, true).f10225;
            Object obj2 = this.f10136.f10224;
            long j7 = c3436.f10129.f11632;
            if (this.f10139.m5684(i, this.f10137).f10235 == iM5679) {
                Pair<Object, Long> pairM5681 = this.f10139.m5681(this.f10137, this.f10136, i, -9223372036854775807L, Math.max(0L, j5));
                if (pairM5681 == null) {
                    return null;
                }
                Object obj3 = pairM5681.first;
                long jLongValue2 = ((Long) pairM5681.second).longValue();
                C3435 c34352 = c3435.f10125;
                if (c34352 == null || !c34352.f10116.equals(obj3)) {
                    j4 = this.f10138;
                    this.f10138 = 1 + j4;
                } else {
                    j4 = c34352.f10120.f10129.f11632;
                }
                j3 = jLongValue2;
                j6 = -9223372036854775807L;
                j2 = j4;
                obj = obj3;
            } else {
                obj = obj2;
                j2 = j7;
                j3 = 0;
            }
            return m5617(m5623(obj, j3, j2), j6, j3);
        }
        InterfaceC3800.C3801 c3801 = c3436.f10129;
        this.f10139.m5683(c3801.f11629, this.f10136);
        if (!c3801.m6122()) {
            int iM5691 = this.f10136.m5691(c3436.f10132);
            if (iM5691 == -1) {
                return m5614(c3801.f11629, c3436.f10133, c3801.f11632);
            }
            int iM5690 = this.f10136.m5690(iM5691);
            if (this.f10136.m5692(iM5691, iM5690)) {
                return m5613(c3801.f11629, iM5691, iM5690, c3436.f10133, c3801.f11632);
            }
            return null;
        }
        int i2 = c3801.f11630;
        C3831.C3832[] c3832Arr = this.f10136.f10228.f11791;
        int i3 = c3832Arr[i2].f11794;
        if (i3 == -1) {
            return null;
        }
        int iM6210 = c3832Arr[i2].m6210(c3801.f11631);
        if (iM6210 < i3) {
            if (this.f10136.m5692(i2, iM6210)) {
                return m5613(c3801.f11629, i2, iM6210, c3436.f10131, c3801.f11632);
            }
            return null;
        }
        long j8 = c3436.f10131;
        if (j8 == -9223372036854775807L) {
            AbstractC3457 abstractC3457 = this.f10139;
            AbstractC3457.C3460 c3460 = this.f10137;
            AbstractC3457.C3459 c3459 = this.f10136;
            Pair<Object, Long> pairM56812 = abstractC3457.m5681(c3460, c3459, c3459.f10225, -9223372036854775807L, Math.max(0L, j5));
            if (pairM56812 == null) {
                return null;
            }
            jLongValue = ((Long) pairM56812.second).longValue();
        } else {
            jLongValue = j8;
        }
        return m5614(c3801.f11629, jLongValue, c3801.f11632);
    }

    /* JADX INFO: renamed from: ֏, reason: contains not printable characters */
    public C3436 m5616(C3436 c3436) {
        long jM5689;
        InterfaceC3800.C3801 c3801 = c3436.f10129;
        boolean z = !c3801.m6122() && c3801.f11633 == -1;
        boolean zM5622 = m5622(c3801, z);
        this.f10139.m5683(c3436.f10129.f11629, this.f10136);
        if (c3801.m6122()) {
            jM5689 = this.f10136.m5689(c3801.f11630, c3801.f11631);
        } else {
            jM5689 = c3436.f10132;
            if (jM5689 == -9223372036854775807L || jM5689 == Long.MIN_VALUE) {
                jM5689 = this.f10136.f10226;
            }
        }
        return new C3436(c3801, c3436.f10130, c3436.f10131, c3436.f10132, jM5689, z, zM5622);
    }

    /* JADX INFO: renamed from: ֏, reason: contains not printable characters */
    public final C3436 m5617(InterfaceC3800.C3801 c3801, long j, long j2) {
        this.f10139.m5683(c3801.f11629, this.f10136);
        if (!c3801.m6122()) {
            return m5614(c3801.f11629, j2, c3801.f11632);
        }
        if (this.f10136.m5692(c3801.f11630, c3801.f11631)) {
            return m5613(c3801.f11629, c3801.f11630, c3801.f11631, j, c3801.f11632);
        }
        return null;
    }

    /* JADX INFO: renamed from: ֏, reason: contains not printable characters */
    public InterfaceC3800.C3801 m5618(Object obj, long j) {
        long j2;
        int iMo1223;
        AbstractC3457 abstractC3457 = this.f10139;
        int i = abstractC3457.mo1225(abstractC3457.mo1223(obj), this.f10136, true).f10225;
        Object obj2 = this.f10146;
        if (obj2 == null || (iMo1223 = this.f10139.mo1223(obj2)) == -1 || this.f10139.m5682(iMo1223, this.f10136).f10225 != i) {
            C3435 c3435 = this.f10142;
            while (true) {
                if (c3435 == null) {
                    C3435 c34352 = this.f10142;
                    while (true) {
                        if (c34352 != null) {
                            int iMo12232 = this.f10139.mo1223(c34352.f10116);
                            if (iMo12232 != -1 && this.f10139.m5682(iMo12232, this.f10136).f10225 == i) {
                                j2 = c34352.f10120.f10129.f11632;
                                break;
                            }
                            c34352 = c34352.f10125;
                        } else {
                            j2 = this.f10138;
                            this.f10138 = 1 + j2;
                            if (this.f10142 == null) {
                                this.f10146 = obj;
                                this.f10147 = j2;
                            }
                        }
                    }
                } else {
                    if (c3435.f10116.equals(obj)) {
                        j2 = c3435.f10120.f10129.f11632;
                        break;
                    }
                    c3435 = c3435.f10125;
                }
            }
        } else {
            j2 = this.f10147;
        }
        return m5623(obj, j, j2);
    }

    /* JADX INFO: renamed from: ֏, reason: contains not printable characters */
    public void m5619(long j) {
        C3435 c3435 = this.f10144;
        if (c3435 != null) {
            C0567.m1932(c3435.m5610());
            if (c3435.f10118) {
                c3435.f10115.mo6108(j - c3435.f10128);
            }
        }
    }

    /* JADX INFO: renamed from: ֏, reason: contains not printable characters */
    public void m5620(boolean z) {
        C3435 c3435 = this.f10142;
        if (c3435 != null) {
            this.f10146 = z ? c3435.f10116 : null;
            this.f10147 = c3435.f10120.f10129.f11632;
            m5621(c3435);
            c3435.m5611();
        } else if (!z) {
            this.f10146 = null;
        }
        this.f10142 = null;
        this.f10144 = null;
        this.f10143 = null;
        this.f10145 = 0;
    }

    /* JADX INFO: renamed from: ֏, reason: contains not printable characters */
    public boolean m5621(C3435 c3435) {
        boolean z = false;
        C0567.m1932(c3435 != null);
        this.f10144 = c3435;
        while (true) {
            c3435 = c3435.f10125;
            if (c3435 == null) {
                break;
            }
            if (c3435 == this.f10143) {
                this.f10143 = this.f10142;
                z = true;
            }
            c3435.m5611();
            this.f10145--;
        }
        C3435 c34352 = this.f10144;
        if (c34352.f10125 != null) {
            c34352.m5606();
            c34352.f10125 = null;
            c34352.m5607();
        }
        return z;
    }

    /* JADX INFO: renamed from: ֏, reason: contains not printable characters */
    public final boolean m5622(InterfaceC3800.C3801 c3801, boolean z) {
        int iMo1223 = this.f10139.mo1223(c3801.f11629);
        if (!this.f10139.m5684(this.f10139.m5682(iMo1223, this.f10136).f10225, this.f10137).f10234) {
            if ((this.f10139.m5679(iMo1223, this.f10136, this.f10137, this.f10140, this.f10141) == -1) && z) {
                return true;
            }
        }
        return false;
    }

    /* JADX INFO: renamed from: ؠ, reason: contains not printable characters */
    public final InterfaceC3800.C3801 m5623(Object obj, long j, long j2) {
        AbstractC3457 abstractC3457 = this.f10139;
        abstractC3457.mo1225(abstractC3457.mo1223(obj), this.f10136, true);
        int iM5691 = this.f10136.m5691(j);
        return iM5691 == -1 ? new InterfaceC3800.C3801(obj, j2, this.f10136.m5687(j)) : new InterfaceC3800.C3801(obj, iM5691, this.f10136.m5690(iM5691), j2);
    }

    /* JADX INFO: renamed from: ؠ, reason: contains not printable characters */
    public final boolean m5624() {
        C3435 c3435 = this.f10142;
        if (c3435 == null) {
            return true;
        }
        int iMo1223 = this.f10139.mo1223(c3435.f10116);
        while (true) {
            iMo1223 = this.f10139.m5679(iMo1223, this.f10136, this.f10137, this.f10140, this.f10141);
            while (true) {
                C3435 c34352 = c3435.f10125;
                if (c34352 == null || c3435.f10120.f10134) {
                    break;
                }
                c3435 = c34352;
            }
            C3435 c34353 = c3435.f10125;
            if (iMo1223 == -1 || c34353 == null || this.f10139.mo1223(c34353.f10116) != iMo1223) {
                break;
            }
            c3435 = c34353;
        }
        boolean zM5621 = m5621(c3435);
        c3435.f10120 = m5616(c3435.f10120);
        return !zM5621;
    }
}
