package com.bytedance.android.livesdk.chatroom.viewmodule;

import X.0CB;
import X.0CH;
import X.0b0;
import X.0co;
import X.0ft;
import X.0yx;
import X.158;
import X.293;
import X.294;
import X.295;
import X.29F;
import X.29H;
import X.29w;
import X.2AL;
import X.2Ak;
import X.2Cn;
import X.2cN;
import X.6Is;
import X.7vl;
import X.878;
import X.C1059Fv2;
import X.C1064Fv7;
import X.C1184Fx3;
import X.C1313Fz8;
import X.C2388GbN;
import X.C2389GbO;
import X.C2393GbS;
import X.C2394GbT;
import X.C2429Gc2;
import X.C2527Gdc;
import X.C2528Gdd;
import X.C2529Gde;
import X.C2550Gdz;
import X.C2552Ge1;
import X.C2553Ge2;
import X.C2554Ge3;
import X.C2559Ge8;
import X.C2573GeM;
import X.C2575GeO;
import X.C2577GeQ;
import X.C2578GeR;
import X.C2580GeT;
import X.C2582GeV;
import X.C2583GeW;
import X.C2584GeX;
import X.C2585GeY;
import X.C2586GeZ;
import X.C2587Gea;
import X.C2588Geb;
import X.C2589Gec;
import X.C2593Geg;
import X.C2596Gej;
import X.C2597Gek;
import X.C2598Gel;
import X.C2599Gem;
import X.C2601Geo;
import X.C2604Ger;
import X.C2607Geu;
import X.C2615Gf2;
import X.C2617Gf4;
import X.C2618Gf5;
import X.C2624GfB;
import X.C2646GfX;
import X.C2675Gg0;
import X.C3028Glh;
import X.C3491GtA;
import X.C4100H7d;
import X.C4366HHj;
import X.C5112HeD;
import X.C6455Hzs;
import X.Crj;
import X.CwZ;
import X.Cwu;
import X.G97;
import X.GRE;
import X.LWw;
import X.LWx;
import X.LeS;
import X.Lea;
import X.M12;
import X.Mk2;
import X.Mk3;
import X.PgU;
import android.os.Build;
import android.os.SystemClock;
import android.view.View;
import android.view.ViewGroup;
import com.bytedance.android.live.base.model.ImageModel;
import com.bytedance.android.live.base.model.user.User;
import com.bytedance.android.livesdk.chatroom.api.DecorationApi;
import com.bytedance.android.livesdk.livesetting.decoration.StickerAnchorEnableSettingNew;
import com.bytedance.android.livesdk.livesetting.decoration.StickerAudienceEnableSetting;
import com.bytedance.android.livesdk.model.RoomDecoration;
import com.bytedance.android.livesdk.model.RoomSticker;
import com.bytedance.android.livesdkapi.depend.model.live.Room;
import com.bytedance.covode.number.Covode;
import com.bytedance.frameworks.apm.trace.MethodCollector;
import com.bytedance.ies.sdk.datachannel.DataChannel;
import com.bytedance.ies.sdk.widgets.LiveWidget;
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.NoSuchElementException;
import java.util.concurrent.TimeUnit;
import kotlin.h.b.n;
import kotlin.o.y;
import org.json.JSONArray;
import org.json.JSONObject;

public final class DecorationWrapperWidget extends LiveWidget implements C2596Gej, C2624GfB, 6Is {
    public static boolean LJIIJJI;
    public static boolean LJIIL;
    public static final C2604Ger LJIILIIL = new C2604Ger((byte) 0);
    public boolean LIZ;
    public boolean LIZIZ;
    public boolean LIZJ;
    public boolean LIZLLL;
    public int[] LJ = new int[4];
    public int[] LJFF = new int[4];
    public final List<C2617Gf4<?>> LJI = new ArrayList();
    public boolean LJII;
    public Room LJIIIIZZ;
    public boolean LJIIIZ;
    public C2585GeY LJIIJ;
    public C2582GeV LJIILJJIL;
    public boolean LJIILL;
    public long LJIILLIIL = -1;
    public 2cN LJIIZILJ;
    public 2cN LJIJ;
    public final Crj LJIJI = 7vl.LIZ(new C2528Gdd(this));

    static {
        Covode.recordClassIndex(14518);
    }

    public final void LIZ(Throwable th) {
        C2429Gc2.LIZ(this, th);
    }

    public final C2527Gdc LIZIZ() {
        return (C2527Gdc) this.LJIJI.getValue();
    }

    public final int getLayoutId() {
        return 2131562171;
    }

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

    public final void LIZ(boolean z) {
        DataChannel dataChannel = this.dataChannel;
        if (dataChannel != null) {
            dataChannel.LIZJ(C2607Geu.class, Boolean.valueOf(z));
        }
    }

    public final String LJIIL() {
        return getClass().getName();
    }

    public final void LIZ() {
        if (isViewValid() && !this.LJII) {
            LIZLLL();
        }
    }

