package defpackage;

import java.util.Collection;
import java.util.HashMap;
import java.util.Map;

/* JADX INFO: renamed from: ᵹᵔᵥ, reason: contains not printable characters */
/* JADX INFO: loaded from: classes3.dex */
public final class C5067 {

    /* JADX INFO: renamed from: ᵻˈᵦʼ, reason: contains not printable characters */
    public static final C2669 f19116 = new C2669();

    /* JADX INFO: renamed from: ʽˈˋ, reason: contains not printable characters */
    public Object f19117;

    /* JADX INFO: renamed from: ːˏᵟᵯ, reason: contains not printable characters */
    public Object f19118;

    /* JADX INFO: renamed from: ᵨᵣ, reason: contains not printable characters */
    public Object f19119;

    /* JADX INFO: renamed from: ᵲᵶᵳˈ, reason: contains not printable characters */
    public boolean f19120;

    /* JADX INFO: renamed from: ᵷᵺʾᵖ, reason: contains not printable characters */
    public Object f19121;

    /* JADX WARN: Removed duplicated region for block: B:110:0x027a  */
    /* JADX WARN: Removed duplicated region for block: B:111:0x027d  */
    /* JADX WARN: Removed duplicated region for block: B:114:0x0283  */
    /* JADX WARN: Removed duplicated region for block: B:116:0x029b  */
    /* JADX WARN: Removed duplicated region for block: B:40:0x00f2  */
    /*
        Code decompiled incorrectly, please refer to instructions dump.
    */
    public C5067(C2831 c2831, C4240 c4240) {
        C1323 c1323M4052;
        char c;
        long j;
        long j2;
        int i = 1;
        this.f19120 = true;
        C2533 c2533 = c2831.f10857;
        C2774 c2774 = c2831.f10856;
        if (c2533.f9801.isEmpty()) {
            C2774.m6697().equals(c2774);
        }
        this.f19117 = c2774.m6700();
        this.f19118 = c2774.m6698();
        c2774.getClass();
        c2774.getClass();
        Map mapM6703 = c2774.m6701() == 0 ? null : c2774.m6703();
        if (mapM6703 != null) {
            AbstractC5291.m10886(mapM6703.keySet());
        } else {
            Object[] objArr = C5196.f19564;
        }
        int iM6701 = c2774.m6701();
        C2533 c25332 = c2831.f10857;
        char c2 = 3;
        if (iM6701 > 0) {
            Collection<C2289> collectionValues = c2774.m6703().values();
            if (collectionValues == null) {
                c1323M4052 = C1323.f5510;
            } else {
                C1404 c1404M7805 = AbstractC3409.m7805();
                for (C2289 c2289 : collectionValues) {
                    int iM5907 = c2289.m5907();
                    int i2 = iM5907 - 1;
                    if (iM5907 == 0) {
                        throw null;
                    }
                    if (i2 == 0) {
                        c1404M7805.m4036(c2289.m5911(), Long.valueOf(c2289.m5908()));
                    } else if (i2 == 1) {
                        c1404M7805.m4036(c2289.m5911(), Boolean.valueOf(c2289.m5909()));
                    } else if (i2 == 2) {
                        c1404M7805.m4036(c2289.m5911(), Double.valueOf(c2289.m5914()));
                    } else if (i2 == 3) {
                        c1404M7805.m4036(c2289.m5911(), c2289.m5913());
                    } else {
                        if (i2 != 4) {
                            ᵕᵩʽᵲ.ᵪᵹᵥᵻ("Could not serialize Flag for override: ".concat(String.valueOf(c2289.m5911())));
                            throw null;
                        }
                        c1404M7805.m4036(c2289.m5911(), c2289.m5916().m9797());
                    }
                }
                c1323M4052 = c1404M7805.m4052(false);
            }
            if (!c1323M4052.isEmpty()) {
                HashMap map = new HashMap(c1323M4052);
                AbstractC4307 abstractC4307 = c25332.f9801;
                C4663 c4663 = new C4663();
                AbstractC0228 it = abstractC4307.iterator();
                while (true) {
                    AbstractC3171 abstractC3171 = (AbstractC3171) it;
                    if (abstractC3171.hasNext()) {
                        C3518 c3518 = (C3518) abstractC3171.next();
                        Object obj = c3518.f13507;
                        long j3 = c3518.f13505;
                        Object objRemove = map.remove(obj == null ? Long.toString(j3) : obj);
                        if (objRemove == null) {
                            c4663.m7406(c3518);
                        } else if (objRemove instanceof String) {
                            c4663.m7406(new C3518(c3518.f13505, c3518.f13507, 4, 0L, objRemove));
                        } else if (objRemove instanceof byte[]) {
                            c4663.m7406(new C3518(c3518.f13505, c3518.f13507, 5, 0L, objRemove));
                        } else if (objRemove instanceof Boolean) {
                            c4663.m7406(new C3518(c3518.f13505, c3518.f13507, ((Boolean) objRemove).booleanValue() ? 1 : 0, 0L, null));
                        } else if (objRemove instanceof Long) {
                            c4663.m7406(new C3518(c3518.f13505, c3518.f13507, 2, ((Long) objRemove).longValue(), null));
                        } else {
                            if (!(objRemove instanceof Double)) {
                                String string = c3518.f13507;
                                string = string == null ? Long.toString(j3) : string;
                                String string2 = objRemove.toString();
                                StringBuilder sb = new StringBuilder(String.valueOf(string).length() + 46 + string2.length());
                                sb.append("Cannot serialize override for existing flag ");
                                sb.append(string);
                                sb.append(": ");
                                sb.append(string2);
                                throw new IllegalStateException(sb.toString());
                            }
                            c4663.m7406(new C3518(c3518.f13505, c3518.f13507, 3, Double.doubleToRawLongBits(((Double) objRemove).doubleValue()), null));
                        }
                    } else {
                        for (String str : map.keySet()) {
                            Object obj2 = map.get(str);
                            int length = str.length();
                            if (length <= 19) {
                                if (length == 0) {
                                    c = c2;
                                } else {
                                    c = c2;
                                    long jCharAt = str.charAt(0) - '0';
                                    if (jCharAt >= 1) {
                                        if (jCharAt <= 9) {
                                            int i3 = i;
                                            while (true) {
                                                if (i3 >= length) {
                                                    j = 0;
                                                    if (jCharAt < 0 || jCharAt > 2305843009213693951L) {
                                                        break;
                                                    } else {
                                                        j2 = jCharAt;
                                                    }
                                                } else {
                                                    int iCharAt = str.charAt(i3) - '0';
                                                    j = 0;
                                                    if ((iCharAt < 0) || (iCharAt > 9)) {
                                                        break;
                                                    }
                                                    jCharAt = (jCharAt * 10) + ((long) iCharAt);
                                                    i3++;
                                                }
                                            }
                                        }
                                        String str2 = j2 != j ? str : null;
                                        if (!(obj2 instanceof String)) {
                                            c4663.m7406(new C3518(j2, str2, 4, 0L, obj2));
                                        } else if (obj2 instanceof byte[]) {
                                            c4663.m7406(new C3518(j2, str2, 5, 0L, obj2));
                                        } else if (obj2 instanceof Boolean) {
                                            c4663.m7406(new C3518(j2, str2, ((Boolean) obj2).booleanValue() ? 1 : 0, 0L, null));
                                        } else if (obj2 instanceof Long) {
                                            c4663.m7406(new C3518(j2, str2, 2, ((Long) obj2).longValue(), null));
                                        } else {
                                            if (!(obj2 instanceof Double)) {
                                                String strValueOf = String.valueOf(obj2);
                                                StringBuilder sb2 = new StringBuilder(str.length() + 28 + strValueOf.length());
                                                sb2.append("Cannot serialize override ");
                                                sb2.append(str);
                                                sb2.append(": ");
                                                sb2.append(strValueOf);
                                                throw new IllegalStateException(sb2.toString());
                                            }
                                            c4663.m7406(new C3518(j2, str2, 3, Double.doubleToRawLongBits(((Double) obj2).doubleValue()), null));
                                        }
                                        c2 = c;
                                        i = 1;
                                    }
                                    j2 = j;
                                    if (j2 != j) {
                                    }
                                    if (!(obj2 instanceof String)) {
                                    }
                                    c2 = c;
                                    i = 1;
                                }
                                j = 0;
                                j2 = 0;
                                if (j2 != j) {
                                }
                                if (!(obj2 instanceof String)) {
                                }
                                c2 = c;
                                i = 1;
                            } else {
                                c = c2;
                            }
                            j = 0;
                            j2 = j;
                            if (j2 != j) {
                            }
                            if (!(obj2 instanceof String)) {
                            }
                            c2 = c;
                            i = 1;
                        }
                        c25332 = new C2533(c4663.m9792());
                    }
                }
            }
        }
        int size = ((C4286) c25332.f9801).f16348.size() + 3;
        ˑᵕʾ.ːˏᵟᵯ(size, "expectedSize");
        C1404 c1404 = new C1404(size);
        AbstractC0228 it2 = c25332.f9801.iterator();
        while (true) {
            AbstractC3171 abstractC31712 = (AbstractC3171) it2;
            if (!abstractC31712.hasNext()) {
                c1404.m4036("__phenotype_server_token", c2774.m6699());
                c1404.m4036("__phenotype_snapshot_token", c2774.m6700());
                c1404.m4036("__phenotype_configuration_version", Long.valueOf(c2774.m6702()));
                this.f19121 = c1404.m4052(false);
                this.f19119 = c4240;
                return;
            }
            C3518 c35182 = (C3518) abstractC31712.next();
            String string3 = c35182.f13507;
            if (string3 == null) {
                string3 = Long.toString(c35182.f13505);
            }
            c1404.m4036(string3, c35182.m8018());
        }
    }

