package defpackage;

import android.view.View;
import androidx.recyclerview.widget.StaggeredGridLayoutManager;
import java.util.ArrayList;
import java.util.Collections;
import java.util.LinkedHashMap;
import java.util.Map;

/* JADX INFO: renamed from: ˏﾞᵯᵨ, reason: contains not printable characters */
/* JADX INFO: loaded from: classes3.dex */
public class C1935 {

    /* JADX INFO: renamed from: ˊᵫᵗ, reason: contains not printable characters */
    public static final C2262 f7709 = new C2262(19);

    /* JADX INFO: renamed from: ᵻʽᵯ, reason: contains not printable characters */
    public static final C2262 f7710 = new C2262(20);

    /* JADX INFO: renamed from: ʽˈˋ, reason: contains not printable characters */
    public int f7711;

    /* JADX INFO: renamed from: ːˏᵟᵯ, reason: contains not printable characters */
    public int f7712;

    /* JADX INFO: renamed from: ᵨᵣ, reason: contains not printable characters */
    public int f7713;

    /* JADX INFO: renamed from: ᵲᵶᵳˈ, reason: contains not printable characters */
    public final /* synthetic */ int f7714;

    /* JADX INFO: renamed from: ᵵᵽ, reason: contains not printable characters */
    public final Object f7715;

    /* JADX INFO: renamed from: ᵷᵺʾᵖ, reason: contains not printable characters */
    public int f7716;

    /* JADX INFO: renamed from: ᵻˈᵦʼ, reason: contains not printable characters */
    public final Object f7717;

    public C1935() {
        this.f7714 = 0;
        this.f7715 = new C3076[5];
        this.f7717 = new ArrayList();
        this.f7711 = -1;
    }

    public C1935(int i) {
        this.f7714 = 1;
        this.f7711 = i;
        if (i <= 0) {
            AbstractC3481.m7945("maxSize <= 0");
            throw null;
        }
        this.f7717 = new C4605(2);
        this.f7715 = new ᵱᵻᵧᵷ();
    }

    public C1935(StaggeredGridLayoutManager staggeredGridLayoutManager, int i) {
        this.f7714 = 2;
        this.f7715 = staggeredGridLayoutManager;
        this.f7717 = new ArrayList();
        this.f7711 = Integer.MIN_VALUE;
        this.f7712 = Integer.MIN_VALUE;
        this.f7716 = 0;
        this.f7713 = i;
    }

    public String toString() {
        String str;
        switch (this.f7714) {
            case 1:
                synchronized (((ᵱᵻᵧᵷ) this.f7715)) {
                    try {
                        int i = this.f7716;
                        int i2 = this.f7713 + i;
                        str = "LruCache[maxSize=" + this.f7711 + ",hits=" + this.f7716 + ",misses=" + this.f7713 + ",hitRate=" + (i2 != 0 ? (i * 100) / i2 : 0) + "%]";
                    } catch (Throwable th) {
                        throw th;
                    }
                }
                return str;
            default:
                return super.toString();
        }
    }

    /* JADX INFO: renamed from: ʽˈˋ, reason: contains not printable characters */
    public void m5174() {
        View view = (View) AbstractC3653.m8235(1, (ArrayList) this.f7717);
        C3088 c3088 = (C3088) view.getLayoutParams();
        this.f7712 = ((StaggeredGridLayoutManager) this.f7715).f934.mo1724(view);
        c3088.getClass();
    }

    /* JADX WARN: Code restructure failed: missing block: B:26:0x005f, code lost:
    
        return;
     */
    /* JADX WARN: Code restructure failed: missing block: B:28:0x0067, code lost:
    
        throw new java.lang.IllegalStateException("LruCache.sizeOf() is reporting inconsistent results!");
     */
    /* JADX INFO: renamed from: ˊᵙᵾᵲ, reason: contains not printable characters */
    /*
        Code decompiled incorrectly, please refer to instructions dump.
    */
    public void m5175(int i) {
        Object key;
        Object value;
        while (true) {
            synchronized (((ᵱᵻᵧᵷ) this.f7715)) {
                try {
                    if (this.f7712 < 0 || (((C4605) this.f7717).f17518.isEmpty() && this.f7712 != 0)) {
                        break;
                    }
                    if (this.f7712 <= i || ((C4605) this.f7717).f17518.isEmpty()) {
                        break;
                    }
                    Map.Entry entry = (Map.Entry) AbstractC4126.m8999(((C4605) this.f7717).f17518.entrySet());
                    if (entry == null) {
                        return;
                    }
                    key = entry.getKey();
                    value = entry.getValue();
                    ((C4605) this.f7717).f17518.remove(key);
                    this.f7712--;
                } catch (Throwable th) {
                    throw th;
                }
            }
            mo5181(key, value, null);
        }
    }

