package defpackage;

import android.graphics.Matrix;
import android.graphics.Path;
import android.graphics.PointF;
import android.graphics.RectF;
import android.os.Handler;
import android.os.Looper;
import java.util.ArrayList;
import java.util.BitSet;
import java.util.HashMap;
import java.util.HashSet;
import java.util.IdentityHashMap;
import java.util.Iterator;

/* renamed from: ʿʚᵤˆ, reason: contains not printable characters */
/* loaded from: classes3.dex */
public final class C0360 {

    /* renamed from: ˇʼʤˎ, reason: contains not printable characters */
    public final Object f2123;

    /* renamed from: ˌᵜᵹᵩ, reason: contains not printable characters */
    public Object f2124;

    /* renamed from: ˎˏʜʾ, reason: contains not printable characters */
    public final Object f2125;

    /* renamed from: ˏˋٴ, reason: contains not printable characters */
    public final Object f2126;

    /* renamed from: ˏᵙ, reason: contains not printable characters */
    public final Object f2127;

    /* renamed from: ᵝᵵᵺ, reason: contains not printable characters */
    public final Object f2128;

    /* renamed from: ᵥᵯˎ, reason: contains not printable characters */
    public boolean f2129;

    /* renamed from: ᵴᵳ, reason: contains not printable characters */
    public final Object f2130;

    /* renamed from: ᵶᵷᵕ, reason: contains not printable characters */
    public final Object f2131;

    /* renamed from: ᵸˑ, reason: contains not printable characters */
    public Object f2132;

    /* renamed from: ᵹᵝᵶ, reason: contains not printable characters */
    public final Object f2133;

    /* renamed from: ᵻᵢﹳᵰ, reason: contains not printable characters */
    public final Object f2134;

    public C0360() {
        this.f2130 = new C4199[4];
        this.f2127 = new Matrix[4];
        this.f2134 = new Matrix[4];
        this.f2123 = new PointF();
        this.f2126 = new Path();
        this.f2125 = new Path();
        this.f2133 = new C4199();
        this.f2128 = new float[2];
        this.f2131 = new float[2];
        this.f2132 = new Path();
        this.f2124 = new Path();
        this.f2129 = true;
        for (int i = 0; i < 4; i++) {
            ((C4199[]) this.f2130)[i] = new C4199();
            ((Matrix[]) this.f2127)[i] = new Matrix();
            ((Matrix[]) this.f2134)[i] = new Matrix();
        }
    }

    public C0360(C0911 c0911, C0422 c0422, C5073 c5073, C1545 c1545) {
        this.f2130 = c1545;
        this.f2125 = c0911;
        this.f2132 = new C1438();
        this.f2134 = new IdentityHashMap();
        this.f2123 = new HashMap();
        this.f2127 = new ArrayList();
        this.f2128 = c0422;
        this.f2131 = c5073;
        this.f2126 = new HashMap();
        this.f2133 = new HashSet();
    }

    /* renamed from: ˇʼʤˎ, reason: contains not printable characters */
    public static C0360 m1788() {
        return Looper.getMainLooper().getThread() == Thread.currentThread() ? AbstractC4173.f15595 : new C0360();
    }

    /* renamed from: ˎˏʜʾ, reason: contains not printable characters */
    public boolean m1789(Path path, int i) {
        Path path2 = (Path) this.f2124;
        path2.reset();
        ((C4199[]) this.f2130)[i].m9125(((Matrix[]) this.f2127)[i], path2);
        RectF rectF = new RectF();
        path.computeBounds(rectF, true);
        path2.computeBounds(rectF, true);
        path.op(path2, Path.Op.INTERSECT);
        path.computeBounds(rectF, true);
        return !rectF.isEmpty() || (rectF.width() > 1.0f && rectF.height() > 1.0f);
    }

    /* renamed from: ˏˋٴ, reason: contains not printable characters */
    public void m1790(C0130 c0130) {
        if (c0130.f1459 && c0130.f1460.isEmpty()) {
            C2141 c2141 = (C2141) ((HashMap) this.f2126).remove(c0130);
            c2141.getClass();
            C3118 c3118 = c2141.f8432;
            InterfaceC4865 interfaceC4865 = c2141.f8433;
            interfaceC4865.mo8194(c2141.f8434);
            interfaceC4865.mo8198(c3118);
            interfaceC4865.mo8201(c3118);
            ((HashSet) this.f2133).remove(c0130);
        }
    }

