import{c as t}from"./character-entities-legacy-BpoLgcEt.js";import{c as e}from"./character-entities-html4-D7taRCQ7.js";const n=/["&'<>`]/g,r=/[\uD800-\uDBFF][\uDC00-\uDFFF]/g,o=/[\x01-\t\v\f\x0E-\x1F\x7F\x81\x8D\x8F\x90\x9D\xA0-\uFFFF]/g,s=/[|\\{}()[\]^$+*?.]/g,c=new WeakMap;function i(t,e){return t=t.replace(e.subset?function(t){let e=c.get(t);e||(e=function(t){const e=[];let n=-1;for(;++n<t.length;)e.push(t[n].replace(s,"\\$&"));return new RegExp("(?:"+e.join("|")+")","g")}(t),c.set(t,e));return e}(e.subset):n,i),e.subset||e.escapeOnly?t:t.replace(r,function(t,n,r){return e.format(1024*(t.charCodeAt(0)-55296)+t.charCodeAt(1)-56320+65536,r.charCodeAt(n+2),e)}).replace(o,i);function i(t,n,r){return e.format(t.charCodeAt(0),r.charCodeAt(n+1),e)}}const a=/[\dA-Fa-f]/;const u=/\d/;const f=["cent","copy","divide","gt","lt","not","para","times"],l={}.hasOwnProperty,h={};let g;for(g in e)l.call(e,g)&&(h[e[g]]=g);const m=/[^\dA-Za-z]/;function p(e,n,r){let o,s=function(t,e,n){const r="&#x"+t.toString(16).toUpperCase();return n&&e&&!a.test(String.fromCharCode(e))?r:r+";"}(e,n,r.omitOptionalSemicolons);if((r.useNamedReferences||r.useShortestReferences)&&(o=function(e,n,r,o){const s=String.fromCharCode(e);if(l.call(h,s)){const e=h[s],c="&"+e;return r&&t.includes(e)&&!f.includes(e)&&(!o||n&&61!==n&&m.test(String.fromCharCode(n)))?c:c+";"}return""}(e,n,r.omitOptionalSemicolons,r.attribute)),(r.useShortestReferences||!o)&&r.useShortestReferences){const t=function(t,e,n){const r="&#"+String(t);return n&&e&&!u.test(String.fromCharCode(e))?r:r+";"}(e,n,r.omitOptionalSemicolons);t.length<s.length&&(s=t)}return o&&(!r.useShortestReferences||o.length<s.length)?o:s}function d(t,e){return i(t,Object.assign({format:p},e))}export{d as s};
