package Y2;

import V2.C0736x;
import V4.C;
import V4.E;
import android.content.Context;
import com.google.firebase.sessions.settings.RemoteSettings;
import j$.time.LocalDate;
import j$.time.ZoneId;
import java.io.EOFException;
import m3.AbstractC2467b;
import w4.C3137A;
import x4.AbstractC3251q;

/* JADX INFO: loaded from: classes.dex */
public final class j extends C4.j implements J4.e {

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

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

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

    /* JADX INFO: renamed from: d, reason: collision with root package name */
    public final /* synthetic */ o f8753d;

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

    /* JADX INFO: renamed from: f, reason: collision with root package name */
    public final /* synthetic */ boolean f8755f;

    /* JADX INFO: renamed from: j, reason: collision with root package name */
    public final /* synthetic */ Integer f8756j;

    /* JADX INFO: renamed from: k, reason: collision with root package name */
    public final /* synthetic */ Integer f8757k;

    /* JADX WARN: 'super' call moved to the top of the method (can break code semantics) */
    public j(int i6, int i7, String str, o oVar, String str2, boolean z6, Integer num, Integer num2, A4.d dVar) {
        super(2, dVar);
        this.f8750a = i6;
        this.f8751b = i7;
        this.f8752c = str;
        this.f8753d = oVar;
        this.f8754e = str2;
        this.f8755f = z6;
        this.f8756j = num;
        this.f8757k = num2;
    }

    @Override // C4.a
    public final A4.d create(Object obj, A4.d dVar) {
        return new j(this.f8750a, this.f8751b, this.f8752c, this.f8753d, this.f8754e, this.f8755f, this.f8756j, this.f8757k, dVar);
    }

    @Override // J4.e
    public final Object invoke(Object obj, Object obj2) {
        return ((j) create((C) obj, (A4.d) obj2)).invokeSuspend(C3137A.f25453a);
    }

    /* JADX WARN: Removed duplicated region for block: B:10:0x004d  */
    @Override // C4.a
    /*
        Code decompiled incorrectly, please refer to instructions dump.
    */
    public final Object invokeSuspend(Object obj) throws EOFException {
        Object objD;
        Object objD2;
        t tVar;
        t tVarW0;
        B4.a aVar = B4.a.f492a;
        AbstractC2467b.l(obj);
        if (this.f8750a < 1) {
            throw new IllegalArgumentException("Trakt page must be >= 1");
        }
        int i6 = this.f8751b;
        if (1 > i6 || i6 >= 101) {
            throw new IllegalArgumentException("Trakt limit must be 1..100");
        }
        String strM0 = AbstractC3251q.m0(S4.p.d1(this.f8752c, new String[]{RemoteSettings.FORWARD_SLASH_STRING}, 6), RemoteSettings.FORWARD_SLASH_STRING, null, null, new C0736x(24), 30);
        o oVar = this.f8753d;
        String str = this.f8754e;
        int i7 = this.f8750a;
        int i8 = this.f8751b;
        a5.c cVar = o.f8777b;
        oVar.getClass();
        String url = o.g(i7, i8, strM0, str);
        kotlin.jvm.internal.o.h(url, "url");
        Context context = W.b.f8366i;
        if (context == null) {
            tVar = null;
        } else {
            try {
                objD = context.getSharedPreferences("debridstream_trakt_catalog_list_cache", 0).getString(url, null);
            } catch (Throwable th) {
                objD = AbstractC2467b.d(th);
            }
            if (objD instanceof w4.m) {
                objD = null;
            }
            String str2 = (String) objD;
            if (str2 != null && !S4.p.Q0(str2)) {
                String string = LocalDate.now(ZoneId.systemDefault()).toString();
                kotlin.jvm.internal.o.g(string, "toString(...)");
                try {
                    objD2 = W.b.u0(str2, string);
                } catch (Throwable th2) {
                    objD2 = AbstractC2467b.d(th2);
                }
                if (objD2 instanceof w4.m) {
                    objD2 = null;
                }
                tVar = (t) objD2;
            }
        }
        if (tVar != null) {
            return q.c(tVar, this.f8755f, this.f8756j, this.f8757k);
        }
        if (this.f8750a == 1 && (tVarW0 = W.b.w0(url)) != null) {
            o oVar2 = this.f8753d;
            String str3 = this.f8754e;
            int i9 = this.f8750a;
            int i10 = this.f8751b;
            boolean z6 = this.f8755f;
            Integer num = this.f8756j;
            Integer num2 = this.f8757k;
            oVar2.getClass();
            if (o.f8778c.add(url)) {
                E.y(o.f8777b, null, null, new l(oVar2, strM0, str3, i9, i10, url, null), 3);
            }
            return q.c(tVarW0, z6, num, num2);
        }
        t tVarI = this.f8753d.i(this.f8750a, this.f8751b, url, url);
        t tVarW02 = W.b.w0(url);
        o oVar3 = this.f8753d;
        int i11 = this.f8750a;
        int i12 = this.f8751b;
        oVar3.getClass();
        if (i11 == 1 && i12 == 100 && tVarI.f8789a.isEmpty() && tVarW02 == null) {
            o oVar4 = this.f8753d;
            String str4 = this.f8754e;
            int i13 = this.f8750a;
            oVar4.getClass();
            t tVarI2 = this.f8753d.i(this.f8750a, 99, o.g(i13, 99, strM0, str4), url);
            if (!tVarI2.f8789a.isEmpty()) {
                return q.c(tVarI2, this.f8755f, this.f8756j, this.f8757k);
            }
        }
        return q.c(tVarI, this.f8755f, this.f8756j, this.f8757k);
    }
}
