package V2;

import android.content.Context;
import m3.AbstractC2467b;
import s2.SharedPreferencesC2907b;
import w4.C3137A;

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

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

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

    /* JADX WARN: 'super' call moved to the top of the method (can break code semantics) */
    public W2(Context context, String str, A4.d dVar) {
        super(2, dVar);
        this.f7607a = context;
        this.f7608b = str;
    }

    @Override // C4.a
    public final A4.d create(Object obj, A4.d dVar) {
        return new W2(this.f7607a, this.f7608b, dVar);
    }

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

    @Override // C4.a
    public final Object invokeSuspend(Object obj) {
        Object objD;
        B4.a aVar = B4.a.f492a;
        AbstractC2467b.l(obj);
        C0716s c0716s = C0716s.f8049a;
        Context context = this.f7607a;
        String str = this.f7608b;
        Boolean boolValueOf = Boolean.valueOf(C0716s.p(c0716s, context, str));
        Boolean boolValueOf2 = Boolean.valueOf(C0716s.n(c0716s, context, str));
        kotlin.jvm.internal.o.h(context, "context");
        try {
            Context applicationContext = context.getApplicationContext();
            kotlin.jvm.internal.o.g(applicationContext, "getApplicationContext(...)");
            Context applicationContext2 = applicationContext.getApplicationContext();
            kotlin.jvm.internal.o.g(applicationContext2, "getApplicationContext(...)");
            String string = ((SharedPreferencesC2907b) W.c.D(applicationContext2)).getString("continue_watching_payload", null);
            objD = string != null ? S4.p.o1(string).toString() : null;
            if (objD == null) {
                objD = "";
            }
        } catch (Throwable th) {
            objD = AbstractC2467b.d(th);
        }
        String str2 = (String) (w4.n.a(objD) == null ? objD : "");
        boolean z6 = false;
        if (str2.length() != 0 && !str2.equals("[]")) {
            z6 = true;
        }
        return new w4.q(boolValueOf, boolValueOf2, Boolean.valueOf(z6));
    }
}
package V2;

import android.content.Context;
import m3.AbstractC2467b;
import s2.SharedPreferencesC2907b;
import w4.C3137A;
import w4.n;

/*
 * This class represents a coroutine factory and execution handler for retrieving
 * a "continue_watching_payload" from SharedPreferences.
 *
 * It extends C4.j (likely a coroutine factory interface) and implements J4.e (likely a suspend function interface).
 * The primary logic resides in the `invokeSuspend` method, which:
 * 1. Validates the context and string parameters.
 * 2. Retrieves a boolean flag (likely indicating if the user has continued watching).
 * 3. Retrieves another boolean flag (likely indicating if the payload is empty or invalid).
 * 4. Fetches the raw string from SharedPreferences under the key "continue_watching_payload".
 * 5. Attempts to parse the string using a utility class (S4.p.o1), likely handling JSON or specific formatting.
 * 6. If parsing fails or returns null, it defaults to an empty string.
 * 7. Checks if the resulting string is non-empty and not equal to "[]" to determine if there is actual content.
 * 8. Returns a result object (w4.q) containing the three boolean flags.
 */
public final class W2 extends C4.j implements J4.e {

    // Context passed to the factory, renamed for clarity
    public final Context context;

    // String parameter passed to the factory, renamed for clarity
    public final String payloadKey;

    public W2(Context context, String payloadKey) {
        super(2, null); // Factory arity and default delegate
        this.context = context;
        this.payloadKey = payloadKey;
    }

    @Override
    public W2 create(Object obj, A4.d dVar) {
        // Factory method to create a new instance with the same context and key
        return new W2((Context) obj, (String) dVar.value);
    }

    @Override
    public Object invoke(Object obj, Object obj2) {
        // Entry point for the coroutine. Creates a new instance and invokes the suspend function.
        return ((W2) create((V4.C) obj, (A4.d) obj2)).invokeSuspend(C3137A.f25453a);
    }

    @Override
    public Object invokeSuspend(Object obj) {
        // Main execution logic
        AbstractC2467b.l(obj); // Ensure coroutine state is valid
        C0716s c0716s = C0716s.f8049a; // Coroutine scope reference
        Context context = this.context;
        String str = this.payloadKey;

        // Retrieve boolean flags from the coroutine scope
        Boolean hasContinued = Boolean.valueOf(C0716s.p(c0716s, context, str));
        Boolean isInvalid = Boolean.valueOf(C0716s.n(c0716s, context, str));

        kotlin.jvm.internal.o.h(context, "context"); // Validate context is not null
        try {
            // Get the application context to access SharedPreferences
            Context appContext = context.getApplicationContext();
            kotlin.jvm.internal.o.g(appContext, "getApplicationContext(...)" );

            // Retrieve the raw string from SharedPreferences
            String rawPayload = ((SharedPreferencesC2907b) W.c.D(appContext)).getString("continue_watching_payload", null);

            // Attempt to parse the payload using the utility class S4.p.o1
            // If parsing fails or returns null, default to empty string
            String parsedPayload = (rawPayload != null) ? S4.p.o1(rawPayload).toString() : "";

            // Check if the payload is non-empty and not an empty array representation "[]"
            boolean hasContent = parsedPayload.length() != 0 && !parsedPayload.equals("[]");

            return new w4.q(hasContinued, isInvalid, Boolean.valueOf(hasContent));
        } catch (Throwable th) {
            // Handle any exceptions during SharedPreferences access or parsing
            return AbstractC2467b.d(th);
        }
    }
}
