package com.bytedance.sdk.openadsdk;

import a6.a;
import android.text.TextUtils;
import androidx.annotation.Nullable;
import com.bytedance.sdk.component.utils.fhx;
import java.util.Map;
import org.json.JSONObject;

/* JADX INFO: loaded from: classes2.dex */
public class AdSlot {
    public static final int ANCHORED_BANNER = 2;
    public static final int FIX_BANNER = 1;
    public static final int INLINE_BANNER = 3;
    public static final int TYPE_BANNER = 1;
    public static final int TYPE_CACHED_SPLASH = 4;
    public static final int TYPE_FEED = 5;
    public static final int TYPE_FULL_SCREEN_VIDEO = 8;
    public static final int TYPE_INTERACTION_AD = 2;
    public static final int TYPE_OPEN_AD = 3;
    public static final int TYPE_REWARD_VIDEO = 7;
    private int ajl;
    private boolean dsz;
    private int duv;

    /* JADX INFO: renamed from: ef, reason: collision with root package name */
    private int f6713ef;
    private String fhx;
    private String fm;
    private String gof;
    private String gqi;
    private Map<String, Object> gzf;
    private boolean hi;
    private int hlt;
    private String irt;
    private float jnr;
    private String ku;

    /* JADX INFO: renamed from: lb, reason: collision with root package name */
    private int f6714lb;
    private int lse;
    private int maa;
    private long mq;
    private int nt;
    private boolean onz;
    private String qhl;
    private int ro;
    private int sds;
    private String vt;
    private int wey;
    private boolean wsy;
    private String wu;
    private float yz;

    public static class Builder {
        private boolean dsz;
        private float duv;
        private String fhx;
        private String fm;
        private String gof;
        private String irt;
        private float ku;
        private String onz;
        private String qhl;
        private int sds;
        private int vt;
        private String wu;
        private int ro = 640;

        /* JADX INFO: renamed from: lb, reason: collision with root package name */
        private int f6716lb = 320;
        private final boolean yz = true;
        private int jnr = 1;
        private final String ajl = "";
        private final int wsy = 0;

        /* JADX INFO: renamed from: ef, reason: collision with root package name */
        private String f6715ef = "defaultUser";
        private boolean gqi = true;
        private Map<String, Object> wey = null;
        private int maa = 1;

        public AdSlot build() {
            AdSlot adSlot = new AdSlot();
            adSlot.fm = this.fm;
            adSlot.ajl = this.jnr;
            adSlot.wsy = true;
            adSlot.ro = this.ro;
            adSlot.f6714lb = this.f6716lb;
            float f10 = this.ku;
            if (f10 <= 0.0f) {
                adSlot.yz = this.ro;
                adSlot.jnr = this.f6716lb;
            } else {
                adSlot.yz = f10;
                adSlot.jnr = this.duv;
            }
            adSlot.wu = "";
            adSlot.f6713ef = 0;
            adSlot.vt = this.wu;
            adSlot.ku = this.f6715ef;
            adSlot.duv = this.vt;
            adSlot.dsz = this.gqi;
            adSlot.onz = this.dsz;
            adSlot.fhx = this.onz;
            adSlot.irt = this.fhx;
            adSlot.qhl = this.irt;
            adSlot.gof = this.qhl;
            adSlot.gqi = this.gof;
            adSlot.gzf = this.wey;
            adSlot.lse = this.sds;
            adSlot.hlt = this.maa;
            return adSlot;
        }

        public Builder isExpressAd(boolean z10) {
            this.dsz = z10;
            return this;
        }

        public Builder setAdCount(int i10) {
            if (i10 <= 0) {
                i10 = 1;
            }
            if (i10 > 20) {
                i10 = 20;
            }
            this.jnr = i10;
            return this;
        }

        public Builder setAdId(String str) {
            this.fhx = str;
            return this;
        }

        public Builder setBannerType(int i10) {
            this.maa = i10;
            return this;
        }

        public Builder setCodeId(String str) {
            this.fm = str;
            return this;
        }

