package com.bytedance.adsdk.ugeno.yoga;

import java.util.ArrayList;
import java.util.List;

/* JADX INFO: loaded from: classes.dex */
@com.bytedance.adsdk.ugeno.yoga.fm.fm
public abstract class YogaNodeJNIBase extends vt implements Cloneable {
    private Object ajl;

    @com.bytedance.adsdk.ugeno.yoga.fm.fm
    private float[] arr;
    protected long fm;
    private ro jnr;

    /* JADX INFO: renamed from: lb, reason: collision with root package name */
    private List<YogaNodeJNIBase> f6403lb;

    @com.bytedance.adsdk.ugeno.yoga.fm.fm
    private int mLayoutDirection;
    private YogaNodeJNIBase ro;
    private boolean wsy;
    private wsy yz;

    private YogaNodeJNIBase(long j10) {
        this.arr = null;
        this.mLayoutDirection = 0;
        this.wsy = true;
        if (j10 == 0) {
            throw new IllegalStateException("Failed to allocate native memory");
        }
        this.fm = j10;
    }

    @com.bytedance.adsdk.ugeno.yoga.fm.fm
    private final long replaceChild(YogaNodeJNIBase yogaNodeJNIBase, int i10) {
        List<YogaNodeJNIBase> list = this.f6403lb;
        if (list == null) {
            throw new IllegalStateException("Cannot replace child. YogaNode does not have children");
        }
        list.remove(i10);
        this.f6403lb.add(i10, yogaNodeJNIBase);
        yogaNodeJNIBase.ro = this;
        return yogaNodeJNIBase.fm;
    }

    @Override // com.bytedance.adsdk.ugeno.yoga.vt
    public void ajl(float f10) {
        YogaNative.jni_YGNodeStyleSetHeightJNI(this.fm, f10);
    }

    @com.bytedance.adsdk.ugeno.yoga.fm.fm
    public final float baseline(float f10, float f11) {
        return this.jnr.fm(this, f10, f11);
    }

    public boolean duv() {
        return this.yz != null;
    }

    @Override // com.bytedance.adsdk.ugeno.yoga.vt
    public void ef(float f10) {
        YogaNative.jni_YGNodeStyleSetMinHeightJNI(this.fm, f10);
    }

    @Override // com.bytedance.adsdk.ugeno.yoga.vt
    public void fm(Object obj) {
        this.ajl = obj;
    }

    @Override // com.bytedance.adsdk.ugeno.yoga.vt
    public void jnr(float f10) {
        YogaNative.jni_YGNodeStyleSetWidthPercentJNI(this.fm, f10);
    }

    @Override // com.bytedance.adsdk.ugeno.yoga.vt
    /* JADX INFO: renamed from: ku, reason: merged with bridge method [inline-methods] */
    public YogaNodeJNIBase ro() {
        return this.ro;
    }

    @Override // com.bytedance.adsdk.ugeno.yoga.vt
    /* JADX INFO: renamed from: lb, reason: merged with bridge method [inline-methods] */
    public YogaNodeJNIBase fm(int i10) {
        List<YogaNodeJNIBase> list = this.f6403lb;
        if (list != null) {
            return list.get(i10);
        }
        throw new IllegalStateException("YogaNode does not have children");
    }

    @com.bytedance.adsdk.ugeno.yoga.fm.fm
    public final long measure(float f10, int i10, float f11, int i11) {
        if (duv()) {
            return this.yz.fm(this, f10, wu.fm(i10), f11, wu.fm(i11));
        }
        throw new RuntimeException("Measure function isn't defined!");
    }

    @Override // com.bytedance.adsdk.ugeno.yoga.vt
    public Object vt() {
        return this.ajl;
    }

    @Override // com.bytedance.adsdk.ugeno.yoga.vt
    public void wsy(float f10) {
        YogaNative.jni_YGNodeStyleSetHeightPercentJNI(this.fm, f10);
    }

    @Override // com.bytedance.adsdk.ugeno.yoga.vt
    public void wu(float f10) {
        YogaNative.jni_YGNodeStyleSetMinWidthJNI(this.fm, f10);
    }

    @Override // com.bytedance.adsdk.ugeno.yoga.vt
    /* JADX INFO: renamed from: yz, reason: merged with bridge method [inline-methods] */
    public YogaNodeJNIBase ro(int i10) {
        List<YogaNodeJNIBase> list = this.f6403lb;
        if (list == null) {
            throw new IllegalStateException("Trying to remove a child of a YogaNode that does not have children");
        }
        YogaNodeJNIBase yogaNodeJNIBaseRemove = list.remove(i10);
        yogaNodeJNIBaseRemove.ro = null;
        YogaNative.jni_YGNodeRemoveChildJNI(this.fm, yogaNodeJNIBaseRemove.fm);
        return yogaNodeJNIBaseRemove;
    }

