package com.appsflyer.internal;

import com.appsflyer.AFLogger;
import com.appsflyer.deeplink.DeepLink;
import com.appsflyer.deeplink.DeepLinkResult;
import com.bytedance.covode.number.Covode;
import java.util.Map;
import org.json.JSONException;

public final class ap {
    static {
        Covode.recordClassIndex(2616);
    }

    public static void AFKeystoreWrapper(String str) {
        if (ai.AFInAppEventType != null) {
            try {
                AFLogger.AFInAppEventType("Calling onAppOpenAttributionFailure with: ".concat(String.valueOf(str)));
                ai.AFInAppEventType.onAttributionFailure(str);
            } catch (Throwable th) {
                AFLogger.valueOf(th.getLocalizedMessage(), th);
            }
        }
    }

    public static void AFKeystoreWrapper(Map<String, String> map) {
        if (ai.AFInAppEventType != null) {
            try {
                StringBuilder sb = new StringBuilder("Calling onAppOpenAttribution with:\n");
                sb.append(map.toString());
                AFLogger.AFInAppEventType(sb.toString());
                ai.AFInAppEventType.onAppOpenAttribution(map);
            } catch (Throwable th) {
                AFLogger.valueOf(th.getLocalizedMessage(), th);
            }
        }
    }

    public static void values(DeepLinkResult deepLinkResult) {
        if (i.values().valueOf != null) {
            StringBuilder sb = new StringBuilder("[DDL] Calling onDeepLinking with:\n");
            sb.append(deepLinkResult.toString());
            AFLogger.AFInAppEventType(sb.toString());
            try {
                i.values().valueOf.onDeepLinking(deepLinkResult);
            } catch (Throwable th) {
                AFLogger.valueOf(th.getLocalizedMessage(), th);
            }
        } else {
            AFLogger.AFInAppEventType("[DDL] skipping, no callback registered");
        }
    }

    public static void AFInAppEventParameterName(Map<String, String> map) {
        DeepLinkResult deepLinkResult;
        if (i.values().valueOf != null) {
            try {
                DeepLink AFKeystoreWrapper = DeepLink.AFKeystoreWrapper(map);
                AFKeystoreWrapper.values.put("is_deferred", false);
                deepLinkResult = new DeepLinkResult(AFKeystoreWrapper, (DeepLinkResult.Error) null);
            } catch (JSONException e) {
                AFLogger.values("[DDL] Error occurred", (Throwable) e);
                deepLinkResult = new DeepLinkResult((DeepLink) null, DeepLinkResult.Error.UNEXPECTED);
            } catch (Throwable th) {
                values(new DeepLinkResult((DeepLink) null, (DeepLinkResult.Error) null));
                throw th;
            }
            values(deepLinkResult);
            return;
        }
        AFKeystoreWrapper(map);
    }

    public static void AFInAppEventParameterName(String str, DeepLinkResult.Error error) {
        if (i.values().valueOf != null) {
            AFLogger.AFInAppEventType("[DDL] Error occurred: ".concat(String.valueOf(str)));
            values(new DeepLinkResult((DeepLink) null, error));
            return;
        }
        AFKeystoreWrapper(str);
    }
}