        public Builder setCreativeId(String str) {
            this.irt = str;
            return this;
        }

        public Builder setDurationSlotType(int i10) {
            this.sds = i10;
            return this;
        }

        public Builder setExpressViewAcceptedSize(float f10, float f11) {
            this.ku = f10;
            this.duv = f11;
            return this;
        }

        public Builder setExt(String str) {
            this.qhl = str;
            return this;
        }

        public Builder setImageAcceptedSize(int i10, int i11) {
            this.ro = i10;
            this.f6716lb = i11;
            return this;
        }

        public Builder setIsAutoPlay(boolean z10) {
            this.gqi = z10;
            return this;
        }

        public Builder setMediaExtra(String str) {
            this.wu = str;
            return this;
        }

        public Builder setNativeAdType(int i10) {
            this.vt = i10;
            return this;
        }

        public Builder setRequestExtraMap(Map<String, Object> map) {
            this.wey = map;
            return this;
        }

        public Builder setRewardAmount(int i10) {
            return this;
        }

        public Builder setRewardName(String str) {
            return this;
        }

        public Builder setSupportDeepLink(boolean z10) {
            return this;
        }

        public Builder setUserData(String str) {
            this.gof = str;
            return this;
        }

        public Builder setUserID(String str) {
            this.f6715ef = str;
            return this;
        }

        public Builder withBid(String str) {
            if (TextUtils.isEmpty(str)) {
                return this;
            }
            if (fhx.lb()) {
                a.a(str);
            }
            this.onz = str;
            return this;
        }
    }

    public static int getPosition(int i10) {
        if (i10 == 1) {
            return 2;
        }
        if (i10 != 2) {
            return (i10 == 3 || i10 == 4 || i10 == 7 || i10 == 8) ? 5 : 3;
        }
        return 4;
    }

    public static AdSlot getSlot(JSONObject jSONObject) {
        if (jSONObject == null) {
            return null;
        }
        Builder builder = new Builder();
        try {
            int iOptInt = jSONObject.optInt("mImgAcceptedWidth", 640);
            int iOptInt2 = jSONObject.optInt("mImgAcceptedHeight", 320);
            double dOptDouble = jSONObject.optDouble("mExpressViewAcceptedWidth", 0.0d);
            double dOptDouble2 = jSONObject.optDouble("mExpressViewAcceptedHeight", 0.0d);
            builder.setCodeId(jSONObject.optString("mCodeId", null));
            builder.setAdCount(jSONObject.optInt("mAdCount", 1));
            builder.setIsAutoPlay(jSONObject.optBoolean("mIsAutoPlay"));
            builder.setImageAcceptedSize(iOptInt, iOptInt2);
            builder.setExpressViewAcceptedSize(Double.valueOf(dOptDouble).floatValue(), Double.valueOf(dOptDouble2).floatValue());
            builder.setSupportDeepLink(jSONObject.optBoolean("mSupportDeepLink", false));
            builder.setRewardName(jSONObject.optString("mRewardName", null));
            builder.setRewardAmount(jSONObject.optInt("mRewardAmount"));
            builder.setMediaExtra(jSONObject.optString("mMediaExtra", null));
            builder.setUserID(jSONObject.optString("mUserID", null));
            builder.setNativeAdType(jSONObject.optInt("mNativeAdType"));
            builder.isExpressAd(jSONObject.optBoolean("mIsExpressAd"));
            builder.withBid(jSONObject.optString("mBidAdm"));
            builder.setAdId(jSONObject.optString("mAdId"));
            builder.setCreativeId(jSONObject.optString("mCreativeId"));
            builder.setExt(jSONObject.optString("mExt"));
            builder.setMediaExtra(jSONObject.optString("mMediaExtra"));
            builder.setBannerType(jSONObject.optInt("mBannerType"));
        } catch (Exception unused) {
        }
        AdSlot adSlotBuild = builder.build();
        adSlotBuild.setDurationSlotType(jSONObject.optInt("mDurationSlotType"));
        return adSlotBuild;
    }

    public int getAdCount() {
        return this.ajl;
    }

