package c0;

import b0.b0;
import b0.u;
import com.google.android.gms.maps.model.BitmapDescriptorFactory;
import dn.p;
import kotlin.jvm.internal.l0;
import kotlin.jvm.internal.t;
import kotlin.jvm.internal.v;
import rm.n0;
import rm.y;
import tp.m0;
import y.z;

/* loaded from: classes.dex */
public final class g implements b0 {

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

    /* renamed from: b, reason: collision with root package name */
    private final z f7297b;

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

    /* renamed from: d, reason: collision with root package name */
    private l1.l f7299d = androidx.compose.foundation.gestures.d.e();

    /* 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 f7300p;

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

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

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

        @Override // kotlin.coroutines.jvm.internal.a
        public final Object invokeSuspend(Object obj) {
            this.f7301q = obj;
            this.f7303s |= Integer.MIN_VALUE;
            return g.this.i(null, BitmapDescriptorFactory.HUE_RED, null, 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 p {

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

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

        /* renamed from: s, reason: collision with root package name */
        final /* synthetic */ float f7307s;

        /* renamed from: t, reason: collision with root package name */
        final /* synthetic */ dn.l f7308t;

        /* renamed from: u, reason: collision with root package name */
        final /* synthetic */ u f7309u;

        /* JADX INFO: Access modifiers changed from: package-private */
        /* loaded from: classes.dex */
        public static final class a extends v implements dn.l {

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

            /* renamed from: q, reason: collision with root package name */
            final /* synthetic */ dn.l f7311q;

            /* JADX WARN: 'super' call moved to the top of the method (can break code semantics) */
            a(l0 l0Var, dn.l lVar) {
                super(1);
                this.f7310p = l0Var;
                this.f7311q = lVar;
            }

            public final void a(float f10) {
                l0 l0Var = this.f7310p;
                float f11 = l0Var.f26195p - f10;
                l0Var.f26195p = f11;
                this.f7311q.invoke(Float.valueOf(f11));
            }

            @Override // dn.l
            public /* bridge */ /* synthetic */ Object invoke(Object obj) {
                a(((Number) obj).floatValue());
                return n0.f34904a;
            }
        }

        /* JADX INFO: Access modifiers changed from: package-private */
        /* renamed from: c0.g$b$b, reason: collision with other inner class name */
        /* loaded from: classes.dex */
        public static final class C0192b extends v implements dn.l {

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

            /* renamed from: q, reason: collision with root package name */
            final /* synthetic */ dn.l f7313q;

            /* JADX WARN: 'super' call moved to the top of the method (can break code semantics) */
            C0192b(l0 l0Var, dn.l lVar) {
                super(1);
                this.f7312p = l0Var;
                this.f7313q = lVar;
            }

            public final void a(float f10) {
                l0 l0Var = this.f7312p;
                float f11 = l0Var.f26195p - f10;
                l0Var.f26195p = f11;
                this.f7313q.invoke(Float.valueOf(f11));
            }

            @Override // dn.l
            public /* bridge */ /* synthetic */ Object invoke(Object obj) {
                a(((Number) obj).floatValue());
                return n0.f34904a;
            }
        }

        /* JADX WARN: 'super' call moved to the top of the method (can break code semantics) */
        b(float f10, dn.l lVar, u uVar, vm.d dVar) {
            super(2, dVar);
            this.f7307s = f10;
            this.f7308t = lVar;
            this.f7309u = uVar;
        }

        @Override // kotlin.coroutines.jvm.internal.a
        public final vm.d create(Object obj, vm.d dVar) {
            return new b(this.f7307s, this.f7308t, this.f7309u, dVar);
        }

