package com.google.firebase.storage.internal;

import android.net.Uri;
import com.bytedance.sdk.openadsdk.core.eT.nii.RBQJVqBPchYrO;
import com.google.firebase.emulators.EmulatedServiceSettings;
import com.google.firebase.storage.network.NetworkRequest;
import com.mbridge.msdk.foundation.download.core.DownloadCommon;
import com.revenuecat.purchases.common.Constants;
/* loaded from: classes7.dex */
public class StorageReferenceUri {
    private final Uri gsUri;
    private final Uri httpBaseUri;
    private final Uri httpUri;

    public Uri getGsUri() {
        return this.gsUri;
    }

    public Uri getHttpBaseUri() {
        return this.httpBaseUri;
    }

    public Uri getHttpUri() {
        return this.httpUri;
    }

    public StorageReferenceUri(Uri uri) {
        this(uri, null);
    }

    public StorageReferenceUri(Uri uri, EmulatedServiceSettings emulatedServiceSettings) {
        Uri parse;
        this.gsUri = uri;
        if (emulatedServiceSettings == null) {
            parse = NetworkRequest.PROD_BASE_URL;
        } else {
            parse = Uri.parse("http://" + emulatedServiceSettings.getHost() + Constants.SUBS_ID_BASE_PLAN_ID_SEPARATOR + emulatedServiceSettings.getPort() + "/v0");
        }
        this.httpBaseUri = parse;
        Uri.Builder appendEncodedPath = parse.buildUpon().appendPath(DownloadCommon.DOWNLOAD_REPORT_FIND_FILE_RESULT_VALUE_B).appendEncodedPath(uri.getAuthority());
        String normalizeSlashes = Slashes.normalizeSlashes(uri.getPath());
        if (normalizeSlashes.length() > 0 && !RBQJVqBPchYrO.MQP.equals(normalizeSlashes)) {
            appendEncodedPath = appendEncodedPath.appendPath("o").appendPath(normalizeSlashes);
        }
        this.httpUri = appendEncodedPath.build();
    }
}