    public final void onPause() {
        MethodCollector.i(16360);
        super.onPause();
        boolean LIZ2 = n.LIZ(Build.BRAND, "HUAWEI");
        if (this.LJII || !LIZ2) {
            MethodCollector.o(16360);
            return;
        }
        if (this.LJIILL) {
            this.LJIILL = false;
        }
        ViewGroup viewGroup = (ViewGroup) getView();
        if (viewGroup != null) {
            viewGroup.removeAllViews();
            MethodCollector.o(16360);
            return;
        }
        MethodCollector.o(16360);
    }

    /* JADX WARNING: type inference failed for: r4v1, types: [X.Gf4, android.view.View] */
    private final void LIZJ() {
        MethodCollector.i(16794);
        if (!isViewValid() || this.LJI.isEmpty() || getView() == null) {
            MethodCollector.o(16794);
            return;
        }
        Iterator<C2617Gf4<?>> it = this.LJI.iterator();
        while (it.hasNext()) {
            ? next = it.next();
            if (next.getType() == 3) {
                View view = getView();
                RoomDecoration roomDecoration = null;
                if (!(view instanceof ViewGroup)) {
                    view = null;
                }
                ViewGroup viewGroup = (ViewGroup) view;
                if (viewGroup != null) {
                    viewGroup.removeView(next);
                }
                it.remove();
                C2675Gg0 LIZ2 = C2675Gg0.LIZ();
                if (next instanceof C2618Gf5) {
                    roomDecoration = (RoomDecoration) next.getRoomDecoration();
                }
                LIZ2.LIZ((Object) new G97(roomDecoration, false));
            }
        }
        MethodCollector.o(16794);
    }

    /* JADX WARNING: type inference failed for: r2v1, types: [X.Gf4, android.view.View] */
    private final void LIZLLL() {
        MethodCollector.i(16795);
        if (!isViewValid() || this.LJI.isEmpty() || getView() == null) {
            MethodCollector.o(16795);
            return;
        }
        Iterator<C2617Gf4<?>> it = this.LJI.iterator();
        while (it.hasNext()) {
            ? next = it.next();
            if (next.getType() == 4 || next.getType() == 5 || next.getType() == 6) {
                View view = getView();
                if (!(view instanceof ViewGroup)) {
                    view = null;
                }
                ViewGroup viewGroup = (ViewGroup) view;
                if (viewGroup != null) {
                    viewGroup.removeView(next);
                }
                it.remove();
            }
        }
        MethodCollector.o(16795);
    }

    public final void onResume() {
        List<RoomSticker> roomStickerList;
        List<RoomDecoration> decorationList;
        super.onResume();
        boolean LIZ2 = n.LIZ(Build.BRAND, "HUAWEI");
        if (!this.LJII && LIZ2 && !this.LJIILL) {
            Room room = this.LJIIIIZZ;
            if (!(room == null || (decorationList = room.getDecorationList()) == null || !(!decorationList.isEmpty()))) {
                LIZIZ((List<RoomDecoration>) LeS.LIZLLL(new RoomDecoration[]{decorationList.get(0)}));
            }
            Room room2 = this.LJIIIIZZ;
            if (room2 != null && (roomStickerList = room2.getRoomStickerList()) != null && (!roomStickerList.isEmpty())) {
                LIZJ((List<RoomSticker>) LeS.LIZLLL(new RoomSticker[]{roomStickerList.get(0)}));
            }
        }
    }

    public final void onDestroy() {
        String str;
        List<RoomSticker> roomStickerList;
        super.onDestroy();
        this.LJIIIZ = false;
        DataChannel dataChannel = this.dataChannel;
        if (dataChannel != null) {
            dataChannel.LIZIZ((Object) this);
        }
        C2582GeV geV = this.LJIILJJIL;
        if (geV != null) {
            geV.f_();
        }
        this.LJIILLIIL = -1;
        LJIIJJI = false;
        LJIIL = false;
        LIZ(this.LJIIZILJ);
        LIZ(this.LJIJ);
        if (this.LJII) {
            Room room = this.LJIIIIZZ;
            if (!(room == null || (roomStickerList = room.getRoomStickerList()) == null || !(!roomStickerList.isEmpty()))) {
                RoomSticker roomSticker = (RoomSticker) Lea.LJIIIIZZ(roomStickerList);
                C2578GeR.LIZIZ.LIZ(this.dataChannel, roomSticker, Boolean.valueOf(!C2575GeO.LJ.LIZ(roomSticker, LJ(roomSticker))));
                C2578GeR.LIZ = 0;
            }
            DataChannel dataChannel2 = this.dataChannel;
            boolean z = this.LIZIZ;
            boolean z2 = this.LIZ;
            boolean z3 = this.LIZLLL;
            boolean z4 = this.LIZJ;
            String str2 = "use";
            if (z) {
                C3491GtA LIZ2 = C3491GtA.LJFF.LIZ("livesdk_live_character_prop_use");
                if (z3) {
                    str = str2;
                } else {
                    str = "unused";
                }
                LIZ2.LIZ("use_status", str);
                LIZ2.LJ("live_take_detail");
                LIZ2.LIZLLL("other");
                LIZ2.LIZJ("live_take");
                LIZ2.LIZ(dataChannel2);
                LIZ2.LIZLLL();
            }
            if (z2) {
                C3491GtA LIZ3 = C3491GtA.LJFF.LIZ("livesdk_live_picture_prop_use");
                if (!z4) {
                    str2 = "unused";
                }
                LIZ3.LIZ("use_status", str2);
                LIZ3.LJ("live_take_detail");
                LIZ3.LIZLLL("other");
                LIZ3.LIZJ("live_take");
                LIZ3.LIZ(dataChannel2);
                LIZ3.LIZLLL();
            }
        }
        C2584GeX.LIZLLL = -1;
        C2584GeX.LJ = -1;
        C2584GeX.LIZIZ = -1;
        C2584GeX.LIZJ = -1;
        158.STICKER_DONATION.unload(this.dataChannel);
    }

