package h0;

import android.util.Log;
import i0.AbstractC1048d;
import java.io.PrintWriter;
import java.lang.reflect.Modifier;
import java.util.ArrayList;
import n4.u0;

/* JADX INFO: renamed from: h0.a, reason: case insensitive filesystem */
/* JADX INFO: loaded from: classes.dex */
public final class C1001a implements L {

    /* JADX INFO: renamed from: a, reason: collision with root package name */
    public final ArrayList f13144a;

    /* JADX INFO: renamed from: b, reason: collision with root package name */
    public int f13145b;

    /* JADX INFO: renamed from: c, reason: collision with root package name */
    public int f13146c;

    /* JADX INFO: renamed from: d, reason: collision with root package name */
    public int f13147d;

    /* JADX INFO: renamed from: e, reason: collision with root package name */
    public int f13148e;

    /* JADX INFO: renamed from: f, reason: collision with root package name */
    public int f13149f;

    /* JADX INFO: renamed from: g, reason: collision with root package name */
    public boolean f13150g;

    /* JADX INFO: renamed from: h, reason: collision with root package name */
    public boolean f13151h;
    public String i;

    /* JADX INFO: renamed from: j, reason: collision with root package name */
    public int f13152j;

    /* JADX INFO: renamed from: k, reason: collision with root package name */
    public CharSequence f13153k;

    /* JADX INFO: renamed from: l, reason: collision with root package name */
    public int f13154l;

    /* JADX INFO: renamed from: m, reason: collision with root package name */
    public CharSequence f13155m;

    /* JADX INFO: renamed from: n, reason: collision with root package name */
    public ArrayList f13156n;

    /* JADX INFO: renamed from: o, reason: collision with root package name */
    public ArrayList f13157o;

    /* JADX INFO: renamed from: p, reason: collision with root package name */
    public boolean f13158p;

    /* JADX INFO: renamed from: q, reason: collision with root package name */
    public ArrayList f13159q;

    /* JADX INFO: renamed from: r, reason: collision with root package name */
    public final P f13160r;

    /* JADX INFO: renamed from: s, reason: collision with root package name */
    public boolean f13161s;

    /* JADX INFO: renamed from: t, reason: collision with root package name */
    public int f13162t;

    /* JADX INFO: renamed from: u, reason: collision with root package name */
    public boolean f13163u;

    /* JADX WARN: 'this' call moved to the top of the method (can break code semantics) */
    public C1001a(P p3) {
        this();
        p3.I();
        C1025z c1025z = p3.f13088w;
        if (c1025z != null) {
            c1025z.f13306u.getClassLoader();
        }
        this.f13162t = -1;
        this.f13163u = false;
        this.f13160r = p3;
    }

    @Override // h0.L
    public final boolean a(ArrayList arrayList, ArrayList arrayList2) {
        if (P.L(2)) {
            Log.v("FragmentManager", "Run: " + this);
        }
        arrayList.add(this);
        arrayList2.add(Boolean.FALSE);
        if (!this.f13150g) {
            return true;
        }
        this.f13160r.f13070d.add(this);
        return true;
    }

    public final void b(X x8) {
        this.f13144a.add(x8);
        x8.f13131d = this.f13145b;
        x8.f13132e = this.f13146c;
        x8.f13133f = this.f13147d;
        x8.f13134g = this.f13148e;
    }

    public final void c(String str) {
        if (!this.f13151h) {
            throw new IllegalStateException("This FragmentTransaction is not allowed to be added to the back stack.");
        }
        this.f13150g = true;
        this.i = str;
    }

    public final void d(int i) {
        if (this.f13150g) {
            if (P.L(2)) {
                Log.v("FragmentManager", "Bump nesting in " + this + " by " + i);
            }
            ArrayList arrayList = this.f13144a;
            int size = arrayList.size();
            for (int i5 = 0; i5 < size; i5++) {
                X x8 = (X) arrayList.get(i5);
                ComponentCallbacksC1023x componentCallbacksC1023x = x8.f13129b;
                if (componentCallbacksC1023x != null) {
                    componentCallbacksC1023x.f13264J += i;
                    if (P.L(2)) {
                        Log.v("FragmentManager", "Bump nesting of " + x8.f13129b + " to " + x8.f13129b.f13264J);
                    }
                }
            }
        }
    }

    public final void e() {
        ArrayList arrayList = this.f13144a;
        int size = arrayList.size() - 1;
        while (size >= 0) {
            X x8 = (X) arrayList.get(size);
            if (x8.f13130c) {
                if (x8.f13128a == 8) {
                    x8.f13130c = false;
                    arrayList.remove(size - 1);
                    size--;
                } else {
                    int i = x8.f13129b.f13270P;
                    x8.f13128a = 2;
                    x8.f13130c = false;
                    for (int i5 = size - 1; i5 >= 0; i5--) {
                        X x9 = (X) arrayList.get(i5);
                        if (x9.f13130c && x9.f13129b.f13270P == i) {
                            arrayList.remove(i5);
                            size--;
                        }
                    }
                }
            }
            size--;
        }
    }

    public final void f() {
        g(false, true);
    }

