Swiggy v4.51.1版本的 MD5 值为:5af7ec91512a0a8c1510e3f8bac20b8b

以下内容为反编译后的 LynxController.java 源代码,内容仅作参考


package in.swiggy.android.controllers;

import android.annotation.TargetApi;
import android.app.Activity;
import android.content.Context;
import android.content.Intent;
import android.content.SharedPreferences;
import android.content.pm.PackageManager;
import android.content.res.Resources;
import android.graphics.Rect;
import android.net.Uri;
import android.os.Bundle;
import android.util.DisplayMetrics;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.view.ViewTreeObserver;
import android.webkit.WebChromeClient;
import android.webkit.WebResourceRequest;
import android.webkit.WebSettings;
import android.webkit.WebView;
import android.widget.FrameLayout;
import androidx.appcompat.app.AppCompatActivity;
import androidx.constraintlayout.widget.ConstraintLayout;
import androidx.lifecycle.s;
import com.google.gson.Gson;
import com.google.gson.reflect.TypeToken;
import com.newrelic.agent.android.instrumentation.GsonInstrumentation;
import com.newrelic.agent.android.instrumentation.Instrumented;
import com.swiggy.lynx.plugin.core.showheader.TitleAlignmentEnum;
import com.swiggy.lynx.webinterface.ILynxViewUpdateHandler;
import in.juspay.hyper.constants.LogSubCategory;
import in.swiggy.android.R;
import in.swiggy.android.SwiggyApplication;
import in.swiggy.android.activities.HomeActivity;
import in.swiggy.android.activities.OffersActivityV2;
import in.swiggy.android.activities.ViewCartLynxActivity;
import in.swiggy.android.analytics_sdk.event.senders.KlyticsEventSender;
import in.swiggy.android.apputils.LocationEventUtil;
import in.swiggy.android.commons.extension.KotlinExtensionsKt;
import in.swiggy.android.commons.utils.i0;
import in.swiggy.android.commons.utils.x;
import in.swiggy.android.commonsui.view.errorview.ErrorView;
import in.swiggy.android.commonsui.view.errorview.ErrorViewV2;
import in.swiggy.android.commonsui.view.toolbar.AdvancedToolbar;
import in.swiggy.android.constants.SwiggyGTMConstants;
import in.swiggy.android.discoverycartkit.RecommendedCartsDriver;
import in.swiggy.android.feature.menuv2.MenuV2Activity;
import in.swiggy.android.payment.behaviour.b;
import in.swiggy.android.swiggylocation.location.j;
import in.swiggy.android.swiggylocation.utils.eventmanager.interfaces.LocationEventSource;
import in.swiggy.android.swiggylynx.interfaces.a;
import in.swiggy.android.swiggylynx.plugin.SwiggyLynxPluginData;
import in.swiggy.android.swiggylynx.plugin.addressplugin.AddressPlugin;
import in.swiggy.android.swiggylynx.plugin.irctcplugin.IrctcPlugin;
import in.swiggy.android.swiggylynx.plugin.loginplugin.LoginPlugin;
import in.swiggy.android.swiggylynx.plugin.ozone.OzonePlugin;
import in.swiggy.android.swiggylynx.plugin.payment.amazonpayplugin.AmazonPlugin;
import in.swiggy.android.swiggylynx.plugin.payment.juspayplugin.JuspayPlugin;
import in.swiggy.android.swiggylynx.plugin.payment.juspayplugin.utility.JuspaySdkWrapper;
import in.swiggy.android.swiggylynx.plugin.payment.paymentcoreplugin.PaymentCorePlugin;
import in.swiggy.android.swiggylynx.plugin.restempathy.RestEmpathyResponsePayload;
import in.swiggy.android.swiggylynx.plugin.swiggylynxcoreplugin.SwiggyLynxCorePlugin;
import in.swiggy.android.swiggylynx.plugin.swiggylynxcoreplugin.quizprogress.QuizProgressUpdatePayload;
import in.swiggy.android.swiggylynx.ui.LynxActivity;
import in.swiggy.android.swiggylynx.ui.LynxData;
import in.swiggy.android.swiggylynx.ui.SwiggyLynxWebView;
import in.swiggy.android.swiggylynx.ui.m;
import in.swiggy.android.swiggylynx.utils.IllegalHostException;
import in.swiggy.android.swiggylynx.utils.f;
import in.swiggy.android.swiggylynx.webviewclient.LynxViewClient;
import in.swiggy.android.swiggylynx.webviewclient.a;
import in.swiggy.android.tejas.TejasConstants;
import in.swiggy.android.tejas.feature.address.model.Address;
import in.swiggy.android.tejas.feature.address.model.AddressSortingWeight;
import in.swiggy.android.tejas.feature.irctc.IrctcDataProvider;
import in.swiggy.android.tejas.feature.menu.PostableMenuRequest;
import in.swiggy.android.tejas.oldapi.models.cart.ReviewedCart;
import in.swiggy.android.tejas.oldapi.models.order.Order;
import in.swiggy.android.tejas.oldapi.network.responses.ReviewedCartResponse;
import in.swiggy.android.utils.c0;
import in.swiggy.android.utils.q0;
import in.swiggy.android.utils.w1;
import io.reactivex.processors.BehaviorProcessor;
import io.reactivex.processors.PublishProcessor;
import java.lang.reflect.Type;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.HashMap;
import java.util.Iterator;
import java.util.List;
import java.util.Map;
import java.util.Set;
import java.util.Stack;
import kotlin.Unit;
import kotlin.collections.j0;
import kotlin.jvm.functions.Function0;
import kotlin.jvm.internal.MutablePropertyReference1Impl;
import kotlin.jvm.internal.o;
import kotlin.jvm.internal.r;
import kotlin.jvm.internal.w;
import kotlin.reflect.l;
import kotlin.text.StringsKt__StringsKt;
import kotlin.text.q;
import okhttp3.OkHttpClient;
@Instrumented
public final class LynxController extends h implements ILynxViewUpdateHandler, in.swiggy.android.swiggylynx.webviewclient.a, in.swiggy.android.payment.behaviour.b, in.swiggy.android.swiggylynx.ui.d {
    static final l<Object>[] n1 = {r.f(new MutablePropertyReference1Impl(LynxController.class, "requestCode", "getRequestCode()I", 0))};
    public static final int o1 = 8;
    public in.swiggy.android.repositories.interfaces.e A0;
    public KlyticsEventSender B0;
    public PublishProcessor<String> C0;
    public PublishProcessor<String> D0;
    public BehaviorProcessor<QuizProgressUpdatePayload> E0;
    public q0 F0;
    public in.swiggy.android.payment.services.interfaces.d G0;
    public in.swiggy.android.crosspollination.c H0;
    public in.swiggy.android.commons.utils.a I0;
    private SwiggyLynxWebView J0;
    public OkHttpClient K0;
    public in.swiggy.android.swiggylynx.interfaces.a L0;
    public in.swiggy.android.mxn.swiggyats.a M0;
    public in.swiggy.android.commons.featureFlags.d N0;
    public in.swiggy.android.swiggylynx.plugin.addressSorting.b O0;
    public in.swiggy.android.feature.address.a P0;
    public in.swiggy.android.deeplink.b Q;
    public RecommendedCartsDriver Q0;
    public c0 R;
    public in.swiggy.android.commons.ozone.a R0;
    public in.swiggy.android.commons.utils.contextservice.h S;
    public in.swiggy.android.commons.ozone.b S0;
    public SharedPreferences T;
    public IrctcDataProvider T0;
    public in.swiggy.android.repositories.interfaces.d U;
    public AmazonPlugin U0;
    public j V;
    private final Stack<SwiggyLynxWebView> V0;
    public in.swiggy.android.analytics.newrelic.a W;
    private in.swiggy.android.commonsFeature.f W0;
    public in.swiggy.koordinates.compass.core.b X;
    public String X0;
    public in.swiggy.android.swiggylynx.headers.a Y;
    public String Y0;
    public in.swiggy.android.feature.payment.services.interfaces.b Z;
    public Set<? extends SwiggyLynxPluginData> Z0;
    public Map<String, String> a1;
    private boolean b1;
    public in.swiggy.android.swiggylocation.utils.eventmanager.interfaces.a c0;
    public Map<String, String> c1;
    private final kotlin.properties.e d1;
    private boolean e1;
    private final String f1;
    private final String g1;
    private String h1;
    public View i1;
    private final kotlin.j j1;
    private LynxViewClient k1;
    private ArrayList<String> l1;
    private final ViewTreeObserver.OnGlobalLayoutListener m1;
    public in.swiggy.android.analytics.interfaces.c p0;
    public in.swiggy.android.analytics.generated.e y0;
    public in.swiggy.android.swiggylynx.service.a z0;

    public static final class a extends TypeToken<ArrayList<String>> {
        a() {
        }
    }

