package d3;

import B0.C0016c;
import android.net.Uri;
import android.os.Bundle;
import android.text.TextUtils;
import android.util.Pair;

/* JADX INFO: loaded from: classes.dex */
public final /* synthetic */ class N0 implements Runnable {

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

    /* JADX INFO: renamed from: r, reason: collision with root package name */
    public final /* synthetic */ Y0 f11628r;

    public /* synthetic */ N0(Y0 y02, int i) {
        this.f11627q = i;
        this.f11628r = y02;
    }

    @Override // java.lang.Runnable
    public final void run() {
        switch (this.f11627q) {
            case n4.u0.f15495q /* 0 */:
                Y0 y02 = this.f11628r;
                y02.E();
                C0817r0 c0817r0 = (C0817r0) y02.f5146q;
                C0785g0 c0785g0 = c0817r0.f12149x;
                C0817r0.i(c0785g0);
                boolean zB = c0785g0.f11965K.b();
                Z z8 = c0817r0.f12150y;
                if (zB) {
                    C0817r0.k(z8);
                    z8.f11871C.b("Deferred Deep Link already retrieved. Not fetching again.");
                } else {
                    C0785g0 c0785g02 = c0817r0.f12149x;
                    C0817r0.i(c0785g02);
                    B0.s0 s0Var = c0785g02.f11966L;
                    long jG = s0Var.g();
                    s0Var.h(1 + jG);
                    if (jG >= 5) {
                        C0817r0.k(z8);
                        z8.f11878y.b("Permanently failed to retrieve Deferred Deep Link. Reached maximum retries.");
                        c0785g02.f11965K.a(true);
                    } else {
                        if (y02.f11849J == null) {
                            y02.f11849J = new P0(y02, c0817r0, 3);
                        }
                        y02.f11849J.c(0L);
                    }
                }
                break;
            case 1:
                this.f11628r.M();
                break;
            case 2:
                C0791i0 c0791i0 = this.f11628r.H;
                C0817r0 c0817r02 = c0791i0.f12005r;
                C0815q0 c0815q0 = c0817r02.f12151z;
                C0817r0.k(c0815q0);
                c0815q0.E();
                if (c0791i0.d()) {
                    boolean zE = c0791i0.e();
                    Y0 y03 = c0817r02.f12125F;
                    C0785g0 c0785g03 = c0817r02.f12149x;
                    if (zE) {
                        C0817r0.i(c0785g03);
                        c0785g03.f11968N.g(null);
                        Bundle bundle = new Bundle();
                        bundle.putString("source", "(not set)");
                        bundle.putString("medium", "(not set)");
                        bundle.putString("_cis", "intent");
                        bundle.putLong("_cc", 1L);
                        C0817r0.j(y03);
                        y03.P("auto", "_cmpx", bundle);
                    } else {
                        C0817r0.i(c0785g03);
                        C0016c c0016c = c0785g03.f11968N;
                        String strF = c0016c.f();
                        if (TextUtils.isEmpty(strF)) {
                            Z z9 = c0817r02.f12150y;
                            C0817r0.k(z9);
                            z9.f11876w.b("Cache still valid but referrer not found");
                        } else {
                            long jG2 = c0785g03.f11969O.g() / 3600000;
                            Uri uri = Uri.parse(strF);
                            Bundle bundle2 = new Bundle();
                            Pair pair = new Pair(uri.getPath(), bundle2);
                            for (String str : uri.getQueryParameterNames()) {
                                bundle2.putString(str, uri.getQueryParameter(str));
                            }
                            ((Bundle) pair.second).putLong("_cc", (jG2 - 1) * 3600000);
                            Object obj = pair.first;
                            String str2 = obj == null ? "app" : (String) obj;
                            C0817r0.j(y03);
                            y03.P(str2, "_cmp", (Bundle) pair.second);
                        }
                        c0016c.g(null);
                    }
                    C0817r0.i(c0785g03);
                    c0785g03.f11969O.h(0L);
                    break;
                }
                break;
            default:
                this.f11628r.M();
                break;
        }
    }
}
