"use strict"; var __importDefault = (this && this.__importDefault) || function (mod) { return (mod && mod.__esModule) ? mod : { "default": mod }; }; Object.defineProperty(exports, "__esModule", { value: true }); const css_1 = __importDefault(require("css")); const class_name_1 = __importDefault(require("./class-name")); const ID_OR_CLASS_RE = /#[a-zA-Z0-9_-]+|\.-?[a-zA-Z0-9_][a-zA-Z0-9_-]*/g; const ADD_POSTFIX_REPLACEMENT = '$&' + class_name_1.default.postfix; function transformSelector(selector) { return selector.replace(ID_OR_CLASS_RE, ADD_POSTFIX_REPLACEMENT); } function addUIClassPostfix(rules) { for (const node of rules) { if (node.type === 'rule') { const rule = node; rule.selectors = rule.selectors && rule.selectors.map(transformSelector); } const nodeWithRules = node; if (nodeWithRules.rules) addUIClassPostfix(nodeWithRules.rules); } } function createShadowStylesheet(cssCode) { const ast = css_1.default.parse(cssCode, { silent: true }); if (ast.stylesheet) addUIClassPostfix(ast.stylesheet.rules); return css_1.default.stringify(ast, { compress: false }); } exports.default = createShadowStylesheet;module.exports = exports.default;