    public LynxController(Bundle result) {
        super(result);
        kotlin.j b;
        o.k(result, "result");
        this.V0 = new Stack<>();
        this.b1 = true;
        this.d1 = kotlin.properties.a.a.a();
        this.f1 = "CART_PLUGIN_V2";
        this.g1 = "CART_PLUGIN";
        b = kotlin.l.b(new Function0<in.swiggy.android.swiggylynx.utils.f>() {
            {
                super(0);
            }

            @Override
            public final in.swiggy.android.swiggylynx.utils.f invoke() {
                return new in.swiggy.android.swiggylynx.utils.f(LynxController.this.r2());
            }
        });
        this.j1 = b;
        this.l1 = new ArrayList<>();
        this.m1 = new ViewTreeObserver.OnGlobalLayoutListener() {
            @Override
            public final void onGlobalLayout() {
                LynxController.A2(LynxController.this);
            }
        };
    }

    public static final void A2(LynxController this$0) {
        float f;
        int i;
        String name;
        String name2;
        Resources resources;
        DisplayMetrics displayMetrics;
        o.k(this$0, "this$0");
        SwiggyLynxWebView swiggyLynxWebView = this$0.J0;
        if (swiggyLynxWebView != null) {
            Rect rect = new Rect();
            swiggyLynxWebView.getWindowVisibleDisplayFrame(rect);
            int height = swiggyLynxWebView.getHeight() - (rect.bottom - rect.top);
            Context context = swiggyLynxWebView.getContext();
            if (context != null && (resources = context.getResources()) != null && (displayMetrics = resources.getDisplayMetrics()) != null) {
                f = displayMetrics.density;
            } else {
                f = 1.0f;
            }
            Resources X = this$0.X();
            if (X != null) {
                i = X.getDimensionPixelSize(R.dimen.dimen_50dp);
            } else {
                i = 0;
            }
            if (height > i) {
                try {
                    SwiggyLynxWebView swiggyLynxWebView2 = this$0.J0;
                    if (swiggyLynxWebView2 != null) {
                        this$0.C1(swiggyLynxWebView2, "keyboardStateChanged(true, " + (height / f) + ")");
                        return;
                    }
                    return;
                } catch (Exception e) {
                    if (!LynxController.class.isAnonymousClass()) {
                        name2 = LynxController.class.getSimpleName();
                        if (name2.length() > 23) {
                            o.h(name2);
                            name2 = name2.substring(0, 23);
                            o.j(name2, "substring(...)");
                        }
                        o.h(name2);
                    } else {
                        name2 = LynxController.class.getName();
                        if (name2.length() > 23) {
                            o.h(name2);
                            name2 = name2.substring(name2.length() - 23, name2.length());
                            o.j(name2, "substring(...)");
                        }
                        o.h(name2);
                    }
                    x.i(name2, e);
                    return;
                }
            }
            try {
                SwiggyLynxWebView swiggyLynxWebView3 = this$0.J0;
                if (swiggyLynxWebView3 != null) {
                    this$0.C1(swiggyLynxWebView3, "keyboardStateChanged(false, 0)");
                }
            } catch (Exception e2) {
                if (!LynxController.class.isAnonymousClass()) {
                    name = LynxController.class.getSimpleName();
                    if (name.length() > 23) {
                        o.h(name);
                        name = name.substring(0, 23);
                        o.j(name, "substring(...)");
                    }
                    o.h(name);
                } else {
                    name = LynxController.class.getName();
                    if (name.length() > 23) {
                        o.h(name);
                        name = name.substring(name.length() - 23, name.length());
                        o.j(name, "substring(...)");
                    }
                    o.h(name);
                }
                x.i(name, e2);
            }
        }
    }

    private final void B2() {
        String str;
        in.swiggy.android.swiggylynx.utils.f W1 = W1();
        SwiggyLynxWebView swiggyLynxWebView = this.J0;
        if (swiggyLynxWebView != null) {
            str = swiggyLynxWebView.getUrl();
        } else {
            str = null;
        }
        if (W1.h(str)) {
            W1().c();
        } else {
            W1().g();
        }
    }

    private final void C1(WebView webView, String str) {
        webView.evaluateJavascript("javascript:try{" + str + "}catch(error){}", null);
    }

    public final void C2() {
        ConstraintLayout constraintLayout;
        ConstraintLayout constraintLayout2 = (ConstraintLayout) b2().findViewById(R.id.headerController);
        if (constraintLayout2 != null && constraintLayout2.getVisibility() == 0 && (constraintLayout = (ConstraintLayout) b2().findViewById(R.id.headerController)) != null) {
            constraintLayout.setVisibility(8);
        }
    }

    private final void D1(int i, int i2, Intent intent) {
        String str;
        ReviewedCart reviewedCart;
        if (i2 == -1 && i == 291 && intent != null) {
            Bundle extras = intent.getExtras();
            if (extras != null) {
                str = extras.getString(OffersActivityV2.d.e());
            } else {
                str = null;
            }
            in.swiggy.android.repositories.cart.interfaces.cart.a r = this.F.r();
            o.i(r, "null cannot be cast to non-null type in.swiggy.android.repositories.cart.impl.Cart");
            ReviewedCartResponse reviewedCartResponse = ((in.swiggy.android.repositories.cart.impl.a) r).a.p;
            if (reviewedCartResponse != null && (reviewedCart = reviewedCartResponse.mReviewedCart) != null && str != null) {
                reviewedCart.mCouponCode = str;
            }
        }
    }

    private final in.swiggy.android.swiggylynx.plugin.cart.d E1(String str, in.swiggy.android.feature.cart.e eVar) {
        Activity activity = getActivity();
        o.i(activity, "null cannot be cast to non-null type androidx.appcompat.app.AppCompatActivity");
        in.swiggy.android.repositories.cart.interfaces.cart.a r = this.F.r();
        o.i(r, "null cannot be cast to non-null type in.swiggy.android.repositories.cart.impl.Cart");
        o.i(this, "null cannot be cast to non-null type in.swiggy.android.mvvm.SwiggyUIComponent");
        in.swiggy.android.repositories.cart.services.i iVar = this.F;
        in.swiggy.android.repositories.interfaces.d u2 = u2();
        in.swiggy.koordinates.compass.core.b Y1 = Y1();
        SharedPreferences r2 = r2();
        LynxController$createCartPluginV2$1 lynxController$createCartPluginV2$1 = new LynxController$createCartPluginV2$1(this);
        io.reactivex.disposables.a t = t();
        in.swiggy.android.analytics.newrelic.a g2 = g2();
        in.swiggy.android.analytics.interfaces.c c2 = c2();
        in.swiggy.android.repositories.interfaces.e z2 = z2();
        String t2 = t2();
        RecommendedCartsDriver p2 = p2();
        in.swiggy.android.swiggylynx.service.a f2 = f2();
        IrctcDataProvider V1 = V1();
        LynxController$createCartPluginV2$2 lynxController$createCartPluginV2$2 = new LynxController$createCartPluginV2$2(this);
        o.h(iVar);
        return new in.swiggy.android.swiggylynx.plugin.cart.d((AppCompatActivity) activity, (in.swiggy.android.repositories.cart.impl.a) r, this, iVar, u2, Y1, LynxController.class, r2, lynxController$createCartPluginV2$1, t, g2, c2, z2, str, t2, eVar, f2, p2, V1, lynxController$createCartPluginV2$2);
    }

    private final void E2(ArrayList<com.swiggy.lynx.plugin.a> arrayList, String str) {
        HashMap k;
        HashMap k2;
        if (in.swiggy.android.cartkit.a.a(r2())) {
            c0 O1 = O1();
            in.swiggy.android.cartkit.interfaces.a l1 = l1();
            o.j(l1, "getCartCommunicationService(...)");
            arrayList.add(E1(str, new in.swiggy.android.feature.cart.e(O1, l1, h2(), F1())));
            in.swiggy.android.analytics.newrelic.a g2 = g2();
            k2 = j0.k(kotlin.o.a("cart_plugin_in_use", this.f1));
            g2.b("web_cart_cart_plugin_in_use", k2);
            return;
        }
        Activity activity = getActivity();
        o.i(activity, "null cannot be cast to non-null type androidx.appcompat.app.AppCompatActivity");
        in.swiggy.android.repositories.cart.interfaces.cart.a r = this.F.r();
        o.i(r, "null cannot be cast to non-null type in.swiggy.android.repositories.cart.impl.Cart");
        o.i(this, "null cannot be cast to non-null type in.swiggy.android.mvvm.SwiggyUIComponent");
        in.swiggy.android.cartkit.interfaces.a l12 = l1();
        o.j(l12, "getCartCommunicationService(...)");
        in.swiggy.android.repositories.cart.services.i cartService = this.F;
        o.j(cartService, "cartService");
        arrayList.add(new in.swiggy.android.feature.cart.c((AppCompatActivity) activity, (in.swiggy.android.repositories.cart.impl.a) r, this, l12, cartService, u2(), Y1(), LynxController.class, O1(), r2(), new LynxController$initCartPlugin$plugin$1(this), t(), g2(), c2(), z2(), h2(), str, t2(), F1(), f2(), p2(), V1(), new LynxController$initCartPlugin$plugin$2(this)));
        in.swiggy.android.analytics.newrelic.a g22 = g2();
        k = j0.k(kotlin.o.a("cart_plugin_in_use", this.g1));
        g22.b("web_cart_cart_plugin_in_use", k);
    }

