package com.google.android.gms.measurement.internal;

import android.content.Context;
import android.content.SharedPreferences;
import android.os.Bundle;
import java.nio.ByteBuffer;
import java.security.GeneralSecurityException;
import java.util.Arrays;
import tv.danmaku.ijk.media.player.IjkMediaPlayer;

/* JADX INFO: loaded from: classes2.dex */
public abstract class c2 {

    /* JADX INFO: renamed from: a, reason: collision with root package name */
    public static final String[] f21498a = {"ad_activeview", "ad_click", "ad_exposure", "ad_query", "ad_reward", "adunit_exposure", "app_clear_data", "app_exception", "app_remove", "app_store_refund", "app_store_subscription_cancel", "app_store_subscription_convert", "app_store_subscription_renew", "app_upgrade", "app_update", "ga_campaign", IjkMediaPlayer.OnNativeInvokeListener.ARG_ERROR, "first_open", "first_visit", "in_app_purchase", "notification_dismiss", "notification_foreground", "notification_open", "notification_receive", "os_update", "session_start", "session_start_with_rollout", "user_engagement", "ad_impression", "screen_view", "ga_extra_parameter", "app_background", "firebase_campaign"};

    /* JADX INFO: renamed from: b, reason: collision with root package name */
    public static final String[] f21499b = {"ad_impression"};

    /* JADX INFO: renamed from: c, reason: collision with root package name */
    public static final String[] f21500c = {"_aa", "_ac", "_xa", "_aq", "_ar", "_xu", "_cd", "_ae", "_ui", "app_store_refund", "app_store_subscription_cancel", "app_store_subscription_convert", "app_store_subscription_renew", "_ug", "_au", "_cmp", "_err", "_f", "_v", "_iap", "_nd", "_nf", "_no", "_nr", "_ou", "_s", "_ssr", "_e", "_ai", "_vs", "_ep", "_ab", "_cmp"};

    /* JADX INFO: renamed from: d, reason: collision with root package name */
    public static final String[] f21501d = {"purchase", "refund", "add_payment_info", "add_shipping_info", "add_to_cart", "add_to_wishlist", "begin_checkout", "remove_from_cart", "select_item", "select_promotion", "view_cart", "view_item", "view_item_list", "view_promotion", "ecommerce_purchase", "purchase_refund", "set_checkout_option", "checkout_progress", "select_content", "view_search_results"};

    /* JADX INFO: renamed from: e, reason: collision with root package name */
    public static final String[] f21502e = {"firebase_last_notification", "first_open_time", "first_visit_time", "last_deep_link_referrer", "user_id", "last_advertising_id_reset", "first_open_after_install", "lifetime_user_engagement", "session_user_engagement", "non_personalized_ads", "ga_session_number", "ga_session_id", "last_gclid", "session_number", "session_id"};

    /* JADX INFO: renamed from: f, reason: collision with root package name */
    public static final String[] f21503f = {"_ln", "_fot", "_fvt", "_ldl", "_id", "_lair", "_fi", "_lte", "_se", "_npa", "_sno", "_sid", "_lgclid", "_sno", "_sid"};

    /* JADX INFO: renamed from: g, reason: collision with root package name */
    public static final String[] f21504g = {"ga_conversion", "engagement_time_msec", "exposure_time", "ad_event_id", "ad_unit_id", "ga_error", "ga_error_value", "ga_error_length", "ga_event_origin", "ga_screen", "ga_screen_class", "ga_screen_id", "ga_previous_screen", "ga_previous_class", "ga_previous_id", "manual_tracking", "message_device_time", "message_id", "message_name", "message_time", "message_tracking_id", "message_type", "previous_app_version", "previous_os_version", "topic", "update_with_analytics", "previous_first_open_count", "system_app", "system_app_update", "previous_install_count", "ga_event_id", "ga_extra_params_ct", "ga_group_name", "ga_list_length", "ga_index", "ga_event_name", "campaign_info_source", "cached_campaign", "deferred_analytics_collection", "ga_session_number", "ga_session_id", "campaign_extra_referrer", "app_in_background", "firebase_feature_rollouts", "firebase_conversion", "firebase_error", "firebase_error_value", "firebase_error_length", "firebase_event_origin", "firebase_screen", "firebase_screen_class", "firebase_screen_id", "firebase_previous_screen", "firebase_previous_class", "firebase_previous_id", "session_number", "session_id"};

