package L0;

import O1.C0225a;
import android.os.Bundle;
import d3.A1;
import d3.C0785g0;
import d3.C0795j1;
import d3.C0817r0;
import d3.W1;
import d3.Y0;
import d3.z1;
import o1.InterfaceC1331g;
import x0.AbstractC1709a;

/* JADX INFO: loaded from: classes.dex */
public final class X implements InterfaceC1331g {

    /* JADX INFO: renamed from: q, reason: collision with root package name */
    public long f3743q;

    /* JADX INFO: renamed from: r, reason: collision with root package name */
    public long f3744r;

    /* JADX INFO: renamed from: s, reason: collision with root package name */
    public Object f3745s;

    /* JADX INFO: renamed from: t, reason: collision with root package name */
    public Object f3746t;

    public X(long j8, int i) {
        AbstractC1709a.j(((P0.a) this.f3745s) == null);
        this.f3743q = j8;
        this.f3744r = j8 + ((long) i);
    }

    public boolean a(boolean z8, boolean z9, long j8) {
        A1 a1 = (A1) this.f3746t;
        a1.E();
        a1.F();
        C0817r0 c0817r0 = (C0817r0) a1.f5146q;
        if (c0817r0.f()) {
            C0785g0 c0785g0 = c0817r0.f12149x;
            C0817r0.i(c0785g0);
            c0817r0.D.getClass();
            c0785g0.f11962G.h(System.currentTimeMillis());
        }
        long j9 = j8 - this.f3743q;
        d3.Z z10 = c0817r0.f12150y;
        if (!z8 && j9 < 1000) {
            C0817r0.k(z10);
            z10.D.c(Long.valueOf(j9), "Screen exposed for less than 1000 ms. Event not sent. time");
            return false;
        }
        if (!z9) {
            j9 = j8 - this.f3744r;
            this.f3744r = j8;
        }
        C0817r0.k(z10);
        z10.D.c(Long.valueOf(j9), "Recording user engagement, ms");
        Bundle bundle = new Bundle();
        bundle.putLong("_et", j9);
        boolean z11 = !c0817r0.f12148w.S();
        C0795j1 c0795j1 = c0817r0.f12124E;
        C0817r0.j(c0795j1);
        W1.U(c0795j1.L(z11), bundle, true);
        if (!z9) {
            Y0 y02 = c0817r0.f12125F;
            C0817r0.j(y02);
            y02.P("auto", "_e", bundle);
        }
        this.f3743q = j8;
        z1 z1Var = (z1) this.f3745s;
        z1Var.a();
        z1Var.c(((Long) d3.I.q0.a(null)).longValue());
        return true;
    }

    @Override // o1.InterfaceC1331g
    public long b(T0.j jVar) {
        long j8 = this.f3744r;
        if (j8 < 0) {
            return -1L;
        }
        long j9 = -(j8 + 2);
        this.f3744r = -1L;
        return j9;
    }

    @Override // o1.InterfaceC1331g
    public T0.z f() {
        AbstractC1709a.j(this.f3743q != -1);
        return new T0.q(0, this.f3743q, (T0.r) this.f3745s);
    }

    @Override // o1.InterfaceC1331g
    public void k(long j8) {
        long[] jArr = (long[]) ((C0225a) this.f3746t).f5010r;
        this.f3744r = jArr[x0.v.e(jArr, j8, true)];
    }

    public X(String str, byte[] bArr, long j8, long j9) {
        this.f3745s = str;
        this.f3746t = bArr;
        this.f3743q = j8;
        this.f3744r = j9;
    }
}
