package com.bytedance.sdk.openadsdk;

import android.os.Bundle;
import android.text.TextUtils;
import com.bykv.vk.openvk.YFl.YFl.YFl.DSW.Sg;
import com.bytedance.sdk.component.utils.YoT;
import com.google.firebase.remoteconfig.FirebaseRemoteConfig;
import com.vungle.ads.internal.protos.Sdk;
import java.util.Map;
import org.json.JSONArray;
import org.json.JSONObject;
/* loaded from: classes2.dex */
public class AdSlot {
    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 float AlY;
    private boolean DSW;
    private String EH;
    private boolean GA;
    private Map<String, Object> Ga;
    private int Ne;
    private int NjR;
    private int Sg;
    private Bundle UZM;
    private int VOe;
    private String Wwa;
    private String YFl;
    private String YI;
    private int YoT;
    private int aIu;
    private JSONArray bZ;
    private String eT;
    private String lG;
    private String nc;
    private boolean pDU;
    private String qO;
    private String qsH;
    private String rkt;
    private int tN;
    private int vc;
    private float wN;
    private int wXo;

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

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

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

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

    public JSONArray getBiddingTokens() {
        return this.bZ;
    }

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

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

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

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

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

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

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

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

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

    public String getLinkId() {
        return this.YI;
    }

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

    public int getNativeAdType() {
        return this.YoT;
    }

    public Bundle getNetworkExtrasBundle() {
        return this.UZM;
    }

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

    @Deprecated
    public int getRewardAmount() {
        return this.NjR;
    }

    @Deprecated
    public String getRewardName() {
        return this.qsH;
    }

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

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

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

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

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

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

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

    public void setAdCount(int i) {
        this.vc = i;
    }

    public void setBiddingTokens(JSONArray jSONArray) {
        this.bZ = jSONArray;
    }

    public void setDurationSlotType(int i) {
        this.VOe = i;
    }

    public void setIsRotateBanner(int i) {
        this.aIu = i;
    }

    public void setNativeAdType(int i) {
        this.YoT = i;
    }

    public void setRotateOrder(int i) {
        this.Ne = i;
    }

    public void setRotateTime(int i) {
        this.wXo = i;
    }

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

    private AdSlot() {
        this.GA = true;
        this.pDU = false;
        this.aIu = 0;
        this.wXo = 0;
        this.Ne = 0;
    }

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

    public JSONObject toJsonObj() {
        JSONObject jSONObject = new JSONObject();
        try {
            jSONObject.put("mCodeId", this.YFl);
            jSONObject.put("mAdCount", this.vc);
            jSONObject.put("mIsAutoPlay", this.GA);
            jSONObject.put("mImgAcceptedWidth", this.Sg);
            jSONObject.put("mImgAcceptedHeight", this.tN);
            jSONObject.put("mExpressViewAcceptedWidth", this.AlY);
            jSONObject.put("mExpressViewAcceptedHeight", this.wN);
            jSONObject.put("mSupportDeepLink", this.DSW);
            jSONObject.put("mRewardName", this.qsH);
            jSONObject.put("mRewardAmount", this.NjR);
            jSONObject.put("mMediaExtra", this.nc);
            jSONObject.put("mUserID", this.eT);
            jSONObject.put("mNativeAdType", this.YoT);
            jSONObject.put("mIsExpressAd", this.pDU);
            jSONObject.put("mAdId", this.rkt);
            jSONObject.put("mCreativeId", this.lG);
            jSONObject.put("mExt", this.Wwa);
            jSONObject.put("mBidAdm", this.EH);
            jSONObject.put("mUserData", this.qO);
            jSONObject.put("mDurationSlotType", this.VOe);
        } catch (Exception unused) {
        }
        return jSONObject;
    }