    /* JADX INFO: renamed from: h, reason: collision with root package name */
    public static final String[] f21505h = {"_c", "_et", "_xt", "_aeid", "_ai", "_err", "_ev", "_el", "_o", "_sn", "_sc", "_si", "_pn", "_pc", "_pi", "_mst", "_ndt", "_nmid", "_nmn", "_nmt", "_nmtid", "_nmc", "_pv", "_po", "_nt", "_uwa", "_pfo", "_sys", "_sysu", "_pin", "_eid", "_epc", "_gn", "_ll", "_i", "_en", "_cis", "_cc", "_dac", "_sno", "_sid", "_cer", "_aib", "_ffr", "_c", "_err", "_ev", "_el", "_o", "_sn", "_sc", "_si", "_pn", "_pc", "_pi", "_sno", "_sid"};

    /* JADX INFO: renamed from: i, reason: collision with root package name */
    public static final String[] f21506i = {"items"};

    /* JADX INFO: renamed from: j, reason: collision with root package name */
    public static final String[] f21507j = {"affiliation", "coupon", "creative_name", "creative_slot", "currency", "discount", "index", "item_id", "item_brand", "item_category", "item_category2", "item_category3", "item_category4", "item_category5", "item_list_name", "item_list_id", "item_name", "item_variant", "location_id", "payment_type", "price", "promotion_id", "promotion_name", "quantity", "shipping", "shipping_tier", "tax", "transaction_id", "value", "item_list", "checkout_step", "checkout_option", "item_location_id"};

    public static float a(float f10, float f11, int i10) {
        return (Math.max(0, i10 - 1) * f11) + f10;
    }

    public static float b(float f10, float f11, int i10) {
        return i10 > 0 ? (f11 / 2.0f) + f10 : f10;
    }

    public static void c(float[] fArr, float f10) {
        if (f10 <= 0.5f) {
            fArr[0] = 1.0f - (f10 * 2.0f);
            fArr[1] = 0.0f;
        } else {
            fArr[0] = 0.0f;
            fArr[1] = (f10 * 2.0f) - 1.0f;
        }
    }

    public static void d(long j10, String str) {
        if (j10 >= 0) {
            return;
        }
        throw new IllegalArgumentException(str + " (" + j10 + ") must be >= 0");
    }