    private final void F2(Intent intent, ArrayList<com.swiggy.lynx.plugin.a> arrayList, WebView webView) {
        Activity activity = getActivity();
        o.i(activity, "null cannot be cast to non-null type androidx.appcompat.app.AppCompatActivity");
        AppCompatActivity appCompatActivity = (AppCompatActivity) activity;
        in.swiggy.android.deeplink.b N1 = N1();
        in.swiggy.android.repositories.interfaces.d u2 = u2();
        in.swiggy.koordinates.compass.core.b Y1 = Y1();
        in.swiggy.android.analytics.generated.e d2 = d2();
        SharedPreferences r2 = r2();
        in.swiggy.android.commons.utils.contextservice.h K1 = K1();
        LynxController$initCorePlugin$plugin$1 lynxController$initCorePlugin$plugin$1 = new LynxController$initCorePlugin$plugin$1(this);
        LynxController$initCorePlugin$plugin$2 lynxController$initCorePlugin$plugin$2 = new LynxController$initCorePlugin$plugin$2(this);
        in.swiggy.android.repositories.cart.interfaces.cart.a r = this.F.r();
        o.j(r, "getCart(...)");
        String w2 = w2();
        LynxController$initCorePlugin$plugin$3 lynxController$initCorePlugin$plugin$3 = new LynxController$initCorePlugin$plugin$3(this);
        String t2 = t2();
        io.reactivex.disposables.a t = t();
        j v2 = v2();
        in.swiggy.android.swiggylynx.service.a f2 = f2();
        in.swiggy.android.repositories.interfaces.e z2 = z2();
        in.swiggy.android.analytics.newrelic.a g2 = g2();
        in.swiggy.android.crosspollination.c L1 = L1();
        in.swiggy.android.swiggylynx.interfaces.a s2 = s2();
        in.swiggy.android.commons.utils.a I1 = I1();
        Activity activity2 = getActivity();
        o.i(activity2, "null cannot be cast to non-null type androidx.appcompat.app.AppCompatActivity");
        arrayList.add(new SwiggyLynxCorePlugin(appCompatActivity, N1, webView, u2, Y1, d2, LynxController.class, r2, K1, null, this, lynxController$initCorePlugin$plugin$1, lynxController$initCorePlugin$plugin$2, r, w2, lynxController$initCorePlugin$plugin$3, intent, t2, t, v2, "", "", "", f2, z2, g2, L1, s2, null, null, I1, s.a((AppCompatActivity) activity2), k2(), new LynxController$initCorePlugin$plugin$4(this), 805306368, 0, null));
        Activity activity3 = getActivity();
        o.i(activity3, "null cannot be cast to non-null type androidx.appcompat.app.AppCompatActivity");
        arrayList.add(new in.swiggy.android.swiggylynx.plugin.swiggylynxcoreplugin.socialshare.b((AppCompatActivity) activity3, r2()));
        Activity activity4 = getActivity();
        o.i(activity4, "null cannot be cast to non-null type androidx.appcompat.app.AppCompatActivity");
        in.swiggy.koordinates.compass.core.b Y12 = Y1();
        in.swiggy.android.swiggylynx.service.a f22 = f2();
        o.i(this, "null cannot be cast to non-null type in.swiggy.android.mvvm.SwiggyUIComponent");
        arrayList.add(new AddressPlugin((AppCompatActivity) activity4, Y12, f22, true, this));
        Activity activity5 = getActivity();
        o.i(activity5, "null cannot be cast to non-null type androidx.appcompat.app.AppCompatActivity");
        arrayList.add(new in.swiggy.android.swiggylynx.plugin.swiggylynxcoreplugin.submitfeedback.b((AppCompatActivity) activity5, N1(), LynxActivity.class, new LynxController$initCorePlugin$1(this)));
        J2(arrayList);
        arrayList.add(in.swiggy.android.swiggylynx.plugin.addressSorting.e.Companion.b(Q1(), G1()));
        Activity activity6 = getActivity();
        o.i(activity6, "null cannot be cast to non-null type androidx.appcompat.app.AppCompatActivity");
        arrayList.add(new LoginPlugin((AppCompatActivity) activity6, f2(), t(), u2(), P1()));
        arrayList.add(new in.swiggy.android.swiggylynx.plugin.dynamicXPWP.a(r2(), z2()));
        in.swiggy.android.commons.ozone.a k2 = k2();
        in.swiggy.android.commons.ozone.b l2 = l2();
        Activity activity7 = getActivity();
        o.i(activity7, "null cannot be cast to non-null type androidx.appcompat.app.AppCompatActivity");
        arrayList.add(new OzonePlugin(k2, l2, (AppCompatActivity) activity7));
        arrayList.add(new in.swiggy.android.swiggylynx.plugin.quizplugin.b(o2()));
    }

    private final void G2(String str, ArrayList<com.swiggy.lynx.plugin.a> arrayList, io.reactivex.disposables.a aVar) {
        Activity activity = getActivity();
        o.i(activity, "null cannot be cast to non-null type androidx.appcompat.app.AppCompatActivity");
        JuspaySdkWrapper juspaySdkWrapper = new JuspaySdkWrapper((AppCompatActivity) activity, u2(), g2(), r2());
        in.swiggy.android.analytics.newrelic.a g2 = g2();
        o.i(this, "null cannot be cast to non-null type in.swiggy.android.mvvm.SwiggyUIComponent");
        in.swiggy.android.swiggylynx.plugin.payment.amazonpayplugin.utility.a aVar2 = new in.swiggy.android.swiggylynx.plugin.payment.amazonpayplugin.utility.a(aVar, this, g2, ViewCartLynxActivity.class, true, this, r2());
        JuspayPlugin juspayPlugin = new JuspayPlugin(r2(), juspaySdkWrapper, aVar, j2());
        Activity activity2 = getActivity();
        o.i(activity2, "null cannot be cast to non-null type androidx.appcompat.app.AppCompatActivity");
        AppCompatActivity appCompatActivity = (AppCompatActivity) activity2;
        in.swiggy.android.repositories.cart.interfaces.cart.a r = this.F.r();
        o.j(r, "getCart(...)");
        PaymentCorePlugin paymentCorePlugin = new PaymentCorePlugin(appCompatActivity, str, r, aVar, d2(), r2(), g2(), this.W0, new LynxController$initPaymentPlugin$paymentCorePlugin$1(this), true, N1(), this, j2(), null, null, null, t2(), u2(), V1(), 57344, null);
        in.swiggy.android.swiggylynx.plugin.payment.upiplugin.b bVar = new in.swiggy.android.swiggylynx.plugin.payment.upiplugin.b(this, r2(), g2(), true, this, z2());
        a3(new AmazonPlugin(aVar2, r2(), g2()));
        in.swiggy.android.swiggylynx.plugin.payment.phonepeplugin.b bVar2 = new in.swiggy.android.swiggylynx.plugin.payment.phonepeplugin.b(this, g2(), true, this);
        arrayList.add(paymentCorePlugin);
        arrayList.add(bVar);
        arrayList.add(juspayPlugin);
        arrayList.add(H1());
        arrayList.add(bVar2);
    }

    private final void H2(RestEmpathyResponsePayload restEmpathyResponsePayload, ArrayList<com.swiggy.lynx.plugin.a> arrayList) {
        arrayList.add(new in.swiggy.android.swiggylynx.plugin.restempathy.b(restEmpathyResponsePayload));
    }

    private final void J2(ArrayList<com.swiggy.lynx.plugin.a> arrayList) {
        com.swiggy.lynx.plugin.a b = in.swiggy.android.swiggylynx.plugin.tns.a.Companion.b(Q1(), r2(), Y1(), K1());
        if (b != null) {
            arrayList.add(b);
        }
    }

