package b0;

import com.google.android.gms.maps.model.BitmapDescriptorFactory;
import z.g0;
import z.n0;

/* loaded from: classes.dex */
public final class z {

    /* renamed from: a, reason: collision with root package name */
    private x f6444a;

    /* renamed from: b, reason: collision with root package name */
    private n0 f6445b;

    /* renamed from: c, reason: collision with root package name */
    private n f6446c;

    /* renamed from: d, reason: collision with root package name */
    private q f6447d;

    /* renamed from: e, reason: collision with root package name */
    private boolean f6448e;

    /* renamed from: f, reason: collision with root package name */
    private c2.b f6449f;

    /* renamed from: g, reason: collision with root package name */
    private int f6450g = c2.e.f7396a.b();

    /* renamed from: h, reason: collision with root package name */
    private u f6451h;

    /* renamed from: i, reason: collision with root package name */
    private final c f6452i;

    /* renamed from: j, reason: collision with root package name */
    private final dn.l f6453j;

    /* JADX INFO: Access modifiers changed from: package-private */
    /* loaded from: classes.dex */
    public static final class a extends kotlin.coroutines.jvm.internal.d {

        /* renamed from: p, reason: collision with root package name */
        Object f6454p;

        /* renamed from: q, reason: collision with root package name */
        /* synthetic */ Object f6455q;

        /* renamed from: s, reason: collision with root package name */
        int f6457s;

        a(vm.d dVar) {
            super(dVar);
        }

        @Override // kotlin.coroutines.jvm.internal.a
        public final Object invokeSuspend(Object obj) {
            this.f6455q = obj;
            this.f6457s |= Integer.MIN_VALUE;
            return z.this.n(0L, this);
        }
    }

    /* JADX INFO: Access modifiers changed from: package-private */
    /* loaded from: classes.dex */
    public static final class b extends kotlin.coroutines.jvm.internal.l implements dn.p {

        /* renamed from: p, reason: collision with root package name */
        Object f6458p;

        /* renamed from: q, reason: collision with root package name */
        Object f6459q;

        /* renamed from: r, reason: collision with root package name */
        long f6460r;

        /* renamed from: s, reason: collision with root package name */
        int f6461s;

        /* renamed from: t, reason: collision with root package name */
        private /* synthetic */ Object f6462t;

        /* renamed from: v, reason: collision with root package name */
        final /* synthetic */ kotlin.jvm.internal.n0 f6464v;

        /* renamed from: w, reason: collision with root package name */
        final /* synthetic */ long f6465w;

        /* loaded from: classes.dex */
        public static final class a implements u {

            /* renamed from: a, reason: collision with root package name */
            final /* synthetic */ z f6466a;

            /* renamed from: b, reason: collision with root package name */
            final /* synthetic */ p f6467b;

            a(z zVar, p pVar) {
                this.f6466a = zVar;
                this.f6467b = pVar;
            }

            @Override // b0.u
            public float a(float f10) {
                z zVar = this.f6466a;
                return zVar.t(zVar.A(this.f6467b.a(zVar.u(zVar.B(f10)), c2.e.f7396a.a())));
            }
        }

        /* JADX WARN: 'super' call moved to the top of the method (can break code semantics) */
        b(kotlin.jvm.internal.n0 n0Var, long j10, vm.d dVar) {
            super(2, dVar);
            this.f6464v = n0Var;
            this.f6465w = j10;
        }

        @Override // dn.p
        /* renamed from: b, reason: merged with bridge method [inline-methods] */
        public final Object invoke(p pVar, vm.d dVar) {
            return ((b) create(pVar, dVar)).invokeSuspend(rm.n0.f34904a);
        }

        @Override // kotlin.coroutines.jvm.internal.a
        public final vm.d create(Object obj, vm.d dVar) {
            b bVar = new b(this.f6464v, this.f6465w, dVar);
            bVar.f6462t = obj;
            return bVar;
        }

        @Override // kotlin.coroutines.jvm.internal.a
        public final Object invokeSuspend(Object obj) {
            Object f10;
            z zVar;
            kotlin.jvm.internal.n0 n0Var;
            long j10;
            z zVar2;
            f10 = wm.d.f();
            int i10 = this.f6461s;
            if (i10 == 0) {
                rm.y.b(obj);
                a aVar = new a(z.this, (p) this.f6462t);
                zVar = z.this;
                kotlin.jvm.internal.n0 n0Var2 = this.f6464v;
                long j11 = this.f6465w;
                n nVar = zVar.f6446c;
                long j12 = n0Var2.f26198p;
                float t10 = zVar.t(zVar.z(j11));
                this.f6462t = zVar;
                this.f6458p = zVar;
                this.f6459q = n0Var2;
                this.f6460r = j12;
                this.f6461s = 1;
                Object a10 = nVar.a(aVar, t10, this);
                if (a10 == f10) {
                    return f10;
                }
                n0Var = n0Var2;
                j10 = j12;
                obj = a10;
                zVar2 = zVar;
            } else {
                if (i10 != 1) {
                    throw new IllegalStateException("call to 'resume' before 'invoke' with coroutine");
                }
                j10 = this.f6460r;
                n0Var = (kotlin.jvm.internal.n0) this.f6459q;
                zVar = (z) this.f6458p;
                zVar2 = (z) this.f6462t;
                rm.y.b(obj);
            }
            n0Var.f26198p = zVar.D(j10, zVar2.t(((Number) obj).floatValue()));
            return rm.n0.f34904a;
        }
    }