    public final void onCreate() {
        C2582GeV geV;
        List<RoomDecoration> list;
        Long l;
        Long l2;
        List<RoomSticker> list2;
        DataChannel dataChannel;
        C2585GeY geY;
        List<RoomSticker> roomStickerList;
        List<RoomSticker> roomStickerList2;
        User owner;
        List<RoomDecoration> decorationList;
        super.onCreate();
        if (isViewValid() && this.context != null) {
            int[] iArr = this.LJ;
            iArr[0] = 0;
            iArr[1] = C5112HeD.LIZIZ(this.context) - 0b0.LIZLLL(2131166258);
            0b0.LIZLLL(2131166184);
            C5112HeD.LIZIZ(this.context, 10.0f);
            0b0.LIZLLL(2131166030);
            int[] iArr2 = this.LJ;
            iArr2[2] = 0;
            iArr2[3] = C5112HeD.LIZ(this.context);
            int[] iArr3 = this.LJ;
            int[] copyOf = Arrays.copyOf(iArr3, iArr3.length);
            n.LIZIZ(copyOf, "");
            this.LJFF = copyOf;
        }
        this.LJIIIZ = false;
        this.LJII = n.LIZ(this.dataChannel.LIZIZ(C1059Fv2.class), true);
        Room room = (Room) this.dataChannel.LIZIZ(C1064Fv7.class);
        this.LJIIIIZZ = room;
        if (room != null) {
            geV = new C2582GeV(room.getId());
        } else {
            geV = null;
        }
        this.LJIILJJIL = geV;
        if (geV != null) {
            geV.LIZ((C2596Gej) this);
        }
        this.LJIIJ = new C2585GeY(this.LJII);
        158.STICKER_DONATION.load(this.dataChannel, LIZIZ());
        DataChannel dataChannel2 = this.dataChannel;
        if (dataChannel2 != null) {
            dataChannel2.LIZIZ((0CH) this, 29F.class, C2573GeM.LIZ);
        }
        DataChannel dataChannel3 = this.dataChannel;
        if (dataChannel3 != null) {
            dataChannel3.LIZIZ((0CH) this, 29H.class, C2393GbS.LIZ);
        }
        Room room2 = this.LJIIIIZZ;
        if (room2 != null) {
            list = room2.getDecorationList();
        } else {
            list = null;
        }
        if (!878.LIZ(list)) {
            ArrayList arrayList = new ArrayList();
            Room room3 = this.LJIIIIZZ;
            if (room3 == null || (decorationList = room3.getDecorationList()) == null) {
                LIZIZ((List<RoomDecoration>) arrayList);
                this.LJIILL = true;
            } else {
                for (RoomDecoration roomDecoration : decorationList) {
                    ImageModel imageModel = roomDecoration.LIZ;
                    int i = roomDecoration.LIZIZ;
                    int[] iArr4 = roomDecoration.LIZJ;
                    int i2 = roomDecoration.LIZLLL;
                    int i3 = i2;
                    RoomDecoration roomDecoration2 = new RoomDecoration(imageModel, i, iArr4, i3, roomDecoration.LJ, roomDecoration.LJFF);
                    roomDecoration2.LJIIL = roomDecoration.LJIIL;
                    roomDecoration2.LJIIJJI = roomDecoration.LJIIJJI;
                    roomDecoration2.LJIILIIL = roomDecoration.LJIILIIL;
                    roomDecoration2.LJIILJJIL = roomDecoration.LJIILJJIL;
                    roomDecoration2.LJIILL = roomDecoration.LJIILL;
                    roomDecoration2.LJIILLIIL = roomDecoration.LJIILLIIL;
                    roomDecoration2.LJIIZILJ = roomDecoration.LJIIZILJ;
                    roomDecoration2.LJIJ = roomDecoration.LJIJ;
                    roomDecoration2.LJIJI = roomDecoration.LJIJI;
                    roomDecoration2.LJIJJ = roomDecoration.LJIJJ;
                    if (arrayList.add(roomDecoration2)) {
                        LIZIZ((List<RoomDecoration>) arrayList);
                        this.LJIILL = true;
                    }
                }
                throw new NoSuchElementException("Collection contains no element matching the predicate.");
            }
        }
        Cwu[] cwuArr = new Cwu[4];
        C3028Glh LIZIZ2 = C4100H7d.LIZ().LIZIZ();
        n.LIZIZ(LIZIZ2, "");
        cwuArr[0] = CwZ.LIZ("user_id", Long.valueOf(LIZIZ2.LIZJ()));
        Room room4 = this.LJIIIIZZ;
        if (room4 != null) {
            l = Long.valueOf(room4.getId());
        } else {
            l = null;
        }
        cwuArr[1] = CwZ.LIZ("room_id", l);
        Room room5 = this.LJIIIIZZ;
        if (room5 == null || (owner = room5.getOwner()) == null) {
            l2 = null;
        } else {
            l2 = Long.valueOf(owner.getId());
        }
        cwuArr[2] = CwZ.LIZ("anchor_id", l2);
        cwuArr[3] = CwZ.LIZ("user_type", Integer.valueOf(this.LJII ? 1 : 0));
        Map LIZ2 = LWw.LIZ(cwuArr);
        M12.LIZ(LIZ2);
        C2584GeX.LIZ.clear();
        C2584GeX.LIZ.putAll(LIZ2);
        Room room6 = this.LJIIIIZZ;
        if (room6 != null) {
            list2 = room6.getRoomStickerList();
        } else {
            list2 = null;
        }
        if (!878.LIZ(list2)) {
            ArrayList arrayList2 = new ArrayList();
            Room room7 = this.LJIIIIZZ;
            if (!(room7 == null || (roomStickerList2 = room7.getRoomStickerList()) == null)) {
                for (RoomSticker roomSticker : roomStickerList2) {
                    roomSticker.LIZ = true;
                }
            }
            Room room8 = this.LJIIIIZZ;
            if (room8 == null || (roomStickerList = room8.getRoomStickerList()) == null) {
                if (this.LJII && (geY = this.LJIIJ) != null) {
                    geY.LIZ(arrayList2, 1);
                }
                if ((!this.LJII && StickerAudienceEnableSetting.INSTANCE.getValue() == 1) || (this.LJII && StickerAnchorEnableSettingNew.INSTANCE.getValue() == 3)) {
                    LIZJ((List<RoomSticker>) arrayList2);
                    this.LJIILL = true;
                }
            } else {
                for (RoomSticker roomSticker2 : roomStickerList) {
                    RoomSticker LIZ3 = RoomSticker.LIZ(roomSticker2);
                    LIZ3.LJIIL = roomSticker2.LJIIL;
                    LIZ3.LJIIJJI = roomSticker2.LJIIJJI;
                    LIZ3.LJIILIIL = roomSticker2.LJIILIIL;
                    LIZ3.LJIILJJIL = roomSticker2.LJIILJJIL;
                    LIZ3.LJIILL = roomSticker2.LJIILL;
                    LIZ3.LJIILLIIL = roomSticker2.LJIILLIIL;
                    LIZ3.LJIIZILJ = roomSticker2.LJIIZILJ;
                    LIZ3.LJIJ = roomSticker2.LJIJ;
                    LIZ3.LJIJI = roomSticker2.LJIJI;
                    LIZ3.LJIJJ = roomSticker2.LJIJJ;
                    if (arrayList2.add(LIZ3)) {
                        geY.LIZ(arrayList2, 1);
                        LIZJ((List<RoomSticker>) arrayList2);
                        this.LJIILL = true;
                    }
                }
                throw new NoSuchElementException("Collection contains no element matching the predicate.");
            }
        }
        C4366HHj<C2577GeQ> LIZ4 = C2675Gg0.LIZ().LIZ(this, C2577GeQ.class);
        DecorationWrapperWidget decorationWrapperWidget = this;
        LIZ4.LIZ(new C2601Geo(new C2580GeT(decorationWrapperWidget)));
        C2675Gg0.LIZ().LIZ(decorationWrapperWidget, C2550Gdz.class).LIZ(new C2601Geo(new C2646GfX(decorationWrapperWidget)));
        C2675Gg0.LIZ().LIZ(decorationWrapperWidget, 0co.class).LIZ(new C2601Geo(new C2389GbO(decorationWrapperWidget)));
        DataChannel dataChannel4 = decorationWrapperWidget.dataChannel;
        dataChannel4.LIZ((Object) decorationWrapperWidget, 2Ak.class, new C2552Ge1(decorationWrapperWidget));
        dataChannel4.LIZIZ((0CH) decorationWrapperWidget, C2554Ge3.class, new C2553Ge2(decorationWrapperWidget));
        dataChannel4.LIZ((0CH) decorationWrapperWidget, 293.class, new C2559Ge8(decorationWrapperWidget));
        dataChannel4.LIZ((0CH) decorationWrapperWidget, 295.class, new C2593Geg(decorationWrapperWidget));
        dataChannel4.LIZ((0CH) decorationWrapperWidget, 29w.class, new C2394GbT(decorationWrapperWidget));
        dataChannel4.LIZ((0CH) decorationWrapperWidget, 2AL.class, new C2388GbN(decorationWrapperWidget));
        if (decorationWrapperWidget.LJII && (dataChannel = decorationWrapperWidget.dataChannel) != null) {
            dataChannel.LIZIZ((0CH) decorationWrapperWidget, 2Cn.class, new C2529Gde(decorationWrapperWidget));
        }
    }