    /* renamed from: ˏᵙ, reason: contains not printable characters */
    public AbstractC0488 m1791() {
        ArrayList arrayList = (ArrayList) this.f2127;
        if (arrayList.isEmpty()) {
            return AbstractC0488.f2597;
        }
        int iMo2124 = 0;
        for (int i = 0; i < arrayList.size(); i++) {
            C0130 c0130 = (C0130) arrayList.get(i);
            c0130.f1463 = iMo2124;
            iMo2124 += c0130.f1461.f4843.f17542.mo2124();
        }
        return new C2906(arrayList, (C1438) this.f2132);
    }

    /* renamed from: ᵝᵵᵺ, reason: contains not printable characters */
    public void m1792(InterfaceC3757 interfaceC3757) {
        IdentityHashMap identityHashMap = (IdentityHashMap) this.f2134;
        C0130 c0130 = (C0130) identityHashMap.remove(interfaceC3757);
        c0130.getClass();
        c0130.f1461.mo2932(interfaceC3757);
        c0130.f1460.remove(((C5090) interfaceC3757).f19023);
        if (!identityHashMap.isEmpty()) {
            m1797();
        }
        m1790(c0130);
    }

    /* renamed from: ᵥᵯˎ, reason: contains not printable characters */
    public AbstractC0488 m1793(int i, ArrayList arrayList, C1438 c1438) {
        ArrayList arrayList2 = (ArrayList) this.f2127;
        if (!arrayList.isEmpty()) {
            this.f2132 = c1438;
            for (int i2 = i; i2 < arrayList.size() + i; i2++) {
                C0130 c0130 = (C0130) arrayList.get(i2 - i);
                if (i2 > 0) {
                    C0130 c01302 = (C0130) arrayList2.get(i2 - 1);
                    c0130.f1463 = c01302.f1461.f4843.f17542.mo2124() + c01302.f1463;
                    c0130.f1459 = false;
                    c0130.f1460.clear();
                } else {
                    c0130.f1463 = 0;
                    c0130.f1459 = false;
                    c0130.f1460.clear();
                }
                int iMo2124 = c0130.f1461.f4843.f17542.mo2124();
                for (int i3 = i2; i3 < arrayList2.size(); i3++) {
                    ((C0130) arrayList2.get(i3)).f1463 += iMo2124;
                }
                arrayList2.add(i2, c0130);
                ((HashMap) this.f2123).put(c0130.f1462, c0130);
                if (this.f2129) {
                    m1796(c0130);
                    if (((IdentityHashMap) this.f2134).isEmpty()) {
                        ((HashSet) this.f2133).add(c0130);
                    } else {
                        C2141 c2141 = (C2141) ((HashMap) this.f2126).get(c0130);
                        if (c2141 != null) {
                            c2141.f8433.mo8192(c2141.f8434);
                        }
                    }
                }
            }
        }
        return m1791();
    }

