'use strict';

var index = require('./index-85258e9e.js');

// This file was generated by lezer-generator. You probably shouldn't edit it.
const parser = index.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
});

/// Calls
/// [`JSON.parse`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/JSON/parse)
/// on the document and, if that throws an error, reports it as a
/// single diagnostic.
const jsonParseLinter = () => (view) => {
    try {
        JSON.parse(view.state.doc.toString());
    }
    catch (e) {
        if (!(e instanceof SyntaxError))
            throw e;
        const pos = getErrorPosition(e, view.state.doc);
        return [{
                from: pos,
                message: e.message,
                severity: 'error',
                to: pos
            }];
    }
    return [];
};
function getErrorPosition(error, doc) {
    let m;
    if (m = error.message.match(/at position (\d+)/))
        return Math.min(+m[1], doc.length);
    if (m = error.message.match(/at line (\d+) column (\d+)/))
        return Math.min(doc.line(+m[1]).from + (+m[2]) - 1, doc.length);
    return 0;
}

/// A language provider that provides JSON parsing.
const jsonLanguage = index.LezerLanguage.define({
    parser: parser.configure({
        props: [
            index.indentNodeProp.add({
                Object: index.continuedIndent({ except: /^\s*\}/ }),
                Array: index.continuedIndent({ except: /^\s*\]/ })
            }),
            index.foldNodeProp.add({
                "Object Array": index.foldInside
            }),
            index.styleTags({
                String: index.tags.string,
                Number: index.tags.number,
                "True False": index.tags.bool,
                PropertyName: index.tags.propertyName,
                null: index.tags.null,
                ",": index.tags.separator,
                "[ ]": index.tags.squareBracket,
                "{ }": index.tags.brace
            })
        ]
    }),
    languageData: {
        closeBrackets: { brackets: ["[", "{", '"'] },
        indentOnInput: /^\s*[\}\]]$/
    }
});
/// JSON language support.
function json() {
    return new index.LanguageSupport(jsonLanguage);
}

exports.json = json;
exports.jsonLanguage = jsonLanguage;
exports.jsonParseLinter = jsonParseLinter;
