package androidx.activity.result;

import java.util.ArrayList;

/* JADX INFO: loaded from: classes.dex */
public final class h extends d {

    /* JADX INFO: renamed from: a, reason: collision with root package name */
    public final /* synthetic */ int f515a;

    /* JADX INFO: renamed from: b, reason: collision with root package name */
    public final /* synthetic */ i f516b;

    /* JADX INFO: renamed from: c, reason: collision with root package name */
    public final /* synthetic */ String f517c;

    /* JADX INFO: renamed from: d, reason: collision with root package name */
    public final /* synthetic */ b.a f518d;

    public /* synthetic */ h(i iVar, String str, b.a aVar, int i10) {
        this.f515a = i10;
        this.f516b = iVar;
        this.f517c = str;
        this.f518d = aVar;
    }

    public final void a() {
        int i10 = this.f515a;
        String str = this.f517c;
        i iVar = this.f516b;
        switch (i10) {
            case 0:
                iVar.f(str);
                break;
            default:
                iVar.f(str);
                break;
        }
    }

    @Override // androidx.activity.result.d
    public final void launch(Object obj, androidx.core.app.h hVar) {
        int i10 = this.f515a;
        b.a aVar = this.f518d;
        String str = this.f517c;
        i iVar = this.f516b;
        switch (i10) {
            case 0:
                Object obj2 = iVar.f520b.get(str);
                if (obj2 == null) {
                    throw new IllegalStateException(("Attempting to launch an unregistered ActivityResultLauncher with contract " + aVar + " and input " + obj + ". You must ensure the ActivityResultLauncher is registered before calling launch().").toString());
                }
                int iIntValue = ((Number) obj2).intValue();
                ArrayList arrayList = iVar.f522d;
                arrayList.add(str);
                try {
                    iVar.b(iIntValue, aVar, obj, hVar);
                    return;
                } catch (Exception e10) {
                    arrayList.remove(str);
                    throw e10;
                }
            default:
                Object obj3 = iVar.f520b.get(str);
                if (obj3 == null) {
                    throw new IllegalStateException(("Attempting to launch an unregistered ActivityResultLauncher with contract " + aVar + " and input " + obj + ". You must ensure the ActivityResultLauncher is registered before calling launch().").toString());
                }
                int iIntValue2 = ((Number) obj3).intValue();
                ArrayList arrayList2 = iVar.f522d;
                arrayList2.add(str);
                try {
                    iVar.b(iIntValue2, aVar, obj, hVar);
                    return;
                } catch (Exception e11) {
                    arrayList2.remove(str);
                    throw e11;
                }
        }
    }
}