    private final void K2(SwiggyLynxWebView swiggyLynxWebView) {
        ViewTreeObserver viewTreeObserver;
        this.V0.push(swiggyLynxWebView);
        this.J0 = swiggyLynxWebView;
        if (swiggyLynxWebView != null) {
            swiggyLynxWebView.setNewrelicPerformanceUtils(g2());
        }
        SwiggyLynxWebView swiggyLynxWebView2 = this.J0;
        if (swiggyLynxWebView2 != null) {
            swiggyLynxWebView2.setViewUpdateHandler(this);
        }
        m mVar = m.a;
        String t2 = t2();
        in.swiggy.android.repositories.interfaces.d u2 = u2();
        in.swiggy.android.commons.utils.contextservice.h K1 = K1();
        in.swiggy.koordinates.compass.core.b Y1 = Y1();
        String w2 = w2();
        in.swiggy.android.repositories.interfaces.e z2 = z2();
        SharedPreferences r2 = r2();
        in.swiggy.android.repositories.cart.interfaces.cart.a r = this.F.r();
        o.j(r, "getCart(...)");
        mVar.e(t2, u2, K1, Y1, w2, z2, r2, r, this.J0, I1(), k2(), TejasConstants.ENABLE_V4_PROFILE_API_DEFAULT, TejasConstants.ENABLE_V4_PROFILE_API_DEFAULT, new LynxController$initialiseLynxWebView$1(this));
        List<com.swiggy.lynx.plugin.a> L2 = L2();
        SwiggyLynxWebView swiggyLynxWebView3 = this.J0;
        if (swiggyLynxWebView3 != null) {
            com.swiggy.lynx.plugin.a[] aVarArr = (com.swiggy.lynx.plugin.a[]) L2.toArray(new com.swiggy.lynx.plugin.a[0]);
            swiggyLynxWebView3.setPlugins((com.swiggy.lynx.plugin.a[]) Arrays.copyOf(aVarArr, aVarArr.length));
        }
        SwiggyLynxWebView swiggyLynxWebView4 = this.J0;
        if (swiggyLynxWebView4 != null) {
            swiggyLynxWebView4.setWhiteListedDomains(y2());
        }
        SwiggyLynxWebView swiggyLynxWebView5 = this.J0;
        if (swiggyLynxWebView5 != null) {
            Context applicationContext = getActivity().getApplicationContext();
            o.j(applicationContext, "getApplicationContext(...)");
            SharedPreferences r22 = r2();
            in.swiggy.android.repositories.interfaces.e z22 = z2();
            Gson g = i0.g();
            o.j(g, "getGson(...)");
            LynxViewClient lynxViewClient = new LynxViewClient(this, applicationContext, r22, z22, g, i2(), K1(), g2());
            this.k1 = lynxViewClient;
            swiggyLynxWebView5.setWebViewClient(lynxViewClient);
        }
        SwiggyLynxWebView swiggyLynxWebView6 = this.J0;
        if (swiggyLynxWebView6 != null && (viewTreeObserver = swiggyLynxWebView6.getViewTreeObserver()) != null) {
            viewTreeObserver.addOnGlobalLayoutListener(this.m1);
        }
        m.f fVar = m.f.a;
        SwiggyLynxWebView swiggyLynxWebView7 = this.J0;
        in.swiggy.android.swiggylynx.service.a f2 = f2();
        in.swiggy.android.repositories.cart.services.i cartService = this.F;
        o.j(cartService, "cartService");
        fVar.a(swiggyLynxWebView7, f2, cartService, r2());
    }

    private final List<com.swiggy.lynx.plugin.a> L2() {
        ArrayList<com.swiggy.lynx.plugin.a> arrayList = new ArrayList<>();
        for (SwiggyLynxPluginData swiggyLynxPluginData : n2()) {
            if (swiggyLynxPluginData instanceof SwiggyLynxPluginData.SwiggyLynxCorePluginData) {
                F2(((SwiggyLynxPluginData.SwiggyLynxCorePluginData) swiggyLynxPluginData).a(), arrayList, this.J0);
            } else if (swiggyLynxPluginData instanceof SwiggyLynxPluginData.PaymentLynxPluginData) {
                SwiggyLynxPluginData.PaymentLynxPluginData paymentLynxPluginData = (SwiggyLynxPluginData.PaymentLynxPluginData) swiggyLynxPluginData;
                String a2 = paymentLynxPluginData.a();
                if (a2 != null) {
                    this.h1 = a2;
                }
                G2(paymentLynxPluginData.a(), arrayList, t());
            } else if (swiggyLynxPluginData instanceof SwiggyLynxPluginData.EmpathyLynxPluginData) {
                H2(((SwiggyLynxPluginData.EmpathyLynxPluginData) swiggyLynxPluginData).a(), arrayList);
            } else if (swiggyLynxPluginData instanceof SwiggyLynxPluginData.CartLynxPluginData) {
                SwiggyLynxPluginData.CartLynxPluginData cartLynxPluginData = (SwiggyLynxPluginData.CartLynxPluginData) swiggyLynxPluginData;
                String a3 = cartLynxPluginData.a();
                if (a3 != null) {
                    this.h1 = a3;
                }
                E2(arrayList, cartLynxPluginData.a());
            } else if (swiggyLynxPluginData instanceof SwiggyLynxPluginData.IrctcPluginData) {
                arrayList.add(new IrctcPlugin(V1(), new LynxController$initialisePlugins$1$3(this)));
            } else if (swiggyLynxPluginData instanceof SwiggyLynxPluginData.MenuListPluginData) {
                arrayList.add(new in.swiggy.android.swiggylynx.plugin.menulistplugin.b(f2()));
            } else if (swiggyLynxPluginData instanceof SwiggyLynxPluginData.AppScannerPluginData) {
                in.swiggy.android.appscanner.a aVar = in.swiggy.android.appscanner.a.a;
                PackageManager packageManager = getActivity().getPackageManager();
                o.j(packageManager, "getPackageManager(...)");
                arrayList.add(aVar.a(packageManager));
            }
        }
        return arrayList;
    }

    public final void N2() {
        T2();
        ILynxViewUpdateHandler.DefaultImpls.a(this, t2(), S1(), false, false, false, null, null, false, 252, null);
    }

    private final void O2() {
        g2().b("web_cart", x2());
    }

    public final void P2() {
        r3();
    }

    public final String R1(String str) {
        return S1().get(str);
    }

    public final void S2(String str) {
        boolean U;
        boolean U2;
        U = StringsKt__StringsKt.U(str, "explore", false, 2, null);
        if (!U) {
            U2 = StringsKt__StringsKt.U(str, "food-page", false, 2, null);
            if (U2) {
                U1().w0(str);
                K0();
                return;
            }
            return;
        }
        q2().w0(str);
        K0();
    }

    private final void T2() {
        Map<String, String> headers;
        String str;
        LynxData lynxData = (LynxData) G().getParcelable("lynxData");
        if (lynxData != null) {
            i3(lynxData.getUrl());
            g3(lynxData.getPluginSet());
            h3(lynxData.getRequestCode());
            d3(lynxData.getHeaders());
            if (!this.l1.isEmpty()) {
                d3(X2(T1(), this.l1));
            }
            this.b1 = lynxData.getAddDefaultHeaders();
            if (lynxData.getAddDefaultHeaders()) {
                headers = j0.o(lynxData.getHeaders(), P1().a());
            } else {
                headers = lynxData.getHeaders();
            }
            c3(headers);
            if (!this.l1.isEmpty()) {
                c3(X2(S1(), this.l1));
                m mVar = m.a;
                String t2 = t2();
                in.swiggy.android.repositories.interfaces.d u2 = u2();
                in.swiggy.android.commons.utils.contextservice.h K1 = K1();
                in.swiggy.koordinates.compass.core.b Y1 = Y1();
                String w2 = w2();
                in.swiggy.android.repositories.interfaces.e z2 = z2();
                SharedPreferences r2 = r2();
                in.swiggy.android.repositories.cart.interfaces.cart.a r = this.F.r();
                o.j(r, "getCart(...)");
                mVar.e(t2, u2, K1, Y1, w2, z2, r2, r, this.J0, I1(), k2(), TejasConstants.ENABLE_V4_PROFILE_API_DEFAULT, TejasConstants.ENABLE_V4_PROFILE_API_DEFAULT, new LynxController$parsingBundle$1$1(this));
            }
            if (S1().containsKey("x-web-checkout-flow")) {
                str = String.valueOf(S1().get("x-web-checkout-flow"));
            } else {
                str = "";
            }
            j3(str);
        }
    }

    public final void U2(Intent intent) {
        String cartId;
        ReviewedCart reviewedCart;
        String stringExtra = intent.getStringExtra("trackOrderJson");
        String stringExtra2 = intent.getStringExtra("launchScreen");
        Activity activity = getActivity();
        if (activity != null) {
            m2().c(stringExtra, intent.getStringExtra("source"), stringExtra2, activity);
        }
        in.swiggy.android.repositories.cart.interfaces.cart.a r = this.F.r();
        o.i(r, "null cannot be cast to non-null type in.swiggy.android.repositories.cart.impl.Cart");
        ReviewedCartResponse reviewedCartResponse = ((in.swiggy.android.repositories.cart.impl.a) r).a.p;
        if (reviewedCartResponse != null && (reviewedCart = reviewedCartResponse.mReviewedCart) != null) {
            cartId = reviewedCart.cartId;
            o.j(cartId, "cartId");
        } else {
            cartId = "";
        }
        if (stringExtra != null) {
            Z2(stringExtra, cartId);
        }
        Activity activity2 = getActivity();
        if (activity2 != null) {
            activity2.finish();
        }
        r2().edit().putBoolean("isPlanAdded", false).apply();
        r2().edit().putInt("planID", 0).apply();
        this.F.r().x();
    }

    private final void V2() {
        T2();
    }

    private final in.swiggy.android.swiggylynx.utils.f W1() {
        return (in.swiggy.android.swiggylynx.utils.f) this.j1.getValue();
    }