    /* JADX INFO: renamed from: ˊᵫᵗ, reason: contains not printable characters */
    public int m5176(int i, int i2) {
        StaggeredGridLayoutManager staggeredGridLayoutManager = (StaggeredGridLayoutManager) this.f7715;
        int iMo1734 = staggeredGridLayoutManager.f934.mo1734();
        int iMo1733 = staggeredGridLayoutManager.f934.mo1733();
        int i3 = i2 > i ? 1 : -1;
        while (i != i2) {
            View view = (View) ((ArrayList) this.f7717).get(i);
            int iMo1729 = staggeredGridLayoutManager.f934.mo1729(view);
            int iMo1724 = staggeredGridLayoutManager.f934.mo1724(view);
            boolean z = iMo1729 <= iMo1733;
            boolean z2 = iMo1724 >= iMo1734;
            if (z && z2 && (iMo1729 < iMo1734 || iMo1724 > iMo1733)) {
                return AbstractC0421.m1777(view);
            }
            i += i3;
        }
        return -1;
    }

    /* JADX INFO: renamed from: ˋˈ, reason: contains not printable characters */
    public int m5177() {
        int i;
        synchronized (((ᵱᵻᵧᵷ) this.f7715)) {
            i = this.f7711;
        }
        return i;
    }

    /* JADX INFO: renamed from: ːˏᵟᵯ, reason: contains not printable characters */
    public void m5178() {
        ((ArrayList) this.f7717).clear();
        this.f7711 = Integer.MIN_VALUE;
        this.f7712 = Integer.MIN_VALUE;
        this.f7716 = 0;
    }

    /* JADX INFO: renamed from: ᵝᵶ, reason: contains not printable characters */
    public int m5179(int i) {
        ArrayList arrayList = (ArrayList) this.f7717;
        int i2 = this.f7711;
        if (i2 != Integer.MIN_VALUE) {
            return i2;
        }
        if (arrayList.size() == 0) {
            return i;
        }
        View view = (View) arrayList.get(0);
        C3088 c3088 = (C3088) view.getLayoutParams();
        this.f7711 = ((StaggeredGridLayoutManager) this.f7715).f934.mo1729(view);
        c3088.getClass();
        return this.f7711;
    }

    /* JADX INFO: renamed from: ᵟᵹᵙ, reason: contains not printable characters */
    public Object m5180(String str) {
        Object objRemove;
        synchronized (((ᵱᵻᵧᵷ) this.f7715)) {
            objRemove = ((C4605) this.f7717).f17518.remove(str);
            if (objRemove != null) {
                this.f7712--;
            }
        }
        if (objRemove != null) {
            mo5181(str, objRemove, null);
        }
        return objRemove;
    }

    /* JADX INFO: renamed from: ᵨᵣ, reason: contains not printable characters */
    public void mo5181(Object obj, Object obj2, Object obj3) {
    }

    /* JADX INFO: renamed from: ᵪᵹᵥᵻ, reason: contains not printable characters */
    public Object m5182(Object obj, Object obj2) {
        Object objPut;
        synchronized (((ᵱᵻᵧᵷ) this.f7715)) {
            this.f7712++;
            objPut = ((C4605) this.f7717).f17518.put(obj, obj2);
            if (objPut != null) {
                this.f7712--;
            }
        }
        if (objPut != null) {
            mo5181(obj, objPut, obj2);
        }
        m5175(this.f7711);
        return objPut;
    }

    /* JADX INFO: renamed from: ᵮᵣᵗˈ, reason: contains not printable characters */
    public float m5183() {
        ArrayList arrayList = (ArrayList) this.f7717;
        if (this.f7711 != 0) {
            Collections.sort(arrayList, f7710);
            this.f7711 = 0;
        }
        float f = 0.5f * this.f7716;
        int i = 0;
        for (int i2 = 0; i2 < arrayList.size(); i2++) {
            C3076 c3076 = (C3076) arrayList.get(i2);
            i += c3076.f11757;
            if (i >= f) {
                return c3076.f11758;
            }
        }
        if (arrayList.isEmpty()) {
            return Float.NaN;
        }
        return ((C3076) AbstractC3653.m8235(1, arrayList)).f11758;
    }

    /* JADX INFO: renamed from: ᵱʡˏ, reason: contains not printable characters */
    public LinkedHashMap m5184() {
        LinkedHashMap linkedHashMap;
        synchronized (((ᵱᵻᵧᵷ) this.f7715)) {
            linkedHashMap = new LinkedHashMap(((C4605) this.f7717).f17518.entrySet().size());
            for (Map.Entry entry : ((C4605) this.f7717).f17518.entrySet()) {
                linkedHashMap.put(entry.getKey(), entry.getValue());
            }
        }
        return linkedHashMap;
    }

