"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.migrate = migrate;
function migrate() {
    return (tree, _context) => {
        tree.visit((path) => {
            if (path.includes('/node_modules/'))
                return;
            if (path.endsWith('.html')) {
                migrateTemplate(tree, path);
            }
        });
    };
}
function migrateTemplate(tree, path) {
    const content = tree.readText(path);
    if (!content.includes('s-chips'))
        return;
    let updated = content;
    // Unique to s-chips — safe to replace globally
    updated = updated.replace(/\(onAdd\)/g, '(added)');
    updated = updated.replace(/\(onRemove\)/g, '(removed)');
    updated = updated.replace(/\(onChipClick\)/g, '(chipClicked)');
    // Generic event names — scope replacement to inside <s-chips opening tag
    updated = updated.replace(/(<s-chips\b[^>]*?)\(onFocus\)([^>]*?>)/gs, '$1(focused)$2');
    updated = updated.replace(/(<s-chips\b[^>]*?)\(onBlur\)([^>]*?>)/gs, '$1(focusLost)$2');
    if (updated !== content) {
        tree.overwrite(path, updated);
    }
}
//# sourceMappingURL=index.js.map