package o;

import android.graphics.Rect;
import android.os.Handler;
import android.os.Looper;
import android.view.KeyEvent;
import android.view.View;
import android.view.ViewGroup;
import android.view.ViewParent;

/* compiled from: r8-map-id-3b7cc9102578c509342fa2f0fabed2bfc72239cd258d579fc679bfcbc198b048 */
/* renamed from: o.k3, reason: case insensitive filesystem */
/* loaded from: classes.dex */
public final class C1637k3 extends AbstractC0706aK implements OC {
    public final /* synthetic */ int m;
    public final /* synthetic */ C2207q3 n;

    /* JADX WARN: 'super' call moved to the top of the method (can break code semantics) */
    public /* synthetic */ C1637k3(C2207q3 c2207q3, int i) {
        super(1);
        this.m = i;
        this.n = c2207q3;
    }

    @Override // o.OC
    public final Object g(Object obj) {
        C0388Oz c0388Oz;
        switch (this.m) {
            case 0:
                KeyEvent keyEvent = ((GJ) obj).a;
                long jR = IJ.r(keyEvent);
                if (FJ.a(jR, FJ.b)) {
                    c0388Oz = new C0388Oz(2);
                } else if (FJ.a(jR, FJ.c)) {
                    c0388Oz = new C0388Oz(1);
                } else if (FJ.a(jR, FJ.i)) {
                    c0388Oz = new C0388Oz(keyEvent.isShiftPressed() ? 2 : 1);
                } else {
                    c0388Oz = FJ.a(jR, FJ.g) ? new C0388Oz(4) : FJ.a(jR, FJ.f) ? new C0388Oz(3) : (FJ.a(jR, FJ.d) || FJ.a(jR, FJ.m)) ? new C0388Oz(5) : (FJ.a(jR, FJ.e) || FJ.a(jR, FJ.n)) ? new C0388Oz(6) : (FJ.a(jR, FJ.h) || FJ.a(jR, FJ.k) || FJ.a(jR, FJ.f117o)) ? new C0388Oz(7) : (FJ.a(jR, FJ.a) || FJ.a(jR, FJ.l)) ? new C0388Oz(8) : null;
                }
                if (c0388Oz != null) {
                    int i = c0388Oz.a;
                    if (IJ.v(keyEvent) == 2) {
                        Integer numT = F3.T(i);
                        C2207q3 c2207q3 = this.n;
                        T00 embeddedViewFocusRect = c2207q3.getEmbeddedViewFocusRect();
                        Boolean boolE = ((C0674Zz) c2207q3.getFocusOwner()).e(i, embeddedViewFocusRect, new C1542j3(c0388Oz, 1));
                        if (boolE != null ? boolE.booleanValue() : true) {
                            return Boolean.TRUE;
                        }
                        if (!(i == 1 || i == 2)) {
                            return Boolean.FALSE;
                        }
                        if (numT != null) {
                            int iIntValue = numT.intValue();
                            C0466Rz c0466Rz = (C0466Rz) C0466Rz.f.get();
                            View viewB = c2207q3;
                            while (true) {
                                if (viewB == null) {
                                    viewB = null;
                                } else {
                                    viewB = c0466Rz.b(iIntValue, viewB, (ViewGroup) c2207q3.getRootView());
                                    if (viewB != null) {
                                        if (!viewB.equals(c2207q3)) {
                                            for (ViewParent parent = viewB.getParent(); parent != null; parent = parent.getParent()) {
                                                if (parent == c2207q3) {
                                                    break;
                                                }
                                            }
                                        }
                                    }
                                }
                            }
                            if (F3.c(viewB, c2207q3)) {
                                viewB = null;
                            }
                            if (viewB != null) {
                                Rect rectW = embeddedViewFocusRect != null ? As0.W(embeddedViewFocusRect) : null;
                                if (rectW == null) {
                                    throw new IllegalStateException("Invalid rect");
                                }
                                ViewGroup viewGroup = (ViewGroup) c2207q3.getRootView();
                                viewGroup.offsetDescendantRectToMyCoords(c2207q3, rectW);
                                viewGroup.offsetRectIntoDescendantCoords(viewB, rectW);
                                if (F3.L(viewB, numT, rectW)) {
                                    return Boolean.TRUE;
                                }
                            }
                        }
                        if (!((C0674Zz) c2207q3.getFocusOwner()).b(i, false, false)) {
                            return Boolean.TRUE;
                        }
                        Boolean boolE2 = ((C0674Zz) c2207q3.getFocusOwner()).e(i, null, new C1542j3(c0388Oz, 0));
                        return Boolean.valueOf(boolE2 != null ? boolE2.booleanValue() : true);
                    }
                }
                return Boolean.FALSE;
            case 1:
                NC nc = (NC) obj;
                C2207q3 c2207q32 = this.n;
                Handler handler = c2207q32.getHandler();
                if ((handler != null ? handler.getLooper() : null) == Looper.myLooper()) {
                    nc.a();
                } else {
                    Handler handler2 = c2207q32.getHandler();
                    if (handler2 != null) {
                        handler2.post(new J1(1, nc));
                    }
                }
                return Oh0.a;
            default:
                C2207q3 c2207q33 = this.n;
                return new V4(c2207q33, c2207q33.getTextInputService(), (InterfaceC0065Cn) obj);
        }
    }
}
