package n7;

import android.content.Context;
import android.os.Parcel;
import android.os.Parcelable;
import android.util.DisplayMetrics;
import android.view.Display;
import android.view.WindowManager;

/* JADX INFO: loaded from: classes2.dex */
public final class f4 extends f8.a {
    public static final Parcelable.Creator<f4> CREATOR = new c4(1);
    public final boolean Q;
    public final boolean R;

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

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

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

    /* JADX INFO: renamed from: d, reason: collision with root package name */
    public final boolean f30949d;

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

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

    /* JADX INFO: renamed from: g, reason: collision with root package name */
    public final f4[] f30952g;

    /* JADX INFO: renamed from: h, reason: collision with root package name */
    public final boolean f30953h;

    /* JADX INFO: renamed from: i, reason: collision with root package name */
    public final boolean f30954i;

    /* JADX INFO: renamed from: j, reason: collision with root package name */
    public boolean f30955j;

    /* JADX INFO: renamed from: k, reason: collision with root package name */
    public final boolean f30956k;

    /* JADX INFO: renamed from: l, reason: collision with root package name */
    public final boolean f30957l;

    /* JADX INFO: renamed from: m, reason: collision with root package name */
    public final boolean f30958m;

    /* JADX WARN: Removed duplicated region for block: B:41:0x00d0  */
    /* JADX WARN: Removed duplicated region for block: B:44:0x00e5  */
    /*
        Code decompiled incorrectly, please refer to instructions dump.
    */
    public f4(Context context, g7.g[] gVarArr) {
        int i10;
        int i11;
        String string;
        int dimensionPixelSize;
        double d10;
        g7.g gVar = gVarArr[0];
        this.f30949d = false;
        int i12 = gVar.f26290a;
        int i13 = gVar.f26291b;
        boolean z10 = i12 == -3 && i13 == -4;
        this.f30954i = z10;
        this.f30958m = false;
        boolean z11 = gVar.f26293d;
        this.Q = z11;
        boolean z12 = gVar.f26295f;
        this.R = z12;
        if (z10) {
            g7.g gVar2 = g7.g.f26280h;
            this.f30950e = gVar2.f26290a;
            i13 = gVar2.f26291b;
            this.f30947b = i13;
        } else if (z11) {
            this.f30950e = i12;
            i13 = gVar.f26294e;
            this.f30947b = i13;
        } else if (z12) {
            this.f30950e = i12;
            i13 = gVar.f26296g;
            this.f30947b = i13;
        } else {
            this.f30950e = i12;
            this.f30947b = i13;
        }
        boolean z13 = this.f30950e == -1;
        boolean z14 = i13 == -2;
        DisplayMetrics displayMetrics = context.getResources().getDisplayMetrics();
        if (z13) {
            q7.e eVar = x.f31085g.f31086a;
            if (context.getResources().getConfiguration().orientation != 2) {
                dimensionPixelSize = displayMetrics.widthPixels;
                this.f30951f = dimensionPixelSize;
                d10 = dimensionPixelSize / displayMetrics.density;
                i10 = (int) d10;
                if (d10 - ((double) i10) >= 0.01d) {
                    i10++;
                }
            } else {
                if (((int) (r12.heightPixels / context.getResources().getDisplayMetrics().density)) < 600) {
                    DisplayMetrics displayMetrics2 = context.getResources().getDisplayMetrics();
                    WindowManager windowManager = (WindowManager) context.getSystemService("window");
                    if (windowManager != null) {
                        Display defaultDisplay = windowManager.getDefaultDisplay();
                        defaultDisplay.getRealMetrics(displayMetrics2);
                        int i14 = displayMetrics2.heightPixels;
                        int i15 = displayMetrics2.widthPixels;
                        defaultDisplay.getMetrics(displayMetrics2);
                        int i16 = displayMetrics2.heightPixels;
                        int i17 = displayMetrics2.widthPixels;
                        if (i16 == i14 && i17 == i15) {
                            int i18 = displayMetrics.widthPixels;
                            int identifier = context.getResources().getIdentifier("navigation_bar_width", "dimen", "android");
                            dimensionPixelSize = i18 - (identifier > 0 ? context.getResources().getDimensionPixelSize(identifier) : 0);
                            this.f30951f = dimensionPixelSize;
                        }
                        d10 = dimensionPixelSize / displayMetrics.density;
                        i10 = (int) d10;
                        if (d10 - ((double) i10) >= 0.01d) {
                        }
                    }
                }
            }
        } else {
            i10 = this.f30950e;
            q7.e eVar2 = x.f31085g.f31086a;
            this.f30951f = q7.e.g(displayMetrics, i10);
        }
        if (z14) {
            int i19 = (int) (displayMetrics.heightPixels / displayMetrics.density);
            i11 = i19 <= 400 ? 32 : i19 <= 720 ? 50 : 90;
        } else {
            i11 = this.f30947b;
        }
        q7.e eVar3 = x.f31085g.f31086a;
        this.f30948c = q7.e.g(displayMetrics, i11);
        if (z13 || z14) {
            StringBuilder sb = new StringBuilder(String.valueOf(i11).length() + com.google.android.gms.measurement.internal.u1.b(i10, 1) + 3);
            sb.append(i10);
            sb.append("x");
            sb.append(i11);
            sb.append("_as");
            this.f30946a = sb.toString();
        } else {
            if (z11 || z12) {
                int i20 = this.f30950e;
                int i21 = this.f30947b;
                StringBuilder sb2 = new StringBuilder(String.valueOf(i21).length() + com.google.android.gms.measurement.internal.u1.b(i20, 1) + 3);
                sb2.append(i20);
                sb2.append("x");
                sb2.append(i21);
                sb2.append("_as");
                string = sb2.toString();
            } else if (z10) {
                string = "320x50_mb";
            } else {
                this.f30946a = gVar.f26292c;
            }
            this.f30946a = string;
        }
        int length = gVarArr.length;
        if (length > 1) {
            this.f30952g = new f4[length];
            for (int i22 = 0; i22 < gVarArr.length; i22++) {
                this.f30952g[i22] = new f4(context, gVarArr[i22]);
            }
        } else {
            this.f30952g = null;
        }
        this.f30953h = false;
        this.f30955j = false;
    }

