package com.bytedance.android.live;

import X.AnonymousClass14O;
import X.AnonymousClass14R;
import X.AnonymousClass14S;
import X.AnonymousClass14T;
import X.AnonymousClass14Y;
import X.C09630aP;
import X.C13950hN;
import X.C13960hO;
import X.C265814e;
import X.C267714x;
import X.C267814y;
import X.C38131fH;
import X.C38221fQ;
import X.C39401hK;
import X.JRW;
import android.text.TextUtils;
import com.bytedance.android.live.slot.BottomLeftSlotWidget;
import com.bytedance.android.live.slot.FrameL2SlotWidget;
import com.bytedance.android.live.slot.FrameL3SlotWidget;
import com.bytedance.android.live.slot.FrameSlotWidget;
import com.bytedance.android.live.slot.FreeFrameSlotWidget;
import com.bytedance.android.live.slot.ISlotService;
import com.bytedance.android.live.slot.IconSlotController;
import com.bytedance.android.live.slot.SlotBarrageWidget;
import com.bytedance.android.livesdk.livesetting.broadcast.LiveSlotExperiment;
import com.bytedance.android.livesdk.livesetting.model.SlotBizTypeDisallow;
import com.bytedance.covode.number.Covode;
import com.bytedance.ies.sdk.widgets.LiveRecyclableWidget;
import com.ss.ugc.live.sdk.message.data.IMessage;
import java.util.ArrayList;
import java.util.Iterator;
import java.util.List;
import java.util.Map;

public class SlotService implements ISlotService {
    static {
        Covode.recordClassIndex(4690);
    }

    public void onInit() {
    }

    public Class<? extends LiveRecyclableWidget> getBarrageWidget() {
        return SlotBarrageWidget.class;
    }

    public Class<? extends LiveRecyclableWidget> getBottomLeftSlotWidget() {
        return BottomLeftSlotWidget.class;
    }

    public Class<? extends LiveRecyclableWidget> getFrameL2SlotWidget() {
        return FrameL2SlotWidget.class;
    }

    public Class<? extends LiveRecyclableWidget> getFrameL3SlotWidget() {
        return FrameL3SlotWidget.class;
    }

    public Class<? extends LiveRecyclableWidget> getFrameSlotWidget() {
        return FrameSlotWidget.class;
    }

    public Class<? extends LiveRecyclableWidget> getFreeFrameSlotWidget() {
        return FreeFrameSlotWidget.class;
    }

    public C267714x getAggregateProviderByID(AnonymousClass14S r2) {
        return C13960hO.LIZ().LIZIZ(r2);
    }

    public List<C265814e> getProviderWrappersByID(AnonymousClass14O r2) {
        return C13960hO.LIZ().LIZ(r2);
    }

    public boolean isBizTypeRegistered(String str) {
        return C13960hO.LIZ().LIZ.LIZLLL.containsKey(str);
    }

    public void dispatchMessage(IMessage iMessage) {
        Iterator<C267814y> it = C13960hO.LIZ().LIZ.LIZLLL.values().iterator();
        while (it.hasNext()) {
            it.next();
        }
    }

    public List<C265814e> getProviderWrappersByID(AnonymousClass14S r2) {
        return C13960hO.LIZ().LIZ(r2);
    }

    public AnonymousClass14Y getSlotMessagerByBiz(String str) {
        C13960hO LIZ = C13960hO.LIZ();
        if (LIZ.LIZ.LIZLLL.containsKey(str) && LIZ.LIZ.LIZ(str) != null) {
            LIZ.LIZ.LIZ(str);
        }
        return null;
    }

