package com.ss.android.ugc.aweme.settingsrequest;

import X.3p3;
import X.46i;
import X.4F9;
import X.4FD;
import X.AnonymousClass7nK;
import X.AnonymousClass9EH;
import X.AnonymousClass9XL;
import X.C09537tw;
import X.C10167ux;
import X.C11137wW;
import X.C11157wY;
import X.C22408Zb;
import X.C396693l;
import X.C41499Am;
import X.C41509An;
import X.C47939Zg;
import X.C48109Zx;
import X.Lnj;
import X.MKj;
import X.SfZ;
import android.app.Activity;
import android.content.Context;
import android.content.SharedPreferences;
import android.net.Uri;
import android.text.TextUtils;
import com.bytedance.covode.number.Covode;
import com.bytedance.frameworks.apm.trace.MethodCollector;
import com.google.gson.m;
import com.ss.android.ugc.aweme.global.config.settings.pojo.IESSettingsProxy;
import com.ss.android.ugc.aweme.settingsrequest.api.ISettingsRequestService;
import java.util.List;
import java.util.Map;
import org.json.JSONException;
import org.json.JSONObject;

public class SettingsRequestServiceImpl implements ISettingsRequestService {
    static {
        Covode.recordClassIndex(106780);
    }

    public final String LJII() {
        return "user_badge_click_settings";
    }

    public final int LIZLLL() {
        return AnonymousClass7nK.LIZ;
    }

    public final int LJ() {
        return AnonymousClass7nK.LIZIZ;
    }

    public final boolean LJFF() {
        return AnonymousClass7nK.LIZJ;
    }

    public final void LIZ(Map<String, String> map) {
        if (map != null) {
            C41509An.LIZJ.putAll(map);
        }
    }

    public final void LIZ(JSONObject jSONObject) {
        C11157wY r1;
        if (jSONObject != null && !TextUtils.isEmpty(jSONObject.toString()) && (r1 = (C11157wY) C11137wW.LIZ.getValue()) != null) {
            r1.LIZ(jSONObject.toString());
        }
    }

    public final MKj LIZIZ() {
        return C41499Am.LIZ.LIZIZ();
    }

    public final boolean LIZJ() {
        return C41499Am.LIZ.LIZJ();
    }

    public final C22408Zb LJI() {
        return new AnonymousClass9XL();
    }

    public final List<4FD> LIZ() {
        return C41499Am.LIZ.LIZ();
    }

    public static ISettingsRequestService LJIIIIZZ() {
        MethodCollector.i(4689);
        ISettingsRequestService iSettingsRequestService = (ISettingsRequestService) Lnj.LIZ(ISettingsRequestService.class, false);
        if (iSettingsRequestService != null) {
            MethodCollector.o(4689);
            return iSettingsRequestService;
        }
        Object LIZIZ = Lnj.LIZIZ(ISettingsRequestService.class, false);
        if (LIZIZ != null) {
            ISettingsRequestService iSettingsRequestService2 = (ISettingsRequestService) LIZIZ;
            MethodCollector.o(4689);
            return iSettingsRequestService2;
        }
        if (Lnj.bf == null) {
            synchronized (ISettingsRequestService.class) {
                try {
                    if (Lnj.bf == null) {
                        Lnj.bf = new SettingsRequestServiceImpl();
                    }
                } catch (Throwable th) {
                    MethodCollector.o(4689);
                    throw th;
                }
            }
        }
        SettingsRequestServiceImpl settingsRequestServiceImpl = (SettingsRequestServiceImpl) Lnj.bf;
        MethodCollector.o(4689);
        return settingsRequestServiceImpl;
    }

    public final void LIZ(3p3 r2) {
        4F9.LIZ.LIZ(r2);
    }

    public final void LIZ(4FD r3) {
        4F9.LIZ.LIZ(r3, false);
    }

    public final JSONObject LIZIZ(String str) {
        if (str == null || str.isEmpty()) {
            return null;
        }
        JSONObject jSONObject = new JSONObject();
        String[] split = Uri.decode(str).split(",");
        try {
            m mVar = new m();
            for (int i = 0; i < split.length; i++) {
                C10167ux.LIZ.LIZ(mVar, split[i], C10167ux.LIZ.LIZ(split[i]));
            }
            return new JSONObject(mVar.toString());
        } catch (JSONException unused) {
            return jSONObject;
        }
    }

    public final void LIZ(C47939Zg r2) {
        C41499Am.LIZ.LIZ(r2);
    }

    public final void LIZ(Activity activity) {
        C41499Am.LIZ.LIZ(activity);
    }

    public final void LIZ(Context context) {
        if (!SfZ.LJIIJJI) {
            if (C48109Zx.LIZ(AnonymousClass9EH.LJJIFFI.LIZ())) {
                C396693l.LIZ = false;
                C396693l.LIZ();
            } else {
                C09537tw.LIZ().initPushAccountService(46i.LJFF().isLogin());
            }
        }
        C41499Am.LIZ.LIZ(context);
    }

