package X6FRs_4.YghfZG_14.PGPF6hQ_2;

import android.view.View;
import android.view.ViewGroup;
import androidx.recyclerview.widget.RecyclerView;
import java.util.ArrayList;
import java.util.List;
/* compiled from: ChildHelper.java */
/* loaded from: classes.dex */
public class QxJ9d_1 {

    /* renamed from: KQgRr5e_0  reason: collision with other field name */
    public final InterfaceC0075QxJ9d_1 f1397KQgRr5e_0;
    public final KQgRr5e_0 KQgRr5e_0 = new KQgRr5e_0();

    /* renamed from: KQgRr5e_0  reason: collision with other field name */
    public final List<View> f1398KQgRr5e_0 = new ArrayList();

    /* compiled from: ChildHelper.java */
    /* renamed from: X6FRs_4.YghfZG_14.PGPF6hQ_2.QxJ9d_1$QxJ9d_1  reason: collision with other inner class name */
    /* loaded from: classes.dex */
    public interface InterfaceC0075QxJ9d_1 {
        int KQgRr5e_0();

        int KQgRr5e_0(View view);

        View KQgRr5e_0(int i);

        /* renamed from: KQgRr5e_0  reason: collision with other method in class */
        RecyclerView.WGk6X_27 m644KQgRr5e_0(View view);

        /* renamed from: KQgRr5e_0  reason: collision with other method in class */
        void m645KQgRr5e_0();

        /* renamed from: KQgRr5e_0  reason: collision with other method in class */
        void m646KQgRr5e_0(int i);

        /* renamed from: KQgRr5e_0  reason: collision with other method in class */
        void m647KQgRr5e_0(View view);

        void KQgRr5e_0(View view, int i);

        void KQgRr5e_0(View view, int i, ViewGroup.LayoutParams layoutParams);

        void QxJ9d_1(int i);

        void QxJ9d_1(View view);
    }

    public QxJ9d_1(InterfaceC0075QxJ9d_1 interfaceC0075QxJ9d_1) {
        this.f1397KQgRr5e_0 = interfaceC0075QxJ9d_1;
    }

    public void KQgRr5e_0(View view, boolean z) {
        KQgRr5e_0(view, -1, z);
    }

    public void Mqv2r_3(View view) {
        int KQgRr5e_02 = this.f1397KQgRr5e_0.KQgRr5e_0(view);
        if (KQgRr5e_02 >= 0) {
            if (this.KQgRr5e_0.m642KQgRr5e_0(KQgRr5e_02)) {
                this.KQgRr5e_0.m641KQgRr5e_0(KQgRr5e_02);
                m638PGPF6hQ_2(view);
                return;
            }
            throw new RuntimeException("trying to unhide a view that was not hidden" + view);
        }
        throw new IllegalArgumentException("view is not a child, cannot hide " + view);
    }

    /* renamed from: PGPF6hQ_2  reason: collision with other method in class */
    public final boolean m638PGPF6hQ_2(View view) {
        if (this.f1398KQgRr5e_0.remove(view)) {
            this.f1397KQgRr5e_0.QxJ9d_1(view);
            return true;
        }
        return false;
    }

    public final void QxJ9d_1(View view) {
        this.f1398KQgRr5e_0.add(view);
        this.f1397KQgRr5e_0.m647KQgRr5e_0(view);
    }

    public String toString() {
        return this.KQgRr5e_0.toString() + ", hidden list:" + this.f1398KQgRr5e_0.size();
    }

    /* compiled from: ChildHelper.java */
    /* loaded from: classes.dex */
    public static class KQgRr5e_0 {
        public long KQgRr5e_0 = 0;

        /* renamed from: KQgRr5e_0  reason: collision with other field name */
        public KQgRr5e_0 f1399KQgRr5e_0;

        public final void KQgRr5e_0() {
            if (this.f1399KQgRr5e_0 == null) {
                this.f1399KQgRr5e_0 = new KQgRr5e_0();
            }
        }

        public void QxJ9d_1(int i) {
            if (i >= 64) {
                KQgRr5e_0();
                this.f1399KQgRr5e_0.QxJ9d_1(i - 64);
                return;
            }
            this.KQgRr5e_0 |= 1 << i;
        }

        public String toString() {
            if (this.f1399KQgRr5e_0 == null) {
                return Long.toBinaryString(this.KQgRr5e_0);
            }
            return this.f1399KQgRr5e_0.toString() + "xx" + Long.toBinaryString(this.KQgRr5e_0);
        }

        /* renamed from: KQgRr5e_0  reason: collision with other method in class */
        public void m641KQgRr5e_0(int i) {
            if (i >= 64) {
                KQgRr5e_0 kQgRr5e_0 = this.f1399KQgRr5e_0;
                if (kQgRr5e_0 != null) {
                    kQgRr5e_0.m641KQgRr5e_0(i - 64);
                    return;
                }
                return;
            }
            this.KQgRr5e_0 &= (1 << i) ^ (-1);
        }

