package androidx.compose.ui.draw;

import c3.s;
import com.google.android.gms.maps.model.BitmapDescriptorFactory;
import dn.l;
import h2.d0;
import h2.f0;
import h2.g0;
import h2.h;
import h2.o;
import h2.p0;
import h2.x0;
import j2.b0;
import j2.r;
import kotlin.jvm.internal.v;
import l1.i;
import r1.m;
import r1.n;
import rm.n0;
import s1.h0;

/* loaded from: classes.dex */
final class e extends i.c implements b0, r {
    private w1.b C;
    private boolean D;
    private l1.c E;
    private h F;
    private float G;
    private h0 H;

    /* loaded from: classes.dex */
    static final class a extends v implements l {

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

        /* JADX WARN: 'super' call moved to the top of the method (can break code semantics) */
        a(p0 p0Var) {
            super(1);
            this.f2133p = p0Var;
        }

        public final void a(p0.a aVar) {
            p0.a.l(aVar, this.f2133p, 0, 0, BitmapDescriptorFactory.HUE_RED, 4, null);
        }

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

    public e(w1.b bVar, boolean z10, l1.c cVar, h hVar, float f10, h0 h0Var) {
        this.C = bVar;
        this.D = z10;
        this.E = cVar;
        this.F = hVar;
        this.G = f10;
        this.H = h0Var;
    }

    private final long h2(long j10) {
        if (!k2()) {
            return j10;
        }
        long a10 = n.a(!m2(this.C.h()) ? m.i(j10) : m.i(this.C.h()), !l2(this.C.h()) ? m.g(j10) : m.g(this.C.h()));
        if (!(m.i(j10) == BitmapDescriptorFactory.HUE_RED)) {
            if (!(m.g(j10) == BitmapDescriptorFactory.HUE_RED)) {
                return x0.b(a10, this.F.a(a10, j10));
            }
        }
        return m.f34339b.b();
    }

    private final boolean k2() {
        if (this.D) {
            return (this.C.h() > 9205357640488583168L ? 1 : (this.C.h() == 9205357640488583168L ? 0 : -1)) != 0;
        }
        return false;
    }

    private final boolean l2(long j10) {
        if (m.f(j10, m.f34339b.a())) {
            return false;
        }
        float g10 = m.g(j10);
        return !Float.isInfinite(g10) && !Float.isNaN(g10);
    }

    private final boolean m2(long j10) {
        if (m.f(j10, m.f34339b.a())) {
            return false;
        }
        float i10 = m.i(j10);
        return !Float.isInfinite(i10) && !Float.isNaN(i10);
    }

    private final long n2(long j10) {
        boolean z10 = c3.b.h(j10) && c3.b.g(j10);
        boolean z11 = c3.b.j(j10) && c3.b.i(j10);
        if ((!k2() && z10) || z11) {
            return c3.b.d(j10, c3.b.l(j10), 0, c3.b.k(j10), 0, 10, null);
        }
        long h10 = this.C.h();
        long h22 = h2(n.a(c3.c.i(j10, m2(h10) ? Math.round(m.i(h10)) : c3.b.n(j10)), c3.c.h(j10, l2(h10) ? Math.round(m.g(h10)) : c3.b.m(j10))));
        return c3.b.d(j10, c3.c.i(j10, Math.round(m.i(h22))), 0, c3.c.h(j10, Math.round(m.g(h22))), 0, 10, null);
    }

    @Override // j2.b0
    public int I(o oVar, h2.n nVar, int i10) {
        if (!k2()) {
            return nVar.T(i10);
        }
        long n22 = n2(c3.c.b(0, 0, 0, i10, 7, null));
        return Math.max(c3.b.n(n22), nVar.T(i10));
    }

    @Override // l1.i.c
    public boolean M1() {
        return false;
    }

    public final void a(float f10) {
        this.G = f10;
    }

    @Override // j2.b0
    public f0 h(g0 g0Var, d0 d0Var, long j10) {
        p0 Y = d0Var.Y(n2(j10));
        return g0.j0(g0Var, Y.S0(), Y.F0(), null, new a(Y), 4, null);
    }

    public final w1.b i2() {
        return this.C;
    }

    public final boolean j2() {
        return this.D;
    }

    public final void o2(l1.c cVar) {
        this.E = cVar;
    }

    @Override // j2.b0
    public int p(o oVar, h2.n nVar, int i10) {
        if (!k2()) {
            return nVar.s(i10);
        }
        long n22 = n2(c3.c.b(0, i10, 0, 0, 13, null));
        return Math.max(c3.b.m(n22), nVar.s(i10));
    }

    public final void p2(h0 h0Var) {
        this.H = h0Var;
    }

    public final void q2(h hVar) {
        this.F = hVar;
    }

    @Override // j2.r
    public void r(u1.c cVar) {
        long b10;
        float h10;
        float i10;
        long h11 = this.C.h();
        long a10 = n.a(m2(h11) ? m.i(h11) : m.i(cVar.b()), l2(h11) ? m.g(h11) : m.g(cVar.b()));
        try {
            if (!(m.i(cVar.b()) == BitmapDescriptorFactory.HUE_RED)) {
                if (!(m.g(cVar.b()) == BitmapDescriptorFactory.HUE_RED)) {
                    b10 = x0.b(a10, this.F.a(a10, cVar.b()));
                    long j10 = b10;
                    long a11 = this.E.a(s.a(Math.round(m.i(j10)), Math.round(m.g(j10))), s.a(Math.round(m.i(cVar.b())), Math.round(m.g(cVar.b()))), cVar.getLayoutDirection());
                    h10 = c3.n.h(a11);
                    i10 = c3.n.i(a11);
                    cVar.Q0().f().d(h10, i10);
                    this.C.g(cVar, j10, this.G, this.H);
                    cVar.Q0().f().d(-h10, -i10);
                    cVar.z1();
                    return;
                }
            }
            this.C.g(cVar, j10, this.G, this.H);
            cVar.Q0().f().d(-h10, -i10);
            cVar.z1();
            return;
        } catch (Throwable th2) {
            cVar.Q0().f().d(-h10, -i10);
            throw th2;
        }
        b10 = m.f34339b.b();
        long j102 = b10;
        long a112 = this.E.a(s.a(Math.round(m.i(j102)), Math.round(m.g(j102))), s.a(Math.round(m.i(cVar.b())), Math.round(m.g(cVar.b()))), cVar.getLayoutDirection());
        h10 = c3.n.h(a112);
        i10 = c3.n.i(a112);
        cVar.Q0().f().d(h10, i10);
    }

    public final void r2(w1.b bVar) {
        this.C = bVar;
    }

    @Override // j2.b0
    public int s(o oVar, h2.n nVar, int i10) {
        if (!k2()) {
            return nVar.v0(i10);
        }
        long n22 = n2(c3.c.b(0, i10, 0, 0, 13, null));
        return Math.max(c3.b.m(n22), nVar.v0(i10));
    }

    public final void s2(boolean z10) {
        this.D = z10;
    }

    public String toString() {
        return "PainterModifier(painter=" + this.C + ", sizeToIntrinsics=" + this.D + ", alignment=" + this.E + ", alpha=" + this.G + ", colorFilter=" + this.H + ')';
    }

    @Override // j2.b0
    public int x(o oVar, h2.n nVar, int i10) {
        if (!k2()) {
            return nVar.X(i10);
        }
        long n22 = n2(c3.c.b(0, 0, 0, i10, 7, null));
        return Math.max(c3.b.n(n22), nVar.X(i10));
    }
}
