package com.bytedance.sdk.openadsdk.component.reward.fm;

import android.app.Activity;
import android.content.Context;
import android.os.SystemClock;
import android.view.View;
import androidx.annotation.NonNull;
import androidx.annotation.Nullable;
import com.bytedance.sdk.component.utils.mq;
import com.bytedance.sdk.openadsdk.core.model.lse;
import com.bytedance.sdk.openadsdk.utils.ef;
import java.util.HashMap;
import java.util.Iterator;
import java.util.Map;
import java.util.concurrent.atomic.AtomicBoolean;
import org.json.JSONException;
import org.json.JSONObject;

/* JADX INFO: loaded from: classes2.dex */
public class ro {
    public long ado;
    public com.bytedance.sdk.openadsdk.dsz.vt ai;
    public final int ajl;
    public boolean aws;
    public float bkb;
    public boolean bwv;
    public final Context bx;
    public boolean cg;
    private String cpu;
    public final boolean daz;
    public final AtomicBoolean dsz;
    public final AtomicBoolean duv;

    /* JADX INFO: renamed from: ef, reason: collision with root package name */
    public final AtomicBoolean f6936ef;
    public final AtomicBoolean fhx;
    public final int fm;

    /* JADX INFO: renamed from: gc, reason: collision with root package name */
    public final com.bytedance.sdk.openadsdk.component.reward.view.wu f6937gc;
    public final AtomicBoolean gof;
    public final AtomicBoolean gqi;
    private long grs;
    public final yz gzf;

    /* JADX INFO: renamed from: ha, reason: collision with root package name */
    @NonNull
    public final dsz f6938ha;
    public final duv hi;
    public final com.bytedance.sdk.openadsdk.component.reward.view.ef hlt;
    public final com.bytedance.sdk.openadsdk.component.reward.view.ku hxv;

    /* JADX INFO: renamed from: ib, reason: collision with root package name */
    public int f6939ib;
    public final AtomicBoolean irt;
    public boolean jm;
    private int jn;
    public final String jnr;
    public final AtomicBoolean ku;
    public int kwx;

    /* JADX INFO: renamed from: lb, reason: collision with root package name */
    public final boolean f6940lb;
    public com.bytedance.sdk.openadsdk.component.reward.top.lb lcp;
    public int lmk;
    public final ef lse;
    public String lz;
    public final jnr maa;
    public boolean mj;
    public final com.bytedance.sdk.openadsdk.core.fhx.yz.ro mon;
    public int mpp;
    public final wsy mq;

    /* JADX INFO: renamed from: ne, reason: collision with root package name */
    public boolean f6941ne;
    public boolean no;
    public final ku nt;
    public final gof ol;
    public final AtomicBoolean onz;
    public boolean pbk;
    public boolean pcm;
    public final ajl pkk;

    /* JADX INFO: renamed from: qb, reason: collision with root package name */
    public com.bytedance.sdk.openadsdk.component.reward.duv f6942qb;

    /* JADX INFO: renamed from: qf, reason: collision with root package name */
    public boolean f6943qf;
    public final AtomicBoolean qhl;
    private int qph;
    public com.bytedance.sdk.openadsdk.utils.onz rka;
    public lse ro;

    @NonNull
    public final qhl sds;
    public boolean si;
    public com.bytedance.sdk.openadsdk.component.reward.ro.ro so;

    /* JADX INFO: renamed from: te, reason: collision with root package name */
    public boolean f6944te;
    public boolean ttj;
    public final boolean tzk;
    public final AtomicBoolean vt;
    public boolean vvj;
    public final onz wbw;
    public final AtomicBoolean wey;
    public int wsy;
    public int wu;
    public boolean xca;

    @NonNull
    public final Activity xgn;
    public int ywr;
    public final boolean yz;
    public final mq zan;
    private long zjk;

    @Nullable
    public com.bytedance.sdk.openadsdk.activity.single.wu zow;

