package androidx.view;

import android.content.Context;
import android.content.res.TypedArray;
import android.util.AttributeSet;
import androidx.media3.container.NalUnitUtil;
import androidx.media3.exoplayer.upstream.CmcdData;
import androidx.view.ao;
import defpackage.bz8;
import defpackage.cr4;
import defpackage.f25;
import defpackage.li6;
import defpackage.rc1;
import defpackage.sg8;
import defpackage.st;
import defpackage.vo7;
import defpackage.vx8;
import defpackage.wy8;
import defpackage.y41;
import java.util.ArrayList;
import java.util.Iterator;
import kotlin.Metadata;

/* JADX INFO: loaded from: classes.dex */
@Metadata(d1 = {"\u0000\u0010\n\u0002\u0018\u0002\n\u0002\u0018\u0002\n\u0002\u0010\u001c\n\u0002\b\u0002\b\u0016\u0018\u00002\u00020\u00012\b\u0012\u0004\u0012\u00020\u00010\u0002:\u0001\u0003¨\u0006\u0004"}, d2 = {"Landroidx/navigation/at;", "Landroidx/navigation/ao;", "", CmcdData.OBJECT_TYPE_AUDIO_ONLY, "navigation-common_release"}, k = 1, mv = {1, 8, 0}, xi = NalUnitUtil.H265_NAL_UNIT_TYPE_UNSPECIFIED)
@vx8
public class at extends ao implements Iterable<ao>, f25 {
    public static final /* synthetic */ int p = 0;
    public final wy8 m;
    public int n;
    public String o;

    @Metadata(d1 = {"\u0000\n\n\u0002\u0018\u0002\n\u0002\u0010\u0000\n\u0000\b\u0086\u0003\u0018\u00002\u00020\u0001¨\u0006\u0002"}, d2 = {"Landroidx/navigation/at$a;", "", "navigation-common_release"}, k = 1, mv = {1, 8, 0}, xi = NalUnitUtil.H265_NAL_UNIT_TYPE_UNSPECIFIED)
    public static final class a {
        public static ao a(at atVar) {
            cr4.g(atVar, "<this>");
            return (ao) sg8.m(sg8.j(as.a, atVar.h(atVar.n, true)));
        }
    }

    public at(au auVar) {
        super(auVar);
        this.m = new wy8();
    }

    @Override // androidx.view.ao
    public final ao.c e(an anVar) {
        ao.c cVarE = super.e(anVar);
        ArrayList arrayList = new ArrayList();
        Iterator<ao> it = iterator();
        while (it.hasNext()) {
            ao.c cVarE2 = it.next().e(anVar);
            if (cVarE2 != null) {
                arrayList.add(cVarE2);
            }
        }
        return (ao.c) y41.ap(st.w(new ao.c[]{cVarE, (ao.c) y41.ap(arrayList)}));
    }

    @Override // androidx.view.ao
    public final boolean equals(Object obj) {
        if (this == obj) {
            return true;
        }
        if (obj == null || !(obj instanceof at) || !super.equals(obj)) {
            return false;
        }
        wy8 wy8Var = this.m;
        int iF = wy8Var.f();
        at atVar = (at) obj;
        wy8 wy8Var2 = atVar.m;
        if (iF != wy8Var2.f() || this.n != atVar.n) {
            return false;
        }
        for (ao aoVar : (rc1) sg8.b(new bz8(wy8Var))) {
            if (!aoVar.equals(wy8Var2.c(aoVar.j))) {
                return false;
            }
        }
        return true;
    }

    @Override // androidx.view.ao
    public final void f(Context context, AttributeSet attributeSet) {
        super.f(context, attributeSet);
        TypedArray typedArrayObtainAttributes = context.getResources().obtainAttributes(attributeSet, vo7.b.d);
        cr4.f(typedArrayObtainAttributes, "context.resources.obtain…vGraphNavigator\n        )");
        int resourceId = typedArrayObtainAttributes.getResourceId(0, 0);
        if (resourceId != this.j) {
            this.n = resourceId;
            this.o = null;
            this.o = ao.b.a(context, resourceId);
            typedArrayObtainAttributes.recycle();
            return;
        }
        throw new IllegalArgumentException(("Start destination " + resourceId + " cannot use the same id as the graph " + this).toString());
    }

    public final void g(ao aoVar) {
        cr4.g(aoVar, "node");
        int i = aoVar.j;
        String str = aoVar.k;
        if (i == 0 && str == null) {
            throw new IllegalArgumentException("Destinations must have an id or route. Call setId(), setRoute(), or include an android:id or app:route in your navigation XML.");
        }
        String str2 = this.k;
        if (str2 != null && cr4.b(str, str2)) {
            throw new IllegalArgumentException(("Destination " + aoVar + " cannot have the same route as graph " + this).toString());
        }
        if (i == this.j) {
            throw new IllegalArgumentException(("Destination " + aoVar + " cannot have the same id as graph " + this).toString());
        }
        wy8 wy8Var = this.m;
        ao aoVar2 = (ao) wy8Var.c(i);
        if (aoVar2 == aoVar) {
            return;
        }
        if (aoVar.b != null) {
            throw new IllegalStateException("Destination already has a parent set. Call NavGraph.remove() to remove the previous parent.");
        }
        if (aoVar2 != null) {
            aoVar2.b = null;
        }
        aoVar.b = this;
        wy8Var.e(aoVar.j, aoVar);
    }

    public final ao h(int i, boolean z) {
        at atVar;
        ao aoVar = (ao) this.m.c(i);
        if (aoVar != null) {
            return aoVar;
        }
        if (!z || (atVar = this.b) == null) {
            return null;
        }
        return atVar.h(i, true);
    }

    @Override // androidx.view.ao
    public final int hashCode() {
        int iD = this.n;
        wy8 wy8Var = this.m;
        int iF = wy8Var.f();
        for (int i = 0; i < iF; i++) {
            iD = (((iD * 31) + wy8Var.d(i)) * 31) + ((ao) wy8Var.g(i)).hashCode();
        }
        return iD;
    }

    @Override // java.lang.Iterable
    public final Iterator<ao> iterator() {
        return new li6(this);
    }

    @Override // androidx.view.ao
    public final String toString() {
        StringBuilder sb = new StringBuilder();
        sb.append(super.toString());
        ao aoVarH = h(this.n, true);
        sb.append(" startDestination=");
        if (aoVarH == null) {
            String str = this.o;
            if (str != null) {
                sb.append(str);
            } else {
                sb.append("0x" + Integer.toHexString(this.n));
            }
        } else {
            sb.append("{");
            sb.append(aoVarH.toString());
            sb.append("}");
        }
        String string = sb.toString();
        cr4.f(string, "sb.toString()");
        return string;
    }
}
