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

import X.0Gf;
import X.0Gp;
import X.6Zq;
import X.C2700NOd;
import X.C2718NOv;
import X.C2967NYk;
import X.C4087NrO;
import X.C4220NtX;
import X.GIs;
import X.LsC;
import X.M12;
import X.MMJ;
import X.NOV;
import X.NOW;
import X.NOX;
import com.bytedance.covode.number.Covode;
import com.ss.android.ugc.aweme.tools.live.LiveSettingApi;
import java.util.List;
import kotlin.h.b.n;

public final class DMTBottomTabIntegrationServiceImplDiff {
    public static final DMTBottomTabIntegrationServiceImplDiff INSTANCE = new DMTBottomTabIntegrationServiceImplDiff();

    static {
        Covode.recordClassIndex(105038);
    }

    public final void tryShowPopupForLiveWhenFirstTime(C4087NrO nrO) {
        NOX nox = new NOX();
        if (!nox.LIZ() && MMJ.LIZIZ()) {
            LiveSettingApi.LIZ.createInfo().LIZ(new DMTBottomTabIntegrationServiceImplDiff$tryShowPopupForLiveWhenFirstTime$1(nox, nrO), 0Gp.LIZIZ, (0Gf) null);
        }
    }

    public final boolean addLiveTabInternal(C4087NrO nrO, LsC<? super Integer, Integer> lsC) {
        Object LIZ = nrO.LIZ(C2700NOd.class);
        n.LIZIZ(LIZ, "");
        C2700NOd nOd = (C2700NOd) LIZ;
        6Zq.LIZ("addLiveTabInternal:" + nOd.isValid());
        if (!nOd.isValid()) {
            return false;
        }
        if (MMJ.LIZ()) {
            NOX nox = new NOX();
            if (nox.LIZ() && nox.LIZIZ()) {
                String currentBottomTag = nOd.getCurrentBottomTag();
                nOd.addBottomTab(((Number) lsC.invoke(Integer.valueOf(nOd.bottomTabSize()))).intValue() - 1, new C2718NOv(nrO), 0);
                nOd.resetToCurTab(currentBottomTag);
            } else if (!nox.LIZ()) {
                LiveSettingApi.LIZ.createInfo().LIZ(new DMTBottomTabIntegrationServiceImplDiff$addLiveTabInternal$2(nox, nOd, lsC, nrO), 0Gp.LIZIZ, (0Gf) null);
                return true;
            } else {
                nOd.addBottomTab(((Number) lsC.invoke(Integer.valueOf(nOd.bottomTabSize()))).intValue(), new C2718NOv(nrO), 0);
            }
        } else {
            nOd.addBottomTab(((Number) lsC.invoke(Integer.valueOf(nOd.bottomTabSize()))).intValue(), new C2718NOv(nrO), 0);
        }
        return false;
    }

    public final List<C2967NYk> addLiveModule(C4087NrO nrO, List<C2967NYk> list, NOV nov) {
        M12.LIZ(nrO, list, nov);
        if (!C4220NtX.LJIJ.LIZ() && nov.LIZIZ.LJJLIIIJJIZ == null) {
            if (MMJ.LIZ() || !nov.LIZIZ.LJJZZI) {
                nov.LIZJ.invoke();
                C4220NtX.LJIILLIIL.LIZ((GIs) new DMTBottomTabIntegrationServiceImplDiff$addLiveModule$$inlined$apply$lambda$1(nov, list, nov, nrO));
            } else {
                NOW.LIZ = 0;
                if (((Boolean) nov.LIZ.invoke()).booleanValue() && !nov.LIZIZ.LJJZZI) {
                    NOW.LIZ = 1;
                }
                if (!((Boolean) nov.LIZ.invoke()).booleanValue() && nov.LIZIZ.LJJZZI) {
                    NOW.LIZ = 2;
                }
                list.add(new C2718NOv(nrO));
                if (!MMJ.LIZ()) {
                    INSTANCE.tryShowPopupForLiveWhenFirstTime(nrO);
                }
            }
        }
        return list;
    }
}