    public final void LIZ(m mVar) {
        C41499Am.LIZ.LIZ(mVar);
    }

    /* JADX WARNING: Removed duplicated region for block: B:41:0x00a1 A[Catch:{ Exception -> 0x00d2 }] */
    /* JADX WARNING: Removed duplicated region for block: B:64:0x0044 A[SYNTHETIC] */
    /* Code decompiled incorrectly, please refer to instructions dump. */
    public final void LIZ(java.lang.String r18) {
        /*
            r17 = this;
            boolean r0 = android.text.TextUtils.isEmpty(r18)
            if (r0 != 0) goto L_0x0008
            X.C41509An.LIZIZ = r18
        L_0x0008:
            boolean r0 = X.C41509An.LIZ
            if (r0 != 0) goto L_0x001d
            X.9Y2 r0 = X.AnonymousClass9Y2.LIZ()
            java.lang.String r4 = ""
            kotlin.h.b.n.LIZIZ(r0, r4)
            X.9JT r0 = r0.LIZIZ
            boolean r0 = r0.LIZLLL()
            if (r0 != 0) goto L_0x001e
        L_0x001d:
            return
        L_0x001e:
            com.google.gson.m r0 = X.C47599Xy.LIZIZ
            if (r0 == 0) goto L_0x001d
            com.google.gson.m r0 = X.C47609Xz.LIZIZ
            if (r0 != 0) goto L_0x0027
            goto L_0x001d
        L_0x0027:
            r6 = 1
            X.C41509An.LIZ = r6
            com.google.gson.m r2 = new com.google.gson.m
            r2.<init>()
            java.util.ArrayList r9 = new java.util.ArrayList
            r9.<init>()
            com.google.gson.m r0 = X.C47609Xz.LIZIZ     // Catch:{ Exception -> 0x00d2 }
            if (r0 == 0) goto L_0x00d2
            com.google.gson.internal.g r0 = r0.LIZ     // Catch:{ Exception -> 0x00d2 }
            java.util.Set r0 = r0.entrySet()     // Catch:{ Exception -> 0x00d2 }
            if (r0 == 0) goto L_0x00d2
            java.util.Iterator r8 = r0.iterator()     // Catch:{ Exception -> 0x00d2 }
        L_0x0044:
            boolean r0 = r8.hasNext()     // Catch:{ Exception -> 0x00d2 }
            if (r0 == 0) goto L_0x00d2
            java.lang.Object r3 = r8.next()     // Catch:{ Exception -> 0x00d2 }
            java.util.Map$Entry r3 = (java.util.Map.Entry) r3     // Catch:{ Exception -> 0x00d2 }
            com.google.gson.m r0 = X.C47599Xy.LIZIZ     // Catch:{ Exception -> 0x00d2 }
            if (r0 == 0) goto L_0x001d
            com.google.gson.m r1 = X.C47599Xy.LIZIZ     // Catch:{ Exception -> 0x00d2 }
            java.lang.Object r0 = r3.getKey()     // Catch:{ Exception -> 0x00d2 }
            java.lang.String r0 = (java.lang.String) r0     // Catch:{ Exception -> 0x00d2 }
            com.google.gson.j r7 = r1.LIZJ(r0)     // Catch:{ Exception -> 0x00d2 }
            java.lang.Object r0 = r3.getValue()     // Catch:{ Exception -> 0x00d2 }
            com.google.gson.j r0 = (com.google.gson.j) r0     // Catch:{ Exception -> 0x00d2 }
            if (r0 == 0) goto L_0x0073
            com.google.gson.m r1 = r0.LJIIL()     // Catch:{ Exception -> 0x00d2 }
            java.lang.String r0 = "val"
            com.google.gson.j r5 = r1.LIZJ(r0)     // Catch:{ Exception -> 0x00d2 }
            goto L_0x0074
        L_0x0073:
            r5 = 0
        L_0x0074:
            java.lang.Object r0 = r3.getValue()     // Catch:{ all -> 0x0096 }
            com.google.gson.j r0 = (com.google.gson.j) r0     // Catch:{ all -> 0x0096 }
            if (r0 == 0) goto L_0x008d
            com.google.gson.m r1 = r0.LJIIL()     // Catch:{ all -> 0x0096 }
            java.lang.String r0 = "vid"
            com.google.gson.j r0 = r1.LIZJ(r0)     // Catch:{ all -> 0x0096 }
            if (r0 == 0) goto L_0x008d
            int r1 = r0.LJI()     // Catch:{ all -> 0x0096 }
            goto L_0x008e
        L_0x008d:
            r1 = 1
        L_0x008e:
            X.2Pr r0 = X.2Pr.LIZ     // Catch:{ all -> 0x0094 }
            X.2te.constructor-impl(r0)     // Catch:{ all -> 0x0094 }
            goto L_0x009f
        L_0x0094:
            r0 = move-exception
            goto L_0x0098
        L_0x0096:
            r0 = move-exception
            r1 = 1
        L_0x0098:
            java.lang.Object r0 = X.2th.LIZ(r0)     // Catch:{ Exception -> 0x00d2 }
            X.2te.constructor-impl(r0)     // Catch:{ Exception -> 0x00d2 }
        L_0x009f:
            if (r1 != r6) goto L_0x0044
            if (r7 != 0) goto L_0x00a6
            if (r5 == 0) goto L_0x0044
            goto L_0x00ae
        L_0x00a6:
            if (r5 == 0) goto L_0x00ae
            boolean r0 = kotlin.h.b.n.LIZ((java.lang.Object) r7, (java.lang.Object) r5)     // Catch:{ Exception -> 0x00d2 }
            if (r0 != 0) goto L_0x0044
        L_0x00ae:
            com.google.gson.m r1 = new com.google.gson.m     // Catch:{ Exception -> 0x00d2 }
            r1.<init>()     // Catch:{ Exception -> 0x00d2 }
            java.lang.String r0 = "oldValue"
            r1.LIZ(r0, r7)     // Catch:{ Exception -> 0x00d2 }
            java.lang.String r0 = "newValue"
            r1.LIZ(r0, r5)     // Catch:{ Exception -> 0x00d2 }
            java.lang.Object r0 = r3.getKey()     // Catch:{ Exception -> 0x00d2 }
            java.lang.String r0 = (java.lang.String) r0     // Catch:{ Exception -> 0x00d2 }
            r2.LIZ(r0, r1)     // Catch:{ Exception -> 0x00d2 }
            java.lang.Object r0 = r3.getKey()     // Catch:{ Exception -> 0x00d2 }
            kotlin.h.b.n.LIZIZ(r0, r4)     // Catch:{ Exception -> 0x00d2 }
            r9.add(r0)     // Catch:{ Exception -> 0x00d2 }
            goto L_0x0044
        L_0x00d2:
            com.google.gson.internal.g r0 = r2.LIZ
            java.util.Set r0 = r0.entrySet()
            kotlin.h.b.n.LIZIZ(r0, r4)
            boolean r0 = r0.isEmpty()
            r0 = r0 ^ r6
            if (r0 == 0) goto L_0x001d
            X.C150186q.LIZJ(r9)
            com.google.gson.Gson r0 = X.2dc.LIZ()
            java.lang.String r2 = r0.LIZ(r2)
            r0 = 6
            X.Cwu[] r3 = new X.Cwu[r0]
            r1 = 0
            java.lang.String r0 = "result"
            X.Cwu r0 = X.CwZ.LIZ(r0, r2)
            r3[r1] = r0
            java.lang.String r0 = X.C41509An.LIZIZ
            java.lang.String r5 = "url"
            X.Cwu r0 = X.CwZ.LIZ(r5, r0)
            r3[r6] = r0
            r2 = 2
            java.util.Map<java.lang.String, java.lang.String> r0 = X.C41509An.LIZJ
            java.lang.String r1 = "commonLogId"
            java.lang.Object r0 = r0.get(r1)
            if (r0 != 0) goto L_0x010f
            r0 = r4
        L_0x010f:
            X.Cwu r0 = X.CwZ.LIZ(r1, r0)
            r3[r2] = r0
            r2 = 3
            java.util.Map<java.lang.String, java.lang.String> r0 = X.C41509An.LIZJ
            java.lang.Object r1 = r0.get(r5)
            if (r1 != 0) goto L_0x011f
            r1 = r4
        L_0x011f:
            java.lang.String r0 = "settingsUrl"
            X.Cwu r0 = X.CwZ.LIZ(r0, r1)
            r3[r2] = r0
            r2 = 4
            java.util.Map<java.lang.String, java.lang.String> r1 = X.C41509An.LIZJ
            java.lang.String r0 = "x-tt-logid"
            java.lang.Object r0 = r1.get(r0)
            if (r0 != 0) goto L_0x015b
        L_0x0132:
            java.lang.String r0 = "settingsLogId"
            X.Cwu r0 = X.CwZ.LIZ(r0, r4)
            r3[r2] = r0
            r2 = 5
            java.lang.String r10 = "#"
            r11 = 0
            r12 = 0
            r13 = 0
            r14 = 0
            r15 = 0
            r16 = 62
            java.lang.String r1 = X.Lea.LIZ(r9, r10, r11, r12, r13, r14, r15, r16)
            java.lang.String r0 = "diff_keys"
            X.Cwu r0 = X.CwZ.LIZ(r0, r1)
            r3[r2] = r0
            java.util.Map r1 = X.LWw.LIZ(r3)
            java.lang.String r0 = "libra_config_diff"
            X.2nK.LIZ(r0, r1)
            goto L_0x001d
        L_0x015b:
            r4 = r0
            goto L_0x0132
        */
        throw new UnsupportedOperationException("Method not decompiled: com.ss.android.ugc.aweme.settingsrequest.SettingsRequestServiceImpl.LIZ(java.lang.String):void");
    }

    public final MKj LIZ(SharedPreferences.Editor editor, IESSettingsProxy iESSettingsProxy) {
        return C41499Am.LIZ.LIZ(editor, iESSettingsProxy);
    }
}
