"use strict";
/* eslint-disable @typescript-eslint/no-explicit-any */
/**
 * @license
 * Copyright Google LLC All Rights Reserved.
 *
 * Use of this source code is governed by an MIT-style license that can be
 * found in the LICENSE file at https://angular.io/license
 */
Object.defineProperty(exports, "__esModule", { value: true });
exports.createCssSelector = void 0;
const selector_1 = require("./selector");
const tags_1 = require("./tags");
/**
 * Creates a `CssSelector` given a tag name and a map of attributes
 */
function createCssSelector(elementName, attributes) {
    const cssSelector = new selector_1.CssSelector();
    const elementNameNoNs = (0, tags_1.splitNsName)(elementName)[1];
    cssSelector.setElement(elementNameNoNs);
    Object.getOwnPropertyNames(attributes).forEach((name) => {
        const nameNoNs = (0, tags_1.splitNsName)(name)[1];
        const value = attributes[name];
        cssSelector.addAttribute(nameNoNs, value);
        if (name.toLowerCase() === 'class') {
            const classes = value.trim().split(/\s+/);
            classes.forEach((className) => cssSelector.addClassName(className));
        }
    });
    return cssSelector;
}
exports.createCssSelector = createCssSelector;