    public final void W2(ArrayList<String> arrayList) {
        this.l1 = arrayList;
    }

    private final Map<String, String> X2(Map<String, String> map, ArrayList<String> arrayList) {
        o.i(map, "null cannot be cast to non-null type kotlin.collections.MutableMap<kotlin.String, kotlin.String>");
        Map<String, String> d = w.d(map);
        Iterator<String> it = arrayList.iterator();
        while (it.hasNext()) {
            d.remove(it.next());
        }
        return d;
    }

    private final void Y2() {
        if (s2().j(G())) {
            in.swiggy.android.swiggylynx.utils.l.h(g2(), s2(), "lynx_controller");
            in.swiggy.android.swiggylynx.utils.l.g(c2(), s2(), "lynx_controller");
            m.g.a.a(this.J0, s2().getState());
            a.C0861a.a(s2(), 0L, 1, null);
        }
    }

    private final void Z2(final String str, final String str2) {
        in.swiggy.android.commons.rxjava.e.m(new Function0<Unit>() {
            {
                super(0);
            }

            @Override
            public Unit invoke() {
                invoke2();
                return Unit.a;
            }

            public final void invoke2() {
                String mOrderId;
                Address address;
                ReviewedCart reviewedCart;
                Gson h = i0.h();
                String str3 = str;
                Order order = (Order) (!(h instanceof Gson) ? h.fromJson(str3, (Class<Object>) Order.class) : GsonInstrumentation.fromJson(h, str3, (Class<Object>) Order.class));
                AddressSortingWeight addressSortingWeight = null;
                if (order != null) {
                    mOrderId = order.mOrderId;
                    o.j(mOrderId, "mOrderId");
                    address = order.mDeliveryAddress;
                } else {
                    mOrderId = "";
                    address = null;
                }
                in.swiggy.android.repositories.cart.interfaces.cart.a r = this.F.r();
                o.i(r, "null cannot be cast to non-null type in.swiggy.android.repositories.cart.impl.Cart");
                in.swiggy.android.repositories.cart.impl.a aVar = (in.swiggy.android.repositories.cart.impl.a) r;
                ReviewedCartResponse reviewedCartResponse = aVar.a.p;
                if (reviewedCartResponse != null && (reviewedCart = reviewedCartResponse.mReviewedCart) != null) {
                    addressSortingWeight = reviewedCart.addressSortingWeight;
                }
                if (address != null) {
                    in.swiggy.koordinates.compass.analytics.a d = LocationEventUtil.d(address, this.Y1().getLocation().getValue(), this.v2(), addressSortingWeight);
                    LocationEventSource locationEventSource = new LocationEventSource(str2, mOrderId);
                    this.Z1().g(d);
                    this.Z1().a(aVar.m().getCartSourceFlowType());
                    in.swiggy.android.swiggylocation.utils.eventmanager.interfaces.a Z1 = this.Z1();
                    in.swiggy.android.analytics.interfaces.c c2 = this.c2();
                    Gson g = i0.g();
                    String json = !(g instanceof Gson) ? g.toJson(locationEventSource) : GsonInstrumentation.toJson(g, locationEventSource);
                    o.j(json, "toJson(...)");
                    LocationEventUtil.f(Z1, c2, "payment", "order-placed", json, "click");
                }
            }
        });
    }

    public static final void k3(Function0 trailingClickAction, View view) {
        o.k(trailingClickAction, "$trailingClickAction");
        trailingClickAction.invoke();
    }

    public static final void l3(Function0 backClickAction, View view) {
        o.k(backClickAction, "$backClickAction");
        backClickAction.invoke();
    }

    public static final void m3(Function0 backClickAction, View view) {
        o.k(backClickAction, "$backClickAction");
        backClickAction.invoke();
    }

    private final void n3(int i) {
        ((ErrorViewV2) b2().findViewById(R.id.errorContainerControllerV2)).setErrorType(i);
        ((ErrorViewV2) b2().findViewById(R.id.errorContainerControllerV2)).setVisibility(0);
        ((ErrorViewV2) b2().findViewById(R.id.errorContainerControllerV2)).setActionClickListener(new Function0<Unit>() {
            {
                super(0);
            }

            @Override
            public Unit invoke() {
                invoke2();
                return Unit.a;
            }

            public final void invoke2() {
                SwiggyLynxWebView M1 = LynxController.this.M1();
                if (M1 != null) {
                    M1.reload();
                }
            }
        });
    }

    static void o3(LynxController lynxController, int i, int i2, Object obj) {
        if ((i2 & 1) != 0) {
            i = 2;
        }
        lynxController.n3(i);
    }

    private final void p3() {
        ((ErrorViewV2) b2().findViewById(R.id.errorContainerControllerV2)).setErrorType(2);
        ((ErrorViewV2) b2().findViewById(R.id.errorContainerControllerV2)).setVisibility(0);
        ((ErrorViewV2) b2().findViewById(R.id.errorContainerControllerV2)).setActionClickListener(new Function0<Unit>() {
            {
                super(0);
            }

            @Override
            public Unit invoke() {
                invoke2();
                return Unit.a;
            }

            public final void invoke2() {
                LynxController.this.K0();
            }
        });
    }

    private final void q3() {
        if (in.swiggy.android.swiggylynx.utils.b.b(this.h1)) {
            o3(this, 0, 1, null);
            return;
        }
        ((ErrorView) b2().findViewById(R.id.errorContainerController)).setErrorType(2);
        ((ErrorView) b2().findViewById(R.id.errorContainerController)).setVisibility(0);
        ((ErrorView) b2().findViewById(R.id.errorContainerController)).setActionClickListener(new Function0<Unit>() {
            {
                super(0);
            }

            @Override
            public Unit invoke() {
                invoke2();
                return Unit.a;
            }

            public final void invoke2() {
                SwiggyLynxWebView M1 = LynxController.this.M1();
                if (M1 != null) {
                    M1.reload();
                }
            }
        });
    }

    private final void r3() {
        Bundle bundle = new Bundle();
        bundle.putBoolean("fromWebCart", true);
        bundle.putString("launchReferrer", "web-cart");
        if (getActivity() != null) {
            HomeActivity.a aVar = HomeActivity.C0;
            Activity activity = getActivity();
            o.j(activity, "getActivity(...)");
            aVar.b(activity, bundle);
        }
    }

    private final void s3(Intent intent) {
        s2().k(AmazonPlugin.Companion.a(intent));
    }

    private final HashMap<String, Object> x2() {
        if (this.Y0 != null) {
            HashMap<String, Object> hashMap = new HashMap<>();
            hashMap.put("x-web-checkout-flow", w2());
            return hashMap;
        }
        return null;
    }

    private final ArrayList<String> y2() {
        Object fromJson;
        String string = r2().getString("white_listed_domains_for_headers", "[\"swiggy.com\", \"swig.gy\", \"d1.swiggyops.de\",\"u4.swiggyops.de\",\"staging-stores.swiggyops.de\", \"sf.swiggyops.de\",\"gifting-ui-ui-cont.uat.singapore.swig.gy\", \"ofo-service.u4.singapore.swig.gy\", \"social-ofo-mweb.sf.singapore.swig.gy\", \"social-ofo-mweb.u4.singapore.swig.gy\", \"social-ofo-mweb.uat.singapore.swig.gy\", \"nyee-mweb.uat.singapore.swig.gy\", \"staging.swiggy.com\", \"reviews.swiggy.com\", \"portal.stg.swiggyops.de\", \"sw-moments-new-onboard-loader-mweb.u4.singapore.swig.gy\", \"swiggy.cloud\", \"sw-moments-gifter-flow-mweb.u4.singapore.swig.gy\" ]");
        Type type = new a().getType();
        Gson g = i0.g();
        if (!(g instanceof Gson)) {
            fromJson = g.fromJson(string, type);
        } else {
            fromJson = GsonInstrumentation.fromJson(g, string, type);
        }
        o.j(fromJson, "fromJson(...)");
        return (ArrayList) fromJson;
    }

    @Override
    public Context C0() {
        return getActivity().getApplicationContext();
    }

    public void D2(Context context) {
        b.a.a(this, context);
    }

    @Override
    public void E(boolean z) {
        if (z) {
            FrameLayout frameLayout = (FrameLayout) b2().findViewById(R.id.loaderContainerController);
            if (frameLayout != null) {
                frameLayout.setVisibility(0);
                return;
            }
            return;
        }
        FrameLayout frameLayout2 = (FrameLayout) b2().findViewById(R.id.loaderContainerController);
        if (frameLayout2 != null) {
            frameLayout2.setVisibility(8);
        }
    }

