package d3;

import V4.InterfaceC0765i0;
import android.os.SystemClock;
import android.view.KeyEvent;
import androidx.compose.runtime.MutableState;
import androidx.media3.exoplayer.ExoPlayer;
import java.util.concurrent.atomic.AtomicBoolean;

/* JADX INFO: loaded from: classes.dex */
public final class U1 implements J4.c {

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

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

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

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

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

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

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

    /* JADX INFO: renamed from: k, reason: collision with root package name */
    public final /* synthetic */ MutableState f15371k;
    public final /* synthetic */ MutableState l;

    /* JADX INFO: renamed from: m, reason: collision with root package name */
    public final /* synthetic */ V4.C f15372m;

    public U1(MutableState mutableState, MutableState mutableState2, ExoPlayer exoPlayer, MutableState mutableState3, AtomicBoolean atomicBoolean, MutableState mutableState4, MutableState mutableState5, MutableState mutableState6, MutableState mutableState7, V4.C c6) {
        this.f15364a = mutableState;
        this.f15365b = mutableState2;
        this.f15366c = exoPlayer;
        this.f15367d = mutableState3;
        this.f15368e = atomicBoolean;
        this.f15369f = mutableState4;
        this.f15370j = mutableState5;
        this.f15371k = mutableState6;
        this.l = mutableState7;
        this.f15372m = c6;
    }

    /* JADX WARN: Multi-variable type inference failed */
    @Override // J4.c
    public final Object invoke(Object obj) {
        boolean z6;
        long jLongValue;
        boolean z7;
        KeyEvent event = ((A0.c) obj).f76a;
        kotlin.jvm.internal.o.h(event, "event");
        MutableState mutableState = this.f15364a;
        if (((Number) mutableState.getValue()).longValue() <= 0) {
            return Boolean.FALSE;
        }
        if (event.getKeyCode() != 21 && event.getKeyCode() != 22) {
            return Boolean.FALSE;
        }
        long eventTime = event.getEventTime();
        Long lValueOf = Long.valueOf(eventTime);
        if (eventTime <= 0) {
            lValueOf = null;
        }
        long jLongValue2 = lValueOf != null ? lValueOf.longValue() : SystemClock.uptimeMillis();
        int action = event.getAction();
        ExoPlayer exoPlayer = this.f15366c;
        MutableState mutableState2 = this.f15369f;
        MutableState mutableState3 = this.f15367d;
        MutableState mutableState4 = this.f15365b;
        if (action == 0) {
            z6 = true;
            if (((Long) mutableState4.getValue()) == null) {
                mutableState4.setValue(Long.valueOf(jLongValue2));
            }
            Long l = (Long) mutableState4.getValue();
            long jLongValue3 = jLongValue2 - (l != null ? l.longValue() : jLongValue2);
            if (jLongValue3 < 0) {
                jLongValue3 = 0;
            }
            long jX = (event.getKeyCode() == 22 ? 1L : -1L) * (jLongValue3 >= 1000 ? jLongValue3 < androidx.media3.common.C.DEFAULT_MAX_SEEK_TO_PREVIOUS_POSITION_MS ? L4.a.x(((long) (((jLongValue3 - 1000) / 2000.0f) * 80000.0f)) + 10000, 10000L, 90000L) : 90000L : 10000L);
            if (((Number) mutableState.getValue()).longValue() > 0) {
                InterfaceC0765i0 interfaceC0765i0 = (InterfaceC0765i0) mutableState3.getValue();
                if (interfaceC0765i0 != null) {
                    interfaceC0765i0.cancel(null);
                }
                v2.H(exoPlayer, this.f15368e, mutableState, mutableState2, this.f15370j, this.f15371k, this.l);
                Long l6 = (Long) mutableState2.getValue();
                if (l6 != null) {
                    jLongValue = l6.longValue();
                } else {
                    long currentPosition = exoPlayer.getCurrentPosition();
                    jLongValue = currentPosition >= 0 ? currentPosition : 0L;
                }
                mutableState2.setValue(Long.valueOf(v2.G(mutableState, jLongValue + jX)));
            }
        } else {
            if (action != 1) {
                z7 = false;
                return Boolean.valueOf(z7);
            }
            mutableState4.setValue(null);
            InterfaceC0765i0 interfaceC0765i02 = (InterfaceC0765i0) mutableState3.getValue();
            if (interfaceC0765i02 != null) {
                interfaceC0765i02.cancel(null);
            }
            Long l7 = (Long) mutableState2.getValue();
            if (l7 != null) {
                z6 = true;
                v2.I(exoPlayer, this.f15368e, this.f15371k, mutableState2, this.l, this.f15370j, v2.G(mutableState, l7.longValue()));
                mutableState3.setValue(null);
            } else {
                z6 = true;
            }
        }
        z7 = z6;
        return Boolean.valueOf(z7);
    }
}
