package androidx.compose.foundation.relocation;

import dn.p;
import h2.s;
import j2.a0;
import j2.x1;
import kotlin.coroutines.jvm.internal.l;
import kotlin.jvm.internal.k;
import kotlin.jvm.internal.q;
import kotlin.jvm.internal.t;
import kotlin.jvm.internal.v;
import l1.i;
import rm.n0;
import rm.y;
import tp.m0;
import tp.u1;

/* loaded from: classes.dex */
public final class f extends i.c implements i0.a, a0, x1 {
    public static final a F = new a(null);
    public static final int G = 8;
    private i0.c C;
    private final boolean D;
    private boolean E;

    /* loaded from: classes.dex */
    public static final class a {
        private a() {
        }

        public /* synthetic */ a(k kVar) {
            this();
        }
    }

    /* loaded from: classes.dex */
    static final class b extends l implements p {

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

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

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

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

        /* renamed from: u, reason: collision with root package name */
        final /* synthetic */ dn.a f1999u;

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

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

            /* renamed from: q, reason: collision with root package name */
            final /* synthetic */ f f2001q;

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

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

            /* JADX INFO: Access modifiers changed from: package-private */
            /* renamed from: androidx.compose.foundation.relocation.f$b$a$a, reason: collision with other inner class name */
            /* loaded from: classes.dex */
            public /* synthetic */ class C0053a extends q implements dn.a {

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

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

                /* renamed from: r, reason: collision with root package name */
                final /* synthetic */ dn.a f2006r;

                /* JADX WARN: 'super' call moved to the top of the method (can break code semantics) */
                C0053a(f fVar, s sVar, dn.a aVar) {
                    super(0, t.a.class, "localRect", "bringChildIntoView$localRect(Landroidx/compose/foundation/relocation/BringIntoViewResponderNode;Landroidx/compose/ui/layout/LayoutCoordinates;Lkotlin/jvm/functions/Function0;)Landroidx/compose/ui/geometry/Rect;", 0);
                    this.f2004p = fVar;
                    this.f2005q = sVar;
                    this.f2006r = aVar;
                }

                @Override // dn.a
                /* renamed from: l, reason: merged with bridge method [inline-methods] */
                public final r1.i invoke() {
                    return f.i2(this.f2004p, this.f2005q, this.f2006r);
                }
            }

            /* JADX WARN: 'super' call moved to the top of the method (can break code semantics) */
            a(f fVar, s sVar, dn.a aVar, vm.d dVar) {
                super(2, dVar);
                this.f2001q = fVar;
                this.f2002r = sVar;
                this.f2003s = aVar;
            }

            @Override // kotlin.coroutines.jvm.internal.a
            public final vm.d create(Object obj, vm.d dVar) {
                return new a(this.f2001q, this.f2002r, this.f2003s, dVar);
            }

            @Override // kotlin.coroutines.jvm.internal.a
            public final Object invokeSuspend(Object obj) {
                Object f10;
                f10 = wm.d.f();
                int i10 = this.f2000p;
                if (i10 == 0) {
                    y.b(obj);
                    i0.c j22 = this.f2001q.j2();
                    C0053a c0053a = new C0053a(this.f2001q, this.f2002r, this.f2003s);
                    this.f2000p = 1;
                    if (j22.I0(c0053a, this) == f10) {
                        return f10;
                    }
                } else {
                    if (i10 != 1) {
                        throw new IllegalStateException("call to 'resume' before 'invoke' with coroutine");
                    }
                    y.b(obj);
                }
                return n0.f34904a;
            }

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

        /* JADX INFO: Access modifiers changed from: package-private */
        /* renamed from: androidx.compose.foundation.relocation.f$b$b, reason: collision with other inner class name */
        /* loaded from: classes.dex */
        public static final class C0054b extends l implements p {

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

            /* renamed from: q, reason: collision with root package name */
            final /* synthetic */ f f2008q;

            /* renamed from: r, reason: collision with root package name */
            final /* synthetic */ dn.a f2009r;