    public static byte[] e(byte[] bArr, byte[] bArr2) {
        if (bArr.length != 32) {
            throw new IllegalArgumentException("The key length in bytes must be 32.");
        }
        byte b10 = 0;
        long jK = k(0, bArr) & 67108863;
        long jK2 = (k(3, bArr) >> 2) & 67108611;
        long jK3 = (k(6, bArr) >> 4) & 67092735;
        long jK4 = (k(9, bArr) >> 6) & 66076671;
        long jK5 = (k(12, bArr) >> 8) & 1048575;
        long j10 = jK2 * 5;
        long j11 = jK3 * 5;
        long j12 = jK4 * 5;
        long j13 = jK5 * 5;
        int i10 = 17;
        byte[] bArr3 = new byte[17];
        long j14 = 0;
        int i11 = 0;
        long j15 = 0;
        long j16 = 0;
        long j17 = 0;
        long j18 = 0;
        while (i11 < bArr2.length) {
            int iMin = Math.min(16, bArr2.length - i11);
            System.arraycopy(bArr2, i11, bArr3, b10, iMin);
            bArr3[iMin] = 1;
            if (iMin != 16) {
                Arrays.fill(bArr3, iMin + 1, i10, b10);
            }
            long jK6 = j18 + (k(b10, bArr3) & 67108863);
            long jK7 = j14 + ((k(3, bArr3) >> 2) & 67108863);
            long jK8 = j15 + ((k(6, bArr3) >> 4) & 67108863);
            long jK9 = j16 + ((k(9, bArr3) >> 6) & 67108863);
            long jK10 = j17 + (((k(12, bArr3) >> 8) & 67108863) | ((long) (bArr3[16] << 24)));
            long j19 = (jK10 * j10) + (jK9 * j11) + (jK8 * j12) + (jK7 * j13) + (jK6 * jK);
            long j20 = (jK10 * j11) + (jK9 * j12) + (jK8 * j13) + (jK7 * jK) + (jK6 * jK2);
            long j21 = (jK10 * j12) + (jK9 * j13) + (jK8 * jK) + (jK7 * jK2) + (jK6 * jK3);
            long j22 = (jK10 * j13) + (jK9 * jK) + (jK8 * jK2) + (jK7 * jK3) + (jK6 * jK4);
            long j23 = jK9 * jK2;
            long j24 = jK10 * jK;
            long j25 = j20 + (j19 >> 26);
            long j26 = j21 + (j25 >> 26);
            long j27 = j22 + (j26 >> 26);
            long j28 = j24 + j23 + (jK8 * jK3) + (jK7 * jK4) + (jK6 * jK5) + (j27 >> 26);
            long j29 = j28 >> 26;
            j17 = j28 & 67108863;
            long j30 = (j29 * 5) + (j19 & 67108863);
            long j31 = j30 & 67108863;
            j14 = (j25 & 67108863) + (j30 >> 26);
            i11 += 16;
            j15 = j26 & 67108863;
            j16 = j27 & 67108863;
            b10 = 0;
            i10 = 17;
            j18 = j31;
        }
        long j32 = j15 + (j14 >> 26);
        long j33 = j32 & 67108863;
        long j34 = j16 + (j32 >> 26);
        long j35 = j34 & 67108863;
        long j36 = j17 + (j34 >> 26);
        long j37 = j36 & 67108863;
        long j38 = ((j36 >> 26) * 5) + j18;
        long j39 = j38 >> 26;
        long j40 = j38 & 67108863;
        long j41 = (j14 & 67108863) + j39;
        long j42 = j40 + 5;
        long j43 = j42 & 67108863;
        long j44 = j41 + (j42 >> 26);
        long j45 = j33 + (j44 >> 26);
        long j46 = j35 + (j45 >> 26);
        long j47 = (j37 + (j46 >> 26)) - 67108864;
        long j48 = j47 >> 63;
        long j49 = ~j48;
        long j50 = (j41 & j48) | (j44 & 67108863 & j49);
        long j51 = (j33 & j48) | (j45 & 67108863 & j49);
        long j52 = (j35 & j48) | (j46 & 67108863 & j49);
        long j53 = ((j40 & j48) | (j43 & j49) | (j50 << 26)) & 4294967295L;
        long j54 = ((j50 >> 6) | (j51 << 20)) & 4294967295L;
        long j55 = ((j51 >> 12) | (j52 << 14)) & 4294967295L;
        long j56 = ((((j47 & j49) | (j37 & j48)) << 8) | (j52 >> 18)) & 4294967295L;
        long jK11 = k(16, bArr) + j53;
        long jK12 = k(20, bArr) + j54 + (jK11 >> 32);
        long jK13 = k(24, bArr) + j55 + (jK12 >> 32);
        long jK14 = (k(28, bArr) + j56 + (jK13 >> 32)) & 4294967295L;
        byte[] bArr4 = new byte[16];
        l(jK11 & 4294967295L, bArr4, 0);
        l(jK12 & 4294967295L, bArr4, 4);
        l(jK13 & 4294967295L, bArr4, 8);
        l(jK14, bArr4, 12);
        return bArr4;
    }

    public static byte[] f(byte[]... bArr) throws GeneralSecurityException {
        int length = 0;
        for (byte[] bArr2 : bArr) {
            if (length > Integer.MAX_VALUE - bArr2.length) {
                throw new GeneralSecurityException("exceeded size limit");
            }
            length += bArr2.length;
        }
        byte[] bArr3 = new byte[length];
        int length2 = 0;
        for (byte[] bArr4 : bArr) {
            System.arraycopy(bArr4, 0, bArr3, length2, bArr4.length);
            length2 += bArr4.length;
        }
        return bArr3;
    }