    private final void LIZ(2cN r2) {
        if (r2 != null && !r2.isDisposed()) {
            r2.dispose();
        }
    }

    private void LIZIZ(List<RoomDecoration> list) {
        View view;
        if (list != null && (view = getView()) != null) {
            view.post(new C2597Gek(this, list));
        }
    }

    private void LIZJ(List<RoomSticker> list) {
        View view;
        if (list != null && (view = getView()) != null) {
            view.post(new C2587Gea(this, list));
        }
    }

    private final String LJ(RoomSticker roomSticker) {
        T t;
        if (roomSticker == null) {
            return null;
        }
        Iterator<T> it = this.LJI.iterator();
        while (true) {
            if (!it.hasNext()) {
                t = null;
                break;
            }
            t = it.next();
            if (((C2617Gf4) t).LJFF.LJIIL == roomSticker.LJIIL) {
                break;
            }
        }
        C2617Gf4 gf4 = (C2617Gf4) t;
        if (gf4 == null || !(gf4 instanceof C2615Gf2) || gf4.LJFF.LJIILIIL != 4) {
            return null;
        }
        return ((C2615Gf2) gf4).getContent();
    }

    public final void LIZ(String str) {
        if (isViewValid() && str != null) {
            C1313Fz8.LIZ(this.context, str, 0);
        }
    }

