import{isValidEscape as t,isName as e}from"../tokenizer/char-code-definitions.mjs";import{consumeEscaped as r,decodeEscaped as o}from"../tokenizer/utils.mjs";import"../tokenizer/TokenStream.mjs";function n(e){const n=e.length-1;let i="";for(let c=0;c<e.length;c++){let h=e.charCodeAt(c);if(92===h){if(c===n)break;if(h=e.charCodeAt(++c),t(92,h)){const t=c-1,n=r(e,t);c=n-1,i+=o(e.substring(t+1,n))}else 13===h&&10===e.charCodeAt(c+1)&&c++}else i+=e[c]}return i}function i(t){let r="";if(1===t.length&&45===t.charCodeAt(0))return"\\-";for(let o=0;o<t.length;o++){const n=t.charCodeAt(o);0!==n?n<=31||127===n||n>=48&&n<=57&&(0===o||1===o&&45===t.charCodeAt(0))?r+="\\"+n.toString(16)+" ":e(n)?r+=t.charAt(o):r+="\\"+t.charAt(o):r+="�"}return r}export{n as decode,i as encode};