"use strict";
Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
const index = require("../character-entities-legacy/index.cjs");
const index$1 = require("../character-entities-html4/index.cjs");
const dangerous = require("./lib-constant-dangerous.cjs");
const own = {}.hasOwnProperty;
const characters = {};
let key;
for (key in index$1.characterEntitiesHtml4) {
  if (own.call(index$1.characterEntitiesHtml4, key)) {
    characters[index$1.characterEntitiesHtml4[key]] = key;
  }
}
const notAlphanumericRegex = /[^\dA-Za-z]/;
function toNamed(code, next, omit, attribute) {
  const character = String.fromCharCode(code);
  if (own.call(characters, character)) {
    const name = characters[character];
    const value = "&" + name;
    if (omit && index.characterEntitiesLegacy.includes(name) && !dangerous.dangerous.includes(name) && (!attribute || next && next !== 61 && notAlphanumericRegex.test(String.fromCharCode(next)))) {
      return value;
    }
    return value + ";";
  }
  return "";
}
exports.toNamed = toNamed;
//# sourceMappingURL=lib-util-to-named.cjs.map