    public ro(@NonNull Activity activity, mq mqVar, @NonNull lse lseVar, com.bytedance.sdk.openadsdk.core.fhx.yz.ro roVar, int i10, boolean z10) {
        this(activity, mqVar, lseVar, roVar, i10, z10, null);
    }

    private void vt() {
        com.bytedance.sdk.openadsdk.utils.onz onzVarFm = com.bytedance.sdk.openadsdk.utils.ef.fm(this.xgn, new ef.fm() { // from class: com.bytedance.sdk.openadsdk.component.reward.fm.ro.1
            @Override // com.bytedance.sdk.openadsdk.utils.ef.fm
            public View fm() {
                com.bytedance.sdk.openadsdk.component.reward.view.ku kuVar = ro.this.hxv;
                if (kuVar != null) {
                    return kuVar.ku();
                }
                return null;
            }

            @Override // com.bytedance.sdk.openadsdk.utils.ef.fm
            public void ro() {
                dsz dszVar = ro.this.f6938ha;
                if (dszVar != null) {
                    dszVar.jnr();
                }
            }
        });
        this.rka = onzVarFm;
        onzVarFm.fm(new com.bytedance.sdk.openadsdk.utils.fhx() { // from class: com.bytedance.sdk.openadsdk.component.reward.fm.ro.2
            @Override // com.bytedance.sdk.openadsdk.utils.fhx
            public void fm() {
                com.bytedance.sdk.openadsdk.component.yz.ro.fm("force_button_tracker", "show", ro.this.ro);
            }
        });
    }

    public long ajl() {
        return (SystemClock.elapsedRealtime() - this.zjk) + this.grs;
    }

    public Map<String, Object> ef() {
        lse lseVar;
        HashMap map = new HashMap();
        if (this.hlt != null && (lseVar = this.ro) != null && lseVar.no() == 2) {
            map.put("dynamic_show_type", Integer.valueOf(this.hlt.ku()));
            JSONObject jSONObjectFm = this.hlt.fm((JSONObject) null);
            if (jSONObjectFm != null) {
                Iterator<String> itKeys = jSONObjectFm.keys();
                while (itKeys.hasNext()) {
                    String next = itKeys.next();
                    try {
                        map.put(next, jSONObjectFm.get(next));
                    } catch (JSONException unused) {
                    }
                }
            }
        }
        return map;
    }

    public int fm() {
        return this.jn;
    }

    public void jnr() {
        if (this.zjk <= 0) {
            this.zjk = SystemClock.elapsedRealtime();
        }
        this.grs = (SystemClock.elapsedRealtime() - this.zjk) + this.grs;
    }

    public boolean lb() {
        return this.jn != 0;
    }

    public int ro() {
        return this.qph;
    }

    public boolean wsy() {
        com.bytedance.sdk.openadsdk.activity.single.wu wuVar;
        return !this.pbk || (wuVar = this.zow) == null || !(wuVar instanceof com.bytedance.sdk.openadsdk.activity.single.jnr) || ((com.bytedance.sdk.openadsdk.activity.single.jnr) wuVar).fm;
    }

    public com.bytedance.sdk.openadsdk.yz.wsy wu() {
        if (!this.ro.ajl()) {
            com.bytedance.sdk.openadsdk.yz.wsy wsyVar = new com.bytedance.sdk.openadsdk.yz.wsy();
            wsyVar.fm(System.currentTimeMillis(), 1.0f);
            return wsyVar;
        }
        com.bytedance.sdk.openadsdk.component.reward.view.ef efVar = this.hlt;
        if (efVar != null && efVar.fm() != null) {
            return this.hlt.fm().getAdShowTime();
        }
        com.bytedance.sdk.openadsdk.yz.wsy wsyVar2 = new com.bytedance.sdk.openadsdk.yz.wsy();
        wsyVar2.fm(System.currentTimeMillis(), 1.0f);
        return wsyVar2;
    }

