"use strict";
Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
const dom = require("../../dom.js");
const codicons = require("../../../common/codicons.js");
const labelWithIconsRegex = new RegExp(`(\\\\)?\\$\\((${codicons.CSSIcon.iconNameExpression}(?:${codicons.CSSIcon.iconModifierExpression})?)\\)`, "g");
function renderLabelWithIcons(text) {
  const elements = new Array();
  let match;
  let textStart = 0, textStop = 0;
  while ((match = labelWithIconsRegex.exec(text)) !== null) {
    textStop = match.index || 0;
    elements.push(text.substring(textStart, textStop));
    textStart = (match.index || 0) + match[0].length;
    const [, escaped, codicon] = match;
    elements.push(escaped ? `$(${codicon})` : renderIcon({ id: codicon }));
  }
  if (textStart < text.length) {
    elements.push(text.substring(textStart));
  }
  return elements;
}
function renderIcon(icon) {
  const node = dom.$(`span`);
  node.classList.add(...codicons.CSSIcon.asClassNameArray(icon));
  return node;
}
exports.renderIcon = renderIcon;
exports.renderLabelWithIcons = renderLabelWithIcons;