    /* loaded from: classes.dex */
    public static final class c implements p {
        c() {
        }

        @Override // b0.p
        public long a(long j10, int i10) {
            z.this.f6450g = i10;
            n0 n0Var = z.this.f6445b;
            if (n0Var != null && z.this.o()) {
                return n0Var.b(j10, z.this.f6450g, z.this.f6453j);
            }
            return z.this.s(z.this.f6451h, j10, i10);
        }

        @Override // b0.p
        public long b(long j10, int i10) {
            return z.this.s(z.this.f6451h, j10, i10);
        }
    }

    /* loaded from: classes.dex */
    static final class d extends kotlin.coroutines.jvm.internal.l implements dn.p {

        /* renamed from: p, reason: collision with root package name */
        long f6469p;

        /* renamed from: q, reason: collision with root package name */
        int f6470q;

        /* renamed from: r, reason: collision with root package name */
        /* synthetic */ long f6471r;

        d(vm.d dVar) {
            super(2, dVar);
        }

        public final Object b(long j10, vm.d dVar) {
            return ((d) create(c3.y.b(j10), dVar)).invokeSuspend(rm.n0.f34904a);
        }

        @Override // kotlin.coroutines.jvm.internal.a
        public final vm.d create(Object obj, vm.d dVar) {
            d dVar2 = new d(dVar);
            dVar2.f6471r = ((c3.y) obj).o();
            return dVar2;
        }

        @Override // dn.p
        public /* bridge */ /* synthetic */ Object invoke(Object obj, Object obj2) {
            return b(((c3.y) obj).o(), (vm.d) obj2);
        }

        /* JADX WARN: Removed duplicated region for block: B:15:0x0086 A[RETURN] */
        /* JADX WARN: Removed duplicated region for block: B:16:0x0087  */
        @Override // kotlin.coroutines.jvm.internal.a
        /*
            Code decompiled incorrectly, please refer to instructions dump.
        */
        public final Object invokeSuspend(Object obj) {
            Object f10;
            Object c10;
            long j10;
            Object n10;
            long j11;
            long j12;
            long o10;
            Object a10;
            long j13;
            f10 = wm.d.f();
            int i10 = this.f6470q;
            if (i10 == 0) {
                rm.y.b(obj);
                long j14 = this.f6471r;
                c2.b bVar = z.this.f6449f;
                this.f6471r = j14;
                this.f6470q = 1;
                c10 = bVar.c(j14, this);
                if (c10 == f10) {
                    return f10;
                }
                j10 = j14;
            } else {
                if (i10 != 1) {
                    if (i10 != 2) {
                        if (i10 != 3) {
                            throw new IllegalStateException("call to 'resume' before 'invoke' with coroutine");
                        }
                        long j15 = this.f6469p;
                        j13 = this.f6471r;
                        rm.y.b(obj);
                        o10 = j15;
                        a10 = obj;
                        return c3.y.b(c3.y.k(j13, c3.y.k(o10, ((c3.y) a10).o())));
                    }
                    j11 = this.f6469p;
                    j12 = this.f6471r;
                    rm.y.b(obj);
                    n10 = obj;
                    o10 = ((c3.y) n10).o();
                    c2.b bVar2 = z.this.f6449f;
                    long k10 = c3.y.k(j11, o10);
                    this.f6471r = j12;
                    this.f6469p = o10;
                    this.f6470q = 3;
                    a10 = bVar2.a(k10, o10, this);
                    if (a10 != f10) {
                        return f10;
                    }
                    j13 = j12;
                    return c3.y.b(c3.y.k(j13, c3.y.k(o10, ((c3.y) a10).o())));
                }
                j10 = this.f6471r;
                rm.y.b(obj);
                c10 = obj;
            }
            long k11 = c3.y.k(j10, ((c3.y) c10).o());
            z zVar = z.this;
            this.f6471r = j10;
            this.f6469p = k11;
            this.f6470q = 2;
            n10 = zVar.n(k11, this);
            if (n10 == f10) {
                return f10;
            }
            j11 = k11;
            j12 = j10;
            o10 = ((c3.y) n10).o();
            c2.b bVar22 = z.this.f6449f;
            long k102 = c3.y.k(j11, o10);
            this.f6471r = j12;
            this.f6469p = o10;
            this.f6470q = 3;
            a10 = bVar22.a(k102, o10, this);
            if (a10 != f10) {
            }
        }
    }