    @Override
    public void E0(boolean z, String title, com.swiggy.lynx.plugin.core.showheader.b bVar, final Function0<Unit> backClickAction, Function0<Unit> closeClickAction) {
        final com.swiggy.lynx.plugin.core.showheader.c g;
        String f;
        o.k(title, "title");
        o.k(backClickAction, "backClickAction");
        o.k(closeClickAction, "closeClickAction");
        AdvancedToolbar advancedToolbar = (AdvancedToolbar) b2().findViewById(R.id.toolbarController);
        if (z) {
            int i = 8388611;
            if (bVar != null && (f = bVar.f()) != null) {
                if (o.f(f, TitleAlignmentEnum.CENTRE.getValue())) {
                    i = 1;
                } else if (o.f(f, TitleAlignmentEnum.RIGHT.getValue())) {
                    i = 8388613;
                } else if (!o.f(f, TitleAlignmentEnum.LEFT.getValue())) {
                    o.f(f, TitleAlignmentEnum.INVALID.getValue());
                }
            }
            ConstraintLayout constraintLayout = (ConstraintLayout) b2().findViewById(R.id.headerController);
            if (constraintLayout != null) {
                constraintLayout.setVisibility(0);
            }
            if (advancedToolbar != null) {
                advancedToolbar.setTitle(title);
                advancedToolbar.setTextGravity(i);
                if (bVar != null && (g = bVar.g()) != null) {
                    advancedToolbar.setTrailingButtonIconAppearance(R.style.CloseNavigationAppearance);
                    final Function0<Unit> function0 = new Function0<Unit>() {
                        {
                            super(0);
                        }

                        @Override
                        public final Unit invoke() {
                            String d = com.swiggy.lynx.plugin.core.showheader.c.this.d();
                            if (d != null) {
                                ILynxViewUpdateHandler.DefaultImpls.a(this, d, null, false, true, false, null, null, false, 246, null);
                                return Unit.a;
                            }
                            return null;
                        }
                    };
                    advancedToolbar.setTrailingOnClickListener(new View.OnClickListener() {
                        @Override
                        public final void onClick(View view) {
                            LynxController.k3(Function0.this, view);
                        }
                    });
                }
                advancedToolbar.setNavigationOnClickListener(new View.OnClickListener() {
                    @Override
                    public final void onClick(View view) {
                        LynxController.l3(Function0.this, view);
                    }
                });
                return;
            }
            return;
        }
        ConstraintLayout constraintLayout2 = (ConstraintLayout) b2().findViewById(R.id.headerController);
        if (constraintLayout2 != null) {
            constraintLayout2.setVisibility(8);
        }
        if (advancedToolbar != null) {
            advancedToolbar.setTitle((CharSequence) null);
        }
        if (advancedToolbar != null) {
            advancedToolbar.setNavigationOnClickListener(new View.OnClickListener() {
                @Override
                public final void onClick(View view) {
                    LynxController.m3(Function0.this, view);
                }
            });
        }
    }

    public final in.swiggy.android.feature.address.a F1() {
        in.swiggy.android.feature.address.a aVar = this.P0;
        if (aVar != null) {
            return aVar;
        }
        o.C("addressEntryPoints");
        return null;
    }

    public final in.swiggy.android.swiggylynx.plugin.addressSorting.b G1() {
        in.swiggy.android.swiggylynx.plugin.addressSorting.b bVar = this.O0;
        if (bVar != null) {
            return bVar;
        }
        o.C("addressSortingPluginMapper");
        return null;
    }

    public final AmazonPlugin H1() {
        AmazonPlugin amazonPlugin = this.U0;
        if (amazonPlugin != null) {
            return amazonPlugin;
        }
        o.C("amazonPayPlugin");
        return null;
    }

    public final in.swiggy.android.commons.utils.a I1() {
        in.swiggy.android.commons.utils.a aVar = this.I0;
        if (aVar != null) {
            return aVar;
        }
        o.C("appBuildDetails");
        return null;
    }

    public final in.swiggy.android.mxn.swiggyats.a J1() {
        in.swiggy.android.mxn.swiggyats.a aVar = this.M0;
        if (aVar != null) {
            return aVar;
        }
        o.C("atsService");
        return null;
    }

    @Override
    public void K0() {
        getActivity().finish();
    }

    public final in.swiggy.android.commons.utils.contextservice.h K1() {
        in.swiggy.android.commons.utils.contextservice.h hVar = this.S;
        if (hVar != null) {
            return hVar;
        }
        o.C("contextService");
        return null;
    }

    public final in.swiggy.android.crosspollination.c L1() {
        in.swiggy.android.crosspollination.c cVar = this.H0;
        if (cVar != null) {
            return cVar;
        }
        o.C("crossPollinationDataManager");
        return null;
    }

    public final SwiggyLynxWebView M1() {
        return this.J0;
    }

    public final void M2(in.swiggy.android.swiggylynx.plugin.swiggylynxcoreplugin.c launchMenuFromRestIdPayload) {
        o.k(launchMenuFromRestIdPayload, "launchMenuFromRestIdPayload");
        Activity activity = getActivity();
        if (activity != null) {
            PostableMenuRequest postableMenuRequest = new PostableMenuRequest(null, null, false, false, launchMenuFromRestIdPayload.d(), null, null, launchMenuFromRestIdPayload.a(), null, null, null, null, null, null, null, null, null, 130919, null);
            Intent intent = new Intent(activity, MenuV2Activity.class);
            intent.putExtra("restaurantId", launchMenuFromRestIdPayload.c());
            intent.putExtra("postable_data", postableMenuRequest);
            intent.putExtra("shouldRefreshMenu", launchMenuFromRestIdPayload.b());
            intent.putExtra("launchReferrer", d0());
            in.swiggy.android.repositories.cart.interfaces.cart.a r = this.F.r();
            o.j(r, "getCart(...)");
            w1.c(this, r);
            o.i(this, "null cannot be cast to non-null type in.swiggy.android.mvvm.SwiggyUIComponent");
            O(intent, 341);
        }
    }

    @Override
    public void N() {
        Activity activity = getActivity();
        if (activity != null) {
            activity.onBackPressed();
        }
    }

    public final in.swiggy.android.deeplink.b N1() {
        in.swiggy.android.deeplink.b bVar = this.Q;
        if (bVar != null) {
            return bVar;
        }
        o.C("deepLinkHandler");
        return null;
    }

    public final c0 O1() {
        c0 c0Var = this.R;
        if (c0Var != null) {
            return c0Var;
        }
        o.C("deepLinkHandlerUtil");
        return null;
    }

    @Override
    public void P() {
        a.C0891a.c(this);
        B2();
    }

    public final in.swiggy.android.swiggylynx.headers.a P1() {
        in.swiggy.android.swiggylynx.headers.a aVar = this.Y;
        if (aVar != null) {
            return aVar;
        }
        o.C("defaultHeaders");
        return null;
    }

    public final in.swiggy.android.commons.featureFlags.d Q1() {
        in.swiggy.android.commons.featureFlags.d dVar = this.N0;
        if (dVar != null) {
            return dVar;
        }
        o.C("featureFlags");
        return null;
    }

    public final void Q2(Intent intent) {
        o.k(intent, "intent");
        s3(intent);
        if (this.U0 != null) {
            H1().onNewIntent(intent);
        }
    }

    @Override
    public void R0() {
        a.C0891a.b(this);
    }

    public void R2() {
        Activity activity = getActivity();
        if (activity != null) {
            activity.finish();
        }
    }

    @Override
    public void S0(boolean z, WebResourceRequest webResourceRequest, com.swiggy.lynx.webinterface.d dVar) {
        CharSequence a2;
        if (z) {
            if (!K1().isNetworkAvailable()) {
                if (in.swiggy.android.swiggylynx.utils.b.b(this.h1)) {
                    n3(0);
                    return;
                }
                ((ErrorView) b2().findViewById(R.id.errorContainerController)).setErrorType(0);
                ((ErrorView) b2().findViewById(R.id.errorContainerController)).setVisibility(0);
                ((ErrorView) b2().findViewById(R.id.errorContainerController)).setActionClickListener(new Function0<Unit>() {
                    {
                        super(0);
                    }

                    @Override
                    public Unit invoke() {
                        invoke2();
                        return Unit.a;
                    }

                    public final void invoke2() {
                        SwiggyLynxWebView M1 = LynxController.this.M1();
                        if (M1 != null) {
                            M1.reload();
                        }
                    }
                });
                return;
            }
            SwiggyLynxWebView swiggyLynxWebView = this.J0;
            if (swiggyLynxWebView == null || !swiggyLynxWebView.j(webResourceRequest, dVar)) {
                if (o.f(r2().getString("handle_received_error", TejasConstants.ENABLE_V4_PROFILE_API_DEFAULT), "true")) {
                    if (dVar == null || (a2 = dVar.a()) == null || !a2.equals("HTTPError")) {
                        q3();
                        return;
                    }
                    return;
                }
                q3();
                return;
            }
            return;
        }
        ((ErrorView) b2().findViewById(R.id.errorContainerController)).setVisibility(8);
        ((ErrorViewV2) b2().findViewById(R.id.errorContainerControllerV2)).setVisibility(8);
    }

    public final Map<String, String> S1() {
        Map<String, String> map = this.a1;
        if (map != null) {
            return map;
        }
        o.C("headers");
        return null;
    }

    @Override
    public void T0(String str, String str2, String str3, String str4) {
        a.C0891a.g(this, str, str2, str3, str4);
    }

