package p012d1;

import java.io.Serializable;
import p012d1.InterfaceC0633f;
import p036l1.InterfaceC1436p;
import p039m1.AbstractC1471h;
import p039m1.C1470g;

/* renamed from: d1.c */
/* loaded from: classes.dex */
public final class C0627c implements InterfaceC0633f, Serializable {

    /* renamed from: d */
    public final InterfaceC0633f f2156d;

    /* renamed from: e */
    public final InterfaceC0633f.InterfaceC0636b f2157e;

    /* renamed from: d1.c$a */
    /* loaded from: classes.dex */
    public static final class C0628a extends AbstractC1471h implements InterfaceC1436p<String, InterfaceC0633f.InterfaceC0636b, String> {

        /* renamed from: e */
        public static final C0628a f2158e = new C0628a();

        public C0628a() {
            super(2);
        }

        @Override // p036l1.InterfaceC1436p
        /* renamed from: c */
        public final String mo1385b(String str, InterfaceC0633f.InterfaceC0636b interfaceC0636b) {
            C1470g.m1292e(str, "acc");
            C1470g.m1292e(interfaceC0636b, "element");
            if (str.length() == 0) {
                return interfaceC0636b.toString();
            }
            return str + ", " + interfaceC0636b;
        }
    }

    public C0627c(InterfaceC0633f interfaceC0633f, InterfaceC0633f.InterfaceC0636b interfaceC0636b) {
        C1470g.m1292e(interfaceC0633f, "left");
        C1470g.m1292e(interfaceC0636b, "element");
        this.f2156d = interfaceC0633f;
        this.f2157e = interfaceC0636b;
    }

    /* renamed from: d */
    public final boolean m3242d(InterfaceC0633f.InterfaceC0636b interfaceC0636b) {
        return C1470g.m1296a(get(interfaceC0636b.getKey()), interfaceC0636b);
    }

    public boolean equals(Object obj) {
        if (this != obj) {
            if (obj instanceof C0627c) {
                C0627c c0627c = (C0627c) obj;
                if (c0627c.m3240i() != m3240i() || !c0627c.m3241f(this)) {
                }
            }
            return false;
        }
        return true;
    }

    /* renamed from: f */
    public final boolean m3241f(C0627c c0627c) {
        while (m3242d(c0627c.f2157e)) {
            InterfaceC0633f interfaceC0633f = c0627c.f2156d;
            if (!(interfaceC0633f instanceof C0627c)) {
                C1470g.m1294c(interfaceC0633f, "null cannot be cast to non-null type kotlin.coroutines.CoroutineContext.Element");
                return m3242d((InterfaceC0633f.InterfaceC0636b) interfaceC0633f);
            }
            c0627c = (C0627c) interfaceC0633f;
        }
        return false;
    }

    @Override // p012d1.InterfaceC0633f
    public <R> R fold(R r, InterfaceC1436p<? super R, ? super InterfaceC0633f.InterfaceC0636b, ? extends R> interfaceC1436p) {
        C1470g.m1292e(interfaceC1436p, "operation");
        return interfaceC1436p.mo1385b((Object) this.f2156d.fold(r, interfaceC1436p), this.f2157e);
    }

    @Override // p012d1.InterfaceC0633f
    public <E extends InterfaceC0633f.InterfaceC0636b> E get(InterfaceC0633f.InterfaceC0638c<E> interfaceC0638c) {
        C1470g.m1292e(interfaceC0638c, "key");
        C0627c c0627c = this;
        while (true) {
            E e = (E) c0627c.f2157e.get(interfaceC0638c);
            if (e != null) {
                return e;
            }
            InterfaceC0633f interfaceC0633f = c0627c.f2156d;
            if (!(interfaceC0633f instanceof C0627c)) {
                return (E) interfaceC0633f.get(interfaceC0638c);
            }
            c0627c = (C0627c) interfaceC0633f;
        }
    }

    public int hashCode() {
        return this.f2156d.hashCode() + this.f2157e.hashCode();
    }

    /* renamed from: i */
    public final int m3240i() {
        int i = 2;
        C0627c c0627c = this;
        while (true) {
            InterfaceC0633f interfaceC0633f = c0627c.f2156d;
            c0627c = interfaceC0633f instanceof C0627c ? (C0627c) interfaceC0633f : null;
            if (c0627c == null) {
                return i;
            }
            i++;
        }
    }

    @Override // p012d1.InterfaceC0633f
    public InterfaceC0633f minusKey(InterfaceC0633f.InterfaceC0638c<?> interfaceC0638c) {
        C1470g.m1292e(interfaceC0638c, "key");
        if (this.f2157e.get(interfaceC0638c) != null) {
            return this.f2156d;
        }
        InterfaceC0633f minusKey = this.f2156d.minusKey(interfaceC0638c);
        return minusKey == this.f2156d ? this : minusKey == C0639g.f2162d ? this.f2157e : new C0627c(minusKey, this.f2157e);
    }

    public String toString() {
        return '[' + ((String) fold("", C0628a.f2158e)) + ']';
    }
}