    public final int g(boolean z8, boolean z9) {
        if (this.f13161s) {
            throw new IllegalStateException("commit already called");
        }
        if (P.L(2)) {
            Log.v("FragmentManager", "Commit: " + this);
            PrintWriter printWriter = new PrintWriter(new Z());
            i("  ", printWriter, true);
            printWriter.close();
        }
        this.f13161s = true;
        boolean z10 = this.f13150g;
        P p3 = this.f13160r;
        if (z10) {
            this.f13162t = p3.f13076k.getAndIncrement();
        } else {
            this.f13162t = -1;
        }
        if (z9) {
            p3.x(this, z8);
        }
        return this.f13162t;
    }

    public final void h(int i, ComponentCallbacksC1023x componentCallbacksC1023x, String str, int i5) {
        String str2 = componentCallbacksC1023x.f13283d0;
        if (str2 != null) {
            AbstractC1048d.c(componentCallbacksC1023x, str2);
        }
        Class<?> cls = componentCallbacksC1023x.getClass();
        int modifiers = cls.getModifiers();
        if (cls.isAnonymousClass() || !Modifier.isPublic(modifiers) || (cls.isMemberClass() && !Modifier.isStatic(modifiers))) {
            throw new IllegalStateException("Fragment " + cls.getCanonicalName() + " must be a public static class to be  properly recreated from instance state.");
        }
        if (str != null) {
            String str3 = componentCallbacksC1023x.f13271Q;
            if (str3 != null && !str.equals(str3)) {
                throw new IllegalStateException("Can't change tag of fragment " + componentCallbacksC1023x + ": was " + componentCallbacksC1023x.f13271Q + " now " + str);
            }
            componentCallbacksC1023x.f13271Q = str;
        }
        if (i != 0) {
            if (i == -1) {
                throw new IllegalArgumentException("Can't add fragment " + componentCallbacksC1023x + " with tag " + str + " to container view with no id");
            }
            int i8 = componentCallbacksC1023x.f13269O;
            if (i8 != 0 && i8 != i) {
                throw new IllegalStateException("Can't change container ID of fragment " + componentCallbacksC1023x + ": was " + componentCallbacksC1023x.f13269O + " now " + i);
            }
            componentCallbacksC1023x.f13269O = i;
            componentCallbacksC1023x.f13270P = i;
        }
        b(new X(i5, componentCallbacksC1023x));
        componentCallbacksC1023x.f13265K = this.f13160r;
    }

    public final void i(String str, PrintWriter printWriter, boolean z8) {
        String str2;
        if (z8) {
            printWriter.print(str);
            printWriter.print("mName=");
            printWriter.print(this.i);
            printWriter.print(" mIndex=");
            printWriter.print(this.f13162t);
            printWriter.print(" mCommitted=");
            printWriter.println(this.f13161s);
            if (this.f13149f != 0) {
                printWriter.print(str);
                printWriter.print("mTransition=#");
                printWriter.print(Integer.toHexString(this.f13149f));
            }
            if (this.f13145b != 0 || this.f13146c != 0) {
                printWriter.print(str);
                printWriter.print("mEnterAnim=#");
                printWriter.print(Integer.toHexString(this.f13145b));
                printWriter.print(" mExitAnim=#");
                printWriter.println(Integer.toHexString(this.f13146c));
            }
            if (this.f13147d != 0 || this.f13148e != 0) {
                printWriter.print(str);
                printWriter.print("mPopEnterAnim=#");
                printWriter.print(Integer.toHexString(this.f13147d));
                printWriter.print(" mPopExitAnim=#");
                printWriter.println(Integer.toHexString(this.f13148e));
            }
            if (this.f13152j != 0 || this.f13153k != null) {
                printWriter.print(str);
                printWriter.print("mBreadCrumbTitleRes=#");
                printWriter.print(Integer.toHexString(this.f13152j));
                printWriter.print(" mBreadCrumbTitleText=");
                printWriter.println(this.f13153k);
            }
            if (this.f13154l != 0 || this.f13155m != null) {
                printWriter.print(str);
                printWriter.print("mBreadCrumbShortTitleRes=#");
                printWriter.print(Integer.toHexString(this.f13154l));
                printWriter.print(" mBreadCrumbShortTitleText=");
                printWriter.println(this.f13155m);
            }
        }
        ArrayList arrayList = this.f13144a;
        if (arrayList.isEmpty()) {
            return;
        }
        printWriter.print(str);
        printWriter.println("Operations:");
        int size = arrayList.size();
        for (int i = 0; i < size; i++) {
            X x8 = (X) arrayList.get(i);
            switch (x8.f13128a) {
                case u0.f15495q /* 0 */:
                    str2 = "NULL";
                    break;
                case 1:
                    str2 = "ADD";
                    break;
                case 2:
                    str2 = "REPLACE";
                    break;
                case 3:
                    str2 = "REMOVE";
                    break;
                case 4:
                    str2 = "HIDE";
                    break;
                case 5:
                    str2 = "SHOW";
                    break;
                case Z.g.STRING_SET_FIELD_NUMBER /* 6 */:
                    str2 = "DETACH";
                    break;
                case Z.g.DOUBLE_FIELD_NUMBER /* 7 */:
                    str2 = "ATTACH";
                    break;
                case Z.g.BYTES_FIELD_NUMBER /* 8 */:
                    str2 = "SET_PRIMARY_NAV";
                    break;
                case 9:
                    str2 = "UNSET_PRIMARY_NAV";
                    break;
                case 10:
                    str2 = "OP_SET_MAX_LIFECYCLE";
                    break;
                default:
                    str2 = "cmd=" + x8.f13128a;
                    break;
            }
            printWriter.print(str);
            printWriter.print("  Op #");
            printWriter.print(i);
            printWriter.print(": ");
            printWriter.print(str2);
            printWriter.print(" ");
            printWriter.println(x8.f13129b);
            if (z8) {
                if (x8.f13131d != 0 || x8.f13132e != 0) {
                    printWriter.print(str);
                    printWriter.print("enterAnim=#");
                    printWriter.print(Integer.toHexString(x8.f13131d));
                    printWriter.print(" exitAnim=#");
                    printWriter.println(Integer.toHexString(x8.f13132e));
                }
                if (x8.f13133f != 0 || x8.f13134g != 0) {
                    printWriter.print(str);
                    printWriter.print("popEnterAnim=#");
                    printWriter.print(Integer.toHexString(x8.f13133f));
                    printWriter.print(" popExitAnim=#");
                    printWriter.println(Integer.toHexString(x8.f13134g));
                }
            }
        }
    }