    public C5067(C3095 c3095, C4240 c4240) {
        this.f19120 = false;
        C3095.m7179().equals(c3095);
        this.f19117 = c3095.m7185();
        this.f19118 = c3095.m7182();
        int i = AbstractC5291.f20005;
        Object[] objArr = C5196.f19564;
        int iM7189 = c3095.m7189() + 3;
        ˑᵕʾ.ːˏᵟᵯ(iM7189, "expectedSize");
        C1404 c1404 = new C1404(iM7189);
        for (C4992 c4992 : c3095.m7187()) {
            int iM10319 = c4992.m10319();
            int i2 = iM10319 - 1;
            if (iM10319 == 0) {
                throw null;
            }
            if (i2 == 0) {
                c1404.m4036(c4992.m10315(), Long.valueOf(c4992.m10312()));
            } else if (i2 == 1) {
                c1404.m4036(c4992.m10315(), Boolean.valueOf(c4992.m10313()));
            } else if (i2 == 2) {
                c1404.m4036(c4992.m10315(), Double.valueOf(c4992.m10318()));
            } else if (i2 == 3) {
                c1404.m4036(c4992.m10315(), c4992.m10317());
            } else if (i2 == 4) {
                c1404.m4036(c4992.m10315(), c4992.m10320().m9797());
            }
        }
        c1404.m4036("__phenotype_server_token", c3095.m7183());
        c1404.m4036("__phenotype_snapshot_token", c3095.m7185());
        c1404.m4036("__phenotype_configuration_version", Long.valueOf(c3095.m7188()));
        this.f19121 = c1404.m4052(false);
        this.f19119 = c4240;
    }

    public C5067(InterfaceC4291 interfaceC4291, C5286 c5286, C0085 c0085, InterfaceC1471 interfaceC1471, boolean z) {
        this.f19117 = interfaceC4291;
        this.f19118 = c5286;
        this.f19121 = c0085;
        this.f19119 = interfaceC1471;
        this.f19120 = z;
    }
}