    public final Map<String, String> T1() {
        Map<String, String> map = this.c1;
        if (map != null) {
            return map;
        }
        o.C("headersFromIntent");
        return null;
    }

    public final PublishProcessor<String> U1() {
        PublishProcessor<String> publishProcessor = this.D0;
        if (publishProcessor != null) {
            return publishProcessor;
        }
        o.C("hideRestoSubmitFeedback");
        return null;
    }

    public final IrctcDataProvider V1() {
        IrctcDataProvider irctcDataProvider = this.T0;
        if (irctcDataProvider != null) {
            return irctcDataProvider;
        }
        o.C("irctcDataProvider");
        return null;
    }

    public final KlyticsEventSender X1() {
        KlyticsEventSender klyticsEventSender = this.B0;
        if (klyticsEventSender != null) {
            return klyticsEventSender;
        }
        o.C("klyticsEventSender");
        return null;
    }

    public final in.swiggy.koordinates.compass.core.b Y1() {
        in.swiggy.koordinates.compass.core.b bVar = this.X;
        if (bVar != null) {
            return bVar;
        }
        o.C("locationContext");
        return null;
    }

    @Override
    public boolean Z() {
        SwiggyLynxWebView swiggyLynxWebView = this.J0;
        if (swiggyLynxWebView != null && swiggyLynxWebView.canGoBack()) {
            return true;
        }
        FrameLayout frameLayout = (FrameLayout) b2().findViewById(R.id.webContainer);
        if (frameLayout != null && KotlinExtensionsKt.f(Integer.valueOf(frameLayout.getChildCount()), 1)) {
            C2();
            ((FrameLayout) b2().findViewById(R.id.webContainerController)).removeView(this.V0.pop());
            this.J0 = this.V0.peek();
            return true;
        }
        return false;
    }

    public final in.swiggy.android.swiggylocation.utils.eventmanager.interfaces.a Z1() {
        in.swiggy.android.swiggylocation.utils.eventmanager.interfaces.a aVar = this.c0;
        if (aVar != null) {
            return aVar;
        }
        o.C("locationEventManager");
        return null;
    }

    public final Stack<SwiggyLynxWebView> a2() {
        return this.V0;
    }

    public final void a3(AmazonPlugin amazonPlugin) {
        o.k(amazonPlugin, "<set-?>");
        this.U0 = amazonPlugin;
    }

    @Override
    @TargetApi(21)
    public void b0(WebChromeClient.FileChooserParams fileChooserParams, in.swiggy.android.web.wrapper.a aVar, int i, in.swiggy.android.web.h hVar, SharedPreferences sharedPreferences) {
        a.C0891a.d(this, fileChooserParams, aVar, i, hVar, sharedPreferences);
    }

    public final View b2() {
        View view = this.i1;
        if (view != null) {
            return view;
        }
        o.C("mRootView");
        return null;
    }

    public final void b3(SwiggyLynxWebView swiggyLynxWebView) {
        this.J0 = swiggyLynxWebView;
    }

    public final in.swiggy.android.analytics.interfaces.c c2() {
        in.swiggy.android.analytics.interfaces.c cVar = this.p0;
        if (cVar != null) {
            return cVar;
        }
        o.C("mSwiggyEventHandler");
        return null;
    }

    public final void c3(Map<String, String> map) {
        o.k(map, "<set-?>");
        this.a1 = map;
    }

    @Override
    public String d0() {
        SwiggyGTMConstants swiggyGTMConstants = SwiggyGTMConstants.a;
        String simpleName = LynxController.class.getSimpleName();
        o.j(simpleName, "getSimpleName(...)");
        return swiggyGTMConstants.c(simpleName);
    }

    public final in.swiggy.android.analytics.generated.e d2() {
        in.swiggy.android.analytics.generated.e eVar = this.y0;
        if (eVar != null) {
            return eVar;
        }
        o.C("mSwiggyEventLogger");
        return null;
    }

    public final void d3(Map<String, String> map) {
        o.k(map, "<set-?>");
        this.c1 = map;
    }

    @Override
    public Context e1() {
        return getActivity();
    }

    public final void e3(View view) {
        o.k(view, "<set-?>");
        this.i1 = view;
    }

    @Override
    public boolean f1() {
        return false;
    }

    public final in.swiggy.android.swiggylynx.service.a f2() {
        in.swiggy.android.swiggylynx.service.a aVar = this.z0;
        if (aVar != null) {
            return aVar;
        }
        o.C("mSwiggyLynxInterface");
        return null;
    }

    public final void f3(in.swiggy.android.commonsFeature.f fVar) {
        this.W0 = fVar;
    }

    public final in.swiggy.android.analytics.newrelic.a g2() {
        in.swiggy.android.analytics.newrelic.a aVar = this.W;
        if (aVar != null) {
            return aVar;
        }
        o.C("newrelicPerformanceUtils");
        return null;
    }

    public final void g3(Set<? extends SwiggyLynxPluginData> set) {
        o.k(set, "<set-?>");
        this.Z0 = set;
    }

    public final q0 h2() {
        q0 q0Var = this.F0;
        if (q0Var != null) {
            return q0Var;
        }
        o.C("ofoUtil");
        return null;
    }

    public final void h3(int i) {
        this.d1.b(this, n1[0], Integer.valueOf(i));
    }

    public final OkHttpClient i2() {
        OkHttpClient okHttpClient = this.K0;
        if (okHttpClient != null) {
            return okHttpClient;
        }
        o.C("okhttp");
        return null;
    }

    public final void i3(String str) {
        o.k(str, "<set-?>");
        this.X0 = str;
    }

    @Override
    public void j0(Uri uri, boolean z) {
        a.C0891a.f(this, uri, z);
    }

    public final in.swiggy.android.payment.services.interfaces.d j2() {
        in.swiggy.android.payment.services.interfaces.d dVar = this.G0;
        if (dVar != null) {
            return dVar;
        }
        o.C("oneClickService");
        return null;
    }

    public final void j3(String str) {
        o.k(str, "<set-?>");
        this.Y0 = str;
    }

    @Override
    public void k0(int i, int i2, Intent intent) {
        SwiggyLynxWebView swiggyLynxWebView = this.J0;
        if (swiggyLynxWebView != null) {
            if (swiggyLynxWebView != null) {
                swiggyLynxWebView.n(i, i2, intent);
            }
        } else {
            Context applicationContext = getActivity().getApplicationContext();
            o.i(applicationContext, "null cannot be cast to non-null type in.swiggy.android.SwiggyApplication");
            ((SwiggyApplication) applicationContext).c0().L(this);
            s2().l(new in.swiggy.android.swiggylynx.utils.a(i, i2, intent));
            D1(i, i2, intent);
        }
        in.swiggy.android.swiggylynx.utils.l.f(g2(), this.J0, i, i2, "lynx_controller");
        in.swiggy.android.swiggylynx.utils.l.e(c2(), this.J0, i, i2, "lynx_controller");
        if (this.J0 == null) {
            x.i("lynx_controller", new Throwable());
        }
        super.k0(i, i2, intent);
    }

    public final in.swiggy.android.commons.ozone.a k2() {
        in.swiggy.android.commons.ozone.a aVar = this.R0;
        if (aVar != null) {
            return aVar;
        }
        o.C("ozoneStorageManager");
        return null;
    }

    public final in.swiggy.android.commons.ozone.b l2() {
        in.swiggy.android.commons.ozone.b bVar = this.S0;
        if (bVar != null) {
            return bVar;
        }
        o.C("ozoneTokenFetchAndRefreshManager");
        return null;
    }

    public final in.swiggy.android.feature.payment.services.interfaces.b m2() {
        in.swiggy.android.feature.payment.services.interfaces.b bVar = this.Z;
        if (bVar != null) {
            return bVar;
        }
        o.C("paymentCartObjectService");
        return null;
    }

    public final Set<SwiggyLynxPluginData> n2() {
        Set set = this.Z0;
        if (set != null) {
            return set;
        }
        o.C("plugins");
        return null;
    }

    @Override
    protected void o0(View view) {
        o.k(view, "view");
        if (this.e1) {
            p3();
            return;
        }
        if (this.Y == null) {
            Context applicationContext = getActivity().getApplicationContext();
            o.i(applicationContext, "null cannot be cast to non-null type in.swiggy.android.SwiggyApplication");
            ((SwiggyApplication) applicationContext).c0().L(this);
        }
        V2();
        W1().e(getActivity(), f.a.C0890a.a);
        K2((SwiggyLynxWebView) b2().findViewById(R.id.defaultLynxViewController));
        ILynxViewUpdateHandler.DefaultImpls.a(this, t2(), S1(), false, false, false, null, null, false, 252, null);
        O2();
        if (s2().h(G())) {
            Y2();
        }
        if (J1().b()) {
            m.a.a.a(this.J0);
        }
    }