    public void yz() {
        this.zjk = SystemClock.elapsedRealtime();
    }

    public ro(@NonNull Activity activity, mq mqVar, @NonNull lse lseVar, com.bytedance.sdk.openadsdk.core.fhx.yz.ro roVar, int i10, boolean z10, @Nullable ro roVar2) {
        this.wsy = 0;
        this.wu = 0;
        this.f6936ef = new AtomicBoolean(false);
        this.vt = new AtomicBoolean(false);
        this.ku = new AtomicBoolean(false);
        this.duv = new AtomicBoolean(false);
        this.dsz = new AtomicBoolean(false);
        this.onz = new AtomicBoolean(false);
        this.fhx = new AtomicBoolean(false);
        this.irt = new AtomicBoolean(false);
        this.qhl = new AtomicBoolean(false);
        this.gof = new AtomicBoolean(false);
        this.gqi = new AtomicBoolean(false);
        this.wey = new AtomicBoolean(false);
        this.si = false;
        this.kwx = 1;
        this.ado = 0L;
        this.zow = null;
        this.f6944te = true;
        this.xca = false;
        this.ttj = false;
        this.qph = -1;
        this.cpu = "";
        this.jn = 0;
        this.xgn = activity;
        this.mon = roVar;
        Context contextFm = com.bytedance.sdk.openadsdk.core.gof.fm();
        this.bx = contextFm;
        this.ro = lseVar;
        this.fm = i10;
        this.cg = roVar2 != null;
        this.aws = i10 == 0 || i10 == 1;
        this.tzk = i10 == 0 || i10 == 2;
        this.zan = mqVar;
        this.daz = z10;
        boolean z11 = lseVar.cpu().getDurationSlotType() == 7;
        this.yz = z11;
        String str = z11 ? "rewarded_video" : "fullscreen_interstitial_ad";
        this.jnr = str;
        this.pcm = lseVar.ajl();
        int iPg = lseVar.pg();
        this.ajl = iPg;
        this.f6943qf = com.bytedance.sdk.openadsdk.core.gof.yz().gof(String.valueOf(iPg));
        this.f6940lb = com.bytedance.sdk.openadsdk.core.settings.ku.ro().fhx(String.valueOf(iPg));
        this.hi = new duv(this);
        this.hxv = i10 == 2 ? new com.bytedance.sdk.openadsdk.component.reward.view.duv(this) : lseVar.ajl() ? new com.bytedance.sdk.openadsdk.component.reward.view.ku(this) : new com.bytedance.sdk.openadsdk.component.reward.view.vt(this);
        this.f6937gc = new com.bytedance.sdk.openadsdk.component.reward.view.wu(this);
        this.sds = new qhl(this);
        this.maa = new jnr(lseVar, str, contextFm, activity);
        this.lse = new ef(this, lseVar);
        com.bytedance.sdk.openadsdk.component.reward.view.ef efVar = roVar2 != null ? roVar2.hlt : new com.bytedance.sdk.openadsdk.component.reward.view.ef(this);
        this.hlt = efVar;
        efVar.fm(this);
        this.ol = new gof(this);
        this.wbw = new onz(this);
        this.f6938ha = new dsz(this);
        this.pkk = new ajl(this);
        this.nt = new ku(this);
        wsy wsyVar = roVar2 != null ? roVar2.mq : new wsy(this);
        this.mq = wsyVar;
        wsyVar.fm(this);
        this.gzf = new yz(this);
        this.ai = new com.bytedance.sdk.openadsdk.dsz.vt(contextFm);
        vt();
    }

    public void fm(int i10, String str, int i11) {
        this.qph = i10;
        this.cpu = str;
        this.jn = i11;
    }

    public void fm(boolean z10) {
        this.mj = z10;
        this.f6938ha.yz(z10);
    }
}
