package com.ss.android.ugc.aweme.ftc.components.sticker.text;

import X.0Gp;
import X.1Bn;
import X.1Hw;
import X.2HN;
import X.2Pr;
import X.7he;
import X.AnonymousClass5LC;
import X.AnonymousClass5M6;
import X.AnonymousClass6NJ;
import X.AnonymousClass6NK;
import X.AnonymousClass6OF;
import X.AnonymousClass6OU;
import X.AnonymousClass6PR;
import X.AnonymousClass6PU;
import X.C03505Am;
import X.C04875Ft;
import X.C06115Kn;
import X.C11865cm;
import X.C14105gO;
import X.C17855mR;
import X.C23805w2;
import X.C32566Og;
import X.C32576Oh;
import X.C32586Oi;
import X.C32596Oj;
import X.C32606Ok;
import X.C32616Ol;
import X.C32626Om;
import X.C32636On;
import X.C32646Oo;
import X.C32656Op;
import X.C32666Oq;
import X.C32676Or;
import X.C32686Os;
import X.C32696Ot;
import X.C32786Pc;
import X.C32936Pr;
import X.C38056dv;
import X.Crj;
import X.Cwu;
import X.LsC;
import X.LsD;
import X.M12;
import android.graphics.PointF;
import android.graphics.RectF;
import android.view.ViewGroup;
import com.bytedance.covode.number.Covode;
import com.bytedance.ui_component.LifecycleAwareViewModel;
import com.ss.android.ugc.aweme.editSticker.compile.TextStickerCompileResult;
import com.ss.android.ugc.aweme.editSticker.text.bean.TextStickerData;
import com.ss.android.ugc.aweme.editSticker.text.bean.TextStickerTextWrap;
import java.util.ArrayList;
import java.util.List;
import kotlin.h.b.n;

public final class FTCEditTextStickerViewModel extends LifecycleAwareViewModel<FTCEditTextStickerViewState> implements C17855mR, C11865cm {
    public static final AnonymousClass6PR LJI = new AnonymousClass6PR((byte) 0);
    public final List<C32786Pc> LIZ = new ArrayList();
    public boolean LIZIZ = true;
    public boolean LIZJ;
    public final 1Hw<2Pr> LIZLLL = new 1Hw<>();
    public final 1Hw<Cwu<Boolean, Boolean>> LJ = new 1Hw<>();
    public final 1Hw<Boolean> LJFF = new 1Hw<>();
    public 1Bn<Boolean> LJII;
    public final Crj LJIIL = 7he.LIZ(C06115Kn.LIZ);
    public Cwu<Integer, Integer> LJIILIIL;
    public final Crj LJIILJJIL = 7he.LIZ(AnonymousClass6PU.LIZ);

    static {
        Covode.recordClassIndex(82189);
    }

    public final 1Bn<Cwu<Float, Boolean>> LJIILJJIL() {
        return (1Bn) this.LJIIL.getValue();
    }

    public final 1Hw<2Pr> LIZIZ() {
        return this.LIZLLL;
    }

    public final 1Hw<Cwu<Boolean, Boolean>> LIZJ() {
        return this.LJ;
    }

    public final 1Hw<Boolean> LIZLLL() {
        return this.LJFF;
    }

    public final C17855mR LJIIL() {
        return this;
    }

    public final List<C32786Pc> LJIILIIL() {
        return this.LIZ;
    }

    public final void LIZ(boolean z) {
        LIZJ(new C32566Og(z));
        1Bn<Boolean> r2 = this.LJII;
        if (r2 != null && (!n.LIZ(r2.getValue(), Boolean.valueOf(z)))) {
            r2.setValue(Boolean.valueOf(z));
        }
    }

    public final void LIZ(TextStickerData textStickerData) {
        M12.LIZ(textStickerData);
        LIZLLL(new AnonymousClass6OF(textStickerData));
    }

    public final boolean LIZ(RectF rectF) {
        M12.LIZ(rectF);
        for (C32786Pc anglePointList : this.LIZ) {
            PointF[] anglePointList2 = anglePointList.getAnglePointList();
            if (!(anglePointList2 == null || anglePointList2.length == 0)) {
                RectF LIZ2 = C23805w2.LIZ(anglePointList2);
                n.LIZIZ(LIZ2, "");
                if (LIZ2.top < rectF.top || LIZ2.bottom > rectF.bottom) {
                    return true;
                }
            }
        }
        return false;
    }

    public final void LJ() {
        LIZLLL(C32646Oo.LIZ);
    }

    public final void LJI() {
        LIZJ(C32666Oq.LIZ);
    }