        @Override // kotlin.coroutines.jvm.internal.a
        public final Object invokeSuspend(Object obj) {
            Object f10;
            l0 l0Var;
            f10 = wm.d.f();
            int i10 = this.f7305q;
            if (i10 == 0) {
                y.b(obj);
                float a10 = g.this.f7296a.a(this.f7307s, y.b0.a(g.this.f7297b, BitmapDescriptorFactory.HUE_RED, this.f7307s));
                if (!(!Float.isNaN(a10))) {
                    throw new IllegalStateException("calculateApproachOffset returned NaN. Please use a valid value.".toString());
                }
                l0Var = new l0();
                float abs = Math.abs(a10) * Math.signum(this.f7307s);
                l0Var.f26195p = abs;
                this.f7308t.invoke(kotlin.coroutines.jvm.internal.b.b(abs));
                g gVar = g.this;
                u uVar = this.f7309u;
                float f11 = l0Var.f26195p;
                float f12 = this.f7307s;
                C0192b c0192b = new C0192b(l0Var, this.f7308t);
                this.f7304p = l0Var;
                this.f7305q = 1;
                obj = gVar.l(uVar, f11, f12, c0192b, this);
                if (obj == f10) {
                    return f10;
                }
            } else {
                if (i10 != 1) {
                    if (i10 == 2) {
                        y.b(obj);
                    }
                    throw new IllegalStateException("call to 'resume' before 'invoke' with coroutine");
                }
                l0Var = (l0) this.f7304p;
                y.b(obj);
            }
            y.k kVar = (y.k) obj;
            float b10 = g.this.f7296a.b(((Number) kVar.r()).floatValue());
            if (!(true ^ Float.isNaN(b10))) {
                throw new IllegalStateException("calculateSnapOffset returned NaN. Please use a valid value.".toString());
            }
            l0Var.f26195p = b10;
            u uVar2 = this.f7309u;
            y.k g10 = y.l.g(kVar, BitmapDescriptorFactory.HUE_RED, BitmapDescriptorFactory.HUE_RED, 0L, 0L, false, 30, null);
            y.i iVar = g.this.f7298c;
            a aVar = new a(l0Var, this.f7308t);
            this.f7304p = null;
            this.f7305q = 2;
            obj = h.h(uVar2, b10, b10, g10, iVar, aVar, this);
            return obj == f10 ? f10 : obj;
        }