    /* JADX WARN: Multi-variable type inference failed */
    /* JADX WARN: Type inference failed for: r16v0 */
    /* JADX WARN: Type inference failed for: r16v1 */
    /* JADX WARN: Type inference failed for: r16v5 */
    /* renamed from: ᵴᵳ, reason: contains not printable characters */
    public void m1794(C4879 c4879, float[] fArr, float f, RectF rectF, ˊʘ r26, Path path) {
        int i;
        boolean z;
        float f2;
        ˊʘ r8;
        boolean z2;
        ˊʘ r3 = r26;
        Matrix[] matrixArr = (Matrix[]) this.f2134;
        float[] fArr2 = (float[]) this.f2128;
        C4199[] c4199Arr = (C4199[]) this.f2130;
        Matrix[] matrixArr2 = (Matrix[]) this.f2127;
        path.rewind();
        Path path2 = (Path) this.f2126;
        path2.rewind();
        Path path3 = (Path) this.f2125;
        path3.rewind();
        path3.addRect(rectF, Path.Direction.CW);
        int i2 = 0;
        while (true) {
            z = 0;
            if (i2 >= 4) {
                break;
            }
            PointF pointF = (PointF) this.f2123;
            InterfaceC2028 c1241 = fArr == null ? i2 != 1 ? i2 != 2 ? i2 != 3 ? c4879.f18174 : c4879.f18171 : c4879.f18181 : c4879.f18173 : new C1241(fArr[i2]);
            ᵲᵝᵪ r13 = i2 != 1 ? i2 != 2 ? i2 != 3 ? c4879.f18178 : c4879.f18177 : c4879.f18182 : c4879.f18175;
            C4199 c4199 = c4199Arr[i2];
            r13.getClass();
            Matrix[] matrixArr3 = matrixArr;
            r13.ᵤᵙᵷ(c4199, f, c1241.mo3779(rectF));
            int i3 = i2 + 1;
            float f3 = (i3 % 4) * 90;
            matrixArr2[i2].reset();
            if (i2 == 1) {
                pointF.set(rectF.right, rectF.bottom);
            } else if (i2 == 2) {
                pointF.set(rectF.left, rectF.bottom);
            } else if (i2 != 3) {
                pointF.set(rectF.right, rectF.top);
            } else {
                pointF.set(rectF.left, rectF.top);
            }
            matrixArr2[i2].setTranslate(pointF.x, pointF.y);
            matrixArr2[i2].preRotate(f3);
            C4199 c41992 = c4199Arr[i2];
            fArr2[0] = c41992.f15692;
            fArr2[1] = c41992.f15690;
            matrixArr2[i2].mapPoints(fArr2);
            matrixArr3[i2].reset();
            matrixArr3[i2].setTranslate(fArr2[0], fArr2[1]);
            matrixArr3[i2].preRotate(f3);
            i2 = i3;
            matrixArr = matrixArr3;
        }
        Matrix[] matrixArr4 = matrixArr;
        int i4 = 0;
        for (i = 4; i4 < i; i = 4) {
            C4199 c41993 = c4199Arr[i4];
            c41993.getClass();
            fArr2[z] = 0.0f;
            fArr2[1] = c41993.f15691;
            matrixArr2[i4].mapPoints(fArr2);
            if (i4 == 0) {
                path.moveTo(fArr2[z], fArr2[1]);
            } else {
                path.lineTo(fArr2[z], fArr2[1]);
            }
            c4199Arr[i4].m9125(matrixArr2[i4], path);
            if (r3 != null) {
                C4199 c41994 = c4199Arr[i4];
                Matrix matrix = matrixArr2[i4];
                C2445 c2445 = (C2445) r3.ᵢˇᵭ;
                BitSet bitSet = c2445.f9550;
                c41994.getClass();
                f2 = 0.0f;
                bitSet.set(i4, z);
                AbstractC5566[] abstractC5566Arr = c2445.f9559;
                c41994.m9124(c41994.f15687);
                abstractC5566Arr[i4] = new C1872(new ArrayList(c41994.f15688), new Matrix(matrix));
            } else {
                f2 = 0.0f;
            }
            Path path4 = (Path) this.f2132;
            C4199 c41995 = (C4199) this.f2133;
            int i5 = i4 + 1;
            int i6 = i5 % 4;
            C4199 c41996 = c4199Arr[i4];
            fArr2[0] = c41996.f15692;
            fArr2[1] = c41996.f15690;
            matrixArr2[i4].mapPoints(fArr2);
            float[] fArr3 = (float[]) this.f2131;
            C4199 c41997 = c4199Arr[i6];
            c41997.getClass();
            fArr3[0] = f2;
            fArr3[1] = c41997.f15691;
            matrixArr2[i6].mapPoints(fArr3);
            C4199[] c4199Arr2 = c4199Arr;
            Matrix[] matrixArr5 = matrixArr2;
            float fMax = Math.max(((float) Math.hypot(fArr2[0] - fArr3[0], fArr2[1] - fArr3[1])) - 0.001f, f2);
            C4199 c41998 = c4199Arr2[i4];
            fArr2[0] = c41998.f15692;
            fArr2[1] = c41998.f15690;
            matrixArr5[i4].mapPoints(fArr2);
            if (i4 == 1 || i4 == 3) {
                Math.abs(rectF.centerX() - fArr2[0]);
            } else {
                Math.abs(rectF.centerY() - fArr2[1]);
            }
            c41995.m9126(0.0f, 270.0f, 0.0f);
            (i4 != 1 ? i4 != 2 ? i4 != 3 ? c4879.f18179 : c4879.f18176 : c4879.f18172 : c4879.f18180).getClass();
            c41995.m9123(fMax, 0.0f);
            path4.reset();
            c41995.m9125(matrixArr4[i4], path4);
            if (this.f2129 && (m1789(path4, i4) || m1789(path4, i6))) {
                path4.op(path4, path3, Path.Op.DIFFERENCE);
                fArr2[0] = 0.0f;
                fArr2[1] = c41995.f15691;
                matrixArr4[i4].mapPoints(fArr2);
                path2.moveTo(fArr2[0], fArr2[1]);
                c41995.m9125(matrixArr4[i4], path2);
            } else {
                c41995.m9125(matrixArr4[i4], path);
            }
            if (r26 != null) {
                Matrix matrix2 = matrixArr4[i4];
                r8 = r26;
                C2445 c24452 = (C2445) r8.ᵢˇᵭ;
                z2 = false;
                c24452.f9550.set(i4 + 4, false);
                AbstractC5566[] abstractC5566Arr2 = c24452.f9558;
                c41995.m9124(c41995.f15687);
                abstractC5566Arr2[i4] = new C1872(new ArrayList(c41995.f15688), new Matrix(matrix2));
            } else {
                r8 = r26;
                z2 = false;
            }
            z = z2;
            r3 = r8;
            i4 = i5;
            c4199Arr = c4199Arr2;
            matrixArr2 = matrixArr5;
        }
        path.close();
        path2.close();
        if (path2.isEmpty()) {
            return;
        }
        path.op(path2, Path.Op.UNION);
    }