    @Override // com.bytedance.adsdk.ugeno.yoga.vt
    public float ajl() {
        float[] fArr = this.arr;
        if (fArr != null) {
            return fArr[3];
        }
        return 0.0f;
    }

    @Override // com.bytedance.adsdk.ugeno.yoga.vt
    public void duv(float f10) {
        YogaNative.jni_YGNodeStyleSetAspectRatioJNI(this.fm, f10);
    }

    @Override // com.bytedance.adsdk.ugeno.yoga.vt
    public float ef() {
        float[] fArr = this.arr;
        if (fArr != null) {
            return fArr[2];
        }
        return 0.0f;
    }

    @Override // com.bytedance.adsdk.ugeno.yoga.vt
    public void jnr() {
        YogaNative.jni_YGNodeStyleSetHeightAutoJNI(this.fm);
    }

    @Override // com.bytedance.adsdk.ugeno.yoga.vt
    public void ku(float f10) {
        YogaNative.jni_YGNodeStyleSetMaxHeightJNI(this.fm, f10);
    }

    @Override // com.bytedance.adsdk.ugeno.yoga.vt
    public void vt(float f10) {
        YogaNative.jni_YGNodeStyleSetMaxWidthJNI(this.fm, f10);
    }

    @Override // com.bytedance.adsdk.ugeno.yoga.vt
    public float wsy() {
        float[] fArr = this.arr;
        if (fArr != null) {
            return fArr[4];
        }
        return 0.0f;
    }

    @Override // com.bytedance.adsdk.ugeno.yoga.vt
    public float wu() {
        float[] fArr = this.arr;
        if (fArr != null) {
            return fArr[1];
        }
        return 0.0f;
    }

    public YogaNodeJNIBase() {
        this(YogaNative.jni_YGNodeNewJNI());
    }

    private void ro(vt vtVar) {
        vt();
    }

    @Override // com.bytedance.adsdk.ugeno.yoga.vt
    public int fm() {
        List<YogaNodeJNIBase> list = this.f6403lb;
        if (list == null) {
            return 0;
        }
        return list.size();
    }

    @Override // com.bytedance.adsdk.ugeno.yoga.vt
    public void lb(fm fmVar) {
        YogaNative.jni_YGNodeStyleSetAlignContentJNI(this.fm, fmVar.fm());
    }

    @Override // com.bytedance.adsdk.ugeno.yoga.vt
    public void fm(vt vtVar, int i10) {
        if (vtVar instanceof YogaNodeJNIBase) {
            YogaNodeJNIBase yogaNodeJNIBase = (YogaNodeJNIBase) vtVar;
            if (yogaNodeJNIBase.ro == null) {
                if (this.f6403lb == null) {
                    this.f6403lb = new ArrayList(4);
                }
                this.f6403lb.add(i10, yogaNodeJNIBase);
                yogaNodeJNIBase.ro = this;
                YogaNative.jni_YGNodeInsertChildJNI(this.fm, yogaNodeJNIBase.fm, i10);
                return;
            }
            throw new IllegalStateException("Child already has a parent, it must be removed first.");
        }
    }

    @Override // com.bytedance.adsdk.ugeno.yoga.vt
    public void lb(float f10) {
        YogaNative.jni_YGNodeStyleSetFlexBasisJNI(this.fm, f10);
    }

    @Override // com.bytedance.adsdk.ugeno.yoga.vt
    public void ro(fm fmVar) {
        YogaNative.jni_YGNodeStyleSetAlignSelfJNI(this.fm, fmVar.fm());
    }

    @Override // com.bytedance.adsdk.ugeno.yoga.vt
    public void lb() {
        YogaNative.jni_YGNodeStyleSetFlexBasisAutoJNI(this.fm);
    }

    @Override // com.bytedance.adsdk.ugeno.yoga.vt
    public void ro(float f10) {
        YogaNative.jni_YGNodeStyleSetFlexShrinkJNI(this.fm, f10);
    }

    @Override // com.bytedance.adsdk.ugeno.yoga.vt
    public void yz(float f10) {
        YogaNative.jni_YGNodeStyleSetWidthJNI(this.fm, f10);
    }

