import { P as Parser, j as LezerLanguage, e as indentNodeProp, f as continuedIndent, h as foldNodeProp, q as foldInside, b as styleTags, t as tags, n as LanguageSupport } from './index-8d03edaf.js';

const parser=Parser.deserialize({version:13,states:"$bOVQPOOOOQO'#Cb'#CbOnQPO'#CcOvQPO'#CfOOQO'#Cl'#ClQOQPOOOOQO'#Ce'#CeO}QPO'#CdO!SQPO'#CpOOQO,58},58}O![QPO,58}O!aQPO'#CuOOQO,59Q,59QO!iQPO,59QOVQPO,59OO!nQPO'#CgO!sQPO,59[OOQO1G.i1G.iOVQPO'#ChO!{QPO,59aOOQO1G.l1G.lOOQO1G.j1G.jOOQO,59R,59ROOQO-E6e-E6eOOQO,59S,59SOOQO-E6f-E6f",stateData:"#T~O_OS~OQSORSOSSOTSOaPOcQOhRO~OaUObXO~Og[O~PVOe^O~Of_ObdX~ObaO~OfbOgiX~OgdO~OaUO~Of_Obda~OfbOgia~O",goto:"!kjPPPPPPkkqwk{!RPPP!XPPP!ePPPP!hXSOR^bQWQRf_TVQ_Q`WRg`QcZRicQTOQZRQe^RhbRYQR]R",nodeNames:"⚠ JsonText True False Null Number String Object Property PropertyName Array",maxTerm:25,skippedNodes:[0],repeatNodeCount:2,tokenData:"(p~RaXY!WYZ!W]^!Wpq!Wrs!]|}$i}!O$n!Q!R$w!R![&V![!]&h!}#O&m#P#Q&r#Y#Z&w#b#c'f#h#i'}#o#p(f#q#r(k~!]O_~~!`Upq!]qr!]rs!rs#O!]#O#P!w#P~!]~!wOa~~!zXrs!]!P!Q!]#O#P!]#U#V!]#Y#Z!]#b#c!]#f#g!]#h#i!]#i#j#g~#jR!Q![#s!c!i#s#T#Z#s~#vR!Q![$P!c!i$P#T#Z$P~$SR!Q![$]!c!i$]#T#Z$]~$`R!Q![!]!c!i!]#T#Z!]~$nOf~~$qQ!Q!R$w!R![&V~$|RT~!O!P%V!g!h%k#X#Y%k~%YP!Q![%]~%bRT~!Q![%]!g!h%k#X#Y%k~%nR{|%w}!O%w!Q![%}~%zP!Q![%}~&SPT~!Q![%}~&[ST~!O!P%V!Q![&V!g!h%k#X#Y%k~&mOe~~&rOh~~&wOg~~&zP#T#U&}~'QP#`#a'T~'WP#g#h'Z~'^P#X#Y'a~'fOR~~'iP#i#j'l~'oP#`#a'r~'uP#`#a'x~'}OS~~(QP#f#g(T~(WP#i#j(Z~(^P#X#Y(a~(fOQ~~(kOc~~(pOb~",tokenizers:[0],topRules:{JsonText:[0,1]},tokenPrec:0});

const jsonParseLinter=()=>e=>{try{JSON.parse(e.state.doc.toString());}catch(r){if(!(r instanceof SyntaxError))throw r;const t=getErrorPosition(r,e.state.doc);return [{from:t,message:r.message,severity:"error",to:t}]}return []};function getErrorPosition(e,r){let t;return (t=e.message.match(/at position (\d+)/))?Math.min(+t[1],r.length):(t=e.message.match(/at line (\d+) column (\d+)/))?Math.min(r.line(+t[1]).from+ +t[2]-1,r.length):0}const jsonLanguage=LezerLanguage.define({parser:parser.configure({props:[indentNodeProp.add({Object:continuedIndent({except:/^\s*\}/}),Array:continuedIndent({except:/^\s*\]/})}),foldNodeProp.add({"Object Array":foldInside}),styleTags({String:tags.string,Number:tags.number,"True False":tags.bool,PropertyName:tags.propertyName,null:tags.null,",":tags.separator,"[ ]":tags.squareBracket,"{ }":tags.brace})]}),languageData:{closeBrackets:{brackets:["[","{",'"']},indentOnInput:/^\s*[\}\]]$/}});function json(){return new LanguageSupport(jsonLanguage)}

export { json, jsonLanguage, jsonParseLinter };
