"use strict";
function init(modules) {
    function create(info) {
        const log = (text) => {
            info.project.projectService.logger.info(`[sfccstar]: ${text}`);
        };
        log("starting plugin");
        const origResolveModuleNames = info.languageServiceHost.resolveModuleNames;
        info.languageServiceHost.resolveModuleNames = (moduleNames, containingFile, reusedNames, redirectedReference) => {
            moduleNames = moduleNames.map(moduleName => {
                if (moduleName.startsWith('*/')) {
                    const newName = `~/${moduleName.substring(2)}`;
                    log(`sfccstar transform "${moduleName}" to "${newName}"`);
                    return newName;
                }
                return moduleName;
            });
            // We use the remapped module names to call the original method
            return origResolveModuleNames.call(info.languageServiceHost, moduleNames, containingFile, reusedNames, redirectedReference);
        };
        // We aren't actually proxying the language service, so we just return the original
        return info.languageService;
    }
    return { create };
}
module.exports = init;