    public static AdSlot getSlot(JSONObject jSONObject) {
        if (jSONObject == null) {
            return null;
        }
        Builder builder = new Builder();
        try {
            int optInt = jSONObject.optInt("mImgAcceptedWidth", 640);
            int optInt2 = jSONObject.optInt("mImgAcceptedHeight", Sdk.SDKError.Reason.WEBVIEW_ERROR_VALUE);
            double optDouble = jSONObject.optDouble("mExpressViewAcceptedWidth", FirebaseRemoteConfig.DEFAULT_VALUE_FOR_DOUBLE);
            double optDouble2 = jSONObject.optDouble("mExpressViewAcceptedHeight", FirebaseRemoteConfig.DEFAULT_VALUE_FOR_DOUBLE);
            builder.setCodeId(jSONObject.optString("mCodeId", null));
            builder.setAdCount(jSONObject.optInt("mAdCount", 1));
            builder.setIsAutoPlay(jSONObject.optBoolean("mIsAutoPlay"));
            builder.setImageAcceptedSize(optInt, optInt2);
            builder.setExpressViewAcceptedSize(Double.valueOf(optDouble).floatValue(), Double.valueOf(optDouble2).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"));
        } catch (Exception unused) {
        }
        AdSlot build = builder.build();
        build.setDurationSlotType(jSONObject.optInt("mDurationSlotType"));
        return build;
    }

    /* loaded from: classes2.dex */
    public static class Builder {
        private String EH;
        private boolean GA;
        private String Ne;
        private int VOe;
        private String Wwa;
        private String YFl;
        private float YoT;
        private float eT;
        private String lG;
        private int nc;
        private String pDU;
        private String qsH;
        private String rkt;
        private Bundle wXo;
        private int Sg = 640;
        private int tN = Sdk.SDKError.Reason.WEBVIEW_ERROR_VALUE;
        private final boolean AlY = true;
        private int wN = 1;
        private final String vc = "";
        private final int DSW = 0;
        private String NjR = "defaultUser";
        private boolean qO = true;
        private Map<String, Object> aIu = null;

        public Builder isExpressAd(boolean z) {
            this.GA = z;
            return this;
        }

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

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

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

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

        public Builder setDurationSlotType(int i) {
            this.VOe = i;
            return this;
        }

        public Builder setExpressViewAcceptedSize(float f, float f2) {
            this.eT = f;
            this.YoT = f2;
            return this;
        }

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

        public Builder setImageAcceptedSize(int i, int i2) {
            this.Sg = i;
            this.tN = i2;
            return this;
        }

        public Builder setIsAutoPlay(boolean z) {
            this.qO = z;
            return this;
        }

        public Builder setLinkId(String str) {
            this.Ne = str;
            return this;
        }

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

        public Builder setNativeAdType(int i) {
            this.nc = i;
            return this;
        }

        public Builder setNetworkExtrasBundle(Bundle bundle) {
            this.wXo = bundle;
            return this;
        }

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

        @Deprecated
        public Builder setRewardAmount(int i) {
            return this;
        }

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

        @Deprecated
        public Builder setSupportDeepLink(boolean z) {
            return this;
        }

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

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

        public Builder withBid(String str) {
            if (TextUtils.isEmpty(str)) {
                return this;
            }
            if (YoT.AlY()) {
                Sg.YFl(str);
            }
            this.pDU = str;
            return this;
        }

        public AdSlot build() {
            AdSlot adSlot = new AdSlot();
            adSlot.YFl = this.YFl;
            adSlot.vc = this.wN;
            adSlot.DSW = true;
            adSlot.Sg = this.Sg;
            adSlot.tN = this.tN;
            float f = this.eT;
            if (f <= 0.0f) {
                adSlot.AlY = this.Sg;
                adSlot.wN = this.tN;
            } else {
                adSlot.AlY = f;
                adSlot.wN = this.YoT;
            }
            adSlot.qsH = "";
            adSlot.NjR = 0;
            adSlot.nc = this.qsH;
            adSlot.eT = this.NjR;
            adSlot.YoT = this.nc;
            adSlot.GA = this.qO;
            adSlot.pDU = this.GA;
            adSlot.EH = this.pDU;
            adSlot.rkt = this.EH;
            adSlot.lG = this.rkt;
            adSlot.Wwa = this.lG;
            adSlot.qO = this.Wwa;
            adSlot.Ga = this.aIu;
            adSlot.YI = this.Ne;
            adSlot.VOe = this.VOe;
            return adSlot;
        }
    }
}