            /* JADX WARN: 'super' call moved to the top of the method (can break code semantics) */
            C0054b(f fVar, dn.a aVar, vm.d dVar) {
                super(2, dVar);
                this.f2008q = fVar;
                this.f2009r = aVar;
            }

            @Override // kotlin.coroutines.jvm.internal.a
            public final vm.d create(Object obj, vm.d dVar) {
                return new C0054b(this.f2008q, this.f2009r, dVar);
            }

            @Override // kotlin.coroutines.jvm.internal.a
            public final Object invokeSuspend(Object obj) {
                Object f10;
                i0.a c10;
                f10 = wm.d.f();
                int i10 = this.f2007p;
                if (i10 == 0) {
                    y.b(obj);
                    if (this.f2008q.O1() && (c10 = androidx.compose.foundation.relocation.b.c(this.f2008q)) != null) {
                        s k10 = j2.k.k(this.f2008q);
                        dn.a aVar = this.f2009r;
                        this.f2007p = 1;
                        if (c10.X(k10, aVar, this) == f10) {
                            return f10;
                        }
                    }
                } else {
                    if (i10 != 1) {
                        throw new IllegalStateException("call to 'resume' before 'invoke' with coroutine");
                    }
                    y.b(obj);
                }
                return n0.f34904a;
            }

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

        /* JADX WARN: 'super' call moved to the top of the method (can break code semantics) */
        b(s sVar, dn.a aVar, dn.a aVar2, vm.d dVar) {
            super(2, dVar);
            this.f1997s = sVar;
            this.f1998t = aVar;
            this.f1999u = aVar2;
        }

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

        @Override // kotlin.coroutines.jvm.internal.a
        public final Object invokeSuspend(Object obj) {
            u1 d10;
            wm.d.f();
            if (this.f1994p != 0) {
                throw new IllegalStateException("call to 'resume' before 'invoke' with coroutine");
            }
            y.b(obj);
            m0 m0Var = (m0) this.f1995q;
            tp.k.d(m0Var, null, null, new a(f.this, this.f1997s, this.f1998t, null), 3, null);
            d10 = tp.k.d(m0Var, null, null, new C0054b(f.this, this.f1999u, null), 3, null);
            return d10;
        }

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

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

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

        /* renamed from: r, reason: collision with root package name */
        final /* synthetic */ dn.a f2012r;

        /* JADX WARN: 'super' call moved to the top of the method (can break code semantics) */
        c(s sVar, dn.a aVar) {
            super(0);
            this.f2011q = sVar;
            this.f2012r = aVar;
        }

        @Override // dn.a
        /* renamed from: a, reason: merged with bridge method [inline-methods] */
        public final r1.i invoke() {
            r1.i i22 = f.i2(f.this, this.f2011q, this.f2012r);
            if (i22 != null) {
                return f.this.j2().p1(i22);
            }
            return null;
        }
    }

    public f(i0.c cVar) {
        this.C = cVar;
    }

    /* JADX INFO: Access modifiers changed from: private */
    public static final r1.i i2(f fVar, s sVar, dn.a aVar) {
        r1.i iVar;
        r1.i c10;
        if (!fVar.O1() || !fVar.E) {
            return null;
        }
        s k10 = j2.k.k(fVar);
        if (!sVar.N()) {
            sVar = null;
        }
        if (sVar == null || (iVar = (r1.i) aVar.invoke()) == null) {
            return null;
        }
        c10 = d.c(k10, sVar, iVar);
        return c10;
    }

    @Override // j2.a0
    public void M(s sVar) {
        this.E = true;
    }

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

    @Override // j2.x1
    public Object N() {
        return F;
    }

    @Override // i0.a
    public Object X(s sVar, dn.a aVar, vm.d dVar) {
        Object f10;
        Object f11 = tp.n0.f(new b(sVar, aVar, new c(sVar, aVar), null), dVar);
        f10 = wm.d.f();
        return f11 == f10 ? f11 : n0.f34904a;
    }

    public final i0.c j2() {
        return this.C;
    }
}