    public final void LIZIZ(RoomSticker roomSticker) {
        C2617Gf4 gf4 = (C2617Gf4) Lea.LJIIIIZZ(this.LJI);
        if ((gf4 instanceof C2615Gf2) && gf4.getType() == 4 && roomSticker != null && C2575GeO.LJ.LIZIZ(Long.valueOf(roomSticker.LJIIL))) {
            ((C2615Gf2) gf4).LIZJ(roomSticker.LJIIIZ);
        }
    }

    public final void LIZLLL(RoomSticker roomSticker) {
        2cN r0;
        if (roomSticker != null) {
            if (roomSticker.LJIILIIL == 4) {
                r0 = this.LJIIZILJ;
            } else {
                r0 = this.LJIJ;
            }
            LIZ(r0);
            2cN LIZLLL2 = PgU.LIZIZ(30, TimeUnit.SECONDS).LIZIZ(Mk2.LIZ(Mk3.LIZ)).LIZLLL(new C2583GeW(this, roomSticker));
            int i = roomSticker.LJIILIIL;
            if (i == 4) {
                this.LJIIZILJ = LIZLLL2;
            } else if (i == 5 || i == 6) {
                this.LJIJ = LIZLLL2;
            }
        }
    }

    /* JADX WARNING: type inference failed for: r7v0, types: [android.view.View, java.lang.Object, X.Gf5] */
    /*  JADX ERROR: JadxRuntimeException in pass: CodeShrinkVisitor
        jadx.core.utils.exceptions.JadxRuntimeException: Don't wrap MOVE or CONST insns: 0x000b: MOVE  (r9v0 com.bytedance.android.livesdk.model.RoomDecoration) = (r15v0 com.bytedance.android.livesdk.model.RoomDecoration)
        	at jadx.core.dex.instructions.args.InsnArg.wrapArg(InsnArg.java:164)
        	at jadx.core.dex.visitors.shrink.CodeShrinkVisitor.assignInline(CodeShrinkVisitor.java:133)
        	at jadx.core.dex.visitors.shrink.CodeShrinkVisitor.checkInline(CodeShrinkVisitor.java:118)
        	at jadx.core.dex.visitors.shrink.CodeShrinkVisitor.shrinkBlock(CodeShrinkVisitor.java:65)
        	at jadx.core.dex.visitors.shrink.CodeShrinkVisitor.shrinkMethod(CodeShrinkVisitor.java:43)
        	at jadx.core.dex.visitors.shrink.CodeShrinkVisitor.visit(CodeShrinkVisitor.java:35)
        */
    public final void LIZ(com.bytedance.android.livesdk.model.RoomDecoration r15) {
        /*
            r14 = this;
            r6 = 16643(0x4103, float:2.3322E-41)
            com.bytedance.frameworks.apm.trace.MethodCollector.i(r6)
            boolean r0 = r14.isViewValid()
            if (r0 == 0) goto L_0x000e
            r9 = r15
            if (r9 != 0) goto L_0x0012
        L_0x000e:
            com.bytedance.frameworks.apm.trace.MethodCollector.o(r6)
            return
        L_0x0012:
            r14.LIZJ()
            X.Gf5 r7 = new X.Gf5
            android.content.Context r8 = r14.context
            boolean r10 = r14.LJII
            int[] r11 = r14.LJ
            r12 = r14
            boolean r13 = r14.LJIIIZ
            r7.<init>(r8, r9, r10, r11, r12, r13)
            X.Gg0 r1 = X.C2675Gg0.LIZ()
            X.G97 r0 = new X.G97
            r3 = 1
            r0.<init>(r9, r3)
            r1.LIZ((java.lang.Object) r0)
            long r4 = r14.LJIILLIIL
            r1 = -1
            int r0 = (r4 > r1 ? 1 : (r4 == r1 ? 0 : -1))
            if (r0 == 0) goto L_0x003e
            long r0 = r9.LJIIL
            int r2 = (r4 > r0 ? 1 : (r4 == r0 ? 0 : -1))
            if (r2 == 0) goto L_0x0054
        L_0x003e:
            com.bytedance.android.livesdk.model.OrganizationModel r4 = r9.LIZ()
            X.GeR r2 = X.C2578GeR.LIZIZ
            com.bytedance.ies.sdk.datachannel.DataChannel r1 = r14.dataChannel
            java.lang.String r0 = "top_left_icon"
            r2.LIZ((com.bytedance.ies.sdk.datachannel.DataChannel) r1, (java.lang.String) r0, (com.bytedance.android.livesdk.model.OrganizationModel) r4)
            X.GeR r2 = X.C2578GeR.LIZIZ
            com.bytedance.ies.sdk.datachannel.DataChannel r1 = r14.dataChannel
            java.lang.String r0 = "donation_sticker"
            r2.LIZ((com.bytedance.ies.sdk.datachannel.DataChannel) r1, (java.lang.String) r0, (com.bytedance.android.livesdk.model.OrganizationModel) r4)
        L_0x0054:
            long r0 = r9.LJIIL
            r14.LJIILLIIL = r0
            java.util.List<X.Gf4<?>> r0 = r14.LJI
            r0.add(r7)
            android.view.View r2 = r14.getView()
            boolean r0 = r2 instanceof android.view.ViewGroup
            if (r0 == 0) goto L_0x0070
            android.view.ViewGroup r2 = (android.view.ViewGroup) r2
            android.view.ViewGroup$LayoutParams r1 = new android.view.ViewGroup$LayoutParams
            r0 = -1
            r1.<init>(r0, r0)
            r2.addView(r7, r1)
        L_0x0070:
            boolean r0 = r14.LJII
            if (r0 == 0) goto L_0x0076
            LJIIJJI = r3
        L_0x0076:
            com.bytedance.frameworks.apm.trace.MethodCollector.o(r6)
            return
        */
        throw new UnsupportedOperationException("Method not decompiled: com.bytedance.android.livesdk.chatroom.viewmodule.DecorationWrapperWidget.LIZ(com.bytedance.android.livesdk.model.RoomDecoration):void");
    }

