package com.facebook.appevents.codeless.internal; import com.tapjoy.TJAdUnitConstants; import java.util.ArrayList; import java.util.Arrays; import java.util.Collections; import java.util.List; import java.util.Locale; import kotlin.jvm.internal.DefaultConstructorMarker; import kotlin.jvm.internal.Intrinsics; import org.json.JSONArray; import org.json.JSONException; import org.json.JSONObject; /* loaded from: classes2.dex */ public final class EventBinding { public static final Companion Companion = new Companion(null); private final String activityName; private final String appVersion; private final String componentId; private final String eventName; private final MappingMethod method; private final List parameters; private final List path; private final String pathType; private final ActionType type; public static final EventBinding getInstanceFromJson(JSONObject jSONObject) throws JSONException, IllegalArgumentException { return Companion.getInstanceFromJson(jSONObject); } public static final List parseArray(JSONArray jSONArray) { return Companion.parseArray(jSONArray); } public final String getActivityName() { return this.activityName; } public final String getAppVersion() { return this.appVersion; } public final String getComponentId() { return this.componentId; } public final String getEventName() { return this.eventName; } public final MappingMethod getMethod() { return this.method; } public final String getPathType() { return this.pathType; } public final ActionType getType() { return this.type; } public EventBinding(String eventName, MappingMethod method, ActionType type, String appVersion, List path, List parameters, String componentId, String pathType, String activityName) { Intrinsics.checkNotNullParameter(eventName, "eventName"); Intrinsics.checkNotNullParameter(method, "method"); Intrinsics.checkNotNullParameter(type, "type"); Intrinsics.checkNotNullParameter(appVersion, "appVersion"); Intrinsics.checkNotNullParameter(path, "path"); Intrinsics.checkNotNullParameter(parameters, "parameters"); Intrinsics.checkNotNullParameter(componentId, "componentId"); Intrinsics.checkNotNullParameter(pathType, "pathType"); Intrinsics.checkNotNullParameter(activityName, "activityName"); this.eventName = eventName; this.method = method; this.type = type; this.appVersion = appVersion; this.path = path; this.parameters = parameters; this.componentId = componentId; this.pathType = pathType; this.activityName = activityName; } public final List getViewPath() { List unmodifiableList = Collections.unmodifiableList(this.path); Intrinsics.checkNotNullExpressionValue(unmodifiableList, "unmodifiableList(path)"); return unmodifiableList; } public final List getViewParameters() { List unmodifiableList = Collections.unmodifiableList(this.parameters); Intrinsics.checkNotNullExpressionValue(unmodifiableList, "unmodifiableList(parameters)"); return unmodifiableList; } public enum MappingMethod { MANUAL, INFERENCE; /* renamed from: values, reason: to resolve conflict with enum method */ public static MappingMethod[] valuesCustom() { MappingMethod[] valuesCustom = values(); return (MappingMethod[]) Arrays.copyOf(valuesCustom, valuesCustom.length); } } public enum ActionType { CLICK, SELECTED, TEXT_CHANGED; /* renamed from: values, reason: to resolve conflict with enum method */ public static ActionType[] valuesCustom() { ActionType[] valuesCustom = values(); return (ActionType[]) Arrays.copyOf(valuesCustom, valuesCustom.length); } } public static final class Companion { public /* synthetic */ Companion(DefaultConstructorMarker defaultConstructorMarker) { this(); } private Companion() { } public final List parseArray(JSONArray jSONArray) { ArrayList arrayList = new ArrayList(); if (jSONArray != null) { try { int length = jSONArray.length(); if (length > 0) { int i = 0; while (true) { int i2 = i + 1; JSONObject jSONObject = jSONArray.getJSONObject(i); Intrinsics.checkNotNullExpressionValue(jSONObject, "array.getJSONObject(i)"); arrayList.add(getInstanceFromJson(jSONObject)); if (i2 >= length) { break; } i = i2; } } } catch (IllegalArgumentException | JSONException unused) { } } return arrayList; } public final EventBinding getInstanceFromJson(JSONObject mapping) throws JSONException, IllegalArgumentException { int length; Intrinsics.checkNotNullParameter(mapping, "mapping"); String eventName = mapping.getString(TJAdUnitConstants.PARAM_PLACEMENT_NAME); String string = mapping.getString("method"); Intrinsics.checkNotNullExpressionValue(string, "mapping.getString(\"method\")"); Locale ENGLISH = Locale.ENGLISH; Intrinsics.checkNotNullExpressionValue(ENGLISH, "ENGLISH"); String upperCase = string.toUpperCase(ENGLISH); Intrinsics.checkNotNullExpressionValue(upperCase, "(this as java.lang.String).toUpperCase(locale)"); MappingMethod valueOf = MappingMethod.valueOf(upperCase); String string2 = mapping.getString("event_type"); Intrinsics.checkNotNullExpressionValue(string2, "mapping.getString(\"event_type\")"); Intrinsics.checkNotNullExpressionValue(ENGLISH, "ENGLISH"); String upperCase2 = string2.toUpperCase(ENGLISH); Intrinsics.checkNotNullExpressionValue(upperCase2, "(this as java.lang.String).toUpperCase(locale)"); ActionType valueOf2 = ActionType.valueOf(upperCase2); String appVersion = mapping.getString("app_version"); JSONArray jSONArray = mapping.getJSONArray("path"); ArrayList arrayList = new ArrayList(); int length2 = jSONArray.length(); int i = 0; if (length2 > 0) { int i2 = 0; while (true) { int i3 = i2 + 1; JSONObject jsonPath = jSONArray.getJSONObject(i2); Intrinsics.checkNotNullExpressionValue(jsonPath, "jsonPath"); arrayList.add(new PathComponent(jsonPath)); if (i3 >= length2) { break; } i2 = i3; } } String pathType = mapping.optString(Constants.EVENT_MAPPING_PATH_TYPE_KEY, Constants.PATH_TYPE_ABSOLUTE); JSONArray optJSONArray = mapping.optJSONArray("parameters"); ArrayList arrayList2 = new ArrayList(); if (optJSONArray != null && (length = optJSONArray.length()) > 0) { while (true) { int i4 = i + 1; JSONObject jsonParameter = optJSONArray.getJSONObject(i); Intrinsics.checkNotNullExpressionValue(jsonParameter, "jsonParameter"); arrayList2.add(new ParameterComponent(jsonParameter)); if (i4 >= length) { break; } i = i4; } } String componentId = mapping.optString("component_id"); String activityName = mapping.optString("activity_name"); Intrinsics.checkNotNullExpressionValue(eventName, "eventName"); Intrinsics.checkNotNullExpressionValue(appVersion, "appVersion"); Intrinsics.checkNotNullExpressionValue(componentId, "componentId"); Intrinsics.checkNotNullExpressionValue(pathType, "pathType"); Intrinsics.checkNotNullExpressionValue(activityName, "activityName"); return new EventBinding(eventName, valueOf, valueOf2, appVersion, arrayList, arrayList2, componentId, pathType, activityName); } } }