    public static float g(float f10, float f11, float f12, float f13) {
        return (float) Math.hypot(f12 - f10, f13 - f11);
    }

    public static float h(float f10, float f11, float f12, float f13) {
        float fG = g(f10, f11, 0.0f, 0.0f);
        float fG2 = g(f10, f11, f12, 0.0f);
        float fG3 = g(f10, f11, f12, f13);
        float fG4 = g(f10, f11, 0.0f, f13);
        return (fG <= fG2 || fG <= fG3 || fG <= fG4) ? (fG2 <= fG3 || fG2 <= fG4) ? fG3 > fG4 ? fG3 : fG4 : fG2 : fG;
    }

    public static SharedPreferences i(Context context) {
        Context applicationContext = context.getApplicationContext();
        if (applicationContext != null) {
            context = applicationContext;
        }
        return context.getSharedPreferences("com.google.firebase.messaging", 0);
    }

    public static float j(float f10, float f11, float f12) {
        return (f12 * f11) + ((1.0f - f12) * f10);
    }

    public static long k(int i10, byte[] bArr) {
        return ((long) (((bArr[i10 + 3] & 255) << 24) | (bArr[i10] & 255) | ((bArr[i10 + 1] & 255) << 8) | ((bArr[i10 + 2] & 255) << 16))) & 4294967295L;
    }

    public static void l(long j10, byte[] bArr, int i10) {
        int i11 = 0;
        while (i11 < 4) {
            bArr[i10 + i11] = (byte) (255 & j10);
            i11++;
            j10 >>= 8;
        }
    }

    public static float m(float f10, int i10, float f11, float f12) {
        return i10 > 0 ? (f12 / 2.0f) + f11 : f10;
    }

    public static final void n(ByteBuffer byteBuffer, ByteBuffer byteBuffer2, ByteBuffer byteBuffer3, int i10) {
        if (i10 < 0 || byteBuffer2.remaining() < i10 || byteBuffer3.remaining() < i10 || byteBuffer.remaining() < i10) {
            throw new IllegalArgumentException("That combination of buffers, offsets and length to xor result in out-of-bond accesses.");
        }
        for (int i11 = 0; i11 < i10; i11++) {
            byteBuffer.put((byte) (byteBuffer2.get() ^ byteBuffer3.get()));
        }
    }

    public static final byte[] o(byte[] bArr, int i10, byte[] bArr2, int i11) {
        if (i11 < 0 || bArr.length - i11 < i10 || bArr2.length - i11 < 0) {
            throw new IllegalArgumentException("That combination of buffers, offsets and length to xor result in out-of-bond accesses.");
        }
        byte[] bArr3 = new byte[i11];
        for (int i12 = 0; i12 < i11; i12++) {
            bArr3[i12] = (byte) (bArr[i12 + i10] ^ bArr2[i12]);
        }
        return bArr3;
    }

    public static final byte[] p(byte[] bArr, byte[] bArr2) {
        if (bArr.length == bArr2.length) {
            return o(bArr, 0, bArr2, bArr.length);
        }
        throw new IllegalArgumentException("The lengths of x and y should match.");
    }

    public static Object q(Bundle bundle, String str, Class cls, Object obj) {
        Object obj2 = bundle.get(str);
        if (obj2 == null) {
            return obj;
        }
        if (cls.isAssignableFrom(obj2.getClass())) {
            return obj2;
        }
        throw new IllegalStateException(String.format("Invalid conditional user property field type. '%s' expected [%s] but was [%s]", str, cls.getCanonicalName(), obj2.getClass().getCanonicalName()));
    }

    public static void r(Bundle bundle, Object obj) {
        if (obj instanceof Double) {
            bundle.putDouble("value", ((Double) obj).doubleValue());
        } else if (obj instanceof Long) {
            bundle.putLong("value", ((Long) obj).longValue());
        } else {
            bundle.putString("value", obj.toString());
        }
    }
}