    public final void j(int i, ComponentCallbacksC1023x componentCallbacksC1023x) {
        if (i == 0) {
            throw new IllegalArgumentException("Must use non-zero containerViewId");
        }
        h(i, componentCallbacksC1023x, null, 2);
    }

    public final void k(ComponentCallbacksC1023x componentCallbacksC1023x) {
        P p3 = componentCallbacksC1023x.f13265K;
        if (p3 == null || p3 == this.f13160r) {
            b(new X(8, componentCallbacksC1023x));
            return;
        }
        throw new IllegalStateException("Cannot setPrimaryNavigation for Fragment attached to a different FragmentManager. Fragment " + componentCallbacksC1023x.toString() + " is already attached to a FragmentManager.");
    }

    public final String toString() {
        StringBuilder sb = new StringBuilder(128);
        sb.append("BackStackEntry{");
        sb.append(Integer.toHexString(System.identityHashCode(this)));
        if (this.f13162t >= 0) {
            sb.append(" #");
            sb.append(this.f13162t);
        }
        if (this.i != null) {
            sb.append(" ");
            sb.append(this.i);
        }
        sb.append("}");
        return sb.toString();
    }

    /* JADX WARN: 'this' call moved to the top of the method (can break code semantics) */
    public C1001a(C1001a c1001a) {
        this();
        c1001a.f13160r.I();
        C1025z c1025z = c1001a.f13160r.f13088w;
        if (c1025z != null) {
            c1025z.f13306u.getClassLoader();
        }
        ArrayList arrayList = c1001a.f13144a;
        int size = arrayList.size();
        int i = 0;
        while (i < size) {
            Object obj = arrayList.get(i);
            i++;
            X x8 = (X) obj;
            ArrayList arrayList2 = this.f13144a;
            X x9 = new X();
            x9.f13128a = x8.f13128a;
            x9.f13129b = x8.f13129b;
            x9.f13130c = x8.f13130c;
            x9.f13131d = x8.f13131d;
            x9.f13132e = x8.f13132e;
            x9.f13133f = x8.f13133f;
            x9.f13134g = x8.f13134g;
            x9.f13135h = x8.f13135h;
            x9.i = x8.i;
            arrayList2.add(x9);
        }
        this.f13145b = c1001a.f13145b;
        this.f13146c = c1001a.f13146c;
        this.f13147d = c1001a.f13147d;
        this.f13148e = c1001a.f13148e;
        this.f13149f = c1001a.f13149f;
        this.f13150g = c1001a.f13150g;
        this.f13151h = c1001a.f13151h;
        this.i = c1001a.i;
        this.f13154l = c1001a.f13154l;
        this.f13155m = c1001a.f13155m;
        this.f13152j = c1001a.f13152j;
        this.f13153k = c1001a.f13153k;
        if (c1001a.f13156n != null) {
            ArrayList arrayList3 = new ArrayList();
            this.f13156n = arrayList3;
            arrayList3.addAll(c1001a.f13156n);
        }
        if (c1001a.f13157o != null) {
            ArrayList arrayList4 = new ArrayList();
            this.f13157o = arrayList4;
            arrayList4.addAll(c1001a.f13157o);
        }
        this.f13158p = c1001a.f13158p;
        this.f13162t = -1;
        this.f13163u = false;
        this.f13160r = c1001a.f13160r;
        this.f13161s = c1001a.f13161s;
        this.f13162t = c1001a.f13162t;
        this.f13163u = c1001a.f13163u;
    }

    public C1001a() {
        this.f13144a = new ArrayList();
        this.f13151h = true;
        this.f13158p = false;
    }
}
