"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
const ml_core_1 = require("@markuplint/ml-core");
const command_1 = require("../command");
async function default_1(files, options, selectors) {
    const name = '__CLI_SEARCH__';
    const locations = [];
    await (0, command_1.command)(files, {
        ...options,
        problemOnly: true,
        importPresetRules: false,
    }, {
        rules: [
            new ml_core_1.MLRule({
                name,
                ...(0, ml_core_1.createRule)({
                    verify({ document }) {
                        const nodes = document.querySelectorAll(selectors);
                        locations.push(...Array.from(nodes).map(node => {
                            return {
                                file: document.filename || '_NO_FILE_',
                                line: node.startLine,
                                col: node.startCol,
                            };
                        }));
                    },
                }),
            }),
        ],
        config: {
            rules: {
                [name]: true,
            },
        },
    });
    locations.forEach(loc => {
        process.stdout.write(`${loc.file}:${loc.line}:${loc.col}\n`);
    });
}
exports.default = default_1;