    /* JADX INFO: renamed from: ᵱᵽʡᵚ, reason: contains not printable characters */
    public int m5185(int i) {
        int i2 = this.f7712;
        if (i2 != Integer.MIN_VALUE) {
            return i2;
        }
        if (((ArrayList) this.f7717).size() == 0) {
            return i;
        }
        m5174();
        return this.f7712;
    }

    /* JADX INFO: renamed from: ᵲᵶᵳˈ, reason: contains not printable characters */
    public void m5186(int i, float f) {
        C3076 c3076;
        C3076[] c3076Arr = (C3076[]) this.f7715;
        ArrayList arrayList = (ArrayList) this.f7717;
        if (this.f7711 != 1) {
            Collections.sort(arrayList, f7709);
            this.f7711 = 1;
        }
        int i2 = this.f7713;
        if (i2 > 0) {
            int i3 = i2 - 1;
            this.f7713 = i3;
            c3076 = c3076Arr[i3];
        } else {
            c3076 = new C3076();
        }
        int i4 = this.f7712;
        this.f7712 = i4 + 1;
        c3076.f11759 = i4;
        c3076.f11757 = i;
        c3076.f11758 = f;
        arrayList.add(c3076);
        this.f7716 += i;
        while (true) {
            int i5 = this.f7716;
            if (i5 <= 2000) {
                return;
            }
            int i6 = i5 - 2000;
            C3076 c30762 = (C3076) arrayList.get(0);
            int i7 = c30762.f11757;
            if (i7 <= i6) {
                this.f7716 -= i7;
                arrayList.remove(0);
                int i8 = this.f7713;
                if (i8 < 5) {
                    this.f7713 = i8 + 1;
                    c3076Arr[i8] = c30762;
                }
            } else {
                c30762.f11757 = i7 - i6;
                this.f7716 -= i6;
            }
        }
    }

    /* JADX INFO: renamed from: ᵵᵽ, reason: contains not printable characters */
    public int m5187() {
        return ((StaggeredGridLayoutManager) this.f7715).f942 ? m5176(0, ((ArrayList) this.f7717).size()) : m5176(r1.size() - 1, -1);
    }

    /* JADX INFO: renamed from: ᵶᵥᵝ, reason: contains not printable characters */
    public View m5188(int i, int i2) {
        StaggeredGridLayoutManager staggeredGridLayoutManager = (StaggeredGridLayoutManager) this.f7715;
        ArrayList arrayList = (ArrayList) this.f7717;
        View view = null;
        if (i2 != -1) {
            int size = arrayList.size() - 1;
            while (size >= 0) {
                View view2 = (View) arrayList.get(size);
                if ((staggeredGridLayoutManager.f942 && AbstractC0421.m1777(view2) >= i) || ((!staggeredGridLayoutManager.f942 && AbstractC0421.m1777(view2) <= i) || !view2.hasFocusable())) {
                    break;
                }
                size--;
                view = view2;
            }
            return view;
        }
        int size2 = arrayList.size();
        int i3 = 0;
        while (i3 < size2) {
            View view3 = (View) arrayList.get(i3);
            if ((staggeredGridLayoutManager.f942 && AbstractC0421.m1777(view3) <= i) || ((!staggeredGridLayoutManager.f942 && AbstractC0421.m1777(view3) >= i) || !view3.hasFocusable())) {
                break;
            }
            i3++;
            view = view3;
        }
        return view;
    }

    /* JADX INFO: renamed from: ᵷᵺʾᵖ */
    public Object mo2603(Object obj) {
        return null;
    }

    /* JADX INFO: renamed from: ᵻʽᵯ, reason: contains not printable characters */
    public Object m5189(Object obj) {
        Object objPut;
        synchronized (((ᵱᵻᵧᵷ) this.f7715)) {
            Object obj2 = ((C4605) this.f7717).f17518.get(obj);
            if (obj2 != null) {
                this.f7716++;
                return obj2;
            }
            this.f7713++;
            Object objMo2603 = mo2603(obj);
            if (objMo2603 == null) {
                return null;
            }
            synchronized (((ᵱᵻᵧᵷ) this.f7715)) {
                objPut = ((C4605) this.f7717).f17518.put(obj, objMo2603);
                if (objPut != null) {
                    ((C4605) this.f7717).f17518.put(obj, objPut);
                } else {
                    this.f7712++;
                }
            }
            if (objPut != null) {
                mo5181(obj, objMo2603, objPut);
                return objPut;
            }
            m5175(this.f7711);
            return objMo2603;
        }
    }

    /* JADX INFO: renamed from: ᵻˈᵦʼ, reason: contains not printable characters */
    public int m5190() {
        return ((StaggeredGridLayoutManager) this.f7715).f942 ? m5176(r1.size() - 1, -1) : m5176(0, ((ArrayList) this.f7717).size());
    }
}