    /* loaded from: classes.dex */
    static final class e extends kotlin.jvm.internal.v implements dn.l {
        e() {
            super(1);
        }

        public final long a(long j10) {
            u uVar = z.this.f6451h;
            z zVar = z.this;
            return zVar.s(uVar, j10, zVar.f6450g);
        }

        @Override // dn.l
        public /* bridge */ /* synthetic */ Object invoke(Object obj) {
            return r1.g.d(a(((r1.g) obj).v()));
        }
    }

    /* JADX INFO: Access modifiers changed from: package-private */
    /* loaded from: classes.dex */
    public static final class f extends kotlin.coroutines.jvm.internal.l implements dn.p {

        /* renamed from: p, reason: collision with root package name */
        int f6474p;

        /* renamed from: q, reason: collision with root package name */
        private /* synthetic */ Object f6475q;

        /* renamed from: s, reason: collision with root package name */
        final /* synthetic */ dn.p f6477s;

        /* JADX WARN: 'super' call moved to the top of the method (can break code semantics) */
        f(dn.p pVar, vm.d dVar) {
            super(2, dVar);
            this.f6477s = pVar;
        }

        @Override // dn.p
        /* renamed from: b, reason: merged with bridge method [inline-methods] */
        public final Object invoke(u uVar, vm.d dVar) {
            return ((f) create(uVar, dVar)).invokeSuspend(rm.n0.f34904a);
        }

        @Override // kotlin.coroutines.jvm.internal.a
        public final vm.d create(Object obj, vm.d dVar) {
            f fVar = new f(this.f6477s, dVar);
            fVar.f6475q = obj;
            return fVar;
        }

        @Override // kotlin.coroutines.jvm.internal.a
        public final Object invokeSuspend(Object obj) {
            Object f10;
            f10 = wm.d.f();
            int i10 = this.f6474p;
            if (i10 == 0) {
                rm.y.b(obj);
                z.this.f6451h = (u) this.f6475q;
                dn.p pVar = this.f6477s;
                c cVar = z.this.f6452i;
                this.f6474p = 1;
                if (pVar.invoke(cVar, this) == f10) {
                    return f10;
                }
            } else {
                if (i10 != 1) {
                    throw new IllegalStateException("call to 'resume' before 'invoke' with coroutine");
                }
                rm.y.b(obj);
            }
            return rm.n0.f34904a;
        }
    }

    public z(x xVar, n0 n0Var, n nVar, q qVar, boolean z10, c2.b bVar) {
        u uVar;
        this.f6444a = xVar;
        this.f6445b = n0Var;
        this.f6446c = nVar;
        this.f6447d = qVar;
        this.f6448e = z10;
        this.f6449f = bVar;
        uVar = androidx.compose.foundation.gestures.d.f1686b;
        this.f6451h = uVar;
        this.f6452i = new c();
        this.f6453j = new e();
    }

    /* JADX INFO: Access modifiers changed from: private */
    public final long D(long j10, float f10) {
        return this.f6447d == q.Horizontal ? c3.y.e(j10, f10, BitmapDescriptorFactory.HUE_RED, 2, null) : c3.y.e(j10, BitmapDescriptorFactory.HUE_RED, f10, 1, null);
    }

    /* JADX INFO: Access modifiers changed from: private */
    public final boolean o() {
        return this.f6444a.e() || this.f6444a.c();
    }

    /* JADX INFO: Access modifiers changed from: private */
    public final long s(u uVar, long j10, int i10) {
        long d10 = this.f6449f.d(j10, i10);
        long q10 = r1.g.q(j10, d10);
        long u10 = u(B(uVar.a(A(u(x(q10))))));
        return r1.g.r(r1.g.r(d10, u10), this.f6449f.b(u10, r1.g.q(q10, u10), i10));
    }

    private final long y(long j10) {
        return this.f6447d == q.Horizontal ? c3.y.e(j10, BitmapDescriptorFactory.HUE_RED, BitmapDescriptorFactory.HUE_RED, 1, null) : c3.y.e(j10, BitmapDescriptorFactory.HUE_RED, BitmapDescriptorFactory.HUE_RED, 2, null);
    }

    /* JADX INFO: Access modifiers changed from: private */
    public final float z(long j10) {
        return this.f6447d == q.Horizontal ? c3.y.h(j10) : c3.y.i(j10);
    }

    public final float A(long j10) {
        return this.f6447d == q.Horizontal ? r1.g.m(j10) : r1.g.n(j10);
    }