        @Override // dn.p
        public final Object invoke(m0 m0Var, vm.d dVar) {
            return ((b) create(m0Var, dVar)).invokeSuspend(n0.f34904a);
        }
    }

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

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

        /* renamed from: r, reason: collision with root package name */
        int f7316r;

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

        @Override // kotlin.coroutines.jvm.internal.a
        public final Object invokeSuspend(Object obj) {
            this.f7314p = obj;
            this.f7316r |= Integer.MIN_VALUE;
            return g.this.c(null, BitmapDescriptorFactory.HUE_RED, null, this);
        }
    }

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

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

        /* renamed from: r, reason: collision with root package name */
        int f7319r;

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

        @Override // kotlin.coroutines.jvm.internal.a
        public final Object invokeSuspend(Object obj) {
            this.f7317p = obj;
            this.f7319r |= Integer.MIN_VALUE;
            return g.this.l(null, BitmapDescriptorFactory.HUE_RED, BitmapDescriptorFactory.HUE_RED, null, this);
        }
    }

    public g(i iVar, z zVar, y.i iVar2) {
        this.f7296a = iVar;
        this.f7297b = zVar;
        this.f7298c = iVar2;
    }

    /* JADX INFO: Access modifiers changed from: private */
    /* JADX WARN: Removed duplicated region for block: B:15:0x0036  */
    /* JADX WARN: Removed duplicated region for block: B:8:0x0023  */
    /*
        Code decompiled incorrectly, please refer to instructions dump.
    */
    public final Object i(u uVar, float f10, dn.l lVar, vm.d dVar) {
        a aVar;
        Object f11;
        int i10;
        if (dVar instanceof a) {
            aVar = (a) dVar;
            int i11 = aVar.f7303s;
            if ((i11 & Integer.MIN_VALUE) != 0) {
                aVar.f7303s = i11 - Integer.MIN_VALUE;
                Object obj = aVar.f7301q;
                f11 = wm.d.f();
                i10 = aVar.f7303s;
                if (i10 != 0) {
                    y.b(obj);
                    l1.l lVar2 = this.f7299d;
                    b bVar = new b(f10, lVar, uVar, null);
                    aVar.f7300p = lVar;
                    aVar.f7303s = 1;
                    obj = tp.i.g(lVar2, bVar, aVar);
                    if (obj == f11) {
                        return f11;
                    }
                } else {
                    if (i10 != 1) {
                        throw new IllegalStateException("call to 'resume' before 'invoke' with coroutine");
                    }
                    lVar = (dn.l) aVar.f7300p;
                    y.b(obj);
                }
                c0.a aVar2 = (c0.a) obj;
                lVar.invoke(kotlin.coroutines.jvm.internal.b.b(BitmapDescriptorFactory.HUE_RED));
                return aVar2;
            }
        }
        aVar = new a(dVar);
        Object obj2 = aVar.f7301q;
        f11 = wm.d.f();
        i10 = aVar.f7303s;
        if (i10 != 0) {
        }
        c0.a aVar22 = (c0.a) obj2;
        lVar.invoke(kotlin.coroutines.jvm.internal.b.b(BitmapDescriptorFactory.HUE_RED));
        return aVar22;
    }

    private final boolean j(float f10, float f11) {
        return Math.abs(y.b0.a(this.f7297b, BitmapDescriptorFactory.HUE_RED, f11)) >= Math.abs(f10);
    }

    private final Object k(u uVar, float f10, float f11, dn.l lVar, vm.d dVar) {
        Object i10;
        i10 = h.i(uVar, f10, f11, j(f10, f11) ? new c0.c(this.f7297b) : new l(this.f7298c), lVar, dVar);
        return i10;
    }

    /* JADX INFO: Access modifiers changed from: private */
    /* JADX WARN: Removed duplicated region for block: B:15:0x0032  */
    /* JADX WARN: Removed duplicated region for block: B:8:0x0024  */
    /*
        Code decompiled incorrectly, please refer to instructions dump.
    */
    public final Object l(u uVar, float f10, float f11, dn.l lVar, vm.d dVar) {
        d dVar2;
        Object f12;
        int i10;
        if (dVar instanceof d) {
            dVar2 = (d) dVar;
            int i11 = dVar2.f7319r;
            if ((i11 & Integer.MIN_VALUE) != 0) {
                dVar2.f7319r = i11 - Integer.MIN_VALUE;
                d dVar3 = dVar2;
                Object obj = dVar3.f7317p;
                f12 = wm.d.f();
                i10 = dVar3.f7319r;
                if (i10 != 0) {
                    y.b(obj);
                    if (!(Math.abs(f10) == BitmapDescriptorFactory.HUE_RED)) {
                        if (!(Math.abs(f11) == BitmapDescriptorFactory.HUE_RED)) {
                            dVar3.f7319r = 1;
                            obj = k(uVar, f10, f11, lVar, dVar3);
                            if (obj == f12) {
                                return f12;
                            }
                        }
                    }
                    return y.l.c(f10, f11, 0L, 0L, false, 28, null);
                }
                if (i10 != 1) {
                    throw new IllegalStateException("call to 'resume' before 'invoke' with coroutine");
                }
                y.b(obj);
                return ((c0.a) obj).c();
            }
        }
        dVar2 = new d(dVar);
        d dVar32 = dVar2;
        Object obj2 = dVar32.f7317p;
        f12 = wm.d.f();
        i10 = dVar32.f7319r;
        if (i10 != 0) {
        }
        return ((c0.a) obj2).c();
    }

    /* JADX WARN: Removed duplicated region for block: B:12:0x0053  */
    /* JADX WARN: Removed duplicated region for block: B:14:0x0057  */
    /* JADX WARN: Removed duplicated region for block: B:20:0x0031  */
    /* JADX WARN: Removed duplicated region for block: B:8:0x0023  */
    @Override // b0.b0
    /*
        Code decompiled incorrectly, please refer to instructions dump.
    */
    public Object c(u uVar, float f10, dn.l lVar, vm.d dVar) {
        c cVar;
        Object f11;
        int i10;
        float floatValue;
        if (dVar instanceof c) {
            cVar = (c) dVar;
            int i11 = cVar.f7316r;
            if ((i11 & Integer.MIN_VALUE) != 0) {
                cVar.f7316r = i11 - Integer.MIN_VALUE;
                Object obj = cVar.f7314p;
                f11 = wm.d.f();
                i10 = cVar.f7316r;
                if (i10 != 0) {
                    y.b(obj);
                    cVar.f7316r = 1;
                    obj = i(uVar, f10, lVar, cVar);
                    if (obj == f11) {
                        return f11;
                    }
                } else {
                    if (i10 != 1) {
                        throw new IllegalStateException("call to 'resume' before 'invoke' with coroutine");
                    }
                    y.b(obj);
                }
                c0.a aVar = (c0.a) obj;
                floatValue = ((Number) aVar.a()).floatValue();
                y.k b10 = aVar.b();
                float f12 = BitmapDescriptorFactory.HUE_RED;
                if (!(floatValue == BitmapDescriptorFactory.HUE_RED)) {
                    f12 = ((Number) b10.r()).floatValue();
                }
                return kotlin.coroutines.jvm.internal.b.b(f12);
            }
        }
        cVar = new c(dVar);
        Object obj2 = cVar.f7314p;
        f11 = wm.d.f();
        i10 = cVar.f7316r;
        if (i10 != 0) {
        }
        c0.a aVar2 = (c0.a) obj2;
        floatValue = ((Number) aVar2.a()).floatValue();
        y.k b102 = aVar2.b();
        float f122 = BitmapDescriptorFactory.HUE_RED;
        if (!(floatValue == BitmapDescriptorFactory.HUE_RED)) {
        }
        return kotlin.coroutines.jvm.internal.b.b(f122);
    }

    public boolean equals(Object obj) {
        if (!(obj instanceof g)) {
            return false;
        }
        g gVar = (g) obj;
        return t.b(gVar.f7298c, this.f7298c) && t.b(gVar.f7297b, this.f7297b) && t.b(gVar.f7296a, this.f7296a);
    }

    public int hashCode() {
        return ((((0 + this.f7298c.hashCode()) * 31) + this.f7297b.hashCode()) * 31) + this.f7296a.hashCode();
    }
}
