/*
 * Copyright (c) 2025, Salesforce, Inc.
 * SPDX-License-Identifier: Apache-2
 * For full license text, see the license.txt file in the repo root or http://www.apache.org/licenses/LICENSE-2.0
 */
/**
 * dw.json configuration source.
 *
 * @internal This module is internal to the SDK. Use ConfigResolver instead.
 */
import { loadDwJson } from '../dw-json.js';
import { getPopulatedFields } from '../mapping.js';
import { mapDwJsonToNormalizedConfig } from '../mapping.js';
import { getLogger } from '../../logging/logger.js';
/**
 * Configuration source that loads from dw.json files.
 *
 * @internal
 */
export class DwJsonSource {
    name = 'DwJsonSource';
    priority = 0;
    load(options) {
        const logger = getLogger();
        const result = loadDwJson({
            instance: options.instance,
            path: options.configPath,
            startDir: options.startDir,
        });
        if (!result) {
            return undefined;
        }
        const config = mapDwJsonToNormalizedConfig(result.config);
        const fields = getPopulatedFields(config);
        logger.trace({ location: result.path, fields }, '[DwJsonSource] Loaded config');
        return { config, location: result.path };
    }
}
//# sourceMappingURL=dw-json-source.js.map