package com.ss.android.ugc.aweme.relation.auth.widget.fb;

import X.1hK;
import X.4HR;
import X.4h7;
import X.4r1;
import X.4rR;
import X.9HM;
import X.An2;
import X.AnJ;
import X.C0782DAc;
import X.C0849DCr;
import X.C3064Dzw;
import X.C3999EZv;
import X.C4003EZz;
import X.DAU;
import X.DB2;
import X.DBT;
import X.EZA;
import X.EZM;
import X.EZU;
import X.EZV;
import X.J7F;
import X.JOF;
import X.LeS;
import X.M12;
import com.bytedance.assem.arch.viewModel.AssemViewModel;
import com.bytedance.covode.number.Covode;
import com.ss.android.ugc.aweme.profile.model.User;
import com.ss.android.ugc.aweme.relation.api.IInviteFriendsApi;
import com.ss.android.ugc.aweme.relation.auth.widget.ext.InviteFriendsSharePackageV2;
import java.util.ArrayList;
import java.util.List;

public final class FacebookMaFWidgetVM extends AssemViewModel<EZU> {
    public static final EZM LIZJ = new EZM((byte) 0);
    public final EZA LIZ;
    public final An2 LIZIZ;
    public InviteFriendsSharePackageV2 LIZLLL;
    public 4rR LJ;
    public final DB2 LJFF;

    static {
        Covode.recordClassIndex(102622);
    }

    public final /* synthetic */ 4HR defaultState() {
        return new EZU();
    }

    public final void onCleared() {
        super.onCleared();
        InviteFriendsSharePackageV2 inviteFriendsSharePackageV2 = this.LIZLLL;
        if (inviteFriendsSharePackageV2 != null) {
            inviteFriendsSharePackageV2.LIZIZ.LIZ();
        }
    }

    private final DBT LIZIZ() {
        return C0782DAc.LIZ(getAssemVMScope(), this.LJFF, (DAU) null, new C3999EZv(this, (4r1) null), 2);
    }

    public final void LIZ() {
        if (!(getState().LIZ instanceof 4h7)) {
            setState(EZV.LIZ);
            LIZIZ();
        }
    }

    public final void onPrepared() {
        super.onPrepared();
        if (this.LIZ.LJ) {
            String str = this.LIZ.LIZJ.LIZ;
            J7F j7f = new J7F();
            j7f.LIZ("text");
            InviteFriendsSharePackageV2 inviteFriendsSharePackageV2 = new InviteFriendsSharePackageV2("invitevia", str, false, (IInviteFriendsApi) null, j7f, 12);
            this.LIZLLL = inviteFriendsSharePackageV2;
            inviteFriendsSharePackageV2.LIZIZ();
        }
    }

    public /* synthetic */ FacebookMaFWidgetVM(EZA eza) {
        this(eza, C4003EZz.LIZ.LIZLLL(), C0849DCr.LIZLLL);
    }

    public final List<C3064Dzw> LIZ(List<? extends User> list) {
        ArrayList arrayList = new ArrayList(9HM.LIZ(list, 10));
        int i = 0;
        for (T next : list) {
            int i2 = i + 1;
            if (i < 0) {
                LeS.LIZIZ();
            }
            arrayList.add(new C3064Dzw(this.LIZ, (User) next, i));
            i = i2;
        }
        return arrayList;
    }

    public final void LIZ(1hK r4) {
        M12.LIZ(r4);
        InviteFriendsSharePackageV2 inviteFriendsSharePackageV2 = this.LIZLLL;
        if (inviteFriendsSharePackageV2 != null) {
            if (this.LJ == null) {
                this.LJ = InviteFriendsSharePackageV2.LIZJ.LIZ(inviteFriendsSharePackageV2, r4);
            }
            4rR r0 = this.LJ;
            if (r0 != null) {
                JOF jof = (JOF) r0.LIZ.get(0);
                if (!inviteFriendsSharePackageV2.LIZ(jof, r4)) {
                    jof.LIZ(inviteFriendsSharePackageV2.LIZ(jof), r4);
                }
            }
            new AnJ(this.LIZ.LIZJ.LIZ).LIZJ();
        }
    }

    public FacebookMaFWidgetVM(EZA eza, An2 an2, DB2 db2) {
        M12.LIZ(eza, an2, db2);
        this.LIZ = eza;
        this.LIZIZ = an2;
        this.LJFF = db2;
    }
}