    public String getAdId() {
        return this.irt;
    }

    public int getBannerType() {
        return this.hlt;
    }

    public String getBidAdm() {
        return this.fhx;
    }

    public int getCacheScene() {
        return this.nt;
    }

    public long getCacheTime() {
        return this.mq;
    }

    public String getCodeId() {
        return this.fm;
    }

    public String getCreativeId() {
        return this.qhl;
    }

    public int getDurationSlotType() {
        return this.lse;
    }

    public float getExpressViewAcceptedHeight() {
        return this.jnr;
    }

    public float getExpressViewAcceptedWidth() {
        return this.yz;
    }

    public String getExt() {
        return this.gof;
    }

    public int getImgAcceptedHeight() {
        return this.f6714lb;
    }

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

    public int getIsRotateBanner() {
        return this.wey;
    }

    public String getMediaExtra() {
        return this.vt;
    }

    @Nullable
    public Map<String, Object> getRequestExtraMap() {
        return this.gzf;
    }

    public int getRewardAmount() {
        return this.f6713ef;
    }

    public String getRewardName() {
        return this.wu;
    }

    public int getRotateOrder() {
        return this.maa;
    }

    public int getRotateTime() {
        return this.sds;
    }

    public String getUserData() {
        return this.gqi;
    }

    public String getUserID() {
        return this.ku;
    }

    public boolean isAutoPlay() {
        return this.dsz;
    }

    public boolean isExpressAd() {
        return this.onz;
    }

    public boolean isPreload() {
        return this.hi;
    }

    public boolean isSupportDeepLink() {
        return this.wsy;
    }

    public void setAdCount(int i10) {
        this.ajl = i10;
    }

    public void setCacheScene(int i10) {
        this.nt = i10;
    }

    public void setCacheTime(long j10) {
        this.mq = j10;
    }

    public void setDurationSlotType(int i10) {
        this.lse = i10;
    }

    public void setExpressViewAccepted(float f10, float f11) {
        this.yz = f10;
        this.jnr = f11;
    }

    public void setIsRotateBanner(int i10) {
        this.wey = i10;
    }

    public void setPreload(boolean z10) {
        this.hi = z10;
    }

    public void setRotateOrder(int i10) {
        this.maa = i10;
    }

    public void setRotateTime(int i10) {
        this.sds = i10;
    }

    public void setUserData(String str) {
        this.gqi = str;
    }

    public JSONObject toJsonObj() {
        JSONObject jSONObject = new JSONObject();
        try {
            jSONObject.put("mCodeId", this.fm);
            jSONObject.put("mAdCount", this.ajl);
            jSONObject.put("mIsAutoPlay", this.dsz);
            jSONObject.put("mImgAcceptedWidth", this.ro);
            jSONObject.put("mImgAcceptedHeight", this.f6714lb);
            jSONObject.put("mExpressViewAcceptedWidth", this.yz);
            jSONObject.put("mExpressViewAcceptedHeight", this.jnr);
            jSONObject.put("mSupportDeepLink", this.wsy);
            jSONObject.put("mRewardName", this.wu);
            jSONObject.put("mRewardAmount", this.f6713ef);
            jSONObject.put("mMediaExtra", this.vt);
            jSONObject.put("mUserID", this.ku);
            jSONObject.put("mNativeAdType", this.duv);
            jSONObject.put("mIsExpressAd", this.onz);
            jSONObject.put("mAdId", this.irt);
            jSONObject.put("mCreativeId", this.qhl);
            jSONObject.put("mExt", this.gof);
            jSONObject.put("mBidAdm", this.fhx);
            jSONObject.put("mUserData", this.gqi);
            jSONObject.put("mDurationSlotType", this.lse);
            jSONObject.put("mBannerType", this.hlt);
        } catch (Exception unused) {
        }
        return jSONObject;
    }

    public String toString() {
        return super.toString();
    }

    private AdSlot() {
        this.dsz = true;
        this.onz = false;
        this.wey = 0;
        this.sds = 0;
        this.maa = 0;
        this.hlt = 1;
    }
}