    public final void LIZIZ(RoomDecoration roomDecoration) {
        M12.LIZ(roomDecoration);
        if (isViewValid() && this.LJII && roomDecoration.LJIILIIL == 3) {
            for (C2617Gf4 gf4 : this.LJI) {
                if (gf4.getType() == 3) {
                    JSONArray jSONArray = new JSONArray();
                    JSONObject decorationInfo = gf4.getDecorationInfo();
                    if (decorationInfo != null) {
                        jSONArray.put(decorationInfo);
                        GRE gre = new GRE();
                        gre.LIZ("deco_list", jSONArray.toString());
                        n.LIZIZ(gre, "");
                        HashMap<String, String> hashMap = gre.LIZ;
                        C2582GeV geV = this.LJIILJJIL;
                        if (geV != null) {
                            n.LIZIZ(hashMap, "");
                            geV.LIZ(hashMap, gf4.getType());
                            return;
                        }
                        return;
                    }
                    return;
                }
            }
            throw new NoSuchElementException("Collection contains no element matching the predicate.");
        }
    }

    public final void LIZ(RoomSticker roomSticker) {
        Object obj;
        if (isViewValid() && !this.LJII && roomSticker != null) {
            Room room = this.LJIIIIZZ;
            if (room != null) {
                room.setRoomStickerList(LeS.LIZJ(new RoomSticker[]{roomSticker}));
            }
            DataChannel dataChannel = this.dataChannel;
            if (dataChannel != null) {
                obj = dataChannel.LIZIZ(C1184Fx3.class);
            } else {
                obj = null;
            }
            if (!n.LIZ(obj, true)) {
                RoomSticker LIZ2 = RoomSticker.LIZ(roomSticker);
                LIZ2.LJIIL = roomSticker.LJIIL;
                LIZ2.LJIIJJI = roomSticker.LJIIJJI;
                LIZ2.LJIILIIL = roomSticker.LJIILIIL;
                LIZ2.LJIILJJIL = roomSticker.LJIILJJIL;
                LIZ2.LJIILL = roomSticker.LJIILL;
                LIZ2.LJIILLIIL = roomSticker.LJIILLIIL;
                LIZ2.LJIIZILJ = roomSticker.LJIIZILJ;
                LIZ2.LJIJ = roomSticker.LJIJ;
                LIZ2.LJIJI = roomSticker.LJIJI;
                LIZ2.LJIJJ = roomSticker.LJIJJ;
                LIZJ(LIZ2);
                if (!this.LJII) {
                    C2578GeR.LIZIZ.LIZ(this.dataChannel, LIZ2);
                }
            }
        }
    }