    /* renamed from: ᵶᵷᵕ, reason: contains not printable characters */
    public void m1795(int i, int i2) {
        ArrayList arrayList = (ArrayList) this.f2127;
        for (int i3 = i2 - 1; i3 >= i; i3--) {
            C0130 c0130 = (C0130) arrayList.remove(i3);
            ((HashMap) this.f2123).remove(c0130.f1462);
            int i4 = -c0130.f1461.f4843.f17542.mo2124();
            for (int i5 = i3; i5 < arrayList.size(); i5++) {
                ((C0130) arrayList.get(i5)).f1463 += i4;
            }
            c0130.f1459 = true;
            if (this.f2129) {
                m1790(c0130);
            }
        }
    }

    /* JADX WARN: Multi-variable type inference failed */
    /* JADX WARN: Type inference failed for: r1v0, types: [ᵠˑʞ, ᵸˆ] */
    /* renamed from: ᵹᵝᵶ, reason: contains not printable characters */
    public void m1796(C0130 c0130) {
        C1125 c1125 = c0130.f1461;
        ?? r1 = new InterfaceC3125() { // from class: ᵸˆ
            @Override // defpackage.InterfaceC3125
            /* renamed from: ᵥᵯˎ */
            public final void mo7470(AbstractC3587 abstractC3587, AbstractC0488 abstractC0488) {
                C5073 c5073 = ((C0911) this.f18423.f2125).f4140;
                c5073.m10535(2);
                c5073.m10536(22);
            }
        };
        C3118 c3118 = new C3118(this, c0130);
        ((HashMap) this.f2126).put(c0130, new C2141(c1125, r1, c3118));
        String str = AbstractC3558.f13329;
        Looper looperMyLooper = Looper.myLooper();
        if (looperMyLooper == null) {
            looperMyLooper = Looper.getMainLooper();
        }
        c1125.mo8196(new Handler(looperMyLooper, null), c3118);
        Looper looperMyLooper2 = Looper.myLooper();
        if (looperMyLooper2 == null) {
            looperMyLooper2 = Looper.getMainLooper();
        }
        c1125.mo8193(new Handler(looperMyLooper2, null), c3118);
        c1125.mo8199(r1, (C3873) this.f2124, (C1545) this.f2130);
    }

    /* renamed from: ᵻᵢﹳᵰ, reason: contains not printable characters */
    public void m1797() {
        Iterator it = ((HashSet) this.f2133).iterator();
        while (it.hasNext()) {
            C0130 c0130 = (C0130) it.next();
            if (c0130.f1460.isEmpty()) {
                C2141 c2141 = (C2141) ((HashMap) this.f2126).get(c0130);
                if (c2141 != null) {
                    c2141.f8433.mo8192(c2141.f8434);
                }
                it.remove();
            }
        }
    }
}
