package com.bytedance.sdk.component.jnr.ro.lb;

import android.content.Context;
import android.text.TextUtils;
import com.bytedance.sdk.component.jnr.dsz;
import com.bytedance.sdk.component.jnr.fhx;
import com.bytedance.sdk.component.jnr.gof;
import com.bytedance.sdk.component.jnr.ro.lb.lb;
import com.bytedance.sdk.component.jnr.vt;
import com.bytedance.sdk.component.utils.irt;
import java.io.ByteArrayInputStream;
import java.io.InputStream;
import java.util.Collection;
import java.util.Iterator;

/* JADX INFO: loaded from: classes.dex */
public class ro implements fhx {
    private volatile ajl fm;

    private ro() {
    }

    public static fhx fm(Context context, dsz dszVar) {
        ro roVar = new ro();
        roVar.ro(context, dszVar);
        return roVar;
    }

    private void ro(Context context, dsz dszVar) {
        if (dszVar == null) {
            dszVar = jnr.fm(context);
        }
        this.fm = new ajl(context, dszVar);
    }

    @Override // com.bytedance.sdk.component.jnr.fhx
    public vt fm(String str) {
        return new lb.ro(this.fm).lb(str);
    }

    @Override // com.bytedance.sdk.component.jnr.fhx
    public InputStream fm(String str, String str2) {
        byte[] bArrFm;
        if (this.fm != null) {
            if (TextUtils.isEmpty(str2)) {
                if (TextUtils.isEmpty(str)) {
                    return null;
                }
                str2 = irt.fm(str);
            }
            gof gofVarLb = this.fm.lb();
            if (gofVarLb != null && (bArrFm = gofVarLb.fm(str2)) != null) {
                return new ByteArrayInputStream(bArrFm);
            }
            Collection<com.bytedance.sdk.component.jnr.lb> collectionYz = this.fm.yz();
            if (collectionYz != null) {
                Iterator<com.bytedance.sdk.component.jnr.lb> it = collectionYz.iterator();
                while (it.hasNext()) {
                    InputStream inputStreamFm = it.next().fm(str2);
                    if (inputStreamFm != null) {
                        return inputStreamFm;
                    }
                }
            }
        }
        return null;
    }

    @Override // com.bytedance.sdk.component.jnr.fhx
    public boolean fm(String str, String str2, String str3) {
        if (this.fm == null || TextUtils.isEmpty(str3)) {
            return false;
        }
        if (TextUtils.isEmpty(str2)) {
            if (TextUtils.isEmpty(str)) {
                return false;
            }
            str2 = irt.fm(str);
        }
        com.bytedance.sdk.component.jnr.lb lbVarFm = this.fm.fm(str3);
        if (lbVarFm != null) {
            return lbVarFm.ro(str2);
        }
        return false;
    }
}
