package n2;

import com.google.android.gms.maps.model.BitmapDescriptorFactory;
import dn.p;
import jn.o;
import rm.n0;
import rm.y;

/* JADX INFO: Access modifiers changed from: package-private */
/* loaded from: classes.dex */
public final class g {

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

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

    /* renamed from: c, reason: collision with root package name */
    private float f29779c;

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

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

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

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

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

    public g(int i10, p pVar) {
        this.f29777a = i10;
        this.f29778b = pVar;
    }

    /* JADX INFO: Access modifiers changed from: private */
    /* 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 e(float f10, vm.d dVar) {
        a aVar;
        Object f11;
        int i10;
        if (dVar instanceof a) {
            aVar = (a) dVar;
            int i11 = aVar.f29783s;
            if ((i11 & Integer.MIN_VALUE) != 0) {
                aVar.f29783s = i11 - Integer.MIN_VALUE;
                Object obj = aVar.f29781q;
                f11 = wm.d.f();
                i10 = aVar.f29783s;
                if (i10 != 0) {
                    y.b(obj);
                    p pVar = this.f29778b;
                    Float b10 = kotlin.coroutines.jvm.internal.b.b(f10);
                    aVar.f29780p = this;
                    aVar.f29783s = 1;
                    obj = pVar.invoke(b10, aVar);
                    if (obj == f11) {
                        return f11;
                    }
                } else {
                    if (i10 != 1) {
                        throw new IllegalStateException("call to 'resume' before 'invoke' with coroutine");
                    }
                    this = (g) aVar.f29780p;
                    y.b(obj);
                }
                this.f29779c += ((Number) obj).floatValue();
                return n0.f34904a;
            }
        }
        aVar = new a(dVar);
        Object obj2 = aVar.f29781q;
        f11 = wm.d.f();
        i10 = aVar.f29783s;
        if (i10 != 0) {
        }
        this.f29779c += ((Number) obj2).floatValue();
        return n0.f34904a;
    }

    public final float b() {
        return this.f29779c;
    }

    public final int c(int i10) {
        int c10;
        int k10;
        c10 = fn.c.c(this.f29779c);
        k10 = o.k(i10 - c10, 0, this.f29777a);
        return k10;
    }

    public final void d() {
        this.f29779c = BitmapDescriptorFactory.HUE_RED;
    }

    public final Object f(int i10, int i11, vm.d dVar) {
        Object f10;
        if (!(i10 <= i11)) {
            throw new IllegalArgumentException(("Expected min=" + i10 + " ≤ max=" + i11).toString());
        }
        int i12 = i11 - i10;
        int i13 = this.f29777a;
        if (!(i12 <= i13)) {
            throw new IllegalArgumentException(("Expected range (" + i12 + ") to be ≤ viewportSize=" + this.f29777a).toString());
        }
        float f11 = i10;
        float f12 = this.f29779c;
        if (f11 >= f12 && i11 <= i13 + f12) {
            return n0.f34904a;
        }
        if (f11 >= f12) {
            i10 = i11 - i13;
        }
        Object g10 = g(i10, dVar);
        f10 = wm.d.f();
        return g10 == f10 ? g10 : n0.f34904a;
    }

    public final Object g(float f10, vm.d dVar) {
        Object f11;
        Object e10 = e(f10 - this.f29779c, dVar);
        f11 = wm.d.f();
        return e10 == f11 ? e10 : n0.f34904a;
    }
}
