package com.mbridge.msdk.newreward.function.a; import android.text.TextUtils; import com.mbridge.msdk.foundation.entity.CampaignEx; import com.mbridge.msdk.foundation.entity.j; import com.mbridge.msdk.foundation.tools.aq; import com.mbridge.msdk.foundation.tools.z; import com.mbridge.msdk.newreward.a.e; import java.util.ArrayList; import java.util.List; import java.util.Map; import org.json.JSONArray; import org.json.JSONObject; /* loaded from: classes4.dex */ public class a { public static int a = 4; public static int b = 5; private static String c = "BaseCandidateCache"; private JSONArray d; private JSONObject e; private String f; private int g; private String h; private e i; private com.mbridge.msdk.newreward.function.command.c j; public final void a(int i) { this.g = i; } public final void a(e eVar) { this.i = eVar; } public final void a(com.mbridge.msdk.newreward.function.command.c cVar) { this.j = cVar; } public final void a(JSONArray jSONArray) { this.d = jSONArray; } public final void e(String str) { this.f = str; } public final void f(String str) { this.h = str; } public final JSONObject a(String str) { JSONArray jSONArray = this.d; if (jSONArray == null) { return null; } if (jSONArray.length() > 1) { if (TextUtils.isEmpty(str)) { return null; } for (int i = 0; i < this.d.length(); i++) { try { JSONObject optJSONObject = this.d.optJSONObject(i); if (optJSONObject != null && str.equals(optJSONObject.getString("g"))) { this.e = optJSONObject; return optJSONObject; } } catch (Exception e) { e.printStackTrace(); } } return null; } return this.d.optJSONObject(0); } public final String b(String str) { b c2 = c(str); if (c2 != null && c2.h() != com.mbridge.msdk.foundation.b.c.c && c2.h() != com.mbridge.msdk.foundation.b.c.a) { String[] split = z.a(str.split("_")[3]).split("\\|"); if (split.length > 1) { return split[1]; } } return ""; } public final b c(String str) { b bVar = new b(); if (TextUtils.isEmpty(str) || str.split("_").length <= 3 || TextUtils.isEmpty(str.split("_")[3])) { bVar.d("bid token exception"); bVar.a(com.mbridge.msdk.foundation.b.c.a); return bVar; } JSONArray jSONArray = this.d; if (jSONArray == null || jSONArray.length() == 0) { bVar.d("config is empty"); bVar.a(com.mbridge.msdk.foundation.b.c.a); return bVar; } String a2 = z.a(str.split("_")[3]); if (TextUtils.isEmpty(a2)) { bVar.d("bid token exception:decode error"); bVar.a(com.mbridge.msdk.foundation.b.c.a); return bVar; } String[] split = a2.split("\\|"); if (split.length == 0) { bVar.d("bid token can not get bid price"); bVar.a(com.mbridge.msdk.foundation.b.c.a); return bVar; } if (split.length > 0) { try { String str2 = split[0]; } catch (Exception unused) { bVar.d("bid token can not cast bid price"); bVar.a(com.mbridge.msdk.foundation.b.c.a); return bVar; } } if (TextUtils.isEmpty(this.f)) { bVar.d("unitId is empty"); bVar.a(com.mbridge.msdk.foundation.b.c.c); } return bVar; } public final double d(String str) { b c2 = c(str); if (c2 != null && c2.h() != com.mbridge.msdk.foundation.b.c.c && c2.h() != com.mbridge.msdk.foundation.b.c.a) { try { String[] split = z.a(str.split("_")[3]).split("\\|"); if (split.length > 0) { return Double.parseDouble(split[0]); } } catch (Exception e) { e.printStackTrace(); } } return -1.0d; } public final void a(List list, com.mbridge.msdk.foundation.same.report.d.c cVar, String str, int i, String str2, int i2, double d) { if (list != null) { try { if (list.size() > 0) { for (int i3 = 0; i3 < list.size(); i3++) { CampaignEx h = list.get(i3).h(); h.setReadyState(0); if (cVar != null) { h.setNLRid(cVar.f()); } h.setNRid(str); h.setReasond(str2); h.setTyped(i); String b2 = z.b(d + ""); h.setNoticeUrl(a(h.getNoticeUrl(), i2, str, b2)); h.setClickURL(a(h.getClickURL(), i2, str, b2)); h.setImpressionURL(a(h.getImpressionURL(), i2, str, b2)); h.setOnlyImpressionURL(a(h.getOnlyImpressionURL(), i2, str, b2)); h.setAdvImp(a(h.getAdvImpList(), i2, str, b2)); j nativeVideoTracking = h.getNativeVideoTracking(); if (nativeVideoTracking != null) { nativeVideoTracking.k(a(nativeVideoTracking.l(), i2, str, b2)); nativeVideoTracking.c(a(nativeVideoTracking.c(), i2, str, b2)); nativeVideoTracking.o(a(nativeVideoTracking.p(), i2, str, b2)); nativeVideoTracking.s(a(nativeVideoTracking.t(), i2, str, b2)); nativeVideoTracking.a(a(nativeVideoTracking.a(), i2, str, b2)); nativeVideoTracking.b(a(nativeVideoTracking.b(), i2, str, b2)); nativeVideoTracking.r(a(nativeVideoTracking.s(), i2, str, b2)); nativeVideoTracking.u(a(nativeVideoTracking.v(), i2, str, b2)); nativeVideoTracking.t(a(nativeVideoTracking.v(), i2, str, b2)); nativeVideoTracking.v(a(nativeVideoTracking.w(), i2, str, b2)); nativeVideoTracking.h(a(nativeVideoTracking.h(), i2, str, b2)); nativeVideoTracking.p(a(nativeVideoTracking.q(), i2, str, b2)); nativeVideoTracking.q(a(nativeVideoTracking.r(), i2, str, b2)); nativeVideoTracking.n(a(nativeVideoTracking.o(), i2, str, b2)); nativeVideoTracking.e(a(nativeVideoTracking.e(), i2, str, b2)); nativeVideoTracking.f(a(nativeVideoTracking.f(), i2, str, b2)); nativeVideoTracking.g(a(nativeVideoTracking.g(), i2, str, b2)); nativeVideoTracking.i(a(nativeVideoTracking.j(), i2, str, b2)); nativeVideoTracking.j(a(nativeVideoTracking.k(), i2, str, b2)); nativeVideoTracking.l(a(nativeVideoTracking.m(), i2, str, b2)); nativeVideoTracking.a(a(nativeVideoTracking.i(), i2, str, b2)); nativeVideoTracking.d(a(nativeVideoTracking.d(), i2, str, b2)); nativeVideoTracking.m(a(nativeVideoTracking.n(), i2, str, b2)); h.setNativeVideoTracking(nativeVideoTracking); h.setNativeVideoTrackingString(CampaignEx.object2TrackingStr(nativeVideoTracking)); } h.setPv_urls(b(h.getPv_urls(), i2, str, b2)); } } } catch (Exception e) { e.printStackTrace(); } } } public final b a() { b bVar = new b(); try { JSONArray jSONArray = this.d; if (jSONArray == null || jSONArray.length() == 0) { bVar.d("setting config is null"); bVar.a(com.mbridge.msdk.foundation.b.c.a); return bVar; } } catch (Exception unused) { bVar.d("checkConfigAndDB exception"); bVar.a(com.mbridge.msdk.foundation.b.c.c); } return bVar; } public final List a(int i, int i2, String str) { return com.mbridge.msdk.newreward.function.d.c.a().b().a(i2, str, this.f, true, 0, ""); } private String a(String str, int i, String str2, String str3) { if (TextUtils.isEmpty(str) || str.contains("ca_sce") || str.contains("real_rid") || str.contains("real_bp")) { return str; } if (aq.c(str) > 0) { return str + "&ca_sce=" + i + "&real_rid=" + str2 + "&real_bp=" + str3; } return str + "?ca_sce=" + i + "&real_rid=" + str2 + "&real_bp=" + str3; } private String a(Map map, int i, String str, String str2) { if (map == null || map.size() == 0) { return null; } JSONArray jSONArray = new JSONArray(); try { for (Map.Entry entry : map.entrySet()) { String value = entry.getValue(); JSONObject jSONObject = new JSONObject(); jSONObject.put(CampaignEx.JSON_AD_IMP_KEY, entry.getKey()); jSONObject.put("url", a(value, i, str, str2)); jSONArray.put(jSONObject); } } catch (Exception e) { e.printStackTrace(); } if (jSONArray.length() == 0) { return null; } return jSONArray.toString(); } private String[] a(String[] strArr, int i, String str, String str2) { if (strArr == null || strArr.length == 0) { return strArr; } String[] strArr2 = new String[strArr.length]; for (int i2 = 0; i2 < strArr.length; i2++) { strArr2[i2] = a(strArr[i2], i, str, str2); } return strArr2; } private List> a(List> list, int i, String str, String str2) { if (list == null || list.size() == 0) { return list; } ArrayList arrayList = new ArrayList(); for (int i2 = 0; i2 < list.size(); i2++) { Map map = list.get(i2); if (map != null && map.size() > 0) { for (Map.Entry entry : map.entrySet()) { map.put(entry.getKey(), a(entry.getValue(), i, str, str2)); } arrayList.add(map); } } return arrayList; } private List b(List list, int i, String str, String str2) { if (list == null || list.size() == 0) { return list; } ArrayList arrayList = new ArrayList(); for (int i2 = 0; i2 < list.size(); i2++) { arrayList.add(a(list.get(i2), i, str, str2)); } return arrayList; } public final void a(String str, String str2, int i, double d) { if (d == 0.0d) { return; } try { if (i == 1) { a(a, 3, null, true, str2, str, -1, this.f); } else if (i == 2) { a(a, 1, null, true, str2, str, -1, this.f); } else if (i != 3) { } else { a(a, 4, null, true, str2, str, -1, this.f); } } catch (Exception e) { e.printStackTrace(); } } /* JADX WARN: Removed duplicated region for block: B:57:0x018b A[Catch: Exception -> 0x0028, TryCatch #1 {Exception -> 0x0028, blocks: (B:3:0x000d, B:6:0x002d, B:8:0x0067, B:11:0x0077, B:14:0x007d, B:16:0x009a, B:19:0x00a1, B:21:0x00a7, B:23:0x00af, B:25:0x0108, B:28:0x010c, B:32:0x0116, B:35:0x011c, B:38:0x0122, B:40:0x0130, B:42:0x0134, B:44:0x0146, B:46:0x014c, B:48:0x0154, B:50:0x016c, B:53:0x016f, B:55:0x0183, B:57:0x018b, B:58:0x0190, B:65:0x017b), top: B:2:0x000d, inners: #0 }] */ /* Code decompiled incorrectly, please refer to instructions dump. To view partially-correct add '--show-bad-code' argument */ private void a(int r17, int r18, java.util.List r19, boolean r20, java.lang.String r21, java.lang.String r22, int r23, java.lang.String r24) { /* Method dump skipped, instructions count: 429 To view this dump add '--comments-level debug' option */ throw new UnsupportedOperationException("Method not decompiled: com.mbridge.msdk.newreward.function.a.a.a(int, int, java.util.List, boolean, java.lang.String, java.lang.String, int, java.lang.String):void"); } /* renamed from: com.mbridge.msdk.newreward.function.a.a$a, reason: collision with other inner class name */ public static class C0215a { private com.mbridge.msdk.newreward.function.c.a.b a; private double b; public final com.mbridge.msdk.newreward.function.c.a.b a() { return this.a; } public C0215a(double d, com.mbridge.msdk.newreward.function.c.a.b bVar) { this.b = d; this.a = bVar; } } }