function M(n,u=!1){const b=n.length;let e=0,i="",T=0,f=16,A=0,m=0,O=0,B=0,s=0;function F(l,g){let t=0,o=0;for(;t<l||!g;){let p=n.charCodeAt(e);if(p>=48&&p<=57)o=o*16+p-48;else if(p>=65&&p<=70)o=o*16+p-65+10;else if(p>=97&&p<=102)o=o*16+p-97+10;else break;e++,t++}return t<l&&(o=-1),o}function E(l){e=l,i="",T=0,f=16,s=0}function w(){let l=e;if(n.charCodeAt(e)===48)e++;else for(e++;e<n.length&&L(n.charCodeAt(e));)e++;if(e<n.length&&n.charCodeAt(e)===46)if(e++,e<n.length&&L(n.charCodeAt(e)))for(e++;e<n.length&&L(n.charCodeAt(e));)e++;else return s=3,n.substring(l,e);let g=e;if(e<n.length&&(n.charCodeAt(e)===69||n.charCodeAt(e)===101))if(e++,(e<n.length&&n.charCodeAt(e)===43||n.charCodeAt(e)===45)&&e++,e<n.length&&L(n.charCodeAt(e))){for(e++;e<n.length&&L(n.charCodeAt(e));)e++;g=e}else s=3;return n.substring(l,g)}function _(){let l="",g=e;for(;;){if(e>=b){l+=n.substring(g,e),s=2;break}const t=n.charCodeAt(e);if(t===34){l+=n.substring(g,e),e++;break}if(t===92){if(l+=n.substring(g,e),e++,e>=b){s=2;break}switch(n.charCodeAt(e++)){case 34:l+='"';break;case 92:l+="\\";break;case 47:l+="/";break;case 98:l+="\b";break;case 102:l+="\f";break;case 110:l+=`
`;break;case 114:l+="\r";break;case 116:l+="	";break;case 117:const p=F(4,!0);p>=0?l+=String.fromCharCode(p):s=4;break;default:s=5}g=e;continue}if(t>=0&&t<=31)if(N(t)){l+=n.substring(g,e),s=2;break}else s=6;e++}return l}function U(){if(i="",s=0,T=e,m=A,B=O,e>=b)return T=b,f=17;let l=n.charCodeAt(e);if(Q(l)){do e++,i+=String.fromCharCode(l),l=n.charCodeAt(e);while(Q(l));return f=15}if(N(l))return e++,i+=String.fromCharCode(l),l===13&&n.charCodeAt(e)===10&&(e++,i+=`
`),A++,O=e,f=14;switch(l){case 123:return e++,f=1;case 125:return e++,f=2;case 91:return e++,f=3;case 93:return e++,f=4;case 58:return e++,f=6;case 44:return e++,f=5;case 34:return e++,i=_(),f=10;case 47:const g=e-1;if(n.charCodeAt(e+1)===47){for(e+=2;e<b&&!N(n.charCodeAt(e));)e++;return i=n.substring(g,e),f=12}if(n.charCodeAt(e+1)===42){e+=2;const t=b-1;let o=!1;for(;e<t;){const p=n.charCodeAt(e);if(p===42&&n.charCodeAt(e+1)===47){e+=2,o=!0;break}e++,N(p)&&(p===13&&n.charCodeAt(e)===10&&e++,A++,O=e)}return o||(e++,s=1),i=n.substring(g,e),f=13}return i+=String.fromCharCode(l),e++,f=16;case 45:if(i+=String.fromCharCode(l),e++,e===b||!L(n.charCodeAt(e)))return f=16;case 48:case 49:case 50:case 51:case 52:case 53:case 54:case 55:case 56:case 57:return i+=w(),f=11;default:for(;e<b&&D(l);)e++,l=n.charCodeAt(e);if(T!==e){switch(i=n.substring(T,e),i){case"true":return f=8;case"false":return f=9;case"null":return f=7}return f=16}return i+=String.fromCharCode(l),e++,f=16}}function D(l){if(Q(l)||N(l))return!1;switch(l){case 125:case 93:case 123:case 91:case 34:case 58:case 44:case 47:return!1}return!0}function I(){let l;do l=U();while(l>=12&&l<=15);return l}return{setPosition:E,getPosition:()=>e,scan:u?I:U,getToken:()=>f,getTokenValue:()=>i,getTokenOffset:()=>T,getTokenLength:()=>e-T,getTokenStartLine:()=>m,getTokenStartCharacter:()=>T-B,getTokenError:()=>s}}function Q(n){return n===32||n===9}function N(n){return n===10||n===13}function L(n){return n>=48&&n<=57}var r;(function(n){n[n.lineFeed=10]="lineFeed",n[n.carriageReturn=13]="carriageReturn",n[n.space=32]="space",n[n._0=48]="_0",n[n._1=49]="_1",n[n._2=50]="_2",n[n._3=51]="_3",n[n._4=52]="_4",n[n._5=53]="_5",n[n._6=54]="_6",n[n._7=55]="_7",n[n._8=56]="_8",n[n._9=57]="_9",n[n.a=97]="a",n[n.b=98]="b",n[n.c=99]="c",n[n.d=100]="d",n[n.e=101]="e",n[n.f=102]="f",n[n.g=103]="g",n[n.h=104]="h",n[n.i=105]="i",n[n.j=106]="j",n[n.k=107]="k",n[n.l=108]="l",n[n.m=109]="m",n[n.n=110]="n",n[n.o=111]="o",n[n.p=112]="p",n[n.q=113]="q",n[n.r=114]="r",n[n.s=115]="s",n[n.t=116]="t",n[n.u=117]="u",n[n.v=118]="v",n[n.w=119]="w",n[n.x=120]="x",n[n.y=121]="y",n[n.z=122]="z",n[n.A=65]="A",n[n.B=66]="B",n[n.C=67]="C",n[n.D=68]="D",n[n.E=69]="E",n[n.F=70]="F",n[n.G=71]="G",n[n.H=72]="H",n[n.I=73]="I",n[n.J=74]="J",n[n.K=75]="K",n[n.L=76]="L",n[n.M=77]="M",n[n.N=78]="N",n[n.O=79]="O",n[n.P=80]="P",n[n.Q=81]="Q",n[n.R=82]="R",n[n.S=83]="S",n[n.T=84]="T",n[n.U=85]="U",n[n.V=86]="V",n[n.W=87]="W",n[n.X=88]="X",n[n.Y=89]="Y",n[n.Z=90]="Z",n[n.asterisk=42]="asterisk",n[n.backslash=92]="backslash",n[n.closeBrace=125]="closeBrace",n[n.closeBracket=93]="closeBracket",n[n.colon=58]="colon",n[n.comma=44]="comma",n[n.dot=46]="dot",n[n.doubleQuote=34]="doubleQuote",n[n.minus=45]="minus",n[n.openBrace=123]="openBrace",n[n.openBracket=91]="openBracket",n[n.plus=43]="plus",n[n.slash=47]="slash",n[n.formFeed=12]="formFeed",n[n.tab=9]="tab"})(r||(r={})),new Array(20).fill(0).map((n,u)=>" ".repeat(u));const v=200;new Array(v).fill(0).map((n,u)=>`
`+" ".repeat(u)),new Array(v).fill(0).map((n,u)=>"\r"+" ".repeat(u)),new Array(v).fill(0).map((n,u)=>`\r
`+" ".repeat(u)),new Array(v).fill(0).map((n,u)=>`
`+"	".repeat(u)),new Array(v).fill(0).map((n,u)=>"\r"+"	".repeat(u)),new Array(v).fill(0).map((n,u)=>`\r
`+"	".repeat(u));var j;(function(n){n.DEFAULT={allowTrailingComma:!1}})(j||(j={}));function X(n,u=[],b=j.DEFAULT){let e=null,i=[];const T=[];function f(m){Array.isArray(i)?i.push(m):e!==null&&(i[e]=m)}return Y(n,{onObjectBegin:()=>{const m={};f(m),T.push(i),i=m,e=null},onObjectProperty:m=>{e=m},onObjectEnd:()=>{i=T.pop()},onArrayBegin:()=>{const m=[];f(m),T.push(i),i=m,e=null},onArrayEnd:()=>{i=T.pop()},onLiteralValue:f,onError:(m,O,B)=>{u.push({error:m,offset:O,length:B})}},b),i[0]}function Y(n,u,b=j.DEFAULT){const e=M(n,!1),i=[];function T(k){return k?()=>k(e.getTokenOffset(),e.getTokenLength(),e.getTokenStartLine(),e.getTokenStartCharacter()):()=>!0}function f(k){return k?()=>k(e.getTokenOffset(),e.getTokenLength(),e.getTokenStartLine(),e.getTokenStartCharacter(),()=>i.slice()):()=>!0}function A(k){return k?c=>k(c,e.getTokenOffset(),e.getTokenLength(),e.getTokenStartLine(),e.getTokenStartCharacter()):()=>!0}function m(k){return k?c=>k(c,e.getTokenOffset(),e.getTokenLength(),e.getTokenStartLine(),e.getTokenStartCharacter(),()=>i.slice()):()=>!0}const O=f(u.onObjectBegin),B=m(u.onObjectProperty),s=T(u.onObjectEnd),F=f(u.onArrayBegin),E=T(u.onArrayEnd),w=m(u.onLiteralValue),_=A(u.onSeparator),U=T(u.onComment),D=A(u.onError),I=b&&b.disallowComments,l=b&&b.allowTrailingComma;function g(){for(;;){const k=e.scan();switch(e.getTokenError()){case 4:t(14);break;case 5:t(15);break;case 3:t(13);break;case 1:I||t(11);break;case 2:t(12);break;case 6:t(16);break}switch(k){case 12:case 13:I?t(10):U();break;case 16:t(1);break;case 15:case 14:break;default:return k}}}function t(k,c=[],R=[]){if(D(k),c.length+R.length>0){let V=e.getToken();for(;V!==17;){if(c.indexOf(V)!==-1){g();break}else if(R.indexOf(V)!==-1)break;V=g()}}}function o(k){const c=e.getTokenValue();return k?w(c):(B(c),i.push(c)),g(),!0}function p(){switch(e.getToken()){case 11:const k=e.getTokenValue();let c=Number(k);isNaN(c)&&(t(2),c=0),w(c);break;case 7:w(null);break;case 8:w(!0);break;case 9:w(!1);break;default:return!1}return g(),!0}function q(){return e.getToken()!==10?(t(3,[],[2,5]),!1):(o(!1),e.getToken()===6?(_(":"),g(),W()||t(4,[],[2,5])):t(5,[],[2,5]),i.pop(),!0)}function z(){O(),g();let k=!1;for(;e.getToken()!==2&&e.getToken()!==17;){if(e.getToken()===5){if(k||t(4,[],[]),_(","),g(),e.getToken()===2&&l)break}else k&&t(6,[],[]);q()||t(4,[],[2,5]),k=!0}return s(),e.getToken()!==2?t(7,[2],[]):g(),!0}function G(){F(),g();let k=!0,c=!1;for(;e.getToken()!==4&&e.getToken()!==17;){if(e.getToken()===5){if(c||t(4,[],[]),_(","),g(),e.getToken()===4&&l)break}else c&&t(6,[],[]);k?(i.push(0),k=!1):i[i.length-1]++,W()||t(4,[],[4,5]),c=!0}return E(),k||i.pop(),e.getToken()!==4?t(8,[4],[]):g(),!0}function W(){switch(e.getToken()){case 3:return G();case 1:return z();case 10:return o(!0);default:return p()}}return g(),e.getToken()===17?b.allowEmptyContent?!0:(t(4,[],[]),!1):W()?(e.getToken()!==17&&t(9,[],[]),!0):(t(4,[],[]),!1)}var y;(function(n){n[n.None=0]="None",n[n.UnexpectedEndOfComment=1]="UnexpectedEndOfComment",n[n.UnexpectedEndOfString=2]="UnexpectedEndOfString",n[n.UnexpectedEndOfNumber=3]="UnexpectedEndOfNumber",n[n.InvalidUnicode=4]="InvalidUnicode",n[n.InvalidEscapeCharacter=5]="InvalidEscapeCharacter",n[n.InvalidCharacter=6]="InvalidCharacter"})(y||(y={}));var H;(function(n){n[n.OpenBraceToken=1]="OpenBraceToken",n[n.CloseBraceToken=2]="CloseBraceToken",n[n.OpenBracketToken=3]="OpenBracketToken",n[n.CloseBracketToken=4]="CloseBracketToken",n[n.CommaToken=5]="CommaToken",n[n.ColonToken=6]="ColonToken",n[n.NullKeyword=7]="NullKeyword",n[n.TrueKeyword=8]="TrueKeyword",n[n.FalseKeyword=9]="FalseKeyword",n[n.StringLiteral=10]="StringLiteral",n[n.NumericLiteral=11]="NumericLiteral",n[n.LineCommentTrivia=12]="LineCommentTrivia",n[n.BlockCommentTrivia=13]="BlockCommentTrivia",n[n.LineBreakTrivia=14]="LineBreakTrivia",n[n.Trivia=15]="Trivia",n[n.Unknown=16]="Unknown",n[n.EOF=17]="EOF"})(H||(H={}));const Z=X;var J;(function(n){n[n.InvalidSymbol=1]="InvalidSymbol",n[n.InvalidNumberFormat=2]="InvalidNumberFormat",n[n.PropertyNameExpected=3]="PropertyNameExpected",n[n.ValueExpected=4]="ValueExpected",n[n.ColonExpected=5]="ColonExpected",n[n.CommaExpected=6]="CommaExpected",n[n.CloseBraceExpected=7]="CloseBraceExpected",n[n.CloseBracketExpected=8]="CloseBracketExpected",n[n.EndOfFileExpected=9]="EndOfFileExpected",n[n.InvalidCommentToken=10]="InvalidCommentToken",n[n.UnexpectedEndOfComment=11]="UnexpectedEndOfComment",n[n.UnexpectedEndOfString=12]="UnexpectedEndOfString",n[n.UnexpectedEndOfNumber=13]="UnexpectedEndOfNumber",n[n.InvalidUnicode=14]="InvalidUnicode",n[n.InvalidEscapeCharacter=15]="InvalidEscapeCharacter",n[n.InvalidCharacter=16]="InvalidCharacter"})(J||(J={}));function $(n,u){return Z(n,u?.errors,u)}export{$ as parseJSONC};