    /* JADX WARNING: type inference failed for: r4v0, types: [X.Gf2, android.view.View, java.lang.Object] */
    /*  JADX ERROR: JadxRuntimeException in pass: CodeShrinkVisitor
        jadx.core.utils.exceptions.JadxRuntimeException: Don't wrap MOVE or CONST insns: 0x000b: MOVE  (r6v0 com.bytedance.android.livesdk.model.RoomSticker) = (r14v0 com.bytedance.android.livesdk.model.RoomSticker)
        	at jadx.core.dex.instructions.args.InsnArg.wrapArg(InsnArg.java:164)
        	at jadx.core.dex.visitors.shrink.CodeShrinkVisitor.assignInline(CodeShrinkVisitor.java:133)
        	at jadx.core.dex.visitors.shrink.CodeShrinkVisitor.checkInline(CodeShrinkVisitor.java:118)
        	at jadx.core.dex.visitors.shrink.CodeShrinkVisitor.shrinkBlock(CodeShrinkVisitor.java:65)
        	at jadx.core.dex.visitors.shrink.CodeShrinkVisitor.shrinkMethod(CodeShrinkVisitor.java:43)
        	at jadx.core.dex.visitors.shrink.CodeShrinkVisitor.visit(CodeShrinkVisitor.java:35)
        */
    public final void LIZJ(com.bytedance.android.livesdk.model.RoomSticker r14) {
        /*
            r13 = this;
            r3 = 16487(0x4067, float:2.3103E-41)
            com.bytedance.frameworks.apm.trace.MethodCollector.i(r3)
            boolean r0 = r13.isViewValid()
            if (r0 == 0) goto L_0x000e
            r6 = r14
            if (r6 != 0) goto L_0x0012
        L_0x000e:
            com.bytedance.frameworks.apm.trace.MethodCollector.o(r3)
            return
        L_0x0012:
            r13.LIZLLL()
            X.Gf2 r4 = new X.Gf2
            android.content.Context r5 = r13.context
            java.lang.String r0 = ""
            kotlin.h.b.n.LIZIZ(r5, r0)
            boolean r7 = r13.LJII
            int[] r8 = r13.LJ
            r9 = r13
            boolean r10 = r13.LJIIIZ
            X.GeY r11 = r13.LJIIJ
            com.bytedance.ies.sdk.datachannel.DataChannel r12 = r13.dataChannel
            r4.<init>(r5, r6, r7, r8, r9, r10, r11, r12)
            java.util.List<X.Gf4<?>> r0 = r13.LJI
            r0.add(r4)
            android.view.View r2 = r13.getView()
            boolean r0 = r2 instanceof android.view.ViewGroup
            if (r0 == 0) goto L_0x0044
            android.view.ViewGroup r2 = (android.view.ViewGroup) r2
            android.view.ViewGroup$LayoutParams r1 = new android.view.ViewGroup$LayoutParams
            r0 = -1
            r1.<init>(r0, r0)
            r2.addView(r4, r1)
        L_0x0044:
            com.bytedance.frameworks.apm.trace.MethodCollector.o(r3)
            return
        */
        throw new UnsupportedOperationException("Method not decompiled: com.bytedance.android.livesdk.chatroom.viewmodule.DecorationWrapperWidget.LIZJ(com.bytedance.android.livesdk.model.RoomSticker):void");
    }

    public final void LIZ(C2588Geb geb) {
        2cN r0;
        boolean z;
        boolean z2;
        M12.LIZ(geb);
        if (isViewValid()) {
            boolean z3 = false;
            if (geb.LJIILIIL == 4) {
                r0 = this.LJIIZILJ;
            } else {
                r0 = this.LJIJ;
            }
            LIZ(r0);
            int i = geb.LJIILIIL;
            if (i == 3) {
                LIZJ();
                C2582GeV geV = this.LJIILJJIL;
                if (geV != null) {
                    geV.LIZ(LWx.LIZ(CwZ.LIZ("deco_list", new JSONArray().toString())), 3);
                }
            } else if (i == 4 || i == 5 || i == 6) {
                if (geb instanceof RoomSticker) {
                    RoomSticker roomSticker = (RoomSticker) geb;
                    z = C2575GeO.LJ.LIZ(roomSticker, LJ(roomSticker));
                } else {
                    z = false;
                }
                C2578GeR geR = C2578GeR.LIZIZ;
                DataChannel dataChannel = this.dataChannel;
                RoomSticker roomSticker2 = (RoomSticker) geb;
                Boolean valueOf = Boolean.valueOf(z);
                M12.LIZ(roomSticker2);
                C3491GtA LIZ2 = C3491GtA.LJFF.LIZ("livesdk_live_prop_delete");
                LIZ2.LIZ("is_remember", roomSticker2.LIZ ? 1 : 0);
                LIZ2.LIZ("tab", geR.LIZ(Integer.valueOf(roomSticker2.LJIILIIL)));
                LIZ2.LIZ("prop_id", roomSticker2.LJIIL);
                LIZ2.LIZ("prop_name", roomSticker2.LJIIIIZZ);
                LIZ2.LIZ("resource_id", roomSticker2.LJIIJJI);
                if (roomSticker2.LJIILIIL == 4) {
                    z2 = true;
                } else {
                    z2 = false;
                }
                LIZ2.LIZ("prop_type", "character", z2);
                if (roomSticker2.LJIILIIL == 5 || roomSticker2.LJIILIIL == 6) {
                    z3 = true;
                }
                LIZ2.LIZ("prop_type", "picture", z3);
                LIZ2.LIZ("is_origin_words", n.LIZ(valueOf, true) ^ true ? 1 : 0);
                LIZ2.LIZ(dataChannel);
                LIZ2.LIZLLL();
                C2578GeR.LIZIZ.LIZ(this.dataChannel, roomSticker2, Boolean.valueOf(!z));
                C2578GeR.LIZ = 0;
                LIZLLL();
                C2582GeV geV2 = this.LJIILJJIL;
                if (geV2 != null) {
                    M12.LIZ(roomSticker2);
                    C2584GeX.LIZIZ = SystemClock.elapsedRealtime();
                    ((DecorationApi) 0yx.LIZ().LIZ(DecorationApi.class)).deleteRoomStickers(roomSticker2.LJIIL, geV2.LIZ).LIZ(new C6455Hzs()).LIZ(C2598Gel.LIZ, new C2589Gec(geV2));
                }
                DataChannel dataChannel2 = this.dataChannel;
                if (dataChannel2 != null) {
                    dataChannel2.LIZ(294.class, null);
                }
            }
        }
    }