        public void QxJ9d_1() {
            this.KQgRr5e_0 = 0L;
            KQgRr5e_0 kQgRr5e_0 = this.f1399KQgRr5e_0;
            if (kQgRr5e_0 != null) {
                kQgRr5e_0.QxJ9d_1();
            }
        }

        /* renamed from: KQgRr5e_0  reason: collision with other method in class */
        public boolean m642KQgRr5e_0(int i) {
            if (i < 64) {
                return (this.KQgRr5e_0 & (1 << i)) != 0;
            }
            KQgRr5e_0();
            return this.f1399KQgRr5e_0.m642KQgRr5e_0(i - 64);
        }

        /* renamed from: QxJ9d_1  reason: collision with other method in class */
        public boolean m643QxJ9d_1(int i) {
            if (i >= 64) {
                KQgRr5e_0();
                return this.f1399KQgRr5e_0.m643QxJ9d_1(i - 64);
            }
            long j = 1 << i;
            boolean z = (this.KQgRr5e_0 & j) != 0;
            long j2 = this.KQgRr5e_0 & (j ^ (-1));
            this.KQgRr5e_0 = j2;
            long j3 = j - 1;
            this.KQgRr5e_0 = (j2 & j3) | Long.rotateRight((j3 ^ (-1)) & j2, 1);
            KQgRr5e_0 kQgRr5e_0 = this.f1399KQgRr5e_0;
            if (kQgRr5e_0 != null) {
                if (kQgRr5e_0.m642KQgRr5e_0(0)) {
                    QxJ9d_1(63);
                }
                this.f1399KQgRr5e_0.m643QxJ9d_1(0);
            }
            return z;
        }

        public void KQgRr5e_0(int i, boolean z) {
            if (i >= 64) {
                KQgRr5e_0();
                this.f1399KQgRr5e_0.KQgRr5e_0(i - 64, z);
                return;
            }
            boolean z2 = (this.KQgRr5e_0 & Long.MIN_VALUE) != 0;
            long j = (1 << i) - 1;
            long j2 = this.KQgRr5e_0;
            this.KQgRr5e_0 = ((j2 & (j ^ (-1))) << 1) | (j2 & j);
            if (z) {
                QxJ9d_1(i);
            } else {
                m641KQgRr5e_0(i);
            }
            if (z2 || this.f1399KQgRr5e_0 != null) {
                KQgRr5e_0();
                this.f1399KQgRr5e_0.KQgRr5e_0(0, z2);
            }
        }

        public int KQgRr5e_0(int i) {
            KQgRr5e_0 kQgRr5e_0 = this.f1399KQgRr5e_0;
            if (kQgRr5e_0 == null) {
                if (i >= 64) {
                    return Long.bitCount(this.KQgRr5e_0);
                }
                return Long.bitCount(this.KQgRr5e_0 & ((1 << i) - 1));
            } else if (i < 64) {
                return Long.bitCount(this.KQgRr5e_0 & ((1 << i) - 1));
            } else {
                return kQgRr5e_0.KQgRr5e_0(i - 64) + Long.bitCount(this.KQgRr5e_0);
            }
        }
    }

    public void KQgRr5e_0(View view, int i, boolean z) {
        int KQgRr5e_02;
        if (i < 0) {
            KQgRr5e_02 = this.f1397KQgRr5e_0.KQgRr5e_0();
        } else {
            KQgRr5e_02 = KQgRr5e_0(i);
        }
        this.KQgRr5e_0.KQgRr5e_0(KQgRr5e_02, z);
        if (z) {
            QxJ9d_1(view);
        }
        this.f1397KQgRr5e_0.KQgRr5e_0(view, KQgRr5e_02);
    }

    public void PGPF6hQ_2(View view) {
        int KQgRr5e_02 = this.f1397KQgRr5e_0.KQgRr5e_0(view);
        if (KQgRr5e_02 < 0) {
            return;
        }
        if (this.KQgRr5e_0.m643QxJ9d_1(KQgRr5e_02)) {
            m638PGPF6hQ_2(view);
        }
        this.f1397KQgRr5e_0.m646KQgRr5e_0(KQgRr5e_02);
    }

    /* renamed from: QxJ9d_1  reason: collision with other method in class */
    public void m639QxJ9d_1(int i) {
        int KQgRr5e_02 = KQgRr5e_0(i);
        View KQgRr5e_03 = this.f1397KQgRr5e_0.KQgRr5e_0(KQgRr5e_02);
        if (KQgRr5e_03 == null) {
            return;
        }
        if (this.KQgRr5e_0.m643QxJ9d_1(KQgRr5e_02)) {
            m638PGPF6hQ_2(KQgRr5e_03);
        }
        this.f1397KQgRr5e_0.m646KQgRr5e_0(KQgRr5e_02);
    }