    public static f4 w() {
        return new f4("320x50_mb", 0, 0, false, 0, 0, null, true, false, false, false, false, false, false, false);
    }

    public static f4 x() {
        return new f4("interstitial_mb", 0, 0, false, 0, 0, null, false, false, false, false, true, false, false, false);
    }

    @Override // android.os.Parcelable
    public final void writeToParcel(Parcel parcel, int i10) {
        int I = com.bumptech.glide.g.I(20293, parcel);
        com.bumptech.glide.g.r(parcel, 2, this.f30946a);
        com.bumptech.glide.g.C(parcel, 3, 4);
        parcel.writeInt(this.f30947b);
        com.bumptech.glide.g.C(parcel, 4, 4);
        parcel.writeInt(this.f30948c);
        com.bumptech.glide.g.C(parcel, 5, 4);
        parcel.writeInt(this.f30949d ? 1 : 0);
        com.bumptech.glide.g.C(parcel, 6, 4);
        parcel.writeInt(this.f30950e);
        com.bumptech.glide.g.C(parcel, 7, 4);
        parcel.writeInt(this.f30951f);
        com.bumptech.glide.g.u(parcel, 8, this.f30952g, i10);
        com.bumptech.glide.g.C(parcel, 9, 4);
        parcel.writeInt(this.f30953h ? 1 : 0);
        com.bumptech.glide.g.C(parcel, 10, 4);
        parcel.writeInt(this.f30954i ? 1 : 0);
        boolean z10 = this.f30955j;
        com.bumptech.glide.g.C(parcel, 11, 4);
        parcel.writeInt(z10 ? 1 : 0);
        com.bumptech.glide.g.C(parcel, 12, 4);
        parcel.writeInt(this.f30956k ? 1 : 0);
        com.bumptech.glide.g.C(parcel, 13, 4);
        parcel.writeInt(this.f30957l ? 1 : 0);
        com.bumptech.glide.g.C(parcel, 14, 4);
        parcel.writeInt(this.f30958m ? 1 : 0);
        com.bumptech.glide.g.C(parcel, 15, 4);
        parcel.writeInt(this.Q ? 1 : 0);
        com.bumptech.glide.g.C(parcel, 16, 4);
        parcel.writeInt(this.R ? 1 : 0);
        com.bumptech.glide.g.N(I, parcel);
    }

    public f4(String str, int i10, int i11, boolean z10, int i12, int i13, f4[] f4VarArr, boolean z11, boolean z12, boolean z13, boolean z14, boolean z15, boolean z16, boolean z17, boolean z18) {
        this.f30946a = str;
        this.f30947b = i10;
        this.f30948c = i11;
        this.f30949d = z10;
        this.f30950e = i12;
        this.f30951f = i13;
        this.f30952g = f4VarArr;
        this.f30953h = z11;
        this.f30954i = z12;
        this.f30955j = z13;
        this.f30956k = z14;
        this.f30957l = z15;
        this.f30958m = z16;
        this.Q = z17;
        this.R = z18;
    }

    public f4() {
        this("interstitial_mb", 0, 0, true, 0, 0, null, false, false, false, false, false, false, false, false);
    }

    public f4(Context context, g7.g gVar) {
        this(context, new g7.g[]{gVar});
    }
}
