package com.ss.android.ugc.aweme.commercialize.e_commerce.wishlist.jsb;

import X.0CB;
import X.0CH;
import X.4UQ;
import X.6Is;
import X.Bi2;
import X.C0655KCg;
import X.C2219KpG;
import X.C3164LAt;
import X.KT7;
import X.M12;
import android.app.Activity;
import android.content.Context;
import android.net.Uri;
import android.os.Bundle;
import com.bytedance.covode.number.Covode;
import com.bytedance.router.SmartRoute;
import com.bytedance.router.SmartRouter;
import com.ss.android.ugc.aweme.ad.preload.AdLandPagePreloadServiceImpl;
import com.ss.android.ugc.aweme.ad.preload.IAdLandPagePreloadService;
import com.ss.android.ugc.aweme.bullet.bridge.BaseBridgeMethod;
import com.ss.android.ugc.aweme.spark.AdSparkUtils;
import com.ss.android.ugc.aweme.spark.IAdSparkUtils;
import kotlin.h.b.n;
import org.json.JSONObject;

public final class OpenHybridMethod extends BaseBridgeMethod implements 6Is {
    public static final C2219KpG LIZIZ = new C2219KpG((byte) 0);
    public final String LIZJ = "openHybrid";

    static {
        Covode.recordClassIndex(58482);
    }

    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 OpenHybridMethod(KT7 kt7) {
        super(kt7);
        M12.LIZ((Object) kt7);
    }

    public final void LIZ(JSONObject jSONObject, 4UQ r13) {
        boolean z;
        String str;
        Uri.Builder buildUpon;
        String str2;
        String queryParameter;
        M12.LIZ((Object) jSONObject, (Object) r13);
        String optString = jSONObject.optString("schema");
        if (jSONObject.optInt("is_ad") == 1) {
            z = true;
        } else {
            z = false;
        }
        String optString2 = jSONObject.optString("param");
        int i = C0655KCg.LIZ[LJII().ordinal()];
        if (i == 1 || i == 2) {
            n.LIZIZ(optString2, "");
            if (optString != null) {
                Context LJ = LJ();
                if (LJ instanceof Activity) {
                    Bundle bundle = new Bundle();
                    Uri parse = Uri.parse(optString);
                    if (!(parse == null || (queryParameter = parse.getQueryParameter("access_key")) == null)) {
                        n.LIZIZ(queryParameter, "");
                        if (queryParameter.length() > 0) {
                            bundle.putString("access_key", queryParameter);
                        }
                    }
                    if (z) {
                        str = AdLandPagePreloadServiceImpl.LJFF().LJ();
                        bundle.putString("bundle_extra_param", optString2);
                    } else {
                        str = null;
                    }
                    if (C3164LAt.LIZIZ.LIZ().LIZ) {
                        Uri parse2 = Uri.parse(optString);
                        if (!(parse2 == null || (buildUpon = parse2.buildUpon()) == null)) {
                            if (z) {
                                IAdSparkUtils LIZIZ2 = AdSparkUtils.LIZIZ();
                                if (LIZIZ2 != null) {
                                    String builder = buildUpon.toString();
                                    n.LIZIZ(builder, "");
                                    IAdLandPagePreloadService LJFF = AdLandPagePreloadServiceImpl.LJFF();
                                    if (LJFF != null) {
                                        str2 = LJFF.LJI("lynx_feed");
                                    } else {
                                        str2 = null;
                                    }
                                    LIZIZ2.LIZ(LJ, builder, bundle, str2);
                                }
                            } else {
                                SmartRoute buildRoute = SmartRouter.buildRoute(LJ, buildUpon.toString());
                                buildRoute.withParam(bundle);
                                buildRoute.open();
                            }
                        }
                    } else {
                        Bi2.LIZ(LJ, optString, str, bundle);
                    }
                }
            }
            r13.LIZ((Object) null, 1, (String) null);
            return;
        }
        r13.LIZ(-1, "The container is not any of these three - Web/RN/Lynx");
    }
}