    public final BehaviorProcessor<QuizProgressUpdatePayload> o2() {
        BehaviorProcessor<QuizProgressUpdatePayload> behaviorProcessor = this.E0;
        if (behaviorProcessor != null) {
            return behaviorProcessor;
        }
        o.C("quizFeedback");
        return null;
    }

    @Override
    protected void onDestroy() {
        ViewTreeObserver viewTreeObserver;
        t().dispose();
        SwiggyLynxWebView swiggyLynxWebView = this.J0;
        if (swiggyLynxWebView != null && (viewTreeObserver = swiggyLynxWebView.getViewTreeObserver()) != null) {
            viewTreeObserver.removeOnGlobalLayoutListener(this.m1);
        }
        SwiggyLynxWebView swiggyLynxWebView2 = this.J0;
        if (swiggyLynxWebView2 != null) {
            swiggyLynxWebView2.h();
        }
        SwiggyLynxWebView swiggyLynxWebView3 = this.J0;
        if (swiggyLynxWebView3 != null) {
            swiggyLynxWebView3.destroy();
        }
        LynxViewClient lynxViewClient = this.k1;
        if (lynxViewClient != null) {
            lynxViewClient.i();
        }
        super.onDestroy();
    }

    public final RecommendedCartsDriver p2() {
        RecommendedCartsDriver recommendedCartsDriver = this.Q0;
        if (recommendedCartsDriver != null) {
            return recommendedCartsDriver;
        }
        o.C("recommendedCartsDriver");
        return null;
    }

    public final PublishProcessor<String> q2() {
        PublishProcessor<String> publishProcessor = this.C0;
        if (publishProcessor != null) {
            return publishProcessor;
        }
        o.C("searchSubmitFeedback");
        return null;
    }

    public final SharedPreferences r2() {
        SharedPreferences sharedPreferences = this.T;
        if (sharedPreferences != null) {
            return sharedPreferences;
        }
        o.C("sharedPreferences");
        return null;
    }

    public final in.swiggy.android.swiggylynx.interfaces.a s2() {
        in.swiggy.android.swiggylynx.interfaces.a aVar = this.L0;
        if (aVar != null) {
            return aVar;
        }
        o.C("stateManager");
        return null;
    }

    @Override
    public io.reactivex.disposables.a t() {
        return new io.reactivex.disposables.a();
    }

    public final String t2() {
        String str = this.X0;
        if (str != null) {
            return str;
        }
        o.C("url");
        return null;
    }

    @Override
    public View u0(LayoutInflater inflater, ViewGroup container) {
        String name;
        o.k(inflater, "inflater");
        o.k(container, "container");
        try {
            View inflate = inflater.inflate(R.layout.controller_lynx, container, false);
            o.j(inflate, "inflate(...)");
            e3(inflate);
            Context applicationContext = getActivity().getApplicationContext();
            o.j(applicationContext, "getApplicationContext(...)");
            D2(applicationContext);
        } catch (Throwable th) {
            if (!LynxController.class.isAnonymousClass()) {
                name = LynxController.class.getSimpleName();
                if (name.length() > 23) {
                    o.h(name);
                    name = name.substring(0, 23);
                    o.j(name, "substring(...)");
                }
                o.h(name);
            } else {
                name = LynxController.class.getName();
                if (name.length() > 23) {
                    o.h(name);
                    name = name.substring(name.length() - 23, name.length());
                    o.j(name, "substring(...)");
                }
                o.h(name);
            }
            x.i(name, th);
            this.e1 = true;
            View inflate2 = inflater.inflate(R.layout.lynx_error_view_layout, container, false);
            o.j(inflate2, "inflate(...)");
            e3(inflate2);
        }
        return b2();
    }

    public final in.swiggy.android.repositories.interfaces.d u2() {
        in.swiggy.android.repositories.interfaces.d dVar = this.U;
        if (dVar != null) {
            return dVar;
        }
        o.C(LogSubCategory.Action.USER);
        return null;
    }

    public final j v2() {
        j jVar = this.V;
        if (jVar != null) {
            return jVar;
        }
        o.C("userLocationManager");
        return null;
    }

    @Override
    public void w0(View view) {
        o.k(view, "view");
    }

    public final String w2() {
        String str = this.Y0;
        if (str != null) {
            return str;
        }
        o.C("webFlow");
        return null;
    }

    @Override
    public HashMap<String, Object> x0() {
        return x2();
    }

    @Override
    public void y0(String url, Map<String, String> additionalHeaders, boolean z, boolean z2, boolean z3, String str, String str2, boolean z4) {
        Map<String, String> T1;
        Map<String, String> o;
        WebSettings webSettings;
        boolean y;
        String name;
        o.k(url, "url");
        o.k(additionalHeaders, "additionalHeaders");
        if (z) {
            Context applicationContext = getActivity().getApplicationContext();
            o.j(applicationContext, "getApplicationContext(...)");
            SwiggyLynxWebView swiggyLynxWebView = new SwiggyLynxWebView(applicationContext);
            FrameLayout frameLayout = (FrameLayout) b2().findViewById(R.id.webContainerController);
            if (frameLayout != null) {
                frameLayout.addView(swiggyLynxWebView);
            }
            this.J0 = swiggyLynxWebView;
            K2(swiggyLynxWebView);
            if (X1().c()) {
                in.swiggy.klytics.singleton.b bVar = in.swiggy.klytics.singleton.b.a;
                String str3 = "";
                String string = r2().getString("userAgent", "");
                if (string != null) {
                    str3 = string;
                }
                bVar.k(str3);
            }
        }
        if (this.b1) {
            T1 = j0.o(T1(), P1().a());
        } else {
            T1 = T1();
        }
        c3(T1);
        o = j0.o(S1(), additionalHeaders);
        ArrayList<String> y2 = y2();
        String a2 = com.swiggy.lynx.utils.a.a.a(url);
        if (o.f(a2, "invalid")) {
            if (!LynxController.class.isAnonymousClass()) {
                name = LynxController.class.getSimpleName();
                if (name.length() > 23) {
                    o.h(name);
                    name = name.substring(0, 23);
                    o.j(name, "substring(...)");
                }
                o.h(name);
            } else {
                name = LynxController.class.getName();
                if (name.length() > 23) {
                    o.h(name);
                    name = name.substring(name.length() - 23, name.length());
                    o.j(name, "substring(...)");
                }
                o.h(name);
            }
            x.i(name, new IllegalHostException(url));
        }
        ArrayList arrayList = new ArrayList();
        Iterator<T> it = y2.iterator();
        while (true) {
            webSettings = null;
            if (!it.hasNext()) {
                break;
            }
            Object next = it.next();
            y = q.y(a2, (String) next, false, 2, null);
            if (y) {
                arrayList.add(next);
            }
        }
        if ((!arrayList.isEmpty()) && !o.f(a2, "invalid")) {
            SwiggyLynxWebView swiggyLynxWebView2 = this.J0;
            if (swiggyLynxWebView2 != null) {
                webSettings = swiggyLynxWebView2.getSettings();
            }
            if (webSettings != null) {
                webSettings.setMediaPlaybackRequiresUserGesture(false);
            }
            SwiggyLynxWebView swiggyLynxWebView3 = this.J0;
            if (swiggyLynxWebView3 != null) {
                swiggyLynxWebView3.l(url, SwiggyLynxWebView.Companion.a(o), z2);
            }
        } else {
            SwiggyLynxWebView swiggyLynxWebView4 = this.J0;
            if (swiggyLynxWebView4 != null) {
                swiggyLynxWebView4.l(url, new HashMap(), z2);
            }
        }
        SwiggyLynxWebView swiggyLynxWebView5 = this.J0;
        if (swiggyLynxWebView5 != null) {
            swiggyLynxWebView5.t(r2());
        }
        if (z3 && str2 != null) {
            ILynxViewUpdateHandler.DefaultImpls.b(this, true, null, null, new Function0<Unit>() {
                {
                    super(0);
                }

                @Override
                public Unit invoke() {
                    invoke2();
                    return Unit.a;
                }

                public final void invoke2() {
                    FrameLayout frameLayout2 = (FrameLayout) LynxController.this.b2().findViewById(R.id.webContainerController);
                    if (KotlinExtensionsKt.f(frameLayout2 != null ? Integer.valueOf(frameLayout2.getChildCount()) : null, 1)) {
                        LynxController.this.C2();
                        FrameLayout frameLayout3 = (FrameLayout) LynxController.this.b2().findViewById(R.id.webContainerController);
                        if (frameLayout3 != null) {
                            frameLayout3.removeView(LynxController.this.a2().pop());
                        }
                        LynxController lynxController = LynxController.this;
                        lynxController.b3(lynxController.a2().peek());
                    }
                }
            }, null, 22, null);
        }
        E(true);
    }

    @Override
    protected void z0(View view) {
        o.k(view, "view");
        t().dispose();
        super.z0(view);
    }

    public final in.swiggy.android.repositories.interfaces.e z2() {
        in.swiggy.android.repositories.interfaces.e eVar = this.A0;
        if (eVar != null) {
            return eVar;
        }
        o.C("xpExperimentContext");
        return null;
    }
}