package com.bytedance.ies.bullet.kit.lynx;

import X.7Xl;
import X.C0672KCx;
import X.C0984KOx;
import X.C1049KRk;
import X.C1054KRp;
import X.C1074KSj;
import X.C1117KUa;
import X.C1120KUd;
import X.C1123KUg;
import X.C1421KcO;
import X.C1424KcR;
import X.HkM;
import X.KR0;
import X.KR2;
import X.KSQ;
import X.KT7;
import X.KU2;
import X.KUE;
import X.KUF;
import X.KUR;
import X.KUS;
import X.KUU;
import X.KUY;
import X.M12;
import com.bytedance.covode.number.Covode;
import com.bytedance.frameworks.apm.trace.MethodCollector;
import com.lynx.tasm.LynxEnv;
import java.util.List;
import kotlin.h.b.n;

public final class LynxKitApi extends ILynxKitApi<KU2> {
    public static final C1120KUd LIZ = new C1120KUd((byte) 0);
    public static volatile boolean LJFF;
    public Throwable LIZIZ;
    public final Class<KU2> LIZJ = KU2.class;
    public KT7 LIZLLL;
    public C1117KUa LJ;

    static {
        Covode.recordClassIndex(28300);
    }

    public final KT7 LIZIZ() {
        return this.LIZLLL;
    }

    public final boolean LJII() {
        return LJFF;
    }

    public final Throwable LJIIIIZZ() {
        return this.LIZIZ;
    }

    private final boolean LJIIIZ() {
        HkM b_ = b_(HkM.class);
        if (b_ != null) {
            b_.LIZ(this);
        }
        HkM b_2 = b_(HkM.class);
        if (b_2 != null) {
            return b_2.LIZIZ();
        }
        return false;
    }

    public final String LIZLLL() {
        LynxEnv LIZJ2 = LynxEnv.LIZJ();
        n.LIZ(LIZJ2, "");
        String LJIIIIZZ = LIZJ2.LJIIIIZZ();
        n.LIZ(LJIIIIZZ, "");
        return LJIIIIZZ;
    }

    public final void LIZJ() {
        C1054KRp LIZIZ2;
        MethodCollector.i(11369);
        C1049KRk kRk = (C1049KRk) b_(C1049KRk.class);
        if (kRk == null || (LIZIZ2 = kRk.LIZIZ()) == null || !LIZIZ2.LIZLLL) {
            LJIIJ();
            MethodCollector.o(11369);
            return;
        }
        LynxEnv LIZJ2 = LynxEnv.LIZJ();
        n.LIZ(LIZJ2, "");
        synchronized (LIZJ2) {
            try {
                C1421KcO.LIZ(this, "ensure lynx init be sync", (C1424KcR) null, (String) null, 6);
                LJIIJ();
            } finally {
                MethodCollector.o(11369);
            }
        }
    }

    private final void LJIIJ() {
        7Xl r2;
        C1117KUa kUa;
        if (!LJFF) {
            C1421KcO.LIZ(this, "start to init lynx lib", (C1424KcR) null, (String) null, 6);
            if (!KUU.LIZJ.LIZ().LIZ) {
                KT7 kt7 = this.LIZLLL;
                if (kt7 == null || (kUa = this.LJ) == null || (r2 = kUa.LIZ(kt7)) == null) {
                    r2 = new 7Xl((byte) 0);
                }
                KUU.LIZJ.LIZ().LIZ(r2.LIZ);
            }
            try {
                LJFF = LJIIIZ();
            } catch (Exception e) {
                printReject(e, "init lynx failed");
                LJFF = false;
                this.LIZIZ = e;
            }
        }
    }

    public final /* bridge */ /* synthetic */ void LIZ(C0984KOx kOx) {
        M12.LIZ((Object) kOx);
    }

    public final KR2<KUF, KUE> LIZ(Object obj) {
        M12.LIZ(obj);
        if (obj instanceof KUY) {
            return new KUR(obj);
        }
        return null;
    }

    public final KSQ<C1117KUa> LIZIZ(Object obj) {
        M12.LIZ(obj);
        if (obj instanceof C1123KUg) {
            return new KUS(obj);
        }
        return null;
    }

    public final /* bridge */ /* synthetic */ void LIZ(C1074KSj kSj, KT7 kt7) {
        M12.LIZ((Object) kt7);
        this.LJ = (C1117KUa) kSj;
        this.LIZLLL = kt7;
    }

    /* access modifiers changed from: private */
    /* renamed from: LIZIZ */
    public KU2 LIZ(C0672KCx kCx, List<String> list, KR0 kr0, KT7 kt7) {
        List<String> list2 = list;
        C0672KCx kCx2 = kCx;
        KT7 kt72 = kt7;
        KR0 kr02 = kr0;
        M12.LIZ(kCx2, list2, kr02, kt72);
        LIZJ();
        return new KU2(this, kCx2, list2, kr02, kt72);
    }
}