    public void registerAggregateSlot(C267714x r7) {
        C13960hO LIZ = C13960hO.LIZ();
        String LIZIZ = r7.LIZIZ();
        if (!TextUtils.isEmpty(LIZIZ)) {
            SlotBizTypeDisallow slotBizTypeDisallow = (SlotBizTypeDisallow) LiveSlotExperiment.INSTANCE.getBizTypeDisallow().get(LIZIZ);
            if (slotBizTypeDisallow == null || !slotBizTypeDisallow.getDisallowAll()) {
                C13950hN r0 = LIZ.LIZ;
                r0.LJ.put(r7.LIZIZ(), r7);
                List<AnonymousClass14S> LIZ2 = r7.LIZ();
                if (LIZ2 != null) {
                    for (AnonymousClass14S next : LIZ2) {
                        if (slotBizTypeDisallow == null || slotBizTypeDisallow.getIconSlotDisallowList() == null || !slotBizTypeDisallow.getIconSlotDisallowList().contains(next.name())) {
                            LIZ.LIZ.LIZJ.put(next, r7);
                        }
                    }
                    return;
                }
                return;
            }
            return;
        }
        throw new IllegalArgumentException("SlotWidgetProvider must return valid bizType");
    }

    public void registerSlot(C267814y r8) {
        C13960hO LIZ = C13960hO.LIZ();
        String LIZJ = r8.LIZJ();
        if (!TextUtils.isEmpty(LIZJ)) {
            SlotBizTypeDisallow slotBizTypeDisallow = (SlotBizTypeDisallow) LiveSlotExperiment.INSTANCE.getBizTypeDisallow().get(LIZJ);
            if (slotBizTypeDisallow == null || !slotBizTypeDisallow.getDisallowAll()) {
                C13950hN r0 = LIZ.LIZ;
                r0.LIZLLL.put(r8.LIZJ(), r8);
                List<AnonymousClass14S> LIZ2 = r8.LIZ();
                if (LIZ2 != null) {
                    for (AnonymousClass14S next : LIZ2) {
                        if (slotBizTypeDisallow == null || slotBizTypeDisallow.getIconSlotDisallowList() == null || !slotBizTypeDisallow.getIconSlotDisallowList().contains(next.name())) {
                            C13950hN r2 = LIZ.LIZ;
                            List list = r2.LIZ.get(next);
                            if (list == null) {
                                list = new ArrayList();
                                r2.LIZ.put(next, list);
                            }
                            list.add(r8);
                        }
                    }
                }
                List<AnonymousClass14O> LIZIZ = r8.LIZIZ();
                if (LIZIZ != null) {
                    for (AnonymousClass14O next2 : LIZIZ) {
                        if (slotBizTypeDisallow == null || slotBizTypeDisallow.getFrameSlotDisallowList() == null || !slotBizTypeDisallow.getFrameSlotDisallowList().contains(next2.name())) {
                            C13950hN r22 = LIZ.LIZ;
                            List list2 = r22.LIZIZ.get(next2);
                            if (list2 == null) {
                                list2 = new ArrayList();
                                r22.LIZIZ.put(next2, list2);
                            }
                            list2.add(r8);
                        }
                    }
                    return;
                }
                return;
            }
            return;
        }
        throw new IllegalArgumentException("SlotWidgetProvider must return valid bizType");
    }

    public List<JRW> getLiveShareSheetAction(Map<String, Object> map, AnonymousClass14S r8) {
        C38131fH r0;
        ArrayList arrayList = new ArrayList();
        List<C265814e> LIZ = C13960hO.LIZ().LIZ(r8);
        if (LIZ == null) {
            return arrayList;
        }
        for (C265814e next : LIZ) {
            List list = null;
            if (next.LIZIZ instanceof C38131fH) {
                r0 = (C38131fH) next.LIZIZ;
            } else {
                r0 = null;
            }
            if (r0 != null) {
                try {
                    list = (List) r0.LIZ(map, r8).get("param_live_broadcast_share_sheet_list");
                } catch (Exception unused) {
                    C09630aP.LIZ(4, "TAG", "getLiveShareSheetAction responseParams get param_live_broadcast_share_sheet_list, error");
                }
                if (list != null && list.size() > 0) {
                    arrayList.addAll(list);
                }
            }
        }
        return arrayList;
    }

    public C38221fQ createIconSlotController(C39401hK r2, AnonymousClass14R r3, AnonymousClass14S r4, AnonymousClass14T r5) {
        return new IconSlotController(r2, r3, r4, r5);
    }
}
