"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.createDefaultResolver = void 0;
const resolve_1 = require("@file-services/resolve");
function createDefaultResolver(options) {
    const resolver = (0, resolve_1.createRequestResolver)({
        extensions: ['.js', '.mjs', '.cjs', '.ts', '.mts', '.cts', '.json'],
        ...options,
    });
    return (directoryPath, request) => {
        const { resolvedFile, visitedPaths } = resolver(directoryPath, request);
        if (resolvedFile === false) {
            throw new Error(`Stylable does not support browser field 'false' values. ${request} resolved to 'false' from ${directoryPath}`);
        }
        if (typeof resolvedFile !== 'string') {
            throw new Error(`Stylable could not resolve ${JSON.stringify(request)} from ${JSON.stringify(directoryPath)}` + (visitedPaths.size ? `\nVisited paths:\n${[...visitedPaths].join('\n')}` : ''));
        }
        return resolvedFile;
    };
}
exports.createDefaultResolver = createDefaultResolver;
//# sourceMappingURL=module-resolver.js.map