    public final int KQgRr5e_0(int i) {
        if (i < 0) {
            return -1;
        }
        int KQgRr5e_02 = this.f1397KQgRr5e_0.KQgRr5e_0();
        int i2 = i;
        while (i2 < KQgRr5e_02) {
            int KQgRr5e_03 = i - (i2 - this.KQgRr5e_0.KQgRr5e_0(i2));
            if (KQgRr5e_03 == 0) {
                while (this.KQgRr5e_0.m642KQgRr5e_0(i2)) {
                    i2++;
                }
                return i2;
            }
            i2 += KQgRr5e_03;
        }
        return -1;
    }

    public View PGPF6hQ_2(int i) {
        return this.f1397KQgRr5e_0.KQgRr5e_0(i);
    }

    public View QxJ9d_1(int i) {
        return this.f1397KQgRr5e_0.KQgRr5e_0(KQgRr5e_0(i));
    }

    /* renamed from: KQgRr5e_0  reason: collision with other method in class */
    public void m634KQgRr5e_0() {
        this.KQgRr5e_0.QxJ9d_1();
        for (int size = this.f1398KQgRr5e_0.size() - 1; size >= 0; size--) {
            this.f1397KQgRr5e_0.QxJ9d_1(this.f1398KQgRr5e_0.get(size));
            this.f1398KQgRr5e_0.remove(size);
        }
        this.f1397KQgRr5e_0.m645KQgRr5e_0();
    }

    public int QxJ9d_1() {
        return this.f1397KQgRr5e_0.KQgRr5e_0();
    }

    /* renamed from: QxJ9d_1  reason: collision with other method in class */
    public boolean m640QxJ9d_1(View view) {
        int KQgRr5e_02 = this.f1397KQgRr5e_0.KQgRr5e_0(view);
        if (KQgRr5e_02 == -1) {
            m638PGPF6hQ_2(view);
            return true;
        } else if (this.KQgRr5e_0.m642KQgRr5e_0(KQgRr5e_02)) {
            this.KQgRr5e_0.m643QxJ9d_1(KQgRr5e_02);
            m638PGPF6hQ_2(view);
            this.f1397KQgRr5e_0.m646KQgRr5e_0(KQgRr5e_02);
            return true;
        } else {
            return false;
        }
    }

    /* renamed from: KQgRr5e_0  reason: collision with other method in class */
    public View m633KQgRr5e_0(int i) {
        int size = this.f1398KQgRr5e_0.size();
        for (int i2 = 0; i2 < size; i2++) {
            View view = this.f1398KQgRr5e_0.get(i2);
            RecyclerView.WGk6X_27 m644KQgRr5e_0 = this.f1397KQgRr5e_0.m644KQgRr5e_0(view);
            if (m644KQgRr5e_0.getLayoutPosition() == i && !m644KQgRr5e_0.isInvalid() && !m644KQgRr5e_0.isRemoved()) {
                return view;
            }
        }
        return null;
    }

    public void KQgRr5e_0(View view, int i, ViewGroup.LayoutParams layoutParams, boolean z) {
        int KQgRr5e_02;
        if (i < 0) {
            KQgRr5e_02 = this.f1397KQgRr5e_0.KQgRr5e_0();
        } else {
            KQgRr5e_02 = KQgRr5e_0(i);
        }
        this.KQgRr5e_0.KQgRr5e_0(KQgRr5e_02, z);
        if (z) {
            QxJ9d_1(view);
        }
        this.f1397KQgRr5e_0.KQgRr5e_0(view, KQgRr5e_02, layoutParams);
    }

    public int KQgRr5e_0() {
        return this.f1397KQgRr5e_0.KQgRr5e_0() - this.f1398KQgRr5e_0.size();
    }

    /* renamed from: KQgRr5e_0  reason: collision with other method in class */
    public void m635KQgRr5e_0(int i) {
        int KQgRr5e_02 = KQgRr5e_0(i);
        this.KQgRr5e_0.m643QxJ9d_1(KQgRr5e_02);
        this.f1397KQgRr5e_0.QxJ9d_1(KQgRr5e_02);
    }

    public int KQgRr5e_0(View view) {
        int KQgRr5e_02 = this.f1397KQgRr5e_0.KQgRr5e_0(view);
        if (KQgRr5e_02 == -1 || this.KQgRr5e_0.m642KQgRr5e_0(KQgRr5e_02)) {
            return -1;
        }
        return KQgRr5e_02 - this.KQgRr5e_0.KQgRr5e_0(KQgRr5e_02);
    }

    /* renamed from: KQgRr5e_0  reason: collision with other method in class */
    public boolean m637KQgRr5e_0(View view) {
        return this.f1398KQgRr5e_0.contains(view);
    }

    /* renamed from: KQgRr5e_0  reason: collision with other method in class */
    public void m636KQgRr5e_0(View view) {
        int KQgRr5e_02 = this.f1397KQgRr5e_0.KQgRr5e_0(view);
        if (KQgRr5e_02 >= 0) {
            this.KQgRr5e_0.QxJ9d_1(KQgRr5e_02);
            QxJ9d_1(view);
            return;
        }
        throw new IllegalArgumentException("view is not a child, cannot hide " + view);
    }
}
