package L0;

import android.graphics.Rect;
import androidx.window.sidecar.SidecarDeviceState;
import androidx.window.sidecar.SidecarDisplayFeature;
import androidx.window.sidecar.SidecarWindowLayoutInfo;
import e4.C0574r;
import java.util.ArrayList;
import java.util.Iterator;
import java.util.List;
import p0.AbstractC0928a;
import r4.AbstractC0983h;

/* JADX INFO: loaded from: classes.dex */
public final class f {

    /* JADX INFO: renamed from: b, reason: collision with root package name */
    public static final /* synthetic */ int f1256b = 0;

    /* JADX INFO: renamed from: a, reason: collision with root package name */
    public final int f1257a;

    public f() {
        AbstractC0928a.q(3, "verificationMode");
        this.f1257a = 3;
    }

    public static boolean a(SidecarDisplayFeature sidecarDisplayFeature, SidecarDisplayFeature sidecarDisplayFeature2) {
        if (AbstractC0983h.a(sidecarDisplayFeature, sidecarDisplayFeature2)) {
            return true;
        }
        if (sidecarDisplayFeature == null || sidecarDisplayFeature2 == null || sidecarDisplayFeature.getType() != sidecarDisplayFeature2.getType()) {
            return false;
        }
        return AbstractC0983h.a(sidecarDisplayFeature.getRect(), sidecarDisplayFeature2.getRect());
    }

    public static boolean b(List list, List list2) {
        if (list == list2) {
            return true;
        }
        if (list.size() == list2.size()) {
            int size = list.size();
            for (int i = 0; i < size; i++) {
                if (a((SidecarDisplayFeature) list.get(i), (SidecarDisplayFeature) list2.get(i))) {
                }
            }
            return true;
        }
        return false;
    }

    public final I0.l c(SidecarWindowLayoutInfo sidecarWindowLayoutInfo, SidecarDeviceState sidecarDeviceState) {
        if (sidecarWindowLayoutInfo == null) {
            return new I0.l(C0574r.f6259k);
        }
        SidecarDeviceState sidecarDeviceState2 = new SidecarDeviceState();
        a.d(sidecarDeviceState2, a.b(sidecarDeviceState));
        return new I0.l(d(a.c(sidecarWindowLayoutInfo), sidecarDeviceState2));
    }

    public final ArrayList d(List list, SidecarDeviceState sidecarDeviceState) {
        ArrayList arrayList = new ArrayList();
        Iterator it = list.iterator();
        while (it.hasNext()) {
            I0.c cVarE = e((SidecarDisplayFeature) it.next(), sidecarDeviceState);
            if (cVarE != null) {
                arrayList.add(cVarE);
            }
        }
        return arrayList;
    }

    public final I0.c e(SidecarDisplayFeature sidecarDisplayFeature, SidecarDeviceState sidecarDeviceState) {
        I0.b bVar;
        I0.b bVar2;
        AbstractC0983h.e("feature", sidecarDisplayFeature);
        F0.a aVar = F0.a.f616a;
        int i = this.f1257a;
        AbstractC0928a.q(i, "verificationMode");
        SidecarDisplayFeature sidecarDisplayFeature2 = (SidecarDisplayFeature) new F0.g(sidecarDisplayFeature, i, aVar).w(b.f1252k, "Type must be either TYPE_FOLD or TYPE_HINGE").w(c.f1253k, "Feature bounds must not be 0").w(d.f1254k, "TYPE_FOLD must have 0 area").w(e.f1255k, "Feature be pinned to either left or top").d();
        if (sidecarDisplayFeature2 == null) {
            return null;
        }
        int type = sidecarDisplayFeature2.getType();
        if (type == 1) {
            bVar = I0.b.f882h;
        } else {
            if (type != 2) {
                return null;
            }
            bVar = I0.b.i;
        }
        int iB = a.b(sidecarDeviceState);
        if (iB == 0 || iB == 1) {
            return null;
        }
        if (iB != 2) {
            bVar2 = I0.b.f880f;
            if (iB != 3 && iB == 4) {
                return null;
            }
        } else {
            bVar2 = I0.b.f881g;
        }
        Rect rect = sidecarDisplayFeature.getRect();
        AbstractC0983h.d("feature.rect", rect);
        return new I0.c(new F0.b(rect), bVar, bVar2);
    }
}
