package com.ss.android.ugc.aweme.bullet.bridge.framework;

import X.0CB;
import X.0CH;
import X.0HH;
import X.4UQ;
import X.6Is;
import X.9K4;
import X.C0339K0c;
import X.C0762KGj;
import X.C0763KGk;
import X.C3236LDn;
import X.KG4;
import X.KG6;
import X.KT7;
import X.M12;
import android.text.TextUtils;
import com.bytedance.covode.number.Covode;
import com.google.gson.m;
import com.ss.android.ugc.aweme.bullet.bridge.BaseBridgeMethod;
import java.util.Iterator;
import kotlin.h.b.n;
import org.json.JSONException;
import org.json.JSONObject;

public final class SendLogMethod extends BaseBridgeMethod implements 6Is {
    public static final KG4 LIZIZ = new KG4((byte) 0);
    public final String LIZJ = "sendLog";

    static {
        Covode.recordClassIndex(55131);
    }

    public final void onStateChanged(0CH r1, 0CB r2) {
        super.onStateChanged(r1, r2);
    }

    public final String LIZLLL() {
        return this.LIZJ;
    }

    /* JADX INFO: super call moved to the top of the method (can break code semantics) */
    public SendLogMethod(KT7 kt7) {
        super(kt7);
        M12.LIZ((Object) kt7);
        LIZ(KG6.LIZ);
    }

    public final void LIZ(JSONObject jSONObject, 4UQ r17) {
        long j;
        boolean z;
        4UQ r1 = r17;
        JSONObject jSONObject2 = jSONObject;
        M12.LIZ((Object) jSONObject2, (Object) r1);
        LJ();
        if (jSONObject2 == null) {
            r1.LIZ(0, "");
            return;
        }
        String optString = jSONObject2.optString("eventName");
        String optString2 = jSONObject2.optString("labelName");
        String optString3 = jSONObject2.optString("value");
        String optString4 = jSONObject2.optString("extValue");
        JSONObject optJSONObject = jSONObject2.optJSONObject("extJson");
        long j2 = 0;
        if (!TextUtils.isEmpty(optString3)) {
            j = Long.parseLong(optString3);
        } else {
            j = 0;
        }
        if (!TextUtils.isEmpty(optString4)) {
            j2 = Long.parseLong(optString4);
        }
        if (optJSONObject == null || !optJSONObject.has("is_ad_event") || (!TextUtils.equals("1", optJSONObject.optString("is_ad_event")) && optJSONObject.optInt("is_ad_event") != 1 && !optJSONObject.optBoolean("is_ad_event"))) {
            z = false;
        } else {
            z = true;
        }
        if (LJ() != null) {
            if (!z) {
                9K4.LIZ(LJ(), optString, optString2, j, j2, optJSONObject);
            } else if (TextUtils.equals("click", optString2)) {
                C3236LDn.LIZ(optString, optString3, j2, optJSONObject);
                optJSONObject.put("has_v3", 1);
                9K4.LIZ(LJ(), optString, optString2, j, j2, optJSONObject);
            } else {
                n.LIZIZ(optString, "");
                n.LIZIZ(optString2, "");
                C0762KGj LIZ = C0339K0c.LIZ(optString, optString2, String.valueOf(j), "", String.valueOf(j2));
                if (optJSONObject != null) {
                    Iterator<String> keys = optJSONObject.keys();
                    n.LIZIZ(keys, "");
                    while (keys.hasNext()) {
                        String next = keys.next();
                        LIZ.LIZIZ(next, optJSONObject.opt(next));
                    }
                }
                LIZ.LIZJ();
                if (C0763KGk.LIZIZ()) {
                    9K4.LIZ(LJ(), optString, optString2, j, j2, optJSONObject);
                } else if (C0763KGk.LIZ()) {
                    if (optJSONObject != null) {
                        try {
                            optJSONObject.put("_ad_staging_flag", "1");
                        } catch (JSONException e) {
                            0HH.LIZ(e);
                        }
                    }
                    9K4.LIZ(LJ(), optString, optString2, j, j2, optJSONObject);
                }
            }
            r1.LIZ(new m());
            return;
        }
        r1.LIZ(0, "");
    }
}