    public final void LJII() {
        LIZJ(C32686Os.LIZ);
    }

    public final void LJIIIZ() {
        LIZJ(C32676Or.LIZ);
    }

    public final boolean LJIILLIIL() {
        return this.LIZ.isEmpty();
    }

    public final void LJIIIIZZ() {
        LIZJ(new C32636On());
    }

    public final boolean LJIIJJI() {
        if (!LJIILLIIL()) {
            return true;
        }
        return false;
    }

    public final boolean LJFF() {
        Boolean bool;
        1Bn<Boolean> r0 = this.LJII;
        if (r0 == null || (bool = (Boolean) r0.getValue()) == null) {
            return false;
        }
        return bool.booleanValue();
    }

    public final /* synthetic */ C03505Am dU_() {
        return new FTCEditTextStickerViewState((C04875Ft) null, false, (C14105gO) null, (AnonymousClass5LC) null, (AnonymousClass5M6) null, (AnonymousClass5LC) null, (C14105gO) null, (C14105gO) null, (C14105gO) null, (C14105gO) null, (C14105gO) null, (C14105gO) null, (C14105gO) null, (AnonymousClass5LC) null, (AnonymousClass5LC) null, (AnonymousClass5LC) null, 65535, (2HN) null);
    }

    public final boolean LJIIJ() {
        LIZJ(AnonymousClass6OU.LIZ);
        boolean z = false;
        for (C32786Pc next : this.LIZ) {
            if (next.LJ()) {
                next.setShowHelpBox(false);
                z = true;
            }
        }
        return z;
    }

    public final int LJIILL() {
        if (this.LIZ.isEmpty()) {
            return 0;
        }
        int size = this.LIZ.size();
        int i = 0;
        for (int i2 = 0; i2 < size; i2++) {
            List<TextStickerTextWrap> textWrapList = this.LIZ.get(i2).getTextWrapList();
            n.LIZIZ(textWrapList, "");
            for (TextStickerTextWrap next : textWrapList) {
                if (next != null) {
                    i += next.safeStrPair().LIZIZ.size();
                }
            }
        }
        return i;
    }

    public final void LIZ(1Bn<Boolean> r1) {
        M12.LIZ(r1);
        this.LJII = r1;
    }

    public final void LIZ(AnonymousClass6NJ r2) {
        LIZJ(new C32626Om(r2));
    }

    public final void LIZ(float f) {
        LJIILJJIL().setValue(new Cwu(Float.valueOf(f), false));
    }

    public final void LIZIZ(boolean z) {
        this.LIZIZ = z;
        for (C32786Pc enableEdit : this.LIZ) {
            enableEdit.setEnableEdit(this.LIZIZ);
        }
    }

    public final void LIZ(AnonymousClass6NK r2) {
        LIZJ(new C32606Ok(r2));
    }

    public final void LIZ(C32786Pc r2) {
        M12.LIZ(r2);
        this.LIZ.remove(r2);
    }

    public final void LIZ(C32936Pr r2) {
        LIZJ(new C32596Oj(r2));
    }

    public final void LIZ(Cwu<Integer, Integer> cwu) {
        if (this.LJIILIIL == null) {
            this.LJIILIIL = cwu;
        }
        LIZJ(new C32616Ol(cwu));
    }

    public final void LIZ(LsC<? super C32786Pc, 2Pr> lsC) {
        LIZJ(new C32656Op(lsC));
    }

    public final void LIZ(LsD<? super C32786Pc, ? super C32786Pc, 2Pr> lsD) {
        LIZJ(new C32586Oi(lsD));
    }

    public final 0Gp<List<TextStickerCompileResult>> LIZ(C32696Ot r14, ViewGroup viewGroup) {
        ViewGroup viewGroup2 = viewGroup;
        M12.LIZ(r14, viewGroup2);
        LJIIJ();
        ArrayList arrayList = new ArrayList();
        for (C32786Pc next : this.LIZ) {
            0Gp LIZJ2 = ((C38056dv) this.LJIILJJIL.getValue()).LIZ(next, viewGroup2, r14.LIZ, r14.LIZIZ, r14.LIZJ, r14.LIZLLL, r14.LJ).LIZJ(new C32576Oh(this, arrayList, next, viewGroup2));
            n.LIZIZ(LIZJ2, "");
            arrayList.add(LIZJ2);
        }
        0Gp<List<TextStickerCompileResult>> LIZ2 = 0Gp.LIZ(arrayList);
        n.LIZIZ(LIZ2, "");
        return LIZ2;
    }
}
