package coil.map;

import S4.p;
import android.net.Uri;
import coil.request.Options;
import coil.util.Utils;
import java.io.File;
import kotlin.jvm.internal.o;

/* JADX INFO: loaded from: classes.dex */
public final class FileUriMapper implements Mapper<Uri, File> {
    private final boolean isApplicable(Uri uri) {
        if (Utils.isAssetUri(uri)) {
            return false;
        }
        String scheme = uri.getScheme();
        if (scheme != null && !scheme.equals("file")) {
            return false;
        }
        String path = uri.getPath();
        if (path == null) {
            path = "";
        }
        return p.e1(path, '/') && Utils.getFirstPathSegment(uri) != null;
    }

    @Override // coil.map.Mapper
    public File map(Uri uri, Options options) {
        if (!isApplicable(uri)) {
            return null;
        }
        if (!o.c(uri.getScheme(), "file")) {
            return new File(uri.toString());
        }
        String path = uri.getPath();
        if (path != null) {
            return new File(path);
        }
        return null;
    }
}