    @Override // com.bytedance.adsdk.ugeno.yoga.vt
    public void lb(yz yzVar, float f10) {
        YogaNative.jni_YGNodeStyleSetPositionJNI(this.fm, yzVar.fm(), f10);
    }

    @Override // com.bytedance.adsdk.ugeno.yoga.vt
    public void ro(yz yzVar, float f10) {
        YogaNative.jni_YGNodeStyleSetPaddingJNI(this.fm, yzVar.fm(), f10);
    }

    @Override // com.bytedance.adsdk.ugeno.yoga.vt
    public void yz() {
        YogaNative.jni_YGNodeStyleSetWidthAutoJNI(this.fm);
    }

    @Override // com.bytedance.adsdk.ugeno.yoga.vt
    public int fm(vt vtVar) {
        List<YogaNodeJNIBase> list = this.f6403lb;
        if (list == null) {
            return -1;
        }
        return list.indexOf(vtVar);
    }

    @Override // com.bytedance.adsdk.ugeno.yoga.vt
    public void fm(float f10, float f11) {
        ro((vt) null);
        ArrayList arrayList = new ArrayList();
        arrayList.add(this);
        for (int i10 = 0; i10 < arrayList.size(); i10++) {
            YogaNodeJNIBase yogaNodeJNIBase = (YogaNodeJNIBase) arrayList.get(i10);
            List<YogaNodeJNIBase> list = yogaNodeJNIBase.f6403lb;
            if (list != null) {
                for (YogaNodeJNIBase yogaNodeJNIBase2 : list) {
                    yogaNodeJNIBase2.ro(yogaNodeJNIBase);
                    arrayList.add(yogaNodeJNIBase2);
                }
            }
        }
        YogaNodeJNIBase[] yogaNodeJNIBaseArr = (YogaNodeJNIBase[]) arrayList.toArray(new YogaNodeJNIBase[arrayList.size()]);
        long[] jArr = new long[yogaNodeJNIBaseArr.length];
        for (int i11 = 0; i11 < yogaNodeJNIBaseArr.length; i11++) {
            jArr[i11] = yogaNodeJNIBaseArr[i11].fm;
        }
        YogaNative.jni_YGNodeCalculateLayoutJNI(this.fm, f10, f11, jArr, yogaNodeJNIBaseArr);
    }

    @Override // com.bytedance.adsdk.ugeno.yoga.vt
    public void fm(lb lbVar) {
        YogaNative.jni_YGNodeStyleSetDirectionJNI(this.fm, lbVar.fm());
    }

    @Override // com.bytedance.adsdk.ugeno.yoga.vt
    public void fm(jnr jnrVar) {
        YogaNative.jni_YGNodeStyleSetFlexDirectionJNI(this.fm, jnrVar.fm());
    }

    @Override // com.bytedance.adsdk.ugeno.yoga.vt
    public void fm(ajl ajlVar) {
        YogaNative.jni_YGNodeStyleSetJustifyContentJNI(this.fm, ajlVar.fm());
    }

    @Override // com.bytedance.adsdk.ugeno.yoga.vt
    public void fm(fm fmVar) {
        YogaNative.jni_YGNodeStyleSetAlignItemsJNI(this.fm, fmVar.fm());
    }

    @Override // com.bytedance.adsdk.ugeno.yoga.vt
    public void fm(dsz dszVar) {
        YogaNative.jni_YGNodeStyleSetPositionTypeJNI(this.fm, dszVar.fm());
    }

    @Override // com.bytedance.adsdk.ugeno.yoga.vt
    public void fm(onz onzVar) {
        YogaNative.jni_YGNodeStyleSetFlexWrapJNI(this.fm, onzVar.fm());
    }

    @Override // com.bytedance.adsdk.ugeno.yoga.vt
    public void fm(float f10) {
        YogaNative.jni_YGNodeStyleSetFlexGrowJNI(this.fm, f10);
    }

    @Override // com.bytedance.adsdk.ugeno.yoga.vt
    public void fm(yz yzVar, float f10) {
        YogaNative.jni_YGNodeStyleSetMarginJNI(this.fm, yzVar.fm(), f10);
    }

    @Override // com.bytedance.adsdk.ugeno.yoga.vt
    public void fm(wsy wsyVar) {
        this.yz = wsyVar;
        YogaNative.jni_YGNodeSetHasMeasureFuncJNI(this.fm, wsyVar != null);
    }

    @Override // com.bytedance.adsdk.ugeno.yoga.vt
    public void fm(boolean z10) {
        YogaNative.jni_YGNodeSetAlwaysFormsContainingBlockJNI(this.fm, z10);
    }
}