    public final void LIZ(List<RoomDecoration> list) {
        Object obj;
        if (isViewValid() && !this.LJII && list != null) {
            Room room = this.LJIIIIZZ;
            if (room != null) {
                room.setDecorationList(list);
            }
            DataChannel dataChannel = this.dataChannel;
            if (dataChannel != null) {
                obj = dataChannel.LIZIZ(C1184Fx3.class);
            } else {
                obj = null;
            }
            if (!n.LIZ(obj, true)) {
                LIZJ();
                for (RoomDecoration LIZ2 : list) {
                    LIZ(LIZ2);
                }
            }
        }
    }

    public final void LIZ(RoomSticker roomSticker, String str) {
        C2582GeV geV;
        String str2;
        boolean z;
        int i;
        List list;
        List list2;
        String str3 = str;
        M12.LIZ(roomSticker);
        if (isViewValid() && this.LJII && (geV = this.LJIILJJIL) != null) {
            M12.LIZ(roomSticker);
            ImageModel imageModel = roomSticker.LIZIZ;
            String str4 = null;
            if (imageModel == null || (list2 = imageModel.mUrls) == null) {
                str2 = null;
            } else {
                str2 = (String) list2.get(0);
            }
            String LIZ2 = geV.LIZ(str2);
            ImageModel imageModel2 = roomSticker.LIZJ;
            if (!(imageModel2 == null || (list = imageModel2.mUrls) == null)) {
                str4 = (String) list.get(0);
            }
            String LIZ3 = geV.LIZ(str4);
            if (roomSticker.LJIILIIL != 4 || !C2575GeO.LJ.LIZIZ(Long.valueOf(roomSticker.LJIIL))) {
                str3 = roomSticker.LJIILJJIL;
                z = false;
            } else {
                List<0ft<RoomSticker>> list3 = C2575GeO.LIZ;
                if (list3 != null) {
                    z = C2575GeO.LJ.LIZ(Long.valueOf(roomSticker.LJIIL), str3, list3);
                } else {
                    Boolean bool = roomSticker.LJIIJ;
                    if (bool != null) {
                        z = bool.booleanValue();
                    } else {
                        z = false;
                    }
                }
                if (str3 != null && str3.length() != 0) {
                    n.LIZIZ(str3, "");
                    if (C2575GeO.LJ.LIZIZ(str3) || y.LIZ(str3, " ", "", false).length() == 0) {
                        return;
                    }
                } else {
                    return;
                }
            }
            if (roomSticker.LJIILIIL == 6) {
                i = 5;
            } else {
                i = roomSticker.LJIILIIL;
            }
            Map LIZ4 = LWw.LIZ(new Cwu[]{CwZ.LIZ("room_id", Long.valueOf(geV.LIZ)), CwZ.LIZ("id", Long.valueOf(roomSticker.LJIIL)), CwZ.LIZ("name", roomSticker.LJIIIIZZ), CwZ.LIZ("type", Integer.valueOf(i)), CwZ.LIZ("content", str3), CwZ.LIZ("content_key", roomSticker.LJII), CwZ.LIZ("text_size", Integer.valueOf(roomSticker.LJIILLIIL)), CwZ.LIZ("text_color", roomSticker.LJIILL), CwZ.LIZ("image_uri", LIZ2), CwZ.LIZ("nine_patch_image_uri", LIZ3), CwZ.LIZ("x", Integer.valueOf(roomSticker.LJIIZILJ)), CwZ.LIZ("y", Integer.valueOf(roomSticker.LJIJ)), CwZ.LIZ("w", Integer.valueOf(roomSticker.LJIJI)), CwZ.LIZ("h", Integer.valueOf(roomSticker.LJIJJ)), CwZ.LIZ("top_left_h", Integer.valueOf(roomSticker.LIZLLL)), CwZ.LIZ("top_left_w", Integer.valueOf(roomSticker.LJ)), CwZ.LIZ("bottom_right_h", Integer.valueOf(roomSticker.LJFF)), CwZ.LIZ("bottom_right_w", Integer.valueOf(roomSticker.LJI)), CwZ.LIZ("edited", Boolean.valueOf(z))});
            C2584GeX.LIZJ = SystemClock.elapsedRealtime();
            ((DecorationApi) 0yx.LIZ().LIZ(DecorationApi.class)).setRoomStickers(LIZ4).LIZ(new C6455Hzs()).LIZ(C2599Gem.LIZ, new C2586GeZ(geV, i, str3, LIZ2, LIZ3, z));
        }
    }
}