    public final long B(float f10) {
        return (f10 > BitmapDescriptorFactory.HUE_RED ? 1 : (f10 == BitmapDescriptorFactory.HUE_RED ? 0 : -1)) == 0 ? r1.g.f34318b.c() : this.f6447d == q.Horizontal ? r1.h.a(f10, BitmapDescriptorFactory.HUE_RED) : r1.h.a(BitmapDescriptorFactory.HUE_RED, f10);
    }

    public final boolean C(x xVar, q qVar, n0 n0Var, boolean z10, n nVar, c2.b bVar) {
        boolean z11;
        boolean z12 = true;
        if (kotlin.jvm.internal.t.b(this.f6444a, xVar)) {
            z11 = false;
        } else {
            this.f6444a = xVar;
            z11 = true;
        }
        this.f6445b = n0Var;
        if (this.f6447d != qVar) {
            this.f6447d = qVar;
            z11 = true;
        }
        if (this.f6448e != z10) {
            this.f6448e = z10;
        } else {
            z12 = z11;
        }
        this.f6446c = nVar;
        this.f6449f = bVar;
        return z12;
    }

    /* JADX WARN: Removed duplicated region for block: B:15:0x0035  */
    /* JADX WARN: Removed duplicated region for block: B:8:0x0023  */
    /*
        Code decompiled incorrectly, please refer to instructions dump.
    */
    public final Object n(long j10, vm.d dVar) {
        a aVar;
        Object f10;
        int i10;
        kotlin.jvm.internal.n0 n0Var;
        if (dVar instanceof a) {
            aVar = (a) dVar;
            int i11 = aVar.f6457s;
            if ((i11 & Integer.MIN_VALUE) != 0) {
                aVar.f6457s = i11 - Integer.MIN_VALUE;
                Object obj = aVar.f6455q;
                f10 = wm.d.f();
                i10 = aVar.f6457s;
                if (i10 != 0) {
                    rm.y.b(obj);
                    kotlin.jvm.internal.n0 n0Var2 = new kotlin.jvm.internal.n0();
                    n0Var2.f26198p = j10;
                    g0 g0Var = g0.Default;
                    dn.p bVar = new b(n0Var2, j10, null);
                    aVar.f6454p = n0Var2;
                    aVar.f6457s = 1;
                    if (v(g0Var, bVar, aVar) == f10) {
                        return f10;
                    }
                    n0Var = n0Var2;
                } else {
                    if (i10 != 1) {
                        throw new IllegalStateException("call to 'resume' before 'invoke' with coroutine");
                    }
                    n0Var = (kotlin.jvm.internal.n0) aVar.f6454p;
                    rm.y.b(obj);
                }
                return c3.y.b(n0Var.f26198p);
            }
        }
        aVar = new a(dVar);
        Object obj2 = aVar.f6455q;
        f10 = wm.d.f();
        i10 = aVar.f6457s;
        if (i10 != 0) {
        }
        return c3.y.b(n0Var.f26198p);
    }

    public final boolean p() {
        return this.f6447d == q.Vertical;
    }

    public final Object q(long j10, vm.d dVar) {
        Object f10;
        Object f11;
        long y10 = y(j10);
        d dVar2 = new d(null);
        n0 n0Var = this.f6445b;
        if (n0Var == null || !o()) {
            Object invoke = dVar2.invoke(c3.y.b(y10), dVar);
            f10 = wm.d.f();
            return invoke == f10 ? invoke : rm.n0.f34904a;
        }
        Object d10 = n0Var.d(y10, dVar2, dVar);
        f11 = wm.d.f();
        return d10 == f11 ? d10 : rm.n0.f34904a;
    }

    public final long r(long j10) {
        return this.f6444a.a() ? r1.g.f34318b.c() : B(t(this.f6444a.f(t(A(j10)))));
    }

    public final float t(float f10) {
        return this.f6448e ? f10 * (-1) : f10;
    }

    public final long u(long j10) {
        return this.f6448e ? r1.g.s(j10, -1.0f) : j10;
    }

    public final Object v(g0 g0Var, dn.p pVar, vm.d dVar) {
        Object f10;
        Object d10 = this.f6444a.d(g0Var, new f(pVar, null), dVar);
        f10 = wm.d.f();
        return d10 == f10 ? d10 : rm.n0.f34904a;
    }

    public final boolean w() {
        if (!this.f6444a.a()) {
            n0 n0Var = this.f6445b;
            if (!(n0Var != null ? n0Var.c() : false)) {
                return false;
            }
        }
        return true;
    }

    public final long x(long j10) {
        return this.f6447d == q.Horizontal ? r1.g.g(j10, BitmapDescriptorFactory.HUE_RED, BitmapDescriptorFactory.HUE_RED, 1, null) : r1.g.g(j10, BitmapDescriptorFactory.HUE_RED, BitmapDescriptorFactory.HUE_RED, 2, null);
    }
}
